From 118e6c304a242d2de95978fdbf593a62c9d86073 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 22 Mar 2016 16:23:01 +1100 Subject: [PATCH] Type check class methods --- qcsrc/client/commands/cl_cmd.qc | 4 +-- qcsrc/client/commands/cl_cmd.qh | 2 +- qcsrc/common/command/all.qh | 2 +- qcsrc/common/command/command.qh | 5 +++- qcsrc/common/command/generic.qc | 4 +-- qcsrc/common/effects/effectinfo.qc | 8 ++++-- .../gamemodes/gamemode/nexball/nexball.qc | 10 +++++--- qcsrc/common/items/item.qh | 10 ++++++-- qcsrc/common/items/item/pickup.qh | 7 +++++- qcsrc/common/mapinfo.qh | 10 ++++++-- qcsrc/common/models/model.qh | 4 ++- qcsrc/common/monsters/monster.qh | 12 ++++----- qcsrc/common/monsters/monster/mage.qc | 21 +++++++++++----- qcsrc/common/monsters/monster/shambler.qc | 18 ++++++++----- qcsrc/common/monsters/monster/spider.qc | 22 ++++++++++------ qcsrc/common/monsters/monster/wyvern.qc | 25 +++++++++++++------ qcsrc/common/monsters/monster/zombie.qc | 18 ++++++++----- qcsrc/common/sounds/sound.qh | 3 ++- qcsrc/common/state.qh | 1 + qcsrc/lib/oo.qh | 2 ++ qcsrc/server/command/all.qh | 2 +- qcsrc/server/command/common.qh | 6 ++--- qcsrc/server/command/sv_cmd.qc | 4 +-- 23 files changed, 136 insertions(+), 64 deletions(-) diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc index fdc7dae70..6dadff2f3 100644 --- a/qcsrc/client/commands/cl_cmd.qc +++ b/qcsrc/client/commands/cl_cmd.qc @@ -489,7 +489,7 @@ bool LocalCommand_macro_command(int argc, string command) { string c = strtolower(argv(0)); FOREACH(CLIENT_COMMANDS, it.m_name == c, { - it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command); + it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command); return true; }); return false; @@ -499,7 +499,7 @@ bool LocalCommand_macro_usage(int argc) { string c = strtolower(argv(1)); FOREACH(CLIENT_COMMANDS, it.m_name == c, { - it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, ""); + it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, ""); return true; }); return false; diff --git a/qcsrc/client/commands/cl_cmd.qh b/qcsrc/client/commands/cl_cmd.qh index 857adeaac..65a723389 100644 --- a/qcsrc/client/commands/cl_cmd.qh +++ b/qcsrc/client/commands/cl_cmd.qh @@ -17,7 +17,7 @@ REGISTRY_SORT(CLIENT_COMMANDS) ATTRIB(clientcommand_##id, m_description, string, description); \ ENDCLASS(clientcommand_##id) \ REGISTER(CLIENT_COMMANDS, CMD_CL, id, m_id, NEW(clientcommand_##id)); \ - METHOD(clientcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command)) + METHOD(clientcommand_##id, m_invokecmd, void(clientcommand_##id this, int request, entity caller, int arguments, string command)) STATIC_INIT(CLIENT_COMMANDS_aliases) { FOREACH(CLIENT_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_cl"))); diff --git a/qcsrc/common/command/all.qh b/qcsrc/common/command/all.qh index 9bbce5e14..129090d3a 100644 --- a/qcsrc/common/command/all.qh +++ b/qcsrc/common/command/all.qh @@ -13,7 +13,7 @@ REGISTRY_SORT(GENERIC_COMMANDS) ATTRIB(genericcommand_##id, m_description, string, description); \ ENDCLASS(genericcommand_##id) \ REGISTER(GENERIC_COMMANDS, CMD_G, id, m_id, NEW(genericcommand_##id)); \ - METHOD(genericcommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command)) + METHOD(genericcommand_##id, m_invokecmd, void(genericcommand_##id this, int request, entity caller, int arguments, string command)) STATIC_INIT(GENERIC_COMMANDS_aliases) { FOREACH(GENERIC_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu"))); diff --git a/qcsrc/common/command/command.qh b/qcsrc/common/command/command.qh index beda2288c..72eaa18da 100644 --- a/qcsrc/common/command/command.qh +++ b/qcsrc/common/command/command.qh @@ -7,7 +7,10 @@ const int CMD_REQUEST_USAGE = 2; CLASS(Command, Object) ATTRIB(Command, m_name, string, string_null); ATTRIB(Command, m_description, string, string_null); - METHOD(Command, m_invokecmd, void(int request, entity caller, int arguments, string command)) { } + METHOD(Command, m_invokecmd, void(Command this, int request, entity caller, int arguments, string command)) + { + TC(Command, this); + } ENDCLASS(Command) #endif diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 50cc49076..90d6cefe7 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -544,7 +544,7 @@ float GenericCommand_macro_command(float argc, string command) { string c = strtolower(argv(0)); FOREACH(GENERIC_COMMANDS, it.m_name == c, { - it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command); + it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command); return true; }); return false; @@ -554,7 +554,7 @@ float GenericCommand_macro_usage(float argc) { string c = strtolower(argv(1)); FOREACH(GENERIC_COMMANDS, it.m_name == c, { - it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, ""); + it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, ""); return true; }); return false; diff --git a/qcsrc/common/effects/effectinfo.qc b/qcsrc/common/effects/effectinfo.qc index da9894602..07d76c480 100644 --- a/qcsrc/common/effects/effectinfo.qc +++ b/qcsrc/common/effects/effectinfo.qc @@ -197,7 +197,9 @@ CLASS(EffectInfo, Object) FIELDS(MY) #undef MY - METHOD(EffectInfo, describe, string(EffectInfo this)) { + METHOD(EffectInfo, describe, string(EffectInfo this)) + { + TC(EffectInfo, this); string s = sprintf("SUB(%s) {\n", this.effectinfo_name); #define str_bool(it) (it ? "true" : "false") #define str_float(it) ftos(it) @@ -209,7 +211,9 @@ CLASS(EffectInfo, Object) return strcat(s, "}\n"); } - METHOD(EffectInfo, dump, string(EffectInfo this)) { + METHOD(EffectInfo, dump, string(EffectInfo this)) + { + TC(EffectInfo, this); string s = sprintf("effect %s\n", this.effectinfo_name); #define MY(f) this.effectinfo_##f #define p(k, isset, parse, unparse) if (isset) { s = strcat(s, "\t", #k, unparse, "\n"); } diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index df062641a..bea1b7b6f 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -854,6 +854,7 @@ float ball_customize() METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire)) { + TC(BallStealer, thiswep); if(fire & 1) if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire)) if(autocvar_g_nexball_basketball_meter) @@ -883,18 +884,21 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we } } -METHOD(BallStealer, wr_setup, void(BallStealer thiswep)) +METHOD(BallStealer, wr_setup, void(BallStealer this)) { + TC(BallStealer, this); //weapon_setup(WEP_PORTO.m_id); } -METHOD(BallStealer, wr_checkammo1, bool(BallStealer thiswep)) +METHOD(BallStealer, wr_checkammo1, bool(BallStealer this)) { + TC(BallStealer, this); return true; } -METHOD(BallStealer, wr_checkammo2, bool(BallStealer thiswep)) +METHOD(BallStealer, wr_checkammo2, bool(BallStealer this)) { + TC(BallStealer, this); return true; } diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index ba21efd96..55f33ecc8 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -47,10 +47,16 @@ CLASS(GameItem, Object) ATTRIB(GameItem, m_color, vector, '1 1 1') ATTRIB(GameItem, m_waypoint, string, string_null) ATTRIB(GameItem, m_waypointblink, int, 1) - METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns)) { + METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns)) + { + TC(GameItem, this); returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null); } - METHOD(GameItem, show, void(GameItem this)) { LOG_INFO("A game item\n"); } + METHOD(GameItem, show, void(GameItem this)) + { + TC(GameItem, this); + LOG_INFO("A game item\n"); + } void ITEM_HANDLE(Show, GameItem this) { this.show(this); } ENDCLASS(GameItem) diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index 9bee4e6b2..08f7ff9c3 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -8,7 +8,11 @@ CLASS(Pickup, GameItem) ATTRIB(Pickup, m_sound, Sound, SND_ITEMPICKUP) #endif ATTRIB(Pickup, m_name, string, string_null) - METHOD(Pickup, show, void(Pickup this)) { LOG_INFOF("%s: %s\n", etos(this), this.m_name); } + METHOD(Pickup, show, void(Pickup this)) + { + TC(Pickup, this); + LOG_INFOF("%s: %s\n", etos(this), this.m_name); + } #ifdef SVQC ATTRIB(Pickup, m_mins, vector, '-16 -16 0') ATTRIB(Pickup, m_maxs, vector, '16 16 32') @@ -22,6 +26,7 @@ CLASS(Pickup, GameItem) float Item_GiveTo(entity item, entity player); METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player)) { + TC(Pickup, this); bool b = Item_GiveTo(item, player); if (b) { LOG_TRACEF("entity %i picked up %s\n", player, this.m_name); diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index ab7233ef2..b7115ef55 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -28,9 +28,15 @@ CLASS(Gametype, Object) ATTRIB(Gametype, m_mutators, string, string_null) ATTRIB(Gametype, m_parse_mapinfo, bool(string k, string v), func_null) - METHOD(Gametype, describe, string(entity this)) { return this.gametype_description; } + METHOD(Gametype, describe, string(Gametype this)) + { + TC(Gametype, this); + return this.gametype_description; + } - METHOD(Gametype, display, void(entity this, void(string name, string icon) returns)) { + METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns)) + { + TC(Gametype, this); returns(this.message, strcat("gametype_", this.mdl)); } diff --git a/qcsrc/common/models/model.qh b/qcsrc/common/models/model.qh index 3e9ebd2f1..1c34a2547 100644 --- a/qcsrc/common/models/model.qh +++ b/qcsrc/common/models/model.qh @@ -11,7 +11,9 @@ CLASS(Model, Object) CONSTRUCT(Model); this.model_str = path; } - METHOD(Model, model_precache, void(entity this)) { + METHOD(Model, model_precache, void(Model this)) + { + TC(Model, this); string s = this.model_str(); if (s != "" && s != "null" && !fexists(s)) { LOG_WARNINGF("Missing model: \"%s\"\n", s); diff --git a/qcsrc/common/monsters/monster.qh b/qcsrc/common/monsters/monster.qh index 22e2072c0..f1a5ee3d4 100644 --- a/qcsrc/common/monsters/monster.qh +++ b/qcsrc/common/monsters/monster.qh @@ -56,17 +56,17 @@ CLASS(Monster, Object) ATTRIB(Monster, maxs, vector, '0 0 0') /** (SERVER) setup monster data */ - METHOD(Monster, mr_setup, bool(Monster this, entity actor)) { return false; } + METHOD(Monster, mr_setup, bool(Monster this, entity actor)) { TC(Monster, this); return false; } /** (SERVER) logic to run every frame */ - METHOD(Monster, mr_think, bool(Monster this, entity actor)) { return false; } + METHOD(Monster, mr_think, bool(Monster this, entity actor)) { TC(Monster, this); return false; } /** (SERVER) called when monster dies */ - METHOD(Monster, mr_death, bool(Monster this, entity actor)) { return false; } + METHOD(Monster, mr_death, bool(Monster this, entity actor)) { TC(Monster, this); return false; } /** (BOTH) precaches models/sounds used by this monster */ - METHOD(Monster, mr_precache, bool(Monster this)) { return false; } + METHOD(Monster, mr_precache, bool(Monster this)) { TC(Monster, this); return false; } /** (SERVER) called when monster is damaged */ - METHOD(Monster, mr_pain, bool(Monster this, entity actor)) { return false; } + METHOD(Monster, mr_pain, bool(Monster this, entity actor)) { TC(Monster, this); return false; } /** (BOTH?) sets animations for monster */ - METHOD(Monster, mr_anim, bool(Monster this, entity actor)) { return false; } + METHOD(Monster, mr_anim, bool(Monster this, entity actor)) { TC(Monster, this); return false; } ENDCLASS(Monster) diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 0bf1a835e..fcac1e409 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -42,7 +42,9 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike)); SOUND(MageSpike_FIRE, W_Sound("electro_fire")); void M_Mage_Attack_Spike(entity this, vector dir); void M_Mage_Attack_Push(entity this); -METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) { +METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) +{ + TC(MageSpike, thiswep); if (fire & 1) if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range; @@ -65,6 +67,7 @@ CLASS(OffhandMageTeleport, OffhandWeapon) .bool OffhandMageTeleport_key_pressed; METHOD(OffhandMageTeleport, offhand_think, void(OffhandMageTeleport this, entity player, bool key_pressed)) { + TC(OffhandMageTeleport, this); if (key_pressed && !player.OffhandMageTeleport_key_pressed) M_Mage_Attack_Teleport(player, player.enemy); player.OffhandMageTeleport_key_pressed = key_pressed; @@ -411,6 +414,7 @@ spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); } #ifdef SVQC METHOD(Mage, mr_think, bool(Mage thismon, entity actor)) { + TC(Mage, thismon); bool need_help = false; FOREACH_ENTITY_FLOAT(iscreature, true, @@ -441,21 +445,24 @@ METHOD(Mage, mr_think, bool(Mage thismon, entity actor)) return true; } -METHOD(Mage, mr_pain, bool(Mage thismon, entity actor)) +METHOD(Mage, mr_pain, bool(Mage this, entity actor)) { + TC(Mage, this); return true; } -METHOD(Mage, mr_death, bool(Mage thismon, entity actor)) +METHOD(Mage, mr_death, bool(Mage this, entity actor)) { + TC(Mage, this); setanim(actor, actor.anim_die1, false, true, true); return true; } #endif #ifndef MENUQC -METHOD(Mage, mr_anim, bool(Mage thismon, entity actor)) +METHOD(Mage, mr_anim, bool(Mage this, entity actor)) { + TC(Mage, this); vector none = '0 0 0'; actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds actor.anim_walk = animfixfps(actor, '1 1 1', none); @@ -469,8 +476,9 @@ METHOD(Mage, mr_anim, bool(Mage thismon, entity actor)) #ifdef SVQC .float speed; spawnfunc(item_health_large); -METHOD(Mage, mr_setup, bool(Mage thismon, entity actor)) +METHOD(Mage, mr_setup, bool(Mage this, entity actor)) { + TC(Mage, this); if(!actor.health) actor.health = (autocvar_g_monster_mage_health); if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); } @@ -483,8 +491,9 @@ METHOD(Mage, mr_setup, bool(Mage thismon, entity actor)) return true; } -METHOD(Mage, mr_precache, bool(Mage thismon)) +METHOD(Mage, mr_precache, bool(Mage this)) { + TC(Mage, this); return true; } #endif diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index b09171279..9f6fb8d1b 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -225,27 +225,31 @@ spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); } #endif // SVQC #ifdef SVQC -METHOD(Shambler, mr_think, bool(Shambler thismon, entity actor)) +METHOD(Shambler, mr_think, bool(Shambler this, entity actor)) { + TC(Shambler, this); return true; } -METHOD(Shambler, mr_pain, bool(Shambler thismon, entity actor)) +METHOD(Shambler, mr_pain, bool(Shambler this, entity actor)) { + TC(Shambler, this); actor.pain_finished = time + 0.5; setanim(actor, actor.anim_pain1, true, true, false); return true; } -METHOD(Shambler, mr_death, bool(Shambler thismon, entity actor)) +METHOD(Shambler, mr_death, bool(Shambler this, entity actor)) { + TC(Shambler, this); setanim(actor, actor.anim_die1, false, true, true); return true; } #endif #ifndef MENUQC -METHOD(Shambler, mr_anim, bool(Shambler thismon, entity actor)) +METHOD(Shambler, mr_anim, bool(Shambler this, entity actor)) { + TC(Shambler, this); vector none = '0 0 0'; actor.anim_die1 = animfixfps(actor, '8 1 0.5', none); // 2 seconds actor.anim_walk = animfixfps(actor, '1 1 1', none); @@ -262,8 +266,9 @@ METHOD(Shambler, mr_anim, bool(Shambler thismon, entity actor)) #ifdef SVQC spawnfunc(item_health_mega); .float animstate_endtime; -METHOD(Shambler, mr_setup, bool(Shambler thismon, entity actor)) +METHOD(Shambler, mr_setup, bool(Shambler this, entity actor)) { + TC(Shambler, this); if(!actor.health) actor.health = (autocvar_g_monster_shambler_health); if(!actor.attack_range) actor.attack_range = 150; if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); } @@ -282,8 +287,9 @@ METHOD(Shambler, mr_setup, bool(Shambler thismon, entity actor)) return true; } -METHOD(Shambler, mr_precache, bool(Shambler thismon)) +METHOD(Shambler, mr_precache, bool(Shambler this)) { + TC(Shambler, this); return true; } #endif diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 512422d33..d85b85535 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -88,7 +88,9 @@ MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn) } SOUND(SpiderAttack_FIRE, W_Sound("electro_fire")); -METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire)) { +METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire)) +{ + TC(SpiderAttack, thiswep); bool isPlayer = IS_PLAYER(actor); if (fire & 1) if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_monster_spider_attack_web_delay)) { @@ -215,26 +217,30 @@ spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); } #endif // SVQC #ifdef SVQC -METHOD(Spider, mr_think, bool(Spider thismon, entity actor)) +METHOD(Spider, mr_think, bool(Spider this, entity actor)) { + TC(Spider, this); return true; } -METHOD(Spider, mr_pain, bool(Spider thismon, entity actor)) +METHOD(Spider, mr_pain, bool(Spider this, entity actor)) { + TC(Spider, this); return true; } -METHOD(Spider, mr_death, bool(Spider thismon, entity actor)) +METHOD(Spider, mr_death, bool(Spider this, entity actor)) { + TC(Spider, this); setanim(actor, actor.anim_melee, false, true, true); actor.angles_x = 180; return true; } #endif #ifndef MENUQC -METHOD(Spider, mr_anim, bool(Spider thismon, entity actor)) +METHOD(Spider, mr_anim, bool(Spider this, entity actor)) { + TC(Spider, this); vector none = '0 0 0'; actor.anim_walk = animfixfps(actor, '1 1 1', none); actor.anim_idle = animfixfps(actor, '0 1 1', none); @@ -246,8 +252,9 @@ METHOD(Spider, mr_anim, bool(Spider thismon, entity actor)) #endif #ifdef SVQC spawnfunc(item_health_medium); -METHOD(Spider, mr_setup, bool(Spider thismon, entity actor)) +METHOD(Spider, mr_setup, bool(Spider this, entity actor)) { + TC(Spider, this); if(!actor.health) actor.health = (autocvar_g_monster_spider_health); if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); } @@ -260,8 +267,9 @@ METHOD(Spider, mr_setup, bool(Spider thismon, entity actor)) return true; } -METHOD(Spider, mr_precache, bool(Spider thismon)) +METHOD(Spider, mr_precache, bool(Spider this)) { + TC(Spider, this); return true; } #endif diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index fc13de40f..f6e9c1306 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -49,7 +49,9 @@ void M_Wyvern_Attack_Fireball_Explode(); void M_Wyvern_Attack_Fireball_Touch(); SOUND(WyvernAttack_FIRE, W_Sound("electro_fire")); -METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire)) { +METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire)) +{ + TC(WyvernAttack, thiswep); if (fire & 1) if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) { if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, SND(WyvernAttack_FIRE), CH_WEAPON_B, 0); @@ -78,7 +80,8 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity } } -METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack thiswep)) { +METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this)) { + TC(WyvernAttack, this); return true; } @@ -143,20 +146,23 @@ spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); } #endif // SVQC #ifdef SVQC -METHOD(Wyvern, mr_think, bool(Wyvern thismon, entity actor)) +METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor)) { + TC(Wyvern, this); return true; } -METHOD(Wyvern, mr_pain, bool(Wyvern thismon, entity actor)) +METHOD(Wyvern, mr_pain, bool(Wyvern this, entity actor)) { + TC(Wyvern, this); actor.pain_finished = time + 0.5; setanim(actor, actor.anim_pain1, true, true, false); return true; } -METHOD(Wyvern, mr_death, bool(Wyvern thismon, entity actor)) +METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor)) { + TC(Wyvern, this); setanim(actor, actor.anim_die1, false, true, true); actor.velocity_x = -200 + 400 * random(); actor.velocity_y = -200 + 400 * random(); @@ -165,8 +171,9 @@ METHOD(Wyvern, mr_death, bool(Wyvern thismon, entity actor)) } #endif #ifndef MENUQC -METHOD(Wyvern, mr_anim, bool(Wyvern thismon, entity actor)) +METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor)) { + TC(Wyvern, this); vector none = '0 0 0'; actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds actor.anim_walk = animfixfps(actor, '1 1 1', none); @@ -179,8 +186,9 @@ METHOD(Wyvern, mr_anim, bool(Wyvern thismon, entity actor)) #endif #ifdef SVQC spawnfunc(item_cells); -METHOD(Wyvern, mr_setup, bool(Wyvern thismon, entity actor)) +METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor)) { + TC(Wyvern, this); if(!actor.health) actor.health = (autocvar_g_monster_wyvern_health); if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); } @@ -193,8 +201,9 @@ METHOD(Wyvern, mr_setup, bool(Wyvern thismon, entity actor)) return true; } -METHOD(Wyvern, mr_precache, bool(Wyvern thismon)) +METHOD(Wyvern, mr_precache, bool(Wyvern this)) { + TC(Wyvern, this); return true; } #endif diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index 9163aaf07..b28bb8d84 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -155,22 +155,25 @@ spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); } #endif // SVQC #ifdef SVQC -METHOD(Zombie, mr_think, bool(Zombie thismon, entity actor)) +METHOD(Zombie, mr_think, bool(Zombie this, entity actor)) { + TC(Zombie, this); if(time >= actor.spawn_time) actor.damageforcescale = autocvar_g_monster_zombie_damageforcescale; return true; } -METHOD(Zombie, mr_pain, bool(Zombie thismon, entity actor)) +METHOD(Zombie, mr_pain, bool(Zombie this, entity actor)) { + TC(Zombie, this); actor.pain_finished = time + 0.34; setanim(actor, ((random() > 0.5) ? actor.anim_pain1 : actor.anim_pain2), true, true, false); return true; } -METHOD(Zombie, mr_death, bool(Zombie thismon, entity actor)) +METHOD(Zombie, mr_death, bool(Zombie this, entity actor)) { + TC(Zombie, this); actor.armorvalue = autocvar_g_monsters_armor_blockpercent; setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true); @@ -178,8 +181,9 @@ METHOD(Zombie, mr_death, bool(Zombie thismon, entity actor)) } #endif #ifndef MENUQC -METHOD(Zombie, mr_anim, bool(Zombie thismon, entity actor)) +METHOD(Zombie, mr_anim, bool(Zombie this, entity actor)) { + TC(Zombie, this); vector none = '0 0 0'; actor.anim_die1 = animfixfps(actor, '9 1 0.5', none); // 2 seconds actor.anim_die2 = animfixfps(actor, '12 1 0.5', none); // 2 seconds @@ -199,8 +203,9 @@ METHOD(Zombie, mr_anim, bool(Zombie thismon, entity actor)) } #endif #ifdef SVQC -METHOD(Zombie, mr_setup, bool(Zombie thismon, entity actor)) +METHOD(Zombie, mr_setup, bool(Zombie this, entity actor)) { + TC(Zombie, this); if(!actor.health) actor.health = (autocvar_g_monster_zombie_health); if(!actor.speed) { actor.speed = (autocvar_g_monster_zombie_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_zombie_speed_run); } @@ -223,8 +228,9 @@ METHOD(Zombie, mr_setup, bool(Zombie thismon, entity actor)) return true; } -METHOD(Zombie, mr_precache, bool(Zombie thismon)) +METHOD(Zombie, mr_precache, bool(Zombie this)) { + TC(Zombie, this); return true; } #endif diff --git a/qcsrc/common/sounds/sound.qh b/qcsrc/common/sounds/sound.qh index 7225cef82..a462861f2 100644 --- a/qcsrc/common/sounds/sound.qh +++ b/qcsrc/common/sounds/sound.qh @@ -120,8 +120,9 @@ CLASS(Sound, Object) return string_null; #endif } - METHOD(Sound, sound_precache, void(entity this)) + METHOD(Sound, sound_precache, void(Sound this)) { + TC(Sound, this); string s = Sound_fixpath(this); if (!s) return; LOG_DEBUGF("precache_sound(\"%s\")\n", s); diff --git a/qcsrc/common/state.qh b/qcsrc/common/state.qh index 90c7029e3..4e80bfd2c 100644 --- a/qcsrc/common/state.qh +++ b/qcsrc/common/state.qh @@ -17,6 +17,7 @@ CLASS(PlayerState, Object) ATTRIB(PlayerState, m_weapon, Weapon, Weapons_from(-1)) METHOD(PlayerState, ps_push, void(PlayerState this, entity cl)) { + TC(PlayerState, this); STAT(ACTIVEWEAPON, cl) = this.m_weapon.m_id; STAT(SWITCHINGWEAPON, cl) = this.m_switchingweapon.m_id; STAT(SWITCHWEAPON, cl) = this.m_switchweapon.m_id; diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index 637dbe924..4615ea970 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -241,6 +241,7 @@ CLASS(Object, ); #define remove(this) delete(this) METHOD(Object, describe, string(Object this)) { + TC(Object, this); string s = _("No description"); if (cvar("developer")) { @@ -254,6 +255,7 @@ CLASS(Object, ); } METHOD(Object, display, void(Object this, void(string name, string icon) returns)) { + TC(Object, this); returns(sprintf("entity %i", this), "nopreview_map"); } ENDCLASS(Object) diff --git a/qcsrc/server/command/all.qh b/qcsrc/server/command/all.qh index 5add6184e..cde5ef367 100644 --- a/qcsrc/server/command/all.qh +++ b/qcsrc/server/command/all.qh @@ -12,7 +12,7 @@ REGISTRY_SORT(SERVER_COMMANDS) ATTRIB(servercommand_##id, m_description, string, description); \ ENDCLASS(servercommand_##id) \ REGISTER(SERVER_COMMANDS, CMD_SV, id, m_id, NEW(servercommand_##id)); \ - METHOD(servercommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command)) + METHOD(servercommand_##id, m_invokecmd, void(servercommand_##id this, int request, entity caller, int arguments, string command)) STATIC_INIT(SERVER_COMMANDS_aliases) { FOREACH(SERVER_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_sv")))); diff --git a/qcsrc/server/command/common.qh b/qcsrc/server/command/common.qh index 2524d31e4..b79a57020 100644 --- a/qcsrc/server/command/common.qh +++ b/qcsrc/server/command/common.qh @@ -12,7 +12,7 @@ REGISTRY_SORT(COMMON_COMMANDS) ATTRIB(commoncommand_##id, m_description, string, description); \ ENDCLASS(commoncommand_##id) \ REGISTER(COMMON_COMMANDS, CMD_SV, id, m_id, NEW(commoncommand_##id)); \ - METHOD(commoncommand_##id, m_invokecmd, void(int request, entity caller, int arguments, string command)) + METHOD(commoncommand_##id, m_invokecmd, void(commoncommand_##id this, int request, entity caller, int arguments, string command)) STATIC_INIT(COMMON_COMMANDS_aliases) { FOREACH(COMMON_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svcmd")))); @@ -165,7 +165,7 @@ float CommonCommand_macro_command(float argc, entity caller, string command) { string c = strtolower(argv(0)); FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_COMMAND, caller, argc, command); + it.m_invokecmd(it, CMD_REQUEST_COMMAND, caller, argc, command); return true; )); return false; @@ -175,7 +175,7 @@ float CommonCommand_macro_usage(float argc, entity caller) { string c = strtolower(argv(1)); FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_USAGE, caller, argc, ""); + it.m_invokecmd(it, CMD_REQUEST_USAGE, caller, argc, ""); return true; )); return false; diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 2f1400245..b48844d20 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1781,7 +1781,7 @@ float GameCommand_macro_command(float argc, string command) { string c = strtolower(argv(0)); FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_COMMAND, NULL, argc, command); + it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command); return true; )); return false; @@ -1791,7 +1791,7 @@ float GameCommand_macro_usage(float argc) { string c = strtolower(argv(1)); FOREACH(SERVER_COMMANDS, it.m_name == c, LAMBDA( - it.m_invokecmd(CMD_REQUEST_USAGE, NULL, argc, ""); + it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, ""); return true; )); return false; -- 2.39.2