diff --git a/src/g_func.c b/src/g_func.c index 06bb316..7823758 100644 --- a/src/g_func.c +++ b/src/g_func.c @@ -664,6 +664,39 @@ Use_Plat(edict_t *ent, edict_t *other, edict_t *activator /* unused */) plat_go_down(ent); } +void +wait_and_change_think(edict_t* ent) +{ + void (*afterwaitfunc)(edict_t *) = ent->moveinfo.endfunc; + ent->moveinfo.endfunc = NULL; + afterwaitfunc(ent); +} + +/* + * In coop mode, this waits for coop_elevator_delay seconds + * before calling afterwaitfunc(ent); otherwise it just calls + * afterwaitfunc(ent); + */ +static void +wait_and_change(edict_t* ent, void (*afterwaitfunc)(edict_t *)) +{ + float waittime = coop_elevator_delay->value; + if (coop->value && waittime > 0.0f) + { + if(ent->nextthink == 0) + { + ent->moveinfo.endfunc = afterwaitfunc; + ent->think = wait_and_change_think; + ent->nextthink = level.time + waittime; + } + } + else + { + afterwaitfunc(ent); + + } +} + void Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane /* unsed */, csurface_t *surf /* unused */) @@ -687,7 +720,7 @@ Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane /* unsed */, if (ent->moveinfo.state == STATE_BOTTOM) { - plat_go_up(ent); + wait_and_change(ent, plat_go_up); } else if (ent->moveinfo.state == STATE_TOP) { diff --git a/src/g_main.c b/src/g_main.c index 5d116a7..3fd865d 100644 --- a/src/g_main.c +++ b/src/g_main.c @@ -23,6 +23,7 @@ edict_t *g_edicts; cvar_t *deathmatch; cvar_t *coop; cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */ +cvar_t *coop_elevator_delay; cvar_t *coop_pickup_weapons; cvar_t *dmflags; cvar_t *skill; diff --git a/src/header/local.h b/src/header/local.h index ec4a184..14ee9f3 100644 --- a/src/header/local.h +++ b/src/header/local.h @@ -585,6 +585,7 @@ extern cvar_t *maxentities; extern cvar_t *deathmatch; extern cvar_t *coop; extern cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */ +extern cvar_t *coop_elevator_delay; extern cvar_t *coop_pickup_weapons; extern cvar_t *dmflags; extern cvar_t *skill; diff --git a/src/savegame/savegame.c b/src/savegame/savegame.c index befa6b3..329d4cd 100644 --- a/src/savegame/savegame.c +++ b/src/savegame/savegame.c @@ -214,7 +214,8 @@ InitGame(void) deathmatch = gi.cvar ("deathmatch", "0", CVAR_LATCH); coop = gi.cvar ("coop", "0", CVAR_LATCH); coop_baseq2 = gi.cvar ("coop_baseq2", "0", CVAR_LATCH); - coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", 0); + coop_elevator_delay = gi.cvar("coop_elevator_delay", "1.0", CVAR_ARCHIVE); + coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", CVAR_ARCHIVE); skill = gi.cvar ("skill", "1", CVAR_LATCH); maxentities = gi.cvar ("maxentities", "1024", CVAR_LATCH); gamerules = gi.cvar ("gamerules", "0", CVAR_LATCH); //PGM diff --git a/src/savegame/tables/gamefunc_decs.h b/src/savegame/tables/gamefunc_decs.h index 787bc1f..3a99f62 100644 --- a/src/savegame/tables/gamefunc_decs.h +++ b/src/savegame/tables/gamefunc_decs.h @@ -1487,3 +1487,4 @@ extern void DBall_GameInit ( void ) ; extern void DBall_SelectSpawnPoint ( edict_t * ent , vec3_t origin , vec3_t angles ) ; extern void DBall_ClientBegin ( edict_t * ent ) ; extern int DBall_CheckDMRules ( void ) ; +extern void wait_and_change_think(edict_t* ent); diff --git a/src/savegame/tables/gamefunc_list.h b/src/savegame/tables/gamefunc_list.h index da457b5..cf5e8f8 100644 --- a/src/savegame/tables/gamefunc_list.h +++ b/src/savegame/tables/gamefunc_list.h @@ -1488,4 +1488,5 @@ {"DBall_SelectSpawnPoint", (byte *)DBall_SelectSpawnPoint}, {"DBall_ClientBegin", (byte *)DBall_ClientBegin}, {"DBall_CheckDMRules", (byte *)DBall_CheckDMRules}, +{"wait_and_change_think", (byte *)wait_and_change_think}, {0, 0}