浏览代码

- Moved "#include <limits.h>" to cbasetypes.h to ensure it's included before checking if UINT_MAX has been defined.
- Minor changes in pc_readdb related to max_level being unsigned.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9561 54d463be-8e91-2dee-dedb-b68131a5f0ec

FlavioJS 18 年之前
父节点
当前提交
52245f90b9

+ 5 - 0
Changelog-Trunk.txt

@@ -3,6 +3,11 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
+2006/12/23
+	* Moved "#include <limits.h>" to cbasetypes.h to ensure it's included 
+	  before checking if UINT_MAX has been defined.
+	* Minor changes in pc_readdb related to max_level being unsigned.
+	[FlavioJS]
 2006/12/22
 2006/12/22
 	* Simplified function agitcheck so it isn't crash prone. Now it takes no
 	* Simplified function agitcheck so it isn't crash prone. Now it takes no
 	  arguments, and will return whether WoE is on or not.
 	  arguments, and will return whether WoE is on or not.

+ 1 - 1
src/char/char.c

@@ -18,8 +18,8 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/strlib.h"
 #include "../common/strlib.h"
 #include "../common/core.h"
 #include "../common/core.h"
 #include "../common/socket.h"
 #include "../common/socket.h"

+ 1 - 1
src/char/int_guild.c

@@ -4,8 +4,8 @@
 #include <string.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/mmo.h"
 #include "../common/mmo.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/db.h"
 #include "../common/db.h"

+ 1 - 1
src/char/int_party.c

@@ -4,8 +4,8 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/mmo.h"
 #include "../common/mmo.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/db.h"
 #include "../common/db.h"

+ 3 - 2
src/char_sql/char.c

@@ -21,17 +21,18 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
-#include <limits.h>
 
 
-#include "char.h"
+#include "../common/cbasetypes.h"
 #include "../common/utils.h"
 #include "../common/utils.h"
 #include "../common/strlib.h"
 #include "../common/strlib.h"
 #include "../common/showmsg.h"
 #include "../common/showmsg.h"
+
 #include "itemdb.h"
 #include "itemdb.h"
 #include "inter.h"
 #include "inter.h"
 #include "db.h"
 #include "db.h"
 #include "malloc.h"
 #include "malloc.h"
 #include "int_guild.h"
 #include "int_guild.h"
+#include "char.h"
 
 
 #ifndef TXT_SQL_CONVERT
 #ifndef TXT_SQL_CONVERT
 static struct dbt *char_db_;
 static struct dbt *char_db_;

+ 2 - 2
src/char_sql/int_guild.c

@@ -7,9 +7,8 @@
 #include <string.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
-#include <limits.h>
 
 
-#include "char.h"
+#include "../common/cbasetypes.h"
 #include "../common/strlib.h"
 #include "../common/strlib.h"
 #include "../common/showmsg.h"
 #include "../common/showmsg.h"
 // #include "int_storage.h"
 // #include "int_storage.h"
@@ -19,6 +18,7 @@
 #include "socket.h"
 #include "socket.h"
 #include "db.h"
 #include "db.h"
 #include "malloc.h"
 #include "malloc.h"
+#include "char.h"
 
 
 #define GS_MEMBER_UNMODIFIED 0x00
 #define GS_MEMBER_UNMODIFIED 0x00
 #define GS_MEMBER_MODIFIED 0x01
 #define GS_MEMBER_MODIFIED 0x01

+ 4 - 2
src/char_sql/int_party.c

@@ -7,13 +7,15 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
-#include "char.h"
+
+#include "../common/cbasetypes.h"
 #include "../common/db.h"
 #include "../common/db.h"
 #include "../common/strlib.h"
 #include "../common/strlib.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/showmsg.h"
 #include "../common/showmsg.h"
 
 
+#include "char.h"
+
 #ifndef TXT_SQL_CONVERT
 #ifndef TXT_SQL_CONVERT
 struct party_data {
 struct party_data {
 	struct party party;
 	struct party party;

+ 6 - 5
src/common/cbasetypes.h

@@ -59,6 +59,12 @@
 // only Silicon Graphics/Cray goes ILP64 so don't care (and don't support)
 // only Silicon Graphics/Cray goes ILP64 so don't care (and don't support)
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 
 
+#include <limits.h>
+// ILP64 isn't supported, so always 32 bits?
+#ifndef UINT_MAX
+#define UINT_MAX 0xffffffff
+#endif
+
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 // Integers with guaranteed _exact_ size.
 // Integers with guaranteed _exact_ size.
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
@@ -126,11 +132,6 @@ typedef unsigned int		uint32;
 #define SINT16_MAX	((sint16)0x7FFF)
 #define SINT16_MAX	((sint16)0x7FFF)
 #define SINT32_MAX	((sint32)0x7FFFFFFF)
 #define SINT32_MAX	((sint32)0x7FFFFFFF)
 
 
-// ILP64 isn't supported, so always 32 bits?
-#ifndef UINT_MAX
-#define UINT_MAX 0xFFFFFFFF
-#endif
-
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 // Integers with guaranteed _minimum_ size.
 // Integers with guaranteed _minimum_ size.
 // These could be larger than you expect,
 // These could be larger than you expect,

+ 0 - 1
src/common/timer.c

@@ -13,7 +13,6 @@
 #include <sys/time.h>
 #include <sys/time.h>
 #endif
 #endif
 
 
-#include <limits.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>

+ 1 - 1
src/map/atcommand.c

@@ -6,8 +6,8 @@
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/mmo.h"
 #include "../common/mmo.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"

+ 2 - 2
src/map/battle.c

@@ -5,9 +5,8 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
-#include "battle.h"
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"
@@ -24,6 +23,7 @@
 #include "pet.h"
 #include "pet.h"
 #include "guild.h"
 #include "guild.h"
 #include "party.h"
 #include "party.h"
+#include "battle.h"
 
 
 int attr_fix_table[4][ELE_MAX][ELE_MAX];
 int attr_fix_table[4][ELE_MAX][ELE_MAX];
 
 

+ 1 - 1
src/map/charcommand.c

@@ -6,8 +6,8 @@
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"

+ 1 - 1
src/map/charsave.c

@@ -4,8 +4,8 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/core.h"
 #include "../common/core.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/timer.h"
 #include "../common/timer.h"

+ 1 - 1
src/map/chrif.c

@@ -6,8 +6,8 @@
 #include <string.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <time.h>
 #include <time.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/timer.h"
 #include "../common/timer.h"

+ 1 - 2
src/map/clif.c

@@ -9,9 +9,9 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <stdarg.h>
 #include <stdarg.h>
-#include <limits.h>
 #include <time.h>
 #include <time.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"
@@ -43,7 +43,6 @@
 #include "pet.h"
 #include "pet.h"
 #include "mercenary.h"	//[orn]
 #include "mercenary.h"	//[orn]
 #include "log.h"
 #include "log.h"
-
 #include "irc.h"
 #include "irc.h"
 
 
 struct Clif_Config {
 struct Clif_Config {

+ 1 - 1
src/map/guild.c

@@ -4,8 +4,8 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"

+ 1 - 1
src/map/mercenary.c

@@ -3,8 +3,8 @@
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"

+ 1 - 1
src/map/mob.c

@@ -6,8 +6,8 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include <string.h>
 #include <string.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/db.h"
 #include "../common/db.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"

+ 1 - 1
src/map/npc.c

@@ -7,8 +7,8 @@
 #include <string.h>
 #include <string.h>
 #include <math.h>
 #include <math.h>
 #include <time.h>
 #include <time.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"

+ 1 - 1
src/map/party.c

@@ -4,8 +4,8 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/socket.h"
 #include "../common/socket.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"

+ 16 - 17
src/map/pc.c

@@ -6,8 +6,8 @@
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <time.h>
 #include <time.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/socket.h" // [Valaris]
 #include "../common/socket.h" // [Valaris]
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"
@@ -7279,7 +7279,7 @@ int pc_readdb(void)
 	while(fgets(line, sizeof(line)-1, fp)){
 	while(fgets(line, sizeof(line)-1, fp)){
 		int jobs[MAX_PC_CLASS], job_count, job;
 		int jobs[MAX_PC_CLASS], job_count, job;
 		int type;
 		int type;
-		unsigned int max;
+		unsigned int ui,maxlv;
 		char *split[4];
 		char *split[4];
 		if(line[0]=='/' && line[1]=='/')
 		if(line[0]=='/' && line[1]=='/')
 			continue;
 			continue;
@@ -7299,28 +7299,27 @@ int pc_readdb(void)
 			ShowError("pc_readdb: Invalid type %d (must be 0 for base levels, 1 for job levels).\n", type);
 			ShowError("pc_readdb: Invalid type %d (must be 0 for base levels, 1 for job levels).\n", type);
 			continue;
 			continue;
 		}
 		}
-		max = atoi(split[0]);
-		if (max > MAX_LEVEL) {
-			ShowWarning("pc_readdb: Specified max level %d for job %d is beyond server's limit (%d).\n ", max, job, MAX_LEVEL);
-			max = MAX_LEVEL;
+		maxlv = atoi(split[0]);
+		if (maxlv > MAX_LEVEL) {
+			ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job, MAX_LEVEL);
+			maxlv = MAX_LEVEL;
 		}
 		}
 		//We send one less and then one more because the last entry in the exp array should hold 0.
 		//We send one less and then one more because the last entry in the exp array should hold 0.
-		max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',max-1)+1;
+		max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1;
 		//Reverse check in case the array has a bunch of trailing zeros... [Skotlex]
 		//Reverse check in case the array has a bunch of trailing zeros... [Skotlex]
 		//The reasoning behind the -2 is this... if the max level is 5, then the array
 		//The reasoning behind the -2 is this... if the max level is 5, then the array
 		//should look like this:
 		//should look like this:
 	   //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3.
 	   //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3.
-		while ((i = max_level[job][type]-2) >= 0 && exp_table[job][type][i] <= 0)
+		while ((ui = max_level[job][type]) >= 2 && exp_table[job][type][ui-2] <= 0)
 			max_level[job][type]--;
 			max_level[job][type]--;
-		if (max_level[job][type] < max) {
-			ShowWarning("pc_readdb: Specified max %d for job %d, but that job's exp table only goes up to level %d.\n", max, job, max_level[job][type]);
+		if (max_level[job][type] < maxlv) {
+			ShowWarning("pc_readdb: Specified max %u for job %d, but that job's exp table only goes up to level %u.\n", maxlv, job, max_level[job][type]);
 			ShowInfo("Filling the missing values with the last exp entry.\n");
 			ShowInfo("Filling the missing values with the last exp entry.\n");
 			//Fill the requested values with the last entry.
 			//Fill the requested values with the last entry.
-			i = max_level[job][type]-2;
-			if (i < 0) i = 0;
-			for (; i < max-2; i++)
-				exp_table[job][type][i] = exp_table[job][type][i-1];
-			max_level[job][type] = max;
+			ui = (max_level[job][type] <= 2? 0: max_level[job][type]-2);
+			for (; ui+2 < maxlv; ui++)
+				exp_table[job][type][ui] = exp_table[job][type][ui-1];
+			max_level[job][type] = maxlv;
 		}
 		}
 //		ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job, max_level[job][type]);
 //		ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job, max_level[job][type]);
 		for (i = 1; i < job_count; i++) {
 		for (i = 1; i < job_count; i++) {
@@ -7330,8 +7329,8 @@ int pc_readdb(void)
 				continue;
 				continue;
 			}
 			}
 			memcpy(exp_table[job][type], exp_table[jobs[0]][type], sizeof(exp_table[0][0]));
 			memcpy(exp_table[job][type], exp_table[jobs[0]][type], sizeof(exp_table[0][0]));
-			max_level[job][type] = max;
-//			ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job, max_level[job][type]);
+			max_level[job][type] = maxlv;
+//			ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job, max_level[job][type]);
 		}
 		}
 	}
 	}
 	fclose(fp);
 	fclose(fp);

+ 1 - 2
src/map/script.c

@@ -10,7 +10,6 @@
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <math.h>
 #include <math.h>
-#include <limits.h>
 
 
 #ifndef _WIN32
 #ifndef _WIN32
 	#include <sys/time.h>
 	#include <sys/time.h>
@@ -2991,7 +2990,7 @@ static int script_load_mapreg(void)
 	ShowInfo("Freeing results...\n");
 	ShowInfo("Freeing results...\n");
 	mysql_free_result(sql_res);
 	mysql_free_result(sql_res);
 	mapreg_dirty=0;
 	mapreg_dirty=0;
-	perfomance = (time(NULL) - perfomance);
+	perfomance = (((unsigned int)time(NULL)) - perfomance);
 	ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance);
 	ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance);
 	return 0;
 	return 0;
 #endif /* TXT_ONLY */
 #endif /* TXT_ONLY */

+ 1 - 1
src/map/skill.c

@@ -5,8 +5,8 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <time.h>
 #include <time.h>
-#include <limits.h>
 
 
+#include "../common/cbasetypes.h"
 #include "../common/timer.h"
 #include "../common/timer.h"
 #include "../common/nullpo.h"
 #include "../common/nullpo.h"
 #include "../common/malloc.h"
 #include "../common/malloc.h"

+ 6 - 6
src/map/status.c

@@ -7,7 +7,12 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <memory.h>
 #include <memory.h>
 #include <string.h>
 #include <string.h>
-#include <limits.h>
+
+#include "../common/cbasetypes.h"
+#include "../common/timer.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+#include "../common/malloc.h"
 
 
 #include "pc.h"
 #include "pc.h"
 #include "map.h"
 #include "map.h"
@@ -25,11 +30,6 @@
 #include "unit.h"
 #include "unit.h"
 #include "mercenary.h"
 #include "mercenary.h"
 
 
-#include "../common/timer.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/malloc.h"
-
 //For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex]
 //For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex]
 #define SC_HM_BASE 800
 #define SC_HM_BASE 800
 #define SC_GD_BASE 900
 #define SC_GD_BASE 900