[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 12:24:38 CST 2007
A page in your DokuWiki was added or changed. Here are the details:
Date : 2007/01/19 12:24
User : mhoram
Edit Summary: This may be it until next week....
@@ -40,16 +40,19 @@
* 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)
+ * Yes, that's what I meant. I now initialize them with ''strdup_lcoal("")'', and am able to scrap my ''free_if_used'' routine.
* 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 :)
+ * Absoultely. Looking at another duplicate made me aware of a bug in my code, by the way. There are three archetypes with the ''name'' "castle guard": light_guard, medium_guard, and guard. Because of the way my code makes an array of the names and then uses ''find_object_by_archetype_name'' to select each one for printing, it ends up selecting whichever one comes first in the list three times. Oops. Following your suggestion about using an array of archt* types to hold them should clear up that confusion.
+
* 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
@@ -61,9 +64,9 @@
* 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.
-
+ * I understand that part, but I'm not sure how to design a template that allows for a variable number of attacktypes, for example, without having the program concat them and plug them in for a single flag. Maybe I'll come up with something eventually.
* Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
* That would be much easier, wouldn't it? :-)
IP-Address : 206.71.197.56
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp?rev=1169220771
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