summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-09 03:51:18 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-09 03:51:18 +0000
commit400200948796c1fcd529b79a1026be4064c37b67 (patch)
tree92a0ae7b09c8b5b96e8e5d11bb3a47d8dc32c6de /src
parent43b44e59a86da8c2bc9103bb28ccf1cd9a86b104 (diff)
downloadhercules-400200948796c1fcd529b79a1026be4064c37b67.tar.gz
hercules-400200948796c1fcd529b79a1026be4064c37b67.tar.bz2
hercules-400200948796c1fcd529b79a1026be4064c37b67.tar.xz
hercules-400200948796c1fcd529b79a1026be4064c37b67.zip
- Modified guild exp to be an unsigned int rather than a signed one.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7059 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char/int_guild.c28
-rw-r--r--src/char_sql/int_guild.c21
-rw-r--r--src/common/mmo.h3
-rw-r--r--src/map/guild.c10
-rw-r--r--src/map/intif.c5
5 files changed, 38 insertions, 29 deletions
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 3a3dd6529..3cd5572d9 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -23,7 +23,7 @@ static struct dbt *castle_db;
static int guild_newid = 10000;
-static int guild_exp[100];
+static unsigned int guild_exp[100];
int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes);
int mapif_guild_broken(int guild_id, int flag);
@@ -38,14 +38,14 @@ int inter_guild_tostr(char *str, struct guild *g) {
int i, c, len;
// 基本データ
- len = sprintf(str, "%d\t%s\t%s\t%d,%d,%d,%d,%d\t%s#\t%s#\t",
+ len = sprintf(str, "%d\t%s\t%s\t%d,%d,%u,%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, g->castle_id,
g->mes1, g->mes2);
// メンバー
for(i = 0; i < g->max_member; i++) {
struct guild_member *m = &g->member[i];
- len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\t%s\t",
+ len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%u,%d,%d\t%s\t",
m->account_id, m->char_id,
m->hair, m->hair_color, m->gender,
m->class_, m->lv, m->exp, m->exp_payper, m->position,
@@ -98,6 +98,7 @@ int inter_guild_tostr(char *str, struct guild *g) {
// ギルドデータの文字列からの変換
int inter_guild_fromstr(char *str, struct guild *g) {
int i, j, c;
+ unsigned int exp;
int tmp_int[16];
char tmp_str[4][256];
char tmp_str2[4096];
@@ -105,16 +106,16 @@ int inter_guild_fromstr(char *str, struct guild *g) {
// 基本データ
memset(g, 0, sizeof(struct guild));
- if (sscanf(str, "%d\t%[^\t]\t%[^\t]\t%d,%d,%d,%d,%d\t%[^\t]\t%[^\t]\t", &tmp_int[0],
+ if (sscanf(str, "%d\t%[^\t]\t%[^\t]\t%d,%d,%u,%d,%d\t%[^\t]\t%[^\t]\t", &tmp_int[0],
tmp_str[0], tmp_str[1],
- &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4], &tmp_int[5],
+ &tmp_int[1], &tmp_int[2], &exp, &tmp_int[4], &tmp_int[5],
tmp_str[2], tmp_str[3]) < 8)
return 1;
g->guild_id = tmp_int[0];
g->guild_lv = tmp_int[1];
g->max_member = tmp_int[2];
- g->exp = tmp_int[3];
+ g->exp = exp;
g->skill_point = tmp_int[4];
g->castle_id = tmp_int[5];
memcpy(g->name, tmp_str[0], NAME_LENGTH-1);
@@ -131,9 +132,9 @@ int inter_guild_fromstr(char *str, struct guild *g) {
// メンバー
for(i = 0; i < g->max_member; i++) {
struct guild_member *m = &g->member[i];
- if (sscanf(str + 1, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\t%[^\t]\t",
+ if (sscanf(str + 1, "%d,%d,%d,%d,%d,%d,%d,%u,%d,%d\t%[^\t]\t",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], &tmp_int[4],
- &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9],
+ &tmp_int[5], &tmp_int[6], &exp, &tmp_int[8], &tmp_int[9],
tmp_str[0]) < 11)
return 1;
m->account_id = tmp_int[0];
@@ -143,7 +144,7 @@ int inter_guild_fromstr(char *str, struct guild *g) {
m->gender = tmp_int[4];
m->class_ = tmp_int[5];
m->lv = tmp_int[6];
- m->exp = tmp_int[7];
+ m->exp = exp;
m->exp_payper = tmp_int[8];
m->position = tmp_int[9];
memcpy(m->name, tmp_str[0], NAME_LENGTH-1);
@@ -350,7 +351,7 @@ int inter_guild_readdb(void) {
while(fgets(line, sizeof(line)-1, fp) && i < 100){
if (line[0] == '/' && line[1] == '/')
continue;
- guild_exp[i] = atoi(line);
+ guild_exp[i] = (unsigned int)atof(line);
i++;
}
fclose(fp);
@@ -567,7 +568,7 @@ int guild_check_conflict(int guild_id, int account_id, int char_id) {
return 0;
}
-int guild_nextexp (int level)
+unsigned int guild_nextexp (int level)
{
if (level == 0)
return 1;
@@ -591,7 +592,8 @@ int guild_checkskill(struct guild *g, int id) {
// ギルドの情報の再計算
int guild_calcinfo(struct guild *g) {
- int i, c, nextexp;
+ int i, c;
+ unsigned int nextexp;
struct guild before = *g;
// スキルIDの設定
@@ -1204,7 +1206,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
break;
case GMI_EXP: // EXP
{
- int exp, oldexp = g->member[i].exp;
+ unsigned int exp, oldexp = g->member[i].exp;
exp = g->member[i].exp = *((unsigned int *)data);
g->exp += (exp - oldexp);
guild_calcinfo(g); // Lvアップ判断
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 1849ba130..f0ee8be4d 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -24,7 +24,7 @@ static struct dbt *guild_db_;
struct guild_castle castles[MAX_GUILDCASTLE];
-static int guild_exp[100];
+static unsigned int guild_exp[100];
#define GS_BASIC 0x01
#define GS_MEMBER 0x02
@@ -134,7 +134,7 @@ int inter_guild_tosql(struct guild *g,int flag)
if (g->guild_id == -1) //Insert
sprintf(tmp_sql,"INSERT INTO `%s` "
"(`name`,`master`,`guild_lv`,`connect_member`,`max_member`,`average_lv`,`exp`,`next_exp`,`skill_point`,`mes1`,`mes2`,`emblem_len`,`emblem_id`,`emblem_data`,`char_id`) "
- "VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%d', '%d', '%s', '%d')",
+ "VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%u', '%u', '%d', '%s', '%s', '%d', '%d', '%s', '%d')",
guild_db,t_name,jstrescapecpy(t_master,g->master),
g->guild_lv,g->connect_member,g->max_member,g->average_lv,g->exp,g->next_exp,g->skill_point,
jstrescapecpy(t_mes1,g->mes1),jstrescapecpy(t_mes2,g->mes2),g->emblem_len,g->emblem_id,emblem_data,
@@ -142,7 +142,7 @@ int inter_guild_tosql(struct guild *g,int flag)
else //Update
sprintf(tmp_sql,"UPDATE `%s` SET"
" `guild_id`=%d, `name`='%s', `master`='%s',`guild_lv`=%d, `connect_member`=%d,`max_member`=%d, "
- "`average_lv`=%d,`exp`=%d,`next_exp`=%d,`skill_point`=%d,`mes1`='%s',`mes2`='%s',"
+ "`average_lv`=%d,`exp`=%u,`next_exp`=%u,`skill_point`=%d,`mes1`='%s',`mes2`='%s',"
"`emblem_len`=%d,`emblem_id`=%d,`emblem_data`='%s',`char_id`=%d WHERE `guild_id`=%d",
guild_db, g->guild_id,t_name,jstrescapecpy(t_master,g->master),
g->guild_lv,g->connect_member,g->max_member,g->average_lv,g->exp,g->next_exp,g->skill_point,
@@ -349,8 +349,8 @@ struct guild * inter_guild_fromsql(int guild_id)
else
g->max_member = atoi(sql_row[4]);
g->average_lv=atoi(sql_row[5]);
- g->exp=atoi(sql_row[6]);
- g->next_exp=atoi(sql_row[7]);
+ g->exp=(unsigned int)atof(sql_row[6]);
+ g->next_exp=(unsigned int)atof(sql_row[7]);
g->skill_point=atoi(sql_row[8]);
//There shouldn't be a need to copy the very last char, as it's the \0 [Skotlex]
strncpy(g->mes1,sql_row[9],59);
@@ -391,7 +391,7 @@ struct guild * inter_guild_fromsql(int guild_id)
m->gender=atoi(sql_row[5]);
m->class_=atoi(sql_row[6]);
m->lv=atoi(sql_row[7]);
- m->exp=atoi(sql_row[8]);
+ m->exp=(unsigned int)atof(sql_row[8]);
m->exp_payper=atoi(sql_row[9]);
m->online=atoi(sql_row[10]);
if (atoi(sql_row[11]) >= MAX_GUILDPOSITION) // Fix reduction of MAX_GUILDPOSITION [PoW]
@@ -631,7 +631,7 @@ int inter_guild_ReadEXP(void)
while(fgets(line,256,fp) && i<100){
if(line[0]=='/' && line[1]=='/')
continue;
- guild_exp[i]=atoi(line);
+ guild_exp[i]=(unsigned int)atof(line);
i++;
}
fclose(fp);
@@ -793,7 +793,7 @@ int guild_check_empty(struct guild *g)
return 1;
}
-int guild_nextexp(int level)
+unsigned int guild_nextexp(int level)
{
if (level == 0)
return 1;
@@ -820,7 +820,8 @@ int guild_checkskill(struct guild *g,int id) {
// ギルドの情報の再計算
int guild_calcinfo(struct guild *g)
{
- int i,c,nextexp;
+ int i,c;
+ unsigned int nextexp;
struct guild before=*g;
// スキルIDの設定
@@ -1523,7 +1524,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
}
case GMI_EXP:
{ // EXP
- int exp,oldexp=g->member[i].exp;
+ unsigned int exp,oldexp=g->member[i].exp;
exp=g->member[i].exp=*((unsigned int *)data);
g->exp+=(exp-oldexp);
guild_calcinfo(g); // Lvアップ判断
diff --git a/src/common/mmo.h b/src/common/mmo.h
index f842c4b0d..205c943c5 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -297,7 +297,8 @@ struct guild_skill {
struct guild {
int guild_id;
short guild_lv, connect_member, max_member, average_lv;
- int exp,next_exp,skill_point;
+ unsigned int exp,next_exp;
+ int skill_point;
#ifdef TXT_ONLY
//FIXME: Gotta remove this variable completely, but doing so screws up the format of the txt save file...
int castle_id;
diff --git a/src/map/guild.c b/src/map/guild.c
index 3d4aeb9f7..9fa9d16c6 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -367,8 +367,8 @@ int guild_payexp_timer_sub(DBKey dataid, void *data, va_list ap)
return 0;
}
- if ((unsigned int)g->member[i].exp > INT_MAX - c->exp)
- g->member[i].exp = INT_MAX;
+ if (g->member[i].exp > UINT_MAX - c->exp)
+ g->member[i].exp = UINT_MAX;
else
g->member[i].exp+= c->exp;
@@ -1139,6 +1139,8 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp)
nullpo_retr(0, sd);
+ if (!exp) return 0;
+
if (sd->status.guild_id == 0 ||
(g = guild_search(sd->status.guild_id)) == NULL ||
(per = g->position[guild_getposition(sd,g)].exp_mode) <= 0)
@@ -1149,7 +1151,9 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp)
else
if (per < 1) return 0;
- if ((tmp = exp * per / 100) <= 0)
+
+ tmp = exp * per / 100;
+ if (tmp <= 0)
return 0;
exp2 = (unsigned int)tmp;
diff --git a/src/map/intif.c b/src/map/intif.c
index fc7fd6c3d..4081997d6 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1166,7 +1166,8 @@ int intif_parse_GuildBroken(int fd)
// ギルド基本情報変更通知
int intif_parse_GuildBasicInfoChanged(int fd)
{
- int type, guild_id, dd;
+ int type, guild_id;
+ unsigned int dd;
void *data;
struct guild *g;
short dw;
@@ -1176,7 +1177,7 @@ int intif_parse_GuildBasicInfoChanged(int fd)
data=RFIFOP(fd,10);
g=guild_search(guild_id);
dw=*((short *)data);
- dd=*((int *)data);
+ dd=*((unsigned int *)data);
if( g==NULL )
return 0;
switch(type){