MCPcopy Create free account
hub / github.com/RSDKModding/RSDKv4-Decompilation / ParseScriptFile

Function ParseScriptFile

RSDKv4/Script.cpp:2735–3072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2733}
2734
2735void ParseScriptFile(char *scriptName, int scriptID)
2736{
2737 jumpTableStackPos = 0;
2738 lineID = 0;
2739
2740 for (int f = 0; f < scriptFunctionCount; ++f) {
2741 if (scriptFunctionList[f].access != ACCESS_PUBLIC)
2742 StrCopy(scriptFunctionList[f].name, "");
2743 }
2744
2745 int newScriptValueCount = COMMON_SCRIPT_VAR_COUNT;
2746 for (int v = COMMON_SCRIPT_VAR_COUNT; v < scriptValueListCount; ++v) {
2747 if (scriptValueList[v].access != ACCESS_PUBLIC) {
2748 StrCopy(scriptValueList[v].name, "");
2749 }
2750 else {
2751 if (newScriptValueCount != v)
2752 memcpy(&scriptValueList[newScriptValueCount], &scriptValueList[v], sizeof(ScriptVariableInfo));
2753
2754 newScriptValueCount++;
2755 }
2756 }
2757 scriptValueListCount = newScriptValueCount;
2758
2759 for (int v = scriptValueListCount; v < SCRIPT_VAR_COUNT; ++v) {
2760 MEM_ZERO(scriptValueList[v]);
2761 }
2762
2763 FileInfo info;
2764 char scriptPath[0x40];
2765
2766 // Try the original script folder
2767 StrCopy(scriptPath, "Data/Scripts/");
2768 StrAdd(scriptPath, scriptName);
2769 if (LoadFile(scriptPath, &info)) {
2770 int readMode = READMODE_NORMAL;
2771 int parseMode = PARSEMODE_SCOPELESS;
2772 char prevChar = 0;
2773 char curChar = 0;
2774 int switchDeep = 0;
2775
2776 while (readMode < READMODE_EOF) {
2777 int textPos = 0;
2778 readMode = READMODE_NORMAL;
2779 bool disableLineIncrement = false;
2780
2781 while (readMode < READMODE_ENDLINE) {
2782 prevChar = curChar;
2783 FileRead(&curChar, 1);
2784 if (readMode == READMODE_STRING) {
2785 if (curChar == '\t' || curChar == '\r' || curChar == '\n' || curChar == ';' || readMode >= READMODE_COMMENTLINE) {
2786 if ((curChar == '\n' && prevChar != '\r') || (curChar == '\n' && prevChar == '\r')) {
2787 readMode = READMODE_ENDLINE;
2788 scriptText[textPos] = 0;
2789 if (curChar == ';')
2790 disableLineIncrement = true;
2791 }
2792 }

Callers 1

Scene.cppFile · 0.85

Calls 15

StrCopyFunction · 0.85
StrAddFunction · 0.85
FileReadFunction · 0.85
ReachedEndOfFileFunction · 0.85
CheckAliasTextFunction · 0.85
CheckStaticTextFunction · 0.85
CheckTableTextFunction · 0.85
StrCompFunction · 0.85
FindStringTokenFunction · 0.85
PrintLogFunction · 0.85
ConvertSwitchStatementFunction · 0.85

Tested by

no test coverage detected