From e5f9ee4ec7103537d4733dbe11dc72343fd9630c Mon Sep 17 00:00:00 2001 From: alexeevdv Date: Sat, 14 Feb 2015 23:18:15 +0300 Subject: [PATCH] First usable version --- FalloutScript.cpp | 22 ++-- FalloutScriptDecompile.cpp | 224 ++++++++++++++++++------------------- FalloutScriptDump.cpp | 32 +++--- FalloutScriptStore.cpp | 175 +++++++++++++++-------------- Hacks/CArchive.cpp | 1 - Hacks/CArray.h | 16 ++- Hacks/CString.cpp | 4 +- Namespace.cpp | 6 +- Node.cpp | 4 +- ProcTable.cpp | 26 ++--- main.cpp | 24 ++-- 11 files changed, 271 insertions(+), 263 deletions(-) diff --git a/FalloutScript.cpp b/FalloutScript.cpp index b09289a..ec85aa7 100644 --- a/FalloutScript.cpp +++ b/FalloutScript.cpp @@ -58,7 +58,7 @@ void CFalloutScript::Serialize(CArchive& ar) INT_PTR nIndexOfStart = GetIndexOfProc("start"); ULONG ulStartProcAddress = (nIndexOfStart != -1) ? m_ProcTable[nIndexOfStart].m_ulBodyOffset : 18; - opcode = HeaderTail.at(HeaderTail.GetUpperBound()); + opcode = HeaderTail[HeaderTail.GetUpperBound()]; if (opcode.GetOperator() == COpcode::O_JMP) { @@ -72,7 +72,7 @@ void CFalloutScript::Serialize(CArchive& ar) } else { - opcode = HeaderTail.at(HeaderTail.GetUpperBound()); + opcode = HeaderTail[HeaderTail.GetUpperBound()]; if (opcode.GetOperator() == COpcode::O_INTOP) { @@ -108,7 +108,7 @@ void CFalloutScript::Serialize(CArchive& ar) if (!HeaderTail.IsEmpty()) { - opcode = HeaderTail.at(HeaderTail.GetUpperBound()); + opcode = HeaderTail[HeaderTail.GetUpperBound()]; if (opcode.GetOperator() == COpcode::O_CRITICAL_DONE) { @@ -116,7 +116,7 @@ void CFalloutScript::Serialize(CArchive& ar) if (!HeaderTail.IsEmpty()) { - opcode = HeaderTail.at(HeaderTail.GetUpperBound()); + opcode = HeaderTail[HeaderTail.GetUpperBound()]; if (opcode.HasArgument()) { @@ -167,7 +167,7 @@ void CFalloutScript::Serialize(CArchive& ar) for(INT_PTR i = 0; i < HeaderTail.GetSize(); i++) { - WORD wGlobalVarOperator = HeaderTail.at(i).GetOperator(); + WORD wGlobalVarOperator = HeaderTail[i].GetOperator(); if ((wGlobalVarOperator != COpcode::O_STRINGOP) && (wGlobalVarOperator != COpcode::O_FLOATOP) && @@ -177,7 +177,7 @@ void CFalloutScript::Serialize(CArchive& ar) AfxThrowUserException(); } - m_GlobalVar.Add(HeaderTail.at(i)); + m_GlobalVar.Add(HeaderTail[i]); } // Procedures bodyes @@ -201,7 +201,7 @@ void CFalloutScript::Serialize(CArchive& ar) { node.m_Opcode.Serialize(ar); node.m_ulOffset = ulOffset; - m_ProcBodies.at(i).Add(node); + m_ProcBodies[i].Add(node); ulOffset += node.m_Opcode.GetSize(); } } @@ -213,7 +213,7 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des for(; i < Source.GetSize(); i++) { - if (Source.at(i).GetOperator() == wDelimeter) + if (Source[i].GetOperator() == wDelimeter) { break; } @@ -227,11 +227,11 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des AfxThrowUserException(); } - while(Source.at(i).GetOperator() == wDelimeter) + while(Source[i].GetOperator() == wDelimeter) { for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { - if (!((this->*pCheckFunc)(Source.at(i - nSizeOfCodeItem + 1 + j).GetOperator(), j))) + if (!((this->*pCheckFunc)(Source[i - nSizeOfCodeItem + 1 + j].GetOperator(), j))) { printf(lpszErrorMessage); AfxThrowUserException(); @@ -240,7 +240,7 @@ void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Des for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { - Destination.Add(Source.at(i - nSizeOfCodeItem + 1)); + Destination.Add(Source[i - nSizeOfCodeItem + 1]); Source.RemoveAt(i - nSizeOfCodeItem + 1); } diff --git a/FalloutScriptDecompile.cpp b/FalloutScriptDecompile.cpp index fc47ef7..bcc060a 100644 --- a/FalloutScriptDecompile.cpp +++ b/FalloutScriptDecompile.cpp @@ -27,8 +27,8 @@ void CFalloutScript::InitDefinitions() } else if ((nObjectIndex = GetIndexOfExportedVariable(ulNameOffset)) != -1) { - WORD wOpcode = m_ExportedVarValue.at(nObjectIndex).GetOperator(); - ULONG ulValue = m_ExportedVarValue.at(nObjectIndex).GetArgument(); + WORD wOpcode = m_ExportedVarValue[nObjectIndex].GetOperator(); + ULONG ulValue = m_ExportedVarValue[nObjectIndex].GetArgument(); m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_EXPORT | wOpcode, ulValue)); } @@ -38,7 +38,7 @@ void CFalloutScript::InitDefinitions() for(INT_PTR i = 0; i < m_GlobalVarsNames.GetSize(); i++) { - m_GlobalVarsNames.at(i).Format(c_strGlobalVarTemplate.c_str(), i); + m_GlobalVarsNames[i].Format(c_strGlobalVarTemplate.c_str(), i); } } @@ -52,7 +52,7 @@ void CFalloutScript::ProcessCode() for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\n", i); - BuildTree(m_ProcBodies.at(i)); + BuildTree(m_ProcBodies[i]); } printf(" Extracting and reducing conditions\n"); @@ -61,15 +61,15 @@ void CFalloutScript::ProcessCode() { if (m_ProcTable[i].m_ulType & P_CONDITIONAL) { - ExtractAndReduceCondition(m_ProcBodies.at(i), m_Conditions.at(i), 0); + ExtractAndReduceCondition(m_ProcBodies[i], m_Conditions[i], 0); } - for(INT_PTR j = 0; j < m_ProcBodies.at(i).GetSize(); j++) + for(INT_PTR j = 0; j < m_ProcBodies[i].GetSize(); j++) { - if (m_ProcBodies.at(i).at(j).m_Opcode.GetOperator() == COpcode::O_CALL_CONDITION) + if (m_ProcBodies[i][j].m_Opcode.GetOperator() == COpcode::O_CALL_CONDITION) { CNodeArray Condition; - CNode node = m_ProcBodies.at(i).at(j).m_Arguments.at(0); + CNode node = m_ProcBodies[i][j].m_Arguments[0]; if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { @@ -81,14 +81,14 @@ void CFalloutScript::ProcessCode() do { - node = m_ProcBodies.at(i).at(j = NextNodeIndex(m_ProcBodies.at(i), j, -1)); + node = m_ProcBodies[i][j = NextNodeIndex(m_ProcBodies[i], j, -1)]; } while(node.m_ulOffset != ulCondStartAddress); - j = NextNodeIndex(m_ProcBodies.at(i), j, -1); // For O_JMP opcode + j = NextNodeIndex(m_ProcBodies[i], j, -1); // For O_JMP opcode - ExtractAndReduceCondition(m_ProcBodies.at(i), Condition, j); - m_ProcBodies.at(i).at(j).m_Arguments.at(0) = Condition.at(0); + ExtractAndReduceCondition(m_ProcBodies[i], Condition, j); + m_ProcBodies[i][j].m_Arguments[0] = Condition[0]; } } } @@ -99,7 +99,7 @@ void CFalloutScript::ProcessCode() for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\r", i); - SetBordersOfBlocks(m_ProcBodies.at(i)); + SetBordersOfBlocks(m_ProcBodies[i]); } printf(" Renaming global variables\n"); @@ -154,7 +154,7 @@ INT_PTR CFalloutScript::GetIndexOfExportedVariable(ULONG ulNameOffset) for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { - if (m_ExportedVarValue.at(i + 1).GetArgument() == ulNameOffset) + if (m_ExportedVarValue[i + 1].GetArgument() == ulNameOffset) { nResult = i; break; @@ -190,11 +190,11 @@ void CFalloutScript::TryRenameGlobalVariables() if (!m_Definitions.Lookup(m_Namespace.GetOffsetByIndex(i), defObject)) { defObject.m_ObjectType = CDefObject::OBJECT_VARIABLE; - defObject.m_ulAttributes = V_GLOBAL | m_GlobalVar.at(nGlobalVarIndex).GetOperator(); - defObject.m_ulVarValue = m_GlobalVar.at(nGlobalVarIndex).GetArgument(); + defObject.m_ulAttributes = V_GLOBAL | m_GlobalVar[nGlobalVarIndex].GetOperator(); + defObject.m_ulVarValue = m_GlobalVar[nGlobalVarIndex].GetArgument(); m_Definitions.SetAt(m_Namespace.GetOffsetByIndex(i), defObject); - m_GlobalVarsNames.at(nGlobalVarIndex) = m_Namespace.GetStringByIndex(i); + m_GlobalVarsNames[nGlobalVarIndex] = m_Namespace.GetStringByIndex(i); nGlobalVarIndex++; } } @@ -246,7 +246,7 @@ BOOL CFalloutScript::RemoveSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStart { nCurrentNodeIndex = NextNodeIndex(NodeArray, nCurrentNodeIndex, 1); - if (NodeArray.at(nCurrentNodeIndex).m_Opcode.GetOperator() != wSequence[nCurrentNodeIndex - nStartIndex]) + if (NodeArray[nCurrentNodeIndex].m_Opcode.GetOperator() != wSequence[nCurrentNodeIndex - nStartIndex]) { return FALSE; } @@ -325,12 +325,12 @@ void CFalloutScript::InitialReduce() for(INT_PTR i = 0 ; i < m_ProcBodies.GetSize(); i++) { // Tail - if (!m_ProcBodies.at(i).IsEmpty()) + if (!m_ProcBodies[i].IsEmpty()) { pwCode = (m_ProcTable[i].m_ulType & P_CRITICAL) ? awTailOfCriticalProc : awTailOfProc; nCount = (m_ProcTable[i].m_ulType & P_CRITICAL) ? 4 : 3; - if (!RemoveSequenceOfNodes(m_ProcBodies.at(i), m_ProcBodies.at(i).GetSize() - nCount, nCount, pwCode, nCount)) + if (!RemoveSequenceOfNodes(m_ProcBodies[i], m_ProcBodies[i].GetSize() - nCount, nCount, pwCode, nCount)) { printf("Error: Invalid tail of procedure\'s body\n"); AfxThrowUserException(); @@ -338,35 +338,35 @@ void CFalloutScript::InitialReduce() } // Body - for(INT_PTR j = 0; j < m_ProcBodies.at(i).GetSize(); j++) + for(INT_PTR j = 0; j < m_ProcBodies[i].GetSize(); j++) { - switch(m_ProcBodies.at(i).at(j).m_Opcode.GetOperator()) + switch(m_ProcBodies[i][j].m_Opcode.GetOperator()) { case COpcode::O_DUP: // 'Check procedure's arguments count' statement - if (!RemoveSequenceOfNodes(m_ProcBodies.at(i), j, 3, awCheckArgCount, 3)) + if (!RemoveSequenceOfNodes(m_ProcBodies[i], j, 3, awCheckArgCount, 3)) { // short circuit AND - UINT actualOperator = CheckSequenceOfNodes(m_ProcBodies.at(i), j, awShortCircuitAnd, 5) + UINT actualOperator = CheckSequenceOfNodes(m_ProcBodies[i], j, awShortCircuitAnd, 5) ? COpcode::O_AND - : (CheckSequenceOfNodes(m_ProcBodies.at(i), j, awShortCircuitOr, 6) + : (CheckSequenceOfNodes(m_ProcBodies[i], j, awShortCircuitOr, 6) ? COpcode::O_OR : 0); if (actualOperator) { - UINT k, skipOffset = m_ProcBodies.at(i).at(j+1).m_Opcode.GetArgument(); + UINT k, skipOffset = m_ProcBodies[i][j+1].m_Opcode.GetArgument(); CNode node; k = j - 1; do { - k = NextNodeIndex(m_ProcBodies.at(i), k, 1); + k = NextNodeIndex(m_ProcBodies[i], k, 1); } - while (skipOffset > m_ProcBodies.at(i).at(k).m_ulOffset); + while (skipOffset > m_ProcBodies[i][k].m_ulOffset); - m_ProcBodies.at(i).InsertAt(k, m_ProcBodies.at(i).at(j)); - m_ProcBodies.at(i).at(k).m_Opcode.SetOperator(actualOperator); // place AND/OR here, so BuildTree() will treat it as a regular binary operator - m_ProcBodies.at(i).at(k).m_ulOffset = m_ProcBodies.at(i).at(k-1).m_ulOffset + COpcode::OPERATOR_SIZE; // adjust offset - m_ProcBodies.at(i).RemoveAt(j, (actualOperator == COpcode::O_AND) ? 5 : 6); // reduce + m_ProcBodies[i].InsertAt(k, m_ProcBodies[i][j]); + m_ProcBodies[i][k].m_Opcode.SetOperator(actualOperator); // place AND/OR here, so BuildTree() will treat it as a regular binary operator + m_ProcBodies[i][k].m_ulOffset = m_ProcBodies[i][k-1].m_ulOffset + COpcode::OPERATOR_SIZE; // adjust offset + m_ProcBodies[i].RemoveAt(j, (actualOperator == COpcode::O_AND) ? 5 : 6); // reduce } else { @@ -383,9 +383,9 @@ void CFalloutScript::InitialReduce() pwCode = (m_ProcTable[i].m_ulType & P_CRITICAL) ? awCriticalReturn : awReturn; nCount = (m_ProcTable[i].m_ulType & P_CRITICAL) ? 7 : 6; - if (!RemoveSequenceOfNodes(m_ProcBodies.at(i), j, nCount - 1, pwCode, nCount)) + if (!RemoveSequenceOfNodes(m_ProcBodies[i], j, nCount - 1, pwCode, nCount)) { - if (!RemoveSequenceOfNodes(m_ProcBodies.at(i), j - 1, 2, awStoreReturnAdress, 2)) + if (!RemoveSequenceOfNodes(m_ProcBodies[i], j - 1, 2, awStoreReturnAdress, 2)) { printf("Error: Unknown sequence of opcodes\n"); AfxThrowUserException(); @@ -408,12 +408,12 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, COpcode::COpcodeAttributes opcodeAttributes; INT_PTR j; - for (j = nStartIndex; (j < NodeArray.GetSize() && NodeArray.at(j).m_ulOffset < ulEndOffset); j++) + for (j = nStartIndex; (j < NodeArray.GetSize() && NodeArray[j].m_ulOffset < ulEndOffset); j++) { - wOperator = NodeArray.at(j).m_Opcode.GetOperator(); - ulArgument = NodeArray.at(j).m_Opcode.GetArgument(); + wOperator = NodeArray[j].m_Opcode.GetOperator(); + ulArgument = NodeArray[j].m_Opcode.GetArgument(); - opcodeAttributes = NodeArray.at(j).m_Opcode.GetAttributes(); + opcodeAttributes = NodeArray[j].m_Opcode.GetAttributes(); nNumOfArgs = INT_PTR(opcodeAttributes.m_ulNumArgs); switch(wOperator) @@ -422,8 +422,8 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, case COpcode::O_STORE_EXTERNAL: { INT_PTR nExtVarNameNodeIndex = NextNodeIndex(NodeArray, j, -1); - WORD wOpeartor = NodeArray.at(nExtVarNameNodeIndex).m_Opcode.GetOperator(); - ULONG ulArgument = NodeArray.at(nExtVarNameNodeIndex).m_Opcode.GetArgument(); + WORD wOpeartor = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetOperator(); + ULONG ulArgument = NodeArray[nExtVarNameNodeIndex].m_Opcode.GetArgument(); if ((wOpeartor != COpcode::O_STRINGOP) && (wOpeartor != COpcode::O_INTOP)) { @@ -438,8 +438,8 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, case COpcode::O_CALL: { INT_PTR nProcNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -2); - WORD wProcNumOfArgsOperator = NodeArray.at(nProcNumOfArgsNodeIndex).m_Opcode.GetOperator(); - ULONG ulProcNumOfArgs = NodeArray.at(nProcNumOfArgsNodeIndex).m_Opcode.GetArgument(); + WORD wProcNumOfArgsOperator = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetOperator(); + ULONG ulProcNumOfArgs = NodeArray[nProcNumOfArgsNodeIndex].m_Opcode.GetArgument(); if (wProcNumOfArgsOperator != COpcode::O_INTOP) { @@ -454,8 +454,8 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, case COpcode::O_ADDREGION: { INT_PTR nAddRegionNumOfArgsNodeIndex = NextNodeIndex(NodeArray, j, -1); - WORD wAddRegionNumOfArgsOperator = NodeArray.at(nAddRegionNumOfArgsNodeIndex).m_Opcode.GetOperator(); - ULONG ulAddRegionNumOfArgs = NodeArray.at(nAddRegionNumOfArgsNodeIndex).m_Opcode.GetArgument(); + WORD wAddRegionNumOfArgsOperator = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetOperator(); + ULONG ulAddRegionNumOfArgs = NodeArray[nAddRegionNumOfArgsNodeIndex].m_Opcode.GetArgument(); if (wAddRegionNumOfArgsOperator != COpcode::O_INTOP) { @@ -476,7 +476,7 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, for(INT_PTR k = 0; k < nNumOfArgs; k++) { nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, -1); - if (!NodeArray.at(nNodeIndex).IsExpression()) + if (!NodeArray[nNodeIndex].IsExpression()) { if (g_bIgnoreWrongNumOfArgs) { @@ -488,13 +488,13 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, } else { - printf("Error: Not enough arguments for %X\n", NodeArray.at(j).m_ulOffset); + printf("Error: Not enough arguments for %X\n", NodeArray[j].m_ulOffset); AfxThrowUserException(); } } else { - printf("Error: Expression required for %X\n", NodeArray.at(j).m_ulOffset); + printf("Error: Expression required for %X\n", NodeArray[j].m_ulOffset); AfxThrowUserException(); } } @@ -505,7 +505,7 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, { if (k < nOmittedArgStartIndex) { - NodeArray.at(j).m_Arguments.InsertAt(0, NodeArray.at(j - 1)); + NodeArray[j].m_Arguments.InsertAt(0, NodeArray[j-1]); NodeArray.RemoveAt(j - 1); j--; } @@ -513,11 +513,11 @@ ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, { if (g_bInsOmittedArgsBackward) { - NodeArray.at(j).m_Arguments.Add(CNode(CNode::TYPE_OMITTED_ARGUMENT)); + NodeArray[j].m_Arguments.Add(CNode(CNode::TYPE_OMITTED_ARGUMENT)); } else { - NodeArray.at(j).m_Arguments.InsertAt(0, CNode(CNode::TYPE_OMITTED_ARGUMENT)); + NodeArray[j].m_Arguments.InsertAt(0, CNode(CNode::TYPE_OMITTED_ARGUMENT)); } } } @@ -525,21 +525,21 @@ 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.at(j).m_Arguments.at(0).m_Opcode.GetArgument(); + ULONG ulElseOffset = NodeArray[j].m_Arguments[0].m_Opcode.GetArgument(); ULONG ulElseIndex, ulSkipIndex = -1; ulElseIndex = BuildTreeBranch(NodeArray, j + 1, ulElseOffset); // true branch - if (NodeArray.at(ulElseIndex - 1).m_Opcode.GetOperator() == COpcode::O_JMP) + if (NodeArray[ulElseIndex - 1].m_Opcode.GetOperator() == COpcode::O_JMP) { - ULONG ulSkipOffset = NodeArray.at(ulElseIndex - 1).m_Opcode.GetArgument(); - if (ulSkipOffset > NodeArray.at(j).m_ulOffset) + ULONG ulSkipOffset = NodeArray[ulElseIndex - 1].m_Opcode.GetArgument(); + if (ulSkipOffset > NodeArray[j].m_ulOffset) { ulSkipIndex = BuildTreeBranch(NodeArray, ulElseIndex, ulSkipOffset); // false branch - if (NodeArray.at(ulElseIndex - 2).IsExpression() && NodeArray.at(ulSkipIndex - 1).IsExpression()) + if (NodeArray[ulElseIndex - 2].IsExpression() && NodeArray[ulSkipIndex - 1].IsExpression()) { // conditional expression - NodeArray.at(j).m_Type = CNode::TYPE_CONDITIONAL_EXPRESSION; - NodeArray.at(j).m_Arguments.RemoveAt(0); // address not needed anymore - NodeArray.at(j).m_Arguments.InsertAt(0, NodeArray.at(ulElseIndex - 2)); // true expression - NodeArray.at(j).m_Arguments.InsertAt(2, NodeArray.at(ulSkipIndex - 1)); // false expression + NodeArray[j].m_Type = CNode::TYPE_CONDITIONAL_EXPRESSION; + NodeArray[j].m_Arguments.RemoveAt(0); // address not needed anymore + NodeArray[j].m_Arguments.InsertAt(0, NodeArray[ulElseIndex - 2]); // true expression + NodeArray[j].m_Arguments.InsertAt(2, NodeArray[ulSkipIndex - 1]); // false expression NodeArray.RemoveAt(j + 1, ulSkipIndex - j - 1); continue; } @@ -556,7 +556,7 @@ void CFalloutScript::BuildTree(CNodeArray& NodeArray) { if (NodeArray.GetSize() > 0) { - BuildTreeBranch(NodeArray, 0, NodeArray.at(NodeArray.GetSize() - 1).m_ulOffset + COpcode::OPERATOR_SIZE); + BuildTreeBranch(NodeArray, 0, NodeArray[NodeArray.GetSize() - 1].m_ulOffset + COpcode::OPERATOR_SIZE); } } @@ -566,7 +566,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D CNode node; INT_PTR nNodeIndex;; - node = Source.at(nNodeIndex = NextNodeIndex(Source, nStartIndex - 1, 1)); + node = Source[nNodeIndex = NextNodeIndex(Source, nStartIndex - 1, 1)]; if (node.m_Opcode.GetOperator() != COpcode::O_JMP) { @@ -574,7 +574,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D AfxThrowUserException(); } - CNode nodeJumpAddress = node.m_Arguments.at(0); + CNode nodeJumpAddress = node.m_Arguments[0]; if (nodeJumpAddress.m_Opcode.GetOperator() != COpcode::O_INTOP) { @@ -582,11 +582,11 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D AfxThrowUserException(); } - ULONG ulJumpOffset = node.m_Arguments.at(0).m_Opcode.GetArgument(); + ULONG ulJumpOffset = node.m_Arguments[0].m_Opcode.GetArgument(); do { - node = Source.at(nNodeIndex = NextNodeIndex(Source, nNodeIndex, 1)); + node = Source[nNodeIndex = NextNodeIndex(Source, nNodeIndex, 1)]; } while(node.m_ulOffset < ulJumpOffset); @@ -594,7 +594,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D for(INT_PTR j = 0; j < nNodeIndex - nStartIndex; j++) { - Destination.at(j) = Source.at(nStartIndex + j); + Destination[j] = Source[nStartIndex + j]; } // Reduce @@ -630,7 +630,7 @@ void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& D } else { - if (Destination.at(0).m_Opcode.GetAttributes().m_Type != COpcode::COpcodeAttributes::TYPE_EXPRESSION) + if (Destination[0].m_Opcode.GetAttributes().m_Type != COpcode::COpcodeAttributes::TYPE_EXPRESSION) { printf("Error: Invalid condition. Expression required\n"); AfxThrowUserException(); @@ -651,29 +651,29 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) ULONG ulOffset; // Start of procedure - if (NodeArray.at(0).m_Opcode.GetOperator() == COpcode::O_PUSH_BASE) + if (NodeArray[0].m_Opcode.GetOperator() == COpcode::O_PUSH_BASE) { - ulOffset = NodeArray.at(0).m_ulOffset; - NodeArray.at(0) = c_NodeBeginOfBlock; - NodeArray.at(0).m_ulOffset = ulOffset; + ulOffset = NodeArray[0].m_ulOffset; + NodeArray[0] = c_NodeBeginOfBlock; + NodeArray[0].m_ulOffset = ulOffset; } // End of procedure INT_PTR nLastNodeIndex = NodeArray.GetUpperBound(); - if ((NodeArray.at(nLastNodeIndex).m_Opcode.GetOperator() == COpcode::O_POP_RETURN) && - (NodeArray.at(nLastNodeIndex).m_Opcode.GetArgument() == 0) && - (NodeArray.at(nLastNodeIndex).m_Arguments.at(0).m_Opcode.GetOperator() == COpcode::O_INTOP)) + if ((NodeArray[nLastNodeIndex].m_Opcode.GetOperator() == COpcode::O_POP_RETURN) && + (NodeArray[nLastNodeIndex].m_Opcode.GetArgument() == 0) && + (NodeArray[nLastNodeIndex].m_Arguments[0].m_Opcode.GetOperator() == COpcode::O_INTOP)) { - ulOffset = NodeArray.at(nLastNodeIndex).m_ulOffset; - NodeArray.at(nLastNodeIndex) = c_NodeEndOfBlock; - NodeArray.at(nLastNodeIndex).m_ulOffset = ulOffset; + ulOffset = NodeArray[nLastNodeIndex].m_ulOffset; + NodeArray[nLastNodeIndex] = c_NodeEndOfBlock; + NodeArray[nLastNodeIndex].m_ulOffset = ulOffset; } else { - ulOffset = NodeArray.at(nLastNodeIndex).m_ulOffset; + ulOffset = NodeArray[nLastNodeIndex].m_ulOffset; NodeArray.InsertAt(nLastNodeIndex + 1, CNode(c_NodeEndOfBlock)); - NodeArray.at(nLastNodeIndex).m_ulOffset = ulOffset; + NodeArray[nLastNodeIndex].m_ulOffset = ulOffset; } // Body @@ -681,12 +681,12 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) for(INT_PTR i = 0; i < NodeArray.GetSize(); i++) { - switch(NodeArray.at(i).m_Opcode.GetOperator()) + switch(NodeArray[i].m_Opcode.GetOperator()) { case COpcode::O_WHILE: { - CNode node = NodeArray.at(i).m_Arguments.at(0); - ULONG loopOffset = NodeArray.at(i).m_Arguments.at(1).GetTopOffset(); + CNode node = NodeArray[i].m_Arguments[0]; + ULONG loopOffset = NodeArray[i].m_Arguments[1].GetTopOffset(); if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { @@ -695,7 +695,7 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) } NodeArray.InsertAt(i + 1, CNode(c_NodeBeginOfBlock)); - NodeArray.at(i + 1).m_ulOffset = NodeArray.at(i).m_ulOffset; + NodeArray[i + 1].m_ulOffset = NodeArray[i].m_ulOffset; ulOffset = node.m_Opcode.GetArgument(); INT_PTR nNodeIndex = i + 1; @@ -703,17 +703,17 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) do { - node = NodeArray.at(nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, 1)); + 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.at(0).m_Opcode.GetArgument(); + ULONG ofs = node.m_Arguments[0].m_Opcode.GetArgument(); if (ofs == ulOffset) { - NodeArray.at(nNodeIndex).m_Type = CNode::TYPE_BREAK; + NodeArray[nNodeIndex].m_Type = CNode::TYPE_BREAK; } else if (ofs == loopOffset) { - NodeArray.at(nNodeIndex).m_Type = CNode::TYPE_CONTINUE; // continue in "while" loop + NodeArray[nNodeIndex].m_Type = CNode::TYPE_CONTINUE; // continue in "while" loop } else { @@ -724,23 +724,23 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) while(node.m_ulOffset < ulOffset); bool isForLoop = false; - if (NodeArray.at(nNodeIndex - 2).m_Arguments.GetSize() > 0 && i > 0) + if (NodeArray[nNodeIndex - 2].m_Arguments.GetSize() > 0 && i > 0) { // *might* be a "for" loop - loopOffset = NodeArray.at(nNodeIndex - 2).GetTopOffset(); + loopOffset = NodeArray[nNodeIndex - 2].GetTopOffset(); for (INT_PTR j=0; j %x", ulOffset, node.m_ulOffset); if (ulOffset > node.m_ulOffset) { NodeArray.RemoveAt(nNodeIndex - 1); // remove jump NodeArray.InsertAt(nNodeIndex, CNode(c_NodeBeginOfBlock)); - NodeArray.at(nNodeIndex).m_ulOffset = NodeArray.at(nNodeIndex + 1).m_ulOffset; + NodeArray[nNodeIndex].m_ulOffset = NodeArray[nNodeIndex + 1].m_ulOffset; - CNode Bnode = NodeArray.at(nNodeIndex - 1); - CNode Cnode = NodeArray.at(nNodeIndex + 1); + CNode Bnode = NodeArray[nNodeIndex - 1]; + CNode Cnode = NodeArray[nNodeIndex + 1]; if ((Bnode.m_Type == CNode::TYPE_END_OF_BLOCK)/* && (Cnode.m_Opcode.GetOperator() != COpcode::O_IF)*/) { do { - node = NodeArray.at(nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, 1)); + node = NodeArray[nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, 1)]; } while(node.m_ulOffset < ulOffset); NodeArray.InsertAt(nNodeIndex, CNode(c_NodeEndOfBlock)); - NodeArray.at(nNodeIndex).m_ulOffset = NodeArray.at(nNodeIndex + 1).m_ulOffset; + NodeArray[nNodeIndex].m_ulOffset = NodeArray[nNodeIndex + 1].m_ulOffset; } } } } - NodeArray.at(i).m_Arguments.RemoveAt(0); + NodeArray[i].m_Arguments.RemoveAt(0); i++; break; @@ -853,7 +853,7 @@ void CFalloutScript::ReduceConditionalExpressions(CNodeArray& NodeArray) for (INT_PTR i = 0; i < NodeArray.GetSize(); i++) { - if (NodeArray.at(i).m_Opcode.GetOperator() == COpcode::O_IF) + if (NodeArray[i].m_Opcode.GetOperator() == COpcode::O_IF) { if (ReduceExpressionBlock(NodeArray, i+1)) { diff --git a/FalloutScriptDump.cpp b/FalloutScriptDump.cpp index edd03ea..faf6222 100644 --- a/FalloutScriptDump.cpp +++ b/FalloutScriptDump.cpp @@ -34,8 +34,8 @@ void CFalloutScript::Dump(CArchive& ar) { for(unsigned int i = 0; i < m_GlobalVar.GetSize(); i++) { - wOperator = m_GlobalVar.at(i).GetOperator(); - ulArgument = m_GlobalVar.at(i).GetArgument(); + wOperator = m_GlobalVar[i].GetOperator(); + ulArgument = m_GlobalVar[i].GetArgument(); switch(wOperator) { @@ -43,7 +43,7 @@ void CFalloutScript::Dump(CArchive& ar) case COpcode::O_INTOP: strOutLine.Format("%d: %s(0x%08x) // %u (%d)\n", i, - m_GlobalVar.at(i).GetAttributes().m_strMnemonic.c_str(), + m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(), ulArgument, ulArgument, ulArgument); @@ -53,7 +53,7 @@ void CFalloutScript::Dump(CArchive& ar) case COpcode::O_FLOATOP: strOutLine.Format("%d: %s(0x%08x) // %05f\n", i, - m_GlobalVar.at(i).GetAttributes().m_strMnemonic.c_str(), + m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(), ulArgument, *((float*)(&ulArgument))); ar.WriteString(strOutLine); @@ -74,9 +74,9 @@ void CFalloutScript::Dump(CArchive& ar) { for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { - wOperator = m_ExportedVarValue.at(i).GetOperator(); - ulArgument = m_ExportedVarValue.at(i).GetArgument(); - ULONG ulNameArgument = m_ExportedVarValue.at(i + 1).GetArgument(); + wOperator = m_ExportedVarValue[i].GetOperator(); + ulArgument = m_ExportedVarValue[i].GetArgument(); + ULONG ulNameArgument = m_ExportedVarValue[i + 1].GetArgument(); switch(wOperator) { @@ -118,20 +118,20 @@ void CFalloutScript::Dump(CArchive& ar) ar.WriteString(strOutLine); ar.WriteString("===============================\n"); - for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++) + for(INT_PTR i = 0; i < m_ProcBodies[nIndexOfProc].GetSize(); i++) { - wOperator = m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetOperator(); - ulArgument = m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetArgument(); + wOperator = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetOperator(); + ulArgument = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetArgument(); switch(wOperator) { case COpcode::O_STRINGOP: case COpcode::O_INTOP: strOutLine.Format("0x%08X: 0x%04X 0x%08x - %s(0x%08x) // %u (%d)\n", - m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset, + m_ProcBodies[nIndexOfProc][i].m_ulOffset, wOperator, ulArgument, - m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str(), + m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(), ulArgument, ulArgument, ulArgument); @@ -140,19 +140,19 @@ void CFalloutScript::Dump(CArchive& ar) case COpcode::O_FLOATOP: strOutLine.Format("0x%08X: 0x%04X 0x%08X - %s // %05f\n", - m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset, + m_ProcBodies[nIndexOfProc][i].m_ulOffset, wOperator, ulArgument, - m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str(), + m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(), *((float*)(&ulArgument))); ar.WriteString(strOutLine); break; default: strOutLine.Format("0x%08X: 0x%04X - %s\n", - m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset, + m_ProcBodies[nIndexOfProc][i].m_ulOffset, wOperator, - m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str()); + m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str()); ar.WriteString(strOutLine); } } diff --git a/FalloutScriptStore.cpp b/FalloutScriptStore.cpp index b6ea726..63fa782 100644 --- a/FalloutScriptStore.cpp +++ b/FalloutScriptStore.cpp @@ -23,11 +23,11 @@ void CFalloutScript::StoreTree(CArchive& ar) ar.WriteString("Condition\n"); ar.WriteString("===============================\n"); - for(INT_PTR i = 0; i < m_Conditions.at(nIndexOfProc).GetSize(); i++) + for(INT_PTR i = 0; i < m_Conditions[nIndexOfProc].GetSize(); i++) { - strOutLine.Format("0x%08X: ", m_Conditions.at(nIndexOfProc).at(i).m_ulOffset); + strOutLine.Format("0x%08X: ", m_Conditions[nIndexOfProc][i].m_ulOffset); ar.WriteString(strOutLine); - m_Conditions.at(nIndexOfProc).at(i).StoreTree(ar, 0, 0); + m_Conditions[nIndexOfProc][i].StoreTree(ar, 0, 0); } ar.WriteString("\n"); @@ -35,11 +35,11 @@ void CFalloutScript::StoreTree(CArchive& ar) ar.WriteString("===============================\n"); } - for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++) + for(INT_PTR i = 0; i < m_ProcBodies[nIndexOfProc].GetSize(); i++) { - strOutLine.Format("0x%08X: ", m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset); + strOutLine.Format("0x%08X: ", m_ProcBodies[nIndexOfProc][i].m_ulOffset); ar.WriteString(strOutLine); - m_ProcBodies.at(nIndexOfProc).at(i).StoreTree(ar, 0, 0); + m_ProcBodies[nIndexOfProc][i].StoreTree(ar, 0, 0); } ar.WriteString("\n"); @@ -79,11 +79,11 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) for(INT_PTR i = 0; i < m_GlobalVar.GetSize(); i++) { - ulVarValue = m_GlobalVar.at(i).GetArgument(); + ulVarValue = m_GlobalVar[i].GetArgument(); strDefinition += "variable "; - strDefinition += m_GlobalVarsNames.at(i); + strDefinition += m_GlobalVarsNames[i]; - switch(m_GlobalVar.at(i).GetOperator()) + switch(m_GlobalVar[i].GetOperator()) { case COpcode::O_STRINGOP: strDefinition.Format(strDefinition + " := \"%s\"", m_Stringspace[ulVarValue].c_str()); @@ -103,7 +103,7 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) strDefinition += ";"; - if ((m_GlobalVar.at(i).GetOperator() == COpcode::O_INTOP) && (ulVarValue & 0x80000000)) + if ((m_GlobalVar[i].GetOperator() == COpcode::O_INTOP) && (ulVarValue & 0x80000000)) { strDefinition.Format(strDefinition + " /* (%d) */", ulVarValue); } @@ -381,7 +381,7 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) } else if (procDescriptor.m_ulType & P_CONDITIONAL) { - strOutLine.Format(strOutLine + " when (%s)", GetSource(m_Conditions.at(i).at(0), FALSE, procDescriptor.m_ulNumArgs).c_str()); + strOutLine.Format(strOutLine + " when (%s)", GetSource(m_Conditions[i][0], FALSE, procDescriptor.m_ulNumArgs).c_str()); } ar.WriteString(strOutLine + "\n"); @@ -391,11 +391,11 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) INT_PTR nIndentLevel = 0; CNode::Type prevNodeType = CNode::TYPE_NORMAL; - for(INT_PTR nNodeIndex = 0; nNodeIndex < m_ProcBodies.at(i).GetSize(); nNodeIndex++) + for(INT_PTR nNodeIndex = 0; nNodeIndex < m_ProcBodies[i].GetSize(); nNodeIndex++) { - if (m_ProcBodies.at(i).at(nNodeIndex).m_Type == CNode::TYPE_BEGIN_OF_BLOCK) + if (m_ProcBodies[i][nNodeIndex].m_Type == CNode::TYPE_BEGIN_OF_BLOCK) { - if ((nNodeIndex - 1 > 0) && (m_ProcBodies.at(i).at(nNodeIndex - 1).m_Type == CNode::TYPE_END_OF_BLOCK)) + if ((nNodeIndex - 1 > 0) && (m_ProcBodies[i][nNodeIndex - 1].m_Type == CNode::TYPE_END_OF_BLOCK)) { ar.WriteString(GetIndentString(nIndentLevel) + "else begin\n"); nIndentLevel++; @@ -407,7 +407,7 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) } prevNodeType = CNode::TYPE_BEGIN_OF_BLOCK; } - else if (m_ProcBodies.at(i).at(nNodeIndex).m_Type == CNode::TYPE_END_OF_BLOCK) + else if (m_ProcBodies[i][nNodeIndex].m_Type == CNode::TYPE_END_OF_BLOCK) { nIndentLevel--; ar.WriteString(GetIndentString(nIndentLevel) + "end\n"); @@ -416,12 +416,12 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) else { prevNodeType = CNode::TYPE_NORMAL; - WORD wOperator = m_ProcBodies.at(i).at(nNodeIndex).m_Opcode.GetOperator(); + WORD wOperator = m_ProcBodies[i][nNodeIndex].m_Opcode.GetOperator(); - if ((m_ProcBodies.at(i).at(nNodeIndex).m_Opcode.GetAttributes().m_Type == COpcode::COpcodeAttributes::TYPE_EXPRESSION) && + if ((m_ProcBodies[i][nNodeIndex].m_Opcode.GetAttributes().m_Type == COpcode::COpcodeAttributes::TYPE_EXPRESSION) && (wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_FLOATOP) && (wOperator != COpcode::O_INTOP)) { - printf("Warning: Result of expression is left in stack. (Opcode 0x%04X at 0x%08X)\n", wOperator, m_ProcBodies.at(i).at(nNodeIndex).m_ulOffset); + printf("Warning: Result of expression is left in stack. (Opcode 0x%04X at 0x%08X)\n", wOperator, m_ProcBodies[i][nNodeIndex].m_ulOffset); } switch(wOperator) @@ -439,40 +439,40 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) str += c_strLocalVarTemplate + " := "; strOutLine.Format(str.c_str(), ulLocalVarIndex); - ar.WriteString(GetIndentString(nIndentLevel) + strOutLine + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + ";\n"); + ar.WriteString(GetIndentString(nIndentLevel) + strOutLine + GetSource(m_ProcBodies[i][nNodeIndex], FALSE, procDescriptor.m_ulNumArgs) + ";\n"); ulLocalVarIndex++; break; } case COpcode::O_IF: - ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + " then "); + ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies[i][nNodeIndex], FALSE, procDescriptor.m_ulNumArgs) + " then "); break; case COpcode::O_WHILE: - if (m_ProcBodies.at(i).at(nNodeIndex).m_Type == CNode::TYPE_FOR_LOOP) + if (m_ProcBodies[i][nNodeIndex].m_Type == CNode::TYPE_FOR_LOOP) { CString str = GetIndentString(nIndentLevel) + "for ("; - for (INT_PTR j = 0; j < m_ProcBodies.at(i).at(nNodeIndex).m_Arguments.GetSize(); j++) + for (INT_PTR j = 0; j < m_ProcBodies[i][nNodeIndex].m_Arguments.GetSize(); j++) { if (j > 0) { str += "; "; } - str += GetSource(m_ProcBodies.at(i).at(nNodeIndex).m_Arguments.at(j), FALSE, procDescriptor.m_ulNumArgs); + str += GetSource(m_ProcBodies[i][nNodeIndex].m_Arguments[j], FALSE, procDescriptor.m_ulNumArgs); } str += ") "; ar.WriteString(str); } else { - ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + " do "); + ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies[i][nNodeIndex], FALSE, procDescriptor.m_ulNumArgs) + " do "); } break; default: - ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + ";\n"); + ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies[i][nNodeIndex], FALSE, procDescriptor.m_ulNumArgs) + ";\n"); - if ((m_ProcBodies.at(i).at(nNodeIndex).m_Type != CNode::TYPE_BEGIN_OF_BLOCK) && - (m_ProcBodies.at(i).at(nNodeIndex).m_Type != CNode::TYPE_END_OF_BLOCK)) + if ((m_ProcBodies[i][nNodeIndex].m_Type != CNode::TYPE_BEGIN_OF_BLOCK) && + (m_ProcBodies[i][nNodeIndex].m_Type != CNode::TYPE_END_OF_BLOCK)) { bLocalVar = FALSE; } @@ -561,48 +561,50 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) case COpcode::O_POP_RETURN: strResult = "return "; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs); break; case COpcode::O_LOOKUP_STRING_PROC: - strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult = GetSource(node.m_Arguments[0], FALSE, ulNumArgs); break; case COpcode::O_FETCH_GLOBAL: - if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) + if (node.m_Arguments[0].m_Opcode.GetOperator() != COpcode::O_INTOP) { printf("Error: Invalid argument to O_FETCH_GLOBAL opcode\n"); AfxThrowUserException(); } - if (INT_PTR(node.m_Arguments.at(0).m_Opcode.GetArgument()) > m_GlobalVarsNames.GetUpperBound()) + if (INT_PTR(node.m_Arguments[0].m_Opcode.GetArgument()) > m_GlobalVarsNames.GetUpperBound()) { printf("Error: Invalid index of global variable\n"); AfxThrowUserException(); } - strResult = m_GlobalVarsNames.at(node.m_Arguments.at(0).m_Opcode.GetArgument()); + strResult = m_GlobalVarsNames[node.m_Arguments[0].m_Opcode.GetArgument()]; break; case COpcode::O_STORE_GLOBAL: - if (node.m_Arguments.at(1).m_Opcode.GetOperator() != COpcode::O_INTOP) + if (node.m_Arguments[1].m_Opcode.GetOperator() != COpcode::O_INTOP) { printf("Error: Invalid argument to O_STORE_GLOBAL opcode\n"); AfxThrowUserException(); } - if (INT_PTR(node.m_Arguments.at(1).m_Opcode.GetArgument()) > m_GlobalVarsNames.GetUpperBound()) + if (INT_PTR(node.m_Arguments[1].m_Opcode.GetArgument()) > m_GlobalVarsNames.GetUpperBound()) { printf("Error: Invalid index of global variable\n"); AfxThrowUserException(); } - strResult = m_GlobalVarsNames.at(node.m_Arguments.at(1).m_Opcode.GetArgument()) + " := " + GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult = m_GlobalVarsNames[node.m_Arguments[1].m_Opcode.GetArgument()]; + strResult += " := "; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs); break; case COpcode::O_FETCH_EXTERNAL: { - WORD wOperator = node.m_Arguments.at(0).m_Opcode.GetOperator(); + WORD wOperator = node.m_Arguments[0].m_Opcode.GetOperator(); if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { @@ -611,12 +613,12 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) } } - strResult = GetSource(node.m_Arguments.at(0), TRUE, ulNumArgs); + strResult = GetSource(node.m_Arguments[0], TRUE, ulNumArgs); break; case COpcode::O_STORE_EXTERNAL: { - WORD wOperator = node.m_Arguments.at(1).m_Opcode.GetOperator(); + WORD wOperator = node.m_Arguments[1].m_Opcode.GetOperator(); if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { @@ -625,18 +627,20 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) } } - strResult = GetSource(node.m_Arguments.at(1), TRUE, ulNumArgs) + " := " + GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult = GetSource(node.m_Arguments[1], TRUE, ulNumArgs); + strResult += " := "; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs); break; case COpcode::O_FETCH: - if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) + if (node.m_Arguments[0].m_Opcode.GetOperator() != COpcode::O_INTOP) { printf("Error: Invalid argument to O_FETCH opcode\n"); AfxThrowUserException(); } { - ULONG ulVarNum = node.m_Arguments.at(0).m_Opcode.GetArgument(); + ULONG ulVarNum = node.m_Arguments[0].m_Opcode.GetArgument(); if (ulVarNum < ulNumArgs) { @@ -651,14 +655,14 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) break; case COpcode::O_STORE: - if (node.m_Arguments.at(1).m_Opcode.GetOperator() != COpcode::O_INTOP) + if (node.m_Arguments[1].m_Opcode.GetOperator() != COpcode::O_INTOP) { printf("Error: Invalid argument to O_STORE opcode\n"); AfxThrowUserException(); } { - ULONG ulVarNum = node.m_Arguments.at(1).m_Opcode.GetArgument(); + ULONG ulVarNum = node.m_Arguments[1].m_Opcode.GetArgument(); if (ulVarNum < ulNumArgs) { strResult.Format(c_strArgumentTemplate.c_str(), ulVarNum); @@ -668,30 +672,29 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) strResult.Format(c_strLocalVarTemplate.c_str(), ulVarNum); } strResult += " := "; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs); } break; case COpcode::O_POP: - strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult = GetSource(node.m_Arguments[0], FALSE, ulNumArgs); - if (node.m_Arguments.at(0).m_Opcode.GetOperator() == COpcode::O_CALL) + if (node.m_Arguments[0].m_Opcode.GetOperator() == COpcode::O_CALL) { - strResult = "call "; - strResult += strResult; + strResult = "call " + strResult.str(); } break; case COpcode::O_CALL: - if (node.m_Arguments.at(node.m_Arguments.GetUpperBound()).m_Opcode.GetOperator() == COpcode::O_INTOP) + if (node.m_Arguments[node.m_Arguments.GetUpperBound()].m_Opcode.GetOperator() == COpcode::O_INTOP) { - strResult = m_Namespace[m_ProcTable[node.m_Arguments.at(node.m_Arguments.GetUpperBound()).m_Opcode.GetArgument()].m_ulNameOffset]; + strResult = m_Namespace[m_ProcTable[node.m_Arguments[node.m_Arguments.GetUpperBound()].m_Opcode.GetArgument()].m_ulNameOffset]; } else { - strResult = GetSource(node.m_Arguments.at(node.m_Arguments.GetUpperBound()), FALSE, ulNumArgs); + strResult = GetSource(node.m_Arguments[node.m_Arguments.GetUpperBound()], FALSE, ulNumArgs); } strResult += "("; @@ -700,12 +703,12 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) { if (nArgIndex == 0) { - strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } else { strResult += ", "; - strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } } @@ -716,49 +719,49 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) case COpcode::O_CALL_AT: strResult = "call "; - if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) + if (node.m_Arguments[1].m_Opcode.GetOperator() == COpcode::O_INTOP) { - strResult += m_Namespace[m_ProcTable[node.m_Arguments.at(1).m_Opcode.GetArgument()].m_ulNameOffset]; + strResult += m_Namespace[m_ProcTable[node.m_Arguments[1].m_Opcode.GetArgument()].m_ulNameOffset]; } else { - strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[1], FALSE, ulNumArgs); } strResult += " in ("; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs) + ")"; break; case COpcode::O_CALL_CONDITION: strResult = "call "; - if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) + if (node.m_Arguments[1].m_Opcode.GetOperator() == COpcode::O_INTOP) { - strResult += m_Namespace[m_ProcTable[node.m_Arguments.at(1).m_Opcode.GetArgument()].m_ulNameOffset]; + strResult += m_Namespace[m_ProcTable[node.m_Arguments[1].m_Opcode.GetArgument()].m_ulNameOffset]; } else { - strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[1], FALSE, ulNumArgs); } strResult += " when ("; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs) + ")"; break; case COpcode::O_ADDREGION: strResult = "addRegion "; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + " { "; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs) + " { "; for(INT_PTR nArgIndex = 1; nArgIndex < node.m_Arguments.GetUpperBound(); nArgIndex++) { if (nArgIndex == 1) { - strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } else { strResult += ", "; - strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } } @@ -791,7 +794,7 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) case COpcode::O_SAYOPTION: { - if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) + if (node.m_Arguments[1].m_Opcode.GetOperator() == COpcode::O_INTOP) { ULONG aulProcArg[2] = { 2 }; strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); @@ -799,7 +802,7 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) else { strResult = "sayOption("; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ", " + GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs) + ", " + GetSource(node.m_Arguments[1], FALSE, ulNumArgs) + ")"; } } @@ -862,26 +865,26 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) break; case COpcode::O_CANCEL: - if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) + if (node.m_Arguments[0].m_Opcode.GetOperator() != COpcode::O_INTOP) { printf("Error: Invalid argument to O_CANCEL opcode\n"); AfxThrowUserException(); } strResult = "cancel("; - strResult += m_Namespace[m_ProcTable[node.m_Arguments.at(0).m_Opcode.GetArgument()].m_ulNameOffset] + ")"; + strResult += m_Namespace[m_ProcTable[node.m_Arguments[0].m_Opcode.GetArgument()].m_ulNameOffset] + ")"; break; case COpcode::O_NEGATE: - if (node.m_Arguments.at(0).m_Opcode.GetAttributes().m_Category == COpcode::COpcodeAttributes::CATEGORY_INFIX) + if (node.m_Arguments[0].m_Opcode.GetAttributes().m_Category == COpcode::COpcodeAttributes::CATEGORY_INFIX) { strResult = "-("; - strResult += GetSource(node.m_Arguments.at(0), bLabel, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[0], bLabel, ulNumArgs) + ")"; } else { strResult = "-"; - strResult += GetSource(node.m_Arguments.at(0), bLabel, ulNumArgs); + strResult += GetSource(node.m_Arguments[0], bLabel, ulNumArgs); } break; @@ -906,36 +909,36 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) strResult = ""; for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) { - bool bParens = ArgNeedParens(node, node.m_Arguments.at(i), CFalloutScript::RIGHT_ASSOC); - strResult += (bParens ? CString("(") : CString("")) + GetSource(node.m_Arguments.at(i), bLabel, ulNumArgs) + (bParens ? ")" : "") + sPostfix[i]; + bool bParens = ArgNeedParens(node, node.m_Arguments[i], CFalloutScript::RIGHT_ASSOC); + strResult += (bParens ? CString("(") : CString("")) + GetSource(node.m_Arguments[i], bLabel, ulNumArgs) + (bParens ? ")" : "") + sPostfix[i]; } break; } switch(attributes.m_Category) { case COpcode::COpcodeAttributes::CATEGORY_INFIX: - if (ArgNeedParens(node, node.m_Arguments.at(0), CFalloutScript::LEFT_ASSOC)) + if (ArgNeedParens(node, node.m_Arguments[0], CFalloutScript::LEFT_ASSOC)) { strResult = "("; - strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[0], FALSE, ulNumArgs) + ")"; } else { - strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); + strResult = GetSource(node.m_Arguments[0], FALSE, ulNumArgs); } strResult += " "; strResult += attributes.m_strName + " "; - if (ArgNeedParens(node, node.m_Arguments.at(1), CFalloutScript::RIGHT_ASSOC)) + if (ArgNeedParens(node, node.m_Arguments[1], CFalloutScript::RIGHT_ASSOC)) { strResult += "("; - strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs) + ")"; + strResult += GetSource(node.m_Arguments[1], FALSE, ulNumArgs) + ")"; } else { - strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[1], FALSE, ulNumArgs); } break; @@ -956,12 +959,12 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) { if (i == 0) { - strResult += GetSource(node.m_Arguments.at(i), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[i], FALSE, ulNumArgs); } else { strResult += ", "; - strResult += GetSource(node.m_Arguments.at(i), FALSE, ulNumArgs); + strResult += GetSource(node.m_Arguments[i], FALSE, ulNumArgs); } } @@ -997,28 +1000,28 @@ CString CFalloutScript::GetSource( CNode& node, BOOL bLabel, ULONG ulNumArgs, UL if (bIsProcArg) { - if (node.m_Arguments.at(nArgIndex).m_Opcode.GetOperator() == COpcode::O_INTOP) + if (node.m_Arguments[nArgIndex].m_Opcode.GetOperator() == COpcode::O_INTOP) { try { - strArgument = m_Namespace[m_ProcTable[node.m_Arguments.at(nArgIndex).m_Opcode.GetArgument()].m_ulNameOffset]; + strArgument = m_Namespace[m_ProcTable[node.m_Arguments[nArgIndex].m_Opcode.GetArgument()].m_ulNameOffset]; } catch(UserException& e) { printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); - strArgument.Format("/* Fake object name: %u (%d)*/", node.m_Arguments.at(nArgIndex).m_Opcode.GetArgument(), node.m_Arguments.at(nArgIndex).m_Opcode.GetArgument()); + strArgument.Format("/* Fake object name: %u (%d)*/", node.m_Arguments[nArgIndex].m_Opcode.GetArgument(), node.m_Arguments[nArgIndex].m_Opcode.GetArgument()); } } else { - strArgument = GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strArgument = GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } } else { - strArgument = GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); + strArgument = GetSource(node.m_Arguments[nArgIndex], FALSE, ulNumArgs); } if (nArgIndex == 0) diff --git a/Hacks/CArchive.cpp b/Hacks/CArchive.cpp index 9663851..d090b40 100644 --- a/Hacks/CArchive.cpp +++ b/Hacks/CArchive.cpp @@ -18,7 +18,6 @@ CFile* CArchive::GetFile() void CArchive::WriteString(const char * value) { - std::cout << _file->_ostream.is_open() << std::endl; _file->_ostream << value; } diff --git a/Hacks/CArray.h b/Hacks/CArray.h index df96552..4778d66 100644 --- a/Hacks/CArray.h +++ b/Hacks/CArray.h @@ -13,6 +13,16 @@ public: { } + A& operator[](ULONG offset) + { + return _vector[offset]; + } + + const A& operator[](ULONG offset) const + { + return _vector[offset]; + } + void RemoveAll() { while (!_vector.empty()) _vector.pop_back(); @@ -54,13 +64,9 @@ public: _vector.insert(_vector.begin() + position, value); } - A& at(ULONG n) - { - return _vector.at(n); - } - void Copy(CArray source) { + _vector.clear(); for (auto it = source._vector.begin(); it != source._vector.end(); ++it) { _vector.push_back(*it); diff --git a/Hacks/CString.cpp b/Hacks/CString.cpp index a1984d2..81331c2 100644 --- a/Hacks/CString.cpp +++ b/Hacks/CString.cpp @@ -28,7 +28,7 @@ const char * CString::c_str() const CString& CString::operator=(const char* value) { - _string += value; + _string = value; return *this; } @@ -40,7 +40,7 @@ CString& CString::operator+=(const char* value) CString& CString::operator+(const char* value) { - _string += value; + _string = _string + value; return *this; } diff --git a/Namespace.cpp b/Namespace.cpp index 41eda77..1e20951 100644 --- a/Namespace.cpp +++ b/Namespace.cpp @@ -122,12 +122,12 @@ INT_PTR CNamespace::GetSize() const CString CNamespace::GetStringByIndex(INT_PTR nIndex) { - return (this->operator [] (m_Order.at(nIndex))); + return (this->operator [] (m_Order[nIndex])); } ULONG CNamespace::GetOffsetByIndex(INT_PTR nIndex) { - return m_Order.at(nIndex); + return m_Order[nIndex]; } void CNamespace::Dump(CArchive& ar) @@ -142,7 +142,7 @@ void CNamespace::Dump(CArchive& ar) { for(unsigned int i = 0; i < m_Order.GetSize(); i++) { - strOutLine.Format("0x%08X: \"%s\"\n", m_Order.at(i), GetStringByIndex(i).c_str()); + strOutLine.Format("0x%08X: \"%s\"\n", m_Order[i], GetStringByIndex(i).c_str()); ar.WriteString(strOutLine); } diff --git a/Node.cpp b/Node.cpp index 6755998..7e595e6 100644 --- a/Node.cpp +++ b/Node.cpp @@ -87,7 +87,7 @@ void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex) { for(int i = 0; i < m_Arguments.GetSize(); i++) { - m_Arguments.at(i).StoreTree(ar, nIndent + 1, i); + m_Arguments[i].StoreTree(ar, nIndent + 1, i); } } else @@ -101,7 +101,7 @@ ULONG CNode::GetTopOffset() { if (m_Arguments.GetSize() > 0) { - return m_Arguments.at(0).GetTopOffset(); + return m_Arguments[0].GetTopOffset(); } else { diff --git a/ProcTable.cpp b/ProcTable.cpp index 0b2564e..42c014e 100644 --- a/ProcTable.cpp +++ b/ProcTable.cpp @@ -207,20 +207,20 @@ void CProcTable::Serialize(CArchive& ar) for(ULONG i = 0; i < ulSizeOfTable; i++) { // printf("======== %u =========\n", i); - m_Table.at(i).Serialize(ar); - m_ProcSize.at(i) = 0; // Initialize size of procedure + m_Table[i].Serialize(ar); + m_ProcSize[i] = 0; // Initialize size of procedure - if (!(m_Table.at(i).m_ulType & P_IMPORT)) + if (!(m_Table[i].m_ulType & P_IMPORT)) { - if ((m_Table.at(i).m_ulBodyOffset != 0) && (m_Table.at(i).m_ulBodyOffset != ulSizeOfFile)) + if ((m_Table[i].m_ulBodyOffset != 0) && (m_Table[i].m_ulBodyOffset != ulSizeOfFile)) { pOffsets[ulIndexOfProcOffset].m_ulProcIndex = i; - pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = m_Table.at(i).m_ulBodyOffset; + pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = m_Table[i].m_ulBodyOffset; ulIndexOfProcOffset++; } else { - m_Table.at(i).m_ulType |= P_NOTIMPLEMENTED; + m_Table[i].m_ulType |= P_NOTIMPLEMENTED; } } } @@ -235,7 +235,7 @@ void CProcTable::Serialize(CArchive& ar) { if (pOffsets[i + 1].m_ulBodyOffset >= pOffsets[i].m_ulBodyOffset) { - m_ProcSize.at(pOffsets[i].m_ulProcIndex) = pOffsets[i + 1].m_ulBodyOffset - pOffsets[i].m_ulBodyOffset; + m_ProcSize[pOffsets[i].m_ulProcIndex] = pOffsets[i + 1].m_ulBodyOffset - pOffsets[i].m_ulBodyOffset; } else { @@ -248,9 +248,9 @@ void CProcTable::Serialize(CArchive& ar) for(ULONG i = 0; i < ulSizeOfTable; i++) { - if (m_Table.at(i).m_ulBodyOffset != 0) + if (m_Table[i].m_ulBodyOffset != 0) { - m_ulOffsetOfProcSection = m_Table.at(i).m_ulBodyOffset; + m_ulOffsetOfProcSection = m_Table[i].m_ulBodyOffset; break; } } @@ -260,7 +260,7 @@ void CProcTable::Serialize(CArchive& ar) // for(i = 0; i < ulSizeOfTable; i++) // { -// printf("Offset: 0x%08X, size: 0x%08X\n", m_Table.at(i).m_ulBodyOffset, m_ProcSize.at(i)); +// printf("Offset: 0x%08X, size: 0x%08X\n", m_Table[i].m_ulBodyOffset, m_ProcSize[i]); // } // printf("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection); @@ -279,7 +279,7 @@ ULONG CProcTable::GetSizeOfProc(INT_PTR nIndex) AfxThrowUserException(); } - return m_ProcSize.at(nIndex); + return m_ProcSize[nIndex]; } ULONG CProcTable::GetOffsetOfProcSection() @@ -297,7 +297,7 @@ void CProcTable::Dump(CArchive& ar) strOutLine.Format("======== Procedure %d ========\n", i); ar.WriteString(strOutLine); - m_Table.at(i).Dump(ar); + m_Table[i].Dump(ar); ar.WriteString("\n"); } } @@ -311,5 +311,5 @@ CProcDescriptor& CProcTable::operator [] (INT_PTR nIndex) AfxThrowUserException(); } - return m_Table.at(nIndex); + return m_Table[nIndex]; } diff --git a/main.cpp b/main.cpp index 8cd097b..f197cc6 100644 --- a/main.cpp +++ b/main.cpp @@ -41,23 +41,23 @@ int main(int argc, char* argv[]) printf(" --: end of options\n"); printf("\n"); -// if (argc < 2) -// { -// PrintUsage(argv[0]); -// cin.get(); -// return 1; -// } + if (argc < 2) + { + PrintUsage(argv[0]); + cin.get(); + return 1; + } -// if (!ProcessCommandLine(argc, argv)) -// { -// return 1; -// } + if (!ProcessCommandLine(argc, argv)) + { + return 1; + } CFile fileInput; CFile fileOutput; - g_strInputFileName = "BECA.int"; - g_strOutputFileName = "BECA.int.ssl"; + //g_strInputFileName = "BECA.int"; + //g_strOutputFileName = "BECA.int.ssl"; if (!fileInput.Open(g_strInputFileName, CFile::modeRead | CFile::shareDenyWrite)) {