diff options
Diffstat (limited to 'src/map/battleground.c')
-rw-r--r-- | src/map/battleground.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/map/battleground.c b/src/map/battleground.c index b557bee8e..fe1c078d8 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -110,7 +110,7 @@ int bg_team_join(int bg_id, struct map_session_data *sd) int bg_team_leave(struct map_session_data *sd, int flag) { // Single Player leaves team int i, bg_id; - struct battleground_data *bg; + struct battleground_data *bg_data; char output[128]; if( sd == NULL || !sd->bg_id ) @@ -120,24 +120,27 @@ int bg_team_leave(struct map_session_data *sd, int flag) bg_id = sd->bg_id; sd->bg_id = 0; - if( (bg = bg_team_search(bg_id)) == NULL ) + if( (bg_data = bg_team_search(bg_id)) == NULL ) return 0; - ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == sd); + ARR_FIND(0, MAX_BG_MEMBERS, i, bg_data->members[i].sd == sd); if( i < MAX_BG_MEMBERS ) // Removes member from BG - memset(&bg->members[i], 0, sizeof(bg->members[0])); - bg->count--; + memset(&bg_data->members[i], 0, sizeof(bg_data->members[0])); + bg_data->count--; if( flag ) sprintf(output, "Server : %s has quit the game...", sd->status.name); else sprintf(output, "Server : %s is leaving the battlefield...", sd->status.name); - clif->bg_message(bg, 0, "Server", output, strlen(output) + 1); + clif->bg_message(bg_data, 0, "Server", output, strlen(output) + 1); - if( bg->logout_event[0] && flag ) - npc_event(sd, bg->logout_event, 0); + if( bg_data->logout_event[0] && flag ) + npc_event(sd, bg_data->logout_event, 0); - return bg->count; + if( sd->bg_queue.arena ) + bg->queue_pc_cleanup(sd); + + return bg_data->count; } int bg_member_respawn(struct map_session_data *sd) @@ -392,6 +395,7 @@ void bg_config_read(void) { bg->arena[i]->fillup_timer = INVALID_TIMER; bg->arena[i]->pregame_duration = pregame_duration; bg->arena[i]->fillup_duration = fillup_duration; + bg->arena[i]->ongoing = false; } bg->arenas = arena_count; @@ -463,6 +467,9 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { struct hQueue *queue = &script->hq[arena->queue_id]; int i; + if( !arena->ongoing ) + return; + for( i = 0; i < queue->items; i++ ) { struct map_session_data * sd = NULL; @@ -470,11 +477,15 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { bg->queue_pc_cleanup(sd); if( canceled ) clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players"); + else { + pc_setglobalreg(sd, arena->delay_var, time(NULL)); + } } } - bg->arena[i]->begin_timer = INVALID_TIMER; - bg->arena[i]->fillup_timer = INVALID_TIMER; + arena->begin_timer = INVALID_TIMER; + arena->fillup_timer = INVALID_TIMER; + arena->ongoing = false; /* reset queue */ script->queue_clear(arena->queue_id); } @@ -496,7 +507,9 @@ void bg_begin(struct bg_arena *arena) { if( count < arena->min_players ) { bg->match_over(arena,true); } else { + arena->ongoing = true; mapreg_setreg(add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */ + mapreg_setregstr(add_str("$@bg_delay_var$"),bg->gdelay_var); npc_event_do(arena->npc_event); /* we split evenly? */ /* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */ @@ -506,6 +519,7 @@ void bg_begin(struct bg_arena *arena) { } int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) { bg->begin(bg->arena[id]); + bg->arena[id]->begin_timer = INVALID_TIMER; return 0; } @@ -524,12 +538,12 @@ void bg_queue_pregame(struct bg_arena *arena) { } int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) { bg->queue_pregame(bg->arena[id]); + bg->arena[id]->fillup_timer = INVALID_TIMER; return 0; } void bg_queue_check(struct bg_arena *arena) { int count = script->hq[arena->queue_id].items; - if( count == arena->max_players ) { if( arena->fillup_timer != INVALID_TIMER ) { iTimer->delete_timer(arena->fillup_timer,bg_fillup_timer); @@ -642,7 +656,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ return BGQA_FAIL_DESERTER; } - if ( ( tick = pc_readglobalreg(sd, arena->cooldown_variable) ) && tsec < tick ) { + if ( ( tick = pc_readglobalreg(sd, arena->delay_var) ) && tsec < tick ) { char response[100]; if( (tick-tsec) > 60 ) sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d minute(s)",(tick-tsec)/60); |