From 001abccbb0f5ec3197dd59e962298e1010161dc6 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 11 Dec 2015 20:48:43 +1100 Subject: [PATCH] Overkill: suppress armour drop warnings --- qcsrc/client/main.qc | 1 + qcsrc/client/miscfunctions.qc | 1 + .../mutators/mutator/overkill/overkill.qc | 36 ++-- qcsrc/lib/log.qh | 14 +- qcsrc/lib/spawnfunc.qh | 12 +- qcsrc/server/autocvars.qh | 1 - qcsrc/server/scores.qc | 4 +- qcsrc/server/sv_main.qc | 1 + qcsrc/server/t_items.qc | 162 +++++++++--------- 9 files changed, 126 insertions(+), 106 deletions(-) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 94225889d..c6529a070 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -167,6 +167,7 @@ void Shutdown() .float has_team; float SetTeam(entity o, int Team) { + assert(Team); entity tm; if(teamplay) { diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 673cf00f1..d488dd63b 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -79,6 +79,7 @@ void MoveToLast(entity e) float RegisterTeam(entity Team) { + assert(Team.team, eprint(Team)); entity tm; AuditLists(); for(tm = teams.sort_next; tm; tm = tm.sort_next) diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index a4d421390..4ad190d25 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -123,30 +123,30 @@ MUTATOR_HOOKFUNCTION(ok, PlayerDamage_SplitHealthArmor) } MUTATOR_HOOKFUNCTION(ok, PlayerDies) -{SELFPARAM(); +{ + SELFPARAM(); entity targ = ((frag_attacker) ? frag_attacker : frag_target); - if(IS_MONSTER(self)) + if(IS_MONSTER(this)) { remove(other); // remove default item - other = world; + other = NULL; } - setself(new(droppedweapon)); // hax - self.ok_item = true; - self.noalign = true; - self.pickup_anyway = true; - this.spawnfunc_checked = true; - spawnfunc_item_armor_small(this); - self.movetype = MOVETYPE_TOSS; - self.gravity = 1; - self.reset = SUB_Remove; - setorigin(self, frag_target.origin + '0 0 32'); - self.velocity = '0 0 200' + normalize(targ.origin - self.origin) * 500; - SUB_SetFade(self, time + 5, 1); - setself(this); - - self.ok_lastwep = self.switchweapon; + entity e = new(droppedweapon); // hax + e.ok_item = true; + e.noalign = true; + e.pickup_anyway = true; + e.spawnfunc_checked = true; + spawnfunc_item_armor_small(e); + e.movetype = MOVETYPE_TOSS; + e.gravity = 1; + e.reset = SUB_Remove; + setorigin(e, frag_target.origin + '0 0 32'); + e.velocity = '0 0 200' + normalize(targ.origin - self.origin) * 500; + SUB_SetFade(e, time + 5, 1); + + this.ok_lastwep = this.switchweapon; return false; } diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index 3ac8ed238..8a5207339 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -73,18 +73,24 @@ noref int autocvar_developer; noref bool autocvar_prvm_backtraceforwarnings; +#ifdef SVQC +#define bt_cvar_set(cvar, value) builtin_cvar_set(cvar, value) +#else +#define bt_cvar_set(cvar, value) cvar_set(cvar, value) +#endif + #define backtrace(msg) \ MACRO_BEGIN \ { \ int dev = autocvar_developer; \ bool war = autocvar_prvm_backtraceforwarnings; \ - cvar_set("developer", "1"); \ - cvar_set("prvm_backtraceforwarnings", "1"); \ + bt_cvar_set("developer", "1"); \ + bt_cvar_set("prvm_backtraceforwarnings", "1"); \ print("\n--- CUT HERE ---\n", msg, "\n"); \ _backtrace(); \ print("\n--- CUT UNTIL HERE ---\n"); \ - cvar_set("developer", ftos(dev)); \ - cvar_set("prvm_backtraceforwarnings", ftos(war)); \ + bt_cvar_set("developer", ftos(dev)); \ + bt_cvar_set("prvm_backtraceforwarnings", ftos(war)); \ } MACRO_END #endif diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index 75f56a23d..3f9ca0e94 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -28,6 +28,7 @@ noref bool require_spawnfunc_prefix; #define _spawnfunc_check(fld) \ if (fieldname == #fld) continue; + noref entity __spawnfunc_expect; bool __spawnfunc_unreachable_workaround = true; #define spawnfunc_1(id) spawnfunc_2(id, FIELDS_UNION) @@ -35,7 +36,16 @@ noref bool require_spawnfunc_prefix; void __spawnfunc_##id(entity this); \ [[accumulate]] void spawnfunc_##id(entity this) \ { \ - this = self; \ + if (self == __spawnfunc_expect) \ + { \ + /* engine call */ \ + __spawnfunc_expect = NULL; \ + this = self; \ + } \ + else \ + { \ + assert(this); \ + } \ if (!this.sourceLocFile) \ { \ this.sourceLocFile = __FILE__; \ diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index e4220f5d0..9b281a1f7 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -64,7 +64,6 @@ bool autocvar_bot_debug_goalstack; bool autocvar_bot_wander_enable; int autocvar_captureleadlimit_override; #define autocvar_capturelimit_override cvar("capturelimit_override") -#define autocvar_developer cvar("developer") float autocvar_ekg; #define autocvar_fraglimit cvar("fraglimit") #define autocvar_fraglimit_override cvar("fraglimit_override") diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 03f3dbba3..8b740ef88 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -59,7 +59,9 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags) float i, p, longflags; WriteHeader(MSG_ENTITY, ENT_CLIENT_TEAMSCORES); - WriteByte(MSG_ENTITY, self.team - 1); + int t = this.team - 1; + assert(t, eprint(this)); + WriteByte(MSG_ENTITY, t); longflags = 0; for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2) diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 90e9f7938..1e9d3a766 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -234,6 +234,7 @@ void StartFrame() float DoesQ3ARemoveThisEntity(); void SV_OnEntityPreSpawnFunction() {SELFPARAM(); + __spawnfunc_expect = this; if (self) if (self.gametypefilter != "") if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter)) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 8d66501cd..d78194eb4 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -1208,10 +1208,10 @@ void StartItem(entity this, GameItem def) spawnfunc(item_rockets) { - if(!self.ammo_rockets) - self.ammo_rockets = g_pickup_rockets; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_rockets) + this.ammo_rockets = g_pickup_rockets; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Rockets); } @@ -1219,7 +1219,7 @@ spawnfunc(item_bullets) { if(!weaponswapping) if(autocvar_sv_q3acompat_machineshotgunswap) - if(self.classname != "droppedweapon") + if(this.classname != "droppedweapon") { weaponswapping = true; spawnfunc_item_shells(this); @@ -1227,28 +1227,28 @@ spawnfunc(item_bullets) return; } - if(!self.ammo_nails) - self.ammo_nails = g_pickup_nails; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_nails) + this.ammo_nails = g_pickup_nails; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Bullets); } spawnfunc(item_cells) { - if(!self.ammo_cells) - self.ammo_cells = g_pickup_cells; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_cells) + this.ammo_cells = g_pickup_cells; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Cells); } spawnfunc(item_plasma) { - if(!self.ammo_plasma) - self.ammo_plasma = g_pickup_plasma; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_plasma) + this.ammo_plasma = g_pickup_plasma; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Plasma); } @@ -1256,7 +1256,7 @@ spawnfunc(item_shells) { if(!weaponswapping) if(autocvar_sv_q3acompat_machineshotgunswap) - if(self.classname != "droppedweapon") + if(this.classname != "droppedweapon") { weaponswapping = true; spawnfunc_item_bullets(this); @@ -1264,98 +1264,98 @@ spawnfunc(item_shells) return; } - if(!self.ammo_shells) - self.ammo_shells = g_pickup_shells; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_shells) + this.ammo_shells = g_pickup_shells; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Shells); } spawnfunc(item_armor_small) { - if(!self.armorvalue) - self.armorvalue = g_pickup_armorsmall; - if(!self.max_armorvalue) - self.max_armorvalue = g_pickup_armorsmall_max; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_armorsmall_anyway; + if(!this.armorvalue) + this.armorvalue = g_pickup_armorsmall; + if(!this.max_armorvalue) + this.max_armorvalue = g_pickup_armorsmall_max; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_armorsmall_anyway; StartItem(this, ITEM_ArmorSmall); } spawnfunc(item_armor_medium) { - if(!self.armorvalue) - self.armorvalue = g_pickup_armormedium; - if(!self.max_armorvalue) - self.max_armorvalue = g_pickup_armormedium_max; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_armormedium_anyway; + if(!this.armorvalue) + this.armorvalue = g_pickup_armormedium; + if(!this.max_armorvalue) + this.max_armorvalue = g_pickup_armormedium_max; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_armormedium_anyway; StartItem(this, ITEM_ArmorMedium); } spawnfunc(item_armor_big) { - if(!self.armorvalue) - self.armorvalue = g_pickup_armorbig; - if(!self.max_armorvalue) - self.max_armorvalue = g_pickup_armorbig_max; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_armorbig_anyway; + if(!this.armorvalue) + this.armorvalue = g_pickup_armorbig; + if(!this.max_armorvalue) + this.max_armorvalue = g_pickup_armorbig_max; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_armorbig_anyway; StartItem(this, ITEM_ArmorLarge); } spawnfunc(item_armor_large) { - if(!self.armorvalue) - self.armorvalue = g_pickup_armorlarge; - if(!self.max_armorvalue) - self.max_armorvalue = g_pickup_armorlarge_max; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_armorlarge_anyway; + if(!this.armorvalue) + this.armorvalue = g_pickup_armorlarge; + if(!this.max_armorvalue) + this.max_armorvalue = g_pickup_armorlarge_max; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_armorlarge_anyway; StartItem(this, ITEM_ArmorMega); } spawnfunc(item_health_small) { - if(!self.max_health) - self.max_health = g_pickup_healthsmall_max; - if(!self.health) - self.health = g_pickup_healthsmall; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_healthsmall_anyway; + if(!this.max_health) + this.max_health = g_pickup_healthsmall_max; + if(!this.health) + this.health = g_pickup_healthsmall; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_healthsmall_anyway; StartItem(this, ITEM_HealthSmall); } spawnfunc(item_health_medium) { - if(!self.max_health) - self.max_health = g_pickup_healthmedium_max; - if(!self.health) - self.health = g_pickup_healthmedium; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_healthmedium_anyway; + if(!this.max_health) + this.max_health = g_pickup_healthmedium_max; + if(!this.health) + this.health = g_pickup_healthmedium; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_healthmedium_anyway; StartItem(this, ITEM_HealthMedium); } spawnfunc(item_health_large) { - if(!self.max_health) - self.max_health = g_pickup_healthlarge_max; - if(!self.health) - self.health = g_pickup_healthlarge; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_healthlarge_anyway; + if(!this.max_health) + this.max_health = g_pickup_healthlarge_max; + if(!this.health) + this.health = g_pickup_healthlarge; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_healthlarge_anyway; StartItem(this, ITEM_HealthLarge); } spawnfunc(item_health_mega) { - if(!self.max_health) - self.max_health = g_pickup_healthmega_max; - if(!self.health) - self.health = g_pickup_healthmega; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_healthmega_anyway; + if(!this.max_health) + this.max_health = g_pickup_healthmega_max; + if(!this.health) + this.health = g_pickup_healthmega; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_healthmega_anyway; StartItem(this, ITEM_HealthMega); } @@ -1368,20 +1368,20 @@ spawnfunc(item_health100) { spawnfunc_item_health_mega(this); } spawnfunc(item_strength) { - if(!self.strength_finished) - self.strength_finished = autocvar_g_balance_powerup_strength_time; + if(!this.strength_finished) + this.strength_finished = autocvar_g_balance_powerup_strength_time; StartItem(this, ITEM_Strength); } spawnfunc(item_invincible) { - if(!self.invincible_finished) - self.invincible_finished = autocvar_g_balance_powerup_invincible_time; + if(!this.invincible_finished) + this.invincible_finished = autocvar_g_balance_powerup_invincible_time; StartItem(this, ITEM_Shield); } // compatibility: -spawnfunc(item_quad) { self.classname = "item_strength";spawnfunc_item_strength(this);} +spawnfunc(item_quad) { this.classname = "item_strength";spawnfunc_item_strength(this);} void target_items_use() {SELFPARAM(); @@ -1530,10 +1530,10 @@ spawnfunc(target_items) spawnfunc(item_fuel) { - if(!self.ammo_fuel) - self.ammo_fuel = g_pickup_fuel; - if(!self.pickup_anyway) - self.pickup_anyway = g_pickup_ammo_anyway; + if(!this.ammo_fuel) + this.ammo_fuel = g_pickup_fuel; + if(!this.pickup_anyway) + this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_JetpackFuel); } @@ -1549,8 +1549,8 @@ spawnfunc(item_fuel_regen) spawnfunc(item_jetpack) { - if(!self.ammo_fuel) - self.ammo_fuel = g_pickup_fuel_jetpack; + if(!this.ammo_fuel) + this.ammo_fuel = g_pickup_fuel_jetpack; if(start_items & ITEM_Jetpack.m_itemid) { spawnfunc_item_fuel(this); -- 2.39.2