summaryrefslogtreecommitdiff
path: root/src/map/guild.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/guild.c')
-rw-r--r--src/map/guild.c130
1 files changed, 93 insertions, 37 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index 30f989f58..27c3b71a9 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -11,6 +11,7 @@
#include "../common/ers.h"
#include "../common/strlib.h"
#include "../common/utils.h"
+#include "../common/HPM.h"
#include "map.h"
#include "guild.h"
@@ -124,14 +125,14 @@ int guild_check_skill_require(struct guild *g,int id)
bool guild_read_castledb(char* str[], int columns, int current)
{// <castle id>,<map name>,<castle name>,<castle event>[,<reserved/unused switch flag>]
struct guild_castle *gc;
- int mapindex = mapindex_name2id(str[1]);
+ int index = mapindex->name2id(str[1]);
- if (map->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server
+ if (map->mapindex2mapid(index) < 0) // Map not found or on another map-server
return false;
CREATE(gc, struct guild_castle, 1);
gc->castle_id = atoi(str[0]);
- gc->mapindex = mapindex;
+ gc->mapindex = index;
safestrncpy(gc->castle_name, str[2], sizeof(gc->castle_name));
safestrncpy(gc->castle_event, str[3], sizeof(gc->castle_event));
@@ -171,14 +172,14 @@ struct guild_castle* guild_castle_search(int gcid)
}
/// lookup: map index -> castle*
-struct guild_castle* guild_mapindex2gc(short mapindex)
+struct guild_castle* guild_mapindex2gc(short map_index)
{
struct guild_castle* gc;
DBIterator *iter = db_iterator(guild->castle_db);
for( gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter) )
{
- if( gc->mapindex == mapindex )
+ if( gc->mapindex == map_index )
break;
}
dbi_destroy(iter);
@@ -189,7 +190,7 @@ struct guild_castle* guild_mapindex2gc(short mapindex)
/// lookup: map name -> castle*
struct guild_castle* guild_mapname2gc(const char* mapname)
{
- return guild->mapindex2gc(mapindex_name2id(mapname));
+ return guild->mapindex2gc(mapindex->name2id(mapname));
}
struct map_session_data* guild_getavailablesd(struct guild* g)
@@ -279,8 +280,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) {
return 0;
}
-int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data)
-{
+int guild_payexp_timer(int tid, int64 tick, int id, intptr_t data) {
guild->expcache_db->clear(guild->expcache_db,guild->payexp_timer_sub);
return 0;
}
@@ -314,8 +314,7 @@ int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
}
//Code from party_send_xy_timer [Skotlex]
-int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data)
-{
+int guild_send_xy_timer(int tid, int64 tick, int id, intptr_t data) {
guild->db->foreach(guild->db,guild->send_xy_timer_sub,tick);
return 0;
}
@@ -456,7 +455,7 @@ int guild_recv_info(struct guild *sg) {
DBData data;
struct map_session_data *sd;
bool guild_new = false;
- void *aChSysSave = NULL;
+ struct hChSysCh *aChSysSave = NULL;
nullpo_ret(sg);
@@ -496,8 +495,8 @@ int guild_recv_info(struct guild *sg) {
if( sg->alliance[i].guild_id == sd->status.guild_id ) {
clif->chsys_join(channel,sd);
} else if( tg[i] != NULL ) {
- if( !(((struct hChSysCh*)tg[i]->channel)->banned && idb_exists(((struct hChSysCh*)tg[i]->channel)->banned, sd->status.account_id)))
- clif->chsys_join((struct hChSysCh*)tg[i]->channel,sd);
+ if( !(tg[i]->channel->banned && idb_exists(tg[i]->channel->banned, sd->status.account_id)))
+ clif->chsys_join(tg[i]->channel,sd);
}
}
}
@@ -508,7 +507,7 @@ int guild_recv_info(struct guild *sg) {
}
- aChSysSave = (void*)channel;
+ aChSysSave = channel;
}
before=*sg;
@@ -727,14 +726,14 @@ void guild_member_joined(struct map_session_data *sd)
if( hChSys.ally && hChSys.ally_autojoin ) {
struct guild* sg = NULL;
- struct hChSysCh *channel = (struct hChSysCh*)g->channel;
+ struct hChSysCh *channel = g->channel;
if( !(channel->banned && idb_exists(channel->banned, sd->status.account_id) ) )
clif->chsys_join(channel,sd);
for (i = 0; i < MAX_GUILDALLIANCE; i++) {
if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild->search(g->alliance[i].guild_id) ) ) {
- if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
- clif->chsys_join((struct hChSysCh*)sg->channel,sd);
+ if( !(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id)))
+ clif->chsys_join(sg->channel,sd);
}
}
}
@@ -867,6 +866,11 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
online_member_sd = guild->getavailablesd(g);
if(online_member_sd == NULL)
return 0; // noone online to inform
+
+#ifdef GP_BOUND_ITEMS
+ //Guild bound item check
+ guild->retrieveitembound(char_id,account_id,guild_id);
+#endif
if(!flag)
clif->guild_leave(online_member_sd, name, mes);
@@ -901,6 +905,28 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
return 0;
}
+void guild_retrieveitembound(int char_id,int aid,int guild_id) {
+#ifdef GP_BOUND_ITEMS
+ TBL_PC *sd = map->id2sd(aid);
+ if(sd){ //Character is online
+ pc->bound_clear(sd,IBT_GUILD);
+ } else { //Character is offline, ask char server to do the job
+ struct guild_storage *gstor = gstorage->id2storage2(guild_id);
+ if(gstor && gstor->storage_status == 1) { //Someone is in guild storage, close them
+ struct s_mapiterator* iter = mapit_getallusers();
+ for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) {
+ if(sd->status.guild_id == guild_id && sd->state.storage_flag == 2) {
+ gstorage->close(sd);
+ break;
+ }
+ }
+ mapit->free(iter);
+ }
+ intif->itembound_req(char_id,aid,guild_id);
+ }
+#endif
+}
+
int guild_send_memberinfoshort(struct map_session_data *sd,int online)
{ // cleaned up [LuzZza]
struct guild *g;
@@ -1299,7 +1325,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id) {
if(g==NULL)
return 0;
if( sd != NULL ) {
- clif->guild_skillup(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv);
+ clif->skillup(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv, 0);
/* Guild Aura handling */
switch( skill_id ) {
@@ -1334,7 +1360,7 @@ void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint1
}
group = skill->unitsetting(&sd->bl,skill_id,skill_lv,sd->bl.x,sd->bl.y,0);
if( group ) {
- sc_start4(&sd->bl,type,100,(battle_config.guild_aura&16)?0:skill_lv,0,0,group->group_id,600000);//duration doesn't matter these status never end with val4
+ sc_start4(NULL,&sd->bl,type,100,(battle_config.guild_aura&16)?0:skill_lv,0,0,group->group_id,600000);//duration doesn't matter these status never end with val4
}
return;
}
@@ -1365,7 +1391,7 @@ void guild_block_skill(struct map_session_data *sd, int time)
uint16 skill_id[] = { GD_BATTLEORDER, GD_REGENERATION, GD_RESTORE, GD_EMERGENCYCALL };
int i;
for (i = 0; i < 4; i++)
- skill->blockpc_start(sd, skill_id[i], time , true);
+ skill->blockpc_start(sd, skill_id[i], time);
}
/*====================================================
@@ -1569,10 +1595,10 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd)
* Notification of a relationship between 2 guilds
*---------------------------------------------------*/
int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) {
- struct guild *g[2];
- int guild_id[2];
- const char *guild_name[2];
- struct map_session_data *sd[2];
+ struct guild *g[2] = { NULL };
+ int guild_id[2] = { 0 };
+ const char *guild_name[2] = { NULL };
+ struct map_session_data *sd[2] = { NULL };
int j,i;
guild_id[0] = guild_id1;
@@ -1639,11 +1665,11 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members
- struct map_session_data *sd;
+ struct map_session_data *msd;
if(g[i]!=NULL)
for(j=0;j<g[i]->max_member;j++)
- if((sd=g[i]->member[j].sd)!=NULL)
- clif->guild_allianceinfo(sd);
+ if((msd=g[i]->member[j].sd)!=NULL)
+ clif->guild_allianceinfo(msd);
}
return 0;
}
@@ -1728,9 +1754,21 @@ int guild_broken(int guild_id,int flag)
gstorage->delete(guild_id);
if( hChSys.ally ) {
if( g->channel != NULL ) {
- clif->chsys_delete(( struct hChSysCh * )g->channel);
+ clif->chsys_delete(g->channel);
+ }
+ }
+ if( g->instance )
+ aFree(g->instance);
+
+ for( i = 0; i < g->hdatac; i++ ) {
+ if( g->hdata[i]->flag.free ) {
+ aFree(g->hdata[i]->data);
}
+ aFree(g->hdata[i]);
}
+ if( g->hdata )
+ aFree(g->hdata);
+
idb_remove(guild->db,guild_id);
return 0;
}
@@ -1815,7 +1853,7 @@ int guild_break(struct map_session_data *sd,char *name) {
struct guild *g;
struct unit_data *ud;
int i;
-
+
nullpo_ret(sd);
if( (g=sd->guild)==NULL )
@@ -1857,6 +1895,10 @@ int guild_break(struct map_session_data *sd,char *name) {
skill->del_unitgroup(groups[i],ALC_MARK);
}
}
+
+#ifdef GP_BOUND_ITEMS
+ pc->bound_clear(sd,IBT_GUILD);
+#endif
intif->guild_break(g->guild_id);
return 1;
@@ -1925,7 +1967,7 @@ int guild_castledatasave(int castle_id, int index, int value)
gc->defense = value;
for (i = 0; i < MAX_GUARDIANS; i++)
if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL)
- status_calc_mob(gd, 0);
+ status_calc_mob(gd, SCO_NONE);
break;
}
case 4:
@@ -2174,12 +2216,15 @@ void guild_flags_clear(void) {
guild->flags_count = 0;
}
-void do_init_guild(void) {
- guild->db = idb_alloc(DB_OPT_RELEASE_DATA);
- guild->castle_db = idb_alloc(DB_OPT_BASE);
- guild->expcache_db = idb_alloc(DB_OPT_BASE);
- guild->infoevent_db = idb_alloc(DB_OPT_BASE);
- guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE);
+void do_init_guild(bool minimal) {
+ if (minimal)
+ return;
+
+ guild->db = idb_alloc(DB_OPT_RELEASE_DATA);
+ guild->castle_db = idb_alloc(DB_OPT_BASE);
+ guild->expcache_db = idb_alloc(DB_OPT_BASE);
+ guild->infoevent_db = idb_alloc(DB_OPT_BASE);
+ guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE);
sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, guild->read_castledb);
@@ -2194,14 +2239,23 @@ void do_init_guild(void) {
void do_final_guild(void) {
DBIterator *iter = db_iterator(guild->db);
struct guild *g;
+ int i;
for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) {
if( g->channel != NULL )
- clif->chsys_delete((struct hChSysCh *)g->channel);
+ clif->chsys_delete(g->channel);
if( g->instance != NULL ) {
aFree(g->instance);
g->instance = NULL;
}
+ for( i = 0; i < g->hdatac; i++ ) {
+ if( g->hdata[i]->flag.free ) {
+ aFree(g->hdata[i]->data);
+ }
+ aFree(g->hdata[i]);
+ }
+ if( g->hdata )
+ aFree(g->hdata);
}
dbi_destroy(iter);
@@ -2327,4 +2381,6 @@ void guild_defaults(void) {
guild->check_member = guild_check_member;
guild->get_alliance_count = guild_get_alliance_count;
guild->castle_reconnect_sub = guild_castle_reconnect_sub;
+ /* */
+ guild->retrieveitembound = guild_retrieveitembound;
}