[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:code:bwp

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Fri Jan 19 09:32:55 CST 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/01/19 09:32
User        : ryo
Edit Summary: more

@@ -32,32 +32,37 @@
      * I see what you're saying, but I was calling it that way in my ''qsort'' of ''archnames'', and that was working ok.  ''archames'' is an array of arrays, though, while ''array->item'' is a pointer to an array of pointers, so I ssupose that's the difference.  In any case, I think I have everything else working, so I've updated the code below.  ''sortbyname'' now no longer causes segfaults, but it still isn't sorting correctly either.  To be exact, it sorts ''archnames'' correctly, but not ''array->item''.  When I try <code>*(const char* *)a</code>, it segfaults, and when I inspect the variables with gdb, it says that's accessing a bad address.  At this point, I'm really stumped on this part, but I'm still looking for other examples.
  
        * can you try with ''qsort(&array->item, ...)'' and the ''const char * ''? Not sure that's the issue, but well... Also a few hints:
            * It seems like I've tried every possible combination at this point -- passing ''array->item'' to ''qsort'' by itself and with & and * ; casting the arguments inside ''sortbyname'' in various ways.  The combination I'm doing now doesn't complain about anything and doesn't mangle any memory, but it doesn't sort it either.
+             * well, when i get time i'll look at that :)
  
          * do ''canuse.count = 0;'' before using ''push''. Count isn't initialized, so weird effects can happen
            * I do, a few lines up.
+             * didn't see that, my mistake
          * ''free(NULL)'' is perfectly correct in ANSI, i don't know what your debugger/compiler is complainign about :)
            * Not the compiler, but running the program spit out a bunch of ''"in free(): warning: junk pointer, too high to make sense"'' warnings.  I assumed that assigning "" to a ''char*'' would give it a valid pointer; obviously I was wrong.  But I didn't want to initialize those ''_row'' pointers to ''NULL'' either, because I'd be passing them as values to ''do_template'' later.  Initializing them with ''strdup_local'' did the trick.
+             * if free() says such a warning, it may mean other issues somewhere :) note that once you called ''do_template'' you ca, safely ''free()'' the values you used - since the function does a strcpy. In the current version, ''canuse_row'' and friends should be set to ''strdup_local("")'', since you ''free'' them (i think you did that, but i'm not sure based on your sentence, so... ;p)
  
          * instead of ''calloc(1, strlen(string)+1) / strncpy'', use ''strdup(string)'' in ''push'' (that's what this is for ^_-) - Crossfire may have a ''strdup_local'' somewhere, better use that if it exists
            * It does; using that now.
          * doing ''char *newtext = "";'' is not required, and may be dangerous since you do ''realloc'' after (but of course you do ''calloc'', so the initialization won't do anything anyway ;p)
            * Good point.  I think that was an attempt to fix a problem that went away.
          * for duplicated names, check if the monster isn't yet part of the array before inserting it
            * Maybe the ideal would be to spit out a warning on duplicate names, but skip the duplicates in the actual output.  Those duplicates are actually separate archetypes; often from separate arch files; check ''monster/humanoid/Dragon/green_dragon?'' for example.  Two identical archetypes except for their faces, so perhaps one should be deleted, or turned into "fiery green dragon" or something (so as not to waste the images).
+             * those specific pisc are for player images - i'd check to make sure there isn't some magic at work before removing them :)
  
          * it may be better to use ''archt* archetypes[4000]'' instead of ''char archnames[4000][MAX_SIZE];''. It would let you sort by name, then plural name, then archetype name in case of duplicated monsters, and also enable you to check for head/more
            * Nice idea; I should have thought of that.  Of course, I might end up having trouble sorting that too. ;-)  Should be examples of that in the code to copy, though.
          * similarly, you may want to avoid inserting archetypes which are ''more'' of another one - thus check ''more != NULL'' somewhere
            * I don't think that's a problem.  The ''first_archetype'' list built by ''init_archetypes()'' seems to only contain whole archetypes, not parts.  Unless I'm misunderstanding your meaning; for example?
+             * hum, you may be right, archetypes probably only contain the HEAD part.
  
          * all in all, seems it'll work fine soon :)
            * We'll see.  I won't make the mistake of claiming to be down to one bug again. ;-)  I'll finish making the change to use ''archt*'' and some other improvements before I bother updating the code here.
  
          * if you wanted to be really really flexible, you could use templates for flags themselves - instead of concatenating items with a comma, let a template (or a few, in this case) decide how to adjust stuff. This may be overkill, though, of course ^_-
            * I thought about that, but I wasn't sure how to do a template where an item could be repeated a variable number of times.  I also intend to insert wiki-style line breaks every N characters in long lines of text, like my perl version does, but that was one line of code there.  It'll take a bit more here. ;-)
- 
+             * well, what i did for the mapper was just: for each eg flag generate the template for this flag, and concatenate with previously generated text (thus my ''cat_template'' which i use specially for that ^_-). Then you use the resulting value in another template, and so on.
  
  
    * Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
      * That would be much easier, wouldn't it? :-)


IP-Address  : 196.3.55.241
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp?rev=1169217133
New Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list