summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-09 23:18:03 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-09 23:18:03 +0000
commit18ec7de528b88d581e3ad10c03f6b8244b207630 (patch)
tree2587521b2a35c6d1bd8953de589a1fbe27607873
parent91d87f7a903545b70e23e3aa0edbd2e3ee2b67bc (diff)
downloadhercules-18ec7de528b88d581e3ad10c03f6b8244b207630.tar.gz
hercules-18ec7de528b88d581e3ad10c03f6b8244b207630.tar.bz2
hercules-18ec7de528b88d581e3ad10c03f6b8244b207630.tar.xz
hercules-18ec7de528b88d581e3ad10c03f6b8244b207630.zip
* Removed some of the duplicate, storage-related packet code.
- Removed clif_guildstoragelist and adjusted clif_storagelist to be able to handle any kind of storage. - Removed clif_guildstorageitemadded in favor of clif_storageitemadded. - This also fixes clif_guildstorageitemadded sending old update packet for clients prior 20090603, although packet 0x1c4 (ZC_ADD_ITEM_TO_STORE2) was added before PACKETVER 5 (before 2003-11-03aSakexe, exact addition date unknown) (since r14286). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14571 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt5
-rw-r--r--src/map/clif.c140
-rw-r--r--src/map/clif.h4
-rw-r--r--src/map/intif.c2
-rw-r--r--src/map/storage.c8
5 files changed, 23 insertions, 136 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index e7192b451..98244e556 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,5 +1,10 @@
Date Added
+2010/12/09
+ * Removed some of the duplicate, storage-related packet code. [Ai4rei]
+ - Removed clif_guildstoragelist and adjusted clif_storagelist to be able to handle any kind of storage.
+ - Removed clif_guildstorageitemadded in favor of clif_storageitemadded.
+ - This also fixes clif_guildstorageitemadded sending old update packet for clients prior 20090603, although packet 0x1c4 (ZC_ADD_ITEM_TO_STORE2) was added before PACKETVER 5 (before 2003-11-03aSakexe, exact addition date unknown) (since r14286).
2010/12/08
* Applied some script command documentation updates and fixes as already done inside the wiki. [Ai4rei]
- Updated description for 'next', 'return', 'attachrid', 'detachrid', 'itemskill', 'openstorage', 'skilleffect', 'donpcevent', 'day', 'night', 'atoi' and 'axtoi' to resolve inaccuracies, missing information or unverified behavior.
diff --git a/src/map/clif.c b/src/map/clif.c
index 29064fe31..0e4fa9104 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2154,7 +2154,7 @@ void clif_equiplist(struct map_session_data *sd)
}
}
-void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
+void clif_storagelist(struct map_session_data* sd, struct item* items, int items_length)
{
struct item_data *id;
int i,n,ne;
@@ -2175,21 +2175,21 @@ void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
const int cmd = 28;
#endif
- buf = (unsigned char*)aMallocA(MAX_STORAGE * s + 4);
- bufe = (unsigned char*)aMallocA(MAX_STORAGE * cmd + 4);
+ buf = (unsigned char*)aMallocA(items_length * s + 4);
+ bufe = (unsigned char*)aMallocA(items_length * cmd + 4);
- for( i = 0, n = 0, ne = 0; i < MAX_STORAGE; i++ )
+ for( i = 0, n = 0, ne = 0; i < items_length; i++ )
{
- if( stor->items[i].nameid <= 0 )
+ if( items[i].nameid <= 0 )
continue;
- id = itemdb_search(stor->items[i].nameid);
+ id = itemdb_search(items[i].nameid);
if( !itemdb_isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+1;
- clif_item_sub(bufe, ne*cmd+6, &stor->items[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*cmd+16), &stor->items[i]);
+ clif_item_sub(bufe, ne*cmd+6, &items[i], id, id->equip);
+ clif_addcards(WBUFP(bufe, ne*cmd+16), &items[i]);
#if PACKETVER >= 20071002
- WBUFL(bufe,ne*cmd+24)=stor->items[i].expire_time;
+ WBUFL(bufe,ne*cmd+24)=items[i].expire_time;
WBUFW(bufe,ne*cmd+28)=0; //Unknown
#endif
ne++;
@@ -2197,93 +2197,12 @@ void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
else
{ //Stackable
WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->items[i], id,-1);
+ clif_item_sub(buf, n*s+6, &items[i], id,-1);
#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->items[i]);
+ clif_addcards(WBUFP(buf,n*s+14), &items[i]);
#endif
#if PACKETVER >= 20080102
- WBUFL(buf,n*s+22)=stor->items[i].expire_time;
-#endif
- n++;
- }
- }
- if( n )
- {
-#if PACKETVER < 5
- WBUFW(buf,0)=0xa5;
-#elif PACKETVER < 20080102
- WBUFW(buf,0)=0x1f0;
-#else
- WBUFW(buf,0)=0x2ea;
-#endif
- WBUFW(buf,2)=4+n*s;
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
- }
- if( ne )
- {
-#if PACKETVER < 20071002
- WBUFW(bufe,0)=0xa6;
-#else
- WBUFW(bufe,0)=0x2d1;
-#endif
- WBUFW(bufe,2)=4+ne*cmd;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
-
- if( buf ) aFree(buf);
- if( bufe ) aFree(bufe);
-}
-
-//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor)
-{
- struct item_data *id;
- int i,n,ne;
- unsigned char *buf;
- unsigned char *bufe;
-#if PACKETVER < 5
- const int s = 10; //Entry size.
-#elif PACKETVER < 20080102
- const int s = 18;
-#else
- const int s = 22;
-#endif
-#if PACKETVER < 20071002
- const int cmd = 20;
-#elif PACKETVER < 20100629
- const int cmd = 26;
-#else
- const int cmd = 28;
-#endif
-
- buf = (unsigned char*)aMallocA(MAX_GUILD_STORAGE * s + 4);
- bufe = (unsigned char*)aMallocA(MAX_GUILD_STORAGE * cmd + 4);
-
- for( i = 0, n = 0, ne = 0; i < MAX_GUILD_STORAGE; i++ )
- {
- if( stor->storage_[i].nameid <= 0 )
- continue;
- id = itemdb_search(stor->storage_[i].nameid);
- if( !itemdb_isstackable2(id) )
- { //Equippable
- WBUFW(bufe,ne*cmd+4)=i+1;
- clif_item_sub(bufe, ne*cmd+6, &stor->storage_[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*cmd+16), &stor->storage_[i]);
-#if PACKETVER >= 20071002
- WBUFL(bufe,ne*cmd+24)=stor->storage_[i].expire_time;
- WBUFW(bufe,ne*cmd+28)=0; //Unknown
-#endif
- ne++;
- }
- else
- { //Stackable
- WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
-#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
-#endif
-#if PACKETVER >= 20080102
- WBUFL(buf,n*s+22)=stor->storage_[i].expire_time;
+ WBUFL(buf,n*s+22)=items[i].expire_time;
#endif
n++;
}
@@ -3674,41 +3593,6 @@ void clif_updateguildstorageamount(struct map_session_data* sd, int amount)
}
/*==========================================
- *
- *------------------------------------------*/
-void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount)
-{
- int view,fd;
- unsigned char *buf;
-#if PACKETVER < 20090603
- const int cmd = 0xf4;
-#else
- const int cmd = 0x1c4;
-#endif
-
- nullpo_retv(sd);
- nullpo_retv(i);
- fd=sd->fd;
- view = itemdb_viewid(i->nameid);
- buf = WFIFOP(fd,0);
-
- WFIFOHEAD(fd,packet_len(cmd));
- WBUFW(buf, 0) = cmd; // Storage item added
- WBUFW(buf, 2) = index+1; // index
- WBUFL(buf, 4) = amount; // amount
- WBUFW(buf, 8) = ( view > 0 ) ? view : i->nameid; // id
-#if PACKETVER >= 20090603
- WBUFB(buf,10) = itemdb_type(i->nameid); //type
- buf = WBUFP(buf,1); //Advance 1B
-#endif
- WBUFB(buf,10) = i->identify; //identify flag
- WBUFB(buf,11) = i->attribute; // attribute
- WBUFB(buf,12) = i->refine; //refine
- clif_addcards(WBUFP(buf,13), i);
- WFIFOSET(fd,packet_len(cmd));
-}
-
-/*==========================================
* カプラ倉庫からアイテムを取り去る
*------------------------------------------*/
void clif_storageitemremoved(struct map_session_data* sd, int index, int amount)
diff --git a/src/map/clif.h b/src/map/clif.h
index cbb8e634f..1af527d1e 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -270,14 +270,12 @@ void clif_tradecompleted(struct map_session_data* sd, int fail);
// storage
#include "storage.h"
-void clif_storagelist(struct map_session_data* sd, struct storage_data* stor);
+void clif_storagelist(struct map_session_data* sd, struct item* items, int items_length);
void clif_updatestorageamount(struct map_session_data* sd, int amount);
void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
void clif_storageitemremoved(struct map_session_data* sd, int index, int amount);
void clif_storageclose(struct map_session_data* sd);
-void clif_guildstoragelist(struct map_session_data* sd, struct guild_storage* stor);
void clif_updateguildstorageamount(struct map_session_data* sd, int amount);
-void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
int clif_insight(struct block_list *,va_list); // map_forallinmovearea callback
int clif_outsight(struct block_list *,va_list); // map_forallinmovearea callback
diff --git a/src/map/intif.c b/src/map/intif.c
index 15d948c59..98e8c0feb 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -986,7 +986,7 @@ int intif_parse_LoadGuildStorage(int fd)
memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
gstor->storage_status = 1;
sd->state.storage_flag = 2;
- clif_guildstoragelist(sd,gstor);
+ clif_storagelist(sd, gstor->storage_, ARRAYLENGTH(gstor->storage_));
clif_updateguildstorageamount(sd,gstor->storage_amount);
return 0;
}
diff --git a/src/map/storage.c b/src/map/storage.c
index 8960f7203..2e668f08d 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -104,7 +104,7 @@ int storage_storageopen(struct map_session_data *sd)
}
sd->state.storage_flag = 1;
- clif_storagelist(sd,&sd->status.storage);
+ clif_storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif_updatestorageamount(sd,sd->status.storage.storage_amount);
return 0;
}
@@ -380,7 +380,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
gstor->storage_status = 1;
sd->state.storage_flag = 2;
- clif_guildstoragelist(sd,gstor);
+ clif_storagelist(sd, gstor->storage_, ARRAYLENGTH(gstor->storage_));
clif_updateguildstorageamount(sd,gstor->storage_amount);
return 0;
}
@@ -410,7 +410,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
if(stor->storage_[i].amount+amount > MAX_AMOUNT)
return 1;
stor->storage_[i].amount+=amount;
- clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
+ clif_storageitemadded(sd,&stor->storage_[i],i,amount);
stor->dirty = 1;
if(log_config.enable_logs&0x1000)
log_pick_pc(sd, "G", item_data->nameid, -amount, item_data);
@@ -427,7 +427,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0]));
stor->storage_[i].amount=amount;
stor->storage_amount++;
- clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
+ clif_storageitemadded(sd,&stor->storage_[i],i,amount);
clif_updateguildstorageamount(sd,stor->storage_amount);
stor->dirty = 1;
if(log_config.enable_logs&0x1000)