diff --git a/FalloutScript.cpp b/FalloutScript.cpp index 9e6c3c8..ade8622 100644 --- a/FalloutScript.cpp +++ b/FalloutScript.cpp @@ -68,7 +68,7 @@ void CFalloutScript::Serialize(CArchive& ar) if (!HeaderTail.IsEmpty()) { - INT_PTR nIndexOfStart = GetIndexOfProc("start"); + int32_t nIndexOfStart = GetIndexOfProc("start"); uint32_t ulStartProcAddress = (nIndexOfStart != -1) ? m_ProcTable[nIndexOfStart].m_ulBodyOffset : 18; opcode = HeaderTail[HeaderTail.GetUpperBound()]; @@ -178,7 +178,7 @@ void CFalloutScript::Serialize(CArchive& ar) // Global variables printf(" Extract \"Global variables\" section\n"); - for(INT_PTR i = 0; i < HeaderTail.GetSize(); i++) + for(int32_t i = 0; i < HeaderTail.GetSize(); i++) { uint16_t wGlobalVarOperator = HeaderTail[i].GetOperator(); @@ -202,7 +202,7 @@ void CFalloutScript::Serialize(CArchive& ar) CNode node; - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\r", i); uint32_t ulOffset = m_ProcTable[i].m_ulBodyOffset; @@ -220,9 +220,9 @@ void CFalloutScript::Serialize(CArchive& ar) } } -void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, uint16_t wDelimeter, int nSizeOfCodeItem, const char* lpszErrorMessage, bool (CFalloutScript::*pCheckFunc)(uint16_t, INT_PTR)) +void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, uint16_t wDelimeter, int nSizeOfCodeItem, const char* lpszErrorMessage, bool (CFalloutScript::*pCheckFunc)(uint16_t, int32_t)) { - INT_PTR i = 0; + int32_t i = 0; for(; i < Source.GetSize(); i++) { @@ -242,7 +242,7 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des while(Source[i].GetOperator() == wDelimeter) { - for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) + for(int32_t j = 0; j < nSizeOfCodeItem - 1; j++) { if (!((this->*pCheckFunc)(Source[i - nSizeOfCodeItem + 1 + j].GetOperator(), j))) { @@ -251,7 +251,7 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des } } - for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) + for(int32_t j = 0; j < nSizeOfCodeItem - 1; j++) { Destination.Add(Source[i - nSizeOfCodeItem + 1]); Source.RemoveAt(i - nSizeOfCodeItem + 1); @@ -268,12 +268,12 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des } } -bool CFalloutScript::CheckExportVarCode(uint16_t wOperator, INT_PTR nIndex) +bool CFalloutScript::CheckExportVarCode(uint16_t wOperator, int32_t nIndex) { return (nIndex == 0) && (wOperator == COpcode::O_STRINGOP); } -bool CFalloutScript::CheckSetExportedVarValueCode(uint16_t wOperator, INT_PTR nIndex) +bool CFalloutScript::CheckSetExportedVarValueCode(uint16_t wOperator, int32_t nIndex) { switch(nIndex) { @@ -289,7 +289,7 @@ bool CFalloutScript::CheckSetExportedVarValueCode(uint16_t wOperator, INT_PTR nI } } -bool CFalloutScript::CheckExportProcCode(uint16_t wOperator, INT_PTR nIndex) +bool CFalloutScript::CheckExportProcCode(uint16_t wOperator, int32_t nIndex) { return ((nIndex == 0) || (nIndex == 1)) && (wOperator == COpcode::O_INTOP); } diff --git a/FalloutScript.h b/FalloutScript.h index a81e1ad..0a311a6 100644 --- a/FalloutScript.h +++ b/FalloutScript.h @@ -46,26 +46,26 @@ private: }; private: - void ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, uint16_t wDelimeter, int nSizeOfCodeItem, const char* lpszErrorMessage, bool (CFalloutScript::*pCheckFunc)(uint16_t, INT_PTR)); - bool CheckExportVarCode(uint16_t wOperator, INT_PTR nIndex); - bool CheckSetExportedVarValueCode(uint16_t wOperator, INT_PTR nIndex); - bool CheckExportProcCode(uint16_t wOperator, INT_PTR nIndex); + void ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, uint16_t wDelimeter, int nSizeOfCodeItem, const char* lpszErrorMessage, bool (CFalloutScript::*pCheckFunc)(uint16_t, int32_t)); + bool CheckExportVarCode(uint16_t wOperator, int32_t nIndex); + bool CheckSetExportedVarValueCode(uint16_t wOperator, int32_t nIndex); + bool CheckExportProcCode(uint16_t wOperator, int32_t nIndex); - INT_PTR GetIndexOfProc(const char* lpszName); - INT_PTR GetIndexOfProc(uint32_t ulNameOffset); - INT_PTR GetIndexOfExportedVariable(uint32_t ulNameOffset); + int32_t GetIndexOfProc(const char* lpszName); + int32_t GetIndexOfProc(uint32_t ulNameOffset); + int32_t GetIndexOfExportedVariable(uint32_t ulNameOffset); void SetExternalVariable(uint32_t ulNameOffset); void TryRenameGlobalVariables(); void TryRenameImportedVariables(); - INT_PTR NextNodeIndex( CNodeArray& NodeArray, INT_PTR nCurrentIndex, INT_PTR nSteep); - bool CheckSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, const uint16_t wSequence[], INT_PTR nSequenceLen); - bool RemoveSequenceOfNodes(CNodeArray& NodeArray,INT_PTR nStartIndex, INT_PTR nCount, const uint16_t wSequence[], INT_PTR nSequenceLen); + int32_t NextNodeIndex( CNodeArray& NodeArray, int32_t nCurrentIndex, int32_t nSteep); + bool CheckSequenceOfNodes(CNodeArray& NodeArray, int32_t nStartIndex, const uint16_t wSequence[], int32_t nSequenceLen); + bool RemoveSequenceOfNodes(CNodeArray& NodeArray,int32_t nStartIndex, int32_t nCount, const uint16_t wSequence[], int32_t nSequenceLen); void InitialReduce(); void BuildTree(CNodeArray& NodeArray); - void ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, INT_PTR nStartIndex); + void ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, int32_t nStartIndex); void SetBordersOfBlocks(CNodeArray& NodeArray); uint32_t BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartIndex, uint32_t ulEndOffset); void ReduceConditionalExpressions(CNodeArray& NodeArray); @@ -77,7 +77,7 @@ private: 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); + std::string GetIndentString(int32_t nLevel); int GetPriority(uint16_t wOperator); Assoc GetAssociation(uint16_t wOperator); diff --git a/FalloutScriptDecompile.cpp b/FalloutScriptDecompile.cpp index 97bcc42..0cb7b08 100644 --- a/FalloutScriptDecompile.cpp +++ b/FalloutScriptDecompile.cpp @@ -25,13 +25,13 @@ extern bool g_bInsOmittedArgsBackward; void CFalloutScript::InitDefinitions() { uint32_t ulNameOffset; - INT_PTR nObjectIndex; + int32_t nObjectIndex; std::string c_strGlobalVarTemplate("GVar%u"); m_Definitions.RemoveAll(); - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) + for(int32_t i = 0; i < m_Namespace.GetSize(); i++) { ulNameOffset = m_Namespace.GetOffsetByIndex(i); @@ -50,7 +50,7 @@ void CFalloutScript::InitDefinitions() m_GlobalVarsNames.resize(m_GlobalVar.GetSize()); - for(INT_PTR i = 0; i < m_GlobalVarsNames.size(); i++) + for(int32_t i = 0; i < m_GlobalVarsNames.size(); i++) { m_GlobalVarsNames[i] = format(c_strGlobalVarTemplate, i); } @@ -63,7 +63,7 @@ void CFalloutScript::ProcessCode() printf(" Building execution tree\n"); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\n", i); BuildTree(m_ProcBodies[i]); @@ -71,14 +71,14 @@ void CFalloutScript::ProcessCode() printf(" Extracting and reducing conditions\n"); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { if (m_ProcTable[i].m_ulType & P_CONDITIONAL) { ExtractAndReduceCondition(m_ProcBodies[i], m_Conditions[i], 0); } - for(INT_PTR j = 0; j < m_ProcBodies[i].GetSize(); j++) + for(int32_t j = 0; j < m_ProcBodies[i].GetSize(); j++) { if (m_ProcBodies[i][j].m_Opcode.GetOperator() == COpcode::O_CALL_CONDITION) { @@ -110,7 +110,7 @@ void CFalloutScript::ProcessCode() printf(" Setting borders of blocks\n"); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\r", i); SetBordersOfBlocks(m_ProcBodies[i]); @@ -123,15 +123,15 @@ void CFalloutScript::ProcessCode() TryRenameImportedVariables(); } -INT_PTR CFalloutScript::GetIndexOfProc(const char* lpszName) +int32_t CFalloutScript::GetIndexOfProc(const char* lpszName) { - INT_PTR nResult = -1; + int32_t nResult = -1; std::string strName(lpszName); std::string strTestName; std::transform(strName.begin(), strName.end(), strName.begin(), ::tolower); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { strTestName = m_Namespace[m_ProcTable[i].m_ulNameOffset]; std::transform(strTestName.begin(), strTestName.end(), strTestName.begin(), ::tolower); @@ -146,11 +146,11 @@ INT_PTR CFalloutScript::GetIndexOfProc(const char* lpszName) return nResult; } -INT_PTR CFalloutScript::GetIndexOfProc(uint32_t ulNameOffset) +int32_t CFalloutScript::GetIndexOfProc(uint32_t ulNameOffset) { - INT_PTR nResult = -1; + int32_t nResult = -1; - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) + for(int32_t i = 0; i < m_ProcTable.GetSize(); i++) { if (m_ProcTable[i].m_ulNameOffset == ulNameOffset) { @@ -162,11 +162,11 @@ INT_PTR CFalloutScript::GetIndexOfProc(uint32_t ulNameOffset) return nResult; } -INT_PTR CFalloutScript::GetIndexOfExportedVariable(uint32_t ulNameOffset) +int32_t CFalloutScript::GetIndexOfExportedVariable(uint32_t ulNameOffset) { - INT_PTR nResult = -1; + int32_t nResult = -1; - for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) + for(int32_t i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { if (m_ExportedVarValue[i + 1].GetArgument() == ulNameOffset) { @@ -190,16 +190,16 @@ void CFalloutScript::SetExternalVariable(uint32_t ulNameOffset) void CFalloutScript::TryRenameGlobalVariables() { - INT_PTR nNamesCount = m_Namespace.GetSize(); - INT_PTR nDefinitionsCount = m_Definitions.GetSize(); - INT_PTR nGlobalVarCount = m_GlobalVar.GetSize(); + int32_t nNamesCount = m_Namespace.GetSize(); + int32_t nDefinitionsCount = m_Definitions.GetSize(); + int32_t nGlobalVarCount = m_GlobalVar.GetSize(); CDefObject defObject; - INT_PTR nGlobalVarIndex = 0; + int32_t nGlobalVarIndex = 0; if (nNamesCount - nDefinitionsCount == nGlobalVarCount) { - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) + for(int32_t i = 0; i < m_Namespace.GetSize(); i++) { if (!m_Definitions.Lookup(m_Namespace.GetOffsetByIndex(i), defObject)) { @@ -222,7 +222,7 @@ void CFalloutScript::TryRenameImportedVariables() if (m_GlobalVar.GetSize() == 0) { - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) + for(int32_t i = 0; i < m_Namespace.GetSize(); i++) { ulNameOffset = m_Namespace.GetOffsetByIndex(i); @@ -234,9 +234,9 @@ void CFalloutScript::TryRenameImportedVariables() } } -INT_PTR CFalloutScript::NextNodeIndex( CNodeArray& NodeArray, INT_PTR nCurrentIndex, INT_PTR nStep) +int32_t CFalloutScript::NextNodeIndex( CNodeArray& NodeArray, int32_t nCurrentIndex, int32_t nStep) { - INT_PTR nResult = nCurrentIndex + nStep; + int32_t nResult = nCurrentIndex + nStep; if ((nResult < 0) || (nResult > NodeArray.GetUpperBound())) { @@ -247,16 +247,16 @@ INT_PTR CFalloutScript::NextNodeIndex( CNodeArray& NodeArray, INT_PTR nCurrentIn return nResult; } -bool CFalloutScript::CheckSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, const uint16_t wSequence[], INT_PTR nSequenceLen) +bool CFalloutScript::CheckSequenceOfNodes(CNodeArray& NodeArray, int32_t nStartIndex, const uint16_t wSequence[], int32_t nSequenceLen) { return RemoveSequenceOfNodes(NodeArray, nStartIndex, 0, wSequence, nSequenceLen); } -bool CFalloutScript::RemoveSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, INT_PTR nCount, const uint16_t wSequence[], INT_PTR nSequenceLen) +bool CFalloutScript::RemoveSequenceOfNodes(CNodeArray& NodeArray, int32_t nStartIndex, int32_t nCount, const uint16_t wSequence[], int32_t nSequenceLen) { - INT_PTR nCurrentNodeIndex = nStartIndex - 1; + int32_t nCurrentNodeIndex = nStartIndex - 1; - for(INT_PTR i = 0; i < nSequenceLen; i++) + for(int32_t i = 0; i < nSequenceLen; i++) { nCurrentNodeIndex = NextNodeIndex(NodeArray, nCurrentNodeIndex, 1); @@ -334,9 +334,9 @@ void CFalloutScript::InitialReduce() }; uint16_t* pwCode; - INT_PTR nCount; + int32_t nCount; - for(INT_PTR i = 0 ; i < m_ProcBodies.GetSize(); i++) + for(int32_t i = 0 ; i < m_ProcBodies.GetSize(); i++) { // Tail if (!m_ProcBodies[i].IsEmpty()) @@ -352,7 +352,7 @@ void CFalloutScript::InitialReduce() } // Body - for(INT_PTR j = 0; j < m_ProcBodies[i].GetSize(); j++) + for(int32_t j = 0; j < m_ProcBodies[i].GetSize(); j++) { switch(m_ProcBodies[i][j].m_Opcode.GetOperator()) { @@ -418,24 +418,24 @@ uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartI { uint16_t wOperator; uint32_t ulArgument; - INT_PTR nNumOfArgs; + int32_t nNumOfArgs; COpcode::COpcodeAttributes opcodeAttributes; - INT_PTR j; + int32_t j; for (j = nStartIndex; (j < NodeArray.GetSize() && NodeArray[j].m_ulOffset < ulEndOffset); j++) { wOperator = NodeArray[j].m_Opcode.GetOperator(); ulArgument = NodeArray[j].m_Opcode.GetArgument(); opcodeAttributes = NodeArray[j].m_Opcode.GetAttributes(); - nNumOfArgs = INT_PTR(opcodeAttributes.m_ulNumArgs); + nNumOfArgs = int32_t(opcodeAttributes.m_ulNumArgs); switch(wOperator) { case COpcode::O_FETCH_EXTERNAL: case COpcode::O_STORE_EXTERNAL: { - INT_PTR nExtVarNameNodeIndex = NextNodeIndex(NodeArray, j, -1); + int32_t nExtVarNameNodeIndex = NextNodeIndex(NodeArray, j, -1); uint16_t wOpeartor = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetOperator(); uint32_t ulArgument = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetArgument(); @@ -451,7 +451,7 @@ uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartI case COpcode::O_CALL: { - INT_PTR nProcNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -2); + int32_t nProcNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -2); uint16_t wProcNumOfArgsOperator = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetOperator(); uint32_t ulProcNumOfArgs = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetArgument(); @@ -461,13 +461,13 @@ uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartI AfxThrowUserException(); } - nNumOfArgs = INT_PTR(ulProcNumOfArgs) + 2; + nNumOfArgs = int32_t(ulProcNumOfArgs) + 2; break; } case COpcode::O_ADDREGION: { - INT_PTR nAddRegionNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -1); + int32_t nAddRegionNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -1); uint16_t wAddRegionNumOfArgsOperator = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetOperator(); uint32_t ulAddRegionNumOfArgs = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetArgument(); @@ -477,17 +477,17 @@ uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartI AfxThrowUserException(); } - nNumOfArgs = INT_PTR(ulAddRegionNumOfArgs) + 1; + nNumOfArgs = int32_t(ulAddRegionNumOfArgs) + 1; break; } } // Check nodes - INT_PTR nOmittedArgStartIndex = nNumOfArgs; + int32_t nOmittedArgStartIndex = nNumOfArgs; COpcode::COpcodeAttributes checkOpcodeAttributes; - INT_PTR nNodeIndex = j; + int32_t nNodeIndex = j; - for(INT_PTR k = 0; k < nNumOfArgs; k++) + for(int32_t k = 0; k < nNumOfArgs; k++) { nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, -1); if (!NodeArray[nNodeIndex].IsExpression()) @@ -515,7 +515,7 @@ uint32_t CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, uint32_t nStartI } // Move arguments - for(INT_PTR k = 0; k < nNumOfArgs; k++) + for(int32_t k = 0; k < nNumOfArgs; k++) { if (k < nOmittedArgStartIndex) { @@ -574,11 +574,11 @@ void CFalloutScript::BuildTree(CNodeArray& NodeArray) } } -void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, INT_PTR nStartIndex) +void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, int32_t nStartIndex) { // Extract CNode node; - INT_PTR nNodeIndex;; + int32_t nNodeIndex;; node = Source[nNodeIndex = NextNodeIndex(Source, nStartIndex - 1, 1)]; @@ -606,7 +606,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D Destination.SetSize(nNodeIndex - nStartIndex); - for(INT_PTR j = 0; j < nNodeIndex - nStartIndex; j++) + for(int32_t j = 0; j < nNodeIndex - nStartIndex; j++) { Destination[j] = Source[nStartIndex + j]; } @@ -673,7 +673,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) } // End of procedure - INT_PTR nLastNodeIndex = NodeArray.GetUpperBound(); + int32_t nLastNodeIndex = NodeArray.GetUpperBound(); if ((NodeArray[nLastNodeIndex].m_Opcode.GetOperator() == COpcode::O_POP_RETURN) && (NodeArray[nLastNodeIndex].m_Opcode.GetArgument() == 0) && @@ -693,7 +693,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) // Body CNode node; - for(INT_PTR i = 0; i < NodeArray.GetSize(); i++) + for(int32_t i = 0; i < NodeArray.GetSize(); i++) { switch(NodeArray[i].m_Opcode.GetOperator()) { @@ -712,8 +712,8 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) NodeArray[i + 1].m_ulOffset = NodeArray[i].m_ulOffset; ulOffset = node.m_Opcode.GetArgument(); - INT_PTR nNodeIndex = i + 1; - CArray jumps; + int32_t nNodeIndex = i + 1; + CArray jumps; do { @@ -741,7 +741,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) if (NodeArray[nNodeIndex - 2].m_Arguments.GetSize() > 0 && i > 0) { // *might* be a "for" loop loopOffset = NodeArray[nNodeIndex - 2].GetTopOffset(); - for (INT_PTR j=0; j 0) { @@ -590,7 +590,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr AfxThrowUserException(); } - if (INT_PTR(node.m_Arguments[0].m_Opcode.GetArgument()) > m_GlobalVarsNames.size() - 1) + if (int32_t(node.m_Arguments[0].m_Opcode.GetArgument()) > m_GlobalVarsNames.size() - 1) { printf("Error: Invalid index of global variable\n"); AfxThrowUserException(); @@ -606,7 +606,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr AfxThrowUserException(); } - if (INT_PTR(node.m_Arguments[1].m_Opcode.GetArgument()) > m_GlobalVarsNames.size() - 1) + if (int32_t(node.m_Arguments[1].m_Opcode.GetArgument()) > m_GlobalVarsNames.size() - 1) { printf("Error: Invalid index of global variable\n"); AfxThrowUserException(); @@ -714,7 +714,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr strResult += "("; - for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetUpperBound() - 1; nArgIndex++) + for(int32_t nArgIndex = 0; nArgIndex < node.m_Arguments.GetUpperBound() - 1; nArgIndex++) { if (nArgIndex == 0) { @@ -767,7 +767,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr strResult = "addRegion "; strResult += GetSource(node.m_Arguments[0], false, ulNumArgs) + " { "; - for(INT_PTR nArgIndex = 1; nArgIndex < node.m_Arguments.GetUpperBound(); nArgIndex++) + for(int32_t nArgIndex = 1; nArgIndex < node.m_Arguments.GetUpperBound(); nArgIndex++) { if (nArgIndex == 1) { @@ -922,7 +922,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr } std::string sPostfix[] = { " if ", " else ", ""}; strResult = ""; - for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) + for(int32_t i = 0; i < node.m_Arguments.GetSize(); i++) { bool bParens = ArgNeedParens(node, node.m_Arguments[i], CFalloutScript::RIGHT_ASSOC); strResult += (bParens ? "(" : "") + GetSource(node.m_Arguments[i], bLabel, ulNumArgs) + (bParens ? ")" : "") + sPostfix[i]; @@ -970,7 +970,7 @@ std::string CFalloutScript::GetSource(CNode& node, bool bLabel, uint32_t ulNumAr strResult += "("; - for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) + for(int32_t i = 0; i < node.m_Arguments.GetSize(); i++) { if (i == 0) { @@ -1000,7 +1000,7 @@ std::string CFalloutScript::GetSource( CNode& node, bool bLabel, uint32_t ulNumA std::string strArgument; bool bIsProcArg; - for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetSize(); nArgIndex++) + for(int32_t nArgIndex = 0; nArgIndex < node.m_Arguments.GetSize(); nArgIndex++) { bIsProcArg = false; @@ -1055,7 +1055,7 @@ std::string CFalloutScript::GetSource( CNode& node, bool bLabel, uint32_t ulNumA return strResult; } -std::string CFalloutScript::GetIndentString(INT_PTR nLevel) +std::string CFalloutScript::GetIndentString(int32_t nLevel) { std::string strResult; diff --git a/Hacks/CArray.h b/Hacks/CArray.h index 19718fb..cbca7d4 100644 --- a/Hacks/CArray.h +++ b/Hacks/CArray.h @@ -52,7 +52,7 @@ public: return _vector.empty(); } - INT_PTR GetUpperBound() + int32_t GetUpperBound() { if (_vector.size() == 0) return 0; return _vector.size() - 1; diff --git a/Hacks/Types.h b/Hacks/Types.h index 8ea676e..671d366 100644 --- a/Hacks/Types.h +++ b/Hacks/Types.h @@ -19,6 +19,5 @@ // Third party includes typedef unsigned char BYTE; -typedef int INT_PTR; #endif // TYPES_H diff --git a/Namespace.cpp b/Namespace.cpp index d25a684..d1b083d 100644 --- a/Namespace.cpp +++ b/Namespace.cpp @@ -111,24 +111,24 @@ void CNamespace::Serialize(CArchive& ar) } // //For debugging only -// for(INT_PTR i = 0; i < GetSize(); i++) { +// for(int32_t i = 0; i < GetSize(); i++) { // printf("Offset: 0x%08X (%9d), string: %s\n", m_Order[i], m_Order[i], GetStringByIndex(i)); // } // // printf("\n"); } -INT_PTR CNamespace::GetSize() const +int32_t CNamespace::GetSize() const { return m_Map.GetSize(); } -std::string CNamespace::GetStringByIndex(INT_PTR nIndex) +std::string CNamespace::GetStringByIndex(int32_t nIndex) { return (this->operator [] (m_Order[nIndex])); } -uint32_t CNamespace::GetOffsetByIndex(INT_PTR nIndex) +uint32_t CNamespace::GetOffsetByIndex(int32_t nIndex) { return m_Order[nIndex]; } diff --git a/Namespace.h b/Namespace.h index d591d2f..2135f56 100644 --- a/Namespace.h +++ b/Namespace.h @@ -28,9 +28,9 @@ public: virtual void Serialize(CArchive& ar); public: - INT_PTR GetSize() const; - std::string GetStringByIndex(INT_PTR nIndex) ; - uint32_t GetOffsetByIndex(INT_PTR nIndex) ; + int32_t GetSize() const; + std::string GetStringByIndex(int32_t nIndex) ; + uint32_t GetOffsetByIndex(int32_t nIndex) ; void Dump(CArchive& ar); diff --git a/ProcTable.cpp b/ProcTable.cpp index 6b767de..935ff25 100644 --- a/ProcTable.cpp +++ b/ProcTable.cpp @@ -278,12 +278,12 @@ void CProcTable::Serialize(CArchive& ar) // printf("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection); } -INT_PTR CProcTable::GetSize() +int32_t CProcTable::GetSize() { return m_Table.GetSize(); } -uint32_t CProcTable::GetSizeOfProc(INT_PTR nIndex) +uint32_t CProcTable::GetSizeOfProc(int32_t nIndex) { if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { @@ -315,7 +315,7 @@ void CProcTable::Dump(CArchive& ar) } -CProcDescriptor& CProcTable::operator [] (INT_PTR nIndex) +CProcDescriptor& CProcTable::operator [] (int32_t nIndex) { if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { diff --git a/ProcTable.h b/ProcTable.h index acdf095..9776d7a 100644 --- a/ProcTable.h +++ b/ProcTable.h @@ -50,14 +50,14 @@ public: public: virtual void Serialize(CArchive& ar); - INT_PTR GetSize(); - uint32_t GetSizeOfProc(INT_PTR nIndex); + int32_t GetSize(); + uint32_t GetSizeOfProc(int32_t nIndex); uint32_t GetOffsetOfProcSection(); void Dump(CArchive& ar); public: - CProcDescriptor& operator [] (INT_PTR nIndex); + CProcDescriptor& operator [] (int32_t nIndex); private: // CProcTableArray diff --git a/StartupCode.cpp b/StartupCode.cpp index 96ad188..b1a7f84 100644 --- a/StartupCode.cpp +++ b/StartupCode.cpp @@ -45,7 +45,7 @@ void CStartupCode::Serialize(CArchive& ar) COpcode::O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN }; - for(INT_PTR i = 0; i < 17; i++) + for(int32_t i = 0; i < 17; i++) { if (i == 1) {