From 127b39ec508b0f32e784b4f3da97b9d7a89b3dfc Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Sat, 30 Jun 2018 16:47:06 +0200 Subject: [PATCH] replaced bg_list for timed messages by std::vector --- code/game/g_active.cpp | 3523 +++++++++++++++++++------------------- code/game/g_local.h | 8 +- code/game/g_main.cpp | 3641 +++++++++++++++++++++------------------- 3 files changed, 3779 insertions(+), 3393 deletions(-) diff --git a/code/game/g_active.cpp b/code/game/g_active.cpp index 1becf6a..30f2daf 100644 --- a/code/game/g_active.cpp +++ b/code/game/g_active.cpp @@ -26,82 +26,83 @@ static const double USE_DISTANCE = 64.0; */ static void TryUse(gentity_t* ent) { - gentity_t* target; - trace_t trace; - vec3_t src, dest, vf; - clientSession_t* sess; + gentity_t* target; + trace_t trace; + vec3_t src, dest, vf; + clientSession_t* sess; - if (ent == NULL) { - return; - } + if(ent == NULL) + { + return; + } - sess = &ent->client->sess; + sess = &ent->client->sess; - VectorCopy(ent->r.currentOrigin, src); - src[2] += ent->client->ps.viewheight * ent->client->pers.pms_height; //TiM - include height offset for tall players + VectorCopy(ent->r.currentOrigin, src); + src[2] += ent->client->ps.viewheight * ent->client->pers.pms_height; //TiM - include height offset for tall players - AngleVectors(ent->client->ps.viewangles, vf, NULL, NULL); + AngleVectors(ent->client->ps.viewangles, vf, NULL, NULL); - //extend to find end of use trace - VectorMA(src, -6, vf, src);//in case we're inside something? - VectorMA(src, 134, vf, dest);//128+6 + //extend to find end of use trace + VectorMA(src, -6, vf, src);//in case we're inside something? + VectorMA(src, 134, vf, dest);//128+6 - //Trace ahead to find a valid target - memset(&trace, 0, sizeof(trace_t)); - trap_Trace(&trace, src, vec3_origin, vec3_origin, dest, ent->s.number, MASK_OPAQUE | CONTENTS_BODY | CONTENTS_ITEM | CONTENTS_CORPSE); + //Trace ahead to find a valid target + memset(&trace, 0, sizeof(trace_t)); + trap_Trace(&trace, src, vec3_origin, vec3_origin, dest, ent->s.number, MASK_OPAQUE | CONTENTS_BODY | CONTENTS_ITEM | CONTENTS_CORPSE); - if (trace.fraction == 1.0f || trace.entityNum < 0) - { - //FIXME: Play a failure sound - return; - } + if(trace.fraction == 1.0f || trace.entityNum < 0) + { + //FIXME: Play a failure sound + return; + } - target = &g_entities[trace.entityNum]; + target = &g_entities[trace.entityNum]; - //Check for a use command - if ((target != NULL) && (target->use != NULL) && (target->type == ENT_FUNC_USABLE)) - {//usable brush - if (target->team && atoi(target->team) != 0) - {//usable has a team - if (atoi(target->team) != sess->sessionTeam) - {//not on my team - //TiM - return - return; - } - } - //FIXME: play sound? - target->use(target, ent, ent); + //Check for a use command + if((target != NULL) && (target->use != NULL) && (target->type == ENT_FUNC_USABLE)) + {//usable brush + if(target->team && atoi(target->team) != 0) + {//usable has a team + if(atoi(target->team) != sess->sessionTeam) + {//not on my team + //TiM - return + return; + } + } + //FIXME: play sound? + target->use(target, ent, ent); #ifdef G_LUA - if (target->luaUse) - LuaHook_G_EntityUse(target->luaUse, target - g_entities, ent - g_entities, ent - g_entities); + if(target->luaUse) + LuaHook_G_EntityUse(target->luaUse, target - g_entities, ent - g_entities, ent - g_entities); #endif - return; - } - else if ((target != NULL) && (target->use != NULL) && (ent->type == ENT_MISC_AMMOSTATION)) - {//ammo station - if (sess->sessionTeam) - { - if (target->team) - { - if (atoi(target->team) != sess->sessionTeam) - { - //FIXME: play sound? - return; - } - } - } - target->use(target, ent, ent); + return; + } + else if((target != NULL) && (target->use != NULL) && (ent->type == ENT_MISC_AMMOSTATION)) + {//ammo station + if(sess->sessionTeam) + { + if(target->team) + { + if(atoi(target->team) != sess->sessionTeam) + { + //FIXME: play sound? + return; + } + } + } + target->use(target, ent, ent); #ifdef G_LUA - if (target->luaUse) - LuaHook_G_EntityUse(target->luaUse, target - g_entities, ent - g_entities, ent - g_entities); + if(target->luaUse) + LuaHook_G_EntityUse(target->luaUse, target - g_entities, ent - g_entities, ent - g_entities); #endif - return; - } - else if ((target && target->s.number == ENTITYNUM_WORLD) || (target->s.pos.trType == TR_STATIONARY && !(trace.surfaceFlags & SURF_NOIMPACT) && !target->takedamage)) - { - return; - } - //FIXME: Play a failure sound + return; + } + else if((target && target->s.number == ENTITYNUM_WORLD) || (target->s.pos.trType == TR_STATIONARY && !(trace.surfaceFlags & SURF_NOIMPACT) && !target->takedamage)) + { + return; + } + //FIXME: Play a failure sound } /* @@ -115,69 +116,76 @@ P_DamageFeedback * damage values to that client for pain blends and kicks, and * global pain sound events for all clients. */ -static void P_DamageFeedback(gentity_t* player) { - gclient_t* client; - float count; - vec3_t angles; - playerState_t* ps; +static void P_DamageFeedback(gentity_t* player) +{ + gclient_t* client; + float count; + vec3_t angles; + playerState_t* ps; - client = player->client; - ps = &client->ps; - if (client->ps.pm_type == PM_DEAD) { - return; - } + client = player->client; + ps = &client->ps; + if(client->ps.pm_type == PM_DEAD) + { + return; + } - // total points of damage shot at the player this frame - count = client->damage_blood + client->damage_armor; - if (count == 0) { - return; // didn't take any damage - } + // total points of damage shot at the player this frame + count = client->damage_blood + client->damage_armor; + if(count == 0) + { + return; // didn't take any damage + } - if (count > 255) { - count = 255; - } + if(count > 255) + { + count = 255; + } - // send the information to the client + // send the information to the client - // world damage (falling, slime, etc) uses a special code - // to make the blend blob centered instead of positional - if (client->damage_fromWorld) { - ps->damagePitch = 255; - ps->damageYaw = 255; + // world damage (falling, slime, etc) uses a special code + // to make the blend blob centered instead of positional + if(client->damage_fromWorld) + { + ps->damagePitch = 255; + ps->damageYaw = 255; - client->damage_fromWorld = qfalse; - } - else { - vectoangles(client->damage_from, angles); - ps->damagePitch = angles[PITCH] / 360.0 * 256; - ps->damageYaw = angles[YAW] / 360.0 * 256; - } + client->damage_fromWorld = qfalse; + } + else + { + vectoangles(client->damage_from, angles); + ps->damagePitch = angles[PITCH] / 360.0 * 256; + ps->damageYaw = angles[YAW] / 360.0 * 256; + } - // play an apropriate pain sound - if ((level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE)) { - player->pain_debounce_time = level.time + 700; - G_AddEvent(player, EV_PAIN, player->health); - ps->damageEvent++; - } + // play an apropriate pain sound + if((level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE)) + { + player->pain_debounce_time = level.time + 700; + G_AddEvent(player, EV_PAIN, player->health); + ps->damageEvent++; + } - ps->damageCount = client->damage_blood; - if (ps->damageCount > 255) - { - ps->damageCount = 255; - } + ps->damageCount = client->damage_blood; + if(ps->damageCount > 255) + { + ps->damageCount = 255; + } - ps->damageShieldCount = client->damage_armor; - if (ps->damageShieldCount > 255) - { - ps->damageShieldCount = 255; - } + ps->damageShieldCount = client->damage_armor; + if(ps->damageShieldCount > 255) + { + ps->damageShieldCount = 255; + } - // - // clear totals - // - client->damage_blood = 0; - client->damage_armor = 0; - client->damage_knockback = 0; + // + // clear totals + // + client->damage_blood = 0; + client->damage_armor = 0; + client->damage_knockback = 0; } @@ -190,78 +198,92 @@ P_WorldEffects /** * Check for lava / slime contents and drowning */ -static void P_WorldEffects(gentity_t *ent) { - int32_t waterlevel; +static void P_WorldEffects(gentity_t *ent) +{ + int32_t waterlevel; - if (ent->client->noclip) { - ent->client->airOutTime = level.time + 12000; // don't need air - return; - } + if(ent->client->noclip) + { + ent->client->airOutTime = level.time + 12000; // don't need air + return; + } - waterlevel = ent->waterlevel; + waterlevel = ent->waterlevel; - // - // check for drowning - // - if (waterlevel == 3 && !(ent->watertype&CONTENTS_LADDER)) { - // envirosuit give air, techs can't drown - if (g_classData[ent->client->sess.sessionClass].isMarine) { - ent->client->airOutTime = level.time + 10000; - } + // + // check for drowning + // + if(waterlevel == 3 && !(ent->watertype&CONTENTS_LADDER)) + { + // envirosuit give air, techs can't drown + if(g_classData[ent->client->sess.sessionClass].isMarine) + { + ent->client->airOutTime = level.time + 10000; + } - // if out of air, start drowning - if (ent->client->airOutTime < level.time) { - // drown! - ent->client->airOutTime += 1000; - if (ent->health > 1) { //TiM : used to be 0, but to fix red's medic code - // take more damage the longer underwater - ent->damage += 2; - if (ent->damage > 15) - ent->damage = 15; + // if out of air, start drowning + if(ent->client->airOutTime < level.time) + { + // drown! + ent->client->airOutTime += 1000; + if(ent->health > 1) + { //TiM : used to be 0, but to fix red's medic code +// take more damage the longer underwater + ent->damage += 2; + if(ent->damage > 15) + ent->damage = 15; - // play a gurp sound instead of a normal pain sound - if (ent->health <= ent->damage) { - G_Sound(ent, G_SoundIndex("*drown.wav")); - } - else if (rand() & 1) { - G_Sound(ent, G_SoundIndex("sound/player/gurp1.wav")); - } - else { - G_Sound(ent, G_SoundIndex("sound/player/gurp2.wav")); - } + // play a gurp sound instead of a normal pain sound + if(ent->health <= ent->damage) + { + G_Sound(ent, G_SoundIndex("*drown.wav")); + } + else if(rand() & 1) + { + G_Sound(ent, G_SoundIndex("sound/player/gurp1.wav")); + } + else + { + G_Sound(ent, G_SoundIndex("sound/player/gurp2.wav")); + } - // don't play a normal pain sound - ent->pain_debounce_time = level.time + 200; + // don't play a normal pain sound + ent->pain_debounce_time = level.time + 200; - G_Combat_Damage(ent, NULL, NULL, NULL, NULL, - ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); - } - } - } - else { - ent->client->airOutTime = level.time + 12000; - ent->damage = 2; - } + G_Combat_Damage(ent, NULL, NULL, NULL, NULL, + ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); + } + } + } + else + { + ent->client->airOutTime = level.time + 12000; + ent->damage = 2; + } - // - // check for sizzle damage (move to pmove?) - // - if (waterlevel && - (ent->watertype&(CONTENTS_LAVA | CONTENTS_SLIME))) { - if (ent->health > 0 - && ent->pain_debounce_time < level.time) { + // + // check for sizzle damage (move to pmove?) + // + if(waterlevel && + (ent->watertype&(CONTENTS_LAVA | CONTENTS_SLIME))) + { + if(ent->health > 0 + && ent->pain_debounce_time < level.time) + { - if (ent->watertype & CONTENTS_LAVA) { - G_Combat_Damage(ent, NULL, NULL, NULL, NULL, - 30 * waterlevel, 0, MOD_LAVA); - } + if(ent->watertype & CONTENTS_LAVA) + { + G_Combat_Damage(ent, NULL, NULL, NULL, NULL, + 30 * waterlevel, 0, MOD_LAVA); + } - if (ent->watertype & CONTENTS_SLIME) { - G_Combat_Damage(ent, NULL, NULL, NULL, NULL, - 10 * waterlevel, 0, MOD_SLIME); - } - } - } + if(ent->watertype & CONTENTS_SLIME) + { + G_Combat_Damage(ent, NULL, NULL, NULL, NULL, + 10 * waterlevel, 0, MOD_SLIME); + } + } + } } @@ -273,10 +295,10 @@ G_SetClientSound */ static void G_SetClientSound(gentity_t *ent) { // 3/28/00 kef -- this is dumb. - if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA | CONTENTS_SLIME))) - ent->s.loopSound = level.snd_fry; - else - ent->s.loopSound = 0; + if(ent->waterlevel && (ent->watertype&(CONTENTS_LAVA | CONTENTS_SLIME))) + ent->s.loopSound = level.snd_fry; + else + ent->s.loopSound = 0; } @@ -288,116 +310,135 @@ static void G_SetClientSound(gentity_t *ent) ClientImpacts ============== */ -static void ClientImpacts(gentity_t* ent, pmove_t* pm) { - int32_t i, j; - trace_t trace; - gentity_t* other; +static void ClientImpacts(gentity_t* ent, pmove_t* pm) +{ + int32_t i, j; + trace_t trace; + gentity_t* other; - memset(&trace, 0, sizeof(trace)); - for (i = 0; i < pm->numtouch; i++) { - for (j = 0; j < i; j++) { - if (pm->touchents[j] == pm->touchents[i]) { - break; - } - } - if (j != i) { - continue; // duplicated - } - other = &g_entities[pm->touchents[i]]; + memset(&trace, 0, sizeof(trace)); + for(i = 0; i < pm->numtouch; i++) + { + for(j = 0; j < i; j++) + { + if(pm->touchents[j] == pm->touchents[i]) + { + break; + } + } + if(j != i) + { + continue; // duplicated + } + other = &g_entities[pm->touchents[i]]; - if ((ent->r.svFlags & SVF_BOT) && (ent->touch)) { - ent->touch(ent, other, &trace); - } + if((ent->r.svFlags & SVF_BOT) && (ent->touch)) + { + ent->touch(ent, other, &trace); + } - if (!other->touch) { - continue; - } + if(!other->touch) + { + continue; + } - other->touch(other, ent, &trace); - } + other->touch(other, ent, &trace); + } } -void G_TouchTriggers(gentity_t *ent) { - int32_t i, num; - int32_t touch[MAX_GENTITIES]; - gentity_t *hit; - trace_t trace; - vec3_t mins, maxs; - vec3_t range = { 40, 40, 52 }; - playerState_t *ps; +void G_TouchTriggers(gentity_t *ent) +{ + int32_t i, num; + int32_t touch[MAX_GENTITIES]; + gentity_t *hit; + trace_t trace; + vec3_t mins, maxs; + vec3_t range = { 40, 40, 52 }; + playerState_t *ps; - if (ent == NULL || ent->client == NULL) { - return; - } + if(ent == NULL || ent->client == NULL) + { + return; + } - ps = &ent->client->ps; + ps = &ent->client->ps; - // dead clients don't activate triggers! - if (ps->stats[STAT_HEALTH] <= 0) { - return; - } + // dead clients don't activate triggers! + if(ps->stats[STAT_HEALTH] <= 0) + { + return; + } - VectorSubtract(ps->origin, range, mins); - VectorAdd(ps->origin, range, maxs); + VectorSubtract(ps->origin, range, mins); + VectorAdd(ps->origin, range, maxs); - num = trap_EntitiesInBox(mins, maxs, touch, MAX_GENTITIES); + num = trap_EntitiesInBox(mins, maxs, touch, MAX_GENTITIES); - // can't use ent->absmin, because that has a one unit pad - VectorAdd(ps->origin, ent->r.mins, mins); - VectorAdd(ps->origin, ent->r.maxs, maxs); + // can't use ent->absmin, because that has a one unit pad + VectorAdd(ps->origin, ent->r.mins, mins); + VectorAdd(ps->origin, ent->r.maxs, maxs); - for (i = 0; i < num; i++) { - hit = &g_entities[touch[i]]; + for(i = 0; i < num; i++) + { + hit = &g_entities[touch[i]]; #ifdef G_LUA - if (hit->luaTouch) - { - LuaHook_G_EntityTouch(hit->luaTouch, hit->s.number, ent->s.number); - } + if(hit->luaTouch) + { + LuaHook_G_EntityTouch(hit->luaTouch, hit->s.number, ent->s.number); + } #endif - if (!hit->touch && !ent->touch) { - continue; - } - if (!(hit->r.contents & CONTENTS_TRIGGER)) { - continue; - } + if(!hit->touch && !ent->touch) + { + continue; + } + if(!(hit->r.contents & CONTENTS_TRIGGER)) + { + continue; + } - // ignore most entities if a spectator - if (ent->client->sess.sessionTeam == TEAM_SPECTATOR) - { - // this is ugly but adding a new ET_? type will - // most likely cause network incompatibilities - if (hit->s.eType != ET_TELEPORT_TRIGGER && hit->touch != G_Mover_TouchDoorTrigger) - { - continue; - } - } + // ignore most entities if a spectator + if(ent->client->sess.sessionTeam == TEAM_SPECTATOR) + { + // this is ugly but adding a new ET_? type will + // most likely cause network incompatibilities + if(hit->s.eType != ET_TELEPORT_TRIGGER && hit->touch != G_Mover_TouchDoorTrigger) + { + continue; + } + } - // use seperate code for determining if an item is picked up - // so you don't have to actually contact its bounding box - if (hit->s.eType == ET_ITEM) { - if (!BG_PlayerTouchesItem(&ent->client->ps, &hit->s, level.time)) { - continue; - } - } - else { - if (!trap_EntityContact(mins, maxs, hit)) { - continue; - } - } + // use seperate code for determining if an item is picked up + // so you don't have to actually contact its bounding box + if(hit->s.eType == ET_ITEM) + { + if(!BG_PlayerTouchesItem(&ent->client->ps, &hit->s, level.time)) + { + continue; + } + } + else + { + if(!trap_EntityContact(mins, maxs, hit)) + { + continue; + } + } - memset(&trace, 0, sizeof(trace)); + memset(&trace, 0, sizeof(trace)); - if (hit->touch) { - hit->touch(hit, ent, &trace); - } + if(hit->touch) + { + hit->touch(hit, ent, &trace); + } - if ((ent->r.svFlags & SVF_BOT) && (ent->touch)) { - ent->touch(ent, hit, &trace); - } - } + if((ent->r.svFlags & SVF_BOT) && (ent->touch)) + { + ent->touch(ent, hit, &trace); + } + } } /* @@ -405,47 +446,51 @@ void G_TouchTriggers(gentity_t *ent) { SpectatorThink ================= */ -static void SpectatorThink(gentity_t* ent, usercmd_t* ucmd) { - pmove_t pm; - gclient_t* client; +static void SpectatorThink(gentity_t* ent, usercmd_t* ucmd) +{ + pmove_t pm; + gclient_t* client; - client = ent->client; + client = ent->client; - if (client->sess.spectatorState != SPECTATOR_FOLLOW) { - client->ps.pm_type = PM_SPECTATOR; - client->ps.speed = 400; // faster than normal + if(client->sess.spectatorState != SPECTATOR_FOLLOW) + { + client->ps.pm_type = PM_SPECTATOR; + client->ps.speed = 400; // faster than normal - // set up for pmove - memset(&pm, 0, sizeof(pm)); - pm.ps = &client->ps; - pm.cmd = *ucmd; - pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies - pm.trace = trap_Trace; - pm.pointcontents = trap_PointContents; + // set up for pmove + memset(&pm, 0, sizeof(pm)); + pm.ps = &client->ps; + pm.cmd = *ucmd; + pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies + pm.trace = trap_Trace; + pm.pointcontents = trap_PointContents; - // perform a pmove - Pmove(&pm); + // perform a pmove + Pmove(&pm); - // save results of pmove - VectorCopy(client->ps.origin, ent->s.origin); + // save results of pmove + VectorCopy(client->ps.origin, ent->s.origin); - G_TouchTriggers(ent); - trap_UnlinkEntity(ent); - } + G_TouchTriggers(ent); + trap_UnlinkEntity(ent); + } - client->oldbuttons = client->buttons; - client->buttons = ucmd->buttons; + client->oldbuttons = client->buttons; + client->buttons = ucmd->buttons; - // attack button cycles through spectators - if ((client->buttons & BUTTON_ATTACK) && !(client->oldbuttons & BUTTON_ATTACK)) { - Cmd_FollowCycle_f(ent, 1); - } - else if ((client->buttons & BUTTON_ALT_ATTACK) && !(client->oldbuttons & BUTTON_ALT_ATTACK)) - { - if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW) { - StopFollowing(ent); - } - } + // attack button cycles through spectators + if((client->buttons & BUTTON_ATTACK) && !(client->oldbuttons & BUTTON_ATTACK)) + { + Cmd_FollowCycle_f(ent, 1); + } + else if((client->buttons & BUTTON_ALT_ATTACK) && !(client->oldbuttons & BUTTON_ALT_ATTACK)) + { + if(ent->client->sess.spectatorState == SPECTATOR_FOLLOW) + { + StopFollowing(ent); + } + } } @@ -460,38 +505,38 @@ ClientInactivityTimer */ static qboolean ClientInactivityTimer(gclient_t *client) { - usercmd_t *cmd = &client->pers.cmd; + usercmd_t *cmd = &client->pers.cmd; - if (g_inactivity.integer == 0) - { - // give everyone some time, so if the operator sets g_inactivity during - // gameplay, everyone isn't kicked - client->inactivityTime = level.time + 60 * 1000; - client->inactivityWarning = qfalse; - } - else if (cmd->forwardmove || - cmd->rightmove || - cmd->upmove || - (cmd->buttons & BUTTON_ATTACK) || - (cmd->buttons & BUTTON_ALT_ATTACK)) - { - client->inactivityTime = level.time + g_inactivity.integer * 1000; - client->inactivityWarning = qfalse; - } - else if (!client->pers.localClient) - { - if (level.time > client->inactivityTime) - { - trap_DropClient(client - level.clients, "Dropped due to inactivity"); - return qfalse; - } - if (level.time > client->inactivityTime - 10000 && !client->inactivityWarning) - { - client->inactivityWarning = qtrue; - trap_SendServerCommand(client - level.clients, "cp \"Ten seconds until inactivity drop!\n\""); - } - } - return qtrue; + if(g_inactivity.integer == 0) + { + // give everyone some time, so if the operator sets g_inactivity during + // gameplay, everyone isn't kicked + client->inactivityTime = level.time + 60 * 1000; + client->inactivityWarning = qfalse; + } + else if(cmd->forwardmove || + cmd->rightmove || + cmd->upmove || + (cmd->buttons & BUTTON_ATTACK) || + (cmd->buttons & BUTTON_ALT_ATTACK)) + { + client->inactivityTime = level.time + g_inactivity.integer * 1000; + client->inactivityWarning = qfalse; + } + else if(!client->pers.localClient) + { + if(level.time > client->inactivityTime) + { + trap_DropClient(client - level.clients, "Dropped due to inactivity"); + return qfalse; + } + if(level.time > client->inactivityTime - 10000 && !client->inactivityWarning) + { + client->inactivityWarning = qtrue; + trap_SendServerCommand(client - level.clients, "cp \"Ten seconds until inactivity drop!\n\""); + } + } + return qtrue; } @@ -515,25 +560,21 @@ currently in it.... /** * \author Ubergames */ -static char *TimedMessage(void){ - char* message; - container_p c; +std::string TimedMessage() +{ + if(level.timedMessages.empty()) + { + return "^1RPG-X ERROR: No messages to display"; + } - if (level.timedMessages->length == 0) { - return "^1RPG-X ERROR: No messages to display"; - } + if(level.timedMessageIndex >= level.timedMessages.size()) + { + level.timedMessageIndex = 0; + } - if (level.iterTimedMessages == NULL) { - level.iterTimedMessages = level.timedMessages->iterator(level.timedMessages, LIST_FRONT); - if (level.iterTimedMessages == NULL) { // something went wrong - return "^1RPG-X ERROR: No messages to display"; - } - } - - c = level.timedMessages->cycl_next(level.iterTimedMessages); - message = static_cast(c->data); - - return message; + auto message = level.timedMessages.at(level.timedMessageIndex); + level.timedMessageIndex++; + return message; } @@ -545,63 +586,65 @@ ClientTimerActions /** * Actions that happen once a second */ -static void ClientTimerActions(gentity_t* ent, int32_t msec) { - gclient_t* client; - char* message; - float messageTime; +static void ClientTimerActions(gentity_t* ent, int32_t msec) +{ + gclient_t* client; + float messageTime; - client = ent->client; - client->timeResidual += msec; + client = ent->client; + client->timeResidual += msec; - if (rpg_timedmessagetime.value > 0.0f){ - //Make sure its not less then one //TiM: Well... we can have under 1, just not toooo far under 1 + if(rpg_timedmessagetime.value > 0.0f) + { + //Make sure its not less then one //TiM: Well... we can have under 1, just not toooo far under 1 - if (rpg_timedmessagetime.value < 0.2f) { //1 - messageTime = 0.2f; - } - else{ - messageTime = rpg_timedmessagetime.value; - } + if(rpg_timedmessagetime.value < 0.2f) + { //1 + messageTime = 0.2f; + } + else + { + messageTime = rpg_timedmessagetime.value; + } - if (level.time >(level.message + (messageTime * 60000))) { - level.message = level.time; + if(level.time > (level.message + (messageTime * 60000))) + { + level.message = level.time; - //TiM - There. So with this working in conjunction with that reset - //code above, this should be more efficient. :) - message = TimedMessage(); //Since we're working with a gloabl scope variable, there's no need for this thing to have parameters:) - - //Alright send the message now - if (message != NULL) { - trap_SendServerCommand(-1, va("cp \"%s\n\"", message)); //Shows the message on their main screen - } - } - } + //TiM - There. So with this working in conjunction with that reset + //code above, this should be more efficient. :) + auto message = "cp \"" + TimedMessage() + "\n\""; //Since we're working with a gloabl scope variable, there's no need for this thing to have parameters:) + trap_SendServerCommand(-1, message.c_str()); //Shows the message on their main screen + } + } - while (client->timeResidual >= 1000) { - client->timeResidual -= 1000; + while(client->timeResidual >= 1000) + { + client->timeResidual -= 1000; - if (ent->health > client->ps.stats[STAT_MAX_HEALTH]) - { - ent->health--; - } + if(ent->health > client->ps.stats[STAT_MAX_HEALTH]) + { + ent->health--; + } - // NOW IT ONCE AGAIN counts down armor when over max, once per second - if (client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH]) { - client->ps.stats[STAT_ARMOR]--; - } + // NOW IT ONCE AGAIN counts down armor when over max, once per second + if(client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH]) + { + client->ps.stats[STAT_ARMOR]--; + } - if (!client->ps.stats[STAT_HOLDABLE_ITEM]) - {//holding nothing... - if (client->ps.stats[STAT_USEABLE_PLACED] > 0) - {//we're in some kind of countdown - //so count down - client->ps.stats[STAT_USEABLE_PLACED]--; - } - } + if(!client->ps.stats[STAT_HOLDABLE_ITEM]) + {//holding nothing... + if(client->ps.stats[STAT_USEABLE_PLACED] > 0) + {//we're in some kind of countdown + //so count down + client->ps.stats[STAT_USEABLE_PLACED]--; + } + } - } + } } /* @@ -609,34 +652,37 @@ static void ClientTimerActions(gentity_t* ent, int32_t msec) { ClientIntermissionThink ==================== */ -static void ClientIntermissionThink(gclient_t* client) { - client->ps.eFlags &= ~EF_TALK; - client->ps.eFlags &= ~EF_FIRING; +static void ClientIntermissionThink(gclient_t* client) +{ + client->ps.eFlags &= ~EF_TALK; + client->ps.eFlags &= ~EF_FIRING; - // the level will exit when everyone wants to or after timeouts + // the level will exit when everyone wants to or after timeouts - // swap and latch button actions - client->oldbuttons = client->buttons; - client->buttons = client->pers.cmd.buttons; - if (g_gametype.integer != GT_SINGLE_PLAYER) - { - if (client->buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) & (client->oldbuttons ^ client->buttons)) { - client->readyToExit = (qboolean)(!client->readyToExit); - } - } + // swap and latch button actions + client->oldbuttons = client->buttons; + client->buttons = client->pers.cmd.buttons; + if(g_gametype.integer != GT_SINGLE_PLAYER) + { + if(client->buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) & (client->oldbuttons ^ client->buttons)) + { + client->readyToExit = (qboolean)(!client->readyToExit); + } + } } typedef struct detHit_s { - gentity_t* detpack; - gentity_t* player; - int32_t time; + gentity_t* detpack; + gentity_t* player; + int32_t time; } detHit_t; -enum g_activeDetPackLimits_e { - MAX_DETHITS = 32 // never define this to be 0 +enum g_activeDetPackLimits_e +{ + MAX_DETHITS = 32 // never define this to be 0 }; static detHit_t detHits[MAX_DETHITS]; @@ -651,27 +697,27 @@ static const uint16_t DETPACK_RADIUS = 500; void detpack_shot(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t meansOfDeath) { - int32_t i = 0; - gentity_t *ent = NULL; + int32_t i = 0; + gentity_t *ent = NULL; - //so we can't be blown up by things we're blowing up - self->takedamage = qfalse; + //so we can't be blown up by things we're blowing up + self->takedamage = qfalse; - G_TempEntity(self->s.origin, EV_GRENADE_EXPLODE); - G_Combat_RadiusDamage(self->s.origin, self->parent ? self->parent : self, DETPACK_DAMAGE*0.125, DETPACK_RADIUS*0.25, - self, DAMAGE_ALL_TEAMS, MOD_DETPACK); - // we're blowing up cuz we've been shot, so make sure we remove ourselves - //from our parent's inventory (so to speak) - for (i = 0; i < MAX_CLIENTS; i++) - { - if (((ent = &g_entities[i]) != NULL) && ent->inuse && (self->parent == ent)) - { - ent->client->ps.stats[STAT_USEABLE_PLACED] = 0; - ent->client->ps.stats[STAT_HOLDABLE_ITEM] = 0; - break; - } - } - G_FreeEntity(self); + G_TempEntity(self->s.origin, EV_GRENADE_EXPLODE); + G_Combat_RadiusDamage(self->s.origin, self->parent ? self->parent : self, DETPACK_DAMAGE*0.125, DETPACK_RADIUS*0.25, + self, DAMAGE_ALL_TEAMS, MOD_DETPACK); + // we're blowing up cuz we've been shot, so make sure we remove ourselves + //from our parent's inventory (so to speak) + for(i = 0; i < MAX_CLIENTS; i++) + { + if(((ent = &g_entities[i]) != NULL) && ent->inuse && (self->parent == ent)) + { + ent->client->ps.stats[STAT_USEABLE_PLACED] = 0; + ent->client->ps.stats[STAT_HOLDABLE_ITEM] = 0; + break; + } + } + G_FreeEntity(self); } /** @@ -679,59 +725,59 @@ void detpack_shot(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, in */ static qboolean PlaceDetpack(gentity_t* ent) { - gentity_t* detpack = NULL; - static gitem_t* detpackItem = NULL; - float detDistance = 80; - trace_t tr; - vec3_t fwd; - vec3_t right; - vec3_t up; - vec3_t end; - vec3_t mins = { -16, -16, -16 }; - vec3_t maxs = { 16, 16, 16 }; - playerState_t* ps = &ent->client->ps; + gentity_t* detpack = NULL; + static gitem_t* detpackItem = NULL; + float detDistance = 80; + trace_t tr; + vec3_t fwd; + vec3_t right; + vec3_t up; + vec3_t end; + vec3_t mins = { -16, -16, -16 }; + vec3_t maxs = { 16, 16, 16 }; + playerState_t* ps = &ent->client->ps; - if (detpackItem == NULL) - { - detpackItem = BG_FindItemForHoldable(HI_DETPACK); - } + if(detpackItem == NULL) + { + detpackItem = BG_FindItemForHoldable(HI_DETPACK); + } - // make sure our detHit info is init'd - if (bDetInit == qfalse) - { - memset(detHits, 0, MAX_DETHITS * sizeof(detHit_t)); - bDetInit = qtrue; - } + // make sure our detHit info is init'd + if(bDetInit == qfalse) + { + memset(detHits, 0, MAX_DETHITS * sizeof(detHit_t)); + bDetInit = qtrue; + } - // can we place this in front of us? - AngleVectors(ps->viewangles, fwd, right, up); - fwd[2] = 0; - VectorMA(ps->origin, detDistance, fwd, end); - memset(&tr, 0, sizeof(trace_t)); - trap_Trace(&tr, ps->origin, mins, maxs, end, ent->s.number, MASK_SHOT); - if (tr.fraction > 0.9) - { - // got enough room so place the detpack - detpack = G_Spawn(); - G_SpawnItem(detpack, detpackItem); - detpack->physicsBounce = 0.0f;//detpacks are *not* bouncy - VectorMA(ps->origin, detDistance + mins[0], fwd, detpack->s.origin); - if (FinishSpawningDetpack(detpack, detpackItem - bg_itemlist) == qfalse) - { - return qfalse; - } - VectorNegate(fwd, fwd); - vectoangles(fwd, detpack->s.angles); - detpack->think = DetonateDetpack; - detpack->nextthink = level.time + 120000; // if not used after 2 minutes it blows up anyway - detpack->parent = ent; - return qtrue; - } - else - { - // no room - return qfalse; - } + // can we place this in front of us? + AngleVectors(ps->viewangles, fwd, right, up); + fwd[2] = 0; + VectorMA(ps->origin, detDistance, fwd, end); + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, ps->origin, mins, maxs, end, ent->s.number, MASK_SHOT); + if(tr.fraction > 0.9) + { + // got enough room so place the detpack + detpack = G_Spawn(); + G_SpawnItem(detpack, detpackItem); + detpack->physicsBounce = 0.0f;//detpacks are *not* bouncy + VectorMA(ps->origin, detDistance + mins[0], fwd, detpack->s.origin); + if(FinishSpawningDetpack(detpack, detpackItem - bg_itemlist) == qfalse) + { + return qfalse; + } + VectorNegate(fwd, fwd); + vectoangles(fwd, detpack->s.angles); + detpack->think = DetonateDetpack; + detpack->nextthink = level.time + 120000; // if not used after 2 minutes it blows up anyway + detpack->parent = ent; + return qtrue; + } + else + { + // no room + return qfalse; + } } /** @@ -739,21 +785,21 @@ static qboolean PlaceDetpack(gentity_t* ent) */ static qboolean PlayerHitByDet(gentity_t* det, gentity_t* player) { - int32_t i = 0; + int32_t i = 0; - if (!bDetInit) - { - // detHit stuff not initialized. who knows what's going on? - return qfalse; - } - for (i = 0; i < MAX_DETHITS; i++) - { - if ((detHits[i].detpack == det) && (detHits[i].player == player)) - { - return qtrue; - } - } - return qfalse; + if(!bDetInit) + { + // detHit stuff not initialized. who knows what's going on? + return qfalse; + } + for(i = 0; i < MAX_DETHITS; i++) + { + if((detHits[i].detpack == det) && (detHits[i].player == player)) + { + return qtrue; + } + } + return qfalse; } /** @@ -761,36 +807,36 @@ static qboolean PlayerHitByDet(gentity_t* det, gentity_t* player) */ static void AddPlayerToDetHits(gentity_t* det, gentity_t* player) { - int32_t i = 0; - detHit_t* lastHit = NULL; - detHit_t* curHit = NULL; + int32_t i = 0; + detHit_t* lastHit = NULL; + detHit_t* curHit = NULL; - for (i = 0; i < MAX_DETHITS; i++) - { - if (0 == detHits[i].time) - { - // empty slot. add our player here. - detHits[i].detpack = det; - detHits[i].player = player; - detHits[i].time = level.time; - } - lastHit = &detHits[i]; - } - // getting here means we've filled our list of detHits, so begin recycling them, starting with the oldest hit. - curHit = &detHits[0]; - while (lastHit->time < curHit->time) - { - lastHit = curHit; - curHit++; - // just a safety check here - if (curHit == &detHits[0]) - { - break; - } - } - curHit->detpack = det; - curHit->player = player; - curHit->time = level.time; + for(i = 0; i < MAX_DETHITS; i++) + { + if(0 == detHits[i].time) + { + // empty slot. add our player here. + detHits[i].detpack = det; + detHits[i].player = player; + detHits[i].time = level.time; + } + lastHit = &detHits[i]; + } + // getting here means we've filled our list of detHits, so begin recycling them, starting with the oldest hit. + curHit = &detHits[0]; + while(lastHit->time < curHit->time) + { + lastHit = curHit; + curHit++; + // just a safety check here + if(curHit == &detHits[0]) + { + break; + } + } + curHit->detpack = det; + curHit->player = player; + curHit->time = level.time; } /** @@ -798,131 +844,134 @@ static void AddPlayerToDetHits(gentity_t* det, gentity_t* player) */ static void ClearThisDetpacksHits(gentity_t* det) { - int32_t i = 0; + int32_t i = 0; - for (i = 0; i < MAX_DETHITS; i++) - { - if (detHits[i].detpack == det) - { - detHits[i].player = NULL; - detHits[i].detpack = NULL; - detHits[i].time = 0; - } - } + for(i = 0; i < MAX_DETHITS; i++) + { + if(detHits[i].detpack == det) + { + detHits[i].player = NULL; + detHits[i].detpack = NULL; + detHits[i].time = 0; + } + } } static void DetpackBlammoThink(gentity_t* ent) { - int32_t i = 0; - int32_t lifetime = 3000; // how long (in msec) the shockwave lasts - int32_t knockback = 400; - float curBlastRadius = 50.0 * ent->count; - float radius = 0; - vec3_t vTemp; - trace_t tr; - gentity_t* pl = NULL; + int32_t i = 0; + int32_t lifetime = 3000; // how long (in msec) the shockwave lasts + int32_t knockback = 400; + float curBlastRadius = 50.0 * ent->count; + float radius = 0; + vec3_t vTemp; + trace_t tr; + gentity_t* pl = NULL; - if (ent->count++ > (lifetime*0.01)) - { - ClearThisDetpacksHits(ent); - G_FreeEntity(ent); - return; - } + if(ent->count++ > (lifetime*0.01)) + { + ClearThisDetpacksHits(ent); + G_FreeEntity(ent); + return; + } - // get a list of players within the blast radius at this time. - // only hit the ones we can see from the center of the explosion. - for (i = 0; i < MAX_CLIENTS; i++) - { - if (g_entities[i].client && g_entities[i].takedamage) - { - pl = &g_entities[i]; - VectorSubtract(pl->s.pos.trBase, ent->s.origin, vTemp); - radius = VectorNormalize(vTemp); - if ((radius <= curBlastRadius) && !PlayerHitByDet(ent, pl)) - { - // within the proper radius. do we have LOS to the player? - memset(&tr, 0, sizeof(trace_t)); - trap_Trace(&tr, ent->s.origin, NULL, NULL, pl->s.pos.trBase, ent->s.number, MASK_SHOT); - if (tr.entityNum == i) - { - // oh yeah. you're gettin' hit. - AddPlayerToDetHits(ent, pl); - VectorMA(pl->client->ps.velocity, knockback, vTemp, pl->client->ps.velocity); - // make sure the player goes up some - if (pl->client->ps.velocity[2] < 100) - { - pl->client->ps.velocity[2] = 100; - } - if (!pl->client->ps.pm_time) - { - int32_t t; + // get a list of players within the blast radius at this time. + // only hit the ones we can see from the center of the explosion. + for(i = 0; i < MAX_CLIENTS; i++) + { + if(g_entities[i].client && g_entities[i].takedamage) + { + pl = &g_entities[i]; + VectorSubtract(pl->s.pos.trBase, ent->s.origin, vTemp); + radius = VectorNormalize(vTemp); + if((radius <= curBlastRadius) && !PlayerHitByDet(ent, pl)) + { + // within the proper radius. do we have LOS to the player? + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, ent->s.origin, NULL, NULL, pl->s.pos.trBase, ent->s.number, MASK_SHOT); + if(tr.entityNum == i) + { + // oh yeah. you're gettin' hit. + AddPlayerToDetHits(ent, pl); + VectorMA(pl->client->ps.velocity, knockback, vTemp, pl->client->ps.velocity); + // make sure the player goes up some + if(pl->client->ps.velocity[2] < 100) + { + pl->client->ps.velocity[2] = 100; + } + if(!pl->client->ps.pm_time) + { + int32_t t; - t = knockback * 2; - if (t < 50) { - t = 50; - } - if (t > 200) { - t = 200; - } - pl->client->ps.pm_time = t; - pl->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; - } - } - } - } - } + t = knockback * 2; + if(t < 50) + { + t = 50; + } + if(t > 200) + { + t = 200; + } + pl->client->ps.pm_time = t; + pl->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + } + } + } + } + } - ent->nextthink = level.time + FRAMETIME; + ent->nextthink = level.time + FRAMETIME; } /** * Detonate a detpack */ -void DetonateDetpack(gentity_t *ent) { - // find all detpacks. the one whose parent is ent...blow up - gentity_t* detpack = NULL; - char* classname = BG_FindClassnameForHoldable(HI_DETPACK); +void DetonateDetpack(gentity_t *ent) +{ + // find all detpacks. the one whose parent is ent...blow up + gentity_t* detpack = NULL; + char* classname = BG_FindClassnameForHoldable(HI_DETPACK); - if (classname == NULL) - { - return; - } + if(classname == NULL) + { + return; + } - while ((detpack = G_Find(detpack, FOFS(classname), classname)) != NULL) - { - if (detpack->parent == ent) - { - // found it. BLAMMO! - // play explosion sound to all clients - gentity_t *te = NULL; + while((detpack = G_Find(detpack, FOFS(classname), classname)) != NULL) + { + if(detpack->parent == ent) + { + // found it. BLAMMO! + // play explosion sound to all clients + gentity_t *te = NULL; - te = G_TempEntity(detpack->s.pos.trBase, EV_GLOBAL_SOUND); - te->s.eventParm = G_SoundIndex("sound/weapons/explosions/detpakexplode.wav");//cgs.media.detpackExplodeSound - te->r.svFlags |= SVF_BROADCAST; + te = G_TempEntity(detpack->s.pos.trBase, EV_GLOBAL_SOUND); + te->s.eventParm = G_SoundIndex("sound/weapons/explosions/detpakexplode.wav");//cgs.media.detpackExplodeSound + te->r.svFlags |= SVF_BROADCAST; - //so we can't be blown up by things we're blowing up - detpack->takedamage = qfalse; + //so we can't be blown up by things we're blowing up + detpack->takedamage = qfalse; - G_AddEvent(detpack, EV_DETPACK, 0); - G_Combat_RadiusDamage(detpack->s.origin, detpack->parent, DETPACK_DAMAGE, DETPACK_RADIUS, - detpack, DAMAGE_HALF_NOTLOS | DAMAGE_ALL_TEAMS, MOD_DETPACK); - // just turn the model invisible and let the entity think for a bit to deliver a shockwave - //G_FreeEntity(detpack); - detpack->classname = NULL; - detpack->s.modelindex = 0; - detpack->think = DetpackBlammoThink; - detpack->count = 1; - detpack->nextthink = level.time + FRAMETIME; - return; - } - else if (detpack == ent) // if detpack == ent, we're blowing up this detpack cuz it's been sitting too long - { - detpack_shot(detpack, NULL, NULL, 0, 0); - return; - } - } - // hmm. couldn't find it. - detpack = NULL; + G_AddEvent(detpack, EV_DETPACK, 0); + G_Combat_RadiusDamage(detpack->s.origin, detpack->parent, DETPACK_DAMAGE, DETPACK_RADIUS, + detpack, DAMAGE_HALF_NOTLOS | DAMAGE_ALL_TEAMS, MOD_DETPACK); + // just turn the model invisible and let the entity think for a bit to deliver a shockwave + //G_FreeEntity(detpack); + detpack->classname = NULL; + detpack->s.modelindex = 0; + detpack->think = DetpackBlammoThink; + detpack->count = 1; + detpack->nextthink = level.time + FRAMETIME; + return; + } + else if(detpack == ent) // if detpack == ent, we're blowing up this detpack cuz it's been sitting too long + { + detpack_shot(detpack, NULL, NULL, 0, 0); + return; + } + } + // hmm. couldn't find it. + detpack = NULL; } @@ -946,15 +995,15 @@ static qhandle_t shieldDeactivateSound = 0; void G_Active_ShieldRemove(gentity_t* self) { - self->think = G_FreeEntity; - self->nextthink = level.time + 300; + self->think = G_FreeEntity; + self->nextthink = level.time + 300; - self->s.eFlags |= EF_ITEMPLACEHOLDER; + self->s.eFlags |= EF_ITEMPLACEHOLDER; - // Play raising sound... - G_AddEvent(self, EV_GENERAL_SOUND, shieldDeactivateSound); + // Play raising sound... + G_AddEvent(self, EV_GENERAL_SOUND, shieldDeactivateSound); - return; + return; } @@ -965,10 +1014,10 @@ void G_Active_ShieldRemove(gentity_t* self) */ void ShieldThink(gentity_t* self) { - self->s.eFlags &= ~(EF_ITEMPLACEHOLDER | EF_NODRAW); - self->nextthink = 0; + self->s.eFlags &= ~(EF_ITEMPLACEHOLDER | EF_NODRAW); + self->nextthink = 0; - return; + return; } /** @@ -976,10 +1025,10 @@ void ShieldThink(gentity_t* self) */ void ShieldDie(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32_t damage, int32_t mod) { - // Play damaging sound... - G_AddEvent(self, EV_GENERAL_SOUND, shieldDamageSound); + // Play damaging sound... + G_AddEvent(self, EV_GENERAL_SOUND, shieldDamageSound); - G_Active_ShieldRemove(self); + G_Active_ShieldRemove(self); } @@ -988,15 +1037,15 @@ void ShieldDie(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int32 */ void ShieldPain(gentity_t* self, gentity_t* attacker, int32_t damage) { - // Set the itemplaceholder flag to indicate the the shield drawing that the shield pain should be drawn. - self->s.eFlags |= EF_ITEMPLACEHOLDER; - self->think = ShieldThink; - self->nextthink = level.time + 400; + // Set the itemplaceholder flag to indicate the the shield drawing that the shield pain should be drawn. + self->s.eFlags |= EF_ITEMPLACEHOLDER; + self->think = ShieldThink; + self->nextthink = level.time + 400; - // Play damaging sound... - G_AddEvent(self, EV_GENERAL_SOUND, shieldDamageSound); + // Play damaging sound... + G_AddEvent(self, EV_GENERAL_SOUND, shieldDamageSound); - return; + return; } @@ -1005,34 +1054,34 @@ void ShieldPain(gentity_t* self, gentity_t* attacker, int32_t damage) */ void ShieldGoSolid(gentity_t* self) { - trace_t tr; + trace_t tr; - if (self->health <= 0) - { - G_Active_ShieldRemove(self); - return; - } + if(self->health <= 0) + { + G_Active_ShieldRemove(self); + return; + } - memset(&tr, 0, sizeof(trace_t)); - trap_Trace(&tr, self->r.currentOrigin, self->r.mins, self->r.maxs, self->r.currentOrigin, self->s.number, CONTENTS_BODY); - if (tr.startsolid) - { // gah, we can't activate yet - self->nextthink = level.time + 200; - self->think = ShieldGoSolid; - trap_LinkEntity(self); - } - else - { // get hard... huh-huh... - self->r.contents = CONTENTS_SOLID; - self->s.eFlags &= ~(EF_ITEMPLACEHOLDER); - self->nextthink = level.time + 1000; - self->think = ShieldThink; - self->takedamage = qtrue;//RPG-X: - RedTechie use to be qtrue //TiM - made true again. should be okay so long as the health isn't decremented + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, self->r.currentOrigin, self->r.mins, self->r.maxs, self->r.currentOrigin, self->s.number, CONTENTS_BODY); + if(tr.startsolid) + { // gah, we can't activate yet + self->nextthink = level.time + 200; + self->think = ShieldGoSolid; + trap_LinkEntity(self); + } + else + { // get hard... huh-huh... + self->r.contents = CONTENTS_SOLID; + self->s.eFlags &= ~(EF_ITEMPLACEHOLDER); + self->nextthink = level.time + 1000; + self->think = ShieldThink; + self->takedamage = qtrue;//RPG-X: - RedTechie use to be qtrue //TiM - made true again. should be okay so long as the health isn't decremented - trap_LinkEntity(self); - } + trap_LinkEntity(self); + } - return; + return; } /** @@ -1041,21 +1090,21 @@ void ShieldGoSolid(gentity_t* self) //RPG-X J2J EDIT here: void ShieldGoNotSolid(gentity_t* self) { - // make the shield non-solid very briefly - self->r.contents = CONTENTS_NONE; + // make the shield non-solid very briefly + self->r.contents = CONTENTS_NONE; - // nextthink needs to have a large enough interval to avoid excess accumulation of Activate messages - self->nextthink = level.time + 200; - self->think = ShieldGoSolid; + // nextthink needs to have a large enough interval to avoid excess accumulation of Activate messages + self->nextthink = level.time + 200; + self->think = ShieldGoSolid; - //TiM - Make the field visible - self->s.eFlags |= EF_ITEMPLACEHOLDER; + //TiM - Make the field visible + self->s.eFlags |= EF_ITEMPLACEHOLDER; - self->takedamage = qfalse; - trap_LinkEntity(self); + self->takedamage = qfalse; + trap_LinkEntity(self); - // Play raising sound... - G_AddEvent(self, EV_GENERAL_SOUND, shieldActivateSound); + // Play raising sound... + G_AddEvent(self, EV_GENERAL_SOUND, shieldActivateSound); } @@ -1064,86 +1113,94 @@ void ShieldGoNotSolid(gentity_t* self) */ void ShieldTouch(gentity_t* self, gentity_t* other, trace_t* trace) { - if (other == NULL || other->client == NULL) - return; + if(other == NULL || other->client == NULL) + return; - if (G_Client_IsAdmin(other) || (rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer != 0 && G_Client_IsBorg(other))/*other->client->sess.sessionClass == PC_ADMIN*/) - { - ShieldGoNotSolid(self); - } - //RPG-X:J2J Damage for shields - else - { - if ((int32_t)(self->s.angles[PITCH]) == 0) - { - vec3_t dir; + if(G_Client_IsAdmin(other) || (rpg_borgAdapt.integer && rpg_borgMoveThroughFields.integer != 0 && G_Client_IsBorg(other))/*other->client->sess.sessionClass == PC_ADMIN*/) + { + ShieldGoNotSolid(self); + } + //RPG-X:J2J Damage for shields + else + { + if((int32_t)(self->s.angles[PITCH]) == 0) + { + vec3_t dir; - //OPTIMIZE ME: If anyone can figure a quick, non hacky way to get the normal vector - //of the side of the forcefield they touch, PLEASE put it here lol. THis way works, but feels very half-assed lol - //Get the directional vector - VectorSubtract(self->r.currentOrigin, other->r.currentOrigin, dir); - VectorNormalize(dir); - //depending on angle, negate the perpendicular direction (else they zap back sideways) - //and set the other as absolute - if (self->s.angles[YAW] == 0) { - dir[1] = 0.0; - if (dir[0] < 0) - dir[0] = -1.0; - else - dir[0] = 1.0; - } - else { - dir[0] = 0.0; - if (dir[1] < 0) - dir[1] = -1.0; - else - dir[1] = 1.0; - } + //OPTIMIZE ME: If anyone can figure a quick, non hacky way to get the normal vector + //of the side of the forcefield they touch, PLEASE put it here lol. THis way works, but feels very half-assed lol + //Get the directional vector + VectorSubtract(self->r.currentOrigin, other->r.currentOrigin, dir); + VectorNormalize(dir); + //depending on angle, negate the perpendicular direction (else they zap back sideways) + //and set the other as absolute + if(self->s.angles[YAW] == 0) + { + dir[1] = 0.0; + if(dir[0] < 0) + dir[0] = -1.0; + else + dir[0] = 1.0; + } + else + { + dir[0] = 0.0; + if(dir[1] < 0) + dir[1] = -1.0; + else + dir[1] = 1.0; + } - //Invert it otherwise we'd be like, sucked into the field lol - VectorScale(dir, -1, dir); - //Un-normalize it to represent a scalar quantity - VectorScale(dir, 50, dir); - //Copy it straight to our velocity (this will mean the player will literally be thrown back) - VectorCopy(dir, other->client->ps.velocity); - other->client->ps.pm_time = 160; // hold time - other->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + //Invert it otherwise we'd be like, sucked into the field lol + VectorScale(dir, -1, dir); + //Un-normalize it to represent a scalar quantity + VectorScale(dir, 50, dir); + //Copy it straight to our velocity (this will mean the player will literally be thrown back) + VectorCopy(dir, other->client->ps.velocity); + other->client->ps.pm_time = 160; // hold time + other->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; - other->flags |= EF_MOVER_STOP; //Attempt to not let non admins thru. - //RPG-X: RedTechie - Added code for zap sound also a cvar to control damage a non admin walks into if cvar is set to 0 disables health from being drained (happens every 1 second) - //if ( level.time >= level.message + 1000 ) { - // level.message = level.time; - G_AddEvent(self, EV_GENERAL_SOUND, shieldMurderSound);//RPG-X: RedTechie - ZAPtacular! sound to my ears - if (rpg_forcefielddamage.integer != 0){ - if (rpg_forcefielddamage.integer > 999){ - rpg_forcefielddamage.integer = 999; - } - other->health -= rpg_forcefielddamage.integer; + other->flags |= EF_MOVER_STOP; //Attempt to not let non admins thru. + //RPG-X: RedTechie - Added code for zap sound also a cvar to control damage a non admin walks into if cvar is set to 0 disables health from being drained (happens every 1 second) + //if ( level.time >= level.message + 1000 ) { + // level.message = level.time; + G_AddEvent(self, EV_GENERAL_SOUND, shieldMurderSound);//RPG-X: RedTechie - ZAPtacular! sound to my ears + if(rpg_forcefielddamage.integer != 0) + { + if(rpg_forcefielddamage.integer > 999) + { + rpg_forcefielddamage.integer = 999; + } + other->health -= rpg_forcefielddamage.integer; - //RPG-X: RedTechie - Fixed free ent if medic revive on - if (rpg_medicsrevive.integer == 1){ - if (other->health <= 1){ - other->client->ps.stats[STAT_WEAPONS] = (1 << WP_0); - other->client->ps.stats[STAT_HOLDABLE_ITEM] = HI_NONE; - other->client->ps.stats[STAT_HEALTH] = other->health = 1; - G_Client_Die(other, other, other, 1, MOD_FORCEFIELD); - } - } - else{ - if (other->health <= 1){ - other->client->ps.stats[STAT_HEALTH] = other->health = 0; - G_Client_Die(other, other, other, 100000, MOD_FORCEFIELD); - } - } - } + //RPG-X: RedTechie - Fixed free ent if medic revive on + if(rpg_medicsrevive.integer == 1) + { + if(other->health <= 1) + { + other->client->ps.stats[STAT_WEAPONS] = (1 << WP_0); + other->client->ps.stats[STAT_HOLDABLE_ITEM] = HI_NONE; + other->client->ps.stats[STAT_HEALTH] = other->health = 1; + G_Client_Die(other, other, other, 1, MOD_FORCEFIELD); + } + } + else + { + if(other->health <= 1) + { + other->client->ps.stats[STAT_HEALTH] = other->health = 0; + G_Client_Die(other, other, other, 100000, MOD_FORCEFIELD); + } + } + } - //TiM: make it flicker when touched, and then throw bak the person - self->s.eFlags |= EF_ITEMPLACEHOLDER; - self->nextthink = level.time + 150; - self->think = ShieldThink; - } + //TiM: make it flicker when touched, and then throw bak the person + self->s.eFlags |= EF_ITEMPLACEHOLDER; + self->nextthink = level.time + 150; + self->think = ShieldThink; + } - } + } } /** @@ -1151,130 +1208,130 @@ void ShieldTouch(gentity_t* self, gentity_t* other, trace_t* trace) */ void CreateShield(gentity_t *ent) { - trace_t tr; - vec3_t end, posTraceEnd, negTraceEnd, start; - int32_t height, posWidth, negWidth, halfWidth = 0; - qboolean xaxis; - int32_t paramData = 0; + trace_t tr; + vec3_t end, posTraceEnd, negTraceEnd, start; + int32_t height, posWidth, negWidth, halfWidth = 0; + qboolean xaxis; + int32_t paramData = 0; - // trace upward to find height of shield - VectorCopy(ent->r.currentOrigin, end); - end[2] += MAX_SHIELD_HEIGHT; - memset(&tr, 0, sizeof(trace_t)); - trap_Trace(&tr, ent->r.currentOrigin, NULL, NULL, end, ent->s.number, MASK_SHOT); - height = (int32_t)(MAX_SHIELD_HEIGHT * tr.fraction); + // trace upward to find height of shield + VectorCopy(ent->r.currentOrigin, end); + end[2] += MAX_SHIELD_HEIGHT; + memset(&tr, 0, sizeof(trace_t)); + trap_Trace(&tr, ent->r.currentOrigin, NULL, NULL, end, ent->s.number, MASK_SHOT); + height = (int32_t)(MAX_SHIELD_HEIGHT * tr.fraction); - // use angles to find the proper axis along which to align the shield - VectorCopy(ent->r.currentOrigin, posTraceEnd); - VectorCopy(ent->r.currentOrigin, negTraceEnd); + // use angles to find the proper axis along which to align the shield + VectorCopy(ent->r.currentOrigin, posTraceEnd); + VectorCopy(ent->r.currentOrigin, negTraceEnd); - if ((int32_t)(ent->s.angles[YAW]) == 0) // shield runs along y-axis - { - ent->s.eFlags |= EF_SHIELD_BOX_Y; - posTraceEnd[1] += MAX_SHIELD_HALFWIDTH; - negTraceEnd[1] -= MAX_SHIELD_HALFWIDTH; - xaxis = qfalse; - } - else // shield runs along x-axis - { - ent->s.eFlags |= EF_SHIELD_BOX_X; - posTraceEnd[0] += MAX_SHIELD_HALFWIDTH; - negTraceEnd[0] -= MAX_SHIELD_HALFWIDTH; - xaxis = qtrue; - } + if((int32_t)(ent->s.angles[YAW]) == 0) // shield runs along y-axis + { + ent->s.eFlags |= EF_SHIELD_BOX_Y; + posTraceEnd[1] += MAX_SHIELD_HALFWIDTH; + negTraceEnd[1] -= MAX_SHIELD_HALFWIDTH; + xaxis = qfalse; + } + else // shield runs along x-axis + { + ent->s.eFlags |= EF_SHIELD_BOX_X; + posTraceEnd[0] += MAX_SHIELD_HALFWIDTH; + negTraceEnd[0] -= MAX_SHIELD_HALFWIDTH; + xaxis = qtrue; + } - // trace horizontally to find extend of shield - // positive trace - VectorCopy(ent->r.currentOrigin, start); - start[2] += (height >> 1); - trap_Trace(&tr, start, 0, 0, posTraceEnd, ent->s.number, MASK_SHOT); - posWidth = MAX_SHIELD_HALFWIDTH * tr.fraction; - // negative trace - trap_Trace(&tr, start, 0, 0, negTraceEnd, ent->s.number, MASK_SHOT); - negWidth = MAX_SHIELD_HALFWIDTH * tr.fraction; + // trace horizontally to find extend of shield + // positive trace + VectorCopy(ent->r.currentOrigin, start); + start[2] += (height >> 1); + trap_Trace(&tr, start, 0, 0, posTraceEnd, ent->s.number, MASK_SHOT); + posWidth = MAX_SHIELD_HALFWIDTH * tr.fraction; + // negative trace + trap_Trace(&tr, start, 0, 0, negTraceEnd, ent->s.number, MASK_SHOT); + negWidth = MAX_SHIELD_HALFWIDTH * tr.fraction; - // kef -- monkey with dimensions and place origin in center - halfWidth = (posWidth + negWidth) >> 1; - if (xaxis) - { - ent->r.currentOrigin[0] = ent->r.currentOrigin[0] - negWidth + halfWidth; - } - else - { - ent->r.currentOrigin[1] = ent->r.currentOrigin[1] - negWidth + halfWidth; - } - ent->r.currentOrigin[2] += (height >> 1); + // kef -- monkey with dimensions and place origin in center + halfWidth = (posWidth + negWidth) >> 1; + if(xaxis) + { + ent->r.currentOrigin[0] = ent->r.currentOrigin[0] - negWidth + halfWidth; + } + else + { + ent->r.currentOrigin[1] = ent->r.currentOrigin[1] - negWidth + halfWidth; + } + ent->r.currentOrigin[2] += (height >> 1); - // set entity's mins and maxs to new values, make it solid, and link it - if (xaxis) - { - VectorSet(ent->r.mins, -halfWidth, -SHIELD_HALFTHICKNESS, -(height >> 1)); - VectorSet(ent->r.maxs, halfWidth, SHIELD_HALFTHICKNESS, height); - } - else - { - VectorSet(ent->r.mins, -SHIELD_HALFTHICKNESS, -halfWidth, -(height >> 1)); - VectorSet(ent->r.maxs, SHIELD_HALFTHICKNESS, halfWidth, height >> 1); - } - ent->clipmask = MASK_SHOT; + // set entity's mins and maxs to new values, make it solid, and link it + if(xaxis) + { + VectorSet(ent->r.mins, -halfWidth, -SHIELD_HALFTHICKNESS, -(height >> 1)); + VectorSet(ent->r.maxs, halfWidth, SHIELD_HALFTHICKNESS, height); + } + else + { + VectorSet(ent->r.mins, -SHIELD_HALFTHICKNESS, -halfWidth, -(height >> 1)); + VectorSet(ent->r.maxs, SHIELD_HALFTHICKNESS, halfWidth, height >> 1); + } + ent->clipmask = MASK_SHOT; - // xaxis - 1 bit - // height - 0-254 8 bits //10 - // posWidth - 0-255 8 bits //10 - // negWidth - 0 - 255 8 bits + // xaxis - 1 bit + // height - 0-254 8 bits //10 + // posWidth - 0-255 8 bits //10 + // negWidth - 0 - 255 8 bits - paramData = (xaxis << 30) | ((height & 1023) << 20) | ((posWidth & 1023) << 10) | (negWidth & 1023); //24 16 8 - ent->s.time2 = paramData; + paramData = (xaxis << 30) | ((height & 1023) << 20) | ((posWidth & 1023) << 10) | (negWidth & 1023); //24 16 8 + ent->s.time2 = paramData; - if (ent->s.otherEntityNum2 == TEAM_RED) - { - ent->team = "1"; - } - else if (ent->s.otherEntityNum2 == TEAM_BLUE) - { - ent->team = "2"; - } + if(ent->s.otherEntityNum2 == TEAM_RED) + { + ent->team = "1"; + } + else if(ent->s.otherEntityNum2 == TEAM_BLUE) + { + ent->team = "2"; + } - ent->health = ceil(SHIELD_HEALTH*g_dmgmult.value); + ent->health = ceil(SHIELD_HEALTH*g_dmgmult.value); - ent->s.time = ent->health;//??? - ent->pain = ShieldPain; - ent->die = ShieldDie; - ent->touch = ShieldTouch; + ent->s.time = ent->health;//??? + ent->pain = ShieldPain; + ent->die = ShieldDie; + ent->touch = ShieldTouch; - ent->r.svFlags |= SVF_SHIELD_BBOX; + ent->r.svFlags |= SVF_SHIELD_BBOX; - // see if we're valid - trap_Trace(&tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ent->s.number, CONTENTS_BODY); + // see if we're valid + trap_Trace(&tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ent->s.number, CONTENTS_BODY); - if (tr.startsolid) - { // Something in the way! - // make the shield non-solid very briefly - ent->r.contents = CONTENTS_NONE; - ent->s.eFlags |= EF_NODRAW; - // nextthink needs to have a large enough interval to avoid excess accumulation of Activate messages - ent->nextthink = level.time + 200; - ent->think = ShieldGoSolid; - ent->takedamage = qfalse; - trap_LinkEntity(ent); - } - else - { // Get solid. - ent->r.contents = CONTENTS_PLAYERCLIP | CONTENTS_SHOTCLIP;//CONTENTS_SOLID; + if(tr.startsolid) + { // Something in the way! + // make the shield non-solid very briefly + ent->r.contents = CONTENTS_NONE; + ent->s.eFlags |= EF_NODRAW; + // nextthink needs to have a large enough interval to avoid excess accumulation of Activate messages + ent->nextthink = level.time + 200; + ent->think = ShieldGoSolid; + ent->takedamage = qfalse; + trap_LinkEntity(ent); + } + else + { // Get solid. + ent->r.contents = CONTENTS_PLAYERCLIP | CONTENTS_SHOTCLIP;//CONTENTS_SOLID; - ent->nextthink = level.time + 400; //1000 - ent->think = ShieldThink; + ent->nextthink = level.time + 400; //1000 + ent->think = ShieldThink; - ent->takedamage = qtrue;//RPG-X: - RedTechie Use to be qtrue //TiM - made true again. should be okay so long as the health isn't decremented - trap_LinkEntity(ent); + ent->takedamage = qtrue;//RPG-X: - RedTechie Use to be qtrue //TiM - made true again. should be okay so long as the health isn't decremented + trap_LinkEntity(ent); - ent->s.eFlags |= EF_ITEMPLACEHOLDER; + ent->s.eFlags |= EF_ITEMPLACEHOLDER; - // Play raising sound... - G_AddEvent(ent, EV_GENERAL_SOUND, shieldActivateSound); - } + // Play raising sound... + G_AddEvent(ent, EV_GENERAL_SOUND, shieldActivateSound); + } - return; + return; } /** @@ -1282,86 +1339,86 @@ void CreateShield(gentity_t *ent) */ static qboolean PlaceShield(gentity_t* playerent) { - static const gitem_t* shieldItem = NULL; - gentity_t* shield = NULL; - trace_t tr; - vec3_t fwd, pos, dest, mins = { -16, -16, 0 }, maxs = { 16, 16, 16 }; - playerState_t* ps = &playerent->client->ps; + static const gitem_t* shieldItem = NULL; + gentity_t* shield = NULL; + trace_t tr; + vec3_t fwd, pos, dest, mins = { -16, -16, 0 }, maxs = { 16, 16, 16 }; + playerState_t* ps = &playerent->client->ps; - if (shieldAttachSound == 0) - { - shieldAttachSound = G_SoundIndex("sound/weapons/detpacklatch.wav"); - shieldActivateSound = G_SoundIndex("sound/movers/forcefield/forcefieldon.wav"); //"sound/movers/forceup.wav" - shieldDamageSound = G_SoundIndex("sound/ambience/spark5.wav"); - shieldMurderSound = G_SoundIndex("sound/movers/forcefield/forcefieldtouch.wav"); //RPG-X: - RedTechie Added shild ZAP! sound //sound/world/electro.wav - shieldDeactivateSound = G_SoundIndex("sound/movers/forcefield/forcefieldoff.wav"); - shieldItem = BG_FindItemForHoldable(HI_SHIELD); - } + if(shieldAttachSound == 0) + { + shieldAttachSound = G_SoundIndex("sound/weapons/detpacklatch.wav"); + shieldActivateSound = G_SoundIndex("sound/movers/forcefield/forcefieldon.wav"); //"sound/movers/forceup.wav" + shieldDamageSound = G_SoundIndex("sound/ambience/spark5.wav"); + shieldMurderSound = G_SoundIndex("sound/movers/forcefield/forcefieldtouch.wav"); //RPG-X: - RedTechie Added shild ZAP! sound //sound/world/electro.wav + shieldDeactivateSound = G_SoundIndex("sound/movers/forcefield/forcefieldoff.wav"); + shieldItem = BG_FindItemForHoldable(HI_SHIELD); + } - // can we place this in front of us? - AngleVectors(ps->viewangles, fwd, NULL, NULL); - fwd[2] = 0; - VectorMA(ps->origin, SHIELD_PLACEDIST, fwd, dest); - trap_Trace(&tr, ps->origin, mins, maxs, dest, playerent->s.number, MASK_SHOT); - if (tr.fraction > 0.9) - {//room in front - VectorCopy(tr.endpos, pos); - // drop to floor - VectorSet(dest, pos[0], pos[1], pos[2] - 4096); - trap_Trace(&tr, pos, mins, maxs, dest, playerent->s.number, MASK_SOLID); - if (!tr.startsolid && !tr.allsolid) - { - // got enough room so place the portable shield - shield = G_Spawn(); + // can we place this in front of us? + AngleVectors(ps->viewangles, fwd, NULL, NULL); + fwd[2] = 0; + VectorMA(ps->origin, SHIELD_PLACEDIST, fwd, dest); + trap_Trace(&tr, ps->origin, mins, maxs, dest, playerent->s.number, MASK_SHOT); + if(tr.fraction > 0.9) + {//room in front + VectorCopy(tr.endpos, pos); + // drop to floor + VectorSet(dest, pos[0], pos[1], pos[2] - 4096); + trap_Trace(&tr, pos, mins, maxs, dest, playerent->s.number, MASK_SOLID); + if(!tr.startsolid && !tr.allsolid) + { + // got enough room so place the portable shield + shield = G_Spawn(); - if (!shield || !shieldItem) return qfalse; + if(!shield || !shieldItem) return qfalse; - // Figure out what direction the shield is facing. - if (fabs(fwd[0]) > fabs(fwd[1])) - { // shield is north/south, facing east. - shield->s.angles[YAW] = 0; - } - else - { // shield is along the east/west axis, facing north - shield->s.angles[YAW] = 90; - } - shield->think = CreateShield; - shield->nextthink = level.time + 500; // power up after .5 seconds - shield->parent = playerent; + // Figure out what direction the shield is facing. + if(fabs(fwd[0]) > fabs(fwd[1])) + { // shield is north/south, facing east. + shield->s.angles[YAW] = 0; + } + else + { // shield is along the east/west axis, facing north + shield->s.angles[YAW] = 90; + } + shield->think = CreateShield; + shield->nextthink = level.time + 500; // power up after .5 seconds + shield->parent = playerent; - // Set team number. - shield->s.otherEntityNum2 = playerent->client->sess.sessionTeam; + // Set team number. + shield->s.otherEntityNum2 = playerent->client->sess.sessionTeam; - shield->s.eType = ET_USEABLE; - shield->s.modelindex = HI_SHIELD; // this'll be used in CG_Useable() for rendering. - shield->classname = shieldItem->classname; + shield->s.eType = ET_USEABLE; + shield->s.modelindex = HI_SHIELD; // this'll be used in CG_Useable() for rendering. + shield->classname = shieldItem->classname; - shield->r.contents = CONTENTS_TRIGGER; + shield->r.contents = CONTENTS_TRIGGER; - shield->touch = 0; - // using an item causes it to respawn - shield->use = 0; //Use_Item; + shield->touch = 0; + // using an item causes it to respawn + shield->use = 0; //Use_Item; - // allow to ride movers - shield->s.groundEntityNum = tr.entityNum; + // allow to ride movers + shield->s.groundEntityNum = tr.entityNum; - G_SetOrigin(shield, tr.endpos); + G_SetOrigin(shield, tr.endpos); - shield->s.origin2[0] = rpg_forceFieldColor.integer; + shield->s.origin2[0] = rpg_forceFieldColor.integer; - shield->s.eFlags &= ~EF_NODRAW; - shield->r.svFlags &= ~SVF_NOCLIENT; + shield->s.eFlags &= ~EF_NODRAW; + shield->r.svFlags &= ~SVF_NOCLIENT; - trap_LinkEntity(shield); + trap_LinkEntity(shield); - // Play placing sound... - G_AddEvent(shield, EV_GENERAL_SOUND, shieldAttachSound); + // Play placing sound... + G_AddEvent(shield, EV_GENERAL_SOUND, shieldAttachSound); - return qtrue; - } - } + return qtrue; + } + } - return qfalse; + return qfalse; } @@ -1372,11 +1429,11 @@ static qboolean PlaceShield(gentity_t* playerent) */ void DecoyThink(gentity_t *ent) { - ent->s.apos = (ent->parent)->s.apos; // Update Current Rotation - ent->nextthink = level.time + irandom(2000, 6000); // Next think between 2 & 8 seconds + ent->s.apos = (ent->parent)->s.apos; // Update Current Rotation + ent->nextthink = level.time + irandom(2000, 6000); // Next think between 2 & 8 seconds - (ent->count)--; // Count Down - if (ent->count < 0) G_FreeEntity(ent); // Time To Erase The Ent + (ent->count)--; // Count Down + if(ent->count < 0) G_FreeEntity(ent); // Time To Erase The Ent } //TiM : I was just able to spawn 600 copies of me... @@ -1388,70 +1445,71 @@ void DecoyThink(gentity_t *ent) * Stops spawning if to many are spawned a a time, stop spawning is a limit was hit. * \author Ubergames - TiM */ -void flushDecoys(gentity_t *ent) { - gentity_t* decoy = NULL; - int32_t foundDecoys[MAX_GENTITIES] = { ENTITYNUM_NONE }; - int32_t lowestTimeStamp; - int32_t orgCount; - int32_t decoyCount = 0; - int32_t removeMe; - int32_t i; +void flushDecoys(gentity_t *ent) +{ + gentity_t* decoy = NULL; + int32_t foundDecoys[MAX_GENTITIES] = { ENTITYNUM_NONE }; + int32_t lowestTimeStamp; + int32_t orgCount; + int32_t decoyCount = 0; + int32_t removeMe; + int32_t i; - //limit to 10 placed at any one time - //see how many there are now - while ((decoy = G_Find(decoy, FOFS(classname), "decoy")) != NULL) - { - if (decoy->parent != ent) - //if ( decoy->s.clientNum != ent->client->ps.clientNum ) - { - continue; - } - foundDecoys[decoyCount++] = decoy->s.clientNum; - } + //limit to 10 placed at any one time + //see how many there are now + while((decoy = G_Find(decoy, FOFS(classname), "decoy")) != NULL) + { + if(decoy->parent != ent) + //if ( decoy->s.clientNum != ent->client->ps.clientNum ) + { + continue; + } + foundDecoys[decoyCount++] = decoy->s.clientNum; + } - //now remove first ones we find until there are only 9 left - decoy = NULL; - orgCount = decoyCount; - lowestTimeStamp = level.time; + //now remove first ones we find until there are only 9 left + decoy = NULL; + orgCount = decoyCount; + lowestTimeStamp = level.time; - //RPG-X: TiM - Let's limit it to say... 64 decoys per player - while (decoyCount > 64) //9 - { - removeMe = -1; - for (i = 0; i < orgCount; i++) - { - if (foundDecoys[i] == ENTITYNUM_NONE) - { - continue; - } - decoy = &g_entities[foundDecoys[i]]; + //RPG-X: TiM - Let's limit it to say... 64 decoys per player + while(decoyCount > 64) //9 + { + removeMe = -1; + for(i = 0; i < orgCount; i++) + { + if(foundDecoys[i] == ENTITYNUM_NONE) + { + continue; + } + decoy = &g_entities[foundDecoys[i]]; - if (decoy && decoy->timestamp < lowestTimeStamp) - { - removeMe = i; - lowestTimeStamp = decoy->timestamp; - } - } + if(decoy && decoy->timestamp < lowestTimeStamp) + { + removeMe = i; + lowestTimeStamp = decoy->timestamp; + } + } - if (removeMe != -1) - { - //remove it... or blow it? - if (&g_entities[foundDecoys[removeMe]] == NULL) - { - break; - } - else - { - G_FreeEntity(&g_entities[foundDecoys[removeMe]]); - } - foundDecoys[removeMe] = ENTITYNUM_NONE; - decoyCount--; - } - else - { - break; - } - } + if(removeMe != -1) + { + //remove it... or blow it? + if(&g_entities[foundDecoys[removeMe]] == NULL) + { + break; + } + else + { + G_FreeEntity(&g_entities[foundDecoys[removeMe]]); + } + foundDecoys[removeMe] = ENTITYNUM_NONE; + decoyCount--; + } + else + { + break; + } + } } /** @@ -1459,46 +1517,52 @@ void flushDecoys(gentity_t *ent) { * they'll become solid once nothing's detected in their boundaries. :) * \author TiM */ -void Decoy_CheckForSolidity(gentity_t *ent) { - int32_t i, num; - int32_t touch[MAX_GENTITIES]; - qboolean canGoSolid = qtrue; - gentity_t* hit = NULL; - vec3_t mins, maxs; +void Decoy_CheckForSolidity(gentity_t *ent) +{ + int32_t i, num; + int32_t touch[MAX_GENTITIES]; + qboolean canGoSolid = qtrue; + gentity_t* hit = NULL; + vec3_t mins, maxs; - VectorAdd(ent->s.origin, ent->r.mins, mins); - VectorAdd(ent->s.origin, ent->r.maxs, maxs); + VectorAdd(ent->s.origin, ent->r.mins, mins); + VectorAdd(ent->s.origin, ent->r.maxs, maxs); - num = trap_EntitiesInBox(mins, maxs, touch, MAX_GENTITIES); + num = trap_EntitiesInBox(mins, maxs, touch, MAX_GENTITIES); - for (i = 0; i < num; i++) { - hit = &g_entities[touch[i]]; + for(i = 0; i < num; i++) + { + hit = &g_entities[touch[i]]; - if (hit && hit->client) { - canGoSolid = qfalse; - break; - } - } + if(hit && hit->client) + { + canGoSolid = qfalse; + break; + } + } - if (canGoSolid) { - ent->r.contents = MASK_PLAYERSOLID; - ent->nextthink = 0; - ent->think = 0; - } - else { - ent->nextthink = level.time + 1000; - ent->r.contents = CONTENTS_NONE; - } + if(canGoSolid) + { + ent->r.contents = MASK_PLAYERSOLID; + ent->nextthink = 0; + ent->think = 0; + } + else + { + ent->nextthink = level.time + 1000; + ent->r.contents = CONTENTS_NONE; + } } /** * Use function for decoy, removes it if activator is an player and admin */ -void DecoyUse(gentity_t *self, gentity_t *other, gentity_t *activator) { - if (activator == NULL || !G_Client_IsAdmin(activator) || activator->client == NULL) - return; +void DecoyUse(gentity_t *self, gentity_t *other, gentity_t *activator) +{ + if(activator == NULL || !G_Client_IsAdmin(activator) || activator->client == NULL) + return; - G_FreeEntity(self); + G_FreeEntity(self); } @@ -1507,149 +1571,152 @@ void DecoyUse(gentity_t *self, gentity_t *other, gentity_t *activator) { */ qboolean PlaceDecoy(gentity_t *ent) { - gentity_t* decoy = NULL; - static gitem_t* decoyItem = NULL; - vec3_t mins = { -16, -16, -24 }; - char userinfo[MAX_INFO_STRING]; - int32_t i; + gentity_t* decoy = NULL; + static gitem_t* decoyItem = NULL; + vec3_t mins = { -16, -16, -24 }; + char userinfo[MAX_INFO_STRING]; + int32_t i; - if (decoyItem == NULL) - { - decoyItem = BG_FindItemForHoldable(HI_DECOY); - } + if(decoyItem == NULL) + { + decoyItem = BG_FindItemForHoldable(HI_DECOY); + } - //If we just hit our 129th decoy (...holy crap), reset the counter - if (level.decoyIndex >= MAX_CLIENTS) { - level.decoyIndex = 0; - } - //Now check if there is already a decoy with the same eventParm index. If there is, terminate it - { - gentity_t* oldDecoy = NULL; + //If we just hit our 129th decoy (...holy crap), reset the counter + if(level.decoyIndex >= MAX_CLIENTS) + { + level.decoyIndex = 0; + } + //Now check if there is already a decoy with the same eventParm index. If there is, terminate it + { + gentity_t* oldDecoy = NULL; - for (i = 0; i < level.num_entities; i++) { - oldDecoy = &g_entities[i]; + for(i = 0; i < level.num_entities; i++) + { + oldDecoy = &g_entities[i]; - if (Q_stricmp(oldDecoy->classname, "decoy") == 0 && oldDecoy->s.eventParm == level.decoyIndex) { - G_FreeEntity(oldDecoy); - break; - } - } - } + if(Q_stricmp(oldDecoy->classname, "decoy") == 0 && oldDecoy->s.eventParm == level.decoyIndex) + { + G_FreeEntity(oldDecoy); + break; + } + } + } - //--------------------------- SPAWN AND PLACE DECOY ON GROUND - decoy = G_Spawn(); + //--------------------------- SPAWN AND PLACE DECOY ON GROUND + decoy = G_Spawn(); - G_SpawnItem(decoy, decoyItem); // Generate it as an item, temporarly - decoy->physicsBounce = 0.0f;//decoys are *not* bouncy - //VectorMA(ent->client->ps.origin, detDistance + mins[0], fwd, decoy->s.origin); - VectorCopy(ent->client->ps.origin, decoy->s.origin); - decoy->r.mins[2] = mins[2];//keep it off the floor - //VectorNegate(fwd, fwd); // ??? What does this do?? - //vectoangles(fwd, decoy->s.angles); - VectorCopy(ent->client->ps.viewangles, decoy->s.angles); - if (!FinishSpawningDecoy(decoy, decoyItem - bg_itemlist)) - { - return qfalse; // Drop to ground and trap to clients - } - decoy->s.clientNum = ent->client->ps.clientNum; - decoy->s.number = decoy - g_entities; + G_SpawnItem(decoy, decoyItem); // Generate it as an item, temporarly + decoy->physicsBounce = 0.0f;//decoys are *not* bouncy + //VectorMA(ent->client->ps.origin, detDistance + mins[0], fwd, decoy->s.origin); + VectorCopy(ent->client->ps.origin, decoy->s.origin); + decoy->r.mins[2] = mins[2];//keep it off the floor + //VectorNegate(fwd, fwd); // ??? What does this do?? + //vectoangles(fwd, decoy->s.angles); + VectorCopy(ent->client->ps.viewangles, decoy->s.angles); + if(!FinishSpawningDecoy(decoy, decoyItem - bg_itemlist)) + { + return qfalse; // Drop to ground and trap to clients + } + decoy->s.clientNum = ent->client->ps.clientNum; + decoy->s.number = decoy - g_entities; - //--------------------------- SPECIALIZED DECOY SETUP - decoy->s.time = -1; // tell cgame this is a decoy so it does not mess up the radar + //--------------------------- SPECIALIZED DECOY SETUP + decoy->s.time = -1; // tell cgame this is a decoy so it does not mess up the radar - decoy->parent = ent; + decoy->parent = ent; - (decoy->s).eType = (ent->s).eType; // set to type PLAYER - (decoy->s).eFlags = (ent->s).eFlags; - (decoy->s).eFlags |= EF_ITEMPLACEHOLDER;// set the HOLOGRAM FLAG to ON - (decoy->s).powerups = (ent->s).powerups; + (decoy->s).eType = (ent->s).eType; // set to type PLAYER + (decoy->s).eFlags = (ent->s).eFlags; + (decoy->s).eFlags |= EF_ITEMPLACEHOLDER;// set the HOLOGRAM FLAG to ON + (decoy->s).powerups = (ent->s).powerups; - //TiM - attach the rotate flag if we need to - if ((ent->s).powerups & (1 << PW_FLIGHT) || ent->client->ps.gravity == 0) - (decoy->s).eFlags |= EF_FULL_ROTATE; + //TiM - attach the rotate flag if we need to + if((ent->s).powerups & (1 << PW_FLIGHT) || ent->client->ps.gravity == 0) + (decoy->s).eFlags |= EF_FULL_ROTATE; - decoy->s.eFlags &= ~(EF_FIRING | EF_ALT_FIRING); + decoy->s.eFlags &= ~(EF_FIRING | EF_ALT_FIRING); - decoy->s.weapon = ent->s.weapon; // get Player's Wepon Type + decoy->s.weapon = ent->s.weapon; // get Player's Wepon Type - decoy->s.apos = ent->s.apos; // copy angle of player to decoy - decoy->s.pos = ent->s.pos; + decoy->s.apos = ent->s.apos; // copy angle of player to decoy + decoy->s.pos = ent->s.pos; - //TiM: Set it's anim to whatever anims we're playing right now - decoy->s.legsAnim = ent->client->ps.stats[LEGSANIM]; - decoy->s.torsoAnim = ent->client->ps.stats[TORSOANIM]; + //TiM: Set it's anim to whatever anims we're playing right now + decoy->s.legsAnim = ent->client->ps.stats[LEGSANIM]; + decoy->s.torsoAnim = ent->client->ps.stats[TORSOANIM]; - decoy->timestamp = level.time; + decoy->timestamp = level.time; - //--------------------------- WEAPON ADJUST - // The Phaser and Dreadnought (Arc Welder) weapons are rendered on the - // client side differently, and cannot be used by the decoy - decoy->classname = "decoy"; + //--------------------------- WEAPON ADJUST + // The Phaser and Dreadnought (Arc Welder) weapons are rendered on the + // client side differently, and cannot be used by the decoy + decoy->classname = "decoy"; - //TiM-Set up data for transmission to client - decoy->s.eventParm = level.decoyIndex; - decoy->r.contents = CONTENTS_SOLID; //has to start off solid, or CGame won't realise this + //TiM-Set up data for transmission to client + decoy->s.eventParm = level.decoyIndex; + decoy->r.contents = CONTENTS_SOLID; //has to start off solid, or CGame won't realise this - VectorSet(decoy->r.mins, DEFAULT_MINS_0, DEFAULT_MINS_1, DEFAULT_MINS_2); - VectorSet(decoy->r.maxs, DEFAULT_MAXS_0, DEFAULT_MAXS_1, DEFAULT_MAXS_2); + VectorSet(decoy->r.mins, DEFAULT_MINS_0, DEFAULT_MINS_1, DEFAULT_MINS_2); + VectorSet(decoy->r.maxs, DEFAULT_MAXS_0, DEFAULT_MAXS_1, DEFAULT_MAXS_2); - decoy->nextthink = level.time + FRAMETIME; - decoy->think = Decoy_CheckForSolidity; - decoy->use = DecoyUse; + decoy->nextthink = level.time + FRAMETIME; + decoy->think = Decoy_CheckForSolidity; + decoy->use = DecoyUse; - trap_GetUserinfo(ent->client->ps.clientNum, userinfo, sizeof(userinfo)); - { - char buffer[MAX_TOKEN_CHARS]; - char model[64]; - char height[9]; - char weight[9]; - char offset[6]; + trap_GetUserinfo(ent->client->ps.clientNum, userinfo, sizeof(userinfo)); + { + char buffer[MAX_TOKEN_CHARS]; + char model[64]; + char height[9]; + char weight[9]; + char offset[6]; - //TiM - ensure that we encapsulate this data better or else it sometimes - //becomes null - Q_strncpyz(model, Info_ValueForKey(userinfo, "model"), sizeof(model)); - Q_strncpyz(height, Info_ValueForKey(userinfo, "height"), sizeof(height)); - Q_strncpyz(weight, Info_ValueForKey(userinfo, "weight"), sizeof(weight)); - Q_strncpyz(offset, Info_ValueForKey(userinfo, "modelOffset"), sizeof(offset)); + //TiM - ensure that we encapsulate this data better or else it sometimes + //becomes null + Q_strncpyz(model, Info_ValueForKey(userinfo, "model"), sizeof(model)); + Q_strncpyz(height, Info_ValueForKey(userinfo, "height"), sizeof(height)); + Q_strncpyz(weight, Info_ValueForKey(userinfo, "weight"), sizeof(weight)); + Q_strncpyz(offset, Info_ValueForKey(userinfo, "modelOffset"), sizeof(offset)); - Com_sprintf(buffer, sizeof(buffer), "model\\%s\\height\\%s\\weight\\%s\\moOf\\%s\\c\\%i", - model, - height, - weight, - offset, - ent->client->sess.sessionClass); + Com_sprintf(buffer, sizeof(buffer), "model\\%s\\height\\%s\\weight\\%s\\moOf\\%s\\c\\%i", + model, + height, + weight, + offset, + ent->client->sess.sessionClass); - trap_SetConfigstring(CS_DECOYS + level.decoyIndex, buffer); - } - level.decoyIndex++; + trap_SetConfigstring(CS_DECOYS + level.decoyIndex, buffer); + } + level.decoyIndex++; - return qtrue; // SUCCESS + return qtrue; // SUCCESS } //-------------------------------------------------------------- DECOY ACTIVITIES void G_Rematerialize(gentity_t *ent) { - playerState_t *ps = &ent->client->ps; + playerState_t *ps = &ent->client->ps; - ent->client->teleportTime = level.time + (15 * 1000); - ps->stats[STAT_USEABLE_PLACED] = 15; + ent->client->teleportTime = level.time + (15 * 1000); + ps->stats[STAT_USEABLE_PLACED] = 15; - ent->flags &= ~FL_NOTARGET; - ent->takedamage = qtrue; - ent->r.contents = MASK_PLAYERSOLID; - ent->s.eFlags &= ~EF_NODRAW; - ps->eFlags &= ~EF_NODRAW; - TeleportPlayer(ent, ps->origin, ps->viewangles, TP_BORG); - //take it away - ps->stats[STAT_HOLDABLE_ITEM] = 0; + ent->flags &= ~FL_NOTARGET; + ent->takedamage = qtrue; + ent->r.contents = MASK_PLAYERSOLID; + ent->s.eFlags &= ~EF_NODRAW; + ps->eFlags &= ~EF_NODRAW; + TeleportPlayer(ent, ps->origin, ps->viewangles, TP_BORG); + //take it away + ps->stats[STAT_HOLDABLE_ITEM] = 0; } static void G_GiveHoldable(gclient_t *client, holdable_t item) { - gitem_t *holdable = BG_FindItemForHoldable(item); + gitem_t *holdable = BG_FindItemForHoldable(item); - client->ps.stats[STAT_HOLDABLE_ITEM] = holdable - bg_itemlist;//teleport spots should be on other side of map - RegisterItem(holdable); + client->ps.stats[STAT_HOLDABLE_ITEM] = holdable - bg_itemlist;//teleport spots should be on other side of map + RegisterItem(holdable); } /* @@ -1661,162 +1728,170 @@ ClientEvents * Events will be passed on to the clients for presentation, * but any server game effects are handled here */ -static void ClientEvents(gentity_t *ent, int oldEventSequence) { - int32_t i; - int32_t event; - gclient_t* client = NULL; - int32_t damage; - playerState_t* ps = NULL; +static void ClientEvents(gentity_t *ent, int oldEventSequence) +{ + int32_t i; + int32_t event; + gclient_t* client = NULL; + int32_t damage; + playerState_t* ps = NULL; - client = ent->client; - ps = &client->ps; + client = ent->client; + ps = &client->ps; - if (oldEventSequence < ps->eventSequence - MAX_PS_EVENTS) { - oldEventSequence = ps->eventSequence - MAX_PS_EVENTS; - } - for (i = oldEventSequence; i < ps->eventSequence; i++) { - event = ps->events[i & (MAX_PS_EVENTS - 1)]; + if(oldEventSequence < ps->eventSequence - MAX_PS_EVENTS) + { + oldEventSequence = ps->eventSequence - MAX_PS_EVENTS; + } + for(i = oldEventSequence; i < ps->eventSequence; i++) + { + event = ps->events[i & (MAX_PS_EVENTS - 1)]; - switch (event) { - case EV_FALL_MEDIUM: - case EV_FALL_FAR: - if (ent->s.eType != ET_PLAYER) { - break; // not in the player model - } - if (g_dmflags.integer & DF_NO_FALLING) { - break; - } - if (rpg_selfdamage.integer != 0) - { - if (event == EV_FALL_FAR) - { - damage = 110; //10 -TiM : Make the falling more realistc! - } - else - { - damage = 90; //5 - } - } - else - { - damage = 0; - } - ent->pain_debounce_time = level.time + 200; // no normal pain sound - G_Combat_Damage(ent, NULL, NULL, NULL, NULL, damage, DAMAGE_ARMOR_PIERCING, MOD_FALLING); + switch(event) + { + case EV_FALL_MEDIUM: + case EV_FALL_FAR: + if(ent->s.eType != ET_PLAYER) + { + break; // not in the player model + } + if(g_dmflags.integer & DF_NO_FALLING) + { + break; + } + if(rpg_selfdamage.integer != 0) + { + if(event == EV_FALL_FAR) + { + damage = 110; //10 -TiM : Make the falling more realistc! + } + else + { + damage = 90; //5 + } + } + else + { + damage = 0; + } + ent->pain_debounce_time = level.time + 200; // no normal pain sound + G_Combat_Damage(ent, NULL, NULL, NULL, NULL, damage, DAMAGE_ARMOR_PIERCING, MOD_FALLING); - break; + break; - case EV_FIRE_WEAPON: - FireWeapon(ent, qfalse); - break; + case EV_FIRE_WEAPON: + FireWeapon(ent, qfalse); + break; - case EV_ALT_FIRE: - FireWeapon(ent, qtrue); - break; + case EV_ALT_FIRE: + FireWeapon(ent, qtrue); + break; - case EV_FIRE_EMPTY_PHASER: - FireWeapon(ent, qfalse); - break; + case EV_FIRE_EMPTY_PHASER: + FireWeapon(ent, qfalse); + break; - case EV_USE_ITEM1: // transporter - //TiM: Since we purge the vectors each cycle. I'll save us some memory by using the vectors themselves as a check. - if (TransDat[ps->clientNum].beamTime == 0 && - VectorCompare(vec3_origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin) && - VectorCompare(vec3_origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles)) - { - VectorCopy(ps->origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin); - VectorCopy(ps->viewangles, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles); - trap_SendServerCommand(ent - g_entities, va("chat \"Site to Site Transporter Location Confirmed.\nPress again to Energize.\"")); - ps->stats[STAT_HOLDABLE_ITEM] = BG_FindItemForHoldable(HI_TRANSPORTER) - bg_itemlist; - ps->stats[STAT_USEABLE_PLACED] = 2; // = 1 - break; - } + case EV_USE_ITEM1: // transporter + //TiM: Since we purge the vectors each cycle. I'll save us some memory by using the vectors themselves as a check. + if(TransDat[ps->clientNum].beamTime == 0 && + VectorCompare(vec3_origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin) && + VectorCompare(vec3_origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles)) + { + VectorCopy(ps->origin, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin); + VectorCopy(ps->viewangles, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles); + trap_SendServerCommand(ent - g_entities, va("chat \"Site to Site Transporter Location Confirmed.\nPress again to Energize.\"")); + ps->stats[STAT_HOLDABLE_ITEM] = BG_FindItemForHoldable(HI_TRANSPORTER) - bg_itemlist; + ps->stats[STAT_USEABLE_PLACED] = 2; // = 1 + break; + } - if (TransDat[ps->clientNum].beamTime == 0 && level.time > ps->powerups[PW_QUAD]) { - G_InitTransport(ps->clientNum, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin, - TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles); + if(TransDat[ps->clientNum].beamTime == 0 && level.time > ps->powerups[PW_QUAD]) + { + G_InitTransport(ps->clientNum, TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].origin, + TransDat[ps->clientNum].storedCoord[TPT_PORTABLE].angles); - memset(&TransDat[ps->clientNum].storedCoord[TPT_PORTABLE], 0, sizeof(TransDat[ps->clientNum].storedCoord[TPT_PORTABLE])); - } - else { - trap_SendServerCommand(ent - g_entities, va("chat \"Unable to comply. Already within transport cycle.\"")); - } + memset(&TransDat[ps->clientNum].storedCoord[TPT_PORTABLE], 0, sizeof(TransDat[ps->clientNum].storedCoord[TPT_PORTABLE])); + } + else + { + trap_SendServerCommand(ent - g_entities, va("chat \"Unable to comply. Already within transport cycle.\"")); + } - ps->stats[STAT_USEABLE_PLACED] = 0; + ps->stats[STAT_USEABLE_PLACED] = 0; - if (g_classData[client->sess.sessionClass].isMarine) - { - client->teleportTime = level.time + (3 * 1000); // 15 * 1000 - ps->stats[STAT_USEABLE_PLACED] = 1; // = 1 - } - break; + if(g_classData[client->sess.sessionClass].isMarine) + { + client->teleportTime = level.time + (3 * 1000); // 15 * 1000 + ps->stats[STAT_USEABLE_PLACED] = 1; // = 1 + } + break; - case EV_USE_ITEM2: // medkit - // New set of rules. You get either 100 health, or an extra 25, whichever is higher. - // Give 1/4 health. - ent->health += ps->stats[STAT_MAX_HEALTH] * 0.25; + case EV_USE_ITEM2: // medkit + // New set of rules. You get either 100 health, or an extra 25, whichever is higher. + // Give 1/4 health. + ent->health += ps->stats[STAT_MAX_HEALTH] * 0.25; - if (ent->health < ps->stats[STAT_MAX_HEALTH]) - { // If that doesn't bring us up to 100, make it go up to 100. - ent->health = ps->stats[STAT_MAX_HEALTH]; - } - else if (ent->health > ps->stats[STAT_MAX_HEALTH] * 2) - { // Otherwise, 25 is all you get. Just make sure we don't go above 200. - ent->health = ps->stats[STAT_MAX_HEALTH] * 2; - } - break; + if(ent->health < ps->stats[STAT_MAX_HEALTH]) + { // If that doesn't bring us up to 100, make it go up to 100. + ent->health = ps->stats[STAT_MAX_HEALTH]; + } + else if(ent->health > ps->stats[STAT_MAX_HEALTH] * 2) + { // Otherwise, 25 is all you get. Just make sure we don't go above 200. + ent->health = ps->stats[STAT_MAX_HEALTH] * 2; + } + break; - case EV_USE_ITEM3: // detpack - // if we haven't placed it yet, place it - if (0 == ps->stats[STAT_USEABLE_PLACED]) - { - if (PlaceDetpack(ent)) - { - ps->stats[STAT_USEABLE_PLACED] = 1; - trap_SendServerCommand(ent - g_entities, "cp \"CHARGE PLACED\""); - } - else - {//couldn't place it - ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_DETPACK) - bg_itemlist); - trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE CHARGE\""); - } - } - else - { - // ok, we placed it earlier. blow it up. - ps->stats[STAT_USEABLE_PLACED] = 0; - DetonateDetpack(ent); - } - break; + case EV_USE_ITEM3: // detpack + // if we haven't placed it yet, place it + if(0 == ps->stats[STAT_USEABLE_PLACED]) + { + if(PlaceDetpack(ent)) + { + ps->stats[STAT_USEABLE_PLACED] = 1; + trap_SendServerCommand(ent - g_entities, "cp \"CHARGE PLACED\""); + } + else + {//couldn't place it + ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_DETPACK) - bg_itemlist); + trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE CHARGE\""); + } + } + else + { + // ok, we placed it earlier. blow it up. + ps->stats[STAT_USEABLE_PLACED] = 0; + DetonateDetpack(ent); + } + break; - case EV_USE_ITEM4: // portable shield - if (!PlaceShield(ent)) // fixme if we fail, perhaps just spawn it as a pickup - {//couldn't place it - ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_SHIELD) - bg_itemlist); - trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE FORCE FIELD\""); - } - else - { - trap_SendServerCommand(ent - g_entities, "cp \"FORCE FIELD PLACED\""); - } - break; + case EV_USE_ITEM4: // portable shield + if(!PlaceShield(ent)) // fixme if we fail, perhaps just spawn it as a pickup + {//couldn't place it + ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_SHIELD) - bg_itemlist); + trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE FORCE FIELD\""); + } + else + { + trap_SendServerCommand(ent - g_entities, "cp \"FORCE FIELD PLACED\""); + } + break; - case EV_USE_ITEM5: // decoy - if (!PlaceDecoy(ent)) - {//couldn't place it - ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_DECOY) - bg_itemlist); - trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE DECOY\""); - } - else - { - trap_SendServerCommand(ent - g_entities, "cp \"DECOY PLACED\""); - } - break; + case EV_USE_ITEM5: // decoy + if(!PlaceDecoy(ent)) + {//couldn't place it + ps->stats[STAT_HOLDABLE_ITEM] = (BG_FindItemForHoldable(HI_DECOY) - bg_itemlist); + trap_SendServerCommand(ent - g_entities, "cp \"NO ROOM TO PLACE DECOY\""); + } + else + { + trap_SendServerCommand(ent - g_entities, "cp \"DECOY PLACED\""); + } + break; - default: - break; - } - } + default: + break; + } + } } @@ -1824,52 +1899,59 @@ void AI_main_BotTestSolid(vec3_t origin); void G_ThrowWeapon(gentity_t *ent, char *txt) { - gclient_t* client = NULL; - usercmd_t* ucmd = NULL; - gitem_t* item = NULL; - gentity_t* drop = NULL; - byte i; - playerState_t* ps = NULL; + gclient_t* client = NULL; + usercmd_t* ucmd = NULL; + gitem_t* item = NULL; + gentity_t* drop = NULL; + byte i; + playerState_t* ps = NULL; - client = ent->client; - ucmd = &ent->client->pers.cmd; - ps = &client->ps; + client = ent->client; + ucmd = &ent->client->pers.cmd; + ps = &client->ps; - if (rpg_allowWeaponDrop.integer == 0) { - return; - } + if(rpg_allowWeaponDrop.integer == 0) + { + return; + } - if (numTotalDropped >= MAX_DROPPED) { - G_LocLogger(LL_WARN, "RPG-X Warning: maximum of dropped items of %i reached.\n", MAX_DROPPED); - return; - } + if(numTotalDropped >= MAX_DROPPED) + { + G_LocLogger(LL_WARN, "RPG-X Warning: maximum of dropped items of %i reached.\n", MAX_DROPPED); + return; + } - if (ps->weapon == WP_0 || ps->weapon == WP_1 || (ucmd->buttons & BUTTON_ATTACK)) { - return; - } + if(ps->weapon == WP_0 || ps->weapon == WP_1 || (ucmd->buttons & BUTTON_ATTACK)) + { + return; + } - numTotalDropped++; + numTotalDropped++; - item = BG_FindItemForWeapon(weapon_t(ps->weapon)); + item = BG_FindItemForWeapon(weapon_t(ps->weapon)); - // admins don't lose weapon when thrown - if (G_Client_IsAdmin(ent) == qfalse) { - ps->ammo[ps->weapon] -= 1; - if (ps->ammo[ps->weapon] <= 0) { - ps->stats[STAT_WEAPONS] &= ~(1 << ps->weapon); - ps->weapon = WP_1; - for (i = WP_NUM_WEAPONS - 1; i > 0; i--) { - if (ps->stats[STAT_WEAPONS] & (1 << i)) { - ps->weapon = i; - break; - } - } - } - } + // admins don't lose weapon when thrown + if(G_Client_IsAdmin(ent) == qfalse) + { + ps->ammo[ps->weapon] -= 1; + if(ps->ammo[ps->weapon] <= 0) + { + ps->stats[STAT_WEAPONS] &= ~(1 << ps->weapon); + ps->weapon = WP_1; + for(i = WP_NUM_WEAPONS - 1; i > 0; i--) + { + if(ps->stats[STAT_WEAPONS] & (1 << i)) + { + ps->weapon = i; + break; + } + } + } + } - drop = DropWeapon(ent, item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM, txt); - drop->parent = ent; - drop->count = 1; + drop = DropWeapon(ent, item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM, txt); + drop->parent = ent; + drop->count = 1; } @@ -1878,44 +1960,49 @@ void G_ThrowWeapon(gentity_t *ent, char *txt) SendPendingPredictableEvents ============== */ -static void SendPendingPredictableEvents(playerState_t *ps) { - gentity_t* t = NULL; - int32_t event, seq; - int32_t extEvent; +static void SendPendingPredictableEvents(playerState_t *ps) +{ + gentity_t* t = NULL; + int32_t event, seq; + int32_t extEvent; - // if there are still events pending - if (ps->entityEventSequence < ps->eventSequence) { - // create a temporary entity for this event which is sent to everyone - // except the client generated the event - seq = ps->entityEventSequence & (MAX_PS_EVENTS - 1); - event = ps->events[seq] | ((ps->entityEventSequence & 3) << 8); - // set external event to zero before calling BG_PlayerStateToEntityState - extEvent = ps->externalEvent; - ps->externalEvent = 0; - // create temporary entity for event - t = G_TempEntity(ps->origin, event); - BG_PlayerStateToEntityState(ps, &t->s, qtrue); - t->s.eType = ET_EVENTS + event; - // send to everyone except the client who generated the event - t->r.svFlags |= SVF_NOTSINGLECLIENT; - t->r.singleClient = ps->clientNum; - // set back external event - ps->externalEvent = extEvent; - } + // if there are still events pending + if(ps->entityEventSequence < ps->eventSequence) + { + // create a temporary entity for this event which is sent to everyone + // except the client generated the event + seq = ps->entityEventSequence & (MAX_PS_EVENTS - 1); + event = ps->events[seq] | ((ps->entityEventSequence & 3) << 8); + // set external event to zero before calling BG_PlayerStateToEntityState + extEvent = ps->externalEvent; + ps->externalEvent = 0; + // create temporary entity for event + t = G_TempEntity(ps->origin, event); + BG_PlayerStateToEntityState(ps, &t->s, qtrue); + t->s.eType = ET_EVENTS + event; + // send to everyone except the client who generated the event + t->r.svFlags |= SVF_NOTSINGLECLIENT; + t->r.singleClient = ps->clientNum; + // set back external event + ps->externalEvent = extEvent; + } } -static void ClientCamThink(gentity_t* client) { - if (client == NULL || client->client == NULL || client->client->cam == NULL) { - if (client->flags & FL_CCAM) { - client->flags ^= FL_CCAM; - } - client->client->ps.pm_type = PM_NORMAL; - return; - } +static void ClientCamThink(gentity_t* client) +{ + if(client == NULL || client->client == NULL || client->client->cam == NULL) + { + if(client->flags & FL_CCAM) + { + client->flags ^= FL_CCAM; + } + client->client->ps.pm_type = PM_NORMAL; + return; + } - G_SetOrigin(client, client->client->cam->s.origin); - G_Client_SetViewAngle(client, client->client->cam->s.angles); - trap_LinkEntity(client); + G_SetOrigin(client, client->client->cam->s.origin); + G_Client_SetViewAngle(client, client->client->cam->s.angles); + trap_LinkEntity(client); } /* @@ -1930,335 +2017,379 @@ ClientThink * If "g_synchronousClients 1" is set, this will be called exactly * once for each server frame, which makes for smooth demo recording. */ -static void ClientThink_real(gentity_t *ent) { - gclient_t* client = NULL; - pmove_t pm; - int32_t oldEventSequence; - int32_t msec; - usercmd_t* ucmd = NULL; - playerState_t* ps = NULL; +static void ClientThink_real(gentity_t *ent) +{ + gclient_t* client = NULL; + pmove_t pm; + int32_t oldEventSequence; + int32_t msec; + usercmd_t* ucmd = NULL; + playerState_t* ps = NULL; - client = ent->client; - ps = &client->ps; + client = ent->client; + ps = &client->ps; - // don't think if the client is not yet connected (and thus not yet spawned in) - if (client->pers.connected != CON_CONNECTED) { - return; - } - // mark the time, so the connection sprite can be removed - ucmd = &client->pers.cmd; + // don't think if the client is not yet connected (and thus not yet spawned in) + if(client->pers.connected != CON_CONNECTED) + { + return; + } + // mark the time, so the connection sprite can be removed + ucmd = &client->pers.cmd; - // sanity check the command time to prevent speedup cheating - if (ucmd->serverTime > level.time + 200) { - ucmd->serverTime = level.time + 200; - } - if (ucmd->serverTime < level.time - 1000) { - ucmd->serverTime = level.time - 1000; - } + // sanity check the command time to prevent speedup cheating + if(ucmd->serverTime > level.time + 200) + { + ucmd->serverTime = level.time + 200; + } + if(ucmd->serverTime < level.time - 1000) + { + ucmd->serverTime = level.time - 1000; + } - msec = ucmd->serverTime - ps->commandTime; - // following others may result in bad times, but we still want - // to check for follow toggles - if (msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW) { - return; - } - if (msec > 200) { - msec = 200; - } + msec = ucmd->serverTime - ps->commandTime; + // following others may result in bad times, but we still want + // to check for follow toggles + if(msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW) + { + return; + } + if(msec > 200) + { + msec = 200; + } - // - // check for exiting intermission - // - if (level.intermissiontime) { - ClientIntermissionThink(client); - return; - } + // + // check for exiting intermission + // + if(level.intermissiontime) + { + ClientIntermissionThink(client); + return; + } - if (ent->flags & FL_CCAM) { - ClientCamThink(ent); - return; - } + if(ent->flags & FL_CCAM) + { + ClientCamThink(ent); + return; + } - // spectators don't do much - if (client->sess.sessionTeam == TEAM_SPECTATOR) { - if (client->sess.spectatorState == SPECTATOR_SCOREBOARD) { - return; - } - SpectatorThink(ent, ucmd); - return; - } + // spectators don't do much + if(client->sess.sessionTeam == TEAM_SPECTATOR) + { + if(client->sess.spectatorState == SPECTATOR_SCOREBOARD) + { + return; + } + SpectatorThink(ent, ucmd); + return; + } - // check for inactivity timer, but never drop the local client of a non-dedicated server - if (!ClientInactivityTimer(client)) { - return; - } + // check for inactivity timer, but never drop the local client of a non-dedicated server + if(!ClientInactivityTimer(client)) + { + return; + } - //TiM - If we're null content... see what's up - if (ent->r.contents == CONTENTS_NONE) { - if (!G_MoveBox(ent)) { - if (ps->stats[STAT_HEALTH] > 1) - ent->r.contents = CONTENTS_BODY; - else - ent->r.contents = CONTENTS_CORPSE; - } - } + //TiM - If we're null content... see what's up + if(ent->r.contents == CONTENTS_NONE) + { + if(!G_MoveBox(ent)) + { + if(ps->stats[STAT_HEALTH] > 1) + ent->r.contents = CONTENTS_BODY; + else + ent->r.contents = CONTENTS_CORPSE; + } + } - //RPG-X: Checked to see if medics revive is on if so do as following - if (rpg_medicsrevive.integer == 1){ - if (client->noclip) { - ps->pm_type = PM_NOCLIP; - } - else if (ps->stats[STAT_HEALTH] == 1) { - ps->pm_type = PM_DEAD; - } - else { - ps->pm_type = PM_NORMAL; - } - } - else{ - if (client->noclip) { - ps->pm_type = PM_NOCLIP; - } - else if (ps->stats[STAT_HEALTH] <= 0) { - ps->pm_type = PM_DEAD; - } - else { - ps->pm_type = PM_NORMAL; - } - } + //RPG-X: Checked to see if medics revive is on if so do as following + if(rpg_medicsrevive.integer == 1) + { + if(client->noclip) + { + ps->pm_type = PM_NOCLIP; + } + else if(ps->stats[STAT_HEALTH] == 1) + { + ps->pm_type = PM_DEAD; + } + else + { + ps->pm_type = PM_NORMAL; + } + } + else + { + if(client->noclip) + { + ps->pm_type = PM_NOCLIP; + } + else if(ps->stats[STAT_HEALTH] <= 0) + { + ps->pm_type = PM_DEAD; + } + else + { + ps->pm_type = PM_NORMAL; + } + } - //RPG-X: J2J & Phenix - For the gravity ent - if (client->SpecialGrav != qtrue) - { - ps->gravity = g_gravity.value; - } + //RPG-X: J2J & Phenix - For the gravity ent + if(client->SpecialGrav != qtrue) + { + ps->gravity = g_gravity.value; + } - // set speed - ps->speed = g_speed.value; + // set speed + ps->speed = g_speed.value; - if (ps->powerups[PW_HASTE]) - { - ps->speed *= 1.5; - } - else if (ps->powerups[PW_FLIGHT]) - {//flying around - ps->speed *= 1.3; - } - else if (ps->stats[STAT_HEALTH] <= 20) { - ps->speed *= 0.55; - } + if(ps->powerups[PW_HASTE]) + { + ps->speed *= 1.5; + } + else if(ps->powerups[PW_FLIGHT]) + {//flying around + ps->speed *= 1.3; + } + else if(ps->stats[STAT_HEALTH] <= 20) + { + ps->speed *= 0.55; + } - if ((ps->powerups[PW_EVOSUIT]) && (ps->gravity == 0)) - {//Evosuit time.. RPG-X | Phenix | 8/8/2004 - ps->speed *= 1.3; - } + if((ps->powerups[PW_EVOSUIT]) && (ps->gravity == 0)) + {//Evosuit time.. RPG-X | Phenix | 8/8/2004 + ps->speed *= 1.3; + } - //RPG-X: Redtechie - n00bie stay.....good boy! - if (g_classData[client->sess.sessionClass].isn00b){ - ps->speed = 0; - } + //RPG-X: Redtechie - n00bie stay.....good boy! + if(g_classData[client->sess.sessionClass].isn00b) + { + ps->speed = 0; + } - //TiM : SP Style Transporter. :) - //first check to see if we should be beaming - if (level.time < TransDat[ps->clientNum].beamTime) { + //TiM : SP Style Transporter. :) + //first check to see if we should be beaming + if(level.time < TransDat[ps->clientNum].beamTime) + { - //if we're past the mid point of each materialization cycle, make it - //so bullets and other players will pass thru the transportee. :) - if ((level.time > TransDat[ps->clientNum].beamTime - 6000) && - (level.time < TransDat[ps->clientNum].beamTime - 2000)) { - if (ps->stats[STAT_HEALTH] > 1) { - ent->r.contents = CONTENTS_NONE; - } - } - else { - if (ps->stats[STAT_HEALTH] > 1) { - ent->r.contents = MASK_PLAYERSOLID; - } - } + //if we're past the mid point of each materialization cycle, make it + //so bullets and other players will pass thru the transportee. :) + if((level.time > TransDat[ps->clientNum].beamTime - 6000) && + (level.time < TransDat[ps->clientNum].beamTime - 2000)) + { + if(ps->stats[STAT_HEALTH] > 1) + { + ent->r.contents = CONTENTS_NONE; + } + } + else + { + if(ps->stats[STAT_HEALTH] > 1) + { + ent->r.contents = MASK_PLAYERSOLID; + } + } - //If we're half-way thru the cycle, teleport the player now - if (level.time > TransDat[ps->clientNum].beamTime - 4000 && - !TransDat[ps->clientNum].beamed) { - TeleportPlayer(ent, TransDat[ps->clientNum].currentCoord.origin, - TransDat[ps->clientNum].currentCoord.angles, - TP_TRI_TP); + //If we're half-way thru the cycle, teleport the player now + if(level.time > TransDat[ps->clientNum].beamTime - 4000 && + !TransDat[ps->clientNum].beamed) + { + TeleportPlayer(ent, TransDat[ps->clientNum].currentCoord.origin, + TransDat[ps->clientNum].currentCoord.angles, + TP_TRI_TP); - TransDat[ps->clientNum].beamed = qtrue; - } - } - else { - //all done, let's reset :) - if (TransDat[ps->clientNum].beamTime > 0) { - TransDat[ps->clientNum].beamTime = 0; - ps->powerups[PW_BEAM_OUT] = 0; - ps->powerups[PW_QUAD] = 0; - TransDat[ps->clientNum].beamed = qfalse; + TransDat[ps->clientNum].beamed = qtrue; + } + } + else + { + //all done, let's reset :) + if(TransDat[ps->clientNum].beamTime > 0) + { + TransDat[ps->clientNum].beamTime = 0; + ps->powerups[PW_BEAM_OUT] = 0; + ps->powerups[PW_QUAD] = 0; + TransDat[ps->clientNum].beamed = qfalse; - memset(&TransDat[ps->clientNum].currentCoord, 0, - sizeof(TransDat[ps->clientNum].currentCoord.origin)); + memset(&TransDat[ps->clientNum].currentCoord, 0, + sizeof(TransDat[ps->clientNum].currentCoord.origin)); - if (g_entities[ps->clientNum].flags & FL_CLAMPED) { - //reset everything if player was beamed by trigger_transporter - g_entities[ps->clientNum].flags ^= FL_CLAMPED; - } - } - } + if(g_entities[ps->clientNum].flags & FL_CLAMPED) + { + //reset everything if player was beamed by trigger_transporter + g_entities[ps->clientNum].flags ^= FL_CLAMPED; + } + } + } - //TiM : Freeze their movement if they're halfway through a transport cycle - if (level.time < TransDat[ps->clientNum].beamTime && - level.time > TransDat[ps->clientNum].beamTime - 4000) - { - vec3_t endPoint; - trace_t tr; - VectorSet(endPoint, ps->origin[0], ps->origin[1], ps->origin[2] - 48); - //Do a trace down. If we're near ground, just re-enable gravity. Else we we get weird animations O_o - trap_Trace(&tr, ps->origin, NULL, NULL, endPoint, ps->clientNum, CONTENTS_SOLID); + //TiM : Freeze their movement if they're halfway through a transport cycle + if(level.time < TransDat[ps->clientNum].beamTime && + level.time > TransDat[ps->clientNum].beamTime - 4000) + { + vec3_t endPoint; + trace_t tr; + VectorSet(endPoint, ps->origin[0], ps->origin[1], ps->origin[2] - 48); + //Do a trace down. If we're near ground, just re-enable gravity. Else we we get weird animations O_o + trap_Trace(&tr, ps->origin, NULL, NULL, endPoint, ps->clientNum, CONTENTS_SOLID); - if (tr.fraction == 1.0) { - ps->gravity = 0; - ps->velocity[2] = 0; - } + if(tr.fraction == 1.0) + { + ps->gravity = 0; + ps->velocity[2] = 0; + } - ps->speed = 0; + ps->speed = 0; - ps->velocity[0] = ps->velocity[1] = 0.0; - } + ps->velocity[0] = ps->velocity[1] = 0.0; + } - // set up for pmove - oldEventSequence = ps->eventSequence; + // set up for pmove + oldEventSequence = ps->eventSequence; - memset(&pm, 0, sizeof(pm)); + memset(&pm, 0, sizeof(pm)); - pm.ps = &client->ps; - pm.cmd = *ucmd; - if (pm.ps->pm_type == PM_DEAD) { - pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; - } - else { - pm.tracemask = MASK_PLAYERSOLID; - } + pm.ps = &client->ps; + pm.cmd = *ucmd; + if(pm.ps->pm_type == PM_DEAD) + { + pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; + } + else + { + pm.tracemask = MASK_PLAYERSOLID; + } - pm.trace = trap_Trace; - pm.pointcontents = trap_PointContents; - pm.debugLevel = g_debugMove.integer; - pm.noFootsteps = (qboolean)((g_dmflags.integer & DF_NO_FOOTSTEPS) > 0); - pm.pModDisintegration = qfalse; + pm.trace = trap_Trace; + pm.pointcontents = trap_PointContents; + pm.debugLevel = g_debugMove.integer; + pm.noFootsteps = (qboolean)((g_dmflags.integer & DF_NO_FOOTSTEPS) > 0); + pm.pModDisintegration = qfalse; - //pm.admin = IsAdmin(ent); // we use this way now the old way didn't work for adminlogin - // y call a function though??? - pm.admin = (qboolean)(g_classData[client->sess.sessionClass].isAdmin || client->LoggedAsAdmin); - //pm.admin = g_classData[client->sess.sessionClass].isAdmin; - pm.medic = (qboolean)g_classData[client->sess.sessionClass].isMedical; - pm.borg = (qboolean)g_classData[client->sess.sessionClass].isBorg; + //pm.admin = IsAdmin(ent); // we use this way now the old way didn't work for adminlogin + // y call a function though??? + pm.admin = (qboolean)(g_classData[client->sess.sessionClass].isAdmin || client->LoggedAsAdmin); + //pm.admin = g_classData[client->sess.sessionClass].isAdmin; + pm.medic = (qboolean)g_classData[client->sess.sessionClass].isMedical; + pm.borg = (qboolean)g_classData[client->sess.sessionClass].isBorg; - // perform a pmove - Pmove(&pm); + // perform a pmove + Pmove(&pm); - // save results of pmove - if (ps->eventSequence != oldEventSequence) { - ent->eventTime = level.time; - } - BG_PlayerStateToEntityState(ps, &ent->s, qtrue); + // save results of pmove + if(ps->eventSequence != oldEventSequence) + { + ent->eventTime = level.time; + } + BG_PlayerStateToEntityState(ps, &ent->s, qtrue); - SendPendingPredictableEvents(ps); + SendPendingPredictableEvents(ps); - // use the snapped origin for linking so it matches client predicted versions - VectorCopy(ent->s.pos.trBase, ent->r.currentOrigin); + // use the snapped origin for linking so it matches client predicted versions + VectorCopy(ent->s.pos.trBase, ent->r.currentOrigin); - VectorCopy(pm.mins, ent->r.mins); - VectorCopy(pm.maxs, ent->r.maxs); + VectorCopy(pm.mins, ent->r.mins); + VectorCopy(pm.maxs, ent->r.maxs); - ent->waterlevel = pm.waterlevel; - ent->watertype = pm.watertype; + ent->waterlevel = pm.waterlevel; + ent->watertype = pm.watertype; - // execute client events - ClientEvents(ent, oldEventSequence); + // execute client events + ClientEvents(ent, oldEventSequence); - if (pm.useEvent) - { //TODO: Use - TryUse(ent); - } + if(pm.useEvent) + { //TODO: Use + TryUse(ent); + } - // link entity now, after any personal teleporters have been used - trap_LinkEntity(ent); - G_TouchTriggers(ent); + // link entity now, after any personal teleporters have been used + trap_LinkEntity(ent); + G_TouchTriggers(ent); - // NOTE: now copy the exact origin over otherwise clients can be snapped into solid - VectorCopy(ps->origin, ent->r.currentOrigin); + // NOTE: now copy the exact origin over otherwise clients can be snapped into solid + VectorCopy(ps->origin, ent->r.currentOrigin); - //test for solid areas in the AAS file - AI_main_BotTestSolid(ent->r.currentOrigin); + //test for solid areas in the AAS file + AI_main_BotTestSolid(ent->r.currentOrigin); - // touch other objects - ClientImpacts(ent, &pm); + // touch other objects + ClientImpacts(ent, &pm); - // save results of triggers and client events - if (ps->eventSequence != oldEventSequence) { - ent->eventTime = level.time; - } + // save results of triggers and client events + if(ps->eventSequence != oldEventSequence) + { + ent->eventTime = level.time; + } - // swap and latch button actions - client->oldbuttons = client->buttons; - client->buttons = ucmd->buttons; - client->latched_buttons |= client->buttons & ~client->oldbuttons; + // swap and latch button actions + client->oldbuttons = client->buttons; + client->buttons = ucmd->buttons; + client->latched_buttons |= client->buttons & ~client->oldbuttons; - // check for respawning - if (client->ps.stats[STAT_HEALTH] <= 0) { - // wait for the attack button to be pressed - if (level.time > client->respawnTime) { - // pressing attack or use is the normal respawn method - if (ucmd->buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE)) { - G_Client_Respawn(ent); - return; - } - } - return; - } + // check for respawning + if(client->ps.stats[STAT_HEALTH] <= 0) + { + // wait for the attack button to be pressed + if(level.time > client->respawnTime) + { + // pressing attack or use is the normal respawn method + if(ucmd->buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE)) + { + G_Client_Respawn(ent); + return; + } + } + return; + } - // perform once-a-second actions - ClientTimerActions(ent, msec); + // perform once-a-second actions + ClientTimerActions(ent, msec); - if (client->teleportTime > 0 && client->teleportTime < level.time) - { - if (g_classData[client->sess.sessionClass].isMarine) - { - G_GiveHoldable(client, HI_TRANSPORTER); - ps->stats[STAT_USEABLE_PLACED] = 0; - client->teleportTime = 0; - } - else if (g_classData[client->sess.sessionClass].isAdmin) - { - G_GiveHoldable(client, HI_SHIELD); - ps->stats[STAT_USEABLE_PLACED] = 0; - client->teleportTime = 0; - } - } + if(client->teleportTime > 0 && client->teleportTime < level.time) + { + if(g_classData[client->sess.sessionClass].isMarine) + { + G_GiveHoldable(client, HI_TRANSPORTER); + ps->stats[STAT_USEABLE_PLACED] = 0; + client->teleportTime = 0; + } + else if(g_classData[client->sess.sessionClass].isAdmin) + { + G_GiveHoldable(client, HI_SHIELD); + ps->stats[STAT_USEABLE_PLACED] = 0; + client->teleportTime = 0; + } + } } -void ClientThink(int clientNum) { - gentity_t* ent = NULL; +void ClientThink(int clientNum) +{ + gentity_t* ent = NULL; - ent = g_entities + clientNum; - trap_GetUsercmd(clientNum, &ent->client->pers.cmd); + ent = g_entities + clientNum; + trap_GetUsercmd(clientNum, &ent->client->pers.cmd); - // mark the time we got info, so we can display the - // phone jack if they don't get any for a while - ent->client->lastCmdTime = level.time; + // mark the time we got info, so we can display the + // phone jack if they don't get any for a while + ent->client->lastCmdTime = level.time; - if (!g_synchronousClients.integer) { - ClientThink_real(ent); - } + if(!g_synchronousClients.integer) + { + ClientThink_real(ent); + } } -void G_RunClient(gentity_t* ent) { - if (g_synchronousClients.integer == 0) { - return; - } +void G_RunClient(gentity_t* ent) +{ + if(g_synchronousClients.integer == 0) + { + return; + } - ent->client->pers.cmd.serverTime = level.time; - ClientThink_real(ent); + ent->client->pers.cmd.serverTime = level.time; + ClientThink_real(ent); } @@ -2268,103 +2399,121 @@ SpectatorClientEndFrame ================== */ -static void SpectatorClientEndFrame(gentity_t *ent) { - gclient_t* cl = NULL; - clientSession_t* sess = &ent->client->sess; - playerState_t* ps = &ent->client->ps; +static void SpectatorClientEndFrame(gentity_t *ent) +{ + gclient_t* cl = NULL; + clientSession_t* sess = &ent->client->sess; + playerState_t* ps = &ent->client->ps; - // if we are doing a chase cam or a remote view, grab the latest info - if (sess->spectatorState == SPECTATOR_FOLLOW) { - int32_t clientNum; + // if we are doing a chase cam or a remote view, grab the latest info + if(sess->spectatorState == SPECTATOR_FOLLOW) + { + int32_t clientNum; - clientNum = sess->spectatorClient; + clientNum = sess->spectatorClient; - // team follow1 and team follow2 go to whatever clients are playing - if (clientNum == -1) { - clientNum = level.follow1; - } - else if (clientNum == -2) { - clientNum = level.follow2; - } - if (clientNum >= 0) { - cl = &level.clients[clientNum]; - if (cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR) { - ent->client->ps = cl->ps; - ps->pm_flags |= PMF_FOLLOW; - return; - } - else { - // drop them to free spectators unless they are dedicated camera followers - if (sess->spectatorClient >= 0) { - sess->spectatorState = SPECTATOR_FREE; - G_Client_Begin(ent->client - level.clients, qfalse, qfalse, qfalse); - } - } - } - } + // team follow1 and team follow2 go to whatever clients are playing + if(clientNum == -1) + { + clientNum = level.follow1; + } + else if(clientNum == -2) + { + clientNum = level.follow2; + } + if(clientNum >= 0) + { + cl = &level.clients[clientNum]; + if(cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR) + { + ent->client->ps = cl->ps; + ps->pm_flags |= PMF_FOLLOW; + return; + } + else + { + // drop them to free spectators unless they are dedicated camera followers + if(sess->spectatorClient >= 0) + { + sess->spectatorState = SPECTATOR_FREE; + G_Client_Begin(ent->client - level.clients, qfalse, qfalse, qfalse); + } + } + } + } - if (sess->spectatorState == SPECTATOR_SCOREBOARD) { - ps->pm_flags |= PMF_SCOREBOARD; - } - else { - ps->pm_flags &= ~PMF_SCOREBOARD; - } + if(sess->spectatorState == SPECTATOR_SCOREBOARD) + { + ps->pm_flags |= PMF_SCOREBOARD; + } + else + { + ps->pm_flags &= ~PMF_SCOREBOARD; + } } -void ClientEndFrame(gentity_t *ent) { - int32_t i; - playerState_t *ps = &ent->client->ps; +void ClientEndFrame(gentity_t *ent) +{ + int32_t i; + playerState_t *ps = &ent->client->ps; - if (ent->client->sess.sessionTeam == TEAM_SPECTATOR /*|| (ps->eFlags&EF_ELIMINATED)*/) { - SpectatorClientEndFrame(ent); - ent->client->noclip = qtrue; - return; - } + if(ent->client->sess.sessionTeam == TEAM_SPECTATOR /*|| (ps->eFlags&EF_ELIMINATED)*/) + { + SpectatorClientEndFrame(ent); + ent->client->noclip = qtrue; + return; + } - // turn off any expired powerups - for (i = 0; i < MAX_POWERUPS; i++) { - if (ps->powerups[i] < level.time) { - ps->powerups[i] = 0; - } - } + // turn off any expired powerups + for(i = 0; i < MAX_POWERUPS; i++) + { + if(ps->powerups[i] < level.time) + { + ps->powerups[i] = 0; + } + } - // save network bandwidth + // save network bandwidth #if 0 - if ( !g_synchronousClients->integer && ps->pm_type == PM_NORMAL ) { - // FIXME: this must change eventually for non-sync demo recording - VectorClear( ps->viewangles ); - } + if(!g_synchronousClients->integer && ps->pm_type == PM_NORMAL) + { + // FIXME: this must change eventually for non-sync demo recording + VectorClear(ps->viewangles); + } #endif - // - // If the end of unit layout is displayed, don't give - // the player any normal movement attributes - // - if (level.intermissiontime) { - return; - } + // + // If the end of unit layout is displayed, don't give + // the player any normal movement attributes + // + if(level.intermissiontime) + { + return; + } - // burn from lava, etc - P_WorldEffects(ent); + // burn from lava, etc + P_WorldEffects(ent); - // apply all the damage taken this frame - P_DamageFeedback(ent); + // apply all the damage taken this frame + P_DamageFeedback(ent); - // add the EF_CONNECTION flag if we haven't gotten commands recently - if (level.time - ent->client->lastCmdTime > 1000) { - ent->s.eFlags |= EF_CONNECTION; - } - else { - ent->s.eFlags &= ~EF_CONNECTION; - } + // add the EF_CONNECTION flag if we haven't gotten commands recently + if(level.time - ent->client->lastCmdTime > 1000) + { + ent->s.eFlags |= EF_CONNECTION; + } + else + { + ent->s.eFlags &= ~EF_CONNECTION; + } - ps->stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health... + ps->stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health... - G_SetClientSound(ent); + G_SetClientSound(ent); - // set the latest infor - BG_PlayerStateToEntityState(ps, &ent->s, qtrue); - SendPendingPredictableEvents(ps); + // set the latest infor + BG_PlayerStateToEntityState(ps, &ent->s, qtrue); + SendPendingPredictableEvents(ps); } diff --git a/code/game/g_local.h b/code/game/g_local.h index 1fab3c4..c40d8e9 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -4,6 +4,9 @@ #ifndef _G_LOCAL_H_ #define _G_LOCAL_H_ +#include +#include + #include "../base_game/q_shared.h" #include "../base_game/bg_public.h" #include "g_public.h" @@ -837,8 +840,9 @@ typedef struct { /*@shared@*/ /*@null@*/ list_p safezones; /*!< self destruct safezones list */ /*@shared@*/ /*@null@*/ list_p locations; /*!< level locations list */ - /*@shared@*/ /*@null@*/ list_p timedMessages; /*!< timed messages list */ - /*@shared@*/ /*@null@*/ list_iter_p iterTimedMessages; + + size_t timedMessageIndex = 0; + std::vector timedMessages; // other stuff srvChangeData_t srvChangeData; /*!< Server change data */ diff --git a/code/game/g_main.cpp b/code/game/g_main.cpp index eae367a..dea5f0b 100644 --- a/code/game/g_main.cpp +++ b/code/game/g_main.cpp @@ -1,6 +1,8 @@ // Copyright (C) 1999-2000 Id Software, Inc. // +#include + #include "g_main.h" #include "g_local.h" #include "g_groups.h" @@ -29,8 +31,9 @@ extern int32_t AI_main_BotAILoadMap(int32_t restart); extern void BG_LoadItemNames(void); extern qboolean BG_ParseRankNames(char* fileName, rankNames_t rankNames[], size_t size); -enum g_mainLimits_e { - MAX_GROUP_FILE_SIZE = 5000 +enum g_mainLimits_e +{ + MAX_GROUP_FILE_SIZE = 5000 }; //RPG-X: RedTechie @@ -43,13 +46,14 @@ group_list_t group_list[MAX_GROUP_MEMBERS]; int32_t group_count; int32_t numKilled; -typedef struct { - /*@shared@*/ /*@null@*/ vmCvar_t *vmCvar; - char* cvarName; - char* defaultString; - int cvarFlags; - int modificationCount; // for tracking changes - qboolean trackChange; // track this variable, and announce if changed +typedef struct +{ + /*@shared@*/ /*@null@*/ vmCvar_t *vmCvar; + char* cvarName; + char* defaultString; + int cvarFlags; + int modificationCount; // for tracking changes + qboolean trackChange; // track this variable, and announce if changed } cvarTable_t; gentity_t g_entities[MAX_GENTITIES]; @@ -312,168 +316,168 @@ vmCvar_t rpg_spEasterEggs; static cvarTable_t gameCvarTable[] = { - // don't override the cheat state set by the system - { &g_cheats, "sv_cheats", "", 0, 0, qfalse }, - // noset vars - { NULL, "gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, - { NULL, "gamedate", __DATE__, CVAR_ROM, 0, qfalse }, - { &g_restarted, "g_restarted", "0", CVAR_ROM, 0, qfalse }, - { NULL, "sv_mapname", "", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, - // latched vars - { &g_gametype, "g_gametype", "0", CVAR_SERVERINFO | CVAR_LATCH | CVAR_INIT | CVAR_ROM, 0, qfalse }, - { &g_maxclients, "sv_maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &g_maxGameClients, "g_maxGameClients", "0", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - // change anytime vars - { &g_dmflags, "dmflags", "0", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, - { &g_synchronousClients, "g_synchronousClients", "0", CVAR_SYSTEMINFO, 0, qfalse }, - { &g_log, "g_log", "", CVAR_ARCHIVE, 0, qfalse }, - { &g_logSync, "g_logSync", "0", CVAR_ARCHIVE, 0, qfalse }, - { &g_password, "g_password", "", CVAR_USERINFO, 0, qfalse }, - { &g_banIPs, "g_banIPs", "", CVAR_ARCHIVE, 0, qfalse }, - { &g_filterBan, "g_filterBan", "1", CVAR_ARCHIVE, 0, qfalse }, - { &g_banIDs, "g_banIDs", "", CVAR_ARCHIVE, 0, qfalse }, - { &g_needpass, "g_needpass", "0", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, - { &g_dedicated, "dedicated", "0", 0, 0, qfalse }, - { &g_speed, "g_speed", "250", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, // Quake 3 default was 320. - { &g_gravity, "g_gravity", "800", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, - { &g_knockback, "g_knockback", "500", 0, 0, qtrue }, - { &g_dmgmult, "g_dmgmult", "1", 0, 0, qtrue }, - { &g_weaponRespawn, "g_weaponrespawn", "5", 0, 0, qtrue }, // Quake 3 default (with 1 ammo weapons) was 5. - { &g_adaptRespawn, "g_adaptrespawn", "1", 0, 0, qtrue }, // Make weapons respawn faster with a lot of players. - { &g_forcerespawn, "g_forcerespawn", "0", 0, 0, qtrue }, // Quake 3 default was 20. This is more "user friendly". - { &g_inactivity, "g_inactivity", "0", 0, 0, qtrue }, - { &g_debugMove, "g_debugMove", "0", 0, 0, qfalse }, - { &g_debugDamage, "g_debugDamage", "0", 0, 0, qfalse }, - { &g_debugAlloc, "g_debugAlloc", "0", 0, 0, qfalse }, - { &g_motd, "g_motd", "", 0, 0, qfalse }, - { &g_allowVote, "g_allowVote", "1", CVAR_SERVERINFO, 0, qfalse }, + // don't override the cheat state set by the system + { &g_cheats, "sv_cheats", "", 0, 0, qfalse }, + // noset vars + { NULL, "gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, + { NULL, "gamedate", __DATE__, CVAR_ROM, 0, qfalse }, + { &g_restarted, "g_restarted", "0", CVAR_ROM, 0, qfalse }, + { NULL, "sv_mapname", "", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, + // latched vars + { &g_gametype, "g_gametype", "0", CVAR_SERVERINFO | CVAR_LATCH | CVAR_INIT | CVAR_ROM, 0, qfalse }, + { &g_maxclients, "sv_maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &g_maxGameClients, "g_maxGameClients", "0", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + // change anytime vars + { &g_dmflags, "dmflags", "0", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, + { &g_synchronousClients, "g_synchronousClients", "0", CVAR_SYSTEMINFO, 0, qfalse }, + { &g_log, "g_log", "", CVAR_ARCHIVE, 0, qfalse }, + { &g_logSync, "g_logSync", "0", CVAR_ARCHIVE, 0, qfalse }, + { &g_password, "g_password", "", CVAR_USERINFO, 0, qfalse }, + { &g_banIPs, "g_banIPs", "", CVAR_ARCHIVE, 0, qfalse }, + { &g_filterBan, "g_filterBan", "1", CVAR_ARCHIVE, 0, qfalse }, + { &g_banIDs, "g_banIDs", "", CVAR_ARCHIVE, 0, qfalse }, + { &g_needpass, "g_needpass", "0", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse }, + { &g_dedicated, "dedicated", "0", 0, 0, qfalse }, + { &g_speed, "g_speed", "250", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, // Quake 3 default was 320. + { &g_gravity, "g_gravity", "800", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue }, + { &g_knockback, "g_knockback", "500", 0, 0, qtrue }, + { &g_dmgmult, "g_dmgmult", "1", 0, 0, qtrue }, + { &g_weaponRespawn, "g_weaponrespawn", "5", 0, 0, qtrue }, // Quake 3 default (with 1 ammo weapons) was 5. + { &g_adaptRespawn, "g_adaptrespawn", "1", 0, 0, qtrue }, // Make weapons respawn faster with a lot of players. + { &g_forcerespawn, "g_forcerespawn", "0", 0, 0, qtrue }, // Quake 3 default was 20. This is more "user friendly". + { &g_inactivity, "g_inactivity", "0", 0, 0, qtrue }, + { &g_debugMove, "g_debugMove", "0", 0, 0, qfalse }, + { &g_debugDamage, "g_debugDamage", "0", 0, 0, qfalse }, + { &g_debugAlloc, "g_debugAlloc", "0", 0, 0, qfalse }, + { &g_motd, "g_motd", "", 0, 0, qfalse }, + { &g_allowVote, "g_allowVote", "1", CVAR_SERVERINFO, 0, qfalse }, #if 0 - { &g_debugForward, "g_debugForward", "0", 0, 0, qfalse }, - { &g_debugRight, "g_debugRight", "0", 0, 0, qfalse }, - { &g_debugUp, "g_debugUp", "0", 0, 0, qfalse }, + { &g_debugForward, "g_debugForward", "0", 0, 0, qfalse }, + { &g_debugRight, "g_debugRight", "0", 0, 0, qfalse }, + { &g_debugUp, "g_debugUp", "0", 0, 0, qfalse }, #endif - { &g_language, "g_language", "", CVAR_ARCHIVE, 0, qfalse }, - { &g_holoIntro, "g_holoIntro", "1", CVAR_ARCHIVE, 0, qfalse }, - { &g_team_group_red, "g_team_group_red", "", CVAR_LATCH, 0, qfalse }, // Used to have CVAR_ARCHIVE - { &g_team_group_blue, "g_team_group_blue", "", CVAR_LATCH, 0, qfalse }, // Used to have CVAR_ARCHIVE - { &g_random_skin_limit, "g_random_skin_limit", "4", CVAR_ARCHIVE, 0, qfalse }, - { &g_classChangeDebounceTime, "g_classChangeDebounceTime", "180", CVAR_ARCHIVE, 0, qfalse }, - //RPG-X: RedTechie - RPG-X CVARS....duh....just for the slow ones - { &rpg_allowvote, "rpg_allowVote", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_chatsallowed, "rpg_chatsAllowed", "10", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_allowsuicide, "rpg_allowSuicide", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_selfdamage, "rpg_selfDamage", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_rpg, "rpg_rpg", "1", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_kickspammers, "rpg_kickSpammers", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_kicksuiciders, "rpg_kickSuiciders", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_allowspmaps, "rpg_allowSPMaps", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_rangetricorder, "rpg_rangeTricorder", "128", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_rangehypo, "rpg_rangeHypo", "32", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_norpgclasses, "rpg_noRPGClasses", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_forceclasscolor, "rpg_forceClassColor", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_restrictions, "rpg_restrictions", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_dmgFlags, "rpg_dmgFlags", "63", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_noweapons, "rpg_noWeapons", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_welcomemessage, "rpg_welcomeMessage", "Welcome to the RPG-X Mod", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_timedmessagetime, "rpg_timedMessageTime", "0", CVAR_ARCHIVE, 0, qfalse }, //TiM : LATCH Not necessary here. - { &rpg_forcekillradius, "rpg_forceKillRadius", "0", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, - { &rpg_forcekillradiuswaittime, "rpg_forceKillRadiusWaitTime", "45000", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, - { &rpg_chatarearange, "rpg_chatAreaRange", "200", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, //Not latched (ie doesnt need server restart) - { &rpg_forcefielddamage, "rpg_forcefieldDamage", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_invisibletripmines, "rpg_invisibleTripmines", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, - { &rpg_medicsrevive, "rpg_medicsRevive", "1", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, - { &rpg_effectsgun, "rpg_effectsGun", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, - { &rpg_phaserdisintegrates, "rpg_phaserDisintegrates", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_kickAfterXkills, "rpg_kickAfterNumkills", "2", CVAR_ARCHIVE, 0, qfalse }, //RPG-X | Phenix | 06/04/2005 - { &rpg_rankSet, "rpg_rankSet", (char*)RANKSET_DEFAULT, CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse }, - { &rpg_passMessage, "rpg_passMessage", "", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_renamedPlayers, "rpg_renamedPlayers", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_uniqueNames, "rpg_uniqueNames", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_startingRank, "rpg_startingRank", "", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_maxRank, "rpg_maxRank", "", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, - { &rpg_changeRanks, "rpg_changeRanks", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_classSet, "rpg_classSet", "rpgx_default", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse }, - { &rpg_maxHeight, "rpg_maxHeight", "1.15", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_minHeight, "rpg_minHeight", "0.90", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_maxWeight, "rpg_maxWeight", "1.10", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_minWeight, "rpg_minWeight", "0.90", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_mapGiveFlags, "rpg_mapGiveFlags", "0", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, - //TiM - maybe we can fix it later, but for now, disable it - { &rpg_scannablePanels, "rpg_scannablePanels", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO, 0, qfalse }, - { &rpg_allowWeaponDrop, "rpg_allowWeaponDrop", "1", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 03/12/2008 - { &rpg_weaponsStay, "rpg_weaponsStay", "0", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 04/12/2008 - { &rpg_rifleSpeed, "rpg_rifleSpeed", "2700", 0, 0, qtrue }, // RPG-X | Marcin | 04/12/2008 - { &rpg_disruptorSpeed, "rpg_disruptorSpeed", "3000", 0, 0, qtrue },// RPG-X | Marcin | 04/12/2008 - { &rpg_photonSpeed, "rpg_photonSpeed", "1300", 0, 0, qtrue }, // RPG-X | Marcin | 05/12/2008 - { &rpg_altPhotonSpeed, "rpg_altPhotonSpeed", "650", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 - { &rpg_rifleDelay, "rpg_rifleDelay", "250", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 - { &rpg_disruptorDelay, "rpg_disruptorDelay", "700", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 - { &rpg_photonDelay, "rpg_photonDelay", "1200", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 - { &rpg_altPhotonDelay, "rpg_altPhotonDelay", "1600", 0, 0, qtrue },// RPG-X | Marcin | 06/12/2008 - { &rpg_TR116Delay, "rpg_TR116Delay", "500", 0, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_motdFile, "rpg_motdFile", "RPG-X_Motd.txt", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, // RPG-X | Marcin | 23/12/2008 - { &rpg_respectPrivacy, "rpg_respectPrivacy", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, // RPG-X | Marcin | 24/12/2008 - { &rpg_maxTricorders, "rpg_maxTricorders", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxPADDs, "rpg_maxPADDs", "10", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxCups, "rpg_maxCups", "2", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxPhasers, "rpg_maxPhasers", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxRifles, "rpg_maxRifles", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxTR116s, "rpg_maxTR116s", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxAdminguns, "rpg_maxAdminguns", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxPhotonbursts, "rpg_maxPhotonbursts", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxDisruptors, "rpg_maxDisruptors", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxMedkits, "rpg_maxMedkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxHyposprays, "rpg_maxHyposprays", "2", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxRegenerators, "rpg_maxRegenerators", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxToolkits, "rpg_maxToolkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_maxHyperSpanners, "rpg_maxHyperSpanners", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minTricorders, "rpg_minTricorders", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minPADDs, "rpg_minPADDs", "5", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minCups, "rpg_minCups", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minPhasers, "rpg_minPhasers", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minRifles, "rpg_minRifles", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minTR116s, "rpg_minTR116s", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minAdminguns, "rpg_minAdminguns", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minPhotonbursts, "rpg_minPhotonbursts", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minDisruptors, "rpg_minDisruptors", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minMedkits, "rpg_minMedkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minHyposprays, "rpg_minHyposprays", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minRegenerators, "rpg_minRegenerators", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minToolkits, "rpg_minToolkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_minHyperSpanners, "rpg_minHyperSpanners", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 - { &rpg_dropOnDeath, "rpg_dropItemsOnDeath", "1", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 30/12/2008 - { &rpg_fraggerSpawnDelay, "rpg_fraggerSpawnDelay", "100", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_borgAdapt, "rpg_borgAdapt", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_hypoMelee, "rpg_hypoMelee", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptUseSound, "rpg_adaptUseSound", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptCrifleHits, "rpg_adaptCrifleHits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptDisruptorHits, "rpg_adaptDisruptorHits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptPhaserHits, "rpg_adaptPhaserHits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptPhotonHits, "rpg_adaptPhotonHits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptTR116Hits, "rpg_adaptTR116Hits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adaptGrenadeLauncherHits, "rpg_adaptGrenadeLauncherHits", "6", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_repairModifier, "rpg_repairModifier", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_forceFieldColor, "rpg_forceFieldColor", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_allowRemodulation, "rpg_allowRemodulation", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_forceFieldFreq, "rpg_forceFieldFreq", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_calcLiftTravelDuration, "rpg_calcLiftTravelDuration", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_liftDurationModifier, "rpg_liftDurationModifier", "0.5", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_altTricorderDelay, "rpg_altTricorderDelay", "1000", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_borgMoveThroughFields, "rpg_borgMoveThroughFields", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_RemodulationDelay, "rpg_RemodulationDelay", "5000", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_adminVoteOverride, "rpg_adminVoteOverride", "1", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_serverchange, "rpg_serverchange", "0", CVAR_ARCHIVE, 0, qfalse }, - { &rpg_allowSPLevelChange, "rpg_allowSPLevelChange", "1", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, - { &rpg_spEasterEggs, "rpg_spEasterEggs", "0", CVAR_ARCHIVE, 0, qfalse }, - { &dev_showTriggers, "dev_showTriggers", "0", CVAR_ARCHIVE, 0, qfalse }, - { &sql_use, "sql_use", "0", CVAR_ARCHIVE, 0, qfalse }, + { &g_language, "g_language", "", CVAR_ARCHIVE, 0, qfalse }, + { &g_holoIntro, "g_holoIntro", "1", CVAR_ARCHIVE, 0, qfalse }, + { &g_team_group_red, "g_team_group_red", "", CVAR_LATCH, 0, qfalse }, // Used to have CVAR_ARCHIVE + { &g_team_group_blue, "g_team_group_blue", "", CVAR_LATCH, 0, qfalse }, // Used to have CVAR_ARCHIVE + { &g_random_skin_limit, "g_random_skin_limit", "4", CVAR_ARCHIVE, 0, qfalse }, + { &g_classChangeDebounceTime, "g_classChangeDebounceTime", "180", CVAR_ARCHIVE, 0, qfalse }, + //RPG-X: RedTechie - RPG-X CVARS....duh....just for the slow ones + { &rpg_allowvote, "rpg_allowVote", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_chatsallowed, "rpg_chatsAllowed", "10", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_allowsuicide, "rpg_allowSuicide", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_selfdamage, "rpg_selfDamage", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_rpg, "rpg_rpg", "1", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_kickspammers, "rpg_kickSpammers", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_kicksuiciders, "rpg_kickSuiciders", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_allowspmaps, "rpg_allowSPMaps", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_rangetricorder, "rpg_rangeTricorder", "128", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_rangehypo, "rpg_rangeHypo", "32", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_norpgclasses, "rpg_noRPGClasses", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_forceclasscolor, "rpg_forceClassColor", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_restrictions, "rpg_restrictions", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_dmgFlags, "rpg_dmgFlags", "63", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_noweapons, "rpg_noWeapons", "0", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_welcomemessage, "rpg_welcomeMessage", "Welcome to the RPG-X Mod", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_timedmessagetime, "rpg_timedMessageTime", "0", CVAR_ARCHIVE, 0, qfalse }, //TiM : LATCH Not necessary here. + { &rpg_forcekillradius, "rpg_forceKillRadius", "0", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, + { &rpg_forcekillradiuswaittime, "rpg_forceKillRadiusWaitTime", "45000", CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse }, + { &rpg_chatarearange, "rpg_chatAreaRange", "200", CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue }, //Not latched (ie doesnt need server restart) + { &rpg_forcefielddamage, "rpg_forcefieldDamage", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_invisibletripmines, "rpg_invisibleTripmines", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, + { &rpg_medicsrevive, "rpg_medicsRevive", "1", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, + { &rpg_effectsgun, "rpg_effectsGun", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, + { &rpg_phaserdisintegrates, "rpg_phaserDisintegrates", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_kickAfterXkills, "rpg_kickAfterNumkills", "2", CVAR_ARCHIVE, 0, qfalse }, //RPG-X | Phenix | 06/04/2005 + { &rpg_rankSet, "rpg_rankSet", (char*)RANKSET_DEFAULT, CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse }, + { &rpg_passMessage, "rpg_passMessage", "", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_renamedPlayers, "rpg_renamedPlayers", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_uniqueNames, "rpg_uniqueNames", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_startingRank, "rpg_startingRank", "", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_maxRank, "rpg_maxRank", "", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, + { &rpg_changeRanks, "rpg_changeRanks", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_classSet, "rpg_classSet", "rpgx_default", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse }, + { &rpg_maxHeight, "rpg_maxHeight", "1.15", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_minHeight, "rpg_minHeight", "0.90", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_maxWeight, "rpg_maxWeight", "1.10", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_minWeight, "rpg_minWeight", "0.90", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_mapGiveFlags, "rpg_mapGiveFlags", "0", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, + //TiM - maybe we can fix it later, but for now, disable it + { &rpg_scannablePanels, "rpg_scannablePanels", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO, 0, qfalse }, + { &rpg_allowWeaponDrop, "rpg_allowWeaponDrop", "1", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 03/12/2008 + { &rpg_weaponsStay, "rpg_weaponsStay", "0", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 04/12/2008 + { &rpg_rifleSpeed, "rpg_rifleSpeed", "2700", 0, 0, qtrue }, // RPG-X | Marcin | 04/12/2008 + { &rpg_disruptorSpeed, "rpg_disruptorSpeed", "3000", 0, 0, qtrue },// RPG-X | Marcin | 04/12/2008 + { &rpg_photonSpeed, "rpg_photonSpeed", "1300", 0, 0, qtrue }, // RPG-X | Marcin | 05/12/2008 + { &rpg_altPhotonSpeed, "rpg_altPhotonSpeed", "650", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 + { &rpg_rifleDelay, "rpg_rifleDelay", "250", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 + { &rpg_disruptorDelay, "rpg_disruptorDelay", "700", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 + { &rpg_photonDelay, "rpg_photonDelay", "1200", 0, 0, qtrue }, // RPG-X | Marcin | 06/12/2008 + { &rpg_altPhotonDelay, "rpg_altPhotonDelay", "1600", 0, 0, qtrue },// RPG-X | Marcin | 06/12/2008 + { &rpg_TR116Delay, "rpg_TR116Delay", "500", 0, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_motdFile, "rpg_motdFile", "RPG-X_Motd.txt", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, // RPG-X | Marcin | 23/12/2008 + { &rpg_respectPrivacy, "rpg_respectPrivacy", "0", CVAR_ARCHIVE | CVAR_SERVERINFO, 0, qfalse }, // RPG-X | Marcin | 24/12/2008 + { &rpg_maxTricorders, "rpg_maxTricorders", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxPADDs, "rpg_maxPADDs", "10", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxCups, "rpg_maxCups", "2", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxPhasers, "rpg_maxPhasers", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxRifles, "rpg_maxRifles", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxTR116s, "rpg_maxTR116s", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxAdminguns, "rpg_maxAdminguns", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxPhotonbursts, "rpg_maxPhotonbursts", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxDisruptors, "rpg_maxDisruptors", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxMedkits, "rpg_maxMedkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxHyposprays, "rpg_maxHyposprays", "2", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxRegenerators, "rpg_maxRegenerators", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxToolkits, "rpg_maxToolkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_maxHyperSpanners, "rpg_maxHyperSpanners", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minTricorders, "rpg_minTricorders", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minPADDs, "rpg_minPADDs", "5", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minCups, "rpg_minCups", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minPhasers, "rpg_minPhasers", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minRifles, "rpg_minRifles", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minTR116s, "rpg_minTR116s", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minAdminguns, "rpg_minAdminguns", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minPhotonbursts, "rpg_minPhotonbursts", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minDisruptors, "rpg_minDisruptors", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minMedkits, "rpg_minMedkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minHyposprays, "rpg_minHyposprays", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minRegenerators, "rpg_minRegenerators", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minToolkits, "rpg_minToolkits", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_minHyperSpanners, "rpg_minHyperSpanners", "1", CVAR_ARCHIVE, 0, qtrue }, // RPG-X | Marcin | 30/12/2008 + { &rpg_dropOnDeath, "rpg_dropItemsOnDeath", "1", CVAR_ARCHIVE, 0, qfalse }, // RPG-X | Marcin | 30/12/2008 + { &rpg_fraggerSpawnDelay, "rpg_fraggerSpawnDelay", "100", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_borgAdapt, "rpg_borgAdapt", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_hypoMelee, "rpg_hypoMelee", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptUseSound, "rpg_adaptUseSound", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptCrifleHits, "rpg_adaptCrifleHits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptDisruptorHits, "rpg_adaptDisruptorHits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptPhaserHits, "rpg_adaptPhaserHits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptPhotonHits, "rpg_adaptPhotonHits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptTR116Hits, "rpg_adaptTR116Hits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adaptGrenadeLauncherHits, "rpg_adaptGrenadeLauncherHits", "6", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_repairModifier, "rpg_repairModifier", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_forceFieldColor, "rpg_forceFieldColor", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_allowRemodulation, "rpg_allowRemodulation", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_forceFieldFreq, "rpg_forceFieldFreq", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_calcLiftTravelDuration, "rpg_calcLiftTravelDuration", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_liftDurationModifier, "rpg_liftDurationModifier", "0.5", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_altTricorderDelay, "rpg_altTricorderDelay", "1000", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_borgMoveThroughFields, "rpg_borgMoveThroughFields", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_RemodulationDelay, "rpg_RemodulationDelay", "5000", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_adminVoteOverride, "rpg_adminVoteOverride", "1", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_serverchange, "rpg_serverchange", "0", CVAR_ARCHIVE, 0, qfalse }, + { &rpg_allowSPLevelChange, "rpg_allowSPLevelChange", "1", CVAR_ARCHIVE | CVAR_LATCH, 0, qfalse }, + { &rpg_spEasterEggs, "rpg_spEasterEggs", "0", CVAR_ARCHIVE, 0, qfalse }, + { &dev_showTriggers, "dev_showTriggers", "0", CVAR_ARCHIVE, 0, qfalse }, + { &sql_use, "sql_use", "0", CVAR_ARCHIVE, 0, qfalse }, #ifdef G_LUA - { &g_debugLua, "g_debugLua", "0", 0, 0, qfalse }, - { &lua_allowedModules, "lua_allowedModules", "", 0, 0, qfalse }, - { &lua_modules, "lua_modules", "", 0, 0, qfalse }, + { &g_debugLua, "g_debugLua", "0", 0, 0, qfalse }, + { &lua_allowedModules, "lua_allowedModules", "", 0, 0, qfalse }, + { &lua_modules, "lua_modules", "", 0, 0, qfalse }, #endif - { &g_developer, "g_developer", "0", CVAR_ARCHIVE, 0, qfalse }, - { &g_logLevel, "g_loglevel", "2", CVAR_ARCHIVE, 0, qfalse } + { &g_developer, "g_developer", "0", CVAR_ARCHIVE, 0, qfalse }, + { &g_logLevel, "g_loglevel", "2", CVAR_ARCHIVE, 0, qfalse } }; static int gameCvarTableSize = (int)(sizeof(gameCvarTable) / sizeof(gameCvarTable[0])); @@ -493,140 +497,147 @@ This is the only way control passes into the module. This MUST be the very first function compiled into the .q3vm file ================ */ -Q_EXPORT intptr_t vmMain(int command, int arg0, int arg1, int arg2, /*@unused@*/ int arg3, /*@unused@*/ int arg4, /*@unused@*/ int arg5, /*@unused@*/ int arg6) { - switch (command) { - case GAME_INIT: - G_InitGame(arg0, (unsigned)arg1, arg2); - return 0; - case GAME_SHUTDOWN: - G_ShutdownGame(arg0); - return 0; - case GAME_CLIENT_CONNECT: - return (intptr_t)G_Client_Connect(arg0, (qboolean)arg1, (qboolean)arg2); - case GAME_CLIENT_THINK: - ClientThink(arg0); - return 0; - case GAME_CLIENT_USERINFO_CHANGED: - G_Client_UserinfoChanged(arg0); //TiM - this means a user just tried to change it - return 0; - case GAME_CLIENT_DISCONNECT: - G_Client_Disconnect(arg0); - return 0; - case GAME_CLIENT_BEGIN: - G_Client_Begin(arg0, qtrue, qfalse, qtrue); - return 0; - case GAME_CLIENT_COMMAND: - G_Client_Command(arg0); - return 0; - case GAME_RUN_FRAME: - G_RunFrame(arg0); - return 0; - case GAME_CONSOLE_COMMAND: - //RPG-X : TiM - plagiarised Red's logic from SFEFMOD here lol - return (intptr_t)ConsoleCommand(); - case BOTAI_START_FRAME: - return (intptr_t)AI_main_BotAIStartFrame(arg0); - } +Q_EXPORT intptr_t vmMain(int command, int arg0, int arg1, int arg2, /*@unused@*/ int arg3, /*@unused@*/ int arg4, /*@unused@*/ int arg5, /*@unused@*/ int arg6) +{ + switch(command) + { + case GAME_INIT: + G_InitGame(arg0, (unsigned)arg1, arg2); + return 0; + case GAME_SHUTDOWN: + G_ShutdownGame(arg0); + return 0; + case GAME_CLIENT_CONNECT: + return (intptr_t)G_Client_Connect(arg0, (qboolean)arg1, (qboolean)arg2); + case GAME_CLIENT_THINK: + ClientThink(arg0); + return 0; + case GAME_CLIENT_USERINFO_CHANGED: + G_Client_UserinfoChanged(arg0); //TiM - this means a user just tried to change it + return 0; + case GAME_CLIENT_DISCONNECT: + G_Client_Disconnect(arg0); + return 0; + case GAME_CLIENT_BEGIN: + G_Client_Begin(arg0, qtrue, qfalse, qtrue); + return 0; + case GAME_CLIENT_COMMAND: + G_Client_Command(arg0); + return 0; + case GAME_RUN_FRAME: + G_RunFrame(arg0); + return 0; + case GAME_CONSOLE_COMMAND: + //RPG-X : TiM - plagiarised Red's logic from SFEFMOD here lol + return (intptr_t)ConsoleCommand(); + case BOTAI_START_FRAME: + return (intptr_t)AI_main_BotAIStartFrame(arg0); + } - return -1; + return -1; } -void QDECL G_PrintfClientAll(const char *fmt, ...) { - va_list argptr; - char text[1024]; +void QDECL G_PrintfClientAll(const char *fmt, ...) +{ + va_list argptr; + char text[1024]; - va_start(argptr, fmt); - vsnprintf(text, sizeof(text), fmt, argptr); - va_end(argptr); + va_start(argptr, fmt); + vsnprintf(text, sizeof(text), fmt, argptr); + va_end(argptr); - trap_SendServerCommand(-1, va("print \"%s\n\"", text)); + trap_SendServerCommand(-1, va("print \"%s\n\"", text)); } -void QDECL G_PrintfClient(gentity_t *ent, const char *fmt, ...) { - va_list argptr; - char text[1024]; +void QDECL G_PrintfClient(gentity_t *ent, const char *fmt, ...) +{ + va_list argptr; + char text[1024]; - /* only makes sense for players */ - G_Assert(ent->client, (void)0); + /* only makes sense for players */ + G_Assert(ent->client, (void)0); - va_start(argptr, fmt); - vsnprintf(text, sizeof(text), fmt, argptr); - va_end(argptr); + va_start(argptr, fmt); + vsnprintf(text, sizeof(text), fmt, argptr); + va_end(argptr); #ifdef G_LUA - LuaHook_G_ClientPrint(text, ent - g_entities); + LuaHook_G_ClientPrint(text, ent - g_entities); #endif - trap_SendServerCommand(ent - g_entities, va("print \"%s\n\"", text)); + trap_SendServerCommand(ent - g_entities, va("print \"%s\n\"", text)); } -void QDECL G_Printf(const char *fmt, ...) { - va_list argptr; - char text[1024]; +void QDECL G_Printf(const char *fmt, ...) +{ + va_list argptr; + char text[1024]; - va_start(argptr, fmt); - vsnprintf(text, sizeof(text), fmt, argptr); - va_end(argptr); + va_start(argptr, fmt); + vsnprintf(text, sizeof(text), fmt, argptr); + va_end(argptr); - if (trap_Cvar_VariableIntegerValue("developer") != 0) { + if(trap_Cvar_VariableIntegerValue("developer") != 0) + { - } + } #ifdef G_LUA - // Lua API callbacks - LuaHook_G_Print(text); + // Lua API callbacks + LuaHook_G_Print(text); #endif - trap_Printf(text); + trap_Printf(text); } -void QDECL G_Error(const char *fmt, ...) { - va_list argptr; - char text[1024]; +void QDECL G_Error(const char *fmt, ...) +{ + va_list argptr; + char text[1024]; - va_start(argptr, fmt); - vsnprintf(text, sizeof(text), fmt, argptr); - va_end(argptr); + va_start(argptr, fmt); + vsnprintf(text, sizeof(text), fmt, argptr); + va_end(argptr); #ifdef G_LUA - G_Lua_Shutdown(); + G_Lua_Shutdown(); #endif - trap_Error(text); + trap_Error(text); } stringID_table_t WeaponTable[] = { - { ENUM2STRING(WP_2) }, - { ENUM2STRING(WP_3) }, - { ENUM2STRING(WP_4) }, - { ENUM2STRING(WP_5) }, - { ENUM2STRING(WP_6) }, - { ENUM2STRING(WP_7) }, - { ENUM2STRING(WP_8) }, - { ENUM2STRING(WP_9) }, - { ENUM2STRING(WP_10) }, - { ENUM2STRING(WP_11) }, - { ENUM2STRING(WP_12) }, - { ENUM2STRING(WP_13) }, - { ENUM2STRING(WP_14) }, - { ENUM2STRING(WP_15) }, + { ENUM2STRING(WP_2) }, + { ENUM2STRING(WP_3) }, + { ENUM2STRING(WP_4) }, + { ENUM2STRING(WP_5) }, + { ENUM2STRING(WP_6) }, + { ENUM2STRING(WP_7) }, + { ENUM2STRING(WP_8) }, + { ENUM2STRING(WP_9) }, + { ENUM2STRING(WP_10) }, + { ENUM2STRING(WP_11) }, + { ENUM2STRING(WP_12) }, + { ENUM2STRING(WP_13) }, + { ENUM2STRING(WP_14) }, + { ENUM2STRING(WP_15) }, - { "WP_TRICORDER", WP_2 }, - { "WP_PADD", WP_3 }, - { "WP_COFFEE", WP_4 }, - { "WP_PHASER", WP_5 }, - { "WP_COMPRESSION_RIFLE", WP_6 }, - { "WP_TR116", WP_7 }, - { "WP_GRENADE_LAUNCHER", WP_8 }, - { "WP_QUANTUM_BURST", WP_9 }, - { "WP_DISRUPTOR", WP_10 }, - { "WP_MEDKIT", WP_11 }, - { "WP_VOYAGER_HYPO", WP_12 }, - { "WP_DERMAL_REGEN", WP_13 }, - { "WP_TOOLKIT", WP_14 }, - { "WP_HYPERSPANNER", WP_15 }, + { "WP_TRICORDER", WP_2 }, + { "WP_PADD", WP_3 }, + { "WP_COFFEE", WP_4 }, + { "WP_PHASER", WP_5 }, + { "WP_COMPRESSION_RIFLE", WP_6 }, + { "WP_TR116", WP_7 }, + { "WP_GRENADE_LAUNCHER", WP_8 }, + { "WP_QUANTUM_BURST", WP_9 }, + { "WP_DISRUPTOR", WP_10 }, + { "WP_MEDKIT", WP_11 }, + { "WP_VOYAGER_HYPO", WP_12 }, + { "WP_DERMAL_REGEN", WP_13 }, + { "WP_TOOLKIT", WP_14 }, + { "WP_HYPERSPANNER", WP_15 }, - { NULL, -1 } + { NULL, -1 } }; /************************** @@ -637,946 +648,1035 @@ and parses the class data for utilization on the server and transfer to clients **************************/ -static qboolean G_LoadClassData(char* fileName) { - char* buffer = NULL; - char* textPtr = NULL; - char* token = NULL; - int fileLen; - fileHandle_t f = 0; - qboolean classValid = qfalse; - int classIndex = 0; - unsigned weapon; - int i; +static qboolean G_LoadClassData(char* fileName) +{ + char* buffer = NULL; + char* textPtr = NULL; + char* token = NULL; + int fileLen; + fileHandle_t f = 0; + qboolean classValid = qfalse; + int classIndex = 0; + unsigned weapon; + int i; - //Init the storage place - memset(&g_classData, 0, sizeof (g_classData)); + //Init the storage place + memset(&g_classData, 0, sizeof(g_classData)); - fileLen = trap_FS_FOpenFile(fileName, &f, FS_READ); + fileLen = trap_FS_FOpenFile(fileName, &f, FS_READ); - if (f == 0) { - G_Printf(S_COLOR_RED "ERROR: File %s not found.\n", fileName); - return qfalse; - } + if(f == 0) + { + G_Printf(S_COLOR_RED "ERROR: File %s not found.\n", fileName); + return qfalse; + } - buffer = (char *)malloc((fileLen + 1) * sizeof(char)); - if (buffer == NULL) { - G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", (fileLen + 1) * sizeof(char)); - trap_FS_FCloseFile(f); - return qfalse; - } - memset(buffer, 0, sizeof(buffer)); + buffer = (char *)malloc((fileLen + 1) * sizeof(char)); + if(buffer == NULL) + { + G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", (fileLen + 1) * sizeof(char)); + trap_FS_FCloseFile(f); + return qfalse; + } + memset(buffer, 0, sizeof(buffer)); - trap_FS_Read(buffer, fileLen, f); - buffer[fileLen] = 0; - trap_FS_FCloseFile(f); + trap_FS_Read(buffer, fileLen, f); + buffer[fileLen] = 0; + trap_FS_FCloseFile(f); - COM_BeginParseSession(); + COM_BeginParseSession(); - textPtr = buffer; + textPtr = buffer; - token = COM_Parse(&textPtr); + token = COM_Parse(&textPtr); - if (token == NULL || token[0] == 0) { - G_Printf(S_COLOR_RED "ERROR: No data was found when going to parse the file!\n"); - free(buffer); - return qfalse; - } + if(token == NULL || token[0] == 0) + { + G_Printf(S_COLOR_RED "ERROR: No data was found when going to parse the file!\n"); + free(buffer); + return qfalse; + } - if (Q_stricmpn(token, "{", 1) != 0) { - G_Printf(S_COLOR_RED "ERROR: File did not start with a '{' symbol!\n"); - free(buffer); - return qfalse; - } + if(Q_stricmpn(token, "{", 1) != 0) + { + G_Printf(S_COLOR_RED "ERROR: File did not start with a '{' symbol!\n"); + free(buffer); + return qfalse; + } - while (qtrue) { - if (classIndex >= MAX_CLASSES) { - break; - } + while(qtrue) + { + if(classIndex >= MAX_CLASSES) + { + break; + } - if (Q_stricmpn(token, "{", 1) == 0) { - while (qtrue) { - token = COM_Parse(&textPtr); - if (token == NULL || token[0] == 0) { - break; - } + if(Q_stricmpn(token, "{", 1) == 0) + { + while(qtrue) + { + token = COM_Parse(&textPtr); + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmpn(token, "consoleName", 11) == 0) { - if (COM_ParseString(&textPtr, &token)) { - G_Printf(S_COLOR_RED "ERROR: Invalid class console name in class index: %i.\n", classIndex); - SkipBracedSection(&textPtr); - continue; - } + if(Q_stricmpn(token, "consoleName", 11) == 0) + { + if(COM_ParseString(&textPtr, &token)) + { + G_Printf(S_COLOR_RED "ERROR: Invalid class console name in class index: %i.\n", classIndex); + SkipBracedSection(&textPtr); + continue; + } - Q_strncpyz(g_classData[classIndex].consoleName, token, sizeof(g_classData[classIndex].consoleName)); - classValid = qtrue; + Q_strncpyz(g_classData[classIndex].consoleName, token, sizeof(g_classData[classIndex].consoleName)); + classValid = qtrue; - continue; - } + continue; + } - if (Q_stricmpn(token, "formalName", 11) == 0) { - if (COM_ParseString(&textPtr, &token)) { - G_Printf(S_COLOR_RED "ERROR: Invalid class formal name in class index: %i.\n", classIndex); - SkipBracedSection(&textPtr); - continue; - } + if(Q_stricmpn(token, "formalName", 11) == 0) + { + if(COM_ParseString(&textPtr, &token)) + { + G_Printf(S_COLOR_RED "ERROR: Invalid class formal name in class index: %i.\n", classIndex); + SkipBracedSection(&textPtr); + continue; + } - Q_strncpyz(g_classData[classIndex].formalName, token, sizeof(g_classData[classIndex].formalName)); - classValid = qtrue; + Q_strncpyz(g_classData[classIndex].formalName, token, sizeof(g_classData[classIndex].formalName)); + classValid = qtrue; - continue; - } + continue; + } - if (Q_stricmpn(token, "message", 7) == 0) { - if (COM_ParseString(&textPtr, &token)) { - G_Printf(S_COLOR_RED "ERROR: Invalid class message in class index: %i.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "message", 7) == 0) + { + if(COM_ParseString(&textPtr, &token)) + { + G_Printf(S_COLOR_RED "ERROR: Invalid class message in class index: %i.\n", classIndex); + continue; + } - Q_strncpyz(g_classData[classIndex].message, token, sizeof(g_classData[classIndex].message)); - continue; - } + Q_strncpyz(g_classData[classIndex].message, token, sizeof(g_classData[classIndex].message)); + continue; + } - if (Q_stricmpn(token, "modelSkin", 9) == 0) { - if (COM_ParseString(&textPtr, &token)) { - G_Printf(S_COLOR_RED "ERROR: Invalid class skin color in class index: %i.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "modelSkin", 9) == 0) + { + if(COM_ParseString(&textPtr, &token)) + { + G_Printf(S_COLOR_RED "ERROR: Invalid class skin color in class index: %i.\n", classIndex); + continue; + } - Q_strncpyz(g_classData[classIndex].modelSkin, token, sizeof(g_classData[classIndex].modelSkin)); - continue; - } + Q_strncpyz(g_classData[classIndex].modelSkin, token, sizeof(g_classData[classIndex].modelSkin)); + continue; + } - if (Q_stricmpn(token, "weapons", 7) == 0) { - token = COM_Parse(&textPtr); + if(Q_stricmpn(token, "weapons", 7) == 0) + { + token = COM_Parse(&textPtr); - if (Q_stricmpn(token, "{", 1) != 0) { - G_Printf(S_COLOR_RED "No opening bracket found for weapons field in class: %i.\n", classIndex); - SkipRestOfLine(&textPtr); - continue; - } + if(Q_stricmpn(token, "{", 1) != 0) + { + G_Printf(S_COLOR_RED "No opening bracket found for weapons field in class: %i.\n", classIndex); + SkipRestOfLine(&textPtr); + continue; + } - //sub loop - while (qtrue) { - token = COM_Parse(&textPtr); + //sub loop + while(qtrue) + { + token = COM_Parse(&textPtr); - if (token == NULL || token[0] == 0) { - break; - } + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmpn(token, "|", 1) == 0) { - continue; - } + if(Q_stricmpn(token, "|", 1) == 0) + { + continue; + } - if (Q_stricmpn(token, "}", 1) == 0) { - break; - } + if(Q_stricmpn(token, "}", 1) == 0) + { + break; + } - if (Q_stricmpn(token, "WP_", 3) == 0) { - int t = GetIDForString(WeaponTable, token); + if(Q_stricmpn(token, "WP_", 3) == 0) + { + int t = GetIDForString(WeaponTable, token); - if (t >= 0) { - weapon = (unsigned)t; - g_classData[classIndex].weaponsFlags |= (1 << weapon); - continue; - } - } - } + if(t >= 0) + { + weapon = (unsigned)t; + g_classData[classIndex].weaponsFlags |= (1 << weapon); + continue; + } + } + } - continue; - } + continue; + } - if (Q_stricmpn(token, "admin", 5) == 0) { - if (COM_ParseInt(&textPtr, &g_classData[classIndex].isAdmin)) { - G_Printf(S_COLOR_RED "ERROR: Class admin check for class %i was invalid.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "admin", 5) == 0) + { + if(COM_ParseInt(&textPtr, &g_classData[classIndex].isAdmin)) + { + G_Printf(S_COLOR_RED "ERROR: Class admin check for class %i was invalid.\n", classIndex); + continue; + } - continue; - } + continue; + } - if (Q_stricmpn(token, "marine", 6) == 0) { - if (COM_ParseInt(&textPtr, &g_classData[classIndex].isMarine)) { - G_Printf(S_COLOR_RED "ERROR: Class marine check for class %i was invalid.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "marine", 6) == 0) + { + if(COM_ParseInt(&textPtr, &g_classData[classIndex].isMarine)) + { + G_Printf(S_COLOR_RED "ERROR: Class marine check for class %i was invalid.\n", classIndex); + continue; + } - continue; - } + continue; + } - if (Q_stricmpn(token, "medical", 7) == 0) { - if (COM_ParseInt(&textPtr, &g_classData[classIndex].isMedical)) { - G_Printf(S_COLOR_RED "ERROR: Class medic check for class %i was invalid.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "medical", 7) == 0) + { + if(COM_ParseInt(&textPtr, &g_classData[classIndex].isMedical)) + { + G_Printf(S_COLOR_RED "ERROR: Class medic check for class %i was invalid.\n", classIndex); + continue; + } - continue; - } + continue; + } - if (Q_stricmpn(token, "isBorg", 6) == 0) { - if (COM_ParseInt(&textPtr, &g_classData[classIndex].isBorg)) { - G_Printf(S_COLOR_RED "ERROR: Class borg check for class %i was invalid.\n", classIndex); - continue; - } - continue; - } + if(Q_stricmpn(token, "isBorg", 6) == 0) + { + if(COM_ParseInt(&textPtr, &g_classData[classIndex].isBorg)) + { + G_Printf(S_COLOR_RED "ERROR: Class borg check for class %i was invalid.\n", classIndex); + continue; + } + continue; + } - if (Q_stricmpn(token, "n00b", 4) == 0) { - if (COM_ParseInt(&textPtr, &g_classData[classIndex].isn00b)) { - G_Printf(S_COLOR_RED "ERROR: Class n00b check for class %i was invalid.\n", classIndex); - continue; - } + if(Q_stricmpn(token, "n00b", 4) == 0) + { + if(COM_ParseInt(&textPtr, &g_classData[classIndex].isn00b)) + { + G_Printf(S_COLOR_RED "ERROR: Class n00b check for class %i was invalid.\n", classIndex); + continue; + } - continue; - } + continue; + } - //skip the client-side specific entries since they interfere with the parsing - if ((Q_stricmpn(token, "radarColor", 10) == 0) - || (Q_stricmpn(token, "iconColor", 9) == 0) - || (Q_stricmpn(token, "hasRanks", 8) == 0) - || (Q_stricmpn(token, "noShow", 6) == 0) - ) { - SkipRestOfLine(&textPtr); - continue; - } + //skip the client-side specific entries since they interfere with the parsing + if((Q_stricmpn(token, "radarColor", 10) == 0) + || (Q_stricmpn(token, "iconColor", 9) == 0) + || (Q_stricmpn(token, "hasRanks", 8) == 0) + || (Q_stricmpn(token, "noShow", 6) == 0) + ) + { + SkipRestOfLine(&textPtr); + continue; + } - if (Q_stricmpn(token, "}", 1) == 0) { - break; - } - } + if(Q_stricmpn(token, "}", 1) == 0) + { + break; + } + } - if (classValid) { - classIndex++; - classValid = qfalse; - } - } + if(classValid) + { + classIndex++; + classValid = qfalse; + } + } - token = COM_Parse(&textPtr); - if (token == NULL || token[0] == 0) { - break; - } - } + token = COM_Parse(&textPtr); + if(token == NULL || token[0] == 0) + { + break; + } + } - free(buffer); + free(buffer); - //build ourselves custom CVARs for each class - for (i = 0; (g_classData[i].consoleName[0] != 0) && (i < MAX_CLASSES); i++) { - trap_Cvar_Register(NULL, va("rpg_%sPass", g_classData[i].consoleName), g_classData[i].consoleName, CVAR_ARCHIVE); - trap_Cvar_Register(NULL, va("rpg_%sFlags", g_classData[i].consoleName), va("%i", g_classData[i].weaponsFlags), CVAR_ARCHIVE); - } + //build ourselves custom CVARs for each class + for(i = 0; (g_classData[i].consoleName[0] != 0) && (i < MAX_CLASSES); i++) + { + trap_Cvar_Register(NULL, va("rpg_%sPass", g_classData[i].consoleName), g_classData[i].consoleName, CVAR_ARCHIVE); + trap_Cvar_Register(NULL, va("rpg_%sFlags", g_classData[i].consoleName), va("%i", g_classData[i].weaponsFlags), CVAR_ARCHIVE); + } - if (classIndex > 0) { - return qtrue; - } - else { - G_Printf(S_COLOR_RED "ERROR: No valid classes were found.\n"); - return qfalse; - } + if(classIndex > 0) + { + return qtrue; + } + else + { + G_Printf(S_COLOR_RED "ERROR: No valid classes were found.\n"); + return qfalse; + } } void SP_target_location(gentity_t *ent); -static void G_LoadTimedMessages(void) { - fileHandle_t f = 0; - bgLex* lexer = NULL; - char* buffer = NULL; - int len; +static void G_LoadTimedMessages(void) +{ + fileHandle_t f = 0; - G_LogFuncBegin(); + const auto len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ); + if(f == 0) + { + return; + } - len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ); - if (f == 0) { - G_LogFuncEnd(); - return; - } + std::string data(len, '\0'); + trap_FS_Read(data.data(), data.size(), f); + trap_FS_FCloseFile(f); - buffer = (char *)malloc(sizeof(char)* (len + 1)); - if (buffer == NULL) { - G_LocLogger(LL_ERROR, "Was unable to allocate %i byte.\n", (len + 1) * sizeof(char)); - trap_FS_FCloseFile(f); - G_LogFuncEnd(); - return; - } - memset(buffer, 0, (size_t)((len + 1) * sizeof(char))); + std::stringstream stream{ data }; - level.timedMessages = create_list(); - if (level.timedMessages == NULL) { - G_LocLogger(LL_ERROR, "Could not create list for timed messages.\n"); - trap_FS_FCloseFile(f); - free(buffer); - G_LogFuncEnd(); - return; - } - - trap_FS_Read(buffer, len, f); - trap_FS_FCloseFile(f); - - lexer = bgLex_create(buffer); - - if (lexer == NULL) { - G_LocLogger(LL_ERROR, "Could not create new bgLex to lex timed messages.\n"); - free(buffer); - G_LogFuncEnd(); - return; - } - - while (bgLex_lex(lexer) != 0) { - if (lexer->morphem.type == LMT_STRING) { - level.timedMessages->append(level.timedMessages, lexer->morphem.data.str, LT_STRING, strlen(lexer->morphem.data.str)); - } - else { - G_Logger(LL_WARN, "Unexpected token in timedmessages.cfg:%d:%d!\n", lexer->morphem.line, lexer->morphem.column); - } - } - G_Logger(LL_INFO, "Loaded %d timed messages.\n", level.timedMessages->length); - - bgLex_destroy(lexer); - free(buffer); - - G_LogFuncEnd(); + std::string buffer; + while(std::getline(stream, buffer)) + { + level.timedMessages.push_back(buffer); + } } holoData_t holoData; -static void G_LoadHolodeckFile(void) { - char fileRoute[MAX_QPATH]; - char mapRoute[MAX_QPATH]; - char* info = NULL; - fileHandle_t f = 0; - char* buffer = NULL; - int file_len; - char* txtPtr = NULL; - char* token = NULL; - int numProgs = 0; +static void G_LoadHolodeckFile(void) +{ + char fileRoute[MAX_QPATH]; + char mapRoute[MAX_QPATH]; + char* info = NULL; + fileHandle_t f = 0; + char* buffer = NULL; + int file_len; + char* txtPtr = NULL; + char* token = NULL; + int numProgs = 0; - memset(fileRoute, 0, sizeof(fileRoute)); - memset(mapRoute, 0, sizeof(mapRoute)); + memset(fileRoute, 0, sizeof(fileRoute)); + memset(mapRoute, 0, sizeof(mapRoute)); - info = (char *)malloc(MAX_INFO_STRING * sizeof(char)); - if (!info) { - G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i byte.\n", MAX_INFO_STRING * sizeof(char)); - return; - } - memset(info, 0, sizeof(info)); + info = (char *)malloc(MAX_INFO_STRING * sizeof(char)); + if(!info) + { + G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i byte.\n", MAX_INFO_STRING * sizeof(char)); + return; + } + memset(info, 0, sizeof(info)); - //get the map name out of the server data - trap_GetServerinfo(info, MAX_INFO_STRING * sizeof(char)); + //get the map name out of the server data + trap_GetServerinfo(info, MAX_INFO_STRING * sizeof(char)); - //setup the file route - Com_sprintf(mapRoute, sizeof(mapRoute), "maps/%s", Info_ValueForKey(info, "mapname")); + //setup the file route + Com_sprintf(mapRoute, sizeof(mapRoute), "maps/%s", Info_ValueForKey(info, "mapname")); - BG_LanguageFilename(mapRoute, "holodeck", fileRoute); + BG_LanguageFilename(mapRoute, "holodeck", fileRoute); - file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); + file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - free(info); + free(info); - if (f == 0) { - return; - } + if(f == 0) + { + return; + } - buffer = (char *)malloc(32000 * sizeof(char)); - if (buffer == NULL) { - G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", 32000 * sizeof(char)); - trap_FS_FCloseFile(f); - return; - } - memset(buffer, 0, sizeof(buffer)); + buffer = (char *)malloc(32000 * sizeof(char)); + if(buffer == NULL) + { + G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", 32000 * sizeof(char)); + trap_FS_FCloseFile(f); + return; + } + memset(buffer, 0, sizeof(buffer)); - trap_FS_Read(buffer, file_len, f); - if (buffer[0] == 0) { - G_Printf(S_COLOR_RED "ERROR: Couldn't read in file: %s!\n", fileRoute); - trap_FS_FCloseFile(f); - free(buffer); - return; - } + trap_FS_Read(buffer, file_len, f); + if(buffer[0] == 0) + { + G_Printf(S_COLOR_RED "ERROR: Couldn't read in file: %s!\n", fileRoute); + trap_FS_FCloseFile(f); + free(buffer); + return; + } - buffer[file_len] = '\0'; - trap_FS_FCloseFile(f); + buffer[file_len] = '\0'; + trap_FS_FCloseFile(f); - memset(&holoData, 0, sizeof(holoData)); + memset(&holoData, 0, sizeof(holoData)); - COM_BeginParseSession(); - txtPtr = buffer; + COM_BeginParseSession(); + txtPtr = buffer; - while (qtrue) { - token = COM_Parse(&txtPtr); - if (token == NULL || token[0] == 0) { - break; - } + while(qtrue) + { + token = COM_Parse(&txtPtr); + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmpn(token, "HolodeckData", 12) == 0) { - token = COM_Parse(&txtPtr); - if (Q_stricmpn(token, "{", 1) != 0) { - G_Printf(S_COLOR_RED "ERROR: HolodeckData had no opening brace ( { )!\n"); - continue; - } - while (Q_stricmpn(token, "}", 1) != 0) { - token = COM_Parse(&txtPtr); - if (token == NULL || token[0] == 0) { - break; - } + if(Q_stricmpn(token, "HolodeckData", 12) == 0) + { + token = COM_Parse(&txtPtr); + if(Q_stricmpn(token, "{", 1) != 0) + { + G_Printf(S_COLOR_RED "ERROR: HolodeckData had no opening brace ( { )!\n"); + continue; + } + while(Q_stricmpn(token, "}", 1) != 0) + { + token = COM_Parse(&txtPtr); + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmpn(token, "Program", 7) == 0) { - token = COM_Parse(&txtPtr); - if (Q_stricmpn(token, "[", 1) != 0) { - G_Printf(S_COLOR_RED "ERROR: Program had no opening brace ( [ )!\n"); - continue; - } + if(Q_stricmpn(token, "Program", 7) == 0) + { + token = COM_Parse(&txtPtr); + if(Q_stricmpn(token, "[", 1) != 0) + { + G_Printf(S_COLOR_RED "ERROR: Program had no opening brace ( [ )!\n"); + continue; + } - // expected format: - // - target notnull - // - name - // - desc1 - // - desc2 - // - image - while (Q_stricmpn(token, "]", 1) != 0) { - if (token == NULL || token[0] == 0) { - break; - } + // expected format: + // - target notnull + // - name + // - desc1 + // - desc2 + // - image + while(Q_stricmpn(token, "]", 1) != 0) + { + if(token == NULL || token[0] == 0) + { + break; + } - if (numProgs >= 5) { - free(buffer); - return; - } + if(numProgs >= 5) + { + free(buffer); + return; + } - // targetname of info_notnull - token = COM_Parse(&txtPtr); - Q_strncpyz(holoData.target[numProgs], token, sizeof(holoData.target[numProgs])); + // targetname of info_notnull + token = COM_Parse(&txtPtr); + Q_strncpyz(holoData.target[numProgs], token, sizeof(holoData.target[numProgs])); - // parse name - token = COM_Parse(&txtPtr); - Q_strncpyz(holoData.name[numProgs], token, sizeof(holoData.name[numProgs])); + // parse name + token = COM_Parse(&txtPtr); + Q_strncpyz(holoData.name[numProgs], token, sizeof(holoData.name[numProgs])); - // parse desc1 - token = COM_Parse(&txtPtr); - Q_strncpyz(holoData.desc1[numProgs], token, sizeof(holoData.desc1[numProgs])); + // parse desc1 + token = COM_Parse(&txtPtr); + Q_strncpyz(holoData.desc1[numProgs], token, sizeof(holoData.desc1[numProgs])); - // parse desc2 - token = COM_Parse(&txtPtr); - Q_strncpyz(holoData.desc2[numProgs], token, sizeof(holoData.desc2[numProgs])); + // parse desc2 + token = COM_Parse(&txtPtr); + Q_strncpyz(holoData.desc2[numProgs], token, sizeof(holoData.desc2[numProgs])); - // parse image - token = COM_Parse(&txtPtr); - Q_strncpyz(holoData.image[numProgs], token, sizeof(holoData.image[numProgs])); + // parse image + token = COM_Parse(&txtPtr); + Q_strncpyz(holoData.image[numProgs], token, sizeof(holoData.image[numProgs])); - holoData.active = -1; + holoData.active = -1; - numProgs++; + numProgs++; - token = COM_Parse(&txtPtr); - } - } - } - } - } + token = COM_Parse(&txtPtr); + } + } + } + } + } - holoData.numProgs = numProgs; + holoData.numProgs = numProgs; - free(buffer); + free(buffer); } /* File Format: ServerChangeConfig { - Server [ - "1.1.1.1" - "Server name" - ] - Server [ - "1.1.1.2" - "Server name 2" - ] + Server [ + "1.1.1.1" + "Server name" + ] + Server [ + "1.1.1.2" + "Server name 2" + ] } */ -static void G_LoadServerChangeFile(void) { - char fileRoute[MAX_QPATH]; - fileHandle_t f = 0; - bgLex* lex; - char* buffer; - int file_len; +static void G_LoadServerChangeFile(void) +{ + char fileRoute[MAX_QPATH]; + fileHandle_t f = 0; + bgLex* lex; + char* buffer; + int file_len; - G_LogFuncBegin(); + G_LogFuncBegin(); - memset(fileRoute, 0, sizeof(fileRoute)); - BG_LanguageFilename("serverchange", "cfg", fileRoute); + memset(fileRoute, 0, sizeof(fileRoute)); + BG_LanguageFilename("serverchange", "cfg", fileRoute); - file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); + file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - if (f == 0) { - G_LogFuncEnd(); - return; - } + if(f == 0) + { + G_LogFuncEnd(); + return; + } - // TODO dynamic buffer size - buffer = (char*)malloc((file_len + 1) * sizeof(char)); - if (buffer == NULL) { - G_LocLogger(LL_ERROR, "Was unable to allocate %i bytes.\n", (file_len + 1) * sizeof(char)); - trap_FS_FCloseFile(f); - G_LogFuncEnd(); - return; - } - memset(buffer, 0, sizeof(buffer)); + // TODO dynamic buffer size + buffer = (char*)malloc((file_len + 1) * sizeof(char)); + if(buffer == NULL) + { + G_LocLogger(LL_ERROR, "Was unable to allocate %i bytes.\n", (file_len + 1) * sizeof(char)); + trap_FS_FCloseFile(f); + G_LogFuncEnd(); + return; + } + memset(buffer, 0, sizeof(buffer)); - trap_FS_Read(buffer, file_len, f); - if (buffer[0] == 0) { - G_LocLogger(LL_ERROR, "Couldn't read in file: %s!\n", fileRoute); - trap_FS_FCloseFile(f); - free(buffer); - G_LogFuncEnd(); - return; - } + trap_FS_Read(buffer, file_len, f); + if(buffer[0] == 0) + { + G_LocLogger(LL_ERROR, "Couldn't read in file: %s!\n", fileRoute); + trap_FS_FCloseFile(f); + free(buffer); + G_LogFuncEnd(); + return; + } - buffer[file_len] = '\0'; - trap_FS_FCloseFile(f); + buffer[file_len] = '\0'; + trap_FS_FCloseFile(f); - memset(&level.srvChangeData, 0, sizeof(&level.srvChangeData)); + memset(&level.srvChangeData, 0, sizeof(&level.srvChangeData)); - G_Logger(LL_INFO, "Loading ServerChangeConfig '%s'.\n", fileRoute); + G_Logger(LL_INFO, "Loading ServerChangeConfig '%s'.\n", fileRoute); - lex = bgLex_create(buffer); - if (lex == NULL) { - G_LocLogger(LL_ERROR, "Could not create bgLex to lex ServerChangeConfig.\n"); - free(buffer); - G_LogFuncEnd(); - return; - } + lex = bgLex_create(buffer); + if(lex == NULL) + { + G_LocLogger(LL_ERROR, "Could not create bgLex to lex ServerChangeConfig.\n"); + free(buffer); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_SERVER_CHANGE_CONFIG) { - G_LocLogger(LL_ERROR, "Expected 'ServerChangeConfig' at beginning of %s.\n", fileRoute); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - if (bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_OBRACEC) { - G_LocLogger(LL_ERROR, "Missing '{' at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_SERVER_CHANGE_CONFIG) + { + G_LocLogger(LL_ERROR, "Expected 'ServerChangeConfig' at beginning of %s.\n", fileRoute); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + if(bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_OBRACEC) + { + G_LocLogger(LL_ERROR, "Missing '{' at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - while (bgLex_lex(lex) != 0) { - if (lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_CBRACEC) { - break; - } + while(bgLex_lex(lex) != 0) + { + if(lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_CBRACEC) + { + break; + } - if (lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_SERVER) { - if (bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_OBRACESQ) { - G_LocLogger(LL_ERROR, "Missing '[' at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_SERVER) + { + if(bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_OBRACESQ) + { + G_LocLogger(LL_ERROR, "Missing '[' at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) == LMT_STRING) { - strncpy(level.srvChangeData.ip[level.srvChangeData.count], lex->morphem.data.str, sizeof(level.srvChangeData.ip[level.srvChangeData.count])); - } - else { - G_LocLogger(LL_ERROR, "Unexpected token at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) == LMT_STRING) + { + strncpy(level.srvChangeData.ip[level.srvChangeData.count], lex->morphem.data.str, sizeof(level.srvChangeData.ip[level.srvChangeData.count])); + } + else + { + G_LocLogger(LL_ERROR, "Unexpected token at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) == LMT_STRING) { - strncpy(level.srvChangeData.name[level.srvChangeData.count], lex->morphem.data.str, sizeof(level.srvChangeData.name[level.srvChangeData.count])); - } - else { - G_LocLogger(LL_ERROR, "Unexpected token at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - memset(level.srvChangeData.ip[level.srvChangeData.count], 0, sizeof(level.srvChangeData.ip[level.srvChangeData.count])); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) == LMT_STRING) + { + strncpy(level.srvChangeData.name[level.srvChangeData.count], lex->morphem.data.str, sizeof(level.srvChangeData.name[level.srvChangeData.count])); + } + else + { + G_LocLogger(LL_ERROR, "Unexpected token at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + memset(level.srvChangeData.ip[level.srvChangeData.count], 0, sizeof(level.srvChangeData.ip[level.srvChangeData.count])); + G_LogFuncEnd(); + return; + } - level.srvChangeData.count++; + level.srvChangeData.count++; - if (bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_CBRACESQ) { - G_LocLogger(LL_ERROR, "Missing ']' at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } - else { - G_LocLogger(LL_ERROR, "Unexpected token at %d:%d. Expected '}' or 'Server'\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } + if(bgLex_lex(lex) != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_CBRACESQ) + { + G_LocLogger(LL_ERROR, "Missing ']' at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } + else + { + G_LocLogger(LL_ERROR, "Unexpected token at %d:%d. Expected '}' or 'Server'\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } - bgLex_destroy(lex); - free(buffer); - G_LogFuncEnd(); + bgLex_destroy(lex); + free(buffer); + G_LogFuncEnd(); } mapChangeData_t mapChangeData; -static void G_LoadMapChangeFile(void) { - char fileRoute[MAX_QPATH]; - fileHandle_t f = 0; - char* buffer; - int file_len; - char* txtPtr, *token; - int cnt = 0; - int i = 0; +static void G_LoadMapChangeFile(void) +{ + char fileRoute[MAX_QPATH]; + fileHandle_t f = 0; + char* buffer; + int file_len; + char* txtPtr, *token; + int cnt = 0; + int i = 0; - memset(fileRoute, 0, sizeof(fileRoute)); - BG_LanguageFilename("mapchange", "cfg", fileRoute); + memset(fileRoute, 0, sizeof(fileRoute)); + BG_LanguageFilename("mapchange", "cfg", fileRoute); - file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); + file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - if (f == 0) { - return; - } + if(f == 0) + { + return; + } - buffer = (char *)malloc(32000 * sizeof(char)); - if (buffer == NULL) { - G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", 32000 * sizeof(char)); - trap_FS_FCloseFile(f); - return; - } - memset(buffer, 0, sizeof(buffer)); + buffer = (char *)malloc(32000 * sizeof(char)); + if(buffer == NULL) + { + G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", 32000 * sizeof(char)); + trap_FS_FCloseFile(f); + return; + } + memset(buffer, 0, sizeof(buffer)); - trap_FS_Read(buffer, file_len, f); - if (buffer[0] == 0) { - G_Printf(S_COLOR_RED "ERROR: Couldn't read in file: %s!\n", fileRoute); - trap_FS_FCloseFile(f); - free(buffer); - return; - } + trap_FS_Read(buffer, file_len, f); + if(buffer[0] == 0) + { + G_Printf(S_COLOR_RED "ERROR: Couldn't read in file: %s!\n", fileRoute); + trap_FS_FCloseFile(f); + free(buffer); + return; + } - buffer[file_len] = '\0'; - trap_FS_FCloseFile(f); + buffer[file_len] = '\0'; + trap_FS_FCloseFile(f); - memset(&mapChangeData, 0, sizeof(mapChangeData)); + memset(&mapChangeData, 0, sizeof(mapChangeData)); - COM_BeginParseSession(); - txtPtr = buffer; + COM_BeginParseSession(); + txtPtr = buffer; - while (qtrue) { - token = COM_Parse(&txtPtr); - if (token == NULL || token[0] == 0) { - break; - } + while(qtrue) + { + token = COM_Parse(&txtPtr); + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmp(token, "MapChangeConfig") == 0) { - token = COM_Parse(&txtPtr); - if (Q_strncmp(token, "{", 1) != 0) { - G_Printf(S_COLOR_RED "ERROR: MapChangeConfig had no opening brace ( { )!\n"); - continue; - } + if(Q_stricmp(token, "MapChangeConfig") == 0) + { + token = COM_Parse(&txtPtr); + if(Q_strncmp(token, "{", 1) != 0) + { + G_Printf(S_COLOR_RED "ERROR: MapChangeConfig had no opening brace ( { )!\n"); + continue; + } - while (Q_strncmp(token, "}", 1) != 0) { - token = COM_Parse(&txtPtr); - if (token == NULL || token[0] == 0) { - break; - } + while(Q_strncmp(token, "}", 1) != 0) + { + token = COM_Parse(&txtPtr); + if(token == NULL || token[0] == 0) + { + break; + } - if (Q_stricmp(token, "Map") == 0) { - token = COM_Parse(&txtPtr); - if (Q_strncmp(token, "[", 1) != 0) { - G_Printf(S_COLOR_RED "ERROR: Server had no opening brace ( [ )!\n"); - continue; - } + if(Q_stricmp(token, "Map") == 0) + { + token = COM_Parse(&txtPtr); + if(Q_strncmp(token, "[", 1) != 0) + { + G_Printf(S_COLOR_RED "ERROR: Server had no opening brace ( [ )!\n"); + continue; + } - token = COM_Parse(&txtPtr); - while (Q_strncmp(token, "]", 1) != 0) { - if (token == NULL || token[0] == 0) { - break; - } + token = COM_Parse(&txtPtr); + while(Q_strncmp(token, "]", 1) != 0) + { + if(token == NULL || token[0] == 0) + { + break; + } - if (cnt > 12) break; + if(cnt > 12) break; - if (cnt % 2 == 0) - Q_strncpyz(mapChangeData.name[i], token, sizeof(mapChangeData.name[i])); - else - Q_strncpyz(mapChangeData.bspname[i], token, sizeof(mapChangeData.bspname[i])); + if(cnt % 2 == 0) + Q_strncpyz(mapChangeData.name[i], token, sizeof(mapChangeData.name[i])); + else + Q_strncpyz(mapChangeData.bspname[i], token, sizeof(mapChangeData.bspname[i])); - cnt++; - if (cnt % 2 == 0) - i++; + cnt++; + if(cnt % 2 == 0) + i++; - token = COM_Parse(&txtPtr); - } - } - } - } - } + token = COM_Parse(&txtPtr); + } + } + } + } + } - free(buffer); + free(buffer); } -static void G_LoadLocationsFile(void) { - char fileRoute[MAX_QPATH]; - char mapRoute[MAX_QPATH]; - char *serverInfo; - fileHandle_t f = 0; - bgLex* lex; - char *buffer; - int file_len; - vec3_t origin, angles; - gentity_t *ent; - char *desc; - int rest = 0; +static void G_LoadLocationsFile(void) +{ + char fileRoute[MAX_QPATH]; + char mapRoute[MAX_QPATH]; + char *serverInfo; + fileHandle_t f = 0; + bgLex* lex; + char *buffer; + int file_len; + vec3_t origin, angles; + gentity_t *ent; + char *desc; + int rest = 0; - G_LogFuncBegin(); + G_LogFuncBegin(); - memset(fileRoute, 0, sizeof(fileRoute)); - memset(mapRoute, 0, sizeof(mapRoute)); + memset(fileRoute, 0, sizeof(fileRoute)); + memset(mapRoute, 0, sizeof(mapRoute)); - serverInfo = (char*)malloc(MAX_INFO_STRING * sizeof(char)); - if (serverInfo == NULL) { - G_LocLogger(LL_ERROR, "Was unable to allocate %i bytes.\n", MAX_INFO_STRING * sizeof(char)); - G_LogFuncEnd(); - return; - } - memset(serverInfo, 0, sizeof(serverInfo)); + serverInfo = (char*)malloc(MAX_INFO_STRING * sizeof(char)); + if(serverInfo == NULL) + { + G_LocLogger(LL_ERROR, "Was unable to allocate %i bytes.\n", MAX_INFO_STRING * sizeof(char)); + G_LogFuncEnd(); + return; + } + memset(serverInfo, 0, sizeof(serverInfo)); - //get the map name out of the server data - trap_GetServerinfo(serverInfo, (size_t)(MAX_INFO_STRING * sizeof(char))); + //get the map name out of the server data + trap_GetServerinfo(serverInfo, (size_t)(MAX_INFO_STRING * sizeof(char))); - //setup the file route - Com_sprintf(mapRoute, sizeof(mapRoute), "maps/%s", Info_ValueForKey(serverInfo, "mapname")); + //setup the file route + Com_sprintf(mapRoute, sizeof(mapRoute), "maps/%s", Info_ValueForKey(serverInfo, "mapname")); - BG_LanguageFilename(mapRoute, "locations", fileRoute); + BG_LanguageFilename(mapRoute, "locations", fileRoute); - file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); + file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - free(serverInfo); + free(serverInfo); - if (f <= 0) { - G_LogFuncEnd(); - return; - } + if(f <= 0) + { + G_LogFuncEnd(); + return; + } - buffer = (char *)malloc((file_len + 1) * sizeof(char)); - if (buffer == NULL) { - G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", (file_len + 1) * sizeof(char)); - trap_FS_FCloseFile(f); - return; - } - memset(buffer, 0, sizeof(buffer)); + buffer = (char *)malloc((file_len + 1) * sizeof(char)); + if(buffer == NULL) + { + G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", (file_len + 1) * sizeof(char)); + trap_FS_FCloseFile(f); + return; + } + memset(buffer, 0, sizeof(buffer)); - trap_FS_Read(buffer, file_len, f); - if (buffer[0] == 0) { - G_LocLogger(LL_ERROR, "Couldn't read in file: %s!\n", fileRoute); - trap_FS_FCloseFile(f); - free(buffer); - G_LogFuncEnd(); - return; - } + trap_FS_Read(buffer, file_len, f); + if(buffer[0] == 0) + { + G_LocLogger(LL_ERROR, "Couldn't read in file: %s!\n", fileRoute); + trap_FS_FCloseFile(f); + free(buffer); + G_LogFuncEnd(); + return; + } - buffer[file_len] = '\0'; - trap_FS_FCloseFile(f); + buffer[file_len] = '\0'; + trap_FS_FCloseFile(f); - G_Logger(LL_INFO, "Locations file %s located. Proceeding to load scan data.\n", fileRoute); //GSIO01: why did this say "Usables file ..."? lol ;) + G_Logger(LL_INFO, "Locations file %s located. Proceeding to load scan data.\n", fileRoute); //GSIO01: why did this say "Usables file ..."? lol ;) - lex = bgLex_create(buffer); - if (lex == NULL) { - G_LocLogger(LL_ERROR, "Could not create bgLex to lex locations file.\n"); - free(buffer); - G_LogFuncEnd(); - return; - } + lex = bgLex_create(buffer); + if(lex == NULL) + { + G_LocLogger(LL_ERROR, "Could not create bgLex to lex locations file.\n"); + free(buffer); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) != LMT_SYMBOL) { - G_LocLogger(LL_ERROR, "Expected locations file to begin with 'LocationsList' or 'LocationsList2'.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) != LMT_SYMBOL) + { + G_LocLogger(LL_ERROR, "Expected locations file to begin with 'LocationsList' or 'LocationsList2'.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (lex->morphem.data.symbol == LSYM_LOCATIONS_LIST || lex->morphem.data.symbol == LSYM_LOCATIONS_LIST_2) { - if (bgLex_lex(lex) == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_OBRACEC) { - if (bgLex_lex(lex) == 0) { - G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } - else { - G_Logger(LL_WARN, "LocationsList2 had no opening brace '{'!\n"); - } + if(lex->morphem.data.symbol == LSYM_LOCATIONS_LIST || lex->morphem.data.symbol == LSYM_LOCATIONS_LIST_2) + { + if(bgLex_lex(lex) == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_OBRACEC) + { + if(bgLex_lex(lex) == 0) + { + G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } + else + { + G_Logger(LL_WARN, "LocationsList2 had no opening brace '{'!\n"); + } - while (qtrue) { - if (lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_CBRACEC) { - break; - } + while(qtrue) + { + if(lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_CBRACEC) + { + break; + } - if (lex->morphem.type == LMT_VECTOR3) { - VectorCopy(lex->morphem.data.vector3, origin); - } - else { - G_LocLogger(LL_ERROR, "Expected vector at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(lex->morphem.type == LMT_VECTOR3) + { + VectorCopy(lex->morphem.data.vector3, origin); + } + else + { + G_LocLogger(LL_ERROR, "Expected vector at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) == LMT_VECTOR3) { - VectorCopy(lex->morphem.data.vector3, angles); - } - else { - G_LocLogger(LL_ERROR, "Expected vector at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) == LMT_VECTOR3) + { + VectorCopy(lex->morphem.data.vector3, angles); + } + else + { + G_LocLogger(LL_ERROR, "Expected vector at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (bgLex_lex(lex) == LMT_STRING) { - int result; + if(bgLex_lex(lex) == LMT_STRING) + { + int result; - desc = G_NewString(lex->morphem.data.str); + desc = G_NewString(lex->morphem.data.str); - if (desc == NULL) { - free(buffer); - bgLex_destroy(lex); - return; - } + if(desc == NULL) + { + free(buffer); + bgLex_destroy(lex); + return; + } - if ((result = bgLex_lex(lex)) == LMT_STRING) { - rest = atoi(desc); - desc = G_NewString(lex->morphem.data.str); + if((result = bgLex_lex(lex)) == LMT_STRING) + { + rest = atoi(desc); + desc = G_NewString(lex->morphem.data.str); - if (bgLex_lex(lex) == 0) { - G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } - else { - if (result == 0) { - G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } - } - else { - G_LocLogger(LL_ERROR, "ERROR: Expected string at %d:%d.\n", lex->morphem.line, lex->morphem.column); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(bgLex_lex(lex) == 0) + { + G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } + else + { + if(result == 0) + { + G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } + } + else + { + G_LocLogger(LL_ERROR, "ERROR: Expected string at %d:%d.\n", lex->morphem.line, lex->morphem.column); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - //create a new entity - ent = G_Spawn(); - if (ent == NULL) { - G_LocLogger(LL_ERROR, "Couldn't create entity in %s!\n", fileRoute); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + //create a new entity + ent = G_Spawn(); + if(ent == NULL) + { + G_LocLogger(LL_ERROR, "Couldn't create entity in %s!\n", fileRoute); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - ent->classname = "target_location"; + ent->classname = "target_location"; - //copy position data - VectorCopy(origin, ent->s.origin); - VectorCopy(angles, ent->s.angles); + //copy position data + VectorCopy(origin, ent->s.origin); + VectorCopy(angles, ent->s.angles); - //copy string - ent->message = G_NewString(desc); + //copy string + ent->message = G_NewString(desc); - //copy desc into target as well - ent->target = ent->targetname = G_NewString(desc); + //copy desc into target as well + ent->target = ent->targetname = G_NewString(desc); - // copy restriction value - ent->sound1to2 = rest; + // copy restriction value + ent->sound1to2 = rest; - //initiate it as a location ent - SP_target_location(ent); + //initiate it as a location ent + SP_target_location(ent); - //reset the ent - ent = NULL; - rest = 0; + //reset the ent + ent = NULL; + rest = 0; - if (lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_SEMICOLON) { - if (bgLex_lex(lex) == 0) { - G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } - } - else { - G_Logger(LL_WARN, "Missing ';' at %d:%d.\n", lex->morphem.line, lex->morphem.column); - } - } - } - else { - G_LocLogger(LL_ERROR, "Unexpected token at %s:%d:%d.\n", fileRoute, lex->morphem.line, lex->morphem.column); - G_LocLogger(LL_ERROR, "Expected 'LocationsList' or 'LocationsList2'.\n"); - free(buffer); - bgLex_destroy(lex); - G_LogFuncEnd(); - return; - } + if(lex->morphem.type == LMT_SYMBOL && lex->morphem.data.symbol == LSYM_SEMICOLON) + { + if(bgLex_lex(lex) == 0) + { + G_LocLogger(LL_ERROR, "Unexpected end of file.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } + } + else + { + G_Logger(LL_WARN, "Missing ';' at %d:%d.\n", lex->morphem.line, lex->morphem.column); + } + } + } + else + { + G_LocLogger(LL_ERROR, "Unexpected token at %s:%d:%d.\n", fileRoute, lex->morphem.line, lex->morphem.column); + G_LocLogger(LL_ERROR, "Expected 'LocationsList' or 'LocationsList2'.\n"); + free(buffer); + bgLex_destroy(lex); + G_LogFuncEnd(); + return; + } - if (lex->morphem.type != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_CBRACEC) { - G_Logger(LL_WARN, "Missing closing brace '}'!\n"); - } + if(lex->morphem.type != LMT_SYMBOL || lex->morphem.data.symbol != LSYM_CBRACEC) + { + G_Logger(LL_WARN, "Missing closing brace '}'!\n"); + } - free(buffer); - bgLex_destroy(lex); + free(buffer); + bgLex_destroy(lex); - G_LogFuncEnd(); + G_LogFuncEnd(); } -char *G_searchGroupList(const char *name) { - char *text_p = NULL, *slash = NULL; - char text[MAX_GROUP_FILE_SIZE]; - int i; - char mod_name[200]; +char *G_searchGroupList(const char *name) +{ + char *text_p = NULL, *slash = NULL; + char text[MAX_GROUP_FILE_SIZE]; + int i; + char mod_name[200]; - memset(mod_name, 0, sizeof(mod_name)); - memset(races, 0, sizeof(races)); - memset(text, 0, sizeof(text)); + memset(mod_name, 0, sizeof(mod_name)); + memset(races, 0, sizeof(races)); + memset(text, 0, sizeof(text)); - // check to see if there is a '/' in the name - Q_strncpyz(mod_name, name, sizeof(mod_name)); - slash = strstr(mod_name, "/"); - if (slash != NULL) {//drop the slash and everything after it for the purpose of finding the model name in th group - *slash = 0; - } + // check to see if there is a '/' in the name + Q_strncpyz(mod_name, name, sizeof(mod_name)); + slash = strstr(mod_name, "/"); + if(slash != NULL) + {//drop the slash and everything after it for the purpose of finding the model name in th group + *slash = 0; + } - // find the name in the group list - for (i = 0; i < group_count; i++) { - if (Q_stricmp(mod_name, group_list[i].name) == 0) { - text_p = group_list[i].text; - break; - } - } + // find the name in the group list + for(i = 0; i < group_count; i++) + { + if(Q_stricmp(mod_name, group_list[i].name) == 0) + { + text_p = group_list[i].text; + break; + } + } - // did we find this group in the list? - if (i == group_count || text_p == NULL) { - Com_sprintf(races, sizeof(races), "unknown"); - } - else { - Com_sprintf(races, sizeof(races), "%s", text_p); - } - return races; + // did we find this group in the list? + if(i == group_count || text_p == NULL) + { + Com_sprintf(races, sizeof(races), "unknown"); + } + else + { + Com_sprintf(races, sizeof(races), "%s", text_p); + } + return races; } @@ -1592,53 +1692,60 @@ All but the first will have the FL_TEAMSLAVE flag set and teammaster field set All but the last will have the teamchain field set to the next one ================ */ -static void G_FindTeams(void) { - /*@shared@*/ /*@null@*/ gentity_t* e; - /*@shared@*/ /*@null@*/ gentity_t* e2; - int i, j; - int c, c2; +static void G_FindTeams(void) +{ + /*@shared@*/ /*@null@*/ gentity_t* e; + /*@shared@*/ /*@null@*/ gentity_t* e2; + int i, j; + int c, c2; - c = 0; - c2 = 0; - for (i = 1, e = g_entities + i; i < level.num_entities; i++, e++) { - if (!e->inuse) - continue; - if (!e->team) - continue; - if ((e->flags & FL_TEAMSLAVE) != 0) - continue; - if ((e->classname != NULL) && (e->type != ENT_FUNC_DOOR)) {//not a door - if (Q_stricmp("1", e->team) == 0 || Q_stricmp("2", e->team) == 0) {//is trying to tell us it belongs to the TEAM_RED or TEAM_BLUE - continue; - } - } - e->teammaster = e; - c++; - c2++; - for (j = i + 1, e2 = e + 1; j < level.num_entities; j++, e2++) { - if (!e2->inuse) - continue; - if (!e2->team) - continue; - if ((e2->flags & FL_TEAMSLAVE) != 0) - continue; - if (strcmp(e->team, e2->team) == 0) { - c2++; - e2->teamchain = e->teamchain; - e->teamchain = e2; - e2->teammaster = e; - e2->flags |= FL_TEAMSLAVE; + c = 0; + c2 = 0; + for(i = 1, e = g_entities + i; i < level.num_entities; i++, e++) + { + if(!e->inuse) + continue; + if(!e->team) + continue; + if((e->flags & FL_TEAMSLAVE) != 0) + continue; + if((e->classname != NULL) && (e->type != ENT_FUNC_DOOR)) + {//not a door + if(Q_stricmp("1", e->team) == 0 || Q_stricmp("2", e->team) == 0) + {//is trying to tell us it belongs to the TEAM_RED or TEAM_BLUE + continue; + } + } + e->teammaster = e; + c++; + c2++; + for(j = i + 1, e2 = e + 1; j < level.num_entities; j++, e2++) + { + if(!e2->inuse) + continue; + if(!e2->team) + continue; + if((e2->flags & FL_TEAMSLAVE) != 0) + continue; + if(strcmp(e->team, e2->team) == 0) + { + c2++; + e2->teamchain = e->teamchain; + e->teamchain = e2; + e2->teammaster = e; + e2->flags |= FL_TEAMSLAVE; - // make sure that targets only point at the master - if (e2->targetname) { - e->targetname = e2->targetname; - e2->targetname = NULL; - } - } - } - } + // make sure that targets only point at the master + if(e2->targetname) + { + e->targetname = e2->targetname; + e2->targetname = NULL; + } + } + } + } - G_Printf("%i teams with %i entities\n", c, c2); + G_Printf("%i teams with %i entities\n", c, c2); } /* @@ -1646,28 +1753,33 @@ static void G_FindTeams(void) { G_RegisterCvars ================= */ -static void G_RegisterCvars(void) { - int i; - cvarTable_t *cv; +static void G_RegisterCvars(void) +{ + int i; + cvarTable_t *cv; - for (i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++) { + for(i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++) + { - if (rpg_rpg.integer != 0) { - trap_Cvar_Set("g_gametype", "0");//RPG-X: RedTechie - Make sure we keep gametype at 0 - } + if(rpg_rpg.integer != 0) + { + trap_Cvar_Set("g_gametype", "0");//RPG-X: RedTechie - Make sure we keep gametype at 0 + } - trap_Cvar_Register(cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags); - if (cv->vmCvar) { - cv->modificationCount = cv->vmCvar->modificationCount; - } - } + trap_Cvar_Register(cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags); + if(cv->vmCvar) + { + cv->modificationCount = cv->vmCvar->modificationCount; + } + } - // check some things + // check some things - if (g_gametype.integer < 0 || g_gametype.integer >= GT_MAX_GAME_TYPE) { - G_Printf("g_gametype %i is out of range, defaulting to 0\n", g_gametype.integer); - trap_Cvar_Set("g_gametype", "0"); - } + if(g_gametype.integer < 0 || g_gametype.integer >= GT_MAX_GAME_TYPE) + { + G_Printf("g_gametype %i is out of range, defaulting to 0\n", g_gametype.integer); + trap_Cvar_Set("g_gametype", "0"); + } } /* @@ -1675,62 +1787,77 @@ static void G_RegisterCvars(void) { G_UpdateCvars ================= */ -static void G_UpdateCvars(void) { - int i; - cvarTable_t *cv; +static void G_UpdateCvars(void) +{ + int i; + cvarTable_t *cv; - for (i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++) { - if (cv->vmCvar) { - trap_Cvar_Update(cv->vmCvar); + for(i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++) + { + if(cv->vmCvar) + { + trap_Cvar_Update(cv->vmCvar); - if (cv->modificationCount != cv->vmCvar->modificationCount) { - cv->modificationCount = cv->vmCvar->modificationCount; + if(cv->modificationCount != cv->vmCvar->modificationCount) + { + cv->modificationCount = cv->vmCvar->modificationCount; - if (cv->trackChange) { - if (!levelExiting) {//no need to do this during level changes - //RPG-X: J2J - Don't show gravity changed messages any more (for the gravity target ents) - if (Q_stricmp(cv->cvarName, "g_gravity") != 0) { - trap_SendServerCommand(-1, va("print \"Server: %s changed to %s\n\"", - cv->cvarName, cv->vmCvar->string)); - } - } - } - } - } - } + if(cv->trackChange) + { + if(!levelExiting) + {//no need to do this during level changes +//RPG-X: J2J - Don't show gravity changed messages any more (for the gravity target ents) + if(Q_stricmp(cv->cvarName, "g_gravity") != 0) + { + trap_SendServerCommand(-1, va("print \"Server: %s changed to %s\n\"", + cv->cvarName, cv->vmCvar->string)); + } + } + } + } + } + } } extern int altAmmoUsage[]; -static void G_InitModRules(void) { - numKilled = 0; +static void G_InitModRules(void) +{ + numKilled = 0; } -static void Dev_ShowTriggers(gentity_t *ent) { - int i; - gentity_t *tar; +static void Dev_ShowTriggers(gentity_t *ent) +{ + int i; + gentity_t *tar; - ent->nextthink = level.time + 9500; + ent->nextthink = level.time + 9500; - for (i = 0; i < MAX_GENTITIES; i++) { - if ((tar = &g_entities[i]) == NULL) continue; - if (tar->type >= ENT_TRIGGER_ALWAYS && tar->type < ENT_TARGET_REMOVE_POWERUPS) { - if (tar->type == ENT_TRIGGER_ALWAYS) { - continue; - } + for(i = 0; i < MAX_GENTITIES; i++) + { + if((tar = &g_entities[i]) == NULL) continue; + if(tar->type >= ENT_TRIGGER_ALWAYS && tar->type < ENT_TARGET_REMOVE_POWERUPS) + { + if(tar->type == ENT_TRIGGER_ALWAYS) + { + continue; + } - if ((tar->r.svFlags & SVF_NOCLIENT) != 0) { - tar->r.svFlags ^= SVF_NOCLIENT; - } + if((tar->r.svFlags & SVF_NOCLIENT) != 0) + { + tar->r.svFlags ^= SVF_NOCLIENT; + } - trap_LinkEntity(ent); - if (tar->type == ENT_TRIGGER_PUSH) { - G_AddEvent(tar, EV_TRIGGER_SHOW, 1); - } - else { - G_AddEvent(tar, EV_TRIGGER_SHOW, 0); - } - } - } + trap_LinkEntity(ent); + if(tar->type == ENT_TRIGGER_PUSH) + { + G_AddEvent(tar, EV_TRIGGER_SHOW, 1); + } + else + { + G_AddEvent(tar, EV_TRIGGER_SHOW, 0); + } + } + } } @@ -1743,297 +1870,322 @@ extern int lastKillTime[]; extern int LastFKRadius[]; //(RPG-X J2J) added so array can be initialised to 0 first. extern RPGX_SiteTOSiteData TransDat[]; //(RPG-X J2J) added for tricorder transporter extern RPGX_DragData DragDat[]; -void G_InitGame(int levelTime, unsigned int randomSeed, int restart) { - int i; - char fileName[MAX_QPATH]; - float messageTime; +void G_InitGame(int levelTime, unsigned int randomSeed, int restart) +{ + int i; + char fileName[MAX_QPATH]; + float messageTime; - G_Printf("------- Game Initialization -------\n"); - G_Printf("gamename: %s\n", GAMEVERSION); - G_Printf("gamedate: %s\n", __DATE__); - G_Printf("This is RPG-X version %s compiled by %s on %s.\n", RPGX_VERSION, RPGX_COMPILEDBY, RPGX_COMPILEDATE); + G_Printf("------- Game Initialization -------\n"); + G_Printf("gamename: %s\n", GAMEVERSION); + G_Printf("gamedate: %s\n", __DATE__); + G_Printf("This is RPG-X version %s compiled by %s on %s.\n", RPGX_VERSION, RPGX_COMPILEDBY, RPGX_COMPILEDATE); - level.overrideCalcLiftTravelDuration = 0; + level.overrideCalcLiftTravelDuration = 0; - init_tonextint(qtrue); - srand(randomSeed); + init_tonextint(qtrue); + srand(randomSeed); - numKilled = 0; - level.numObjectives = 0;//no objectives by default + numKilled = 0; + level.numObjectives = 0;//no objectives by default - G_RegisterCvars(); + G_RegisterCvars(); - G_ProcessIPBans(); - G_ProcessIDBans(); + G_ProcessIPBans(); + G_ProcessIDBans(); - G_InitMemory(); + G_InitMemory(); - //G_initGroupsList(); + //G_initGroupsList(); - BG_LoadItemNames(); + BG_LoadItemNames(); - // set some level globals - memset(&level, 0, sizeof(level)); + // set some level globals + memset(&level, 0, sizeof(level)); - //Class loader - memset(fileName, 0, sizeof(fileName)); - Com_sprintf(fileName, sizeof(fileName), "ext_data/classes/%s.classes", rpg_classSet.string); - if (!G_LoadClassData(fileName)) { - G_Printf(S_COLOR_RED "ERROR: Could not load class set %s. Reverting to default.\n", fileName); - trap_Cvar_Set("rpg_classSet", CLASS_DEFAULT); + //Class loader + memset(fileName, 0, sizeof(fileName)); + Com_sprintf(fileName, sizeof(fileName), "ext_data/classes/%s.classes", rpg_classSet.string); + if(!G_LoadClassData(fileName)) + { + G_Printf(S_COLOR_RED "ERROR: Could not load class set %s. Reverting to default.\n", fileName); + trap_Cvar_Set("rpg_classSet", CLASS_DEFAULT); - if (!G_LoadClassData(va("ext_data/classes/%s.classes", CLASS_DEFAULT))) { - G_Error("Could not load default class set: %s", CLASS_DEFAULT); - } - } + if(!G_LoadClassData(va("ext_data/classes/%s.classes", CLASS_DEFAULT))) + { + G_Error("Could not load default class set: %s", CLASS_DEFAULT); + } + } - //Rank Loader - memset(fileName, 0, sizeof(fileName)); - Com_sprintf(fileName, sizeof(fileName), "ext_data/ranksets/%s.ranks", rpg_rankSet.string); - if (!BG_ParseRankNames(fileName, g_rankNames, sizeof(rankNames_t)* MAX_RANKS)) { - G_Printf(S_COLOR_RED "ERROR: Could not load rankset %s. Reverting to default.\n", fileName); - trap_Cvar_Set("rpg_rankSet", RANKSET_DEFAULT); + //Rank Loader + memset(fileName, 0, sizeof(fileName)); + Com_sprintf(fileName, sizeof(fileName), "ext_data/ranksets/%s.ranks", rpg_rankSet.string); + if(!BG_ParseRankNames(fileName, g_rankNames, sizeof(rankNames_t)* MAX_RANKS)) + { + G_Printf(S_COLOR_RED "ERROR: Could not load rankset %s. Reverting to default.\n", fileName); + trap_Cvar_Set("rpg_rankSet", RANKSET_DEFAULT); - if (!BG_ParseRankNames(va("ext_data/ranksets/%s.ranks", RANKSET_DEFAULT), g_rankNames, sizeof(rankNames_t)* MAX_RANKS)) { - G_Error("Could not load default rankset: %s", RANKSET_DEFAULT); - } - } + if(!BG_ParseRankNames(va("ext_data/ranksets/%s.ranks", RANKSET_DEFAULT), g_rankNames, sizeof(rankNames_t)* MAX_RANKS)) + { + G_Error("Could not load default rankset: %s", RANKSET_DEFAULT); + } + } - level.time = levelTime; - level.startTime = levelTime; - level.restarted = (qboolean)restart; + level.time = levelTime; + level.startTime = levelTime; + level.restarted = (qboolean)restart; - //level.message = levelTime - (int)(rpg_timedmessagetime.value * 60000) + 30000; - if (rpg_timedmessagetime.value < 0.2) { - messageTime = 0.2; - } - else { - messageTime = rpg_timedmessagetime.value; - } + //level.message = levelTime - (int)(rpg_timedmessagetime.value * 60000) + 30000; + if(rpg_timedmessagetime.value < 0.2) + { + messageTime = 0.2; + } + else + { + messageTime = rpg_timedmessagetime.value; + } - level.message = levelTime + (messageTime * 60000); + level.message = levelTime + (messageTime * 60000); - level.snd_fry = G_SoundIndex("sound/player/fry.wav"); // FIXME standing in lava / slime + level.snd_fry = G_SoundIndex("sound/player/fry.wav"); // FIXME standing in lava / slime - if (g_gametype.integer != GT_SINGLE_PLAYER && g_log.string[0] != 0) { - if (g_logSync.integer != 0) { - trap_FS_FOpenFile(g_log.string, &level.logFile, FS_APPEND_SYNC); - } - else { - trap_FS_FOpenFile(g_log.string, &level.logFile, FS_APPEND); - } - if (level.logFile == 0) { - G_Printf("WARNING: Couldn't open logfile: %s\n", g_log.string); - } - else { - char serverinfo[MAX_INFO_STRING]; + if(g_gametype.integer != GT_SINGLE_PLAYER && g_log.string[0] != 0) + { + if(g_logSync.integer != 0) + { + trap_FS_FOpenFile(g_log.string, &level.logFile, FS_APPEND_SYNC); + } + else + { + trap_FS_FOpenFile(g_log.string, &level.logFile, FS_APPEND); + } + if(level.logFile == 0) + { + G_Printf("WARNING: Couldn't open logfile: %s\n", g_log.string); + } + else + { + char serverinfo[MAX_INFO_STRING]; - memset(serverinfo, 0, sizeof(serverinfo)); - trap_GetServerinfo(serverinfo, sizeof(serverinfo)); + memset(serverinfo, 0, sizeof(serverinfo)); + trap_GetServerinfo(serverinfo, sizeof(serverinfo)); - G_LogPrintf("------------------------------------------------------------\n"); - G_LogPrintf("InitGame: %s\n", serverinfo); - } - } - else { - G_Printf("Not logging to disk.\n"); - } + G_LogPrintf("------------------------------------------------------------\n"); + G_LogPrintf("InitGame: %s\n", serverinfo); + } + } + else + { + G_Printf("Not logging to disk.\n"); + } #ifdef G_LUA - G_Lua_Init(); + G_Lua_Init(); #endif - G_Weapon_LoadConfig(); + G_Weapon_LoadConfig(); - G_LogWeaponInit(); + G_LogWeaponInit(); - G_InitWorldSession(); + G_InitWorldSession(); - // initialize all entities for this game - memset(g_entities, 0, MAX_GENTITIES * sizeof(g_entities[0])); - level.gentities = g_entities; + // initialize all entities for this game + memset(g_entities, 0, MAX_GENTITIES * sizeof(g_entities[0])); + level.gentities = g_entities; - // initialize all clients for this game - level.maxclients = g_maxclients.integer; - memset(g_clients, 0, MAX_CLIENTS * sizeof(g_clients[0])); - level.clients = g_clients; + // initialize all clients for this game + level.maxclients = g_maxclients.integer; + memset(g_clients, 0, MAX_CLIENTS * sizeof(g_clients[0])); + level.clients = g_clients; - // set client fields on player ents - for (i = 0; i < level.maxclients; i++) { - g_entities[i].client = level.clients + i; - } + // set client fields on player ents + for(i = 0; i < level.maxclients; i++) + { + g_entities[i].client = level.clients + i; + } - // always leave room for the max number of clients, - // even if they aren't all used, so numbers inside that - // range are NEVER anything but clients - level.num_entities = MAX_CLIENTS; + // always leave room for the max number of clients, + // even if they aren't all used, so numbers inside that + // range are NEVER anything but clients + level.num_entities = MAX_CLIENTS; - // let the server system know where the entites are - trap_LocateGameData(level.gentities, level.num_entities, (int)sizeof(gentity_t), - &level.clients[0].ps, (int)sizeof(level.clients[0])); + // let the server system know where the entites are + trap_LocateGameData(level.gentities, level.num_entities, (int)sizeof(gentity_t), + &level.clients[0].ps, (int)sizeof(level.clients[0])); - // reserve some spots for dead player bodies - G_Client_InitBodyQue(); + // reserve some spots for dead player bodies + G_Client_InitBodyQue(); - ClearRegisteredItems(); + ClearRegisteredItems(); - // parse the map usables file - G_Usable_SetupUsablesStrings(); + // parse the map usables file + G_Usable_SetupUsablesStrings(); - // parse the key/value pairs and spawn gentities - G_SpawnEntitiesFromString(); + // parse the key/value pairs and spawn gentities + G_SpawnEntitiesFromString(); - //TiM: load a locations file, whereever possible - G_LoadLocationsFile(); + //TiM: load a locations file, whereever possible + G_LoadLocationsFile(); - //GSIO: load server change file if avaible - G_LoadServerChangeFile(); + //GSIO: load server change file if avaible + G_LoadServerChangeFile(); - //GSIO: load map change file if avaible - G_LoadMapChangeFile(); + //GSIO: load map change file if avaible + G_LoadMapChangeFile(); - //GSIO: load holodeck file if avaible - G_LoadHolodeckFile(); + //GSIO: load holodeck file if avaible + G_LoadHolodeckFile(); - //GSIO: load timed message - G_LoadTimedMessages(); + //GSIO: load timed message + G_LoadTimedMessages(); - // general initialization - G_FindTeams(); + // general initialization + G_FindTeams(); - SaveRegisteredItems(); + SaveRegisteredItems(); - G_Printf("-----------------------------------\n"); + G_Printf("-----------------------------------\n"); - if (g_gametype.integer == GT_SINGLE_PLAYER || trap_Cvar_VariableIntegerValue("com_buildScript") != 0) { - G_ModelIndex(SP_PODIUM_MODEL); - G_SoundIndex("sound/player/gurp1.wav"); - G_SoundIndex("sound/player/gurp2.wav"); - } - if (g_gametype.integer >= GT_TEAM || trap_Cvar_VariableIntegerValue("com_buildScript") != 0) { - G_ModelIndex(TEAM_PODIUM_MODEL); - } + if(g_gametype.integer == GT_SINGLE_PLAYER || trap_Cvar_VariableIntegerValue("com_buildScript") != 0) + { + G_ModelIndex(SP_PODIUM_MODEL); + G_SoundIndex("sound/player/gurp1.wav"); + G_SoundIndex("sound/player/gurp2.wav"); + } + if(g_gametype.integer >= GT_TEAM || trap_Cvar_VariableIntegerValue("com_buildScript") != 0) + { + G_ModelIndex(TEAM_PODIUM_MODEL); + } - if (trap_Cvar_VariableIntegerValue("bot_enable") != 0) { - AI_main_BotAISetup(restart); - AI_main_BotAILoadMap(restart); - G_InitBots((qboolean)restart); - } + if(trap_Cvar_VariableIntegerValue("bot_enable") != 0) + { + AI_main_BotAISetup(restart); + AI_main_BotAILoadMap(restart); + G_InitBots((qboolean)restart); + } - G_InitModRules(); + G_InitModRules(); - levelExiting = qfalse; + levelExiting = qfalse; - /*RPG-X J2J************************************************************************************/ - G_Printf("Initializing RPG-X Globals..."); + /*RPG-X J2J************************************************************************************/ + G_Printf("Initializing RPG-X Globals..."); - //WARNING - used hard coded number to shut up compiler, 1023 is MAX_ENTITIES (which apperently cant be increased without substansial exe recoding) - //TiM : NB Ents 0 -> 128 are clients only. cyclicng thru all ents here is not needed. - for (i = 0; i < MAX_CLIENTS; i++) { - //RPG-X: Redtechie - Make sure score cant be chnaged unless other wise told to - if (g_entities[i].client) { - g_entities[i].client->UpdateScore = qfalse; - g_entities[i].client->AdminFailed = 0; // RPG-X | Phenix | 21/11/2004 | Init Admin Failed Integer - g_entities[i].client->LoggedAsAdmin = qfalse; - g_entities[i].client->LoggedAsDeveloper = qfalse; - } - } + //WARNING - used hard coded number to shut up compiler, 1023 is MAX_ENTITIES (which apperently cant be increased without substansial exe recoding) + //TiM : NB Ents 0 -> 128 are clients only. cyclicng thru all ents here is not needed. + for(i = 0; i < MAX_CLIENTS; i++) + { + //RPG-X: Redtechie - Make sure score cant be chnaged unless other wise told to + if(g_entities[i].client) + { + g_entities[i].client->UpdateScore = qfalse; + g_entities[i].client->AdminFailed = 0; // RPG-X | Phenix | 21/11/2004 | Init Admin Failed Integer + g_entities[i].client->LoggedAsAdmin = qfalse; + g_entities[i].client->LoggedAsDeveloper = qfalse; + } + } - for (i = 0; i < MAX_CLIENTS; i++) { - lastKillTime[i] = level.time - 30000; + for(i = 0; i < MAX_CLIENTS; i++) + { + lastKillTime[i] = level.time - 30000; - //FKR - LastFKRadius[i] = level.time - rpg_forcekillradiuswaittime.integer; + //FKR + LastFKRadius[i] = level.time - rpg_forcekillradiuswaittime.integer; - //Transporter - memset(&TransDat[i], 0, sizeof(TransDat[i])); - TransDat[i].LastClick = level.time - 5000; //Make last click current time less 5 seconds. + //Transporter + memset(&TransDat[i], 0, sizeof(TransDat[i])); + TransDat[i].LastClick = level.time - 5000; //Make last click current time less 5 seconds. - //Drag Data - DragDat[i].AdminId = -1; - } + //Drag Data + DragDat[i].AdminId = -1; + } - G_Printf("%i entities loaded.\n", level.num_entities); + G_Printf("%i entities loaded.\n", level.num_entities); - G_Printf("COMPLETED\n"); + G_Printf("COMPLETED\n"); #ifdef G_LUA - LuaHook_G_InitGame(levelTime, randomSeed, restart); + LuaHook_G_InitGame(levelTime, randomSeed, restart); #endif - if (dev_showTriggers.integer != 0 && restart == 0) { - gentity_t *t; - t = G_Spawn(); - if (t) { - t->think = Dev_ShowTriggers; - t->nextthink = level.time + 1000; - } - } + if(dev_showTriggers.integer != 0 && restart == 0) + { + gentity_t *t; + t = G_Spawn(); + if(t) + { + t->think = Dev_ShowTriggers; + t->nextthink = level.time + 1000; + } + } #ifdef SQL - if(G_Sql_Init()) { - G_Printf("SQL initialization successful.\n"); - } else { - G_Printf(S_COLOR_RED "Error: SQL initialization failed!\n"); - } + if(G_Sql_Init()) + { + G_Printf("SQL initialization successful.\n"); + } + else + { + G_Printf(S_COLOR_RED "Error: SQL initialization failed!\n"); + } #endif - /*************************************************************************************************/ + /*************************************************************************************************/ - G_Printf(" ,. \n"); G_Printf(" ..:, :Xt. ,:. \n"); - G_Printf(" ,=+t: .IRX= :++=. \n"); G_Printf(" .=iVt:. :RYYI. .itt+ \n"); - G_Printf(" .:tXI=;. tRtiV; ,IYY:. \n"); G_Printf(" .+;ii=;. ,XVi+Vt. :tIi+ \n"); - G_Printf(" .;ti;;:. +RI++IY, ,+tt=. \n"); G_Printf(" ,++YY;. ,XXi+++X= ;IYI=. \n"); - G_Printf(" ;ttY+;. .,=iVRI++++YX+;. ;VYt; \n"); G_Printf(" .;ii+=, .;IXRRXVi++++iVRXVi:. ,=iii. \n"); - G_Printf(" .==;ti, .;YRRVVXYii+++++IVIVRXt, ,+=tI= \n"); G_Printf(" .iitY=, .tRRVXXVRV+++ii++YRXVIYXV; :tYti, \n"); - G_Printf(" .+iii=,,IBVVXYiiXViiiiiiitVtIXViVR= ,+t+I: \n"); G_Printf(" =+=I:.tBVXVt=;tRIiiiiiiiiXi:=YXiIX; :+=It; \n"); - G_Printf(" .;;tYt:;RVVV+=:,YRiiiiiiiiiYI,.:IXiVY..+IYi= \n"); G_Printf(" .ti=t+;tRIXi;, :XViiiiiiiiiIV: ,YViX=.:titt. \n"); - G_Printf(" iY++I;YVYY=: +BIiiiiiiiiiiX= +XiVi;i++Vi, \n"); G_Printf(" ,+YYYI:VYYY;. .YRiiiiiiiiiiiVt. ;RIYt:IIVVi: \n"); - G_Printf(" ,+tYXi;YVIX; ;RVtiiiiIXXtiiVI, iRIVt,=XVit: \n"); G_Printf(" .+iiti++XiXI. iBIiiiiYXIIXtiIV: :XXIV++;i+iI;.\n"); - G_Printf(" ;Ii=ii:VYtRi,VRtiiiVVi=;IXitX=;VBYXI=i+;iV+;.\n"); G_Printf(" ;tYtVt;;XYIRXBVttiVV+;:.:VYiXVRBVXY+;+IYVt+, \n"); - G_Printf(" =iiItii,=XVIRRIttXV+=:..,tRtVBXVRI+=i:iIit+. \n"); G_Printf(" :t==++I:.=YXYIIiYBXYIttIVRBYtVXXI+;;t+;;+Y=, \n"); - G_Printf(" +I=;+Y= .:IRItYIVXRRRBBRXXVIRY+=;.:i=;iVi;. \n"); G_Printf(" .+IYVV+: +BYXXVXXXXXXXXXVRVVi;:.:;tVYY+=: \n"); - G_Printf(" .+ttii+ .IBXY++ittIIIti++tXXi, .++=tI+;: \n"); G_Printf(" ;YYtIY;;VBI+;:,::;;;;;:,:IBt,::tItYV=. \n"); - G_Printf(" =IYYI++ti+;, ....... :Xt;i=iYYI+;. \n"); G_Printf(" .:+i++ii;;. .=i=+i=t+;;:. \n"); - G_Printf(" ,tYIVI==:,.. ..,;=+iYIVt:.. \n"); G_Printf(" ,itt+iIYYti;. ,;itYIIt:iIi=;. \n"); - G_Printf(" .:;;:+tIIVIi:.;iYYIii+=:,;;:. \n"); G_Printf(" . ,:=itIXi.tXYit=;::, . \n"); - G_Printf(" .+tti=,,iIt+;. \n"); G_Printf(" .:;;:. ,;;;:. \n"); + G_Printf(" ,. \n"); G_Printf(" ..:, :Xt. ,:. \n"); + G_Printf(" ,=+t: .IRX= :++=. \n"); G_Printf(" .=iVt:. :RYYI. .itt+ \n"); + G_Printf(" .:tXI=;. tRtiV; ,IYY:. \n"); G_Printf(" .+;ii=;. ,XVi+Vt. :tIi+ \n"); + G_Printf(" .;ti;;:. +RI++IY, ,+tt=. \n"); G_Printf(" ,++YY;. ,XXi+++X= ;IYI=. \n"); + G_Printf(" ;ttY+;. .,=iVRI++++YX+;. ;VYt; \n"); G_Printf(" .;ii+=, .;IXRRXVi++++iVRXVi:. ,=iii. \n"); + G_Printf(" .==;ti, .;YRRVVXYii+++++IVIVRXt, ,+=tI= \n"); G_Printf(" .iitY=, .tRRVXXVRV+++ii++YRXVIYXV; :tYti, \n"); + G_Printf(" .+iii=,,IBVVXYiiXViiiiiiitVtIXViVR= ,+t+I: \n"); G_Printf(" =+=I:.tBVXVt=;tRIiiiiiiiiXi:=YXiIX; :+=It; \n"); + G_Printf(" .;;tYt:;RVVV+=:,YRiiiiiiiiiYI,.:IXiVY..+IYi= \n"); G_Printf(" .ti=t+;tRIXi;, :XViiiiiiiiiIV: ,YViX=.:titt. \n"); + G_Printf(" iY++I;YVYY=: +BIiiiiiiiiiiX= +XiVi;i++Vi, \n"); G_Printf(" ,+YYYI:VYYY;. .YRiiiiiiiiiiiVt. ;RIYt:IIVVi: \n"); + G_Printf(" ,+tYXi;YVIX; ;RVtiiiiIXXtiiVI, iRIVt,=XVit: \n"); G_Printf(" .+iiti++XiXI. iBIiiiiYXIIXtiIV: :XXIV++;i+iI;.\n"); + G_Printf(" ;Ii=ii:VYtRi,VRtiiiVVi=;IXitX=;VBYXI=i+;iV+;.\n"); G_Printf(" ;tYtVt;;XYIRXBVttiVV+;:.:VYiXVRBVXY+;+IYVt+, \n"); + G_Printf(" =iiItii,=XVIRRIttXV+=:..,tRtVBXVRI+=i:iIit+. \n"); G_Printf(" :t==++I:.=YXYIIiYBXYIttIVRBYtVXXI+;;t+;;+Y=, \n"); + G_Printf(" +I=;+Y= .:IRItYIVXRRRBBRXXVIRY+=;.:i=;iVi;. \n"); G_Printf(" .+IYVV+: +BYXXVXXXXXXXXXVRVVi;:.:;tVYY+=: \n"); + G_Printf(" .+ttii+ .IBXY++ittIIIti++tXXi, .++=tI+;: \n"); G_Printf(" ;YYtIY;;VBI+;:,::;;;;;:,:IBt,::tItYV=. \n"); + G_Printf(" =IYYI++ti+;, ....... :Xt;i=iYYI+;. \n"); G_Printf(" .:+i++ii;;. .=i=+i=t+;;:. \n"); + G_Printf(" ,tYIVI==:,.. ..,;=+iYIVt:.. \n"); G_Printf(" ,itt+iIYYti;. ,;itYIIt:iIi=;. \n"); + G_Printf(" .:;;:+tIIVIi:.;iYYIii+=:,;;:. \n"); G_Printf(" . ,:=itIXi.tXYit=;::, . \n"); + G_Printf(" .+tti=,,iIt+;. \n"); G_Printf(" .:;;:. ,;;;:. \n"); } -void G_ShutdownGame(int restart) { - G_Printf("==== ShutdownGame ====\n"); +void G_ShutdownGame(int restart) +{ + G_Printf("==== ShutdownGame ====\n"); #ifdef G_LUA - LuaHook_G_Shutdown(restart); - G_Lua_Shutdown(); + LuaHook_G_Shutdown(restart); + G_Lua_Shutdown(); #endif #if 0 // kef -- Pat sez this is causing some trouble these days - G_LogWeaponOutput(); + G_LogWeaponOutput(); #endif - if (level.logFile != 0) { - G_LogPrintf("ShutdownGame:\n"); - G_LogPrintf("------------------------------------------------------------\n"); - trap_FS_FCloseFile(level.logFile); - } + if(level.logFile != 0) + { + G_LogPrintf("ShutdownGame:\n"); + G_LogPrintf("------------------------------------------------------------\n"); + trap_FS_FCloseFile(level.logFile); + } - // write all the client session data so we can get it back - G_WriteSessionData(); + // write all the client session data so we can get it back + G_WriteSessionData(); - if (trap_Cvar_VariableIntegerValue("bot_enable") != 0) { - AI_main_BotAIShutdown(restart); - } + if(trap_Cvar_VariableIntegerValue("bot_enable") != 0) + { + AI_main_BotAIShutdown(restart); + } - if (level.timedMessages != NULL) { - destroy_list(level.timedMessages); - } - - destroy_iterator(level.iterTimedMessages); + level.timedMessages.clear(); + level.timedMessageIndex = 0; #ifdef SQL - G_Sql_Shutdown(); + G_Sql_Shutdown(); #endif } @@ -2044,26 +2196,28 @@ void G_ShutdownGame(int restart) { #ifndef GAME_HARD_LINKED // this is only here so the functions in q_shared.c and bg_*.c can link -void QDECL Com_Error( /*@unused@*/ int32_t errlevel, const char *error, ...) { - va_list argptr; - char text[1024]; +void QDECL Com_Error( /*@unused@*/ int32_t errlevel, const char *error, ...) +{ + va_list argptr; + char text[1024]; - va_start(argptr, error); - vsnprintf(text, sizeof(text), error, argptr); - va_end(argptr); + va_start(argptr, error); + vsnprintf(text, sizeof(text), error, argptr); + va_end(argptr); - G_Error("%s", text); + G_Error("%s", text); } -void QDECL Com_Printf(const char *msg, ...) { - va_list argptr; - char text[1024]; +void QDECL Com_Printf(const char *msg, ...) +{ + va_list argptr; + char text[1024]; - va_start(argptr, msg); - vsnprintf(text, sizeof(text), msg, argptr); - va_end(argptr); + va_start(argptr, msg); + vsnprintf(text, sizeof(text), msg, argptr); + va_end(argptr); - G_Printf("%s", text); + G_Printf("%s", text); } #endif @@ -2083,21 +2237,24 @@ RemoveTournamentLoser Make the loser a spectator at the back of the line ======================= */ -static void RemoveTournamentLoser(void) { - int clientNum; +static void RemoveTournamentLoser(void) +{ + int clientNum; - if (level.numPlayingClients != 2) { - return; - } + if(level.numPlayingClients != 2) + { + return; + } - clientNum = level.sortedClients[1]; + clientNum = level.sortedClients[1]; - if (level.clients[clientNum].pers.connected != CON_CONNECTED) { - return; - } + if(level.clients[clientNum].pers.connected != CON_CONNECTED) + { + return; + } - // make them a spectator - SetTeam(&g_entities[clientNum], "s"); + // make them a spectator + SetTeam(&g_entities[clientNum], "s"); } @@ -2107,20 +2264,23 @@ AdjustTournamentScores ======================= */ -static void AdjustTournamentScores(void) { - int clientNum; +static void AdjustTournamentScores(void) +{ + int clientNum; - clientNum = level.sortedClients[0]; - if (level.clients[clientNum].pers.connected == CON_CONNECTED) { - level.clients[clientNum].sess.wins++; - G_Client_UserinfoChanged(clientNum); - } + clientNum = level.sortedClients[0]; + if(level.clients[clientNum].pers.connected == CON_CONNECTED) + { + level.clients[clientNum].sess.wins++; + G_Client_UserinfoChanged(clientNum); + } - clientNum = level.sortedClients[1]; - if (level.clients[clientNum].pers.connected == CON_CONNECTED) { - level.clients[clientNum].sess.losses++; - G_Client_UserinfoChanged(clientNum); - } + clientNum = level.sortedClients[1]; + if(level.clients[clientNum].pers.connected == CON_CONNECTED) + { + level.clients[clientNum].sess.losses++; + G_Client_UserinfoChanged(clientNum); + } } @@ -2141,73 +2301,84 @@ Do this at G_Client_BeginIntermission time and whenever ranks are recalculated due to enters/exits/forced team changes ======================== */ -void SendScoreboardMessageToAllClients(void) { - int i; +void SendScoreboardMessageToAllClients(void) +{ + int i; - for (i = 0; i < level.maxclients; i++) { - if (level.clients[i].pers.connected == CON_CONNECTED) { - DeathmatchScoreboardMessage(g_entities + i); - } - } + for(i = 0; i < level.maxclients; i++) + { + if(level.clients[i].pers.connected == CON_CONNECTED) + { + DeathmatchScoreboardMessage(g_entities + i); + } + } } -void MoveClientToIntermission(gentity_t *ent) { - entityState_t* es; - playerState_t* ps; +void MoveClientToIntermission(gentity_t *ent) +{ + entityState_t* es; + playerState_t* ps; - if (ent == NULL || ent->client == NULL) { - return; - } + if(ent == NULL || ent->client == NULL) + { + return; + } - ps = &ent->client->ps; - es = &ent->s; + ps = &ent->client->ps; + es = &ent->s; - // take out of follow mode if needed - if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW) { - StopFollowing(ent); - } + // take out of follow mode if needed + if(ent->client->sess.spectatorState == SPECTATOR_FOLLOW) + { + StopFollowing(ent); + } - // move to the spot - VectorCopy(level.intermission_origin, es->origin); - VectorCopy(level.intermission_origin, ps->origin); - VectorCopy(level.intermission_angle, ps->viewangles); - ps->pm_type = PM_INTERMISSION; - ps->eFlags ^= EF_TELEPORT_BIT; + // move to the spot + VectorCopy(level.intermission_origin, es->origin); + VectorCopy(level.intermission_origin, ps->origin); + VectorCopy(level.intermission_angle, ps->viewangles); + ps->pm_type = PM_INTERMISSION; + ps->eFlags ^= EF_TELEPORT_BIT; - // clean up powerup info - memset(ps->powerups, 0, sizeof(ps->powerups)); + // clean up powerup info + memset(ps->powerups, 0, sizeof(ps->powerups)); - ps->eFlags = 0; - es->eFlags = 0; - es->eType = ET_GENERAL; - es->modelindex = 0; - es->loopSound = 0; - es->event = 0; - ent->r.contents = 0; + ps->eFlags = 0; + es->eFlags = 0; + es->eType = ET_GENERAL; + es->modelindex = 0; + es->loopSound = 0; + es->event = 0; + ent->r.contents = 0; } -void FindIntermissionPoint(void) { - gentity_t *ent, *target; - vec3_t dir; +void FindIntermissionPoint(void) +{ + gentity_t *ent, *target; + vec3_t dir; - // find the intermission spot - ent = G_Find(NULL, FOFS(classname), "info_player_intermission"); - if (ent == NULL) { // the map creator forgot to put in an intermission point... - G_Client_SelectSpawnPoint(vec3_origin, level.intermission_origin, level.intermission_angle); - } - else { - VectorCopy(ent->s.origin, level.intermission_origin); - VectorCopy(ent->s.angles, level.intermission_angle); - // if it has a target, look towards it - if (ent->target) { - target = G_PickTarget(ent->target); - if (target) { - VectorSubtract(target->s.origin, level.intermission_origin, dir); - vectoangles(dir, level.intermission_angle); - } - } - } + // find the intermission spot + ent = G_Find(NULL, FOFS(classname), "info_player_intermission"); + if(ent == NULL) + { // the map creator forgot to put in an intermission point... + G_Client_SelectSpawnPoint(vec3_origin, level.intermission_origin, level.intermission_angle); + } + else + { + VectorCopy(ent->s.origin, level.intermission_origin); + VectorCopy(ent->s.angles, level.intermission_angle); + // if it has a target, look towards it + if(ent->target) + { + target = G_PickTarget(ent->target); + if(target) + { + VectorSubtract(target->s.origin, level.intermission_origin, dir); + vectoangles(dir, level.intermission_angle); + } + } + } } @@ -2216,19 +2387,22 @@ void FindIntermissionPoint(void) { ClearFiringFlags ================== */ -static void ClearFiringFlags(void) { - int i = 0; - gentity_t *ent = NULL; +static void ClearFiringFlags(void) +{ + int i = 0; + gentity_t *ent = NULL; - for (i = 0; i < level.maxclients; i++) { - ent = g_entities + i; - if (!ent->inuse) - continue; - // clear the firing flag - if (ent->client) { - ent->client->ps.eFlags &= ~EF_FIRING; - } - } + for(i = 0; i < level.maxclients; i++) + { + ent = g_entities + i; + if(!ent->inuse) + continue; + // clear the firing flag + if(ent->client) + { + ent->client->ps.eFlags &= ~EF_FIRING; + } + } } /* @@ -2236,68 +2410,75 @@ static void ClearFiringFlags(void) { G_Client_BeginIntermission ================== */ -void G_Client_BeginIntermission(void) { - int i; - gentity_t *client; - qboolean doingLevelshot; +void G_Client_BeginIntermission(void) +{ + int i; + gentity_t *client; + qboolean doingLevelshot; - if (level.intermissiontime == -1) - doingLevelshot = qtrue; - else - doingLevelshot = qfalse; + if(level.intermissiontime == -1) + doingLevelshot = qtrue; + else + doingLevelshot = qfalse; - if (level.intermissiontime != 0 && level.intermissiontime != -1) { - return; // already active - } + if(level.intermissiontime != 0 && level.intermissiontime != -1) + { + return; // already active + } - // if in tournament mode, change the wins / losses - if (g_gametype.integer == GT_TOURNAMENT) { - AdjustTournamentScores(); - } + // if in tournament mode, change the wins / losses + if(g_gametype.integer == GT_TOURNAMENT) + { + AdjustTournamentScores(); + } - level.intermissiontime = level.time; - FindIntermissionPoint(); + level.intermissiontime = level.time; + FindIntermissionPoint(); - // kef -- make sure none of the players are still firing (cuz we don't want weapons fx going off while - //they're on the podium) - ClearFiringFlags(); + // kef -- make sure none of the players are still firing (cuz we don't want weapons fx going off while + //they're on the podium) + ClearFiringFlags(); - // cdr - Want to generate victory pads for all game types - except level shots (gametype 10) - UpdateTournamentInfo(); - if (!doingLevelshot) - SpawnModelsOnVictoryPads(); + // cdr - Want to generate victory pads for all game types - except level shots (gametype 10) + UpdateTournamentInfo(); + if(!doingLevelshot) + SpawnModelsOnVictoryPads(); - // move all clients to the intermission point - for (i = 0; i < level.maxclients; i++) { - client = g_entities + i; - if (!client->inuse) - continue; - if (client->health <= 0) { - G_Client_Respawn(client); - } - MoveClientToIntermission(client); + // move all clients to the intermission point + for(i = 0; i < level.maxclients; i++) + { + client = g_entities + i; + if(!client->inuse) + continue; + if(client->health <= 0) + { + G_Client_Respawn(client); + } + MoveClientToIntermission(client); - } + } - // send the current scoring to all clients - SendScoreboardMessageToAllClients(); + // send the current scoring to all clients + SendScoreboardMessageToAllClients(); } -static void G_ClearObjectives(void) { - gentity_t *tent; +static void G_ClearObjectives(void) +{ + gentity_t *tent; - tent = G_TempEntity(vec3_origin, EV_OBJECTIVE_COMPLETE); + tent = G_TempEntity(vec3_origin, EV_OBJECTIVE_COMPLETE); - if (tent == NULL) { - return; - } + if(tent == NULL) + { + return; + } - //Be sure to send the event to everyone - tent->r.svFlags |= SVF_BROADCAST; - tent->s.eventParm = 0;//tells it to clear all + //Be sure to send the event to everyone + tent->r.svFlags |= SVF_BROADCAST; + tent->s.eventParm = 0;//tells it to clear all } /* ============= @@ -2309,40 +2490,45 @@ or moved to a new level based on the "nextmap" cvar ============= */ qboolean levelExiting = qfalse; -void ExitLevel(void) { - int i; +void ExitLevel(void) +{ + int i; - levelExiting = qtrue; + levelExiting = qtrue; - //bot interbreeding - AI_main_BotInterbreedEndMatch(); + //bot interbreeding + AI_main_BotInterbreedEndMatch(); - G_ClearObjectives(); - // if we are running a tournement map, kick the loser to spectator status, - // which will automatically grab the next spectator and restart - if (g_gametype.integer == GT_TOURNAMENT) { - if (!level.restarted) { - RemoveTournamentLoser(); - trap_SendConsoleCommand(EXEC_APPEND, "map_restart 0\n"); - level.restarted = qtrue; - level.intermissiontime = 0; - } - return; - } + G_ClearObjectives(); + // if we are running a tournement map, kick the loser to spectator status, + // which will automatically grab the next spectator and restart + if(g_gametype.integer == GT_TOURNAMENT) + { + if(!level.restarted) + { + RemoveTournamentLoser(); + trap_SendConsoleCommand(EXEC_APPEND, "map_restart 0\n"); + level.restarted = qtrue; + level.intermissiontime = 0; + } + return; + } - trap_SendConsoleCommand(EXEC_APPEND, "vstr nextmap\n"); - level.intermissiontime = 0; + trap_SendConsoleCommand(EXEC_APPEND, "vstr nextmap\n"); + level.intermissiontime = 0; - // we need to do this here before chaning to CON_CONNECTING - G_WriteSessionData(); + // we need to do this here before chaning to CON_CONNECTING + G_WriteSessionData(); - // change all client states to connecting, so the early players into the - // next level will know the others aren't done reconnecting - for (i = 0; i < g_maxclients.integer; i++) { - if (level.clients[i].pers.connected == CON_CONNECTED) { - level.clients[i].pers.connected = CON_CONNECTING; - } - } + // change all client states to connecting, so the early players into the + // next level will know the others aren't done reconnecting + for(i = 0; i < g_maxclients.integer; i++) + { + if(level.clients[i].pers.connected == CON_CONNECTED) + { + level.clients[i].pers.connected = CON_CONNECTING; + } + } } @@ -2362,21 +2548,27 @@ CheckTournement Once a frame, check for changes in tournement player state ============= */ -static void CheckTournement(void) { - if (level.numPlayingClients == 0) { - return; - } +static void CheckTournement(void) +{ + if(level.numPlayingClients == 0) + { + return; + } - if (g_gametype.integer == GT_TOURNAMENT) { - if (level.warmupTime == 0 || level.warmupTime != 0) {//RPG-X: RedTechie - No warmup Fail safe - return; - } - } - else if (g_gametype.integer != GT_SINGLE_PLAYER) { - if (level.warmupTime == 0) { - return; - } - } + if(g_gametype.integer == GT_TOURNAMENT) + { + if(level.warmupTime == 0 || level.warmupTime != 0) + {//RPG-X: RedTechie - No warmup Fail safe + return; + } + } + else if(g_gametype.integer != GT_SINGLE_PLAYER) + { + if(level.warmupTime == 0) + { + return; + } + } } @@ -2385,32 +2577,39 @@ static void CheckTournement(void) { CheckVote ================== */ -static void CheckVote(void) { - if (level.voteTime == 0) { - return; - } - if (level.time - level.voteTime >= VOTE_TIME) { - trap_SendServerCommand(-1, "print \"Vote failed.\n\""); - } - else { - if (level.voteYes > level.numVotingClients / 2) { - // execute the command, then remove the vote - char message[1024] = ""; - trap_SendServerCommand(-1, "print \"Vote passed.\n\""); - Com_sprintf(message, 1024, "%s\n", level.voteString); - trap_SendConsoleCommand(EXEC_APPEND, message); - } - else if (level.voteNo >= level.numVotingClients / 2) { - // same behavior as a timeout - trap_SendServerCommand(-1, "print \"Vote failed.\n\""); - } - else { - // still waiting for a majority - return; - } - } - level.voteTime = 0; - trap_SetConfigstring(CS_VOTE_TIME, ""); +static void CheckVote(void) +{ + if(level.voteTime == 0) + { + return; + } + if(level.time - level.voteTime >= VOTE_TIME) + { + trap_SendServerCommand(-1, "print \"Vote failed.\n\""); + } + else + { + if(level.voteYes > level.numVotingClients / 2) + { + // execute the command, then remove the vote + char message[1024] = ""; + trap_SendServerCommand(-1, "print \"Vote passed.\n\""); + Com_sprintf(message, 1024, "%s\n", level.voteString); + trap_SendConsoleCommand(EXEC_APPEND, message); + } + else if(level.voteNo >= level.numVotingClients / 2) + { + // same behavior as a timeout + trap_SendServerCommand(-1, "print \"Vote failed.\n\""); + } + else + { + // still waiting for a majority + return; + } + } + level.voteTime = 0; + trap_SetConfigstring(CS_VOTE_TIME, ""); } @@ -2420,18 +2619,22 @@ static void CheckVote(void) { CheckCvars ================== */ -static void CheckCvars(void) { - static int lastMod = -1; +static void CheckCvars(void) +{ + static int lastMod = -1; - if (g_password.modificationCount != lastMod) { - lastMod = g_password.modificationCount; - if (g_password.string[0] != 0 && Q_stricmp(g_password.string, "none") != 0) { - trap_Cvar_Set("g_needpass", "1"); - } - else { - trap_Cvar_Set("g_needpass", "0"); - } - } + if(g_password.modificationCount != lastMod) + { + lastMod = g_password.modificationCount; + if(g_password.string[0] != 0 && Q_stricmp(g_password.string, "none") != 0) + { + trap_Cvar_Set("g_needpass", "1"); + } + else + { + trap_Cvar_Set("g_needpass", "0"); + } + } } /* @@ -2441,34 +2644,40 @@ G_RunThink Runs thinking code for this frame if necessary ============= */ -void G_RunThink(gentity_t *ent) { - int thinktime; +void G_RunThink(gentity_t *ent) +{ + int thinktime; - if (ent == NULL) { - return; - } + if(ent == NULL) + { + return; + } - thinktime = ent->nextthink; - if (thinktime <= 0) { - return; - } - if (thinktime > level.time) { - return; - } + thinktime = ent->nextthink; + if(thinktime <= 0) + { + return; + } + if(thinktime > level.time) + { + return; + } - ent->nextthink = 0; - if (ent->think == NULL) { - G_Error("NULL ent->think"); - return; - } + ent->nextthink = 0; + if(ent->think == NULL) + { + G_Error("NULL ent->think"); + return; + } #ifdef G_LUA - if (ent->luaThink != NULL && ent->client == NULL) { - LuaHook_G_EntityThink(ent->luaThink, ent->s.number); - } + if(ent->luaThink != NULL && ent->client == NULL) + { + LuaHook_G_EntityThink(ent->luaThink, ent->s.number); + } #endif - ent->think(ent); + ent->think(ent); } /* @@ -2480,147 +2689,171 @@ Advances the non-player objects in the world */ void CheckHealthInfoMessage(void); -void G_RunFrame(int32_t levelTime) { - int32_t i; - gentity_t* ent; - gclient_t* client; - playerState_t* ps; - entityState_t* es; +void G_RunFrame(int32_t levelTime) +{ + int32_t i; + gentity_t* ent; + gclient_t* client; + playerState_t* ps; + entityState_t* es; - // if we are waiting for the level to restart, do nothing - if (level.restarted) { - return; - } + // if we are waiting for the level to restart, do nothing + if(level.restarted) + { + return; + } - level.framenum++; - level.previousTime = level.time; - level.time = levelTime; + level.framenum++; + level.previousTime = level.time; + level.time = levelTime; - // get any cvar changes - G_UpdateCvars(); + // get any cvar changes + G_UpdateCvars(); - // - // go through all allocated objects - // - ent = &g_entities[0]; - for (i = 0; iinuse == qfalse) { - continue; - } + // + // go through all allocated objects + // + ent = &g_entities[0]; + for(i = 0; i < level.num_entities; i++, ent++) + { + if(ent == NULL || ent->inuse == qfalse) + { + continue; + } - es = &ent->s; - ps = &ent->client->ps; + es = &ent->s; + ps = &ent->client->ps; - // clear events that are too old - if (level.time - ent->eventTime > EVENT_VALID_MSEC) { - if (es->event != 0) { - es->event = 0; - if (ent->client) { - ps->externalEvent = 0; - ps->events[0] = 0; - ps->events[1] = 0; - ps->events[2] = 0; - ps->events[3] = 0; - } - } - if (ent->freeAfterEvent) { - // tempEntities or dropped items completely go away after their event - G_FreeEntity(ent); - continue; - } - else if (ent->unlinkAfterEvent) { - // items that will respawn will hide themselves after their pickup event - ent->unlinkAfterEvent = qfalse; - trap_UnlinkEntity(ent); - } - } + // clear events that are too old + if(level.time - ent->eventTime > EVENT_VALID_MSEC) + { + if(es->event != 0) + { + es->event = 0; + if(ent->client) + { + ps->externalEvent = 0; + ps->events[0] = 0; + ps->events[1] = 0; + ps->events[2] = 0; + ps->events[3] = 0; + } + } + if(ent->freeAfterEvent) + { + // tempEntities or dropped items completely go away after their event + G_FreeEntity(ent); + continue; + } + else if(ent->unlinkAfterEvent) + { + // items that will respawn will hide themselves after their pickup event + ent->unlinkAfterEvent = qfalse; + trap_UnlinkEntity(ent); + } + } - // temporary entities don't think - if (ent->freeAfterEvent) { - continue; - } + // temporary entities don't think + if(ent->freeAfterEvent) + { + continue; + } - if (!ent->r.linked && ent->neverFree) { - continue; - } + if(!ent->r.linked && ent->neverFree) + { + continue; + } - if (!ent->client) { - if ((es->eFlags & EF_ANIM_ONCE) == EF_ANIM_ONCE) {//this must be capped render-side - es->frame++; - } - } + if(!ent->client) + { + if((es->eFlags & EF_ANIM_ONCE) == EF_ANIM_ONCE) + {//this must be capped render-side + es->frame++; + } + } - if ((es->eType == ET_MISSILE) || (es->eType == ET_ALT_MISSILE)) { - G_Missile_Run(ent); - continue; - } + if((es->eType == ET_MISSILE) || (es->eType == ET_ALT_MISSILE)) + { + G_Missile_Run(ent); + continue; + } - if (es->eType == ET_ITEM || ent->physicsObject) { - G_RunItem(ent); - continue; - } + if(es->eType == ET_ITEM || ent->physicsObject) + { + G_RunItem(ent); + continue; + } - if (es->eType == ET_MOVER || es->eType == ET_MOVER_STR) { //RPG-X | GSIO01 | 13/05/2009 - G_Mover_Run(ent); - continue; - } + if(es->eType == ET_MOVER || es->eType == ET_MOVER_STR) + { //RPG-X | GSIO01 | 13/05/2009 + G_Mover_Run(ent); + continue; + } - if (i < MAX_CLIENTS) { - G_RunClient(ent); - continue; - } + if(i < MAX_CLIENTS) + { + G_RunClient(ent); + continue; + } - G_RunThink(ent); - } + G_RunThink(ent); + } - // perform final fixups on the players - ent = &g_entities[0]; - for (i = 0; i < level.maxclients; i++, ent++) { - if (ent->inuse) { - ClientEndFrame(ent); - } - } + // perform final fixups on the players + ent = &g_entities[0]; + for(i = 0; i < level.maxclients; i++, ent++) + { + if(ent->inuse) + { + ClientEndFrame(ent); + } + } - // see if it is time to do a tournement restart - CheckTournement(); + // see if it is time to do a tournement restart + CheckTournement(); - // update to client status? - G_Client_CheckClientStatus(); + // update to client status? + G_Client_CheckClientStatus(); - // cancel vote if timed out - CheckVote(); + // cancel vote if timed out + CheckVote(); - // for tracking changes - CheckCvars(); + // for tracking changes + CheckCvars(); - //RPG-X: J2J - This will check for drag movements that need to be calculated. - DragCheck(); + //RPG-X: J2J - This will check for drag movements that need to be calculated. + DragCheck(); - for (i = 0; i < MAX_CLIENTS; i++) { - ent = &g_entities[i]; + for(i = 0; i < MAX_CLIENTS; i++) + { + ent = &g_entities[i]; - if (!ent || !ent->client) - continue; + if(!ent || !ent->client) + continue; - client = ent->client; + client = ent->client; - if ((client->pers.cmd.buttons & BUTTON_USE) == 0) { - client->pressedUse = qfalse; - } + if((client->pers.cmd.buttons & BUTTON_USE) == 0) + { + client->pressedUse = qfalse; + } - if (g_classData[client->sess.sessionClass].isn00b != 0) { - if ((client->n00bTime != -1) && (client->n00bTime <= level.time) && client->origClass[0] != 0) { - if (SetClass(ent, client->origClass, NULL, qtrue) == qfalse) { - DEVELOPER(G_Printf(S_COLOR_YELLOW "G_RunFrame - Warning: SetClass failed!\n");); - } - } - } - } + if(g_classData[client->sess.sessionClass].isn00b != 0) + { + if((client->n00bTime != -1) && (client->n00bTime <= level.time) && client->origClass[0] != 0) + { + if(SetClass(ent, client->origClass, NULL, qtrue) == qfalse) + { + DEVELOPER(G_Printf(S_COLOR_YELLOW "G_RunFrame - Warning: SetClass failed!\n");); + } + } + } + } - //RPG-X: Marcin: To clear pressedUse. - 30/12/2008 + //RPG-X: Marcin: To clear pressedUse. - 30/12/2008 #ifdef G_LUA - LuaHook_G_RunFrame(levelTime); + LuaHook_G_RunFrame(levelTime); #endif }