summaryrefslogtreecommitdiff
path: root/src/map/guild.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-07 21:04:28 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-07 21:04:28 +0000
commit1792fa7dcbae6d0678d9672ccb38eba88e87c757 (patch)
tree24189c639a4ac9a340a3c0dfd9060630e779b157 /src/map/guild.c
parent44f46558e22a2b6c7287a233767bbcb713e25f55 (diff)
downloadhercules-1792fa7dcbae6d0678d9672ccb38eba88e87c757.tar.gz
hercules-1792fa7dcbae6d0678d9672ccb38eba88e87c757.tar.bz2
hercules-1792fa7dcbae6d0678d9672ccb38eba88e87c757.tar.xz
hercules-1792fa7dcbae6d0678d9672ccb38eba88e87c757.zip
* Made script command 'flagemblem' and guild_emblem_change send an update of the emblem_id to the players in the area.
- known bug: ui components that are displaying the emblem at the time (emblem in flag npc and emblem over head in gvg maps) are not updated, but putting the mouse over the target shows the new emblem * Modified script command 'guardian': - returns the id of the guardian - if guardian index isn't supplied, it generates a temporary guardian * Implemented support for temporary guardians (not saved with castle). * Added missing includes from r12520. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12525 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/guild.c')
-rw-r--r--src/map/guild.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index f02deb16c..473599cc7 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -1103,8 +1103,49 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
sd->guild_emblem_id=emblem_id;
clif_guild_belonginfo(sd,g);
clif_guild_emblem(sd,g);
+ clif_guild_emblem_area(&sd->bl);
}
}
+ {// update guardians (mobs)
+ DBIterator* iter = db_iterator(castle_db);
+ struct guild_castle* gc;
+ for( gc = (struct guild_castle*)dbi_first(iter) ; dbi_exists(iter); gc = (struct guild_castle*)dbi_next(iter) )
+ {
+ if( gc->guild_id != guild_id )
+ continue;
+ // update permanent guardians
+ for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i )
+ {
+ TBL_MOB* md = (gc->guardian[i].id ? map_id2md(gc->guardian[i].id) : NULL);
+ if( md == NULL || md->guardian_data == NULL )
+ continue;
+ md->guardian_data->emblem_id = emblem_id;
+ clif_guild_emblem_area(&md->bl);
+ }
+ // update temporary guardians
+ for( i = 0; i < gc->temp_guardians_max; ++i )
+ {
+ TBL_MOB* md = (gc->temp_guardians[i] ? map_id2md(gc->temp_guardians[i]) : NULL);
+ if( md == NULL || md->guardian_data == NULL )
+ continue;
+ md->guardian_data->emblem_id = emblem_id;
+ clif_guild_emblem_area(&md->bl);
+ }
+ }
+ dbi_destroy(iter);
+ }
+ {// update npcs (flags or other npcs that used flagemblem to attach to this guild)
+ // TODO this is not efficient [FlavioJS]
+ struct s_mapiterator* iter = mapit_geteachnpc();
+ TBL_NPC* nd;
+ for( nd = (TBL_NPC*)mapit_first(iter) ; mapit_exists(iter); nd = (TBL_NPC*)mapit_next(iter) )
+ {
+ if( nd->subtype != SCRIPT || nd->u.scr.guild_id != guild_id )
+ continue;
+ clif_guild_emblem_area(&nd->bl);
+ }
+ mapit_free(iter);
+ }
return 0;
}
@@ -1909,10 +1950,19 @@ static int guild_expcache_db_final(DBKey key,void *data,va_list ap)
return 0;
}
+static int guild_castle_db_final(DBKey key, void* data,va_list ap)
+{
+ struct guild_castle* gc = (struct guild_castle*)data;
+ if( gc->temp_guardians )
+ aFree(gc->temp_guardians);
+ aFree(data);
+ return 0;
+}
+
void do_init_guild(void)
{
guild_db=idb_alloc(DB_OPT_RELEASE_DATA);
- castle_db=idb_alloc(DB_OPT_RELEASE_DATA);
+ castle_db=idb_alloc(DB_OPT_BASE);
guild_expcache_db=idb_alloc(DB_OPT_BASE);
guild_infoevent_db=idb_alloc(DB_OPT_BASE);
expcache_ers = ers_new(sizeof(struct guild_expcache));
@@ -1932,7 +1982,7 @@ void do_init_guild(void)
void do_final_guild(void)
{
guild_db->destroy(guild_db,NULL);
- castle_db->destroy(castle_db,NULL);
+ castle_db->destroy(castle_db,guild_castle_db_final);
guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final);
guild_infoevent_db->destroy(guild_infoevent_db,guild_infoevent_db_final);
guild_castleinfoevent_db->destroy(guild_castleinfoevent_db,guild_infoevent_db_final);