summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-07-05 22:27:33 -0300
committershennetsind <ind@henn.et>2013-07-05 22:27:33 -0300
commit449a41af45d448e18006ef9c105c393592239de1 (patch)
treec1e62facb122b68dcd9b0c0daa7fb2678d6a2e2e /src/map
parenta804951a82633340744a506e3609e6905066988c (diff)
downloadhercules-449a41af45d448e18006ef9c105c393592239de1.tar.gz
hercules-449a41af45d448e18006ef9c105c393592239de1.tar.bz2
hercules-449a41af45d448e18006ef9c105c393592239de1.tar.xz
hercules-449a41af45d448e18006ef9c105c393592239de1.zip
DB Queue Debug Update
Some documentation update on battlegrounds.conf Fixed Hercules Queue Option constants, they're 1-2-3 not 0-1-2. Some Bugfixes to the test script, special thanks to ossi0110 http://hercules.ws/board/topic/1302-bg-queue-debug Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battleground.c40
-rw-r--r--src/map/battleground.h2
2 files changed, 28 insertions, 14 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);
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 36f6f0cee..b6d95b813 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -67,7 +67,6 @@ struct bg_arena {
short min_players;
short max_players;
short min_team_players;
- char cooldown_variable[NAME_LENGTH];
char delay_var[NAME_LENGTH];
unsigned short maxDuration;
int queue_id;
@@ -76,6 +75,7 @@ struct bg_arena {
int game_timer;
unsigned short fillup_duration;
unsigned short pregame_duration;
+ bool ongoing;
};
/* battleground.c interface (incomplete) */