006-007.diff.bz2

patches · 3.4 KB · 2010-03-30

Download   « Back to the patches list

diff -buraP 006/HACKLOG 007/HACKLOG
--- 006/HACKLOG	2008-10-08 12:32:02.000000000 -0400
+++ 007/HACKLOG	2008-10-08 12:40:28.000000000 -0400
@@ -175,3 +175,127 @@
 	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++
+
Only in 006: HACKLOG_1
diff -buraP 006/src/Makefile 007/src/Makefile
--- 006/src/Makefile	2008-10-08 12:32:02.000000000 -0400
+++ 007/src/Makefile	2008-10-08 12:40:28.000000000 -0400
@@ -2,7 +2,7 @@
 
 W_FORMAT        = -Wformat -Wformat-security -Wmissing-format-attribute
 W_NITPICK       = -Wpointer-arith -Winline
-W_MESSY         = -Wmissing-braces -Wparentheses -Wshadow #-Wredundant-decls
+W_MESSY         = -Wmissing-braces -Wparentheses -Wshadow -Wredundant-decls
 W_TYPE          = -Wcast-qual -Wcast-align -Wchar-subscripts -Wreturn-type -Wswitch #-Wwrite-strings
 W_EXTRA         = -Wunused #-Wunreachable-code
 W_ANSI          = #-pedantic
diff -buraP 006/src/act_comm.c 007/src/act_comm.c
--- 006/src/act_comm.c	2008-10-08 12:14:23.000000000 -0400
+++ 007/src/act_comm.c	2008-10-08 12:40:28.000000000 -0400
@@ -41,7 +41,7 @@
 #include "recycle.h"
 #include "tables.h"
 
-int unlink(const char *pathname);
+/* int unlink(const char *pathname); */
 
 /* RT code to delete yourself */
 
diff -buraP 006/src/ban.c 007/src/ban.c
--- 006/src/ban.c	2008-10-08 12:14:23.000000000 -0400
+++ 007/src/ban.c	2008-10-08 12:40:28.000000000 -0400
@@ -39,7 +39,7 @@
 #include "merc.h"
 #include "recycle.h"
 
-int unlink(const char *pathname);
+/* int unlink(const char *pathname); */
 BAN_DATA *ban_list;
 
 void save_bans(void)
diff -buraP 006/src/db.c 007/src/db.c
--- 006/src/db.c	2008-10-08 12:33:39.000000000 -0400
+++ 007/src/db.c	2008-10-08 12:40:28.000000000 -0400
@@ -54,9 +54,9 @@
 #if !defined(linux)
 long random();
 #endif
-void srandom(unsigned int);
-int getpid();
-time_t time(time_t *tloc);
+/* void srandom(unsigned int); */
+/* int getpid(); */
+/* time_t time(time_t *tloc); */
 #endif
 
 
diff -buraP 006/src/fight.c 007/src/fight.c
--- 006/src/fight.c	2008-10-08 12:32:02.000000000 -0400
+++ 007/src/fight.c	2008-10-08 12:40:28.000000000 -0400
@@ -41,7 +41,7 @@
  */
 void	check_assist	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
 bool	check_dodge	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
-void	check_killer	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
+/* void	check_killer	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) ); */
 bool	check_parry	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
 bool    check_shield_block     args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
 void    dam_message 	args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dam,
@@ -50,7 +50,7 @@
 void	group_gain	args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
 int	xp_compute	args( ( CHAR_DATA *gch, CHAR_DATA *victim, 
 			    int total_levels ) );
-bool	is_safe		args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
+/* bool	is_safe		args( ( CHAR_DATA *ch, CHAR_DATA *victim ) ); */
 void	make_corpse	args( ( CHAR_DATA *ch ) );
 void	one_hit		args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
 void    mob_hit		args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
diff -buraP 006/src/merc.h 007/src/merc.h
--- 006/src/merc.h	2008-10-08 12:33:39.000000000 -0400
+++ 007/src/merc.h	2008-10-08 12:40:28.000000000 -0400
@@ -72,6 +72,12 @@
  */
 #if !defined __cplusplus
 typedef unsigned char	bool;
+#if !defined true
+#define true	TRUE
+#endif
+#if !defined false
+#define false	FALSE
+#endif
 #endif
 
 
@@ -1953,7 +1959,7 @@
 #endif
 
 #if	defined(linux)
-char *	crypt		args( ( const char *key, const char *salt ) );
+/* char *	crypt		args( ( const char *key, const char *salt ) ); */
 #endif
 
 #if	defined(macintosh)
diff -buraP 006/src/save.c 007/src/save.c
--- 006/src/save.c	2008-10-08 12:32:02.000000000 -0400
+++ 007/src/save.c	2008-10-08 12:40:28.000000000 -0400
@@ -45,9 +45,9 @@
 extern  int     _filbuf         args( (FILE *) );
 #endif
 
-int system(const char *command);
+/* int system(const char *command); */
 
-int rename(const char *oldfname, const char *newfname);
+/* int rename(const char *oldfname, const char *newfname); */
 
 char *print_flags(int flag)
 {

Site Stats

Snippets: 1791
Codebases: 571