Skip to content

Commit f419305

Browse files
committed
Add gamedata error, minor code improvements
1 parent d129d06 commit f419305

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

addons/sourcemod/scripting/hwn_cosmetic_enabler.sp

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
#include <tf2_stocks>
2424
#include <dhooks>
2525

26+
#define PLUGIN_VERSION "1.3.1"
27+
28+
enum
29+
{
30+
VISION_MODE_NONE = 0,
31+
VISION_MODE_PYRO,
32+
VISION_MODE_HALLOWEEN,
33+
VISION_MODE_ROME,
34+
35+
MAX_VISION_MODES
36+
};
37+
2638
ConVar tf_enable_halloween_cosmetics;
2739
ConVar tf_forced_holiday;
2840
DynamicDetour g_hDetourIsHolidayActive;
@@ -37,7 +49,7 @@ public Plugin myinfo =
3749
name = "[TF2] Halloween Cosmetic Enabler",
3850
author = "Mikusch",
3951
description = "Enables Halloween cosmetics and spells regardless of current holiday",
40-
version = "1.3.0",
52+
version = PLUGIN_VERSION,
4153
url = "https://github.com/Mikusch/HalloweenCosmeticEnabler"
4254
}
4355

@@ -48,19 +60,19 @@ public void OnPluginStart()
4860

4961
tf_forced_holiday = FindConVar("tf_forced_holiday");
5062

51-
GameData hGameData = new GameData("hwn_cosmetic_enabler");
52-
if (hGameData)
53-
{
54-
g_hDetourIsHolidayActive = DynamicDetour.FromConf(hGameData, "TF_IsHolidayActive");
55-
if (!g_hDetourIsHolidayActive)
56-
SetFailState("Failed to setup detour for TF_IsHolidayActive");
57-
58-
g_hDetourInputFire = DynamicDetour.FromConf(hGameData, "CLogicOnHoliday::InputFire");
59-
if (!g_hDetourInputFire)
60-
SetFailState("Failed to setup detour for CLogicOnHoliday::InputFire");
61-
62-
delete hGameData;
63-
}
63+
GameData hGameConf = new GameData("hwn_cosmetic_enabler");
64+
if (!hGameConf)
65+
SetFailState("Failed to find hwn_cosmetic_enabler gamedata");
66+
67+
g_hDetourIsHolidayActive = DynamicDetour.FromConf(hGameConf, "TF_IsHolidayActive");
68+
if (!g_hDetourIsHolidayActive)
69+
SetFailState("Failed to setup detour for TF_IsHolidayActive");
70+
71+
g_hDetourInputFire = DynamicDetour.FromConf(hGameConf, "CLogicOnHoliday::InputFire");
72+
if (!g_hDetourInputFire)
73+
SetFailState("Failed to setup detour for CLogicOnHoliday::InputFire");
74+
75+
delete hGameConf;
6476

6577
for (int iClient = 1; iClient <= MaxClients; iClient++)
6678
{
@@ -163,7 +175,7 @@ public void SDKHookCB_HealthKit_SpawnPost(int iEntity)
163175
if (!TF2_IsHolidayActive(TFHoliday_HalloweenOrFullMoon))
164176
{
165177
// Force normal non-holiday health kit model
166-
SetEntProp(iEntity, Prop_Send, "m_nModelIndexOverrides", 0, _, 2);
178+
SetEntProp(iEntity, Prop_Send, "m_nModelIndexOverrides", 0, _, VISION_MODE_HALLOWEEN);
167179
}
168180

169181
g_bNoForcedHoliday = false;
@@ -240,7 +252,7 @@ void TogglePlugin(bool bEnable)
240252

241253
void ReplicateHolidayToClient(int iClient, TFHoliday eHoliday)
242254
{
243-
char szHoliday[20];
255+
char szHoliday[11];
244256
if (IntToString(view_as<int>(eHoliday), szHoliday, sizeof(szHoliday)))
245257
{
246258
// Make client code think that it is a different holiday

0 commit comments

Comments
 (0)