From 87fa394daaac00fda26d65241f5f4aa31badc852 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 23 Dec 2018 22:53:10 +0100 Subject: [PATCH] Add Christmas skin event for client --- src/engine/shared/config_variables.h | 2 +- src/game/client/components/skins.cpp | 19 +++++++++++++++++-- src/game/client/components/skins.h | 1 + src/game/server/player.cpp | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index bc9bd087d..c05e9e162 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -12,6 +12,7 @@ MACRO_CONFIG_INT(PlayerCountry, player_country, -1, -1, 1000, CFGFLAG_SAVE|CFGFL MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, "Password to the server") MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to") MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Adjusts the amount of information in the console") +MACRO_CONFIG_INT(Events, events, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Enable triggering of events, like the happy eye emotes on some holidays.") MACRO_CONFIG_INT(ClSaveSettings, cl_save_settings, 1, 0, 1, CFGFLAG_CLIENT, "Write the settings file on exit") MACRO_CONFIG_INT(ClRefreshRate, cl_refresh_rate, 0, 0, 10000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Refresh rate for updating the game (in Hz)") @@ -350,7 +351,6 @@ MACRO_CONFIG_INT(SvChatPenalty, sv_chat_penalty, 250, 50, 1000, CFGFLAG_SERVER, MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 50, 10000 , CFGFLAG_SERVER, "if chats core exceeds this, the player will be muted for sv_spam_mute_duration seconds") MACRO_CONFIG_INT(SvSpamMuteDuration, sv_spam_mute_duration, 60, 0, 3600 , CFGFLAG_SERVER, "how many seconds to mute, if player triggers mute on spam. 0 = off") -MACRO_CONFIG_INT(SvEvents, sv_events, 1, 0, 1, CFGFLAG_SERVER, "Enable triggering of server events, like the happy eyeemotes on some holidays.") MACRO_CONFIG_INT(SvRankCheats, sv_rank_cheats, 0, 0, 1, CFGFLAG_SERVER, "Enable ranks after cheats have been used (file based server only)") MACRO_CONFIG_INT(SvShutdownWhenEmpty, sv_shutdown_when_empty, 0, 0, 1, CFGFLAG_SERVER, "Shutdown server as soon as no one is on it anymore") MACRO_CONFIG_INT(SvReloadWhenEmpty, sv_reload_when_empty, 0, 0, 2, CFGFLAG_SERVER, "Reload map when server is empty (1 = reload once, 2 = reload every time server gets empty)") diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index bc7eb39d3..464da265d 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -150,6 +150,20 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) void CSkins::OnInit() { + m_EventSkinPrefix[0] = '\0'; + + if(g_Config.m_Events) + { + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + if(timeinfo->tm_mon == 11 && timeinfo->tm_mday >= 24 && timeinfo->tm_mday <= 26) + { // Christmas + str_copy(m_EventSkinPrefix, "santa", sizeof(m_EventSkinPrefix)); + } + } + // load skins m_aSkins.clear(); Storage()->ListDirectory(IStorage::TYPE_ALL, "skins", SkinScan, this); @@ -185,14 +199,15 @@ const CSkins::CSkin *CSkins::Get(int Index) int CSkins::Find(const char *pName) const { + const char *pSkinPrefix = m_EventSkinPrefix[0] ? m_EventSkinPrefix : g_Config.m_ClSkinPrefix; if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(pName)) { return -1; } - else if(g_Config.m_ClSkinPrefix[0]) + else if(pSkinPrefix) { char aBuf[64]; - str_format(aBuf, sizeof(aBuf), "%s_%s", g_Config.m_ClSkinPrefix, pName); + str_format(aBuf, sizeof(aBuf), "%s_%s", pSkinPrefix, pName); // If we find something, use it, otherwise fall back to normal skins. int Result = FindImpl(aBuf); if(Result != -1) diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 0a76c6cce..ab880a8ea 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -31,6 +31,7 @@ public: private: sorted_array m_aSkins; + char m_EventSkinPrefix[100]; int FindImpl(const char *pName) const; static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 531503c0b..d880eab94 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -77,7 +77,7 @@ void CPlayer::Reset() m_SendVoteIndex = -1; - if (g_Config.m_SvEvents) + if(g_Config.m_Events) { time_t rawtime; struct tm* timeinfo;