From 96f70ce1b77dc1b2961e521be967dee1dfec0b3e Mon Sep 17 00:00:00 2001 From: Lyberta Date: Mon, 16 Oct 2017 13:48:25 +0300 Subject: [PATCH] Removed some unneeded macros. --- .../mutator/random_items/sv_random_items.qc | 87 ++++++++----------- 1 file changed, 37 insertions(+), 50 deletions(-) diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 2df1fabfa..0c86c72ab 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -92,34 +92,34 @@ string RandomItems_GetItemVarName(string class_name) bool is_ok = expr_evaluate(autocvar_g_overkill); switch (class_name) { - #define X(classname, var) case #classname: return #var + #define X(classname) case #classname: return #classname #define XCOND(classname, var, expr) case #classname: if (expr) return #var; else break - X(item_health_small, item_health_small); - X(item_health_medium, item_health_medium); - X(item_health_big, item_health_big); + X(item_health_small); + X(item_health_medium); + X(item_health_big); XCOND(item_health_mega, item_health_mega, !is_ok || !autocvar_g_overkill_filter_healthmega); - X(item_armor_small, item_armor_small); + X(item_armor_small); XCOND(item_armor_medium, item_armor_medium, !is_ok || !autocvar_g_overkill_filter_armormedium); XCOND(item_armor_big, item_armor_big, !is_ok || !autocvar_g_overkill_filter_armorbig); XCOND(item_armor_mega, item_armor_mega, !is_ok || !autocvar_g_overkill_filter_armormega); - X(item_shells, item_shells); - X(item_bullets, item_bullets); - X(item_rockets, item_rockets); - X(item_cells, item_cells); - X(item_plasma, item_plasma); - X(item_fuel, item_fuel); + X(item_shells); + X(item_bullets); + X(item_rockets); + X(item_cells); + X(item_plasma); + X(item_fuel); - X(item_strength, item_strength); - X(item_invincible, item_shield); - X(item_fuel_regen, item_fuel_regen); - X(item_jetpack, item_jetpack); + X(item_strength); + case "item_invincible" : return "item_shield"; + X(item_fuel_regen); + X(item_jetpack); - X(item_vaporizer_cells, item_vaporizer_cells); - X(item_invisibility, item_invisibility); - X(item_extralife, item_extralife); - X(item_speed, item_speed); + X(item_vaporizer_cells); + X(item_invisibility); + X(item_extralife); + X(item_speed); #undef X #undef XCOND @@ -217,46 +217,34 @@ string RandomItems_GetRandomMapItemClassName() case RANDOM_ITEM_TYPE_HEALTH: { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_random_items_%s_probability", RandomItems_GetItemVarName(classname))), \ - 1 \ - ) - FOREACH(Items, it.instanceOfHealth, { - X(sprintf("item_%s", it.netname)); + FOREACH(Items, it.instanceOfHealth, + { + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(sprintf("g_random_items_%s_probability", + RandomItems_GetItemVarName(it.m_canonical_spawnfunc))), 1); }); - #undef X return RandomSelection_chosen_string; } case RANDOM_ITEM_TYPE_ARMOR: { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_random_items_%s_probability", RandomItems_GetItemVarName(classname))), \ - 1 \ - ) - FOREACH(Items, it.instanceOfArmor, { - X(sprintf("item_%s", it.netname)); + FOREACH(Items, it.instanceOfArmor, + { + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(sprintf("g_random_items_%s_probability", + RandomItems_GetItemVarName(it.m_canonical_spawnfunc))), 1); }); - #undef X return RandomSelection_chosen_string; } case RANDOM_ITEM_TYPE_RESOURCE: { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_random_items_%s_probability", RandomItems_GetItemVarName(classname))), \ - 1 \ - ) - FOREACH(Items, it.instanceOfAmmo, { - X(sprintf("item_%s", it.netname)); + FOREACH(Items, it.instanceOfAmmo, + { + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(sprintf("g_random_items_%s_probability", + RandomItems_GetItemVarName(it.m_canonical_spawnfunc))), 1); }); - #undef X return RandomSelection_chosen_string; } case RANDOM_ITEM_TYPE_WEAPON: @@ -264,14 +252,13 @@ string RandomItems_GetRandomMapItemClassName() RandomSelection_Init(); FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), { - string class_name = strcat("weapon_", it.netname); - string cvar_name = sprintf( - "g_random_items_%s_probability", class_name); + string cvar_name = sprintf("g_random_items_%s_probability", + it.m_canonical_spawnfunc); if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS)) { continue; } - RandomSelection_AddString(class_name, cvar(cvar_name), 1); + RandomSelection_AddString(it.m_canonical_spawnfunc, cvar(cvar_name), 1); }); return RandomSelection_chosen_string; } -- 2.39.2