From 7bfe35400c79bf97a5b0bed9f170912c37cf9452 Mon Sep 17 00:00:00 2001 From: amber Date: Tue, 29 Mar 2005 05:05:50 +0000 Subject: Fixed use of storage variable to conform to ANSI C spec [MouseJstr] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1327 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 2 + src/char/int_storage.c | 112 ++++++++++++------------ src/char_sql/int_storage.c | 92 ++++++++++---------- src/common/mmo.h | 4 +- src/map/charcommand.c | 14 +-- src/map/clif.c | 208 ++++++++++++++++++++++----------------------- src/map/storage.c | 60 ++++++------- 7 files changed, 247 insertions(+), 245 deletions(-) diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 7dba98552..7f32d47cb 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -1,6 +1,8 @@ Date Added 03/29 + * Fixed use of storage variable to conform to ANSI C spec + [1327: MouseJstr] * Added CIA-bot to the #athena channel [MouseJstr] * Some tidying up in mail.c [celest] * Added an invalid pointer check in clif_displaymessage [celest] diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 67b25909b..498004bc0 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -28,11 +28,11 @@ int storage_tostr(char *str,struct storage *p) str_p += sprintf(str_p,"%d,%d\t",p->account_id,p->storage_amount); for(i=0;istorage[i].nameid) && (p->storage[i].amount) ){ + if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){ str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", - p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip, - p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute, - p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3]); + p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip, + p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute, + p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]); f++; } @@ -63,17 +63,17 @@ int storage_fromstr(char *str,struct storage *p) &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[10], &tmp_int[10], &len) == 12) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') next++; @@ -83,17 +83,17 @@ int storage_fromstr(char *str,struct storage *p) &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[10], &len) == 11) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') next++; @@ -111,11 +111,11 @@ int guild_storage_tostr(char *str,struct guild_storage *p) str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount); for(i=0;istorage[i].nameid) && (p->storage[i].amount) ){ + if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){ str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", - p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip, - p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute, - p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3]); + p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip, + p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute, + p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]); f++; } @@ -145,17 +145,17 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) &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[10], &tmp_int[10], &len) == 12) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') next++; @@ -165,17 +165,17 @@ int guild_storage_fromstr(char *str,struct guild_storage *p) &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[10], &len) == 11) { - p->storage[i].id = tmp_int[0]; - p->storage[i].nameid = tmp_int[1]; - p->storage[i].amount = tmp_int[2]; - p->storage[i].equip = tmp_int[3]; - p->storage[i].identify = tmp_int[4]; - p->storage[i].refine = tmp_int[5]; - p->storage[i].attribute = tmp_int[6]; - p->storage[i].card[0] = tmp_int[7]; - p->storage[i].card[1] = tmp_int[8]; - p->storage[i].card[2] = tmp_int[9]; - p->storage[i].card[3] = tmp_int[10]; + p->storage_[i].id = tmp_int[0]; + p->storage_[i].nameid = tmp_int[1]; + p->storage_[i].amount = tmp_int[2]; + p->storage_[i].equip = tmp_int[3]; + p->storage_[i].identify = tmp_int[4]; + p->storage_[i].refine = tmp_int[5]; + p->storage_[i].attribute = tmp_int[6]; + p->storage_[i].card[0] = tmp_int[7]; + p->storage_[i].card[1] = tmp_int[8]; + p->storage_[i].card[2] = tmp_int[9]; + p->storage_[i].card[3] = tmp_int[10]; next += len; if (str[next] == ' ') next++; @@ -368,8 +368,8 @@ int inter_storage_delete(int account_id) if(s) { int i; for(i=0;istorage_amount;i++){ - if(s->storage[i].card[0] == (short)0xff00) - inter_pet_delete(*((long *)(&s->storage[i].card[2]))); + if(s->storage_[i].card[0] == (short)0xff00) + inter_pet_delete(*((long *)(&s->storage_[i].card[2]))); } numdb_erase(storage_db,account_id); aFree(s); @@ -384,8 +384,8 @@ int inter_guild_storage_delete(int guild_id) if(gs) { int i; for(i=0;istorage_amount;i++){ - if(gs->storage[i].card[0] == (short)0xff00) - inter_pet_delete(*((long *)(&gs->storage[i].card[2]))); + if(gs->storage_[i].card[0] == (short)0xff00) + inter_pet_delete(*((long *)(&gs->storage_[i].card[2]))); } numdb_erase(guild_storage_db,guild_id); aFree(gs); diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 7f059fcf8..c13c782a6 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -24,19 +24,19 @@ int storage_tosql(int account_id,struct storage *p){ int count=0; struct itemtmp mapitem[MAX_GUILD_STORAGE]; for(i=0;istorage[i].nameid>0){ + if(p->storage_[i].nameid>0){ mapitem[count].flag=0; - mapitem[count].id = p->storage[i].id; - mapitem[count].nameid=p->storage[i].nameid; - mapitem[count].amount = p->storage[i].amount; - mapitem[count].equip = p->storage[i].equip; - mapitem[count].identify = p->storage[i].identify; - mapitem[count].refine = p->storage[i].refine; - mapitem[count].attribute = p->storage[i].attribute; - mapitem[count].card[0] = p->storage[i].card[0]; - mapitem[count].card[1] = p->storage[i].card[1]; - mapitem[count].card[2] = p->storage[i].card[2]; - mapitem[count].card[3] = p->storage[i].card[3]; + mapitem[count].id = p->storage_[i].id; + mapitem[count].nameid=p->storage_[i].nameid; + mapitem[count].amount = p->storage_[i].amount; + mapitem[count].equip = p->storage_[i].equip; + mapitem[count].identify = p->storage_[i].identify; + mapitem[count].refine = p->storage_[i].refine; + mapitem[count].attribute = p->storage_[i].attribute; + mapitem[count].card[0] = p->storage_[i].card[0]; + mapitem[count].card[1] = p->storage_[i].card[1]; + mapitem[count].card[2] = p->storage_[i].card[2]; + mapitem[count].card[3] = p->storage_[i].card[3]; count++; } } @@ -64,17 +64,17 @@ int storage_fromsql(int account_id, struct storage *p){ if (sql_res) { while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch - p->storage[i].id= atoi(sql_row[0]); - p->storage[i].nameid= atoi(sql_row[1]); - p->storage[i].amount= atoi(sql_row[2]); - p->storage[i].equip= atoi(sql_row[3]); - p->storage[i].identify= atoi(sql_row[4]); - p->storage[i].refine= atoi(sql_row[5]); - p->storage[i].attribute= atoi(sql_row[6]); - p->storage[i].card[0]= atoi(sql_row[7]); - p->storage[i].card[1]= atoi(sql_row[8]); - p->storage[i].card[2]= atoi(sql_row[9]); - p->storage[i].card[3]= atoi(sql_row[10]); + p->storage_[i].id= atoi(sql_row[0]); + p->storage_[i].nameid= atoi(sql_row[1]); + p->storage_[i].amount= atoi(sql_row[2]); + p->storage_[i].equip= atoi(sql_row[3]); + p->storage_[i].identify= atoi(sql_row[4]); + p->storage_[i].refine= atoi(sql_row[5]); + p->storage_[i].attribute= atoi(sql_row[6]); + p->storage_[i].card[0]= atoi(sql_row[7]); + p->storage_[i].card[1]= atoi(sql_row[8]); + p->storage_[i].card[2]= atoi(sql_row[9]); + p->storage_[i].card[3]= atoi(sql_row[10]); p->storage_amount = ++i; } mysql_free_result(sql_res); @@ -92,19 +92,19 @@ int guild_storage_tosql(int guild_id, struct guild_storage *p){ int count=0; struct itemtmp mapitem[MAX_GUILD_STORAGE]; for(i=0;istorage[i].nameid>0){ + if(p->storage_[i].nameid>0){ mapitem[count].flag=0; - mapitem[count].id = p->storage[i].id; - mapitem[count].nameid=p->storage[i].nameid; - mapitem[count].amount = p->storage[i].amount; - mapitem[count].equip = p->storage[i].equip; - mapitem[count].identify = p->storage[i].identify; - mapitem[count].refine = p->storage[i].refine; - mapitem[count].attribute = p->storage[i].attribute; - mapitem[count].card[0] = p->storage[i].card[0]; - mapitem[count].card[1] = p->storage[i].card[1]; - mapitem[count].card[2] = p->storage[i].card[2]; - mapitem[count].card[3] = p->storage[i].card[3]; + mapitem[count].id = p->storage_[i].id; + mapitem[count].nameid=p->storage_[i].nameid; + mapitem[count].amount = p->storage_[i].amount; + mapitem[count].equip = p->storage_[i].equip; + mapitem[count].identify = p->storage_[i].identify; + mapitem[count].refine = p->storage_[i].refine; + mapitem[count].attribute = p->storage_[i].attribute; + mapitem[count].card[0] = p->storage_[i].card[0]; + mapitem[count].card[1] = p->storage_[i].card[1]; + mapitem[count].card[2] = p->storage_[i].card[2]; + mapitem[count].card[3] = p->storage_[i].card[3]; count++; } } @@ -134,17 +134,17 @@ int guild_storage_fromsql(int guild_id, struct guild_storage *p){ if (sql_res) { while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch - p->storage[i].id= atoi(sql_row[0]); - p->storage[i].nameid= atoi(sql_row[1]); - p->storage[i].amount= atoi(sql_row[2]); - p->storage[i].equip= atoi(sql_row[3]); - p->storage[i].identify= atoi(sql_row[4]); - p->storage[i].refine= atoi(sql_row[5]); - p->storage[i].attribute= atoi(sql_row[6]); - p->storage[i].card[0]= atoi(sql_row[7]); - p->storage[i].card[1]= atoi(sql_row[8]); - p->storage[i].card[2]= atoi(sql_row[9]); - p->storage[i].card[3]= atoi(sql_row[10]); + p->storage_[i].id= atoi(sql_row[0]); + p->storage_[i].nameid= atoi(sql_row[1]); + p->storage_[i].amount= atoi(sql_row[2]); + p->storage_[i].equip= atoi(sql_row[3]); + p->storage_[i].identify= atoi(sql_row[4]); + p->storage_[i].refine= atoi(sql_row[5]); + p->storage_[i].attribute= atoi(sql_row[6]); + p->storage_[i].card[0]= atoi(sql_row[7]); + p->storage_[i].card[1]= atoi(sql_row[8]); + p->storage_[i].card[2]= atoi(sql_row[9]); + p->storage_[i].card[3]= atoi(sql_row[10]); p->storage_amount = ++i; if (i >= MAX_GUILD_STORAGE) break; diff --git a/src/common/mmo.h b/src/common/mmo.h index b61af6658..1602c5655 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -173,14 +173,14 @@ struct storage { int account_id; short storage_status; short storage_amount; - struct item storage[MAX_STORAGE]; + struct item storage_[MAX_STORAGE]; }; struct guild_storage { int guild_id; short storage_status; short storage_amount; - struct item storage[MAX_GUILD_STORAGE]; + struct item storage_[MAX_GUILD_STORAGE]; }; struct map_session_data; diff --git a/src/map/charcommand.c b/src/map/charcommand.c index ab57a6b39..15c94e51a 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -944,23 +944,23 @@ charcommand_storagelist( counter = 0; count = 0; for (i = 0; i < MAX_STORAGE; i++) { - if (stor->storage[i].nameid > 0 && (item_data = itemdb_search(stor->storage[i].nameid)) != NULL) { - counter = counter + stor->storage[i].amount; + if (stor->storage_[i].nameid > 0 && (item_data = itemdb_search(stor->storage_[i].nameid)) != NULL) { + counter = counter + stor->storage_[i].amount; count++; if (count == 1) { sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name); clif_displaymessage(fd, output); } - if (stor->storage[i].refine) - sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage[i].amount, item_data->name, stor->storage[i].refine, item_data->jname, stor->storage[i].refine, stor->storage[i].nameid); + if (stor->storage_[i].refine) + sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage_[i].amount, item_data->name, stor->storage_[i].refine, item_data->jname, stor->storage_[i].refine, stor->storage_[i].nameid); else - sprintf(output, "%d %s (%s, id: %d)", stor->storage[i].amount, item_data->name, item_data->jname, stor->storage[i].nameid); + sprintf(output, "%d %s (%s, id: %d)", stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid); clif_displaymessage(fd, output); memset(output, '\0', sizeof(output)); counter2 = 0; for (j = 0; j < item_data->slot; j++) { - if (stor->storage[i].card[j]) { - if ((item_temp = itemdb_search(stor->storage[i].card[j])) != NULL) { + if (stor->storage_[i].card[j]) { + if ((item_temp = itemdb_search(stor->storage_[i].card[j])) != NULL) { if (output[0] == '\0') sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname); else diff --git a/src/map/clif.c b/src/map/clif.c index 03622cfe3..9e649df40 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2084,9 +2084,9 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor) #if PACKETVER < 5 WBUFW(buf,0)=0xa5; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(itemdb_isequip2(id)) continue; @@ -2094,10 +2094,10 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor) if(id->view_id > 0) WBUFW(buf,n*10+6)=id->view_id; else - WBUFW(buf,n*10+6)=stor->storage[i].nameid; + WBUFW(buf,n*10+6)=stor->storage_[i].nameid; WBUFB(buf,n*10+8)=id->type;; - WBUFB(buf,n*10+9)=stor->storage[i].identify; - WBUFW(buf,n*10+10)=stor->storage[i].amount; + WBUFB(buf,n*10+9)=stor->storage_[i].identify; + WBUFW(buf,n*10+10)=stor->storage_[i].amount; WBUFW(buf,n*10+12)=0; n++; } @@ -2108,9 +2108,9 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor) #else WBUFW(buf,0)=0x1f0; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(itemdb_isequip2(id)) continue; @@ -2118,15 +2118,15 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor) if(id->view_id > 0) WBUFW(buf,n*18+6)=id->view_id; else - WBUFW(buf,n*18+6)=stor->storage[i].nameid; + WBUFW(buf,n*18+6)=stor->storage_[i].nameid; WBUFB(buf,n*18+8)=id->type;; - WBUFB(buf,n*18+9)=stor->storage[i].identify; - WBUFW(buf,n*18+10)=stor->storage[i].amount; + WBUFB(buf,n*18+9)=stor->storage_[i].identify; + WBUFW(buf,n*18+10)=stor->storage_[i].amount; WBUFW(buf,n*18+12)=0; - WBUFW(buf,n*18+14)=stor->storage[i].card[0]; - WBUFW(buf,n*18+16)=stor->storage[i].card[1]; - WBUFW(buf,n*18+18)=stor->storage[i].card[2]; - WBUFW(buf,n*18+20)=stor->storage[i].card[3]; + WBUFW(buf,n*18+14)=stor->storage_[i].card[0]; + WBUFW(buf,n*18+16)=stor->storage_[i].card[1]; + WBUFW(buf,n*18+18)=stor->storage_[i].card[2]; + WBUFW(buf,n*18+20)=stor->storage_[i].card[3]; n++; } if(n){ @@ -2154,44 +2154,44 @@ int clif_storageequiplist(struct map_session_data *sd,struct storage *stor) buf = WFIFOP(fd,0); WBUFW(buf,0)=0xa6; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(!itemdb_isequip2(id)) continue; WBUFW(buf,n*20+4)=i+1; if(id->view_id > 0) WBUFW(buf,n*20+6)=id->view_id; else - WBUFW(buf,n*20+6)=stor->storage[i].nameid; + WBUFW(buf,n*20+6)=stor->storage_[i].nameid; WBUFB(buf,n*20+8)=id->type; - WBUFB(buf,n*20+9)=stor->storage[i].identify; + WBUFB(buf,n*20+9)=stor->storage_[i].identify; WBUFW(buf,n*20+10)=id->equip; - WBUFW(buf,n*20+12)=stor->storage[i].equip; - WBUFB(buf,n*20+14)=stor->storage[i].attribute; - WBUFB(buf,n*20+15)=stor->storage[i].refine; - if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) { - WBUFW(buf,n*20+16)=stor->storage[i].card[0]; - WBUFW(buf,n*20+18)=stor->storage[i].card[1]; - WBUFW(buf,n*20+20)=stor->storage[i].card[2]; - WBUFW(buf,n*20+22)=stor->storage[i].card[3]; + WBUFW(buf,n*20+12)=stor->storage_[i].equip; + WBUFB(buf,n*20+14)=stor->storage_[i].attribute; + WBUFB(buf,n*20+15)=stor->storage_[i].refine; + if(stor->storage_[i].card[0]==0x00ff || stor->storage_[i].card[0]==0x00fe || stor->storage_[i].card[0]==(short)0xff00) { + WBUFW(buf,n*20+16)=stor->storage_[i].card[0]; + WBUFW(buf,n*20+18)=stor->storage_[i].card[1]; + WBUFW(buf,n*20+20)=stor->storage_[i].card[2]; + WBUFW(buf,n*20+22)=stor->storage_[i].card[3]; } else { - if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0) + if(stor->storage_[i].card[0] > 0 && (j=itemdb_viewid(stor->storage_[i].card[0])) > 0) WBUFW(buf,n*20+16)=j; else - WBUFW(buf,n*20+16)=stor->storage[i].card[0]; - if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0) + WBUFW(buf,n*20+16)=stor->storage_[i].card[0]; + if(stor->storage_[i].card[1] > 0 && (j=itemdb_viewid(stor->storage_[i].card[1])) > 0) WBUFW(buf,n*20+18)=j; else - WBUFW(buf,n*20+18)=stor->storage[i].card[1]; - if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0) + WBUFW(buf,n*20+18)=stor->storage_[i].card[1]; + if(stor->storage_[i].card[2] > 0 && (j=itemdb_viewid(stor->storage_[i].card[2])) > 0) WBUFW(buf,n*20+20)=j; else - WBUFW(buf,n*20+20)=stor->storage[i].card[2]; - if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0) + WBUFW(buf,n*20+20)=stor->storage_[i].card[2]; + if(stor->storage_[i].card[3] > 0 && (j=itemdb_viewid(stor->storage_[i].card[3])) > 0) WBUFW(buf,n*20+22)=j; else - WBUFW(buf,n*20+22)=stor->storage[i].card[3]; + WBUFW(buf,n*20+22)=stor->storage_[i].card[3]; } n++; } @@ -2221,9 +2221,9 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage * #if PACKETVER < 5 WBUFW(buf,0)=0xa5; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(itemdb_isequip2(id)) continue; @@ -2231,10 +2231,10 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage * if(id->view_id > 0) WBUFW(buf,n*10+6)=id->view_id; else - WBUFW(buf,n*10+6)=stor->storage[i].nameid; + WBUFW(buf,n*10+6)=stor->storage_[i].nameid; WBUFB(buf,n*10+8)=id->type;; - WBUFB(buf,n*10+9)=stor->storage[i].identify; - WBUFW(buf,n*10+10)=stor->storage[i].amount; + WBUFB(buf,n*10+9)=stor->storage_[i].identify; + WBUFW(buf,n*10+10)=stor->storage_[i].amount; WBUFW(buf,n*10+12)=0; n++; } @@ -2245,9 +2245,9 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage * #else WBUFW(buf,0)=0x1f0; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(itemdb_isequip2(id)) continue; @@ -2255,15 +2255,15 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage * if(id->view_id > 0) WBUFW(buf,n*18+6)=id->view_id; else - WBUFW(buf,n*18+6)=stor->storage[i].nameid; + WBUFW(buf,n*18+6)=stor->storage_[i].nameid; WBUFB(buf,n*18+8)=id->type;; - WBUFB(buf,n*18+9)=stor->storage[i].identify; - WBUFW(buf,n*18+10)=stor->storage[i].amount; + WBUFB(buf,n*18+9)=stor->storage_[i].identify; + WBUFW(buf,n*18+10)=stor->storage_[i].amount; WBUFW(buf,n*18+12)=0; - WBUFW(buf,n*18+14)=stor->storage[i].card[0]; - WBUFW(buf,n*18+16)=stor->storage[i].card[1]; - WBUFW(buf,n*18+18)=stor->storage[i].card[2]; - WBUFW(buf,n*18+20)=stor->storage[i].card[3]; + WBUFW(buf,n*18+14)=stor->storage_[i].card[0]; + WBUFW(buf,n*18+16)=stor->storage_[i].card[1]; + WBUFW(buf,n*18+18)=stor->storage_[i].card[2]; + WBUFW(buf,n*18+20)=stor->storage_[i].card[3]; n++; } if(n){ @@ -2291,44 +2291,44 @@ int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage WBUFW(buf,0)=0xa6; for(i=0,n=0;istorage[i].nameid<=0) + if(stor->storage_[i].nameid<=0) continue; - nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid)); + nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid)); if(!itemdb_isequip2(id)) continue; WBUFW(buf,n*20+4)=i+1; if(id->view_id > 0) WBUFW(buf,n*20+6)=id->view_id; else - WBUFW(buf,n*20+6)=stor->storage[i].nameid; + WBUFW(buf,n*20+6)=stor->storage_[i].nameid; WBUFB(buf,n*20+8)=id->type; - WBUFB(buf,n*20+9)=stor->storage[i].identify; + WBUFB(buf,n*20+9)=stor->storage_[i].identify; WBUFW(buf,n*20+10)=id->equip; - WBUFW(buf,n*20+12)=stor->storage[i].equip; - WBUFB(buf,n*20+14)=stor->storage[i].attribute; - WBUFB(buf,n*20+15)=stor->storage[i].refine; - if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) { - WBUFW(buf,n*20+16)=stor->storage[i].card[0]; - WBUFW(buf,n*20+18)=stor->storage[i].card[1]; - WBUFW(buf,n*20+20)=stor->storage[i].card[2]; - WBUFW(buf,n*20+22)=stor->storage[i].card[3]; + WBUFW(buf,n*20+12)=stor->storage_[i].equip; + WBUFB(buf,n*20+14)=stor->storage_[i].attribute; + WBUFB(buf,n*20+15)=stor->storage_[i].refine; + if(stor->storage_[i].card[0]==0x00ff || stor->storage_[i].card[0]==0x00fe || stor->storage_[i].card[0]==(short)0xff00) { + WBUFW(buf,n*20+16)=stor->storage_[i].card[0]; + WBUFW(buf,n*20+18)=stor->storage_[i].card[1]; + WBUFW(buf,n*20+20)=stor->storage_[i].card[2]; + WBUFW(buf,n*20+22)=stor->storage_[i].card[3]; } else { - if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0) + if(stor->storage_[i].card[0] > 0 && (j=itemdb_viewid(stor->storage_[i].card[0])) > 0) WBUFW(buf,n*20+16)=j; else - WBUFW(buf,n*20+16)=stor->storage[i].card[0]; - if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0) + WBUFW(buf,n*20+16)=stor->storage_[i].card[0]; + if(stor->storage_[i].card[1] > 0 && (j=itemdb_viewid(stor->storage_[i].card[1])) > 0) WBUFW(buf,n*20+18)=j; else - WBUFW(buf,n*20+18)=stor->storage[i].card[1]; - if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0) + WBUFW(buf,n*20+18)=stor->storage_[i].card[1]; + if(stor->storage_[i].card[2] > 0 && (j=itemdb_viewid(stor->storage_[i].card[2])) > 0) WBUFW(buf,n*20+20)=j; else - WBUFW(buf,n*20+20)=stor->storage[i].card[2]; - if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0) + WBUFW(buf,n*20+20)=stor->storage_[i].card[2]; + if(stor->storage_[i].card[3] > 0 && (j=itemdb_viewid(stor->storage_[i].card[3])) > 0) WBUFW(buf,n*20+22)=j; else - WBUFW(buf,n*20+22)=stor->storage[i].card[3]; + WBUFW(buf,n*20+22)=stor->storage_[i].card[3]; } n++; } @@ -3372,35 +3372,35 @@ int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int i WFIFOW(fd,0) =0xf4; // Storage item added WFIFOW(fd,2) =index+1; // index WFIFOL(fd,4) =amount; // amount - if((view = itemdb_viewid(stor->storage[index].nameid)) > 0) + if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0) WFIFOW(fd,8) =view; else - WFIFOW(fd,8) =stor->storage[index].nameid; // id - WFIFOB(fd,10)=stor->storage[index].identify; //identify flag - WFIFOB(fd,11)=stor->storage[index].attribute; // attribute - WFIFOB(fd,12)=stor->storage[index].refine; //refine - if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) { - WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w) - WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w) - WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w) - WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w) + WFIFOW(fd,8) =stor->storage_[index].nameid; // id + WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag + WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute + WFIFOB(fd,12)=stor->storage_[index].refine; //refine + if(stor->storage_[index].card[0]==0x00ff || stor->storage_[index].card[0]==0x00fe || stor->storage_[index].card[0]==(short)0xff00) { + WFIFOW(fd,13)=stor->storage_[index].card[0]; //card (4w) + WFIFOW(fd,15)=stor->storage_[index].card[1]; //card (4w) + WFIFOW(fd,17)=stor->storage_[index].card[2]; //card (4w) + WFIFOW(fd,19)=stor->storage_[index].card[3]; //card (4w) } else { - if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0) + if(stor->storage_[index].card[0] > 0 && (j=itemdb_viewid(stor->storage_[index].card[0])) > 0) WFIFOW(fd,13)= j; else - WFIFOW(fd,13)= stor->storage[index].card[0]; - if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0) + WFIFOW(fd,13)= stor->storage_[index].card[0]; + if(stor->storage_[index].card[1] > 0 && (j=itemdb_viewid(stor->storage_[index].card[1])) > 0) WFIFOW(fd,15)= j; else - WFIFOW(fd,15)= stor->storage[index].card[1]; - if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0) + WFIFOW(fd,15)= stor->storage_[index].card[1]; + if(stor->storage_[index].card[2] > 0 && (j=itemdb_viewid(stor->storage_[index].card[2])) > 0) WFIFOW(fd,17)= j; else - WFIFOW(fd,17)= stor->storage[index].card[2]; - if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0) + WFIFOW(fd,17)= stor->storage_[index].card[2]; + if(stor->storage_[index].card[3] > 0 && (j=itemdb_viewid(stor->storage_[index].card[3])) > 0) WFIFOW(fd,19)= j; else - WFIFOW(fd,19)= stor->storage[index].card[3]; + WFIFOW(fd,19)= stor->storage_[index].card[3]; } WFIFOSET(fd,packet_len_table[0xf4]); @@ -3442,35 +3442,35 @@ int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage WFIFOW(fd,0) =0xf4; // Storage item added WFIFOW(fd,2) =index+1; // index WFIFOL(fd,4) =amount; // amount - if((view = itemdb_viewid(stor->storage[index].nameid)) > 0) + if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0) WFIFOW(fd,8) =view; else - WFIFOW(fd,8) =stor->storage[index].nameid; // id - WFIFOB(fd,10)=stor->storage[index].identify; //identify flag - WFIFOB(fd,11)=stor->storage[index].attribute; // attribute - WFIFOB(fd,12)=stor->storage[index].refine; //refine - if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) { - WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w) - WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w) - WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w) - WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w) + WFIFOW(fd,8) =stor->storage_[index].nameid; // id + WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag + WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute + WFIFOB(fd,12)=stor->storage_[index].refine; //refine + if(stor->storage_[index].card[0]==0x00ff || stor->storage_[index].card[0]==0x00fe || stor->storage_[index].card[0]==(short)0xff00) { + WFIFOW(fd,13)=stor->storage_[index].card[0]; //card (4w) + WFIFOW(fd,15)=stor->storage_[index].card[1]; //card (4w) + WFIFOW(fd,17)=stor->storage_[index].card[2]; //card (4w) + WFIFOW(fd,19)=stor->storage_[index].card[3]; //card (4w) } else { - if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0) + if(stor->storage_[index].card[0] > 0 && (j=itemdb_viewid(stor->storage_[index].card[0])) > 0) WFIFOW(fd,13)= j; else - WFIFOW(fd,13)= stor->storage[index].card[0]; - if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0) + WFIFOW(fd,13)= stor->storage_[index].card[0]; + if(stor->storage_[index].card[1] > 0 && (j=itemdb_viewid(stor->storage_[index].card[1])) > 0) WFIFOW(fd,15)= j; else - WFIFOW(fd,15)= stor->storage[index].card[1]; - if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0) + WFIFOW(fd,15)= stor->storage_[index].card[1]; + if(stor->storage_[index].card[2] > 0 && (j=itemdb_viewid(stor->storage_[index].card[2])) > 0) WFIFOW(fd,17)= j; else - WFIFOW(fd,17)= stor->storage[index].card[2]; - if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0) + WFIFOW(fd,17)= stor->storage_[index].card[2]; + if(stor->storage_[index].card[3] > 0 && (j=itemdb_viewid(stor->storage_[index].card[3])) > 0) WFIFOW(fd,19)= j; else - WFIFOW(fd,19)= stor->storage[index].card[3]; + WFIFOW(fd,19)= stor->storage_[index].card[3]; } WFIFOSET(fd,packet_len_table[0xf4]); diff --git a/src/map/storage.c b/src/map/storage.c index 5e3797740..c9f4ffd62 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -46,13 +46,13 @@ struct item *i2=(struct item *)_i2; void sortage_sortitem(struct storage* stor){ nullpo_retv(stor); - qsort(stor->storage, MAX_STORAGE, sizeof(struct item), storage_comp_item); + qsort(stor->storage_, MAX_STORAGE, sizeof(struct item), storage_comp_item); } void sortage_gsortitem(struct guild_storage* gstor){ nullpo_retv(gstor); - qsort(gstor->storage, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item); + qsort(gstor->storage_, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item); } /*========================================== @@ -169,10 +169,10 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item if(!itemdb_isequip2(data)){ // 装備品ではないので、既所有品なら個数のみ変化させる for(i=0;istorage[i], item_data)) { - if(stor->storage[i].amount+amount > MAX_AMOUNT) + if( compare_item (&stor->storage_[i], item_data)) { + if(stor->storage_[i].amount+amount > MAX_AMOUNT) return 1; - stor->storage[i].amount+=amount; + stor->storage_[i].amount+=amount; clif_storageitemadded(sd,stor,i,amount); break; } @@ -181,9 +181,9 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item if(i>=MAX_STORAGE){ // 装備品か未所有品だったので空き欄へ追加 for(i=0;istorage[i].nameid==0){ - memcpy(&stor->storage[i],item_data,sizeof(stor->storage[0])); - stor->storage[i].amount=amount; + if(stor->storage_[i].nameid==0){ + memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0])); + stor->storage_[i].amount=amount; stor->storage_amount++; clif_storageitemadded(sd,stor,i,amount); clif_updatestorageamount(sd,stor); @@ -205,12 +205,12 @@ int storage_delitem(struct map_session_data *sd,struct storage *stor,int n,int a nullpo_retr(1, sd); nullpo_retr(1, stor); - if(stor->storage[n].nameid==0 || stor->storage[n].amountstorage_[n].nameid==0 || stor->storage_[n].amountstorage[n].amount-=amount; - if(stor->storage[n].amount==0){ - memset(&stor->storage[n],0,sizeof(stor->storage[0])); + stor->storage_[n].amount-=amount; + if(stor->storage_[n].amount==0){ + memset(&stor->storage_[n],0,sizeof(stor->storage_[0])); stor->storage_amount--; clif_updatestorageamount(sd,stor); } @@ -258,8 +258,8 @@ int storage_storageget(struct map_session_data *sd,int index,int amount) if(stor->storage_status == 1) { // storage open if(index>=0 && indexstorage[index].amount) && (amount > 0) ) { //valid amount - if((flag = pc_additem(sd,&stor->storage[index],amount)) == 0) + if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount + if((flag = pc_additem(sd,&stor->storage_[index],amount)) == 0) storage_delitem(sd,stor,index,amount); else clif_additem(sd,0,0,flag); @@ -305,8 +305,8 @@ int storage_storagegettocart(struct map_session_data *sd,int index,int amount) if(stor->storage_status == 1) { // storage open if(index>=0 && indexstorage[index].amount) && (amount > 0) ) { //valid amount - if(pc_cart_additem(sd,&stor->storage[index],amount)==0){ + if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount + if(pc_cart_additem(sd,&stor->storage_[index],amount)==0){ storage_delitem(sd,stor,index,amount); } } // valid amount @@ -454,10 +454,10 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor if(!itemdb_isequip2(data)){ // 装備品ではないので、既所有品なら個数のみ変化させる for(i=0;istorage[i], item_data)) { - if(stor->storage[i].amount+amount > MAX_AMOUNT) + if(compare_item(&stor->storage_[i], item_data)) { + if(stor->storage_[i].amount+amount > MAX_AMOUNT) return 1; - stor->storage[i].amount+=amount; + stor->storage_[i].amount+=amount; clif_guildstorageitemadded(sd,stor,i,amount); break; } @@ -466,9 +466,9 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor if(i>=MAX_GUILD_STORAGE){ // 装備品か未所有品だったので空き欄へ追加 for(i=0;istorage[i].nameid==0){ - memcpy(&stor->storage[i],item_data,sizeof(stor->storage[0])); - stor->storage[i].amount=amount; + if(stor->storage_[i].nameid==0){ + memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0])); + stor->storage_[i].amount=amount; stor->storage_amount++; clif_guildstorageitemadded(sd,stor,i,amount); clif_updateguildstorageamount(sd,stor); @@ -486,12 +486,12 @@ int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor nullpo_retr(1, sd); nullpo_retr(1, stor); - if(stor->storage[n].nameid==0 || stor->storage[n].amountstorage_[n].nameid==0 || stor->storage_[n].amountstorage[n].amount-=amount; - if(stor->storage[n].amount==0){ - memset(&stor->storage[n],0,sizeof(stor->storage[0])); + stor->storage_[n].amount-=amount; + if(stor->storage_[n].amount==0){ + memset(&stor->storage_[n],0,sizeof(stor->storage_[0])); stor->storage_amount--; clif_updateguildstorageamount(sd,stor); } @@ -531,8 +531,8 @@ int storage_guild_storageget(struct map_session_data *sd,int index,int amount) if((stor=guild2storage(sd->status.guild_id)) != NULL) { if(stor->storage_status == 1) { // storage open if(index>=0 && indexstorage[index].amount) && (amount > 0) ) { //valid amount - if((flag = pc_additem(sd,&stor->storage[index],amount)) == 0) + if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount + if((flag = pc_additem(sd,&stor->storage_[index],amount)) == 0) guild_storage_delitem(sd,stor,index,amount); else clif_additem(sd,0,0,flag); @@ -573,8 +573,8 @@ int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amo if((stor=guild2storage(sd->status.guild_id)) != NULL) { if(stor->storage_status == 1) { // storage open if(index>=0 && indexstorage[index].amount) && (amount > 0) ) { //valid amount - if(pc_cart_additem(sd,&stor->storage[index],amount)==0){ + if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount + if(pc_cart_additem(sd,&stor->storage_[index],amount)==0){ guild_storage_delitem(sd,stor,index,amount); } } // valid amount -- cgit v1.2.3-70-g09d2