MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / Reparse

Method Reparse

core/logic/GameConfigs.cpp:821–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819static MasterReader master_reader;
820
821bool CGameConfig::Reparse(char *error, size_t maxlength)
822{
823 /* Reset cached data */
824 m_Offsets.clear();
825 m_Props.clear();
826 m_Keys.clear();
827 m_Addresses.clear();
828
829 char path[PLATFORM_MAX_PATH];
830
831 /* See if we can use the extended gamedata format. */
832 g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/master.games.txt", m_File);
833 if (!libsys->PathExists(path))
834 {
835 /* Nope, use the old mechanism. */
836 ke::SafeSprintf(path, sizeof(path), "%s.txt", m_File);
837 if (!EnterFile(path, error, maxlength))
838 {
839 return false;
840 }
841
842 /* Allow customization. */
843 g_pSM->BuildPath(Path_SM, path, sizeof(path), "gamedata/custom/%s.txt", m_File);
844 if (libsys->PathExists(path))
845 {
846 ke::SafeSprintf(path, sizeof(path), "custom/%s.txt", m_File);
847 bool success = EnterFile(path, error, maxlength);
848 if (success)
849 {
850 rootmenu->ConsolePrint("[SM] Parsed custom gamedata override file: %s", path);
851 }
852 return success;
853 }
854 return true;
855 }
856
857 /* Otherwise, it's time to parse the master. */
858 SMCError err;
859 SMCStates state = {0, 0};
860 List<String> fileList;
861 master_reader.fileList = &fileList;
862 const char *pEngine[2] = { m_pBaseEngine, m_pEngine };
863
864 for (unsigned char iter = 0; iter < SM_ARRAYSIZE(pEngine); ++iter)
865 {
866 if (pEngine[iter] == NULL)
867 {
868 continue;
869 }
870
871 this->SetParseEngine(pEngine[iter]);
872 err = textparsers->ParseSMCFile(path, &master_reader, &state, error, maxlength);
873 if (err != SMCError_Okay)
874 {
875 const char *msg = textparsers->GetSMCErrorString(err);
876
877 logger->LogError("[SM] Error parsing master gameconf file \"%s\":", path);
878 logger->LogError("[SM] Error %d on line %d, col %d: %s",

Callers 2

LoadGameConfigFileMethod · 0.45

Calls 15

SetParseEngineMethod · 0.95
BuildPathMethod · 0.80
PathExistsMethod · 0.80
OpenDirectoryMethod · 0.80
MoreFilesMethod · 0.80
IsEntryFileMethod · 0.80
NextEntryMethod · 0.80
GetEntryNameMethod · 0.80
CloseDirectoryMethod · 0.80
clearMethod · 0.45
ConsolePrintMethod · 0.45
ParseSMCFileMethod · 0.45

Tested by

no test coverage detected