From: Mario Date: Wed, 23 Sep 2020 08:15:18 +0000 (+1000) Subject: Replace some of the remaining cvar globals with autocvars, allows changing a few... X-Git-Tag: xonotic-v0.8.5~755 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d9d13627b0c82a96dab08c2f3cd2d966d5425ea8;p=xonotic%2Fxonotic-data.pk3dir.git Replace some of the remaining cvar globals with autocvars, allows changing a few more settings without restarting the match, also move a few function definitions out of miscfunctions --- diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index afc366ba0..8e671b17d 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -380,12 +380,12 @@ { if (voicetype == VOICETYPE_AUTOTAUNT) { - if (!sv_autotaunt) break; + if (!autocvar_sv_autotaunt) break; } else if (IS_PLAYER(this) && !IS_DEAD(this)) animdecide_setaction(this, ANIMACTION_TAUNT, true); - if (!sv_taunt) break; + if (!autocvar_sv_taunt) break; if (autocvar_sv_gentle) break; float tauntrand = 0; if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random(); diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index bd539aa8e..64c67bd54 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1208,7 +1208,7 @@ void nades_CheckThrow(entity this) _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05); - dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style); + dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style); toss_nade(this, true, dir * _force, 0); } } @@ -1252,7 +1252,7 @@ CLASS(NadeOffhand, OffhandWeapon) _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1); - dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style); + dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style); toss_nade(player, false, dir * _force, 0); } } diff --git a/qcsrc/common/mutators/mutator/overkill/okhmg.qc b/qcsrc/common/mutators/mutator/overkill/okhmg.qc index 31db0c4db..210b77ec4 100644 --- a/qcsrc/common/mutators/mutator/overkill/okhmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/okhmg.qc @@ -73,7 +73,7 @@ METHOD(OverkillHeavyMachineGun, wr_think, void(entity thiswep, entity actor, .en FOREACH_CLIENT(true, LAMBDA( if (it == actor || (IS_SPEC(it) && it.enemy == actor)) { - wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, g_weaponratefactor, true); + wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true); } )); animdecide_setaction(actor, ANIMACTION_SHOOT, true); diff --git a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc index 9ce9a2901..597d17e2e 100644 --- a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc @@ -67,7 +67,7 @@ METHOD(OverkillMachineGun, wr_think, void(entity thiswep, entity actor, .entity FOREACH_CLIENT(true, LAMBDA( if (it == actor || (IS_SPEC(it) && it.enemy == actor)) { - wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, g_weaponratefactor, true); + wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true); } )); animdecide_setaction(actor, ANIMACTION_SHOOT, true); diff --git a/qcsrc/common/mutators/mutator/overkill/oknex.qc b/qcsrc/common/mutators/mutator/overkill/oknex.qc index 55afbe45c..3ece45bde 100644 --- a/qcsrc/common/mutators/mutator/overkill/oknex.qc +++ b/qcsrc/common/mutators/mutator/overkill/oknex.qc @@ -154,7 +154,7 @@ METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weapone FOREACH_CLIENT(true, LAMBDA( if (it == actor || (IS_SPEC(it) && it.enemy == actor)) { - wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, g_weaponratefactor, true); + wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true); } )); animdecide_setaction(actor, ANIMACTION_SHOOT, true); diff --git a/qcsrc/common/mutators/mutator/overkill/okrpc.qc b/qcsrc/common/mutators/mutator/overkill/okrpc.qc index 25704934f..ea700a9ca 100644 --- a/qcsrc/common/mutators/mutator/overkill/okrpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/okrpc.qc @@ -148,7 +148,7 @@ METHOD(OverkillRocketPropelledChainsaw, wr_think, void(entity thiswep, entity ac FOREACH_CLIENT(true, LAMBDA( if (it == actor || (IS_SPEC(it) && it.enemy == actor)) { - wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, g_weaponratefactor, true); + wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true); } )); animdecide_setaction(actor, ANIMACTION_SHOOT, true); diff --git a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc index da4c4749d..627c14f20 100644 --- a/qcsrc/common/mutators/mutator/overkill/okshotgun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okshotgun.qc @@ -28,7 +28,7 @@ METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity wea FOREACH_CLIENT(true, LAMBDA( if (it == actor || (IS_SPEC(it) && it.enemy == actor)) { - wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, g_weaponratefactor, true); + wframe_send(it, actor.(weaponentity), WFRAME_FIRE2, autocvar_g_weaponratefactor, true); } )); animdecide_setaction(actor, ANIMACTION_SHOOT, true); diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 7e63442ca..5e9460c83 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -650,7 +650,7 @@ void PM_check_hitground(entity this) void PM_Footsteps(entity this) { #ifdef SVQC - if (!g_footsteps) return; + if (!autocvar_g_footsteps) return; if (IS_DUCKED(this)) return; if (time >= this.lastground + 0.2) return; if (vdist(this.velocity, <=, autocvar_sv_maxspeed * 0.6)) return; diff --git a/qcsrc/common/sounds/all.qh b/qcsrc/common/sounds/all.qh index 6d011e21a..2a0d7ac4f 100644 --- a/qcsrc/common/sounds/all.qh +++ b/qcsrc/common/sounds/all.qh @@ -2,6 +2,28 @@ #include "sound.qh" +#ifdef SVQC +void soundat(entity e, vector o, float chan, string samp, float vol, float _atten); + +void stopsoundto(float _dest, entity e, float chan); + +void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten, float _pitch); + +bool sound_allowed(int dest, entity e); + +float spamsound(entity e, float chan, Sound samp, float vol, float _atten); + +void play2(entity e, string filename); + +void play2all(string samp); + +void play2team(float t, string filename); + +void soundto(float dest, entity e, float chan, string samp, float vol, float atten, float _pitch); + +void stopsound(entity e, float chan); +#endif + REGISTRY(Sounds, BITS(9)) REGISTER_REGISTRY(Sounds) diff --git a/qcsrc/common/weapons/calculations.qc b/qcsrc/common/weapons/calculations.qc index 3323d8e36..cd2d925bc 100644 --- a/qcsrc/common/weapons/calculations.qc +++ b/qcsrc/common/weapons/calculations.qc @@ -189,7 +189,7 @@ vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float float sigma; vector v1 = '0 0 0', v2; float dx, dy, r; - spread *= spreadfactor; //g_weaponspreadfactor; + spread *= spreadfactor; //autocvar_g_weaponspreadfactor; if(spread <= 0) return forward; diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 51d175750..5458a2496 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -357,7 +357,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity) s.y = v_forward.x; s.z = v_forward.y; } - s = s * WEP_CVAR_PRI(crylink, spread) * g_weaponspreadfactor; + s = s * WEP_CVAR_PRI(crylink, spread) * autocvar_g_weaponspreadfactor; W_SetupProjVelocity_Explicit(proj, w_shotdir + right * s.y + up * s.z, v_up, WEP_CVAR_PRI(crylink, speed), 0, 0, 0, false); settouch(proj, W_Crylink_Touch); @@ -471,12 +471,12 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) s.y = v_forward.x; s.z = v_forward.y; } - s = s * WEP_CVAR_SEC(crylink, spread) * g_weaponspreadfactor; + s = s * WEP_CVAR_SEC(crylink, spread) * autocvar_g_weaponspreadfactor; s = w_shotdir + right * s.y + up * s.z; } else { - s = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * WEP_CVAR_SEC(crylink, spread) * g_weaponspreadfactor); + s = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * WEP_CVAR_SEC(crylink, spread) * autocvar_g_weaponspreadfactor); } W_SetupProjVelocity_Explicit(proj, s, v_up, WEP_CVAR_SEC(crylink, speed), 0, 0, 0, false); diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 73cb2b8b9..bfda2124d 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -221,7 +221,7 @@ void W_Hagar_Attack2_Load_Release(Weapon thiswep, entity actor, .entity weaponen // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar) spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1)); spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias))); - spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor); + spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * autocvar_g_weaponspreadfactor); // pattern spread calculation s = '0 0 0'; @@ -233,7 +233,7 @@ void W_Hagar_Attack2_Load_Release(Weapon thiswep, entity actor, .entity weaponen s.y = v_forward.x; s.z = v_forward.y; } - s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor; + s = s * WEP_CVAR_SEC(hagar, load_spread) * autocvar_g_weaponspreadfactor; W_SetupProjVelocity_Explicit(missile, w_shotdir + right * s.y + up * s.z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, false); diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index 175c57c48..313040126 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -22,7 +22,7 @@ void sys_phys_monitor(entity this, float dt) { int buttons = PHYS_INPUT_BUTTON_MASK(this); anticheat_physics(this); - if (sv_maxidle > 0) { + if (autocvar_sv_maxidle > 0) { if (buttons != CS(this).buttons_old || CS(this).movement != CS(this).movement_old || this.v_angle != CS(this).v_angle_old) { CS(this).parm_idlesince = time; } diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 99077dcfe..83ea702ae 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -534,3 +534,22 @@ bool autocvar_g_weaponswitch_debug; bool autocvar_g_weaponswitch_debug_alternate; bool autocvar_g_allow_checkpoints; bool autocvar_sv_q3defragcompat_changehitbox = false; +int autocvar_sv_clones; +bool autocvar_g_footsteps; +float autocvar_sv_maxidle; +bool autocvar_sv_maxidle_spectatorsareidle; +int autocvar_sv_maxidle_slots; +bool autocvar_sv_maxidle_slots_countbots; +bool autocvar_sv_autotaunt; +bool autocvar_g_warmup_allguns; +bool autocvar_g_warmup_allow_timeout; +float autocvar_g_weaponspreadfactor; +float autocvar_g_weaponforcefactor; +float autocvar_g_weapondamagefactor; +float autocvar_g_weaponratefactor; +float autocvar_g_weaponspeedfactor; +float autocvar_sv_foginterval; +bool autocvar_sv_ready_restart_repeatable; +bool autocvar_g_jetpack; +bool autocvar_sv_taunt; +bool autocvar_sv_ready_restart; diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index cf7cd99c2..ff361388b 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1462,8 +1462,7 @@ bool navigation_routetogoal(entity this, entity e, vector startposition) this.wp_goal_prev0 = e; } - if(g_jetpack) - if(e==this.navigation_jetpack_goal) + if((this.items & IT_JETPACK) && e == this.navigation_jetpack_goal) return true; // if it can reach the goal there is nothing more to do diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9d5cc1d42..eb0b95e07 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -72,7 +72,7 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets return 0; if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse) - if(this.lip < sv_clones) + if(this.lip < autocvar_sv_clones) return 1; // haha diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 5aca281ae..3afbf4ded 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -862,7 +862,7 @@ void ClientInit_misc(entity this) WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[2])); WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[3])); - if(sv_foginterval && world.fog != "") + if(autocvar_sv_foginterval && world.fog != "") WriteString(channel, world.fog); else WriteString(channel, ""); @@ -935,7 +935,7 @@ void DecodeLevelParms(entity this) CS(this).parm_idlesince = time; // whatever happens, allow 60 seconds of idling directly after connect for map loading - CS(this).parm_idlesince = max(CS(this).parm_idlesince, time - sv_maxidle + 60); + CS(this).parm_idlesince = max(CS(this).parm_idlesince, time - autocvar_sv_maxidle + 60); MUTATOR_CALLHOOK(DecodeLevelParms); } @@ -1048,7 +1048,7 @@ string getwelcomemessage(entity this) modifications = strcat(modifications, ", Low gravity"); if(g_weapon_stay && !g_cts) modifications = strcat(modifications, ", Weapons stay"); - if(g_jetpack) + if(autocvar_g_jetpack) modifications = strcat(modifications, ", Jet pack"); if(autocvar_g_powerups == 0) modifications = strcat(modifications, ", No powerups"); @@ -1167,7 +1167,7 @@ void ClientConnect(entity this) stuffcmd(this, "cl_cmd settemp chase_active 1\n"); } - if (!sv_foginterval && world.fog != "") + if (!autocvar_sv_foginterval && world.fog != "") stuffcmd(this, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n")); if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AvailableTeams() == 2)) @@ -2754,21 +2754,21 @@ void PlayerPostThink (entity this) { Player_Physics(this); - if (sv_maxidle > 0) + if (autocvar_sv_maxidle > 0) if (frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero). if (IS_REAL_CLIENT(this)) - if (IS_PLAYER(this) || sv_maxidle_spectatorsareidle) + if (IS_PLAYER(this) || autocvar_sv_maxidle_spectatorsareidle) { int totalClients = 0; - if(sv_maxidle_slots > 0) + if(autocvar_sv_maxidle_slots > 0) { - FOREACH_CLIENT(IS_REAL_CLIENT(it) || sv_maxidle_slots_countbots, + FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_maxidle_slots_countbots, { ++totalClients; }); } - if (sv_maxidle_slots > 0 && (maxclients - totalClients) > sv_maxidle_slots) + if (autocvar_sv_maxidle_slots > 0 && (maxclients - totalClients) > autocvar_sv_maxidle_slots) { /* do nothing */ } else if (time - CS(this).parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10 { @@ -2780,8 +2780,8 @@ void PlayerPostThink (entity this) } else { - float timeleft = ceil(sv_maxidle - (time - CS(this).parm_idlesince)); - if (timeleft == min(10, sv_maxidle - 1)) { // - 1 to support sv_maxidle <= 10 + float timeleft = ceil(autocvar_sv_maxidle - (time - CS(this).parm_idlesince)); + if (timeleft == min(10, autocvar_sv_maxidle - 1)) { // - 1 to support sv_maxidle <= 10 if (!CS(this).idlekick_lasttimeleft) Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_DISCONNECT_IDLING, timeleft); } diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index e288bebfc..a4309822d 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -297,12 +297,6 @@ const int SVC_SETVIEW = 5; // TODO: move to dpdefs where this belongs! .float pauserotarmor_finished; .float pauserotfuel_finished; -// idle kicking -float sv_maxidle; -float sv_maxidle_spectatorsareidle; -int sv_maxidle_slots; -bool sv_maxidle_slots_countbots; - // g__str: // If 0, default is used. // If <0, 0 is used. diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index fe92d3667..67ac6d641 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -384,9 +384,9 @@ void ClientCommand_ready(entity caller, int request) // todo: anti-spam for tog { if (IS_CLIENT(caller)) { - if (warmup_stage || sv_ready_restart || g_race_qualifying == 2) + if (warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2) { - if (!readyrestart_happened || sv_ready_restart_repeatable) + if (!readyrestart_happened || autocvar_sv_ready_restart_repeatable) { if (time < game_starttime) // game is already restarting return; diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 0f59802dd..01fb5ad48 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -720,7 +720,7 @@ void CommonCommand_timeout(int request, entity caller) // DEAR GOD THIS COMMAND { print_to(caller, "^7Error: You can not call a timeout while a vote is active."); } - else if (warmup_stage && !g_warmup_allow_timeout) + else if (warmup_stage && !autocvar_g_warmup_allow_timeout) { print_to(caller, "^7Error: You can not call a timeout in warmup-stage."); } diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index f799e96f7..02a795bba 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -686,11 +686,11 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de if (!DEATH_ISSPECIAL(deathtype)) { - damage *= g_weapondamagefactor; - mirrordamage *= g_weapondamagefactor; - complainteamdamage *= g_weapondamagefactor; - force = force * g_weaponforcefactor; - mirrorforce *= g_weaponforcefactor; + damage *= autocvar_g_weapondamagefactor; + mirrordamage *= autocvar_g_weapondamagefactor; + complainteamdamage *= autocvar_g_weapondamagefactor; + force = force * autocvar_g_weaponforcefactor; + mirrorforce *= autocvar_g_weaponforcefactor; } // should this be changed at all? If so, in what way? diff --git a/qcsrc/server/items/items.qh b/qcsrc/server/items/items.qh index 8dbb47283..49fea39d0 100644 --- a/qcsrc/server/items/items.qh +++ b/qcsrc/server/items/items.qh @@ -112,3 +112,6 @@ float GiveItems(entity e, float beginarg, float endarg); IntrusiveList g_items; STATIC_INIT(g_items) { g_items = IL_NEW(); } + +#define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) +#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id)) diff --git a/qcsrc/server/main.qc b/qcsrc/server/main.qc index 359456b39..3db2a0f8e 100644 --- a/qcsrc/server/main.qc +++ b/qcsrc/server/main.qc @@ -178,6 +178,58 @@ void dedicated_print(string input) if (server_is_dedicated) print(input); } +void make_safe_for_remove(entity e) +{ + if (e.initialize_entity) + { + entity ent, prev = NULL; + for (ent = initialize_entity_first; ent; ) + { + if ((ent == e) || ((ent.classname == "initialize_entity") && (ent.enemy == e))) + { + //print("make_safe_for_remove: getting rid of initializer ", etos(ent), "\n"); + // skip it in linked list + if (prev) + { + prev.initialize_entity_next = ent.initialize_entity_next; + ent = prev.initialize_entity_next; + } + else + { + initialize_entity_first = ent.initialize_entity_next; + ent = initialize_entity_first; + } + } + else + { + prev = ent; + ent = ent.initialize_entity_next; + } + } + } +} + +.float remove_except_protected_forbidden; +void remove_except_protected(entity e) +{ + if(e.remove_except_protected_forbidden) + error("not allowed to remove this at this point"); + builtin_remove(e); +} + +void remove_unsafely(entity e) +{ + if(e.classname == "spike") + error("Removing spikes is forbidden (crylink bug), please report"); + builtin_remove(e); +} + +void remove_safely(entity e) +{ + make_safe_for_remove(e); + builtin_remove(e); +} + /* ============= StartFrame diff --git a/qcsrc/server/main.qh b/qcsrc/server/main.qh index e89d68304..515ec62e6 100644 --- a/qcsrc/server/main.qh +++ b/qcsrc/server/main.qh @@ -3,6 +3,10 @@ /** print(), but only print if the server is not local */ void dedicated_print(string input); +void remove_safely(entity e); + +void remove_unsafely(entity e); + bool expr_evaluate(string s); #ifdef PROFILING diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index cc5c2d139..df830d13e 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -714,7 +714,7 @@ void readplayerstartcvars() warmup_start_weapons_default = '0 0 0'; warmup_start_weapons_defaultmask = '0 0 0'; FOREACH(Weapons, it != WEP_Null, { - int w = want_weapon(it, g_warmup_allguns); + int w = want_weapon(it, autocvar_g_warmup_allguns); WepSet s = it.m_wepset; if(w & 1) warmup_start_weapons |= s; @@ -725,7 +725,7 @@ void readplayerstartcvars() }); } - if (g_jetpack) + if (autocvar_g_jetpack) start_items |= ITEM_Jetpack.m_itemid; MUTATOR_CALLHOOK(SetStartItems); @@ -837,59 +837,6 @@ PRECACHE(PlayerModels) } } - -void make_safe_for_remove(entity e) -{ - if (e.initialize_entity) - { - entity ent, prev = NULL; - for (ent = initialize_entity_first; ent; ) - { - if ((ent == e) || ((ent.classname == "initialize_entity") && (ent.enemy == e))) - { - //print("make_safe_for_remove: getting rid of initializer ", etos(ent), "\n"); - // skip it in linked list - if (prev) - { - prev.initialize_entity_next = ent.initialize_entity_next; - ent = prev.initialize_entity_next; - } - else - { - initialize_entity_first = ent.initialize_entity_next; - ent = initialize_entity_first; - } - } - else - { - prev = ent; - ent = ent.initialize_entity_next; - } - } - } -} - -.float remove_except_protected_forbidden; -void remove_except_protected(entity e) -{ - if(e.remove_except_protected_forbidden) - error("not allowed to remove this at this point"); - builtin_remove(e); -} - -void remove_unsafely(entity e) -{ - if(e.classname == "spike") - error("Removing spikes is forbidden (crylink bug), please report"); - builtin_remove(e); -} - -void remove_safely(entity e) -{ - make_safe_for_remove(e); - builtin_remove(e); -} - void InitializeEntity(entity e, void(entity this) func, int order) { entity prev, cur; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index f79c9e84a..82618160a 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -17,25 +17,14 @@ void write_recordmarker(entity pl, float tstart, float dt); -void play2all(string samp); - -void play2team(float t, string filename); - void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .float field, string name); -float spamsound(entity e, float chan, Sound samp, float vol, float _atten); - void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name); void precache_all_playermodels(string pattern); -void soundat(entity e, vector o, float chan, string samp, float vol, float _atten); - void InitializeEntitiesRun(); -void stopsoundto(float _dest, entity e, float chan); -void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten, float _pitch); - void droptofloor(entity this); float trace_hits_box_1d(float end, float thmi, float thma); @@ -60,8 +49,6 @@ string formatmessage(entity this, string msg); void GetCvars(entity this, entity store, int f); -string GetMapname(); - float LostMovetypeFollow(entity ent); string uid2name(string myuid); @@ -72,20 +59,10 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f string NearestLocation(vector p); -void play2(entity e, string filename); - string playername(entity p, bool team_colorize); -void remove_safely(entity e); - -void remove_unsafely(entity e); - void SetMovetypeFollow(entity ent, entity e); -void soundto(float dest, entity e, float chan, string samp, float vol, float atten, float _pitch); - -void stopsound(entity e, float chan); - float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma); void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag); @@ -94,41 +71,11 @@ void WarpZone_crosshair_trace(entity pl); void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag); -#define IS_DEAD(s) ((s).deadflag != DEAD_NO) - - -#define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) -#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id)) - #define PROJECTILE_TOUCH(e,t) MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END -#define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) - // copies a string to a tempstring (so one can strunzone it) string strcat1(string s) = #115; // FRIK_FILE -/* -// NOTE: DO NOT USE THIS FUNCTION TOO OFTEN. -// IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP -// STRINGS AND TAKE QUITE LONG. haystack and needle MUST -// BE CONSTANT OR strzoneD! -float strstrofs(string haystack, string needle, float offset) -{ - float len, endpos; - string found; - len = strlen(needle); - endpos = strlen(haystack) - len; - while(offset <= endpos) - { - found = substring(haystack, offset, len); - if(found == needle) - return offset; - offset = offset + 1; - } - return -1; -} -*/ - const float NUM_NEAREST_ENTITIES = 4; entity nearest_entity[NUM_NEAREST_ENTITIES]; float nearest_length[NUM_NEAREST_ENTITIES]; @@ -147,11 +94,6 @@ float g_weaponarena; WepSet g_weaponarena_weapons; float g_weaponarena_random; // TODO string g_weaponarena_list; -float g_weaponspeedfactor; -float g_weaponratefactor; -float g_weapondamagefactor; -float g_weaponforcefactor; -float g_weaponspreadfactor; WepSet start_weapons; WepSet start_weapons_default; @@ -175,7 +117,7 @@ float start_armorvalue; WepSet warmup_start_weapons; WepSet warmup_start_weapons_default; WepSet warmup_start_weapons_defaultmask; -#define WARMUP_START_WEAPONS ((g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons) +#define WARMUP_START_WEAPONS ((autocvar_g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons) float warmup_start_ammo_shells; float warmup_start_ammo_nails; float warmup_start_ammo_rockets; @@ -189,45 +131,20 @@ float g_weapon_stay; float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done? void readplayerstartcvars(); -float sv_autotaunt; -float sv_taunt; - -float g_footsteps, g_grappling_hook; -float g_warmup_allguns; -float g_warmup_allow_timeout; +float g_grappling_hook; float warmup_stage; -float g_jetpack; -bool sv_ready_restart; bool sv_ready_restart_after_countdown; -bool sv_ready_restart_repeatable; - -float sv_clones; -float sv_foginterval; void readlevelcvars() { if(cvar("sv_allow_fullbright")) serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT; - sv_clones = cvar("sv_clones"); - sv_foginterval = cvar("sv_foginterval"); - g_footsteps = cvar("g_footsteps"); - g_jetpack = cvar("g_jetpack"); - sv_maxidle = cvar("sv_maxidle"); - sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle"); - sv_maxidle_slots = cvar("sv_maxidle_slots"); - sv_maxidle_slots_countbots = cvar("sv_maxidle_slots_countbots"); - sv_autotaunt = cvar("sv_autotaunt"); - sv_taunt = cvar("sv_taunt"); - sv_ready_restart = cvar("sv_ready_restart"); sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown"); - sv_ready_restart_repeatable = cvar("sv_ready_restart_repeatable"); warmup_stage = cvar("g_warmup"); warmup_limit = cvar("g_warmup_limit"); - g_warmup_allguns = cvar("g_warmup_allguns"); - g_warmup_allow_timeout = cvar("g_warmup_allow_timeout"); if(cvar("g_campaign")) warmup_stage = 0; // no warmup during campaign @@ -247,12 +164,6 @@ void readlevelcvars() g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long"); g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup"); - g_weaponspeedfactor = cvar("g_weaponspeedfactor"); - g_weaponratefactor = cvar("g_weaponratefactor"); - g_weapondamagefactor = cvar("g_weapondamagefactor"); - g_weaponforcefactor = cvar("g_weaponforcefactor"); - g_weaponspreadfactor = cvar("g_weaponspreadfactor"); - g_pickup_shells = cvar("g_pickup_shells"); g_pickup_shells_max = cvar("g_pickup_shells_max"); g_pickup_nails = cvar("g_pickup_nails"); @@ -324,11 +235,6 @@ const int INITPRIO_LAST = 99; .entity initialize_entity_next; entity initialize_entity_first; - - - - -bool sound_allowed(int dest, entity e); void InitializeEntity(entity e, void(entity this) func, int order); IntrusiveList g_ctrace_changed; diff --git a/qcsrc/server/utils.qh b/qcsrc/server/utils.qh index a37029590..ae0c284fe 100644 --- a/qcsrc/server/utils.qh +++ b/qcsrc/server/utils.qh @@ -23,6 +23,9 @@ const string STR_OBSERVER = "observer"; #define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET) #define IS_MOVABLE(v) ((IS_PLAYER(v) || IS_MONSTER(v)) && !STAT(FROZEN, v)) +#define IS_DEAD(s) ((s).deadflag != DEAD_NO) + +#define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5))) // NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; }); // NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; }); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index f4de0e1bf..3e8382652 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -196,7 +196,7 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p mspercallsum -= gettime(GETTIME_HIRES); #endif - dir = W_CalculateSpread(dir, spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style); + dir = W_CalculateSpread(dir, spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style); #if 0 mspercallsum += gettime(GETTIME_HIRES); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 763881388..487154fe3 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -31,8 +31,8 @@ float W_WeaponRateFactor(entity this) { float t = 1; - if(g_weaponratefactor > 0) - t = 1.0 / g_weaponratefactor; + if(autocvar_g_weaponratefactor > 0) + t = 1.0 / autocvar_g_weaponratefactor; MUTATOR_CALLHOOK(WeaponRateFactor, t, this); t = M_ARGV(0, float); @@ -42,7 +42,7 @@ float W_WeaponRateFactor(entity this) float W_WeaponSpeedFactor(entity this) { - float t = 1.0 * g_weaponspeedfactor; + float t = 1.0 * autocvar_g_weaponspeedfactor; MUTATOR_CALLHOOK(WeaponSpeedFactor, t, this); t = M_ARGV(0, float); @@ -409,7 +409,7 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( { FOREACH_CLIENT(true, { if(it == actor || (IS_SPEC(it) && it.enemy == actor)) - wframe_send(it, this, fr, g_weaponratefactor, restartanim); + wframe_send(it, this, fr, autocvar_g_weaponratefactor, restartanim); }); } diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 3bbaad682..f49346a1c 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -60,6 +60,7 @@ void Map_MarkAsRecent(string m); float DoNextMapOverride(float reinit); void CheckRules_World(); float RedirectionThink(); +string GetMapname(); IntrusiveList g_moveables; STATIC_INIT(g_moveables) { g_moveables = IL_NEW(); }