diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/tfstats/customawardlist.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/tfstats/customawardlist.cpp')
| -rw-r--r-- | utils/tfstats/customawardlist.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/utils/tfstats/customawardlist.cpp b/utils/tfstats/customawardlist.cpp new file mode 100644 index 0000000..14bcc13 --- /dev/null +++ b/utils/tfstats/customawardlist.cpp @@ -0,0 +1,80 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Implementation of CCustomAwardList +// +// $Workfile: $ +// $Date: $ +// +//------------------------------------------------------------------------------------------------------ +// $Log: $ +// +// $NoKeywords: $ +//=============================================================================// + +#include "CustomAwardList.h" +#include "memdbg.h" + +//------------------------------------------------------------------------------------------------------ +// Function: CCustomAwardList::readCustomAwards +// Purpose: Factory method to read from a file and return a list of custom awards +// Input: mapname - the name of the map determines the rule file to read the awards from +// pmi - a pointer to the Match Info which will be passed to each custom award +// Output: CCustomAwardList* +//------------------------------------------------------------------------------------------------------ +CCustomAwardList* CCustomAwardList::readCustomAwards(string mapname) +{ + char filename[255]; + + g_pApp->os->chdir(g_pApp->ruleDirectory.c_str()); + sprintf(filename,"tfc.%s.rul",mapname.c_str()); + + CTextFile ctf1(filename); + CTextFile ctf2("tfc.rul"); + + if (!ctf1.isValid() && ctf2.isValid()) + { + if (stricmp(filename,"tfc..rul")==0) + g_pApp->warning("Could not find mapname in the log file, map-specific custom rules will not be used"); + else + g_pApp->warning("Could not find %s, map-specific custom rules will not be used",filename); + } + if (!ctf2.isValid() && ctf1.isValid()) + { + g_pApp->warning("tfc.rul could not be found. Only map-specific rules will be used"); + } + if (!ctf2.isValid() && !ctf1.isValid()) + { + g_pApp->warning("Neither tfc.rul nor %s could be found. No custom rules will be used"); + return NULL; + } + + + CCustomAwardList* newList=new TRACKED CCustomAwardList; + bool foundAward=false; + + CCustomAward* pcca=CCustomAward::readCustomAward(ctf1); + while (pcca) + { + foundAward=true; + newList->theList.push_back(pcca); + pcca=CCustomAward::readCustomAward(ctf1); + } + + pcca=CCustomAward::readCustomAward(ctf2); + while (pcca) + { + foundAward=true; + newList->theList.push_back(pcca); + pcca=CCustomAward::readCustomAward(ctf2); + } + + if (!foundAward) + { + delete newList; + g_pApp->warning("Could not find any custom rules in either tfc.rul or %s. No custom rules will be used.\n",filename); + newList=NULL; + } + + return newList; +} +
\ No newline at end of file |