Convert TFHoliday values to pubvars.

This commit is contained in:
Nicholas Hastings 2014-12-09 20:21:24 -05:00
parent 8a8917ba2e
commit 09060c265f
3 changed files with 65 additions and 10 deletions

View File

@ -126,9 +126,40 @@ void HolidayManager::UnhookIfNecessary()
m_iHookID = 0; m_iHookID = 0;
} }
static inline void PopulateHolidayVar(IPluginRuntime *pRuntime, const char *pszName)
{
uint32_t idx;
if (pRuntime->FindPubvarByName(pszName, &idx) != SP_ERROR_NONE)
return;
int varValue = -1;
const char *key = g_pGameConf->GetKeyValue(pszName);
if (key)
{
varValue = atoi(key);
}
sp_pubvar_t *var;
pRuntime->GetPubvarByIndex(idx, &var);
*var->offs = varValue;
}
void HolidayManager::OnPluginLoaded(IPlugin *plugin) void HolidayManager::OnPluginLoaded(IPlugin *plugin)
{ {
HookIfNecessary(); HookIfNecessary();
auto *pRuntime = plugin->GetRuntime();
PopulateHolidayVar(pRuntime, "TFHoliday_Birthday");
PopulateHolidayVar(pRuntime, "TFHoliday_Halloween");
PopulateHolidayVar(pRuntime, "TFHoliday_Christmas");
PopulateHolidayVar(pRuntime, "TFHoliday_EndOfTheLine");
PopulateHolidayVar(pRuntime, "TFHoliday_ValentinesDay");
PopulateHolidayVar(pRuntime, "TFHoliday_MeetThePyro");
PopulateHolidayVar(pRuntime, "TFHoliday_SpyVsEngyWar");
PopulateHolidayVar(pRuntime, "TFHoliday_FullMoon");
PopulateHolidayVar(pRuntime, "TFHoliday_HalloweenOrFullMoon");
PopulateHolidayVar(pRuntime, "TFHoliday_HalloweenOrFullMoonOrValentines");
PopulateHolidayVar(pRuntime, "TFHoliday_AprilFools");
} }
void HolidayManager::OnPluginUnloaded(IPlugin *plugin) void HolidayManager::OnPluginUnloaded(IPlugin *plugin)

View File

@ -146,4 +146,25 @@
} }
} }
} }
/*
* TF2 Holiday index values. Formerly SM TFHoliday enum.
*/
"tf"
{
"Keys"
{
"TFHoliday_Birthday" "1"
"TFHoliday_Halloween" "2"
"TFHoliday_Christmas" "3"
"TFHoliday_EndOfTheLine" "4"
"TFHoliday_ValentinesDay" "5"
"TFHoliday_MeetThePyro" "6"
"TFHoliday_SpyVsEngyWar" "7"
"TFHoliday_FullMoon" "8"
"TFHoliday_HalloweenOrFullMoon" "9"
"TFHoliday_HalloweenOrFullMoonOrValentines" "10"
"TFHoliday_AprilFools" "11"
}
}
} }

View File

@ -170,18 +170,21 @@ const Float:TFCondDuration_Infinite = -1.0;
enum TFHoliday enum TFHoliday
{ {
TFHoliday_Birthday = 1, TFHoliday_Invalid = -1
TFHoliday_Halloween,
TFHoliday_Christmas,
TFHoliday_ValentinesDay,
TFHoliday_MeetThePyro,
TFHoliday_SpyVsEngyWar,
TFHoliday_FullMoon,
TFHoliday_HalloweenOrFullMoon,
TFHoliday_HalloweenOrFullMoonOrValentines,
TFHoliday_AprilFools,
}; };
public const TFHoliday:TFHoliday_Birthday;
public const TFHoliday:TFHoliday_Halloween;
public const TFHoliday:TFHoliday_Christmas;
public const TFHoliday:TFHoliday_EndOfTheLine;
public const TFHoliday:TFHoliday_ValentinesDay;
public const TFHoliday:TFHoliday_MeetThePyro;
public const TFHoliday:TFHoliday_SpyVsEngyWar;
public const TFHoliday:TFHoliday_FullMoon;
public const TFHoliday:TFHoliday_HalloweenOrFullMoon;
public const TFHoliday:TFHoliday_HalloweenOrFullMoonOrValentines;
public const TFHoliday:TFHoliday_AprilFools;
enum TFObjectType enum TFObjectType
{ {
TFObject_CartDispenser = 0, TFObject_CartDispenser = 0,