081004 Quixadhal 2031 Started this HACKLOG file! Removed the multiple Makefiles and merged their diffrences into a single Makefile. The user can simply comment and uncomment the correct lines for their platform. Removed the "make" rule from "make clean", since many times we just want to get rid of the object files and not rebuild. Replaced the old .c.o suffix rule with a modern one, and removed the generic "merc.h" prerequisite. Instead, I've had gcc generate dependancy information and appended that to the Makefile. This could be automated, but for simplicity I won't do so. 2107 Changed the function name weapon_type() to be weapon_type_lookup(). merc.h:2194: warning: 'int weapon_type(const char*)' hides constructor for 'struct weapon_type' Fixed a variable scope issue in act_obj.c. act_obj.c: In function 'void do_buy(CHAR_DATA*, char*)': act_obj.c:2518: warning: declaration of 'buf' shadows a previous local act_obj.c:2506: warning: shadowed declaration is here Same thing here. act_wiz.c: In function 'void do_mset(CHAR_DATA*, char*)': act_wiz.c:3466: warning: declaration of 'buf' shadows a previous local act_wiz.c:3329: warning: shadowed declaration is here This is a local re-declarations of a global variable. comm.c: In function 'void bust_a_prompt(CHAR_DATA*)': comm.c:1328: warning: declaration of 'dir_name' shadows a global declaration merc.h:1904: warning: shadowed declaration is here In this case, I think the correct answer is to move the local declaration up to act_move.c, and rename it to be dir_abbrev[], since it really needs to always stay in sync with dir_name[]. And this is just another shadowed global. comm.c: In function 'void nanny(DESCRIPTOR_DATA*, char*)': comm.c:1546: warning: declaration of 'd_next' shadows a global declaration comm.c:301: warning: shadowed declaration is here Let's try commenting out the global and see if it's really used anywhere. Hmmmm, mostly just as a local loop variable, only one place seems to want it global, and that doesn't appear to have any effect. /* if ( d_next == dclose ) d_next = d_next->next; */ That keeps d_next set, but it isn't ever used anywhere else. 2133 Another shadow... db.c: In function 'void load_old_obj(FILE*)': db.c:655: warning: declaration of 'letter' shadows a previous local db.c:595: warning: shadowed declaration is here A quick change to is_name() to make it also const char *, and this is fine. db.c: In function 'char* get_extra_descr(const char*, EXTRA_DESCR_DATA*)': db.c:2055: warning: cast from type 'const char*' to type 'char*' casts away constness This one is a bit ugly. str_dup() accepts a const char *, but returns a char *. Normally, not a big deal, but because of the shared string space, it wants to return the source pointer sometimes. THAT now has to be declared without the const, because we won't know ahead of time if it IS const or not. db.c: In function 'char* str_dup(const char*)': db.c:2693: warning: cast from type 'const char*' to type 'char*' casts away constness Another local shadow... db2.c: In function 'void load_objects(FILE*)': db2.c:458: warning: declaration of 'letter' shadows a previous local db2.c:354: warning: shadowed declaration is here 2159 Meeeeee, and my shaaaaadow! You'd think -Wshadow would be part of -Wall by now.... *sigh* fight.c: In function 'void one_hit(CHAR_DATA*, CHAR_DATA*, int)': fight.c:587: warning: declaration of 'dam' shadows a previous local fight.c:392: warning: shadowed declaration is here fight.c: In function 'void check_killer(CHAR_DATA*, CHAR_DATA*)': fight.c:1218: warning: declaration of 'buf' shadows a previous local fight.c:1194: warning: shadowed declaration is here Wheeeee! handler.c is unhappy! handler.c: In function 'bool is_name(const char*, char*)': handler.c:822: error: invalid conversion from 'const char*' to 'char*' handler.c:826: error: invalid conversion from 'const char*' to 'char*' handler.c:826: error: initializing argument 1 of 'char* one_argument(char*, char*)' cc1plus: warnings being treated as errors handler.c: In function 'char* affect_bit_name(int)': handler.c:2614: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* extra_bit_name(int)': handler.c:2622: warning: declaration of 'extra_flags' shadows a global declaration tables.h:74: warning: shadowed declaration is here handler.c:2648: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* act_bit_name(int)': handler.c:2652: warning: declaration of 'act_flags' shadows a global declaration tables.h:66: warning: shadowed declaration is here handler.c:2698: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* comm_bit_name(int)': handler.c:2701: warning: declaration of 'comm_flags' shadows a global declaration tables.h:73: warning: shadowed declaration is here handler.c:2725: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* imm_bit_name(int)': handler.c:2728: warning: declaration of 'imm_flags' shadows a global declaration tables.h:70: warning: shadowed declaration is here handler.c:2757: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* wear_bit_name(int)': handler.c:2760: warning: declaration of 'wear_flags' shadows a global declaration tables.h:75: warning: shadowed declaration is here handler.c:2783: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* form_bit_name(int)': handler.c:2786: warning: declaration of 'form_flags' shadows a global declaration tables.h:71: warning: shadowed declaration is here handler.c:2818: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* part_bit_name(int)': handler.c:2821: warning: declaration of 'part_flags' shadows a global declaration tables.h:72: warning: shadowed declaration is here handler.c:2848: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* weapon_bit_name(int)': handler.c:2851: warning: declaration of 'weapon_flags' shadows a global declaration tables.h:76: warning: shadowed declaration is here handler.c:2865: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* cont_bit_name(int)': handler.c:2879: warning: cast from type 'const char*' to type 'char*' casts away constness handler.c: In function 'char* off_bit_name(int)': handler.c:2883: warning: declaration of 'off_flags' shadows a global declaration tables.h:69: warning: shadowed declaration is here handler.c:2911: warning: cast from type 'const char*' to type 'char*' casts away constness These were all fixed by redoing the return values so it always returns the buffer, but copies "none" into it where there were no flags. Also, renamed all the local variables to "vector", since it made sense and eliminated the conflicts. 2312 Undid the change to is_name(), and also removed the const modifier from get_extra_descr(). Adding proper const flags will need some more carful work. save.c: In function 'void fread_char(CHAR_DATA*, FILE*)': save.c:743: warning: cast from type 'const char*' to type 'char*' casts away constness save.c: In function 'void fread_pet(CHAR_DATA*, FILE*)': save.c:1140: warning: cast from type 'const char*' to type 'char*' casts away constness save.c:1162: warning: cast from type 'const char*' to type 'char*' casts away constness save.c: In function 'void fread_obj(CHAR_DATA*, FILE*)': save.c:1364: warning: cast from type 'const char*' to type 'char*' casts away constness save.c:1400: warning: cast from type 'const char*' to type 'char*' casts away constness Fixed those by adding a static char buffer which is set to "End" or "END" and returned instead of a constant string. 081006 MacGregor/Nibios Taking Quixadhal's fixup_081004 src and adapting to compile with g++ 3.4.6. First pass: compile dies with these errors and fixes: comm.c: In function `void act_new(const char*, CHAR_DATA*, const void*, const void*, int, int)': comm.c:2443: warning: cast from `const void*' to `CHAR_DATA*' discards qualifiers from pointer target type comm.c:2444: warning: cast from `const void*' to `OBJ_DATA*' discards qualifiers from pointer target type comm.c:2445: warning: cast from `const void*' to `OBJ_DATA*' discards qualifiers from pointer target type comm.c:2512: warning: cast from `const void*' to `char*' discards qualifiers from pointer target type comm.c:2513: warning: cast from `const void*' to `char*' discards qualifiers from pointer target type comm.c:2536: warning: cast from `const void*' to `char*' discards qualifiers from pointer target type comm.c:2542: warning: cast from `const void*' to `char*' discards qualifiers from pointer target type The offending lines: 2443: CHAR_DATA *vch = (CHAR_DATA *) arg2; 2444: OBJ_DATA *obj1 = (OBJ_DATA *) arg1; 2445: OBJ_DATA *obj2 = (OBJ_DATA *) arg2; 2512: case 't': i = (char *) arg1; break; 2513: case 'T': i = (char *) arg2; break; 2536: if ( arg2 == NULL || ((char *) arg2)[0] == '\0' ) 2542: one_argument( (char *) arg2, fname ); The first six were pretty straightforward to fix, changing them respectively to: 2443: const CHAR_DATA *vch = (const CHAR_DATA *) arg2; 2444: const OBJ_DATA *obj1 = (const OBJ_DATA *) arg1; 2445: const OBJ_DATA *obj2 = (const OBJ_DATA *) arg2; 2512: case 't': i = (const char *) arg1; break; 2513: case 'T': i = (const char *) arg2; break; 2536: if ( arg2 == NULL || ((const char *) arg2)[0] == '\0' ) We'll defer fixing line 2542 for now, and just recompile with what we have. We now get: comm.c: In function `void act_new(const char*, CHAR_DATA*, const void*, const void*, int, int)': comm.c:2515: error: invalid conversion from `const CHAR_DATA*' to `CHAR_DATA*' comm.c:2515: error: initializing argument 2 of `bool can_see(CHAR_DATA*, CHAR_DATA*)' comm.c:2524: error: invalid conversion from `const OBJ_DATA*' to `OBJ_DATA*' comm.c:2524: error: initializing argument 2 of `bool can_see_obj(CHAR_DATA*, OBJ_DATA*)' comm.c:2530: error: invalid conversion from `const OBJ_DATA*' to `OBJ_DATA*' comm.c:2530: error: initializing argument 2 of `bool can_see_obj(CHAR_DATA*, OBJ_DATA*)' comm.c:2542: warning: cast from `const void*' to `char*' discards qualifiers from pointer target type The offending lines: 2515: case 'N': i = PERS( vch, to ); break; 2524: i = can_see_obj( to, obj1 ) 2530: i = can_see_obj( to, obj2 ) 2542: one_argument( (char *) arg2, fname ); The PERS macro takes us to the can_see() function in handler.c. We change it from bool can_see( CHAR_DATA *ch, CHAR_DATA *victim ) to bool can_see( const CHAR_DATA *ch, const CHAR_DATA *victim ) This in turn requires changing get_trust(), get_skill() and get_curr_stat() all to take const CHAR_DATA * arguments instead of CHAR_DATA *. Fixing can_see_obj() is a bit more straightforward since we only have to change its own arguments to const CHAR_DATA * and const OBJ_DATA *. So now the only problem left is line 2542 and its call to one_argument(). Changing one_argument() to take a const char * as its first argument, and returning a const char *, is going to open up a huge can of worms. The Right Thing To Do at this point would be to make the function take a const char * for its first argument, and return a const char *. This would mean, among other things, that every do_fun would have to take a const char * for their second argument. However this would definitely break about 95% of the existing ROM snippets, and we'd agreed we didn't want to do that. Furthermore, it already compiles just fine with gcc 4.1.x. So pretty much against my better judgement, I copied one_argument() to a new function get_argument(), with get_argument() taking and returning const char *'s, and changed line 2542 to call the new get_argument() function. Okay, it compiles cleanly now! Let's try compiling as gcc instead of g++. Whoops! act_comm.c blows up big time, referencing incomplete data types. The problem is that g++ has its own bool data type and gcc doesn't. So we add a couple lines in merc.h like so: /* * Accomodate both gcc and g++ */ #if !defined __cplusplus typedef unsigned char bool; #endif g++ is still happy, and so is gcc until it gets to act_wiz.c: act_wiz.c: In function `do_clone': act_wiz.c:2386: warning: declaration of 'new_obj' shadows a global declaration recycle.h:81: warning: shadowed declaration is here Hmm, wonder why this didn't show up earlier? Seems to me it should have. Anyway, change the local variable new_obj to cloned_obj and continue. Uh oh, comm.c blows up again, this time over those declarations of system calls at the top of comm.c. Let's extend the comment around the declarations for accept, bind et al to include the declarations for read, select, etc too. I think it would be safe to just remove them but I'll do it conservatively. Okay, another shadow problem in db.c, the variable 'exit' in the function do_dump(). Let's change it to pExit. Now we're getting, of all things, this error: handler.c: In function `unequip_char': handler.c:1646: warning: suggest explicit braces to avoid ambiguous `else' We add curley braces around the for loop inside the 'if', and also around the for-loop itself. Either set resolves the problem, but good practice requires both. Now, finally, it compiles with both g++ and gcc. 081006 Quixadhal Merged in MacGregor's HACKLOG entries Added the -Wredundant-declarations flag and fixed a few more warnings. These are typically redefinitions of system routines that are already defined by system include files, and should NOT be done locally. Added defines for true/false if we're not C++ 081006 Quixadhal 2255 Trying to compile with g++ 2.95 now....wheeee! act_info.c: In function `void do_password(CHAR_DATA *, char *)': act_info.c:2726: implicit declaration of function `int crypt(...)' act_info.c:2726: passing `int' to argument 1 of `strcmp(const char *, const char *)' lacks a cast act_info.c:2743: assignment to `char *' from `int' lacks a cast Ok, this is because the man page for crypt() LIES! Yes, that's right.... according to man(3), crypt() is defined in unistd.h, but it's actually split off into crypt.h (at least on linux systems). So, I've included <crypt.h> in act_info.c and comm.c. handler.c: In function `char * item_name(int)': handler.c:188: warning: declaration of `item_type' shadows global declaration handler.c: In function `char * weapon_name(int)': handler.c:198: warning: declaration of `weapon_type' shadows global declaration *chocking noises come from the console...* Ok, newer gcc's don't complain here, because they distinguish between functions, type definitions, and variables. However, I think (a) having any of those with the same name is asking for trouble (unless it's a constructor), and (b) having a a variable named "type" is as bad as one named "class". Lines like item_type == item_table[type].type make my eyes bleed. In file included from save.c:38: /usr/include/stdlib.h:584: warning: redundant redeclaration of `malloc(unsigned int)' in same scope /usr/include/malloc.h:118: warning: previous declaration of `malloc(unsigned int)' /usr/include/stdlib.h:587: warning: redundant redeclaration of `calloc(unsigned int, unsigned int)' in same scope /usr/include/malloc.h:122: warning: previous declaration of `calloc(unsigned int, unsigned int)' /usr/include/stdlib.h:595: warning: redundant redeclaration of `realloc(void *, unsigned int)' in same scope /usr/include/malloc.h:128: warning: previous declaration of `realloc(void *, unsigned int)' /usr/include/stdlib.h:597: warning: redundant redeclaration of `free(void *)' in same scope /usr/include/malloc.h:131: warning: previous declaration of `free(void *)' /usr/include/stdlib.h:602: warning: redundant redeclaration of `cfree(void *)' in same scope /usr/include/malloc.h:134: warning: previous declaration of `cfree(void *)' In file included from save.c:38: /usr/include/stdlib.h:611: warning: redundant redeclaration of `valloc(unsigned int)' in same scope /usr/include/malloc.h:140: warning: previous declaration of `valloc(unsigned int)' Hmmmm, ok. I'm guessing 2.95 was more picky about the order of include files. Commenting out malloc.h should do the trick! Interesting! Switching from g++-2.95 to gcc-2.95 reveals a few new errors too! act_info.c: In function `do_exits': act_info.c:1324: warning: redundant redeclaration of `dir_name' in same scope merc.h:1916: warning: previous declaration of `dir_name' Several more too.... apparently, the merc folks added extern declarations inside their function bodies... and when the functions got moved around, they shadowed the actual declarations since they now shared the same file. 081007 Quixahdal 1024 Oops! I have no idea where my datestamps came from. I called the last directory 081008, when it had only just become the 7th. So, today's is called 081009 and is also a day in the future! I figure I'll not do stuff in a day or two, and real time will catch up. :) In any case, this patch is the big const char * fix for gcc 4.2 and up! I'm actually using g++ 4.3.2 in a VM, so we're right up there in the modern era. A LOT of casting. A few cases where I had to use local copies so things like smash_tilde() could write to the string. One very nasty trick in str_dup(), which shouldn't work, but does. I won't bother pasting all the errors here, there are way too many of them. I also added a few flags that MacGregor asked for, although some of them are only available when using the C language. I enabled -Wwrite-strings, which is what gcc 4.2 adds to -Wall, so even older compilers should now be grumpy if we miss something. I disabled -Wmissing-delcarations by default, because most folks won't have gcc 4.2.x or higher yet. 081008 Quixadhal 1244 It should be noted that this revision marks the last that was done outside of version control. I've set up a local SVN repository and will happily export it in the event of our using one hosted in a central location. Otherwise, I'll create patches from svn's diff system. 1356 I've added ID tags to the top of every source file. These will get filled in by svn with the last time that file was changed and commited, as well as revision numbers, etc. 2115 Removed all the OS specific things. I started out stripping the MSDOS and macintosh code. Once that was done, the majority of all the other OS defines were workarounds for supposedly missing system header definitions. I've never seen a C compiler for ANY platform (even the Commodore 64!) where a function existed in the system library, but didn't have a header defintion somewhere. For historical archiving, I removed: MSDOS, macintosh, _AIX, apollo, hpux, MIPS_OS, NeXT, sequent, sun, ultrix, and interactive Things that used to be linux or unix are now simply there. I will make a small effort to see if anything special needs to be done for FreeBSD (which should also cover OS X), but anything else has an audience which should know what they need to do to handle portability issues. 081009 Quixadhal 0545 ACK! I didn't realize that you had to ENABLE token substitution on every file you want svn to perform substitution on. Ok... New patch just to enable the "Id" keyword on every source file. On the upside, it is kindof nice that it doesn't have to check all the data files for substitution values on every checkout. 0621 Removed all references to fpReserve. This is from the old days when the number of file descriptors was very limited, and it was fairly common to be unable to open a file because you had too many sockets active. I can't imagine this is still an issue, even if you have 500 players. Out it goes!