fix line endings and tabs

This commit is contained in:
ineed bots
2023-09-01 10:50:11 -06:00
parent b17a56a7fd
commit bb216441bf
40 changed files with 22114 additions and 22115 deletions

View File

@ -3,434 +3,434 @@
namespace codsrc
{
// Restored inlined function
int Scr_IsInOpcodeMemory(game::scriptInstance_t inst, const char* pos)
{
assert(game::gScrVarPub[inst].programBuffer);
assert(pos);
// Restored inlined function
int Scr_IsInOpcodeMemory(game::scriptInstance_t inst, const char* pos)
{
assert(game::gScrVarPub[inst].programBuffer);
assert(pos);
return (unsigned int)(pos - game::gScrVarPub[inst].programBuffer) < game::gScrCompilePub[inst].programLen;
}
return (unsigned int)(pos - game::gScrVarPub[inst].programBuffer) < game::gScrCompilePub[inst].programLen;
}
// Decomp Status: Completed
bool Scr_IsIdentifier(char* token)
{
while ( *token )
{
if (!iscsym(*token))
{
return false;
}
// Decomp Status: Completed
bool Scr_IsIdentifier(char* token)
{
while ( *token )
{
if (!iscsym(*token))
{
return false;
}
++token;
}
return true;
}
++token;
}
return true;
}
// Decomp Status: Completed
unsigned int Scr_GetFunctionHandle(const char* file, game::scriptInstance_t inst, const char* handle)
{
assert(game::gScrCompilePub[inst].scriptsPos);
assert(strlen(file) < 0x40);
// Decomp Status: Completed
unsigned int Scr_GetFunctionHandle(const char* file, game::scriptInstance_t inst, const char* handle)
{
assert(game::gScrCompilePub[inst].scriptsPos);
assert(strlen(file) < 0x40);
unsigned int fileNameHash = game::Scr_CreateCanonicalFilename(inst, file);
int id = game::FindVariable(fileNameHash, game::gScrCompilePub[inst].scriptsPos, inst);
unsigned int fileNameHash = game::Scr_CreateCanonicalFilename(inst, file);
int id = game::FindVariable(fileNameHash, game::gScrCompilePub[inst].scriptsPos, inst);
game::SL_RemoveRefToString(fileNameHash, inst);
game::SL_RemoveRefToString(fileNameHash, inst);
if (!id)
{
return 0;
}
if (!id)
{
return 0;
}
unsigned int posId = game::FindObject(inst, id);
unsigned int str = game::SL_FindLowercaseString(handle, inst);
if (!str)
{
return 0;
}
unsigned int posId = game::FindObject(inst, id);
unsigned int str = game::SL_FindLowercaseString(handle, inst);
if (!str)
{
return 0;
}
unsigned int filePosId = game::FindVariable(str, posId, inst);
if (!filePosId)
{
return 0;
}
unsigned int filePosId = game::FindVariable(str, posId, inst);
if (!filePosId)
{
return 0;
}
game::VariableValue val = game::Scr_EvalVariable(inst, filePosId);
game::VariableValue val = game::Scr_EvalVariable(inst, filePosId);
assert(val.type == game::VAR_CODEPOS);
assert(val.type == game::VAR_CODEPOS);
const char* pos = val.u.codePosValue;
if (!game::Scr_IsInOpcodeMemory(inst, pos))
{
return 0;
}
const char* pos = val.u.codePosValue;
if (!game::Scr_IsInOpcodeMemory(inst, pos))
{
return 0;
}
assert(pos - game::gScrVarPub[inst].programBuffer);
assert(pos - game::gScrVarPub[inst].programBuffer);
assert(pos > game::gScrVarPub[inst].programBuffer);
assert(pos > game::gScrVarPub[inst].programBuffer);
return pos - game::gScrVarPub[inst].programBuffer;
}
return pos - game::gScrVarPub[inst].programBuffer;
}
// Decomp Status: Completed
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue)
{
assert(stringValue);
// Decomp Status: Completed
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue)
{
assert(stringValue);
game::SL_TransferRefToUser(stringValue, 2u, inst);
game::SL_TransferRefToUser(stringValue, 2u, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[stringValue] )
{
return game::gScrCompilePub[inst].canonicalStrings[stringValue];
}
if ( game::gScrCompilePub[inst].canonicalStrings[stringValue] )
{
return game::gScrCompilePub[inst].canonicalStrings[stringValue];
}
game::gScrCompilePub[inst].canonicalStrings[stringValue] = ++game::gScrVarPub[inst].canonicalStrCount;
game::gScrCompilePub[inst].canonicalStrings[stringValue] = ++game::gScrVarPub[inst].canonicalStrCount;
return game::gScrVarPub[inst].canonicalStrCount;
}
return game::gScrVarPub[inst].canonicalStrCount;
}
// Decomp Status: Tested, Completed
unsigned int SL_GetCanonicalString(char* token, game::scriptInstance_t inst)
{
unsigned int str;
// Decomp Status: Tested, Completed
unsigned int SL_GetCanonicalString(char* token, game::scriptInstance_t inst)
{
unsigned int str;
str = game::SL_FindString(token, inst);
str = game::SL_FindString(token, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[str] )
{
return game::gScrCompilePub[inst].canonicalStrings[str];
}
if ( game::gScrCompilePub[inst].canonicalStrings[str] )
{
return game::gScrCompilePub[inst].canonicalStrings[str];
}
str = game::SL_GetString_(token, inst, 0);
str = game::SL_GetString_(token, inst, 0);
return game::SL_TransferToCanonicalString(inst, str);
}
return game::SL_TransferToCanonicalString(inst, str);
}
// Restored
void SL_BeginLoadScripts(game::scriptInstance_t inst)
{
memset(game::gScrCompilePub[inst].canonicalStrings, 0, sizeof(game::gScrCompilePub[inst].canonicalStrings));
game::gScrVarPub[inst].canonicalStrCount = 0;
}
// Restored
void SL_BeginLoadScripts(game::scriptInstance_t inst)
{
memset(game::gScrCompilePub[inst].canonicalStrings, 0, sizeof(game::gScrCompilePub[inst].canonicalStrings));
game::gScrVarPub[inst].canonicalStrCount = 0;
}
// Restored
void Scr_SetLoadedImpureScript(bool loadedImpureScript)
{
*game::loadedImpureScript = loadedImpureScript;
}
// Restored
void Scr_SetLoadedImpureScript(bool loadedImpureScript)
{
*game::loadedImpureScript = loadedImpureScript;
}
// Decomp Status: Tested, Completed
void Scr_BeginLoadScripts(game::scriptInstance_t inst, int user)
{
assert(!game::gScrCompilePub[inst].script_loading);
// Decomp Status: Tested, Completed
void Scr_BeginLoadScripts(game::scriptInstance_t inst, int user)
{
assert(!game::gScrCompilePub[inst].script_loading);
game::gScrCompilePub[inst].script_loading = 1;
game::gScrCompilePub[inst].script_loading = 1;
game::Scr_InitOpcodeLookup(inst);
game::Scr_InitOpcodeLookup(inst);
assert(!game::gScrCompilePub[inst].loadedscripts);
assert(!game::gScrCompilePub[inst].loadedscripts);
game::gScrCompilePub[inst].loadedscripts = game::Scr_AllocArray(inst);
game::gScrCompilePub[inst].loadedscripts = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].scriptsPos);
assert(!game::gScrCompilePub[inst].scriptsPos);
game::gScrCompilePub[inst].scriptsPos = game::Scr_AllocArray(inst);
game::gScrCompilePub[inst].scriptsPos = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].scriptsCount);
game::gScrCompilePub[inst].scriptsCount = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinFunc);
game::gScrCompilePub[inst].builtinFunc = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinMeth);
game::gScrCompilePub[inst].builtinMeth = game::Scr_AllocArray(inst);
game::gScrVarPub[inst].programHunkUser = game::Hunk_UserCreate(0x100000, "Scr_BeginLoadScripts", 1, 0, 0, 7);
game::TempMemoryReset(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programBuffer = game::TempMalloc(0);
assert(((int)game::gScrVarPub[inst].programBuffer & 0x1F) == 0);
assert(!game::gScrCompilePub[inst].scriptsCount);
game::gScrCompilePub[inst].scriptsCount = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinFunc);
game::gScrCompilePub[inst].builtinFunc = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinMeth);
game::gScrCompilePub[inst].builtinMeth = game::Scr_AllocArray(inst);
game::gScrVarPub[inst].programHunkUser = game::Hunk_UserCreate(0x100000, "Scr_BeginLoadScripts", 1, 0, 0, 7);
game::TempMemoryReset(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programBuffer = game::TempMalloc(0);
assert(((int)game::gScrVarPub[inst].programBuffer & 0x1F) == 0);
game::gScrCompilePub[inst].programLen = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::SL_BeginLoadScripts(inst);
game::gScrVarPub[inst].fieldBuffer = 0;
game::gScrCompilePub[inst].value_count = 0;
game::gScrVarPub[inst].error_message = 0;
game::gScrVmGlob[inst].dialog_error_message = 0;
game::gScrVarPub[inst].error_index = 0;
game::gScrCompilePub[inst].func_table_size = 0;
game::Scr_SetLoadedImpureScript(false);
game::gScrAnimPub[inst].animTreeNames = 0;
game::Scr_BeginLoadAnimTrees(inst, user);
}
// Decomp Status: Completed
void Scr_BeginLoadAnimTrees(game::scriptInstance_t inst, int user)
{
assert(!game::gScrAnimPub[inst].animtree_loading);
game::gScrAnimPub[inst].animtree_loading = 1;
game::gScrAnimPub[inst].xanim_num[user] = 0;
game::gScrAnimPub[inst].xanim_lookup[user][0].anims = 0;
assert(!game::gScrAnimPub[inst].animtrees);
game::gScrAnimPub[inst].animtrees = game::Scr_AllocArray(inst);
game::gScrAnimPub[inst].animtree_node = 0;
game::gScrCompilePub[inst].developer_statement = 0;
}
// Decomp Status: Completed
int Scr_ScanFile(int max_size, char* buf)
{
char c;
int n;
game::scriptInstance_t inst;
inst = *game::gInst;
c = '*';
for ( n = 0;
n < max_size;
++n )
{
c = *game::gScrCompilePub[inst].in_ptr++;
if ( !c || c == '\n')
{
break;
}
buf[n] = c;
}
if ( c == '\n')
{
buf[n++] = c;
}
else if ( !c )
{
if ( game::gScrCompilePub[inst].parseBuf )
{
game::gScrCompilePub[inst].in_ptr = game::gScrCompilePub[inst].parseBuf;
game::gScrCompilePub[inst].parseBuf = 0;
}
else
{
--game::gScrCompilePub[inst].in_ptr;
}
}
return n;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScriptInternal(game::scriptInstance_t inst, const char* filename, game::PrecacheEntry* entries, int entriesCount)
{
unsigned int scriptPosVar;
unsigned int scriptCountVar;
const char *codepos;
char extFilename[64];
unsigned int fileCountId;
unsigned int filePosPtr;
char *sourceBuffer;
const char *oldFilename;
unsigned int name;
unsigned int oldAnimTreeNames;
const char *oldSourceBuf;
unsigned int scriptId;
unsigned int filePosId;
const char *formatExtString;
game::sval_u parseData;
assert(game::gScrCompilePub[inst].script_loading);
assert(strlen(filename) < 0x40);
name = game::Scr_CreateCanonicalFilename(inst, filename);
if ( game::FindVariable(name, game::gScrCompilePub[inst].loadedscripts, inst) )
{
game::SL_RemoveRefToString(name, inst);
filePosPtr = game::FindVariable(name, game::gScrCompilePub[inst].scriptsPos, inst);
if ( filePosPtr )
{
return game::FindObject(inst, filePosPtr);
}
return 0;
}
scriptId = game::GetNewVariable(inst, name, game::gScrCompilePub[inst].loadedscripts);
game::SL_RemoveRefToString(name, inst);
formatExtString = "%s.gsc";
if ( inst == game::SCRIPTINSTANCE_CLIENT && !strncmp(filename, "clientscripts", 13) )
{
formatExtString = "%s.csc";
}
snprintf(extFilename, 64, formatExtString, filename);
oldSourceBuf = game::gScrParserPub[inst].sourceBuf;
codepos = (const char *)game::TempMalloc(0);
sourceBuffer = game::Scr_AddSourceBuffer(inst, (int)filename, extFilename, codepos);
if (!sourceBuffer)
{
return 0;
}
oldAnimTreeNames = game::gScrAnimPub[inst].animTreeNames;
game::gScrAnimPub[inst].animTreeNames = 0;
game::gScrCompilePub[inst].far_function_count = 0;
game::Scr_InitAllocNode(inst);
oldFilename = game::gScrParserPub[inst].scriptfilename;
game::gScrParserPub[inst].scriptfilename = extFilename;
game:: gScrCompilePub[inst].in_ptr = "+";
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
game::ScriptParse(inst, &parseData);
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
filePosId = game::GetObject(inst, scriptPosVar);
scriptCountVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsCount, name);
fileCountId = game::GetObject(inst, scriptCountVar);
game::ScriptCompile(inst, parseData, filePosId, fileCountId, scriptId, entries, entriesCount);
game::gScrParserPub[inst].scriptfilename = oldFilename;
game::gScrParserPub[inst].sourceBuf = oldSourceBuf;
game::gScrAnimPub[inst].animTreeNames = oldAnimTreeNames;
return filePosId;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScript(const char* file, game::scriptInstance_t inst)
{
game::PrecacheEntry entries[1024];
return game::Scr_LoadScriptInternal(inst, file, entries, 0);
}
// Decomp Status: Tested, Completed
void Scr_EndLoadScripts(game::scriptInstance_t inst)
{
// pluto
game::plutonium::load_custom_script_func(inst);
//
game::SL_ShutdownSystem(inst, 2u);
game::gScrCompilePub[inst].script_loading = 0;
assert(game::gScrCompilePub[inst].loadedscripts);
game::ClearObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::gScrCompilePub[inst].loadedscripts = 0;
assert(game::gScrCompilePub[inst].scriptsPos);
game::ClearObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::gScrCompilePub[inst].scriptsPos = 0;
assert(game::gScrCompilePub[inst].scriptsCount);
game::ClearObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::gScrCompilePub[inst].scriptsCount = 0;
assert(game::gScrCompilePub[inst].builtinFunc);
game::ClearObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::gScrCompilePub[inst].builtinFunc = 0;
assert(game::gScrCompilePub[inst].builtinMeth);
game::ClearObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::gScrCompilePub[inst].builtinMeth = 0;
}
// Decomp Status: Tested, Completed
void Scr_PrecacheAnimTrees(game::scriptInstance_t inst, void* (__cdecl *Alloc)(int), int user, int modChecksum)
{
unsigned int i;
for (i = 1; i <= game::gScrAnimPub[inst].xanim_num[user]; ++i)
{
game::Scr_LoadAnimTreeAtIndex(inst, user, i, Alloc, modChecksum);
}
}
// Decomp Status: Tested, Completed
void Scr_EndLoadAnimTrees(game::scriptInstance_t inst)
{
unsigned int animtreeNode;
assert(game::gScrAnimPub[inst].animtrees);
game::ClearObject(game::gScrAnimPub[inst].animtrees, inst);
game::RemoveRefToObject(game::gScrAnimPub[inst].animtrees, inst);
animtreeNode = game::gScrAnimPub[inst].animtree_node;
game::gScrAnimPub[inst].animtrees = 0;
if (animtreeNode)
{
game::RemoveRefToObject(animtreeNode, inst);
}
game::SL_ShutdownSystem(inst, 2u);
if (game::gScrVarPub[inst].programBuffer && !game::gScrVarPub[inst].endScriptBuffer)
{
game::gScrVarPub[inst].endScriptBuffer = game::TempMalloc(0);
}
game::gScrAnimPub[inst].animtree_loading = 0;
}
// Decomp Status: Tested, Completed
void Scr_FreeScripts(game::scriptInstance_t inst)
{
//char sys = 1;
//assert(sys == SCR_SYS_GAME);
if (game::gScrCompilePub[inst].script_loading)
{
game::gScrCompilePub[inst].script_loading = 0;
game::Scr_EndLoadScripts(inst);
}
if (game::gScrAnimPub[inst].animtree_loading)
{
game::gScrAnimPub[inst].animtree_loading = 0;
game::Scr_EndLoadAnimTrees(inst);
}
game::SL_ShutdownSystem(inst, 1u);
game::Scr_ShutdownOpcodeLookup(inst);
if (game::gScrVarPub[inst].programHunkUser)
{
game::Hunk_UserDestroy(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programHunkUser = 0;
}
game::gScrVarPub[inst].programBuffer = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::gScrVarPub[inst].checksum = 0;
game::gScrCompilePub[inst].programLen = 0;
}
game::gScrCompilePub[inst].programLen = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::SL_BeginLoadScripts(inst);
game::gScrVarPub[inst].fieldBuffer = 0;
game::gScrCompilePub[inst].value_count = 0;
game::gScrVarPub[inst].error_message = 0;
game::gScrVmGlob[inst].dialog_error_message = 0;
game::gScrVarPub[inst].error_index = 0;
game::gScrCompilePub[inst].func_table_size = 0;
game::Scr_SetLoadedImpureScript(false);
game::gScrAnimPub[inst].animTreeNames = 0;
game::Scr_BeginLoadAnimTrees(inst, user);
}
// Decomp Status: Completed
void Scr_BeginLoadAnimTrees(game::scriptInstance_t inst, int user)
{
assert(!game::gScrAnimPub[inst].animtree_loading);
game::gScrAnimPub[inst].animtree_loading = 1;
game::gScrAnimPub[inst].xanim_num[user] = 0;
game::gScrAnimPub[inst].xanim_lookup[user][0].anims = 0;
assert(!game::gScrAnimPub[inst].animtrees);
game::gScrAnimPub[inst].animtrees = game::Scr_AllocArray(inst);
game::gScrAnimPub[inst].animtree_node = 0;
game::gScrCompilePub[inst].developer_statement = 0;
}
// Decomp Status: Completed
int Scr_ScanFile(int max_size, char* buf)
{
char c;
int n;
game::scriptInstance_t inst;
inst = *game::gInst;
c = '*';
for ( n = 0;
n < max_size;
++n )
{
c = *game::gScrCompilePub[inst].in_ptr++;
if ( !c || c == '\n')
{
break;
}
buf[n] = c;
}
if ( c == '\n')
{
buf[n++] = c;
}
else if ( !c )
{
if ( game::gScrCompilePub[inst].parseBuf )
{
game::gScrCompilePub[inst].in_ptr = game::gScrCompilePub[inst].parseBuf;
game::gScrCompilePub[inst].parseBuf = 0;
}
else
{
--game::gScrCompilePub[inst].in_ptr;
}
}
return n;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScriptInternal(game::scriptInstance_t inst, const char* filename, game::PrecacheEntry* entries, int entriesCount)
{
unsigned int scriptPosVar;
unsigned int scriptCountVar;
const char *codepos;
char extFilename[64];
unsigned int fileCountId;
unsigned int filePosPtr;
char *sourceBuffer;
const char *oldFilename;
unsigned int name;
unsigned int oldAnimTreeNames;
const char *oldSourceBuf;
unsigned int scriptId;
unsigned int filePosId;
const char *formatExtString;
game::sval_u parseData;
assert(game::gScrCompilePub[inst].script_loading);
assert(strlen(filename) < 0x40);
name = game::Scr_CreateCanonicalFilename(inst, filename);
if ( game::FindVariable(name, game::gScrCompilePub[inst].loadedscripts, inst) )
{
game::SL_RemoveRefToString(name, inst);
filePosPtr = game::FindVariable(name, game::gScrCompilePub[inst].scriptsPos, inst);
if ( filePosPtr )
{
return game::FindObject(inst, filePosPtr);
}
return 0;
}
scriptId = game::GetNewVariable(inst, name, game::gScrCompilePub[inst].loadedscripts);
game::SL_RemoveRefToString(name, inst);
formatExtString = "%s.gsc";
if ( inst == game::SCRIPTINSTANCE_CLIENT && !strncmp(filename, "clientscripts", 13) )
{
formatExtString = "%s.csc";
}
snprintf(extFilename, 64, formatExtString, filename);
oldSourceBuf = game::gScrParserPub[inst].sourceBuf;
codepos = (const char *)game::TempMalloc(0);
sourceBuffer = game::Scr_AddSourceBuffer(inst, (int)filename, extFilename, codepos);
if (!sourceBuffer)
{
return 0;
}
oldAnimTreeNames = game::gScrAnimPub[inst].animTreeNames;
game::gScrAnimPub[inst].animTreeNames = 0;
game::gScrCompilePub[inst].far_function_count = 0;
game::Scr_InitAllocNode(inst);
oldFilename = game::gScrParserPub[inst].scriptfilename;
game::gScrParserPub[inst].scriptfilename = extFilename;
game:: gScrCompilePub[inst].in_ptr = "+";
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
game::ScriptParse(inst, &parseData);
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
filePosId = game::GetObject(inst, scriptPosVar);
scriptCountVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsCount, name);
fileCountId = game::GetObject(inst, scriptCountVar);
game::ScriptCompile(inst, parseData, filePosId, fileCountId, scriptId, entries, entriesCount);
game::gScrParserPub[inst].scriptfilename = oldFilename;
game::gScrParserPub[inst].sourceBuf = oldSourceBuf;
game::gScrAnimPub[inst].animTreeNames = oldAnimTreeNames;
return filePosId;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScript(const char* file, game::scriptInstance_t inst)
{
game::PrecacheEntry entries[1024];
return game::Scr_LoadScriptInternal(inst, file, entries, 0);
}
// Decomp Status: Tested, Completed
void Scr_EndLoadScripts(game::scriptInstance_t inst)
{
// pluto
game::plutonium::load_custom_script_func(inst);
//
game::SL_ShutdownSystem(inst, 2u);
game::gScrCompilePub[inst].script_loading = 0;
assert(game::gScrCompilePub[inst].loadedscripts);
game::ClearObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::gScrCompilePub[inst].loadedscripts = 0;
assert(game::gScrCompilePub[inst].scriptsPos);
game::ClearObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::gScrCompilePub[inst].scriptsPos = 0;
assert(game::gScrCompilePub[inst].scriptsCount);
game::ClearObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::gScrCompilePub[inst].scriptsCount = 0;
assert(game::gScrCompilePub[inst].builtinFunc);
game::ClearObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::gScrCompilePub[inst].builtinFunc = 0;
assert(game::gScrCompilePub[inst].builtinMeth);
game::ClearObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::gScrCompilePub[inst].builtinMeth = 0;
}
// Decomp Status: Tested, Completed
void Scr_PrecacheAnimTrees(game::scriptInstance_t inst, void* (__cdecl *Alloc)(int), int user, int modChecksum)
{
unsigned int i;
for (i = 1; i <= game::gScrAnimPub[inst].xanim_num[user]; ++i)
{
game::Scr_LoadAnimTreeAtIndex(inst, user, i, Alloc, modChecksum);
}
}
// Decomp Status: Tested, Completed
void Scr_EndLoadAnimTrees(game::scriptInstance_t inst)
{
unsigned int animtreeNode;
assert(game::gScrAnimPub[inst].animtrees);
game::ClearObject(game::gScrAnimPub[inst].animtrees, inst);
game::RemoveRefToObject(game::gScrAnimPub[inst].animtrees, inst);
animtreeNode = game::gScrAnimPub[inst].animtree_node;
game::gScrAnimPub[inst].animtrees = 0;
if (animtreeNode)
{
game::RemoveRefToObject(animtreeNode, inst);
}
game::SL_ShutdownSystem(inst, 2u);
if (game::gScrVarPub[inst].programBuffer && !game::gScrVarPub[inst].endScriptBuffer)
{
game::gScrVarPub[inst].endScriptBuffer = game::TempMalloc(0);
}
game::gScrAnimPub[inst].animtree_loading = 0;
}
// Decomp Status: Tested, Completed
void Scr_FreeScripts(game::scriptInstance_t inst)
{
//char sys = 1;
//assert(sys == SCR_SYS_GAME);
if (game::gScrCompilePub[inst].script_loading)
{
game::gScrCompilePub[inst].script_loading = 0;
game::Scr_EndLoadScripts(inst);
}
if (game::gScrAnimPub[inst].animtree_loading)
{
game::gScrAnimPub[inst].animtree_loading = 0;
game::Scr_EndLoadAnimTrees(inst);
}
game::SL_ShutdownSystem(inst, 1u);
game::Scr_ShutdownOpcodeLookup(inst);
if (game::gScrVarPub[inst].programHunkUser)
{
game::Hunk_UserDestroy(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programHunkUser = 0;
}
game::gScrVarPub[inst].programBuffer = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::gScrVarPub[inst].checksum = 0;
game::gScrCompilePub[inst].programLen = 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -21,9 +21,9 @@ namespace codsrc
return game::FindVariableIndexInternal2(inst, name, (parentId + name) % 0xFFFD + 1);
}
// Decomp Status: Tested, Completed
unsigned int FindVariableIndexInternal2(game::scriptInstance_t inst, unsigned int name, unsigned int index)
{
// Decomp Status: Tested, Completed
unsigned int FindVariableIndexInternal2(game::scriptInstance_t inst, unsigned int name, unsigned int index)
{
unsigned int newIndex;
game::VariableValueInternal* newEntryValue;
game::VariableValueInternal* entryValue;
@ -76,11 +76,11 @@ namespace codsrc
}
return 0;
}
}
// Decomp Status: Tested, Completed
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst)
{
// Decomp Status: Tested, Completed
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst)
{
game::VariableValueInternal* parentValue;
unsigned int nextParentVarIndex;
unsigned int id;
@ -101,10 +101,10 @@ namespace codsrc
id = game::gScrVarGlob[inst].parentVariables[nextParentVarIndex].hash.u.prev;
if (!id)
{
return 0;
}
if (!id)
{
return 0;
}
childVarName = game::gScrVarGlob[inst].childVariables[id].w.status >> VAR_NAME_BIT_SHIFT;
@ -113,5 +113,5 @@ namespace codsrc
assert(index);
return index;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,21 +3,21 @@
namespace codsrc
{
// Restored
char* TempMalloc(int len)
{
return (char *)game::Hunk_UserAlloc(*game::g_user, len, 1);
}
// Restored
char* TempMalloc(int len)
{
return (char *)game::Hunk_UserAlloc(*game::g_user, len, 1);
}
// Restored
void TempMemoryReset(game::HunkUser* user)
{
*game::g_user = user;
}
// Restored
void TempMemoryReset(game::HunkUser* user)
{
*game::g_user = user;
}
// Restored
void TempMemorySetPos(char* pos)
{
(*game::g_user)->pos = (int)pos;
}
// Restored
void TempMemorySetPos(char* pos)
{
(*game::g_user)->pos = (int)pos;
}
}

View File

@ -1108,16 +1108,16 @@ namespace codsrc
game::gScrVmPub[inst].function_frame->fs.pos = game::gFs[inst].pos;
/*
if ( gScrVmGlob[inst].recordPlace )
Scr_GetFileAndLine(inst, localFs.pos, &gScrVmGlob[inst].lastFileName, &gScrVmGlob[inst].lastLine);
if ( gScrVmDebugPub[inst].func_table[builtinIndex].breakpointCount )
{
if ( gScrVmPub[inst].top != localFs.top - 1 && !Assert_MyHandler("C:\\projects_pc\\cod\\codsrc\\src\\clientscript\\cscr_vm.cpp", 1611, 0, "%s", "gScrVmPub[inst].top == localFs.top - 1") )
__debugbreak();
v104 = gScrVmPub[inst].outparamcount;
Scr_HitBuiltinBreakpoint(inst, localFs.top, debugpos, localFs.localId, gOpcode[inst], builtinIndex, v104 + 1);
gScrVmPub[inst].outparamcount = v104;
gScrVmPub[inst].top = localFs.top - 1;
}*/
Scr_GetFileAndLine(inst, localFs.pos, &gScrVmGlob[inst].lastFileName, &gScrVmGlob[inst].lastLine);
if ( gScrVmDebugPub[inst].func_table[builtinIndex].breakpointCount )
{
if ( gScrVmPub[inst].top != localFs.top - 1 && !Assert_MyHandler("C:\\projects_pc\\cod\\codsrc\\src\\clientscript\\cscr_vm.cpp", 1611, 0, "%s", "gScrVmPub[inst].top == localFs.top - 1") )
__debugbreak();
v104 = gScrVmPub[inst].outparamcount;
Scr_HitBuiltinBreakpoint(inst, localFs.top, debugpos, localFs.localId, gOpcode[inst], builtinIndex, v104 + 1);
gScrVmPub[inst].outparamcount = v104;
gScrVmPub[inst].top = localFs.top - 1;
}*/
assert(builtinIndex >= 0);
assert(builtinIndex < 1024);
@ -5442,7 +5442,7 @@ namespace codsrc
}
else
{
return game::CScr_SetEntityField(offset, entnum, clientNum);
return game::CScr_SetEntityField(offset, entnum, clientNum);
}
}