summaryrefslogtreecommitdiff
path: root/src/map/guild.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-24 12:14:18 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-24 12:14:18 +0000
commit3ecde465534c93315a1f88430129e8400f4d9fe2 (patch)
treefb1153e7be48da7d89b9697be733124650045fdf /src/map/guild.c
parent04580084c4ac2113d06a23fdf2ca4596dd04011b (diff)
downloadhercules-3ecde465534c93315a1f88430129e8400f4d9fe2.tar.gz
hercules-3ecde465534c93315a1f88430129e8400f4d9fe2.tar.bz2
hercules-3ecde465534c93315a1f88430129e8400f4d9fe2.tar.xz
hercules-3ecde465534c93315a1f88430129e8400f4d9fe2.zip
* Cleaned up some messy guild code (more to come)
* Cleaned up the mail code, no more pointless dynamic allocation * Added upgrade_svn11548.sql to convert the mail table to new format * Updated vs7 and vs6 project files * Increased the max. send buffer size to 5M since 1M is not enough * Please complain if something stops working ^^; git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11571 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/guild.c')
-rw-r--r--src/map/guild.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index 1fda18d9f..12577a8fd 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -475,21 +475,23 @@ int guild_request_info(int guild_id)
// イベント付き情報要求
int guild_npc_request_info(int guild_id,const char *event)
{
- struct eventlist *ev;
-
- if( guild_search(guild_id) ){
- if(event && *event)
+ if( guild_search(guild_id) )
+ {
+ if( event && *event )
npc_event_do(event);
+
return 0;
}
- if(event==NULL || *event==0)
- return guild_request_info(guild_id);
+ if( event && *event )
+ {
+ struct eventlist* ev;
+ ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
+ memcpy(ev->name,event,strlen(event));
+ //The one in the db becomes the next event from this.
+ ev->next=idb_put(guild_infoevent_db,guild_id,ev);
+ }
- ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
- memcpy(ev->name,event,strlen(event));
- //The one in the db becomes the next event from this.
- ev->next=idb_put(guild_infoevent_db,guild_id,ev);
return guild_request_info(guild_id);
}
@@ -1723,8 +1725,8 @@ int guild_castledataloadack(int castle_id,int index,int value)
switch(index){
case 1:
gc->guild_id = value;
- if (value && guild_search(value)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
- guild_request_info(value);
+ if (gc->guild_id && guild_search(gc->guild_id)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
+ guild_request_info(gc->guild_id);
break;
case 2: gc->economy = value; break;
case 3: gc->defense = value; break;
@@ -1826,34 +1828,39 @@ int guild_castledatasaveack(int castle_id,int index,int value)
int guild_castlealldataload(int len,struct guild_castle *gc)
{
int i;
- int n = (len-4) / sizeof(struct guild_castle), ev = -1;
+ int n = (len-4) / sizeof(struct guild_castle);
+ int ev;
nullpo_retr(0, gc);
//Last owned castle in the list invokes ::OnAgitinit
- for(i = 0; i < n; i++) {
- if ((gc + i)->guild_id)
- ev = i;
- }
+ for( i = n-1; i >= 0 && !(gc[i].guild_id); --i );
+ ev = i; // offset of castle or -1
- // 城データ格納とギルド情報要求
- for(i = 0; i < n; i++, gc++) {
+ // load received castles into memory, one by one
+ for( i = 0; i < n; i++, gc++ )
+ {
struct guild_castle *c = guild_castle_search(gc->castle_id);
if (!c) {
ShowError("guild_castlealldataload Castle id=%d not found.\n", gc->castle_id);
continue;
}
- memcpy(&c->guild_id,&gc->guild_id,
- sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c) );
- if( c->guild_id ){
- if(i!=ev)
+
+ // update mapserver castle data with new info
+ memcpy(&c->guild_id, &gc->guild_id, sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c));
+
+ if( c->guild_id )
+ {
+ if( i != ev )
guild_request_info(c->guild_id);
- else
+ else // last owned one
guild_npc_request_info(c->guild_id, "::OnAgitInit");
}
}
- if (ev == -1) //No castles owned, invoke OnAgitInit as it is.
+
+ if( ev < 0 ) //No castles owned, invoke OnAgitInit as it is.
npc_event_doall("OnAgitInit");
+
return 0;
}