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.c76
1 files changed, 42 insertions, 34 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index b83f05f00..b28c14db7 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -24,6 +24,7 @@
#include "clif.h"
#include "skill.h"
#include "log.h"
+#include "instance.h"
#include <stdio.h>
#include <stdlib.h>
@@ -75,7 +76,7 @@ unsigned short guild_flags_count;
*------------------------------------------*/
static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id)
{
- TBL_PC* sd = map_id2sd(account_id);
+ TBL_PC* sd = iMap->id2sd(account_id);
if (!(sd && sd->status.char_id == char_id))
return NULL;
@@ -166,7 +167,7 @@ static bool guild_read_castledb(char* str[], int columns, int current)
struct guild_castle *gc;
int mapindex = mapindex_name2id(str[1]);
- if (map_mapindex2mapid(mapindex) < 0) // Map not found or on another map-server
+ if (iMap->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server
return false;
CREATE(gc, struct guild_castle, 1);
@@ -385,7 +386,7 @@ int guild_create(struct map_session_data *sd, const char *name)
clif->guild_created(sd,1);
return 0;
}
- if( battle_config.guild_emperium_check && pc_search_inventory(sd,714) == -1 )
+ if( battle_config.guild_emperium_check && pc->search_inventory(sd,714) == -1 )
{// item required
clif->guild_created(sd,3);
return 0;
@@ -399,7 +400,7 @@ int guild_create(struct map_session_data *sd, const char *name)
//Whether or not to create guild
int guild_created(int account_id,int guild_id) {
- struct map_session_data *sd=map_id2sd(account_id);
+ struct map_session_data *sd=iMap->id2sd(account_id);
if(sd==NULL)
return 0;
@@ -411,7 +412,7 @@ int guild_created(int account_id,int guild_id) {
sd->status.guild_id=guild_id;
clif->guild_created(sd,0);
if(battle_config.guild_emperium_check)
- pc_delitem(sd,pc_search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
+ pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
return 0;
}
@@ -503,6 +504,8 @@ int guild_recv_info(struct guild *sg) {
if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) {
guild_new = true;
g=(struct guild *)aCalloc(1,sizeof(struct guild));
+ g->instance = NULL;
+ g->instances = 0;
idb_put(guild_db,sg->guild_id,g);
if( hChSys.ally ) {
struct hChSysCh *channel;
@@ -552,7 +555,7 @@ int guild_recv_info(struct guild *sg) {
before=*sg;
//Perform the check on the user because the first load
guild_check_member(sg);
- if ((sd = map_nick2sd(sg->master)) != NULL) {
+ if ((sd = iMap->nick2sd(sg->master)) != NULL) {
//If the guild master is online the first time the guild_info is received,
//that means he was the first to join, so apply guild skill blocking here.
if( battle_config.guild_skill_relog_delay )
@@ -659,7 +662,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
if(tsd->status.guild_id>0 ||
tsd->guild_invite>0 ||
- ((agit_flag || agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
{ //Can't invite people inside castles. [Skotlex]
clif->guild_inviteack(sd,0);
return 0;
@@ -693,7 +696,7 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag)
// look up the person who sent the invite
//NOTE: this can be NULL because the person might have logged off in the meantime
- tsd = map_id2sd(sd->guild_invite_account);
+ tsd = iMap->id2sd(sd->guild_invite_account);
if ( sd->status.guild_id > 0 ) // [Paradox924X]
{ // Already in another guild.
@@ -785,7 +788,7 @@ void guild_member_joined(struct map_session_data *sd)
*----------------------------------------*/
int guild_member_added(int guild_id,int account_id,int char_id,int flag)
{
- struct map_session_data *sd= map_id2sd(account_id),*sd2;
+ struct map_session_data *sd= iMap->id2sd(account_id),*sd2;
struct guild *g;
if( (g=guild->search(guild_id))==NULL )
@@ -799,7 +802,7 @@ int guild_member_added(int guild_id,int account_id,int char_id,int flag)
}
return 0;
}
- sd2 = map_id2sd(sd->guild_invite_account);
+ sd2 = iMap->id2sd(sd->guild_invite_account);
sd->guild_invite = 0;
sd->guild_invite_account = 0;
@@ -844,7 +847,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c
if(sd->status.account_id!=account_id ||
sd->status.char_id!=char_id || sd->status.guild_id!=guild_id ||
- ((agit_flag || agit2_flag) && map[sd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[sd->bl.m].flag.gvg_castle))
return 0;
intif_guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes);
@@ -874,9 +877,9 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i
return 0; //Expulsion permission
//Can't leave inside guild castles.
- if ((tsd = map_id2sd(account_id)) &&
+ if ((tsd = iMap->id2sd(account_id)) &&
tsd->status.char_id == char_id &&
- ((agit_flag || agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
return 0;
// find the member and perform expulsion
@@ -891,7 +894,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
{
int i;
struct guild* g = guild->search(guild_id);
- struct map_session_data* sd = map_charid2sd(char_id);
+ struct map_session_data* sd = iMap->charid2sd(char_id);
struct map_session_data* online_member_sd;
if(g == NULL)
@@ -926,7 +929,8 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
sd->status.guild_id = 0;
sd->guild = NULL;
sd->guild_emblem_id = 0;
-
+ if( g->instances )
+ instance->check_kick(sd);
clif->charnameupdate(sd); //Update display name [Skotlex]
//TODO: send emblem update to self and people around
}
@@ -993,7 +997,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin
if(idx == -1 || c == 0) {
//Treat char_id who doesn't match guild_id (not found as member)
- struct map_session_data *sd = map_id2sd(account_id);
+ struct map_session_data *sd = iMap->id2sd(account_id);
if(sd && sd->status.char_id == char_id) {
sd->status.guild_id=0;
sd->guild_emblem_id=0;
@@ -1202,7 +1206,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
// 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);
+ TBL_MOB* md = (gc->guardian[i].id ? iMap->id2md(gc->guardian[i].id) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
@@ -1211,7 +1215,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
// 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);
+ TBL_MOB* md = (gc->temp_guardians[i] ? iMap->id2md(gc->temp_guardians[i]) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
@@ -1329,7 +1333,7 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id)
*---------------------------------------------------*/
int guild_skillupack(int guild_id,uint16 skill_id,int account_id)
{
- struct map_session_data *sd=map_id2sd(account_id);
+ struct map_session_data *sd=iMap->id2sd(account_id);
struct guild *g=guild->search(guild_id);
int i;
if(g==NULL)
@@ -1359,7 +1363,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id)
void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) {
struct skill_unit_group* group = NULL;
int type = status_skill2sc(skill_id);
- if( !(battle_config.guild_aura&((agit_flag || agit2_flag)?2:1)) &&
+ if( !(battle_config.guild_aura&((iMap->agit_flag || iMap->agit2_flag)?2:1)) &&
!(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) )
return;
if( !skill_lv )
@@ -1432,7 +1436,7 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd)
struct guild *g[2];
int i;
- if(agit_flag || agit2_flag) { // Disable alliance creation during woe [Valaris]
+ if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance creation during woe [Valaris]
clif->message(sd->fd,msg_txt(676)); //"Alliances cannot be made during Guild Wars!"
return 0;
} // end addition [Valaris]
@@ -1490,7 +1494,7 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag)
struct map_session_data *tsd;
nullpo_ret(sd);
- tsd= map_id2sd( account_id );
+ tsd= iMap->id2sd( account_id );
if (!tsd) { //Character left? Cancel alliance.
clif->guild_allianceack(sd,3);
return 0;
@@ -1550,7 +1554,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
{
nullpo_ret(sd);
- if(agit_flag || agit2_flag) { // Disable alliance breaking during woe [Valaris]
+ if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance breaking during woe [Valaris]
clif->message(sd->fd,msg_txt(677)); //"Alliances cannot be broken during Guild Wars!"
return 0;
} // end addition [Valaris]
@@ -1588,7 +1592,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd)
clif->guild_oppositionack(sd,2);
return 0;
}
- if(agit_flag || agit2_flag) // Prevent the changing of alliances to oppositions during WoE.
+ if(iMap->agit_flag || iMap->agit2_flag) // Prevent the changing of alliances to oppositions during WoE.
return 0;
//Change alliance to opposition.
intif_guild_alliance( sd->status.guild_id,tsd->status.guild_id,
@@ -1617,8 +1621,8 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
guild_id[1] = guild_id2;
guild_name[0] = name1;
guild_name[1] = name2;
- sd[0] = map_id2sd(account_id1);
- sd[1] = map_id2sd(account_id2);
+ sd[0] = iMap->id2sd(account_id1);
+ sd[1] = iMap->id2sd(account_id2);
g[0]=guild->search(guild_id1);
g[1]=guild->search(guild_id2);
@@ -1922,7 +1926,7 @@ int guild_castledatasave(int castle_id, int index, int value)
struct mob_data *gd;
gc->guild_id = value;
for (i = 0; i < MAX_GUARDIANS; i++)
- if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+ if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL)
mob_guardian_guildchange(gd);
break;
}
@@ -1934,7 +1938,7 @@ int guild_castledatasave(int castle_id, int index, int value)
struct mob_data *gd;
gc->defense = value;
for (i = 0; i < MAX_GUARDIANS; i++)
- if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+ if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL)
status_calc_mob(gd, 0);
break;
}
@@ -2193,15 +2197,15 @@ void do_init_guild(void) {
guild_flags_count = 0;
- sv->readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
+ sv->readdb(iMap->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
memset(guild_skill_tree,0,sizeof(guild_skill_tree));
- sv->readdb(db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
+ sv->readdb(iMap->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
- add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
- add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer");
- add_timer_interval(gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL);
- add_timer_interval(gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL);
+ iTimer->add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
+ iTimer->add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL);
+ iTimer->add_timer_interval(iTimer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL);
}
void do_final_guild(void) {
@@ -2211,6 +2215,10 @@ void do_final_guild(void) {
for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) {
if( g->channel != NULL )
clif->chsys_delete((struct hChSysCh *)g->channel);
+ if( g->instance != NULL ) {
+ aFree(g->instance);
+ g->instance = NULL;
+ }
}
dbi_destroy(iter);