summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-22 16:52:46 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-22 16:52:46 +0000
commit2a3ca1bcfa82023b3f890f19775b115e8a744b88 (patch)
tree589420d27d8276eb70e90fd686ac92385830965a /src/char
parent873717f2814a890f5b8c52f0302d6cd67e3e29f6 (diff)
downloadhercules-2a3ca1bcfa82023b3f890f19775b115e8a744b88.tar.gz
hercules-2a3ca1bcfa82023b3f890f19775b115e8a744b88.tar.bz2
hercules-2a3ca1bcfa82023b3f890f19775b115e8a744b88.tar.xz
hercules-2a3ca1bcfa82023b3f890f19775b115e8a744b88.zip
* Fixed guild and guild member exp truncation issue (bugreport:4130, since r14242).
- Fixed guild member position, hair, hair color, gender, class and level could potentially become corrupted due to shorts being read as ints (partially since r2986). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14487 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char')
-rw-r--r--src/char/int_guild.c30
-rw-r--r--src/char/int_guild.h2
2 files changed, 16 insertions, 16 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index ed9e52d96..9a815200f 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -42,7 +42,7 @@ int inter_guild_tostr(char* str, struct guild* g)
int i, c, len;
// save guild base info
- len = sprintf(str, "%d\t%s\t%s\t%d,%d,%u,%d,%d\t%s#\t%s#\t",
+ len = sprintf(str, "%d\t%s\t%s\t%d,%d,%"PRIu64",%d,%d\t%s#\t%s#\t",
g->guild_id, g->name, g->master, g->guild_lv, g->max_member, g->exp, g->skill_point, 0, g->mes1, g->mes2);
// save guild member info
@@ -118,13 +118,13 @@ int inter_guild_fromstr(char* str, struct guild* g)
char master[256]; // only 24 used
int guildlv;
int max_member;
- unsigned int exp;
+ uint64 exp;
int skpoint;
char mes1[256]; // only 60 used
char mes2[256]; // only 120 used
int len;
- if( sscanf(str, "%d\t%[^\t]\t%[^\t]\t%d,%d,%u,%d,%*d\t%[^\t]\t%[^\t]\t%n",
+ if( sscanf(str, "%d\t%[^\t]\t%[^\t]\t%d,%d,%"SCNu64",%d,%*d\t%[^\t]\t%[^\t]\t%n",
&guildid, name, master, &guildlv, &max_member, &exp, &skpoint, mes1, mes2, &len) < 9 )
return 1;
@@ -1236,55 +1236,55 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
}
switch(type) {
case GMI_POSITION: // –ðE
- g->member[i].position = *((int *)data);
+ g->member[i].position = *((short *)data);
mapif_guild_memberinfochanged(guild_id, account_id, char_id, type, data, len);
break;
case GMI_EXP: // EXP
{
- unsigned int exp, old_exp=g->member[i].exp;
- g->member[i].exp=*((unsigned int *)data);
+ uint64 exp, old_exp=g->member[i].exp;
+ g->member[i].exp=*((uint64 *)data);
if (g->member[i].exp > old_exp)
{
exp = g->member[i].exp - old_exp;
if (guild_exp_rate != 100)
exp = exp*guild_exp_rate/100;
- if (exp > UINT_MAX - g->exp)
- g->exp = UINT_MAX;
+ if (exp > UINT64_MAX - g->exp)
+ g->exp = UINT64_MAX;
else
g->exp+=exp;
guild_calcinfo(g);
- mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,4);
+ mapif_guild_basicinfochanged(guild_id,GBI_EXP,&g->exp,sizeof(g->exp));
}
mapif_guild_memberinfochanged(guild_id, account_id, char_id, type, data, len);
break;
}
case GMI_HAIR:
{
- g->member[i].hair=*((int *)data);
+ g->member[i].hair=*((short *)data);
mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
break;
}
case GMI_HAIR_COLOR:
{
- g->member[i].hair_color=*((int *)data);
+ g->member[i].hair_color=*((short *)data);
mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
break;
}
case GMI_GENDER:
{
- g->member[i].gender=*((int *)data);
+ g->member[i].gender=*((short *)data);
mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
break;
}
case GMI_CLASS:
{
- g->member[i].class_=*((int *)data);
+ g->member[i].class_=*((short *)data);
mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
break;
}
case GMI_LEVEL:
{
- g->member[i].lv=*((int *)data);
+ g->member[i].lv=*((short *)data);
mapif_guild_memberinfochanged(guild_id,account_id,char_id,type,data,len);
break;
}
@@ -1297,7 +1297,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
return 0;
}
-int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender)
+int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender)
{
return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender));
}
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 06293eb0f..0be6c50d9 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -14,7 +14,7 @@ int inter_guild_parse_frommap(int fd);
struct guild *inter_guild_search(int guild_id);
int inter_guild_mapif_init(int fd);
int inter_guild_leave(int guild_id,int account_id,int char_id);
-int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender);
+int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender);
extern char guild_txt[1024];
extern char castle_txt[1024];