diff --git a/FalloutScript.cpp b/FalloutScript.cpp index cb8d6bb..6be32c9 100644 --- a/FalloutScript.cpp +++ b/FalloutScript.cpp @@ -37,7 +37,7 @@ void CFalloutScript::Serialize(CArchive& ar) // Sections with variable sizes ar.Flush(); - ULONG ullCurrentOffset = ar.GetFile()->GetPosition(); + uint32_t ullCurrentOffset = ar.GetFile()->GetPosition(); // Load globals m_GlobalVar.RemoveAll(); @@ -60,7 +60,7 @@ void CFalloutScript::Serialize(CArchive& ar) if (!HeaderTail.IsEmpty()) { INT_PTR nIndexOfStart = GetIndexOfProc("start"); - ULONG ulStartProcAddress = (nIndexOfStart != -1) ? m_ProcTable[nIndexOfStart].m_ulBodyOffset : 18; + uint32_t ulStartProcAddress = (nIndexOfStart != -1) ? m_ProcTable[nIndexOfStart].m_ulBodyOffset : 18; opcode = HeaderTail[HeaderTail.GetUpperBound()]; @@ -196,8 +196,8 @@ void CFalloutScript::Serialize(CArchive& ar) for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\r", i); - ULONG ulOffset = m_ProcTable[i].m_ulBodyOffset; - ULONG ulSize = m_ProcTable.GetSizeOfProc(i); + uint32_t ulOffset = m_ProcTable[i].m_ulBodyOffset; + uint32_t ulSize = m_ProcTable.GetSizeOfProc(i); ar.Flush(); ar.GetFile()->Seek(ulOffset, CFile::begin); diff --git a/FalloutScript.h b/FalloutScript.h index a77e3bf..5ab9e55 100644 --- a/FalloutScript.h +++ b/FalloutScript.h @@ -43,10 +43,10 @@ private: bool CheckExportProcCode(uint16_t wOperator, INT_PTR nIndex); INT_PTR GetIndexOfProc(const char* lpszName); - INT_PTR GetIndexOfProc(ULONG ulNameOffset); - INT_PTR GetIndexOfExportedVariable(ULONG ulNameOffset); + INT_PTR GetIndexOfProc(uint32_t ulNameOffset); + INT_PTR GetIndexOfExportedVariable(uint32_t ulNameOffset); - void SetExternalVariable(ULONG ulNameOffset); + void SetExternalVariable(uint32_t ulNameOffset); void TryRenameGlobalVariables(); void TryRenameImportedVariables(); @@ -58,15 +58,15 @@ private: void BuildTree(CNodeArray& NodeArray); void ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, INT_PTR nStartIndex); void SetBordersOfBlocks(CNodeArray& NodeArray); - ULONG BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, ULONG ulEndOffset); + uint32_t BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartIndex, uint32_t ulEndOffset); void ReduceConditionalExpressions(CNodeArray& NodeArray); bool IsOmittetArgsAllowed(uint16_t wOpcode); void StoreDefinitions(CArchive& ar); void StoreDeclarations(CArchive& ar); - std::string GetSource( CNode& node, bool bLabel, ULONG ulNumArgs); - std::string GetSource( CNode& node, bool bLabel, ULONG ulNumArgs, ULONG aulProcArg[], ULONG ulProcArgCount); + std::string GetSource( CNode& node, bool bLabel, uint32_t ulNumArgs); + std::string GetSource( CNode& node, bool bLabel, uint32_t ulNumArgs, uint32_t aulProcArg[], uint32_t ulProcArgCount); bool ArgNeedParens(const CNode& node, const CNode& argument, CFalloutScript::Assoc assoc = CFalloutScript::NON_ASSOC); std::string GetIndentString(INT_PTR nLevel); @@ -84,21 +84,21 @@ private: }; public: - CDefObject(ObjectType type = OBJECT_VARIABLE, ULONG ulAttributes = 0, ULONG ulObjectData = 0); + CDefObject(ObjectType type = OBJECT_VARIABLE, uint32_t ulAttributes = 0, uint32_t ulObjectData = 0); public: ObjectType m_ObjectType; - ULONG m_ulAttributes; + uint32_t m_ulAttributes; union { - ULONG m_ulVarValue; - ULONG m_ulProcIndex; + uint32_t m_ulVarValue; + uint32_t m_ulProcIndex; }; }; private: - // CMapULongToDefObject - typedef CMap CMapULongToDefObject; + // CMapuint32_tToDefObject + typedef CMap CMapuint32_tToDefObject; CStartupCode m_StartupCode; CProcTable m_ProcTable; @@ -113,7 +113,7 @@ private: CArrayOfNodeArray m_ProcBodies; CArrayOfNodeArray m_Conditions; - CMapULongToDefObject m_Definitions; + CMapuint32_tToDefObject m_Definitions; std::vector m_GlobalVarsNames; }; diff --git a/FalloutScriptDecompile.cpp b/FalloutScriptDecompile.cpp index bee843f..2840609 100644 --- a/FalloutScriptDecompile.cpp +++ b/FalloutScriptDecompile.cpp @@ -12,7 +12,7 @@ extern bool g_bInsOmittedArgsBackward; void CFalloutScript::InitDefinitions() { - ULONG ulNameOffset; + uint32_t ulNameOffset; INT_PTR nObjectIndex; std::string c_strGlobalVarTemplate("GVar%u"); @@ -25,12 +25,12 @@ void CFalloutScript::InitDefinitions() if ((nObjectIndex = GetIndexOfProc(ulNameOffset)) != -1) { - m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_PROCEDURE, 0, ULONG(nObjectIndex))); + m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_PROCEDURE, 0, uint32_t(nObjectIndex))); } else if ((nObjectIndex = GetIndexOfExportedVariable(ulNameOffset)) != -1) { uint16_t wOpcode = m_ExportedVarValue[nObjectIndex].GetOperator(); - ULONG ulValue = m_ExportedVarValue[nObjectIndex].GetArgument(); + uint32_t ulValue = m_ExportedVarValue[nObjectIndex].GetArgument(); m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_EXPORT | wOpcode, ulValue)); } @@ -79,7 +79,7 @@ void CFalloutScript::ProcessCode() AfxThrowUserException(); } - ULONG ulCondStartAddress = node.m_Opcode.GetArgument(); + uint32_t ulCondStartAddress = node.m_Opcode.GetArgument(); do { @@ -134,7 +134,7 @@ INT_PTR CFalloutScript::GetIndexOfProc(const char* lpszName) return nResult; } -INT_PTR CFalloutScript::GetIndexOfProc(ULONG ulNameOffset) +INT_PTR CFalloutScript::GetIndexOfProc(uint32_t ulNameOffset) { INT_PTR nResult = -1; @@ -150,7 +150,7 @@ INT_PTR CFalloutScript::GetIndexOfProc(ULONG ulNameOffset) return nResult; } -INT_PTR CFalloutScript::GetIndexOfExportedVariable(ULONG ulNameOffset) +INT_PTR CFalloutScript::GetIndexOfExportedVariable(uint32_t ulNameOffset) { INT_PTR nResult = -1; @@ -166,7 +166,7 @@ INT_PTR CFalloutScript::GetIndexOfExportedVariable(ULONG ulNameOffset) return nResult; } -void CFalloutScript::SetExternalVariable(ULONG ulNameOffset) +void CFalloutScript::SetExternalVariable(uint32_t ulNameOffset) { CDefObject defObject; @@ -206,7 +206,7 @@ void CFalloutScript::TryRenameGlobalVariables() void CFalloutScript::TryRenameImportedVariables() { CDefObject defObject; - ULONG ulNameOffset; + uint32_t ulNameOffset; if (m_GlobalVar.GetSize() == 0) { @@ -402,10 +402,10 @@ void CFalloutScript::InitialReduce() } // build tree for all nodes from nStartIndex to file offset ulEndOffset (not including) -ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, ULONG ulEndOffset) +uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartIndex, uint32_t ulEndOffset) { uint16_t wOperator; - ULONG ulArgument; + uint32_t ulArgument; INT_PTR nNumOfArgs; COpcode::COpcodeAttributes opcodeAttributes; @@ -425,7 +425,7 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, { INT_PTR nExtVarNameNodeIndex = NextNodeIndex(NodeArray, j, -1); uint16_t wOpeartor = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetOperator(); - ULONG ulArgument = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetArgument(); + uint32_t ulArgument = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetArgument(); if ((wOpeartor != COpcode::O_STRINGOP) && (wOpeartor != COpcode::O_INTOP)) { @@ -441,7 +441,7 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, { INT_PTR nProcNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -2); uint16_t wProcNumOfArgsOperator = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetOperator(); - ULONG ulProcNumOfArgs = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetArgument(); + uint32_t ulProcNumOfArgs = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetArgument(); if (wProcNumOfArgsOperator != COpcode::O_INTOP) { @@ -457,7 +457,7 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, { INT_PTR nAddRegionNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -1); uint16_t wAddRegionNumOfArgsOperator = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetOperator(); - ULONG ulAddRegionNumOfArgs = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetArgument(); + uint32_t ulAddRegionNumOfArgs = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetArgument(); if (wAddRegionNumOfArgsOperator != COpcode::O_INTOP) { @@ -527,12 +527,12 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, if (wOperator == COpcode::O_IF) { // process possible conditional expression - this may be either normal IF statement or (x IF y ELSE z) expression - ULONG ulElseOffset = NodeArray[j].m_Arguments[0].m_Opcode.GetArgument(); - ULONG ulElseIndex, ulSkipIndex = -1; + uint32_t ulElseOffset = NodeArray[j].m_Arguments[0].m_Opcode.GetArgument(); + uint32_t ulElseIndex, ulSkipIndex = -1; ulElseIndex = BuildTreeBranch(NodeArray, j + 1, ulElseOffset); // true branch if (NodeArray[ulElseIndex - 1].m_Opcode.GetOperator() == COpcode::O_JMP) { - ULONG ulSkipOffset = NodeArray[ulElseIndex - 1].m_Opcode.GetArgument(); + uint32_t ulSkipOffset = NodeArray[ulElseIndex - 1].m_Opcode.GetArgument(); if (ulSkipOffset > NodeArray[j].m_ulOffset) { ulSkipIndex = BuildTreeBranch(NodeArray, ulElseIndex, ulSkipOffset); // false branch @@ -584,7 +584,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D AfxThrowUserException(); } - ULONG ulJumpOffset = node.m_Arguments[0].m_Opcode.GetArgument(); + uint32_t ulJumpOffset = node.m_Arguments[0].m_Opcode.GetArgument(); do { @@ -650,7 +650,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) return; } - ULONG ulOffset; + uint32_t ulOffset; // Start of procedure if (NodeArray[0].m_Opcode.GetOperator() == COpcode::O_PUSH_BASE) @@ -688,7 +688,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) case COpcode::O_WHILE: { CNode node = NodeArray[i].m_Arguments[0]; - ULONG loopOffset = NodeArray[i].m_Arguments[1].GetTopOffset(); + uint32_t loopOffset = NodeArray[i].m_Arguments[1].GetTopOffset(); if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { @@ -708,7 +708,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) node = NodeArray[nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, 1)]; if (node.m_Opcode.GetOperator() == COpcode::O_JMP && node.m_Type == CNode::TYPE_NORMAL && node.m_Arguments.GetSize() > 0) { - ULONG ofs = node.m_Arguments[0].m_Opcode.GetArgument(); + uint32_t ofs = node.m_Arguments[0].m_Opcode.GetArgument(); if (ofs == ulOffset) { NodeArray[nNodeIndex].m_Type = CNode::TYPE_BREAK; @@ -811,7 +811,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) printf("Error: Invalid opcode for jump-address\n"); AfxThrowUserException(); } - //ULONG jumpPastElseOffset = + //uint32_t jumpPastElseOffset = ulOffset = node.m_Arguments[0].m_Opcode.GetArgument(); //printf("(else) goto %x > %x", ulOffset, node.m_ulOffset); if (ulOffset > node.m_ulOffset) diff --git a/FalloutScriptDefObject.cpp b/FalloutScriptDefObject.cpp index 19c80cd..fba5ea5 100644 --- a/FalloutScriptDefObject.cpp +++ b/FalloutScriptDefObject.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "FalloutScript.h" -CFalloutScript::CDefObject::CDefObject(ObjectType type, ULONG ulAttributes, ULONG ulObjectData) +CFalloutScript::CDefObject::CDefObject(ObjectType type, uint32_t ulAttributes, uint32_t ulObjectData) { m_ulAttributes = ulAttributes; diff --git a/FalloutScriptDump.cpp b/FalloutScriptDump.cpp index 1975c99..6265dc5 100644 --- a/FalloutScriptDump.cpp +++ b/FalloutScriptDump.cpp @@ -23,7 +23,7 @@ void CFalloutScript::Dump(CArchive& ar) std::string strOutLine; uint16_t wOperator; - ULONG ulArgument = 0; + uint32_t ulArgument = 0; ar.WriteString("============== Global variables values ==================\n"); @@ -77,7 +77,7 @@ void CFalloutScript::Dump(CArchive& ar) { wOperator = m_ExportedVarValue[i].GetOperator(); ulArgument = m_ExportedVarValue[i].GetArgument(); - ULONG ulNameArgument = m_ExportedVarValue[i + 1].GetArgument(); + uint32_t ulNameArgument = m_ExportedVarValue[i + 1].GetArgument(); switch(wOperator) { diff --git a/FalloutScriptStore.cpp b/FalloutScriptStore.cpp index 7076b52..1ab0934 100644 --- a/FalloutScriptStore.cpp +++ b/FalloutScriptStore.cpp @@ -70,7 +70,7 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) INT_PTR nNamesCount = m_Namespace.GetSize(); INT_PTR nDefinitionsCount = m_Definitions.GetSize(); std::string strDefinition; - ULONG ulVarValue; + uint32_t ulVarValue; if (nNamesCount != nDefinitionsCount) { @@ -120,7 +120,7 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) // Named objects - ULONG ulNameOffset; + uint32_t ulNameOffset; CDefObject defObject; enum OutDefObject { @@ -188,7 +188,7 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) { strDefinition += "("; - for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) + for(uint32_t i = 0; i < procDescriptor.m_ulNumArgs; i++) { if (i == 0) { @@ -364,7 +364,7 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) { strOutLine += "("; - for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) + for(uint32_t i = 0; i < procDescriptor.m_ulNumArgs; i++) { if (i == 0) { @@ -391,7 +391,7 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) ar.WriteString(strOutLine + "\n"); bool bLocalVar = true; - ULONG ulLocalVarIndex = procDescriptor.m_ulNumArgs; + uint32_t ulLocalVarIndex = procDescriptor.m_ulNumArgs; INT_PTR nIndentLevel = 0; CNode::Type prevNodeType = CNode::TYPE_NORMAL; @@ -488,7 +488,7 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) } } -std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) +std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumArgs) { std::string c_strArgumentTemplate("arg%u"); std::string c_strLocalVarTemplate("LVar%u"); @@ -501,7 +501,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) } uint16_t wOperator = node.m_Opcode.GetOperator(); - ULONG ulArgument = node.m_Opcode.GetArgument(); + uint32_t ulArgument = node.m_Opcode.GetArgument(); // sslc additions: if (wOperator == COpcode::O_JMP) @@ -644,7 +644,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) } { - ULONG ulVarNum = node.m_Arguments[0].m_Opcode.GetArgument(); + uint32_t ulVarNum = node.m_Arguments[0].m_Opcode.GetArgument(); if (ulVarNum < ulNumArgs) { @@ -666,7 +666,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) } { - ULONG ulVarNum = node.m_Arguments[1].m_Opcode.GetArgument(); + uint32_t ulVarNum = node.m_Arguments[1].m_Opcode.GetArgument(); if (ulVarNum < ulNumArgs) { strResult = format(c_strArgumentTemplate.c_str(), ulVarNum); @@ -774,7 +774,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_REFRESHMOUSE: { - ULONG aulProcArg[1] = { 1 }; + uint32_t aulProcArg[1] = { 1 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -782,7 +782,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDBUTTONPROC: { - ULONG aulProcArg[4] = { 2, 3, 4, 5 }; + uint32_t aulProcArg[4] = { 2, 3, 4, 5 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); } @@ -790,7 +790,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDBUTTONRIGHTPROC: { - ULONG aulProcArg[2] = { 2, 3 }; + uint32_t aulProcArg[2] = { 2, 3 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); } @@ -800,7 +800,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) { if (node.m_Arguments[1].m_Opcode.GetOperator() == COpcode::O_INTOP) { - ULONG aulProcArg[2] = { 2 }; + uint32_t aulProcArg[2] = { 2 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } else @@ -814,7 +814,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDREGIONPROC: { - ULONG aulProcArg[4] = { 2, 3, 4, 5 }; + uint32_t aulProcArg[4] = { 2, 3, 4, 5 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); } @@ -822,7 +822,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDREGIONRIGHTPROC: { - ULONG aulProcArg[2] = { 2, 3 }; + uint32_t aulProcArg[2] = { 2, 3 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); } @@ -830,7 +830,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDNAMEDEVENT: { - ULONG aulProcArg[1] = { 2 }; + uint32_t aulProcArg[1] = { 2 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -838,7 +838,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDNAMEDHANDLER: { - ULONG aulProcArg[1] = { 2 }; + uint32_t aulProcArg[1] = { 2 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -846,7 +846,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_ADDKEY: { - ULONG aulProcArg[1] = { 2 }; + uint32_t aulProcArg[1] = { 2 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -854,7 +854,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_GSAY_OPTION: { - ULONG aulProcArg[1] = { 3 }; + uint32_t aulProcArg[1] = { 3 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -862,7 +862,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) case COpcode::O_GIQ_OPTION: { - ULONG aulProcArg[1] = { 4 }; + uint32_t aulProcArg[1] = { 4 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); } @@ -895,8 +895,8 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) default: COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); - ULONG *procArgs = attributes.m_procArgs; - ULONG numProcArgs = attributes.m_numProcArgs; + uint32_t *procArgs = attributes.m_procArgs; + uint32_t numProcArgs = attributes.m_numProcArgs; if (numProcArgs > 0) { strResult = GetSource(node, bLabel, ulNumArgs, procArgs, numProcArgs); @@ -982,7 +982,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, ULONG ulNumArgs) return strResult; } -std::string CFalloutScript::GetSource( CNode& node, bool bLabel, ULONG ulNumArgs, ULONG aulProcArg[], ULONG ulProcArgCount) +std::string CFalloutScript::GetSource( CNode& node, bool bLabel, uint32_t ulNumArgs, uint32_t aulProcArg[], uint32_t ulProcArgCount) { COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); std::string strResult = attributes.m_strName + "("; @@ -993,7 +993,7 @@ std::string CFalloutScript::GetSource( CNode& node, bool bLabel, ULONG ulNumArgs { bIsProcArg = false; - for(ULONG ulProcArgIndex = 0; ulProcArgIndex < ulProcArgCount; ulProcArgIndex++) + for(uint32_t ulProcArgIndex = 0; ulProcArgIndex < ulProcArgCount; ulProcArgIndex++) { if (nArgIndex == aulProcArg[ulProcArgIndex] - 1) { diff --git a/Hacks/CArchive.cpp b/Hacks/CArchive.cpp index 0ee2ac7..b4fde73 100644 --- a/Hacks/CArchive.cpp +++ b/Hacks/CArchive.cpp @@ -26,7 +26,7 @@ void CArchive::WriteString(std::string value) _file->_ostream << value; } -ULONG CArchive::Read(char *buffer, ULONG size) +uint32_t CArchive::Read(char *buffer, uint32_t size) { _file->_istream.read(buffer, size); return size; diff --git a/Hacks/CArchive.h b/Hacks/CArchive.h index 7e0f25b..34505d7 100644 --- a/Hacks/CArchive.h +++ b/Hacks/CArchive.h @@ -27,7 +27,7 @@ public: void WriteString(const char * value); void WriteString(std::string value); - ULONG Read(char * buffer, ULONG size); + uint32_t Read(char * buffer, uint32_t size); std::ofstream* ofstream(); diff --git a/Hacks/CArray.h b/Hacks/CArray.h index 41a3122..d1ea72c 100644 --- a/Hacks/CArray.h +++ b/Hacks/CArray.h @@ -18,12 +18,12 @@ public: { } - A& operator[](ULONG offset) + A& operator[](uint32_t offset) { return _vector[offset]; } - const A& operator[](ULONG offset) const + const A& operator[](uint32_t offset) const { return _vector[offset]; } @@ -49,22 +49,22 @@ public: return _vector.size() - 1; } - void RemoveAt(ULONG n, ULONG count = 1) + void RemoveAt(uint32_t n, uint32_t count = 1) { _vector.erase(_vector.begin() + n, _vector.begin() + n + count); } - ULONG GetSize() + uint32_t GetSize() { return _vector.size(); } - void SetSize(ULONG n) + void SetSize(uint32_t n) { _vector.resize(n); } - void InsertAt(ULONG position, A value) + void InsertAt(uint32_t position, A value) { _vector.insert(_vector.begin() + position, value); } diff --git a/Hacks/CFile.cpp b/Hacks/CFile.cpp index f38379b..e4a71c9 100644 --- a/Hacks/CFile.cpp +++ b/Hacks/CFile.cpp @@ -23,7 +23,7 @@ bool CFile::Open(std::string name, unsigned int mode) } } -ULONG CFile::GetPosition() +uint32_t CFile::GetPosition() { switch (_mode) { @@ -35,7 +35,7 @@ ULONG CFile::GetPosition() return _istream.tellg(); } -void CFile::Seek(ULONG position, unsigned int mode) +void CFile::Seek(uint32_t position, unsigned int mode) { switch (_mode) { @@ -48,14 +48,14 @@ void CFile::Seek(ULONG position, unsigned int mode) } } -ULONG CFile::GetLength() +uint32_t CFile::GetLength() { - ULONG size = 0; + uint32_t size = 0; switch (_mode) { case modeWrite: { - ULONG oldPosition = _ostream.tellp(); + uint32_t oldPosition = _ostream.tellp(); _ostream.seekp(0, std::ios_base::end); size = _ostream.tellp(); _ostream.seekp(oldPosition, std::ios_base::beg); @@ -63,7 +63,7 @@ ULONG CFile::GetLength() } default: { - ULONG oldPosition = _istream.tellg(); + uint32_t oldPosition = _istream.tellg(); _istream.seekg(0, std::ios_base::end); size = _istream.tellg(); _istream.seekg(oldPosition, std::ios_base::beg); diff --git a/Hacks/CFile.h b/Hacks/CFile.h index 0d7788b..bfb20b2 100644 --- a/Hacks/CFile.h +++ b/Hacks/CFile.h @@ -29,9 +29,9 @@ class CFile CFile(); bool Open(std::string name, unsigned int mode); - ULONG GetPosition(); - void Seek(ULONG position, unsigned int mode); - ULONG GetLength(); + uint32_t GetPosition(); + void Seek(uint32_t position, unsigned int mode); + uint32_t GetLength(); }; diff --git a/Hacks/CMap.h b/Hacks/CMap.h index 6472f42..9c37098 100644 --- a/Hacks/CMap.h +++ b/Hacks/CMap.h @@ -19,7 +19,7 @@ class CMap { } - ULONG GetSize() const + uint32_t GetSize() const { return _map.size(); } @@ -29,7 +29,7 @@ class CMap _map.clear(); } - void SetAt(ULONG offset, C value) + void SetAt(uint32_t offset, C value) { if (_map.find(offset) != _map.end()) { @@ -39,7 +39,7 @@ class CMap _map.insert(std::pair(offset, value)); } - bool Lookup(ULONG offset, C& value) const + bool Lookup(uint32_t offset, C& value) const { auto it = _map.find(offset); if (it != _map.end()) @@ -50,7 +50,7 @@ class CMap return false; } - void InitHashTable(ULONG n) + void InitHashTable(uint32_t n) { } diff --git a/Hacks/Types.h b/Hacks/Types.h index 59fd4f3..7e31708 100644 --- a/Hacks/Types.h +++ b/Hacks/Types.h @@ -11,6 +11,5 @@ typedef unsigned char BYTE; typedef int INT_PTR; -typedef unsigned int ULONG; #endif // TYPES_H diff --git a/Namespace.cpp b/Namespace.cpp index 4996016..b3c9092 100644 --- a/Namespace.cpp +++ b/Namespace.cpp @@ -26,7 +26,7 @@ void CNamespace::Serialize(CArchive& ar) m_Map.RemoveAll(); m_Order.RemoveAll(); - ULONG ulLength; + uint32_t ulLength; if (ReadMSBULong(ar, ulLength) != 4) { @@ -36,7 +36,7 @@ void CNamespace::Serialize(CArchive& ar) if (ulLength == 0xFFFFFFFF) return; - ULONG ulTotalRead = 0; + uint32_t ulTotalRead = 0; uint16_t wLengthOfString; char* lpszNewString; @@ -92,7 +92,7 @@ void CNamespace::Serialize(CArchive& ar) ulTotalRead += (2 + wLengthOfString); } - ULONG ulTerminator; + uint32_t ulTerminator; if (ReadMSBULong(ar, ulTerminator) != 4) { @@ -124,7 +124,7 @@ std::string CNamespace::GetStringByIndex(INT_PTR nIndex) return (this->operator [] (m_Order[nIndex])); } -ULONG CNamespace::GetOffsetByIndex(INT_PTR nIndex) +uint32_t CNamespace::GetOffsetByIndex(INT_PTR nIndex) { return m_Order[nIndex]; } @@ -151,7 +151,7 @@ void CNamespace::Dump(CArchive& ar) } } -std::string CNamespace::operator [] (ULONG ulOffset) const +std::string CNamespace::operator [] (uint32_t ulOffset) const { std::string strResult; diff --git a/Namespace.h b/Namespace.h index 8ad4e67..e46d397 100644 --- a/Namespace.h +++ b/Namespace.h @@ -21,12 +21,12 @@ public: public: INT_PTR GetSize() const; std::string GetStringByIndex(INT_PTR nIndex) ; - ULONG GetOffsetByIndex(INT_PTR nIndex) ; + uint32_t GetOffsetByIndex(INT_PTR nIndex) ; void Dump(CArchive& ar); public: - std::string operator [] (ULONG ulOffset) const; + std::string operator [] (uint32_t ulOffset) const; private: typedef CMap CMapDWordToString; diff --git a/Node.cpp b/Node.cpp index 8d9e0bc..2874fa2 100644 --- a/Node.cpp +++ b/Node.cpp @@ -60,7 +60,7 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex) // Node std::string strOutLine; uint16_t wOperator = m_Opcode.GetOperator(); - ULONG ulArgument = m_Opcode.GetArgument(); + uint32_t ulArgument = m_Opcode.GetArgument(); switch(wOperator) { @@ -98,7 +98,7 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex) } -ULONG CNode::GetTopOffset() +uint32_t CNode::GetTopOffset() { if (m_Arguments.GetSize() > 0) { diff --git a/Node.h b/Node.h index 4322646..4a9154c 100644 --- a/Node.h +++ b/Node.h @@ -37,12 +37,12 @@ public: public: void StoreTree(CArchive& ar, int nIndent, int nIndex); - ULONG GetTopOffset(); + uint32_t GetTopOffset(); bool IsExpression() const; bool IsInfix() const; public: - ULONG m_ulOffset; + uint32_t m_ulOffset; COpcode m_Opcode; Type m_Type; diff --git a/Opcode.cpp b/Opcode.cpp index 71f6400..ad2fab8 100644 --- a/Opcode.cpp +++ b/Opcode.cpp @@ -61,7 +61,7 @@ void COpcode::Serialize(CArchive& ar) } } -void COpcode::Expect(CArchive& ar, uint16_t wOperator, bool bArgumentFound, ULONG ulArgument) +void COpcode::Expect(CArchive& ar, uint16_t wOperator, bool bArgumentFound, uint32_t ulArgument) { Serialize(ar); @@ -141,7 +141,7 @@ void COpcode::SetOperator(uint16_t op) m_wOperator = op; } -ULONG COpcode::GetArgument() const +uint32_t COpcode::GetArgument() const { return m_ulArgument; } diff --git a/Opcode.h b/Opcode.h index 71f9189..9f7561a 100644 --- a/Opcode.h +++ b/Opcode.h @@ -781,11 +781,11 @@ public: public: COpcodeAttributes(std::string mnemonic = "", std::string name = "", - ULONG ulNumArgs = 0, + uint32_t ulNumArgs = 0, Type type = TYPE_STATEMENT, Category category = CATEGORY_PREFIX, - ULONG* procArgs = NULL, - ULONG numProcArgs = 0); + uint32_t* procArgs = NULL, + uint32_t numProcArgs = 0); COpcodeAttributes(const COpcodeAttributes& attributes); COpcodeAttributes& operator = (const COpcodeAttributes& attributes); void InitAttributes(); @@ -793,11 +793,11 @@ public: public: std::string m_strMnemonic; std::string m_strName; - ULONG m_ulNumArgs; + uint32_t m_ulNumArgs; Type m_Type; Category m_Category; - ULONG *m_procArgs; - ULONG m_numProcArgs; + uint32_t *m_procArgs; + uint32_t m_numProcArgs; }; // CF2OpcodeAttributesMap @@ -824,7 +824,7 @@ public: public: virtual void Serialize(CArchive& ar); - void Expect(CArchive& ar, uint16_t wOperator, bool bArgumentFound = false, ULONG ulArgument = 0); + void Expect(CArchive& ar, uint16_t wOperator, bool bArgumentFound = false, uint32_t ulArgument = 0); void Expect(CArchive& ar, int nCount, uint16_t pwOperators[]); bool HasArgument() const; @@ -832,13 +832,13 @@ public: uint16_t GetOperator() const; void SetOperator(uint16_t op); - ULONG GetArgument() const; + uint32_t GetArgument() const; const COpcodeAttributes GetAttributes() const; private: uint16_t m_wOperator; - ULONG m_ulArgument; + uint32_t m_ulArgument; }; typedef CArray COpcodeArray; diff --git a/OpcodeAttributes.cpp b/OpcodeAttributes.cpp index 36e8254..831b3af 100644 --- a/OpcodeAttributes.cpp +++ b/OpcodeAttributes.cpp @@ -3,11 +3,11 @@ COpcode::COpcodeAttributes::COpcodeAttributes(std::string mnemonic, std::string name, - ULONG ulNumArgs, + uint32_t ulNumArgs, Type type, Category category, - ULONG *procArgs, - ULONG numProcArgs) : + uint32_t *procArgs, + uint32_t numProcArgs) : m_strMnemonic(mnemonic), m_strName(name), m_ulNumArgs(ulNumArgs), @@ -62,7 +62,7 @@ COpcode::CF1OpcodeAttributesMap::CF1OpcodeAttributesMap() SetAt(O_TOWN_MAP, COpcodeAttributes("O_TOWN_MAP", "town_map", 0)); } -ULONG procArgs_register_hook_proc[1] = {2}; +uint32_t procArgs_register_hook_proc[1] = {2}; // COpcode::CF2OpcodeAttributesMap COpcode::CF2OpcodeAttributesMap::CF2OpcodeAttributesMap() diff --git a/ProcTable.cpp b/ProcTable.cpp index 20d9ab8..fd1d6ab 100644 --- a/ProcTable.cpp +++ b/ProcTable.cpp @@ -66,7 +66,7 @@ void CProcDescriptor::Serialize(CArchive& ar) // printf("m_ulNumArgs = 0x%08X\n", m_ulNumArgs); - if (uiTotalRead != (sizeof(ULONG) * 6)) + if (uiTotalRead != (sizeof(uint32_t) * 6)) { printf("Error: Unable read procedure descriptor\n"); AfxThrowUserException(); @@ -138,8 +138,8 @@ CProcTable::~CProcTable() } struct ProcBodyOffset { - ULONG m_ulProcIndex; - ULONG m_ulBodyOffset; + uint32_t m_ulProcIndex; + uint32_t m_ulBodyOffset; }; int compareProcBodyOffsets(const void* elem0, const void* elem1) @@ -177,11 +177,11 @@ void CProcTable::Serialize(CArchive& ar) m_Table.RemoveAll(); m_ProcSize.RemoveAll(); - ULONG ulSizeOfTable; - ULONG ulRead; + uint32_t ulSizeOfTable; + uint32_t ulRead; ar.Flush(); - ULONG ulSizeOfFile = ULONG(ar.GetFile()->GetLength()); + uint32_t ulSizeOfFile = uint32_t(ar.GetFile()->GetLength()); ulRead = ReadMSBULong(ar, ulSizeOfTable); @@ -194,7 +194,7 @@ void CProcTable::Serialize(CArchive& ar) m_Table.SetSize(ulSizeOfTable); m_ProcSize.SetSize(ulSizeOfTable); - ULONG ulIndexOfProcOffset = 0; + uint32_t ulIndexOfProcOffset = 0; ProcBodyOffset* pOffsets = new ProcBodyOffset[ulSizeOfTable + 1]; if (pOffsets == NULL) @@ -203,7 +203,7 @@ void CProcTable::Serialize(CArchive& ar) throw 1; } - for(ULONG i = 0; i < ulSizeOfTable; i++) + for(uint32_t i = 0; i < ulSizeOfTable; i++) { // printf("======== %u =========\n", i); m_Table[i].Serialize(ar); @@ -230,7 +230,7 @@ void CProcTable::Serialize(CArchive& ar) qsort(pOffsets, ulIndexOfProcOffset, sizeof(ProcBodyOffset), compareProcBodyOffsets); // Sizes of procedures - for(ULONG i = 0; i < ulIndexOfProcOffset; i++) + for(uint32_t i = 0; i < ulIndexOfProcOffset; i++) { if (pOffsets[i + 1].m_ulBodyOffset >= pOffsets[i].m_ulBodyOffset) { @@ -245,7 +245,7 @@ void CProcTable::Serialize(CArchive& ar) delete [] pOffsets; - for(ULONG i = 0; i < ulSizeOfTable; i++) + for(uint32_t i = 0; i < ulSizeOfTable; i++) { if (m_Table[i].m_ulBodyOffset != 0) { @@ -270,7 +270,7 @@ INT_PTR CProcTable::GetSize() return m_Table.GetSize(); } -ULONG CProcTable::GetSizeOfProc(INT_PTR nIndex) +uint32_t CProcTable::GetSizeOfProc(INT_PTR nIndex) { if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { @@ -281,7 +281,7 @@ ULONG CProcTable::GetSizeOfProc(INT_PTR nIndex) return m_ProcSize[nIndex]; } -ULONG CProcTable::GetOffsetOfProcSection() +uint32_t CProcTable::GetOffsetOfProcSection() { return m_ulOffsetOfProcSection; } diff --git a/ProcTable.h b/ProcTable.h index 99549bd..b9c0f59 100644 --- a/ProcTable.h +++ b/ProcTable.h @@ -24,12 +24,12 @@ public: CProcDescriptor& operator = (const CProcDescriptor& Item); public: - ULONG m_ulNameOffset; // Index into namespace for procedure name - ULONG m_ulType; // Type of function (P_TIMED, P_CONDITIONAL, none) - ULONG m_ulTime; // Time this proc should go off, if timed - ULONG m_ulExpressionOffset; // Pointer to conditional code, if conditional - ULONG m_ulBodyOffset; // Pointer to procedure - ULONG m_ulNumArgs; // Number of args to procedure + uint32_t m_ulNameOffset; // Index into namespace for procedure name + uint32_t m_ulType; // Type of function (P_TIMED, P_CONDITIONAL, none) + uint32_t m_ulTime; // Time this proc should go off, if timed + uint32_t m_ulExpressionOffset; // Pointer to conditional code, if conditional + uint32_t m_ulBodyOffset; // Pointer to procedure + uint32_t m_ulNumArgs; // Number of args to procedure }; class CProcTable @@ -42,8 +42,8 @@ public: virtual void Serialize(CArchive& ar); INT_PTR GetSize(); - ULONG GetSizeOfProc(INT_PTR nIndex); - ULONG GetOffsetOfProcSection(); + uint32_t GetSizeOfProc(INT_PTR nIndex); + uint32_t GetOffsetOfProcSection(); void Dump(CArchive& ar); @@ -56,7 +56,7 @@ private: CProcTableArray m_Table; CDWordArray m_ProcSize; - ULONG m_ulOffsetOfProcSection; + uint32_t m_ulOffsetOfProcSection; }; #endif //PROC_TABLE_H