From fc7d3e31ac2772d10e773241e595d9180f3c8ad6 Mon Sep 17 00:00:00 2001 From: alexeevdv Date: Sat, 14 Feb 2015 13:39:47 +0300 Subject: [PATCH] Code formating --- FalloutScript.cpp | 80 +- FalloutScript.h | 136 ++-- FalloutScriptDecompile.cpp | 804 +++++++++---------- FalloutScriptDefObject.cpp | 16 +- FalloutScriptDump.cpp | 186 ++--- FalloutScriptStore.cpp | 1238 ++++++++++++++--------------- Hacks/CArchive.cpp | 1 - Namespace.cpp | 134 ++-- Namespace.h | 20 +- Node.cpp | 130 ++-- Node.h | 44 +- ObjectAttributes.h | 18 +- Opcode.cpp | 160 ++-- Opcode.h | 1434 +++++++++++++++++----------------- OpcodeAttributes.cpp | 1496 ++++++++++++++++++------------------ ProcTable.cpp | 330 ++++---- ProcTable.h | 50 +- StartupCode.h | 14 +- Utility.cpp | 6 +- main.cpp | 397 +++++----- 20 files changed, 3350 insertions(+), 3344 deletions(-) diff --git a/FalloutScript.cpp b/FalloutScript.cpp index d1e6f5c..68b6be2 100644 --- a/FalloutScript.cpp +++ b/FalloutScript.cpp @@ -184,7 +184,7 @@ void CFalloutScript::Serialize(CArchive& ar) // Procedures bodyes printf(" Read procedure\'s bodies\n"); - m_ProcBodies.RemoveAll(); // Destroy old data + m_ProcBodies.RemoveAll(); // Destroy old data m_Conditions.RemoveAll(); m_ProcBodies.SetSize(m_ProcTable.GetSize()); m_Conditions.SetSize(m_ProcTable.GetSize()); @@ -211,71 +211,71 @@ void CFalloutScript::Serialize(CArchive& ar) void CFalloutScript::ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, WORD wDelimeter, int nSizeOfCodeItem, LPCTSTR lpszErrorMessage, BOOL (CFalloutScript::*pCheckFunc)(WORD, INT_PTR)) { - INT_PTR i = 0; + INT_PTR i = 0; - for(; i < Source.GetSize(); i++) { + for(; i < Source.GetSize(); i++) { if (Source.at(i).GetOperator() == wDelimeter) { - break; - } - } + break; + } + } - if (i < Source.GetSize()) { - if (i < nSizeOfCodeItem - 1) { - printf(lpszErrorMessage); - AfxThrowUserException(); - } + if (i < Source.GetSize()) { + if (i < nSizeOfCodeItem - 1) { + printf(lpszErrorMessage); + AfxThrowUserException(); + } while(Source.at(i).GetOperator() == wDelimeter) { - for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { + for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { if (!((this->*pCheckFunc)(Source.at(i - nSizeOfCodeItem + 1 + j).GetOperator(), j))) { - printf(lpszErrorMessage); - AfxThrowUserException(); - } - } + printf(lpszErrorMessage); + AfxThrowUserException(); + } + } - for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { + for(INT_PTR j = 0; j < nSizeOfCodeItem - 1; j++) { Destination.Add(Source.at(i - nSizeOfCodeItem + 1)); - Source.RemoveAt(i - nSizeOfCodeItem + 1); - } + Source.RemoveAt(i - nSizeOfCodeItem + 1); + } - Source.RemoveAt(i - nSizeOfCodeItem + 1); // Delimeter + Source.RemoveAt(i - nSizeOfCodeItem + 1); // Delimeter - if (i > Source.GetUpperBound()) { - break; - } - } - } + if (i > Source.GetUpperBound()) { + break; + } + } + } } BOOL CFalloutScript::CheckExportVarCode(WORD wOperator, INT_PTR nIndex) { - return (nIndex == 0) && (wOperator == COpcode::O_STRINGOP); + return (nIndex == 0) && (wOperator == COpcode::O_STRINGOP); } BOOL CFalloutScript::CheckSetExportedVarValueCode(WORD wOperator, INT_PTR nIndex) { - switch(nIndex) { - case 0: - return (wOperator == COpcode::O_STRINGOP) || - (wOperator == COpcode::O_FLOATOP) || - (wOperator == COpcode::O_INTOP); - case 1: - return (wOperator == COpcode::O_STRINGOP); + switch(nIndex) { + case 0: + return (wOperator == COpcode::O_STRINGOP) || + (wOperator == COpcode::O_FLOATOP) || + (wOperator == COpcode::O_INTOP); + case 1: + return (wOperator == COpcode::O_STRINGOP); - default: - return FALSE; - } + default: + return FALSE; + } } BOOL CFalloutScript::CheckExportProcCode(WORD wOperator, INT_PTR nIndex) { - return ((nIndex == 0) || (nIndex == 1)) && (wOperator == COpcode::O_INTOP); + return ((nIndex == 0) || (nIndex == 1)) && (wOperator == COpcode::O_INTOP); } bool CFalloutScript::ArgNeedParens( const CNode& node, const CNode& argument, CFalloutScript::Assoc assoc) { - return (argument.IsInfix() - && ((GetPriority(argument.m_Opcode.GetOperator()) != GetPriority(node.m_Opcode.GetOperator())) - || (GetAssociation(node.m_Opcode.GetOperator()) != assoc))); + return (argument.IsInfix() + && ((GetPriority(argument.m_Opcode.GetOperator()) != GetPriority(node.m_Opcode.GetOperator())) + || (GetAssociation(node.m_Opcode.GetOperator()) != assoc))); } diff --git a/FalloutScript.h b/FalloutScript.h index 46463b7..7b2fb97 100644 --- a/FalloutScript.h +++ b/FalloutScript.h @@ -14,105 +14,105 @@ // CFalloutScript class CFalloutScript : public CObject { public: - CFalloutScript(); - virtual ~CFalloutScript(); + CFalloutScript(); + virtual ~CFalloutScript(); public: - virtual void Serialize(CArchive& ar); + virtual void Serialize(CArchive& ar); - void Dump(CArchive& ar); + void Dump(CArchive& ar); - void InitDefinitions(); - void ProcessCode(); + void InitDefinitions(); + void ProcessCode(); - void StoreSource(CArchive& ar); - void StoreTree(CArchive& ar); + void StoreSource(CArchive& ar); + void StoreTree(CArchive& ar); private: - enum Assoc { - NON_ASSOC, - LEFT_ASSOC, - RIGHT_ASSOC, - }; + enum Assoc { + NON_ASSOC, + LEFT_ASSOC, + RIGHT_ASSOC, + }; private: - void ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, WORD wDelimeter, int nSizeOfCodeItem, LPCTSTR lpszErrorMessage, BOOL (CFalloutScript::*pCheckFunc)(WORD, INT_PTR)); - BOOL CheckExportVarCode(WORD wOperator, INT_PTR nIndex); - BOOL CheckSetExportedVarValueCode(WORD wOperator, INT_PTR nIndex); - BOOL CheckExportProcCode(WORD wOperator, INT_PTR nIndex); + void ExtractCodeElements(COpcodeArray& Source, COpcodeArray& Destination, WORD wDelimeter, int nSizeOfCodeItem, LPCTSTR lpszErrorMessage, BOOL (CFalloutScript::*pCheckFunc)(WORD, INT_PTR)); + BOOL CheckExportVarCode(WORD wOperator, INT_PTR nIndex); + BOOL CheckSetExportedVarValueCode(WORD wOperator, INT_PTR nIndex); + BOOL CheckExportProcCode(WORD wOperator, INT_PTR nIndex); INT_PTR GetIndexOfProc(const char* lpszName); - INT_PTR GetIndexOfProc(ULONG ulNameOffset); - INT_PTR GetIndexOfExportedVariable(ULONG ulNameOffset); + INT_PTR GetIndexOfProc(ULONG ulNameOffset); + INT_PTR GetIndexOfExportedVariable(ULONG ulNameOffset); - void SetExternalVariable(ULONG ulNameOffset); - void TryRenameGlobalVariables(); - void TryRenameImportedVariables(); + void SetExternalVariable(ULONG ulNameOffset); + void TryRenameGlobalVariables(); + void TryRenameImportedVariables(); INT_PTR NextNodeIndex( CNodeArray& NodeArray, INT_PTR nCurrentIndex, INT_PTR nSteep); - BOOL CheckSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, const WORD wSequence[], INT_PTR nSequenceLen); - BOOL RemoveSequenceOfNodes(CNodeArray& NodeArray,INT_PTR nStartIndex, INT_PTR nCount, const WORD wSequence[], INT_PTR nSequenceLen); + BOOL CheckSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, const WORD wSequence[], INT_PTR nSequenceLen); + BOOL RemoveSequenceOfNodes(CNodeArray& NodeArray,INT_PTR nStartIndex, INT_PTR nCount, const WORD wSequence[], INT_PTR nSequenceLen); - void InitialReduce(); - 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); - void ReduceConditionalExpressions(CNodeArray& NodeArray); - BOOL IsOmittetArgsAllowed(WORD wOpcode); + void InitialReduce(); + 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); + void ReduceConditionalExpressions(CNodeArray& NodeArray); + BOOL IsOmittetArgsAllowed(WORD wOpcode); - void StoreDefinitions(CArchive& ar); - void StoreDeclarations(CArchive& ar); + void StoreDefinitions(CArchive& ar); + void StoreDeclarations(CArchive& ar); CString GetSource( CNode& node, BOOL bLabel, ULONG ulNumArgs); CString GetSource( CNode& node, BOOL bLabel, ULONG ulNumArgs, ULONG aulProcArg[], ULONG ulProcArgCount); - bool ArgNeedParens(const CNode& node, const CNode& argument, CFalloutScript::Assoc assoc = CFalloutScript::NON_ASSOC); - CString GetIndentString(INT_PTR nLevel); + bool ArgNeedParens(const CNode& node, const CNode& argument, CFalloutScript::Assoc assoc = CFalloutScript::NON_ASSOC); + CString GetIndentString(INT_PTR nLevel); - int GetPriority(WORD wOperator); - Assoc GetAssociation(WORD wOperator); + int GetPriority(WORD wOperator); + Assoc GetAssociation(WORD wOperator); private: - // CDefObject - class CDefObject { - public: - enum ObjectType { - OBJECT_VARIABLE, - OBJECT_PROCEDURE - }; + // CDefObject + class CDefObject { + public: + enum ObjectType { + OBJECT_VARIABLE, + OBJECT_PROCEDURE + }; - public: - CDefObject(ObjectType type = OBJECT_VARIABLE, ULONG ulAttributes = 0, ULONG ulObjectData = 0); + public: + CDefObject(ObjectType type = OBJECT_VARIABLE, ULONG ulAttributes = 0, ULONG ulObjectData = 0); - public: - ObjectType m_ObjectType; - ULONG m_ulAttributes; + public: + ObjectType m_ObjectType; + ULONG m_ulAttributes; - union { - ULONG m_ulVarValue; - ULONG m_ulProcIndex; - }; - }; + union { + ULONG m_ulVarValue; + ULONG m_ulProcIndex; + }; + }; private: - // CMapULongToDefObject - typedef CMap CMapULongToDefObject; + // CMapULongToDefObject + typedef CMap CMapULongToDefObject; - CStartupCode m_StartupCode; - CProcTable m_ProcTable; - CNamespace m_Namespace; - CNamespace m_Stringspace; + CStartupCode m_StartupCode; + CProcTable m_ProcTable; + CNamespace m_Namespace; + CNamespace m_Stringspace; - COpcodeArray m_GlobalVar; - COpcodeArray m_ExportedVar; - COpcodeArray m_ExportedVarValue; - COpcodeArray m_ExportedProc; + COpcodeArray m_GlobalVar; + COpcodeArray m_ExportedVar; + COpcodeArray m_ExportedVarValue; + COpcodeArray m_ExportedProc; - CArrayOfNodeArray m_ProcBodies; - CArrayOfNodeArray m_Conditions; + CArrayOfNodeArray m_ProcBodies; + CArrayOfNodeArray m_Conditions; - CMapULongToDefObject m_Definitions; - CStringArray m_GlobalVarsNames; + CMapULongToDefObject m_Definitions; + CStringArray m_GlobalVarsNames; }; #endif diff --git a/FalloutScriptDecompile.cpp b/FalloutScriptDecompile.cpp index 18e6071..9db1914 100644 --- a/FalloutScriptDecompile.cpp +++ b/FalloutScriptDecompile.cpp @@ -13,377 +13,377 @@ extern BOOL g_bInsOmittedArgsBackward; // CFalloutScript void CFalloutScript::InitDefinitions() { - ULONG ulNameOffset; - INT_PTR nObjectIndex; + ULONG ulNameOffset; + INT_PTR nObjectIndex; CString c_strGlobalVarTemplate("GVar%u"); - m_Definitions.RemoveAll(); + m_Definitions.RemoveAll(); for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { - ulNameOffset = m_Namespace.GetOffsetByIndex(i); - + ulNameOffset = m_Namespace.GetOffsetByIndex(i); + 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, ULONG(nObjectIndex))); + } else if ((nObjectIndex = GetIndexOfExportedVariable(ulNameOffset)) != -1) { WORD wOpcode = m_ExportedVarValue.at(nObjectIndex).GetOperator(); ULONG ulValue = m_ExportedVarValue.at(nObjectIndex).GetArgument(); - m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_EXPORT | wOpcode, ulValue)); - } - } + m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_EXPORT | wOpcode, ulValue)); + } + } - m_GlobalVarsNames.SetSize(m_GlobalVar.GetSize()); + m_GlobalVarsNames.SetSize(m_GlobalVar.GetSize()); for(INT_PTR i = 0; i < m_GlobalVarsNames.GetSize(); i++) { m_GlobalVarsNames.at(i).Format(c_strGlobalVarTemplate.c_str(), i); - } + } } void CFalloutScript::ProcessCode() { - printf(" Intial reducing\n"); - InitialReduce(); + printf(" Intial reducing\n"); + InitialReduce(); - printf(" Building execution tree\n"); - + printf(" Building execution tree\n"); + for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { printf(" Procedure: %d\n", i); BuildTree(m_ProcBodies.at(i)); - } + } - printf(" Extracting and reducing conditions\n"); - - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { + printf(" Extracting and reducing conditions\n"); + + for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { if (m_ProcTable[i].m_ulType & P_CONDITIONAL) { ExtractAndReduceCondition(m_ProcBodies.at(i), m_Conditions.at(i), 0); - } + } for(INT_PTR j = 0; j < m_ProcBodies.at(i).GetSize(); j++) { if (m_ProcBodies.at(i).at(j).m_Opcode.GetOperator() == COpcode::O_CALL_CONDITION) { - CNodeArray Condition; + CNodeArray Condition; CNode node = m_ProcBodies.at(i).at(j).m_Arguments.at(0); - if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid opcode for start address of condition\n"); - AfxThrowUserException(); - } + if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { + printf("Error: Invalid opcode for start address of condition\n"); + AfxThrowUserException(); + } - ULONG ulCondStartAddress = node.m_Opcode.GetArgument(); + ULONG ulCondStartAddress = node.m_Opcode.GetArgument(); - do { + do { node = m_ProcBodies.at(i).at(j = NextNodeIndex(m_ProcBodies.at(i), j, -1)); - } while(node.m_ulOffset != ulCondStartAddress); + } while(node.m_ulOffset != ulCondStartAddress); - j = NextNodeIndex(m_ProcBodies.at(i), j, -1); // For O_JMP opcode + j = NextNodeIndex(m_ProcBodies.at(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); - } - } - } + } + } + } - printf(" Setting borders of blocks\n"); + printf(" Setting borders of blocks\n"); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { - printf(" Procedure: %d\r", i); + for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { + printf(" Procedure: %d\r", i); SetBordersOfBlocks(m_ProcBodies.at(i)); - } + } - printf(" Renaming global variables\n"); - TryRenameGlobalVariables(); + printf(" Renaming global variables\n"); + TryRenameGlobalVariables(); - printf(" Renaming imported variables\n"); - TryRenameImportedVariables(); + printf(" Renaming imported variables\n"); + TryRenameImportedVariables(); } INT_PTR CFalloutScript::GetIndexOfProc(const char* lpszName) { - INT_PTR nResult = -1; - CString strName(lpszName); - CString strTestName; + INT_PTR nResult = -1; + CString strName(lpszName); + CString strTestName; - strName.MakeLower(); + strName.MakeLower(); - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { + for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { strTestName = m_Namespace[m_ProcTable[i].m_ulNameOffset]; - strTestName.MakeLower(); + strTestName.MakeLower(); - if (strTestName == strName) { - nResult = i; - break; - } - } + if (strTestName == strName) { + nResult = i; + break; + } + } - return nResult; + return nResult; } INT_PTR CFalloutScript::GetIndexOfProc(ULONG ulNameOffset) { - INT_PTR nResult = -1; + INT_PTR nResult = -1; for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { if (m_ProcTable[i].m_ulNameOffset == ulNameOffset) { - nResult = i; - break; - } - } + nResult = i; + break; + } + } - return nResult; + return nResult; } INT_PTR CFalloutScript::GetIndexOfExportedVariable(ULONG ulNameOffset) { - INT_PTR nResult = -1; + INT_PTR nResult = -1; - for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { + for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { if (m_ExportedVarValue.at(i + 1).GetArgument() == ulNameOffset) { - nResult = i; - break; - } - } + nResult = i; + break; + } + } - return nResult; + return nResult; } void CFalloutScript::SetExternalVariable(ULONG ulNameOffset) { - CDefObject defObject; + CDefObject defObject; - if (!m_Definitions.Lookup(ulNameOffset, defObject)) { - m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_IMPORT)); - } + if (!m_Definitions.Lookup(ulNameOffset, defObject)) { + m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_IMPORT)); + } } void CFalloutScript::TryRenameGlobalVariables() { - INT_PTR nNamesCount = m_Namespace.GetSize(); - INT_PTR nDefinitionsCount = m_Definitions.GetSize(); - INT_PTR nGlobalVarCount = m_GlobalVar.GetSize(); + INT_PTR nNamesCount = m_Namespace.GetSize(); + INT_PTR nDefinitionsCount = m_Definitions.GetSize(); + INT_PTR nGlobalVarCount = m_GlobalVar.GetSize(); - CDefObject defObject; - INT_PTR nGlobalVarIndex = 0; + CDefObject defObject; + INT_PTR nGlobalVarIndex = 0; - if (nNamesCount - nDefinitionsCount == nGlobalVarCount) { - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { - if (!m_Definitions.Lookup(m_Namespace.GetOffsetByIndex(i), defObject)) { - defObject.m_ObjectType = CDefObject::OBJECT_VARIABLE; + if (nNamesCount - nDefinitionsCount == nGlobalVarCount) { + for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { + 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(); - m_Definitions.SetAt(m_Namespace.GetOffsetByIndex(i), defObject); + m_Definitions.SetAt(m_Namespace.GetOffsetByIndex(i), defObject); m_GlobalVarsNames.at(nGlobalVarIndex) = m_Namespace.GetStringByIndex(i); - nGlobalVarIndex++; - } - } - } + nGlobalVarIndex++; + } + } + } } void CFalloutScript::TryRenameImportedVariables() { - CDefObject defObject; - ULONG ulNameOffset; + CDefObject defObject; + ULONG ulNameOffset; - if (m_GlobalVar.GetSize() == 0) { - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { - ulNameOffset = m_Namespace.GetOffsetByIndex(i); + if (m_GlobalVar.GetSize() == 0) { + for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { + ulNameOffset = m_Namespace.GetOffsetByIndex(i); - if (!m_Definitions.Lookup(ulNameOffset, defObject)) { - m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_IMPORT)); - } - } - } + if (!m_Definitions.Lookup(ulNameOffset, defObject)) { + m_Definitions.SetAt(ulNameOffset, CDefObject(CDefObject::OBJECT_VARIABLE, V_IMPORT)); + } + } + } } INT_PTR CFalloutScript::NextNodeIndex( CNodeArray& NodeArray, INT_PTR nCurrentIndex, INT_PTR nStep) { - INT_PTR nResult = nCurrentIndex + nStep; + INT_PTR nResult = nCurrentIndex + nStep; // if ((nResult < 0) || (nResult > NodeArray.GetUpperBound())) if ((nResult < 0) || (nResult > NodeArray.GetUpperBound())) { - printf("Error: Index of node out of range\n"); - AfxThrowUserException(); - } + printf("Error: Index of node out of range\n"); + AfxThrowUserException(); + } - return nResult; + return nResult; } BOOL CFalloutScript::CheckSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, const WORD wSequence[], INT_PTR nSequenceLen) { - return RemoveSequenceOfNodes(NodeArray, nStartIndex, 0, wSequence, nSequenceLen); + return RemoveSequenceOfNodes(NodeArray, nStartIndex, 0, wSequence, nSequenceLen); } BOOL CFalloutScript::RemoveSequenceOfNodes(CNodeArray& NodeArray, INT_PTR nStartIndex, INT_PTR nCount, const WORD wSequence[], INT_PTR nSequenceLen) { - INT_PTR nCurrentNodeIndex = nStartIndex - 1; + INT_PTR nCurrentNodeIndex = nStartIndex - 1; - for(INT_PTR i = 0; i < nSequenceLen; i++) { - nCurrentNodeIndex = NextNodeIndex(NodeArray, nCurrentNodeIndex, 1); + for(INT_PTR i = 0; i < nSequenceLen; i++) { + nCurrentNodeIndex = NextNodeIndex(NodeArray, nCurrentNodeIndex, 1); if (NodeArray.at(nCurrentNodeIndex).m_Opcode.GetOperator() != wSequence[nCurrentNodeIndex - nStartIndex]) { - return FALSE; - } - } + return FALSE; + } + } - NodeArray.RemoveAt(nStartIndex, nCount); + NodeArray.RemoveAt(nStartIndex, nCount); - return TRUE; + return TRUE; } void CFalloutScript::InitialReduce() { - static WORD awTailOfProc[3] = { - COpcode::O_POP_TO_BASE, - COpcode::O_POP_BASE, - COpcode::O_POP_RETURN - }; + static WORD awTailOfProc[3] = { + COpcode::O_POP_TO_BASE, + COpcode::O_POP_BASE, + COpcode::O_POP_RETURN + }; - static WORD awTailOfCriticalProc[4] = { - COpcode::O_POP_TO_BASE, - COpcode::O_POP_BASE, - COpcode::O_CRITICAL_DONE, - COpcode::O_POP_RETURN - }; + static WORD awTailOfCriticalProc[4] = { + COpcode::O_POP_TO_BASE, + COpcode::O_POP_BASE, + COpcode::O_CRITICAL_DONE, + COpcode::O_POP_RETURN + }; - static WORD awCheckArgCount[3] = { - COpcode::O_DUP, - COpcode::O_INTOP, - COpcode::O_CHECK_ARG_COUNT - }; + static WORD awCheckArgCount[3] = { + COpcode::O_DUP, + COpcode::O_INTOP, + COpcode::O_CHECK_ARG_COUNT + }; - static WORD awShortCircuitAnd[5] = { - COpcode::O_DUP, - COpcode::O_INTOP, - COpcode::O_SWAP, - COpcode::O_IF, - COpcode::O_POP - }; + static WORD awShortCircuitAnd[5] = { + COpcode::O_DUP, + COpcode::O_INTOP, + COpcode::O_SWAP, + COpcode::O_IF, + COpcode::O_POP + }; - static WORD awShortCircuitOr[6] = { - COpcode::O_DUP, - COpcode::O_INTOP, - COpcode::O_SWAP, - COpcode::O_NOT, - COpcode::O_IF, - COpcode::O_POP - }; + static WORD awShortCircuitOr[6] = { + COpcode::O_DUP, + COpcode::O_INTOP, + COpcode::O_SWAP, + COpcode::O_NOT, + COpcode::O_IF, + COpcode::O_POP + }; - static WORD awStoreReturnAdress[2] = { - COpcode::O_INTOP, - COpcode::O_D_TO_A - }; + static WORD awStoreReturnAdress[2] = { + COpcode::O_INTOP, + COpcode::O_D_TO_A + }; - static WORD awReturn[6] = { - COpcode::O_D_TO_A, - COpcode::O_SWAPA, - COpcode::O_POP_TO_BASE, - COpcode::O_POP_BASE, - COpcode::O_A_TO_D, - COpcode::O_POP_RETURN, - }; + static WORD awReturn[6] = { + COpcode::O_D_TO_A, + COpcode::O_SWAPA, + COpcode::O_POP_TO_BASE, + COpcode::O_POP_BASE, + COpcode::O_A_TO_D, + COpcode::O_POP_RETURN, + }; - static WORD awCriticalReturn[7] = { - COpcode::O_D_TO_A, - COpcode::O_SWAPA, - COpcode::O_POP_TO_BASE, - COpcode::O_POP_BASE, - COpcode::O_A_TO_D, - COpcode::O_CRITICAL_DONE, - COpcode::O_POP_RETURN, - }; + static WORD awCriticalReturn[7] = { + COpcode::O_D_TO_A, + COpcode::O_SWAPA, + COpcode::O_POP_TO_BASE, + COpcode::O_POP_BASE, + COpcode::O_A_TO_D, + COpcode::O_CRITICAL_DONE, + COpcode::O_POP_RETURN, + }; - WORD* pwCode; - INT_PTR nCount; + WORD* pwCode; + INT_PTR nCount; - for(INT_PTR i = 0 ; i < m_ProcBodies.GetSize(); i++) { - // Tail + for(INT_PTR i = 0 ; i < m_ProcBodies.GetSize(); i++) { + // Tail if (!m_ProcBodies.at(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)) { - printf("Error: Invalid tail of procedure\'s body\n"); - AfxThrowUserException(); - } - } + printf("Error: Invalid tail of procedure\'s body\n"); + AfxThrowUserException(); + } + } - // Body + // Body for(INT_PTR j = 0; j < m_ProcBodies.at(i).GetSize(); j++) { switch(m_ProcBodies.at(i).at(j).m_Opcode.GetOperator()) { - case COpcode::O_DUP: - // 'Check procedure's arguments count' statement + case COpcode::O_DUP: + // 'Check procedure's arguments count' statement if (!RemoveSequenceOfNodes(m_ProcBodies.at(i), j, 3, awCheckArgCount, 3)) { - // short circuit AND + // short circuit AND UINT actualOperator = CheckSequenceOfNodes(m_ProcBodies.at(i), j, awShortCircuitAnd, 5) - ? COpcode::O_AND + ? COpcode::O_AND : (CheckSequenceOfNodes(m_ProcBodies.at(i), j, awShortCircuitOr, 6) - ? COpcode::O_OR - : 0); - if (actualOperator) { + ? COpcode::O_OR + : 0); + if (actualOperator) { UINT k, skipOffset = m_ProcBodies.at(i).at(j+1).m_Opcode.GetArgument(); - CNode node; - k = j - 1; - do { + CNode node; + k = j - 1; + do { k = NextNodeIndex(m_ProcBodies.at(i), k, 1); } while (skipOffset > m_ProcBodies.at(i).at(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 - } else { - printf("Error: Unknown sequence of opcodes\n"); - AfxThrowUserException(); - } - } + } else { + printf("Error: Unknown sequence of opcodes\n"); + AfxThrowUserException(); + } + } - j--; - break; + j--; + break; - case COpcode::O_D_TO_A: - // 'return' and 'store return address' statements + case COpcode::O_D_TO_A: + // 'return' and 'store return address' statements 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.at(i), j - 1, 2, awStoreReturnAdress, 2)) { - printf("Error: Unknown sequence of opcodes\n"); - AfxThrowUserException(); - } - } + printf("Error: Unknown sequence of opcodes\n"); + AfxThrowUserException(); + } + } - j--; - break; - } - } - } + j--; + break; + } + } + } } // build tree for all nodes from nStartIndex to file offset ulEndOffset (not including) ULONG CFalloutScript::BuildTreeBranch(CNodeArray& NodeArray, ULONG nStartIndex, ULONG ulEndOffset) { - WORD wOperator; - ULONG ulArgument; - INT_PTR nNumOfArgs; + WORD wOperator; + ULONG ulArgument; + INT_PTR nNumOfArgs; - COpcode::COpcodeAttributes opcodeAttributes; - INT_PTR j; + COpcode::COpcodeAttributes opcodeAttributes; + INT_PTR j; for (j = nStartIndex; (j < NodeArray.GetSize() && NodeArray.at(j).m_ulOffset < ulEndOffset); j++) { wOperator = NodeArray.at(j).m_Opcode.GetOperator(); ulArgument = NodeArray.at(j).m_Opcode.GetArgument(); opcodeAttributes = NodeArray.at(j).m_Opcode.GetAttributes(); - nNumOfArgs = INT_PTR(opcodeAttributes.m_ulNumArgs); + nNumOfArgs = INT_PTR(opcodeAttributes.m_ulNumArgs); std::cout << std::hex << wOperator << std::endl; @@ -438,90 +438,90 @@ std::cout << std::hex << wOperator << std::endl; } break; - } + } - // Check nodes - INT_PTR nOmittedArgStartIndex = nNumOfArgs; - COpcode::COpcodeAttributes checkOpcodeAttributes; - INT_PTR nNodeIndex = j; + // Check nodes + INT_PTR nOmittedArgStartIndex = nNumOfArgs; + COpcode::COpcodeAttributes checkOpcodeAttributes; + INT_PTR nNodeIndex = j; for(INT_PTR k = 0; k < nNumOfArgs; k++) { - nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, -1); + nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, -1); if (!NodeArray.at(nNodeIndex).IsExpression()) { if (g_bIgnoreWrongNumOfArgs) { if (IsOmittetArgsAllowed(wOperator)) { - printf("Warning: Omitted expression found\n"); - nOmittedArgStartIndex = k; - break; - } + printf("Warning: Omitted expression found\n"); + nOmittedArgStartIndex = k; + break; + } else { printf("Error: Not enough arguments for %X\n", NodeArray.at(j).m_ulOffset); - AfxThrowUserException(); - } - } + AfxThrowUserException(); + } + } else { printf("Error: Expression required for %X\n", NodeArray.at(j).m_ulOffset); - AfxThrowUserException(); - } - } - } + AfxThrowUserException(); + } + } + } - // Move arguments + // Move arguments for(INT_PTR k = 0; k < nNumOfArgs; k++) { if (k < nOmittedArgStartIndex) { NodeArray.at(j).m_Arguments.InsertAt(0, NodeArray.at(j - 1)); - NodeArray.RemoveAt(j - 1); - j--; - } + NodeArray.RemoveAt(j - 1); + j--; + } else { if (g_bInsOmittedArgsBackward) { NodeArray.at(j).m_Arguments.Add(CNode(CNode::TYPE_OMITTED_ARGUMENT)); - } + } else { NodeArray.at(j).m_Arguments.InsertAt(0, CNode(CNode::TYPE_OMITTED_ARGUMENT)); - } - } - } + } + } + } 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 ulElseIndex, ulSkipIndex = -1; - ulElseIndex = BuildTreeBranch(NodeArray, j + 1, ulElseOffset); // true branch + ULONG ulElseIndex, ulSkipIndex = -1; + ulElseIndex = BuildTreeBranch(NodeArray, j + 1, ulElseOffset); // true branch if (NodeArray.at(ulElseIndex - 1).m_Opcode.GetOperator() == COpcode::O_JMP) { ULONG ulSkipOffset = NodeArray.at(ulElseIndex - 1).m_Opcode.GetArgument(); if (ulSkipOffset > NodeArray.at(j).m_ulOffset) { - ulSkipIndex = BuildTreeBranch(NodeArray, ulElseIndex, ulSkipOffset); // false branch + ulSkipIndex = BuildTreeBranch(NodeArray, ulElseIndex, ulSkipOffset); // false branch if (NodeArray.at(ulElseIndex - 2).IsExpression() && NodeArray.at(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.RemoveAt(j + 1, ulSkipIndex - j - 1); - continue; - } - } - } - j = ((ulSkipIndex != -1) ? ulSkipIndex : ulElseIndex) - 1; // skip already built - } - } + NodeArray.RemoveAt(j + 1, ulSkipIndex - j - 1); + continue; + } + } + } + j = ((ulSkipIndex != -1) ? ulSkipIndex : ulElseIndex) - 1; // skip already built + } + } - return j; + return j; } void CFalloutScript::BuildTree(CNodeArray& NodeArray) @@ -529,97 +529,97 @@ void CFalloutScript::BuildTree(CNodeArray& NodeArray) if (NodeArray.GetSize() > 0) { BuildTreeBranch(NodeArray, 0, NodeArray.at(NodeArray.GetSize() - 1).m_ulOffset + COpcode::OPERATOR_SIZE); - } + } } void CFalloutScript::ExtractAndReduceCondition(CNodeArray& Source, CNodeArray& Destination, INT_PTR nStartIndex) { - // Extract - CNode node; - INT_PTR nNodeIndex;; + // Extract + CNode node; + INT_PTR nNodeIndex;; node = Source.at(nNodeIndex = NextNodeIndex(Source, nStartIndex - 1, 1)); - if (node.m_Opcode.GetOperator() != COpcode::O_JMP) { - printf("Error: Invalid startup of condition\n"); - AfxThrowUserException(); - } + if (node.m_Opcode.GetOperator() != COpcode::O_JMP) { + printf("Error: Invalid startup of condition\n"); + AfxThrowUserException(); + } CNode nodeJumpAddress = node.m_Arguments.at(0); - if (nodeJumpAddress.m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid startup of condition\n"); - AfxThrowUserException(); - } + if (nodeJumpAddress.m_Opcode.GetOperator() != COpcode::O_INTOP) { + printf("Error: Invalid startup of condition\n"); + AfxThrowUserException(); + } ULONG ulJumpOffset = node.m_Arguments.at(0).m_Opcode.GetArgument(); - do { + do { node = Source.at(nNodeIndex = NextNodeIndex(Source, nNodeIndex, 1)); - } while(node.m_ulOffset < ulJumpOffset); + } while(node.m_ulOffset < ulJumpOffset); - Destination.SetSize(nNodeIndex - nStartIndex); + Destination.SetSize(nNodeIndex - nStartIndex); - for(INT_PTR j = 0; j < nNodeIndex - nStartIndex; j++) { + for(INT_PTR j = 0; j < nNodeIndex - nStartIndex; j++) { Destination.at(j) = Source.at(nStartIndex + j); - } + } - // Reduce - static WORD awStartupOfCondition[2] = { - COpcode::O_JMP, - COpcode::O_CRITICAL_START - }; + // Reduce + static WORD awStartupOfCondition[2] = { + COpcode::O_JMP, + COpcode::O_CRITICAL_START + }; - static WORD awCleanupOfCondition[2] = { - COpcode::O_CRITICAL_DONE, - COpcode::O_STOP_PROG - }; + static WORD awCleanupOfCondition[2] = { + COpcode::O_CRITICAL_DONE, + COpcode::O_STOP_PROG + }; - // Startup - if (!RemoveSequenceOfNodes(Destination, 0, 2, awStartupOfCondition, 2)) { - printf("Error: Invalid startup of condition\n"); - AfxThrowUserException(); - } + // Startup + if (!RemoveSequenceOfNodes(Destination, 0, 2, awStartupOfCondition, 2)) { + printf("Error: Invalid startup of condition\n"); + AfxThrowUserException(); + } - // Cleanup - if (!RemoveSequenceOfNodes(Destination, Destination.GetSize() - 2, 2, awCleanupOfCondition, 2)) { - printf("Error: Invalid cleanup of condition\n"); - AfxThrowUserException(); - } + // Cleanup + if (!RemoveSequenceOfNodes(Destination, Destination.GetSize() - 2, 2, awCleanupOfCondition, 2)) { + printf("Error: Invalid cleanup of condition\n"); + AfxThrowUserException(); + } - // Check condition - if (Destination.GetSize() != 1) { - printf("Error: Invalid condition. Only one expression allowed\n"); - AfxThrowUserException(); - } - else { + // Check condition + if (Destination.GetSize() != 1) { + printf("Error: Invalid condition. Only one expression allowed\n"); + AfxThrowUserException(); + } + else { if (Destination.at(0).m_Opcode.GetAttributes().m_Type != COpcode::COpcodeAttributes::TYPE_EXPRESSION) { - printf("Error: Invalid condition. Expression required\n"); - AfxThrowUserException(); - } - } + printf("Error: Invalid condition. Expression required\n"); + AfxThrowUserException(); + } + } - // Remove from source - Source.RemoveAt(nStartIndex, nNodeIndex - nStartIndex); + // Remove from source + Source.RemoveAt(nStartIndex, nNodeIndex - nStartIndex); } void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) { - if (NodeArray.IsEmpty()) { - return; - } + if (NodeArray.IsEmpty()) { + return; + } - ULONG ulOffset; + ULONG ulOffset; - // Start of procedure + // Start of procedure if (NodeArray.at(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; - } + } - // End of procedure - INT_PTR nLastNodeIndex = NodeArray.GetUpperBound(); + // 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) && @@ -631,173 +631,173 @@ void CFalloutScript::SetBordersOfBlocks(CNodeArray& NodeArray) (NodeArray.at(nLastNodeIndex).m_Arguments.at(0).m_Opcode.GetOperator() == COpcode::O_INTOP))*/ { ulOffset = NodeArray.at(nLastNodeIndex).m_ulOffset; //NodeArray.at(nLastNodeIndex) = c_NodeEndOfBlock; - NodeArray.InsertAt(nLastNodeIndex + 1, CNode(c_NodeEndOfBlock)); + NodeArray.InsertAt(nLastNodeIndex + 1, CNode(c_NodeEndOfBlock)); NodeArray.at(nLastNodeIndex).m_ulOffset = ulOffset; - } - - // Body - CNode node; + } + + // Body + CNode node; - for(INT_PTR i = 0; i < NodeArray.GetSize(); i++) { + for(INT_PTR i = 0; i < NodeArray.GetSize(); i++) { switch(NodeArray.at(i).m_Opcode.GetOperator()) { - case COpcode::O_WHILE: - { + case COpcode::O_WHILE: + { CNode node = NodeArray.at(i).m_Arguments.at(0); ULONG loopOffset = NodeArray.at(i).m_Arguments.at(1).GetTopOffset(); - - if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid opcode for jump-address\n"); - AfxThrowUserException(); - } + + if (node.m_Opcode.GetOperator() != COpcode::O_INTOP) { + printf("Error: Invalid opcode for jump-address\n"); + AfxThrowUserException(); + } - NodeArray.InsertAt(i + 1, CNode(c_NodeBeginOfBlock)); + NodeArray.InsertAt(i + 1, CNode(c_NodeBeginOfBlock)); NodeArray.at(i + 1).m_ulOffset = NodeArray.at(i).m_ulOffset; - ulOffset = node.m_Opcode.GetArgument(); + ulOffset = node.m_Opcode.GetArgument(); - INT_PTR nNodeIndex = i + 1; + INT_PTR nNodeIndex = i + 1; CArray jumps; - //CMap elses = CMap (); - //bool unused; - do { + //CMap elses = CMap (); + //bool unused; + do { node = NodeArray.at(nNodeIndex = NextNodeIndex(NodeArray, nNodeIndex, 1)); - if (node.m_Opcode.GetOperator() == COpcode::O_JMP && node.m_Type == CNode::TYPE_NORMAL && node.m_Arguments.GetSize() > 0) { + 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(); - if (ofs == ulOffset) { + if (ofs == ulOffset) { NodeArray.at(nNodeIndex).m_Type = CNode::TYPE_BREAK; - } else if (ofs == loopOffset) { + } else if (ofs == loopOffset) { NodeArray.at(nNodeIndex).m_Type = CNode::TYPE_CONTINUE; // continue in "while" loop - } else { - //if (!elses.Lookup(NodeArray[nNodeIndex+1].GetTopOffset(), unused)) { - jumps.Add(nNodeIndex); - //} - } - }/* else if (node.m_Opcode.GetOperator() == COpcode::O_IF && node.m_Arguments.GetSize() > 0) { + } else { + //if (!elses.Lookup(NodeArray[nNodeIndex+1].GetTopOffset(), unused)) { + jumps.Add(nNodeIndex); + //} + } + }/* else if (node.m_Opcode.GetOperator() == COpcode::O_IF && node.m_Arguments.GetSize() > 0) { elses[node.m_Arguments.at(0).m_Opcode.GetArgument()] = true; - }*/ - } while(node.m_ulOffset < ulOffset); + }*/ + } while(node.m_ulOffset < ulOffset); - bool isForLoop = false; + bool isForLoop = false; if (NodeArray.at(nNodeIndex - 2).m_Arguments.GetSize() > 0 && i > 0) { // *might* be a "for" loop loopOffset = NodeArray.at(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)); + //printf("(else) goto %x > %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; CNode Bnode = NodeArray.at(nNodeIndex - 1); CNode Cnode = NodeArray.at(nNodeIndex + 1); - if ((Bnode.m_Type == CNode::TYPE_END_OF_BLOCK)/* && - (Cnode.m_Opcode.GetOperator() != COpcode::O_IF)*/) { - do { + 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)); - } while(node.m_ulOffset < ulOffset); - NodeArray.InsertAt(nNodeIndex, CNode(c_NodeEndOfBlock)); + } while(node.m_ulOffset < ulOffset); + NodeArray.InsertAt(nNodeIndex, CNode(c_NodeEndOfBlock)); NodeArray.at(nNodeIndex).m_ulOffset = NodeArray.at(nNodeIndex + 1).m_ulOffset; - } - } - } - } + } + } + } + } NodeArray.at(i).m_Arguments.RemoveAt(0); - i++; + i++; - break; - } - } + break; + } + } } void CFalloutScript::ReduceConditionalExpressions(CNodeArray& NodeArray) { - /*if (NodeArray.IsEmpty()) { - return; - } - CNode node; + /*if (NodeArray.IsEmpty()) { + return; + } + CNode node; - for (INT_PTR i = 0; i < NodeArray.GetSize(); i++) { + for (INT_PTR i = 0; i < NodeArray.GetSize(); i++) { if (NodeArray.at(i).m_Opcode.GetOperator() == COpcode::O_IF) { - if (ReduceExpressionBlock(NodeArray, i+1)) { + if (ReduceExpressionBlock(NodeArray, i+1)) { - } - } - }*/ + } + } + }*/ } BOOL CFalloutScript::IsOmittetArgsAllowed(WORD wOpcode) { - if (((wOpcode >= COpcode::O_END_CORE) && (wOpcode < COpcode::O_END_OP)) || - (wOpcode == COpcode::O_POP_RETURN)) { - return TRUE; - } - else { - return FALSE; - } + if (((wOpcode >= COpcode::O_END_CORE) && (wOpcode < COpcode::O_END_OP)) || + (wOpcode == COpcode::O_POP_RETURN)) { + return TRUE; + } + else { + return FALSE; + } } diff --git a/FalloutScriptDefObject.cpp b/FalloutScriptDefObject.cpp index b9d7a11..80c9154 100644 --- a/FalloutScriptDefObject.cpp +++ b/FalloutScriptDefObject.cpp @@ -8,14 +8,14 @@ // CFalloutScript::CDefObject CFalloutScript::CDefObject::CDefObject(ObjectType type, ULONG ulAttributes, ULONG ulObjectData) { - m_ulAttributes = ulAttributes; + m_ulAttributes = ulAttributes; - switch(m_ObjectType = type) { - case OBJECT_VARIABLE: - m_ulVarValue = ulObjectData; - break; + switch(m_ObjectType = type) { + case OBJECT_VARIABLE: + m_ulVarValue = ulObjectData; + break; - case OBJECT_PROCEDURE: - m_ulProcIndex = ulObjectData; - } + case OBJECT_PROCEDURE: + m_ulProcIndex = ulObjectData; + } } diff --git a/FalloutScriptDump.cpp b/FalloutScriptDump.cpp index 8659d74..1ddf1f8 100644 --- a/FalloutScriptDump.cpp +++ b/FalloutScriptDump.cpp @@ -4,33 +4,33 @@ // CFalloutScript void CFalloutScript::Dump(CArchive& ar) { - ar.WriteString("============== Procedures table ==================\n"); - ar.WriteString("\n"); - m_ProcTable.Dump(ar); - ar.WriteString("\n"); - ar.WriteString("\n"); + ar.WriteString("============== Procedures table ==================\n"); + ar.WriteString("\n"); + m_ProcTable.Dump(ar); + ar.WriteString("\n"); + ar.WriteString("\n"); - ar.WriteString("============== Namespace ==================\n"); - m_Namespace.Dump(ar); - ar.WriteString("\n"); - ar.WriteString("\n"); + ar.WriteString("============== Namespace ==================\n"); + m_Namespace.Dump(ar); + ar.WriteString("\n"); + ar.WriteString("\n"); - ar.WriteString("============== Stringspace ==================\n"); - m_Stringspace.Dump(ar); - ar.WriteString("\n"); - ar.WriteString("\n"); + ar.WriteString("============== Stringspace ==================\n"); + m_Stringspace.Dump(ar); + ar.WriteString("\n"); + ar.WriteString("\n"); - CString strOutLine; - WORD wOperator; - ULONG ulArgument = 0; + CString strOutLine; + WORD wOperator; + ULONG ulArgument = 0; - ar.WriteString("============== Global variables values ==================\n"); + ar.WriteString("============== Global variables values ==================\n"); if (m_GlobalVar.IsEmpty()) { - ar.WriteString("Not found\n"); - } + ar.WriteString("Not found\n"); + } else { for(unsigned int i = 0; i < m_GlobalVar.GetSize(); i++) @@ -40,118 +40,118 @@ void CFalloutScript::Dump(CArchive& ar) switch(wOperator) { - case COpcode::O_STRINGOP: - case COpcode::O_INTOP: - strOutLine.Format("%d: %s(0x%08x) // %u (%d)\n", - i, + case COpcode::O_STRINGOP: + case COpcode::O_INTOP: + strOutLine.Format("%d: %s(0x%08x) // %u (%d)\n", + i, m_GlobalVar.at(i).GetAttributes().m_strMnemonic.c_str(), ulArgument, ulArgument, ulArgument); - ar.WriteString(strOutLine); - break; + ar.WriteString(strOutLine); + break; - case COpcode::O_FLOATOP: - strOutLine.Format("%d: %s(0x%08x) // %05f\n", - i, + case COpcode::O_FLOATOP: + strOutLine.Format("%d: %s(0x%08x) // %05f\n", + i, m_GlobalVar.at(i).GetAttributes().m_strMnemonic.c_str(), - ulArgument, - *((float*)(&ulArgument))); - ar.WriteString(strOutLine); - } - } - } + ulArgument, + *((float*)(&ulArgument))); + ar.WriteString(strOutLine); + } + } + } - ar.WriteString("\n"); - ar.WriteString("\n"); + ar.WriteString("\n"); + ar.WriteString("\n"); - ar.WriteString("============== Exported variables ==================\n"); + ar.WriteString("============== Exported variables ==================\n"); - if (m_ExportedVarValue.IsEmpty()) { - ar.WriteString("Not found\n"); - } - else { - for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2) { + if (m_ExportedVarValue.IsEmpty()) { + ar.WriteString("Not found\n"); + } + else { + 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(); - switch(wOperator) { - case COpcode::O_STRINGOP: - strOutLine.Format("%s := \"%s\"\n", + switch(wOperator) { + case COpcode::O_STRINGOP: + strOutLine.Format("%s := \"%s\"\n", m_Namespace[ulNameArgument].c_str(), m_Stringspace[ulArgument].c_str()); - ar.WriteString(strOutLine); - break; + ar.WriteString(strOutLine); + break; - case COpcode::O_INTOP: - strOutLine.Format("%s := %u (%d)\n", + case COpcode::O_INTOP: + strOutLine.Format("%s := %u (%d)\n", m_Namespace[ulNameArgument].c_str(), - ulArgument, - ulArgument); - ar.WriteString(strOutLine); - break; + ulArgument, + ulArgument); + ar.WriteString(strOutLine); + break; - case COpcode::O_FLOATOP: - strOutLine.Format("%s := %05f\n", + case COpcode::O_FLOATOP: + strOutLine.Format("%s := %05f\n", m_Namespace[ulNameArgument].c_str(), - *((float*)(&ulArgument))); - ar.WriteString(strOutLine); - } - } - } + *((float*)(&ulArgument))); + ar.WriteString(strOutLine); + } + } + } - ar.WriteString("\n"); - ar.WriteString("\n"); + ar.WriteString("\n"); + ar.WriteString("\n"); - ar.WriteString("============== Procedures ==================\n"); - ar.WriteString("\n"); + ar.WriteString("============== Procedures ==================\n"); + ar.WriteString("\n"); - for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++) { + for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++) { strOutLine.Format("%d: %s (0x%08x)\n", nIndexOfProc, m_Namespace[m_ProcTable[nIndexOfProc].m_ulNameOffset].c_str(), m_ProcTable[nIndexOfProc].m_ulBodyOffset ); - ar.WriteString(strOutLine); - ar.WriteString("===============================\n"); + ar.WriteString(strOutLine); + ar.WriteString("===============================\n"); for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++) { wOperator = m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetOperator(); ulArgument = m_ProcBodies.at(nIndexOfProc).at(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", + 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, - wOperator, - ulArgument, + wOperator, + ulArgument, m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str(), - ulArgument, - ulArgument, - ulArgument); - ar.WriteString(strOutLine); - break; + ulArgument, + ulArgument, + ulArgument); + ar.WriteString(strOutLine); + break; - case COpcode::O_FLOATOP: - strOutLine.Format("0x%08X: 0x%04X 0x%08X - %s // %05f\n", + case COpcode::O_FLOATOP: + strOutLine.Format("0x%08X: 0x%04X 0x%08X - %s // %05f\n", m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset, - wOperator, - ulArgument, + wOperator, + ulArgument, m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str(), - *((float*)(&ulArgument))); - ar.WriteString(strOutLine); - break; + *((float*)(&ulArgument))); + ar.WriteString(strOutLine); + break; - default: - strOutLine.Format("0x%08X: 0x%04X - %s\n", + default: + strOutLine.Format("0x%08X: 0x%04X - %s\n", m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset, - wOperator, + wOperator, m_ProcBodies.at(nIndexOfProc).at(i).m_Opcode.GetAttributes().m_strMnemonic.c_str()); - ar.WriteString(strOutLine); - } - } + ar.WriteString(strOutLine); + } + } - ar.WriteString("\n"); - } + ar.WriteString("\n"); + } } diff --git a/FalloutScriptStore.cpp b/FalloutScriptStore.cpp index b4a61b7..a86e271 100644 --- a/FalloutScriptStore.cpp +++ b/FalloutScriptStore.cpp @@ -11,49 +11,49 @@ extern CString g_strIndentFill; // CFalloutScript void CFalloutScript::StoreTree(CArchive& ar) { - CString strOutLine; + CString strOutLine; - ar.WriteString("============== Procedures ==================\n"); - ar.WriteString("\n"); + ar.WriteString("============== Procedures ==================\n"); + ar.WriteString("\n"); - for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++) { + for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++) { strOutLine.Format("%d: %s (0x%08x)\n", nIndexOfProc, m_Namespace[m_ProcTable[nIndexOfProc].m_ulNameOffset].c_str(), m_ProcTable[nIndexOfProc].m_ulBodyOffset); - ar.WriteString(strOutLine); - ar.WriteString("===============================\n"); + ar.WriteString(strOutLine); + ar.WriteString("===============================\n"); if (m_ProcTable[nIndexOfProc].m_ulType & P_CONDITIONAL) { - ar.WriteString("Condition\n"); - ar.WriteString("===============================\n"); + ar.WriteString("Condition\n"); + ar.WriteString("===============================\n"); for(INT_PTR i = 0; i < m_Conditions.at(nIndexOfProc).GetSize(); i++) { strOutLine.Format("0x%08X: ", m_Conditions.at(nIndexOfProc).at(i).m_ulOffset); - ar.WriteString(strOutLine); + ar.WriteString(strOutLine); m_Conditions.at(nIndexOfProc).at(i).StoreTree(ar, 0, 0); - } + } - ar.WriteString("\n"); - ar.WriteString("Body\n"); - ar.WriteString("===============================\n"); - } + ar.WriteString("\n"); + ar.WriteString("Body\n"); + ar.WriteString("===============================\n"); + } for(INT_PTR i = 0; i < m_ProcBodies.at(nIndexOfProc).GetSize(); i++) { strOutLine.Format("0x%08X: ", m_ProcBodies.at(nIndexOfProc).at(i).m_ulOffset); - ar.WriteString(strOutLine); + ar.WriteString(strOutLine); m_ProcBodies.at(nIndexOfProc).at(i).StoreTree(ar, 0, 0); - } + } ar.WriteString("\n"); - } + } } void CFalloutScript::StoreSource(CArchive& ar) { - StoreDefinitions(ar); - ar.WriteString("\n"); - ar.WriteString("\n"); - StoreDeclarations(ar); -// StoreTree(ar); + StoreDefinitions(ar); + ar.WriteString("\n"); + ar.WriteString("\n"); + StoreDeclarations(ar); +// StoreTree(ar); } @@ -63,192 +63,192 @@ void CFalloutScript::StoreDefinitions(CArchive& ar) CString c_strBogusProcedureName(".............."); CString c_strArgumentTemplate("arg%u"); - printf(" Storing definitions\n"); + printf(" Storing definitions\n"); - // Unnamed global variables - INT_PTR nNamesCount = m_Namespace.GetSize(); - INT_PTR nDefinitionsCount = m_Definitions.GetSize(); - CString strDefinition; - ULONG ulVarValue; + // Unnamed global variables + INT_PTR nNamesCount = m_Namespace.GetSize(); + INT_PTR nDefinitionsCount = m_Definitions.GetSize(); + CString strDefinition; + ULONG ulVarValue; - if (nNamesCount != nDefinitionsCount) { - ar.WriteString("/*******************************************************\n"); - ar.WriteString("* Some unreferenced imported varables found. *\n"); - ar.WriteString("* Because of it it is impossible to specify *\n"); - ar.WriteString("* the real names of global variables. *\n"); - ar.WriteString("*******************************************************/\n"); - ar.WriteString("\n"); + if (nNamesCount != nDefinitionsCount) { + ar.WriteString("/*******************************************************\n"); + ar.WriteString("* Some unreferenced imported varables found. *\n"); + ar.WriteString("* Because of it it is impossible to specify *\n"); + ar.WriteString("* the real names of global variables. *\n"); + ar.WriteString("*******************************************************/\n"); + ar.WriteString("\n"); - for(INT_PTR i = 0; i < m_GlobalVar.GetSize(); i++) { + for(INT_PTR i = 0; i < m_GlobalVar.GetSize(); i++) { ulVarValue = m_GlobalVar.at(i).GetArgument(); strDefinition += "variable "; strDefinition += m_GlobalVarsNames.at(i); switch(m_GlobalVar.at(i).GetOperator()) { - case COpcode::O_STRINGOP: + case COpcode::O_STRINGOP: strDefinition.Format(strDefinition + " := \"%s\"", m_Stringspace[ulVarValue].c_str()); - break; + break; - case COpcode::O_FLOATOP: - strDefinition.Format(strDefinition + " := %.5f", *((float*)(&ulVarValue))); - break; + case COpcode::O_FLOATOP: + strDefinition.Format(strDefinition + " := %.5f", *((float*)(&ulVarValue))); + break; - case COpcode::O_INTOP: - if (ulVarValue != 0) { - strDefinition.Format(strDefinition + " := %d", (long)ulVarValue); - } + case COpcode::O_INTOP: + if (ulVarValue != 0) { + strDefinition.Format(strDefinition + " := %d", (long)ulVarValue); + } - break; - } + break; + } - strDefinition += ";"; + strDefinition += ";"; if ((m_GlobalVar.at(i).GetOperator() == COpcode::O_INTOP) && (ulVarValue & 0x80000000)) { - strDefinition.Format(strDefinition + " /* (%d) */", ulVarValue); - } + strDefinition.Format(strDefinition + " /* (%d) */", ulVarValue); + } - ar.WriteString(strDefinition + "\n"); - } + ar.WriteString(strDefinition + "\n"); + } - ar.WriteString("\n"); - } + ar.WriteString("\n"); + } - // Named objects - ULONG ulNameOffset; - CDefObject defObject; + // Named objects + ULONG ulNameOffset; + CDefObject defObject; - enum OutDefObject { - OUT_NOTHING, - OUT_UNKNOWN_VARIABLE, - OUT_GLOBAL_VARIABLE, - OUT_EXPORTED_VARIABLE, - OUT_IMPORTED_VARIABLE, - OUT_PROCEDURE, - OUT_EXPORTED_PROCEDURE, - OUT_IMPORTED_PROCEDURE - }; + enum OutDefObject { + OUT_NOTHING, + OUT_UNKNOWN_VARIABLE, + OUT_GLOBAL_VARIABLE, + OUT_EXPORTED_VARIABLE, + OUT_IMPORTED_VARIABLE, + OUT_PROCEDURE, + OUT_EXPORTED_PROCEDURE, + OUT_IMPORTED_PROCEDURE + }; - OutDefObject lastOut = OUT_NOTHING; - OutDefObject currentOut = OUT_NOTHING; - CProcDescriptor procDescriptor; + OutDefObject lastOut = OUT_NOTHING; + OutDefObject currentOut = OUT_NOTHING; + CProcDescriptor procDescriptor; - for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { - ulNameOffset = m_Namespace.GetOffsetByIndex(i); + for(INT_PTR i = 0; i < m_Namespace.GetSize(); i++) { + ulNameOffset = m_Namespace.GetOffsetByIndex(i); - if (i == 0) { + if (i == 0) { if (m_Namespace[ulNameOffset] == c_strBogusProcedureName.c_str()) { - continue; - } - else { + continue; + } + else { std::string msg = "Warning: Bogus procedure with name "; msg += c_strBogusProcedureName; msg += " not found at expected location\n"; printf(msg.c_str()); - } - } + } + } - if (m_Definitions.Lookup(ulNameOffset, defObject)) { - strDefinition = ""; + if (m_Definitions.Lookup(ulNameOffset, defObject)) { + strDefinition = ""; - switch(defObject.m_ObjectType) { - case CDefObject::OBJECT_PROCEDURE: - procDescriptor = m_ProcTable[defObject.m_ulProcIndex]; + switch(defObject.m_ObjectType) { + case CDefObject::OBJECT_PROCEDURE: + procDescriptor = m_ProcTable[defObject.m_ulProcIndex]; - if (procDescriptor.m_ulType & P_IMPORT) { - strDefinition = "import "; - currentOut = OUT_IMPORTED_PROCEDURE; - } - else if (procDescriptor.m_ulType & P_EXPORT) { - strDefinition = "export "; - currentOut = OUT_EXPORTED_PROCEDURE; - } - else { - currentOut = OUT_PROCEDURE; - } + if (procDescriptor.m_ulType & P_IMPORT) { + strDefinition = "import "; + currentOut = OUT_IMPORTED_PROCEDURE; + } + else if (procDescriptor.m_ulType & P_EXPORT) { + strDefinition = "export "; + currentOut = OUT_EXPORTED_PROCEDURE; + } + else { + currentOut = OUT_PROCEDURE; + } strDefinition += "procedure "; strDefinition += m_Namespace[ulNameOffset]; - if (procDescriptor.m_ulNumArgs != 0) { - strDefinition += "("; + if (procDescriptor.m_ulNumArgs != 0) { + strDefinition += "("; - for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) { - if (i == 0) { + for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) { + if (i == 0) { strDefinition.Format(strDefinition + "variable " + c_strArgumentTemplate.c_str(), i); - } - else { + } + else { strDefinition.Format(strDefinition + ", variable " + c_strArgumentTemplate.c_str(), i); - } - } + } + } - strDefinition += ")"; - } + strDefinition += ")"; + } - strDefinition += ";"; + strDefinition += ";"; - if (procDescriptor.m_ulType & P_NOTIMPLEMENTED) { - strDefinition += " /* Prodedure defined, but not implemented */"; - } + if (procDescriptor.m_ulType & P_NOTIMPLEMENTED) { + strDefinition += " /* Prodedure defined, but not implemented */"; + } - break; + break; - case CDefObject::OBJECT_VARIABLE: - if (defObject.m_ulAttributes & V_IMPORT) { - strDefinition = "import "; - currentOut = OUT_IMPORTED_VARIABLE; - } - else if (defObject.m_ulAttributes & V_EXPORT) { - strDefinition = "export "; - currentOut = OUT_EXPORTED_VARIABLE; - } - else { - currentOut = OUT_GLOBAL_VARIABLE; - } + case CDefObject::OBJECT_VARIABLE: + if (defObject.m_ulAttributes & V_IMPORT) { + strDefinition = "import "; + currentOut = OUT_IMPORTED_VARIABLE; + } + else if (defObject.m_ulAttributes & V_EXPORT) { + strDefinition = "export "; + currentOut = OUT_EXPORTED_VARIABLE; + } + else { + currentOut = OUT_GLOBAL_VARIABLE; + } strDefinition += "variable "; strDefinition += m_Namespace[ulNameOffset]; - if (!(defObject.m_ulAttributes & V_IMPORT)) { - switch(defObject.m_ulAttributes & 0xFFFF) { - case COpcode::O_STRINGOP: + if (!(defObject.m_ulAttributes & V_IMPORT)) { + switch(defObject.m_ulAttributes & 0xFFFF) { + case COpcode::O_STRINGOP: strDefinition.Format(strDefinition + " := \"%s\"", m_Stringspace[defObject.m_ulVarValue].c_str()); - break; + break; - case COpcode::O_FLOATOP: - strDefinition.Format(strDefinition + " := %.5f", *((float*)(&defObject.m_ulVarValue))); - break; + case COpcode::O_FLOATOP: + strDefinition.Format(strDefinition + " := %.5f", *((float*)(&defObject.m_ulVarValue))); + break; - case COpcode::O_INTOP: - if (defObject.m_ulVarValue != 0) { - strDefinition.Format(strDefinition + " := %d", (long)defObject.m_ulVarValue); - } + case COpcode::O_INTOP: + if (defObject.m_ulVarValue != 0) { + strDefinition.Format(strDefinition + " := %d", (long)defObject.m_ulVarValue); + } - break; - } - } + break; + } + } - strDefinition += ";"; + strDefinition += ";"; - //if (((defObject.m_ulAttributes & 0xFFFF) == COpcode::O_INTOP) && - // (defObject.m_ulVarValue & 0x80000000)) { - // strDefinition.Format(strDefinition + " /* (%d) */", defObject.m_ulVarValue); - //} - } - } - else { - currentOut = OUT_UNKNOWN_VARIABLE; + //if (((defObject.m_ulAttributes & 0xFFFF) == COpcode::O_INTOP) && + // (defObject.m_ulVarValue & 0x80000000)) { + // strDefinition.Format(strDefinition + " /* (%d) */", defObject.m_ulVarValue); + //} + } + } + else { + currentOut = OUT_UNKNOWN_VARIABLE; strDefinition = "/* ?import? variable "; strDefinition+= m_Namespace.GetStringByIndex(i) + "; */"; - } + } - if ((currentOut != lastOut) && (lastOut != OUT_NOTHING)) { - ar.WriteString("\n"); - } + if ((currentOut != lastOut) && (lastOut != OUT_NOTHING)) { + ar.WriteString("\n"); + } - lastOut = currentOut; - ar.WriteString(strDefinition + "\n"); - } + lastOut = currentOut; + ar.WriteString(strDefinition + "\n"); + } } void CFalloutScript::StoreDeclarations(CArchive& ar) @@ -257,183 +257,183 @@ void CFalloutScript::StoreDeclarations(CArchive& ar) CString c_strArgumentTemplate("arg%u"); CString c_strLocalVarTemplate("LVar%u"); - printf(" Storing declarations\n"); + printf(" Storing declarations\n"); - CString strOutLine; + CString strOutLine; - for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { - printf(" Procedure: %d\r", i); + for(INT_PTR i = 0; i < m_ProcTable.GetSize(); i++) { + printf(" Procedure: %d\r", i); - // Bogus procedure + // Bogus procedure if ((i == 0) && (m_Namespace[m_ProcTable[i].m_ulNameOffset] == c_strBogusProcedureName.c_str())) { - continue; - } + continue; + } - // Empty procedure - if (m_ProcTable.GetSizeOfProc(i) == 0) { - ar.WriteString("/*******************************************************\n"); - ar.WriteString("* Found Procedure without body. *\n"); - ar.WriteString("* *\n"); + // Empty procedure + if (m_ProcTable.GetSizeOfProc(i) == 0) { + ar.WriteString("/*******************************************************\n"); + ar.WriteString("* Found Procedure without body. *\n"); + ar.WriteString("* *\n"); strOutLine = "* Name: "; strOutLine+= m_Namespace[m_ProcTable[i].m_ulNameOffset]; - while(strOutLine.GetLength() < 55) { - strOutLine += " "; - } + while(strOutLine.GetLength() < 55) { + strOutLine += " "; + } - strOutLine += "*\n"; - ar.WriteString(strOutLine); + strOutLine += "*\n"; + ar.WriteString(strOutLine); - ar.WriteString("* *\n"); + ar.WriteString("* *\n"); - if (!(m_ProcTable[i].m_ulType & P_NOTIMPLEMENTED)) { - ar.WriteString("* Other possible name(s): *\n"); + if (!(m_ProcTable[i].m_ulType & P_NOTIMPLEMENTED)) { + ar.WriteString("* Other possible name(s): *\n"); - for(INT_PTR j = i + 1; j < m_ProcTable.GetSize(); j++) { - if (m_ProcTable[j].m_ulBodyOffset == m_ProcTable[i].m_ulBodyOffset) { + for(INT_PTR j = i + 1; j < m_ProcTable.GetSize(); j++) { + if (m_ProcTable[j].m_ulBodyOffset == m_ProcTable[i].m_ulBodyOffset) { strOutLine = "* "; strOutLine+= m_Namespace[m_ProcTable[j].m_ulNameOffset]; - while(strOutLine.GetLength() < 55) { - strOutLine += " "; - } + while(strOutLine.GetLength() < 55) { + strOutLine += " "; + } - strOutLine += "*\n"; - ar.WriteString(strOutLine); - strOutLine = "* "; - } - } - } - else { - ar.WriteString("* Not implemented *\n"); - } + strOutLine += "*\n"; + ar.WriteString(strOutLine); + strOutLine = "* "; + } + } + } + else { + ar.WriteString("* Not implemented *\n"); + } - ar.WriteString("* *\n"); - ar.WriteString("*******************************************************/\n"); - ar.WriteString("\n"); - continue; - } + ar.WriteString("* *\n"); + ar.WriteString("*******************************************************/\n"); + ar.WriteString("\n"); + continue; + } - // 'Normal' procedure - CProcDescriptor procDescriptor = m_ProcTable[i]; + // 'Normal' procedure + CProcDescriptor procDescriptor = m_ProcTable[i]; - if (procDescriptor.m_ulType & P_CRITICAL) { - strOutLine = "critical "; - } - else { - strOutLine = ""; - } + if (procDescriptor.m_ulType & P_CRITICAL) { + strOutLine = "critical "; + } + else { + strOutLine = ""; + } strOutLine += "procedure "; strOutLine+= m_Namespace[m_ProcTable[i].m_ulNameOffset]; - if (procDescriptor.m_ulNumArgs != 0) { - strOutLine += "("; + if (procDescriptor.m_ulNumArgs != 0) { + strOutLine += "("; - for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) { - if (i == 0) { + for(ULONG i = 0; i < procDescriptor.m_ulNumArgs; i++) { + if (i == 0) { strOutLine.Format(strOutLine + "variable " + c_strArgumentTemplate.c_str(), i); - } - else { + } + else { strOutLine.Format(strOutLine + ", variable " + c_strArgumentTemplate.c_str(), i); - } - } + } + } - strOutLine += ")"; - } + strOutLine += ")"; + } - if (procDescriptor.m_ulType & P_TIMED) { - strOutLine.Format(strOutLine + " in %d", procDescriptor.m_ulTime); - } - else if (procDescriptor.m_ulType & P_CONDITIONAL) { + if (procDescriptor.m_ulType & P_TIMED) { + strOutLine.Format(strOutLine + " in %d", procDescriptor.m_ulTime); + } + 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()); - } + } - ar.WriteString(strOutLine + "\n"); + ar.WriteString(strOutLine + "\n"); - BOOL bLocalVar = TRUE; - ULONG ulLocalVarIndex = procDescriptor.m_ulNumArgs; - INT_PTR nIndentLevel = 0; - CNode::Type prevNodeType = CNode::TYPE_NORMAL; + BOOL bLocalVar = TRUE; + ULONG ulLocalVarIndex = procDescriptor.m_ulNumArgs; + INT_PTR nIndentLevel = 0; + CNode::Type prevNodeType = CNode::TYPE_NORMAL; for(INT_PTR nNodeIndex = 0; nNodeIndex < m_ProcBodies.at(i).GetSize(); nNodeIndex++) { if (m_ProcBodies.at(i).at(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)) && ((nNodeIndex + 1 <= m_ProcBodies.at(i).GetSize()) && (m_ProcBodies.at(i)[nNodeIndex + 1].m_Opcode.GetOperator() == COpcode::O_IF))) { ar.WriteString(GetIndentString(nIndentLevel) + "else\n"); - } + } else */if ((nNodeIndex - 1 > 0) && (m_ProcBodies.at(i).at(nNodeIndex - 1).m_Type == CNode::TYPE_END_OF_BLOCK)) { - ar.WriteString(GetIndentString(nIndentLevel) + "else begin\n"); - nIndentLevel++; - } - else { - ar.WriteString("begin\n"); - nIndentLevel++; - } - prevNodeType = CNode::TYPE_BEGIN_OF_BLOCK; - } + ar.WriteString(GetIndentString(nIndentLevel) + "else begin\n"); + nIndentLevel++; + } + else { + ar.WriteString("begin\n"); + nIndentLevel++; + } + prevNodeType = CNode::TYPE_BEGIN_OF_BLOCK; + } else if (m_ProcBodies.at(i).at(nNodeIndex).m_Type == CNode::TYPE_END_OF_BLOCK) { - nIndentLevel--; - ar.WriteString(GetIndentString(nIndentLevel) + "end\n"); + nIndentLevel--; + ar.WriteString(GetIndentString(nIndentLevel) + "end\n"); prevNodeType = CNode::TYPE_END_OF_BLOCK; - } - else { - prevNodeType = CNode::TYPE_NORMAL; + } + else { + prevNodeType = CNode::TYPE_NORMAL; WORD wOperator = m_ProcBodies.at(i).at(nNodeIndex).m_Opcode.GetOperator(); if ((m_ProcBodies.at(i).at(nNodeIndex).m_Opcode.GetAttributes().m_Type == COpcode::COpcodeAttributes::TYPE_EXPRESSION) && - (wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_FLOATOP) && (wOperator != COpcode::O_INTOP)) { + (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); - } + } - switch(wOperator) { - case COpcode::O_STRINGOP: - case COpcode::O_FLOATOP: - case COpcode::O_INTOP: + switch(wOperator) { + case COpcode::O_STRINGOP: + case COpcode::O_FLOATOP: + case COpcode::O_INTOP: { - if (!bLocalVar) { - printf("Warning: Free value found. Converted to definition of local variable\n"); - } + if (!bLocalVar) { + printf("Warning: Free value found. Converted to definition of local variable\n"); + } std::string str = "variable "; 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"); - ulLocalVarIndex++; - break; + ulLocalVarIndex++; + break; } - case COpcode::O_IF: + case COpcode::O_IF: ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + " then "); - break; + break; - case COpcode::O_WHILE: + case COpcode::O_WHILE: if (m_ProcBodies.at(i).at(nNodeIndex).m_Type == CNode::TYPE_FOR_LOOP) { - CString str = GetIndentString(nIndentLevel) + "for ("; + CString str = GetIndentString(nIndentLevel) + "for ("; for (INT_PTR j = 0; j < m_ProcBodies.at(i).at(nNodeIndex).m_Arguments.GetSize(); j++) { - if (j > 0) str += "; "; + if (j > 0) str += "; "; str += GetSource(m_ProcBodies.at(i).at(nNodeIndex).m_Arguments.at(j), FALSE, procDescriptor.m_ulNumArgs); - } - str += ") "; - ar.WriteString(str); - } else { + } + str += ") "; + ar.WriteString(str); + } else { ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(nNodeIndex), FALSE, procDescriptor.m_ulNumArgs) + " do "); - } - break; + } + break; - default: + default: ar.WriteString(GetIndentString(nIndentLevel) + GetSource(m_ProcBodies.at(i).at(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)) { - bLocalVar = FALSE; - } - } - } - } + bLocalVar = FALSE; + } + } + } + } - ar.WriteString("\n"); - } + ar.WriteString("\n"); + } } CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) @@ -441,564 +441,564 @@ CString CFalloutScript::GetSource(CNode& node, BOOL bLabel, ULONG ulNumArgs) CString c_strArgumentTemplate("arg%u"); CString c_strLocalVarTemplate("LVar%u"); - CString strResult("Damn!!!"); + CString strResult("Damn!!!"); - if (node.m_Type == CNode::TYPE_OMITTED_ARGUMENT) { + if (node.m_Type == CNode::TYPE_OMITTED_ARGUMENT) { return CString("/* Omitted argument */"); - } + } - WORD wOperator = node.m_Opcode.GetOperator(); - ULONG ulArgument = node.m_Opcode.GetArgument(); + WORD wOperator = node.m_Opcode.GetOperator(); + ULONG ulArgument = node.m_Opcode.GetArgument(); - // sslc additions: - if (wOperator == COpcode::O_JMP) { - if (node.m_Type == CNode::TYPE_BREAK) { + // sslc additions: + if (wOperator == COpcode::O_JMP) { + if (node.m_Type == CNode::TYPE_BREAK) { return CString("break"); - } else if (node.m_Type == CNode::TYPE_CONTINUE) { + } else if (node.m_Type == CNode::TYPE_CONTINUE) { return CString("continue"); - } - } - switch(wOperator) { - case COpcode::O_STRINGOP: + } + } + switch(wOperator) { + case COpcode::O_STRINGOP: try { - if (bLabel) { - strResult = m_Namespace[ulArgument]; - } - else { + if (bLabel) { + strResult = m_Namespace[ulArgument]; + } + else { strResult = "\""; strResult += m_Stringspace[ulArgument] + "\""; - } - } + } + } catch(UserException& e) { - printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); - strResult = "/* Fake object name */"; - } + printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); + strResult = "/* Fake object name */"; + } - break; - - case COpcode::O_FLOATOP: - strResult.Format("%.5f", *((float*)(&ulArgument))); - break; - - case COpcode::O_INTOP: - try { - if (bLabel) { - strResult = m_Namespace[ulArgument]; -// strResult = m_Namespace[m_ProcTable[ulArgument].m_ulNameOffset]; - } - else { - strResult.Format("%d", (long)ulArgument); - } - } - - catch(UserException& e) { - printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); - strResult = "/* Fake object name */"; - } break; - case COpcode::O_POP_RETURN: + case COpcode::O_FLOATOP: + strResult.Format("%.5f", *((float*)(&ulArgument))); + break; + + case COpcode::O_INTOP: + try { + if (bLabel) { + strResult = m_Namespace[ulArgument]; +// strResult = m_Namespace[m_ProcTable[ulArgument].m_ulNameOffset]; + } + else { + strResult.Format("%d", (long)ulArgument); + } + } + + catch(UserException& e) { + printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); + strResult = "/* Fake object name */"; + } + break; + + case COpcode::O_POP_RETURN: strResult = "return "; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); - break; + break; - case COpcode::O_LOOKUP_STRING_PROC: + case COpcode::O_LOOKUP_STRING_PROC: strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); - break; + break; - case COpcode::O_FETCH_GLOBAL: + case COpcode::O_FETCH_GLOBAL: if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid argument to O_FETCH_GLOBAL opcode\n"); - AfxThrowUserException(); - } + 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()) { - printf("Error: Invalid index of global variable\n"); - AfxThrowUserException(); - } + printf("Error: Invalid index of global variable\n"); + AfxThrowUserException(); + } strResult = m_GlobalVarsNames.at(node.m_Arguments.at(0).m_Opcode.GetArgument()); - break; + break; - case COpcode::O_STORE_GLOBAL: + case COpcode::O_STORE_GLOBAL: if (node.m_Arguments.at(1).m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid argument to O_STORE_GLOBAL opcode\n"); - AfxThrowUserException(); - } + 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()) { - printf("Error: Invalid index of global variable\n"); - AfxThrowUserException(); - } + 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); - break; + break; - case COpcode::O_FETCH_EXTERNAL: - { + case COpcode::O_FETCH_EXTERNAL: + { WORD wOperator = node.m_Arguments.at(0).m_Opcode.GetOperator(); - if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { - printf("Error: Invalid argument to O_FETCH_EXTERNAL opcode\n"); - AfxThrowUserException(); - } - } + if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { + printf("Error: Invalid argument to O_FETCH_EXTERNAL opcode\n"); + AfxThrowUserException(); + } + } strResult = GetSource(node.m_Arguments.at(0), TRUE, ulNumArgs); - break; + break; - case COpcode::O_STORE_EXTERNAL: - { + case COpcode::O_STORE_EXTERNAL: + { WORD wOperator = node.m_Arguments.at(1).m_Opcode.GetOperator(); - if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { - printf("Error: Invalid argument to O_STORE_EXTERNAL opcode\n"); - AfxThrowUserException(); - } - } + if ((wOperator != COpcode::O_STRINGOP) && (wOperator != COpcode::O_INTOP)) { + printf("Error: Invalid argument to O_STORE_EXTERNAL opcode\n"); + AfxThrowUserException(); + } + } strResult = GetSource(node.m_Arguments.at(1), TRUE, ulNumArgs) + " := " + GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); - break; + break; - case COpcode::O_FETCH: + case COpcode::O_FETCH: if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid argument to O_FETCH opcode\n"); - AfxThrowUserException(); - } + printf("Error: Invalid argument to O_FETCH opcode\n"); + AfxThrowUserException(); + } - { + { ULONG ulVarNum = node.m_Arguments.at(0).m_Opcode.GetArgument(); - if (ulVarNum < ulNumArgs) { + if (ulVarNum < ulNumArgs) { strResult.Format(c_strArgumentTemplate.c_str(), ulVarNum); - } - else { + } + else { strResult.Format(c_strLocalVarTemplate.c_str(), ulVarNum); - } - } + } + } - break; + break; - case COpcode::O_STORE: + case COpcode::O_STORE: if (node.m_Arguments.at(1).m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid argument to O_STORE opcode\n"); - AfxThrowUserException(); - } + printf("Error: Invalid argument to O_STORE opcode\n"); + AfxThrowUserException(); + } - { + { ULONG ulVarNum = node.m_Arguments.at(1).m_Opcode.GetArgument(); - if (ulVarNum < ulNumArgs) { + if (ulVarNum < ulNumArgs) { strResult.Format(c_strArgumentTemplate.c_str(), ulVarNum); - } else { + } else { strResult.Format(c_strLocalVarTemplate.c_str(), ulVarNum); - } + } strResult += " := "; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); - } + } - break; + break; - case COpcode::O_POP: + case COpcode::O_POP: strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); if (node.m_Arguments.at(0).m_Opcode.GetOperator() == COpcode::O_CALL) { strResult = "call "; strResult += strResult; - } + } - break; + break; - case COpcode::O_CALL: + case COpcode::O_CALL: if (node.m_Arguments.at(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]; - } - else { + } + else { strResult = GetSource(node.m_Arguments.at(node.m_Arguments.GetUpperBound()), FALSE, ulNumArgs); - } + } - //if (node.m_Arguments.GetSize() > 2) { - strResult += "("; + //if (node.m_Arguments.GetSize() > 2) { + strResult += "("; - for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetUpperBound() - 1; nArgIndex++) { - if (nArgIndex == 0) { + for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetUpperBound() - 1; nArgIndex++) { + if (nArgIndex == 0) { strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } - else { + } + else { strResult += ", "; strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } - } + } + } - strResult += ")"; - //} + strResult += ")"; + //} - break; + break; - case COpcode::O_CALL_AT: - strResult = "call "; + case COpcode::O_CALL_AT: + strResult = "call "; if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) { strResult += m_Namespace[m_ProcTable[node.m_Arguments.at(1).m_Opcode.GetArgument()].m_ulNameOffset]; - } - else { + } + else { strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); - } + } strResult += " in ("; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; - break; + break; - case COpcode::O_CALL_CONDITION: - strResult = "call "; + case COpcode::O_CALL_CONDITION: + strResult = "call "; if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) { strResult += m_Namespace[m_ProcTable[node.m_Arguments.at(1).m_Opcode.GetArgument()].m_ulNameOffset]; - } - else { + } + else { strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); - } + } strResult += " when ("; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; - break; + break; - case COpcode::O_ADDREGION: + case COpcode::O_ADDREGION: strResult = "addRegion "; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + " { "; - for(INT_PTR nArgIndex = 1; nArgIndex < node.m_Arguments.GetUpperBound(); nArgIndex++) { - if (nArgIndex == 1) { + for(INT_PTR nArgIndex = 1; nArgIndex < node.m_Arguments.GetUpperBound(); nArgIndex++) { + if (nArgIndex == 1) { strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } - else { + } + else { strResult += ", "; strResult += GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } - } + } + } - strResult += " }"; - break; + strResult += " }"; + break; - case COpcode::O_REFRESHMOUSE: - { - ULONG aulProcArg[1] = { 1 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_REFRESHMOUSE: + { + ULONG aulProcArg[1] = { 1 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_ADDBUTTONPROC: - { - ULONG aulProcArg[4] = { 2, 3, 4, 5 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); - } + case COpcode::O_ADDBUTTONPROC: + { + ULONG aulProcArg[4] = { 2, 3, 4, 5 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); + } - break; + break; - case COpcode::O_ADDBUTTONRIGHTPROC: - { - ULONG aulProcArg[2] = { 2, 3 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); - } + case COpcode::O_ADDBUTTONRIGHTPROC: + { + ULONG aulProcArg[2] = { 2, 3 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); + } - break; + break; - case COpcode::O_SAYOPTION: - { + case COpcode::O_SAYOPTION: + { if (node.m_Arguments.at(1).m_Opcode.GetOperator() == COpcode::O_INTOP) { - ULONG aulProcArg[2] = { 2 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } - else { + ULONG aulProcArg[2] = { 2 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } + else { strResult = "sayOption("; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ", " + GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs) + ")"; - } - } + } + } - break; + break; - case COpcode::O_ADDREGIONPROC: - { - ULONG aulProcArg[4] = { 2, 3, 4, 5 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); - } + case COpcode::O_ADDREGIONPROC: + { + ULONG aulProcArg[4] = { 2, 3, 4, 5 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 4); + } - break; + break; - case COpcode::O_ADDREGIONRIGHTPROC: - { - ULONG aulProcArg[2] = { 2, 3 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); - } + case COpcode::O_ADDREGIONRIGHTPROC: + { + ULONG aulProcArg[2] = { 2, 3 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 2); + } - break; + break; - case COpcode::O_ADDNAMEDEVENT: - { - ULONG aulProcArg[1] = { 2 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_ADDNAMEDEVENT: + { + ULONG aulProcArg[1] = { 2 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_ADDNAMEDHANDLER: - { - ULONG aulProcArg[1] = { 2 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_ADDNAMEDHANDLER: + { + ULONG aulProcArg[1] = { 2 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_ADDKEY: - { - ULONG aulProcArg[1] = { 2 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_ADDKEY: + { + ULONG aulProcArg[1] = { 2 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_GSAY_OPTION: - { - ULONG aulProcArg[1] = { 3 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_GSAY_OPTION: + { + ULONG aulProcArg[1] = { 3 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_GIQ_OPTION: - { - ULONG aulProcArg[1] = { 4 }; - strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); - } + case COpcode::O_GIQ_OPTION: + { + ULONG aulProcArg[1] = { 4 }; + strResult = GetSource(node, bLabel, ulNumArgs, aulProcArg, 1); + } - break; + break; - case COpcode::O_CANCEL: + case COpcode::O_CANCEL: if (node.m_Arguments.at(0).m_Opcode.GetOperator() != COpcode::O_INTOP) { - printf("Error: Invalid argument to O_CANCEL opcode\n"); - AfxThrowUserException(); - } + 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] + ")"; - break; + break; - case COpcode::O_NEGATE: + case COpcode::O_NEGATE: if (node.m_Arguments.at(0).m_Opcode.GetAttributes().m_Category == COpcode::COpcodeAttributes::CATEGORY_INFIX) { strResult = "-("; strResult += GetSource(node.m_Arguments.at(0), bLabel, ulNumArgs) + ")"; - } - else { + } + else { strResult = "-"; strResult += GetSource(node.m_Arguments.at(0), bLabel, ulNumArgs); - } + } - break; - -// case COpcode::O_SETGLOBALMOUSEFUNC: -// printf("Warning: Fallout2 don'\t have implemented handler for O_SETGLOBALMOUSEFUNC opcode\n"); -// continue default execution + break; + +// case COpcode::O_SETGLOBALMOUSEFUNC: +// printf("Warning: Fallout2 don'\t have implemented handler for O_SETGLOBALMOUSEFUNC opcode\n"); +// continue default execution - default: - COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); - ULONG *procArgs = attributes.m_procArgs; - ULONG numProcArgs = attributes.m_numProcArgs; - if (numProcArgs > 0) { - strResult = GetSource(node, bLabel, ulNumArgs, procArgs, numProcArgs); - break; - } - if (node.m_Type == CNode::TYPE_CONDITIONAL_EXPRESSION) { - if (node.m_Arguments.GetSize() != 3) { - printf("Error: Invalid number of arguments in conditional expression\n"); - AfxThrowUserException(); - } + default: + COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); + ULONG *procArgs = attributes.m_procArgs; + ULONG numProcArgs = attributes.m_numProcArgs; + if (numProcArgs > 0) { + strResult = GetSource(node, bLabel, ulNumArgs, procArgs, numProcArgs); + break; + } + if (node.m_Type == CNode::TYPE_CONDITIONAL_EXPRESSION) { + if (node.m_Arguments.GetSize() != 3) { + printf("Error: Invalid number of arguments in conditional expression\n"); + AfxThrowUserException(); + } CString sPostfix[] = { CString(" if "), CString(" else "), CString("")}; - strResult = ""; - for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) { + 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]; - } - break; - } - switch(attributes.m_Category) { - case COpcode::COpcodeAttributes::CATEGORY_INFIX: + } + break; + } + switch(attributes.m_Category) { + case COpcode::COpcodeAttributes::CATEGORY_INFIX: if (ArgNeedParens(node, node.m_Arguments.at(0), CFalloutScript::LEFT_ASSOC)) { strResult = "("; strResult += GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs) + ")"; - } - else { + } + else { strResult = GetSource(node.m_Arguments.at(0), FALSE, ulNumArgs); - } + } strResult += " "; strResult += attributes.m_strName + " "; - + if (ArgNeedParens(node, node.m_Arguments.at(1), CFalloutScript::RIGHT_ASSOC)) { strResult += "("; strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs) + ")"; - } - else { + } + else { strResult += GetSource(node.m_Arguments.at(1), FALSE, ulNumArgs); - } + } - break; + break; - case COpcode::COpcodeAttributes::CATEGORY_PREFIX: - strResult = attributes.m_strName; + case COpcode::COpcodeAttributes::CATEGORY_PREFIX: + strResult = attributes.m_strName; - if (node.m_Arguments.GetSize() != 0) { - if (wOperator == COpcode::O_IF || wOperator == COpcode::O_WHILE) { - strResult += " "; - } + if (node.m_Arguments.GetSize() != 0) { + if (wOperator == COpcode::O_IF || wOperator == COpcode::O_WHILE) { + strResult += " "; + } - strResult += "("; + strResult += "("; - for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) { - if (i == 0) { + for(INT_PTR i = 0; i < node.m_Arguments.GetSize(); i++) { + if (i == 0) { strResult += GetSource(node.m_Arguments.at(i), FALSE, ulNumArgs); - } - else { + } + else { strResult += ", "; strResult += GetSource(node.m_Arguments.at(i), FALSE, ulNumArgs); - } - } + } + } - strResult += ")"; - } + strResult += ")"; + } - break; - } - } + break; + } + } - return strResult; + return strResult; } CString CFalloutScript::GetSource( CNode& node, BOOL bLabel, ULONG ulNumArgs, ULONG aulProcArg[], ULONG ulProcArgCount) { - COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); - CString strResult = attributes.m_strName + "("; - CString strArgument; - BOOL bIsProcArg; + COpcode::COpcodeAttributes attributes = node.m_Opcode.GetAttributes(); + CString strResult = attributes.m_strName + "("; + CString strArgument; + BOOL bIsProcArg; - for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetSize(); nArgIndex++) { - bIsProcArg = FALSE; + for(INT_PTR nArgIndex = 0; nArgIndex < node.m_Arguments.GetSize(); nArgIndex++) { + bIsProcArg = FALSE; - for(ULONG ulProcArgIndex = 0; ulProcArgIndex < ulProcArgCount; ulProcArgIndex++) { - if (nArgIndex == aulProcArg[ulProcArgIndex] - 1) { - bIsProcArg = TRUE; - break; - } - } + for(ULONG ulProcArgIndex = 0; ulProcArgIndex < ulProcArgCount; ulProcArgIndex++) { + if (nArgIndex == aulProcArg[ulProcArgIndex] - 1) { + bIsProcArg = TRUE; + break; + } + } - if (bIsProcArg) { + if (bIsProcArg) { if (node.m_Arguments.at(nArgIndex).m_Opcode.GetOperator() == COpcode::O_INTOP) { try { strArgument = m_Namespace[m_ProcTable[node.m_Arguments.at(nArgIndex).m_Opcode.GetArgument()].m_ulNameOffset]; - } + } catch(UserException& e) { - printf("Warning: Restoration after exception. Object name replaced with '/* Fake object name */'\n"); + 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()); - } + } - } - else { + } + else { strArgument = GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } - } - else { + } + } + else { strArgument = GetSource(node.m_Arguments.at(nArgIndex), FALSE, ulNumArgs); - } + } - if (nArgIndex == 0) { - strResult += strArgument; - } - else { + if (nArgIndex == 0) { + strResult += strArgument; + } + else { strResult += ", "; strResult += strArgument; - } - } + } + } - strResult += ")"; + strResult += ")"; - return strResult; + return strResult; } CString CFalloutScript::GetIndentString(INT_PTR nLevel) { - CString strResult; - - for(; nLevel > 0; nLevel--) { - strResult += g_strIndentFill; - } + CString strResult; + + for(; nLevel > 0; nLevel--) { + strResult += g_strIndentFill; + } - return strResult; + return strResult; } int CFalloutScript::GetPriority(WORD wOperator) { - switch(wOperator) { - case COpcode::O_IF: - return 0; - case COpcode::O_OR: - case COpcode::O_AND: - return 2; + switch(wOperator) { + case COpcode::O_IF: + return 0; + case COpcode::O_OR: + case COpcode::O_AND: + return 2; - case COpcode::O_GREATER: - case COpcode::O_LESS: - case COpcode::O_GREATER_EQUAL: - case COpcode::O_LESS_EQUAL: - case COpcode::O_EQUAL: - case COpcode::O_NOT_EQUAL: - return 3; + case COpcode::O_GREATER: + case COpcode::O_LESS: + case COpcode::O_GREATER_EQUAL: + case COpcode::O_LESS_EQUAL: + case COpcode::O_EQUAL: + case COpcode::O_NOT_EQUAL: + return 3; - case COpcode::O_ADD: - case COpcode::O_SUB: - case COpcode::O_BWXOR: - case COpcode::O_BWOR: - case COpcode::O_BWAND: - return 4; + case COpcode::O_ADD: + case COpcode::O_SUB: + case COpcode::O_BWXOR: + case COpcode::O_BWOR: + case COpcode::O_BWAND: + return 4; - case COpcode::O_MUL: - case COpcode::O_DIV: - case COpcode::O_MOD: - case COpcode::O_TS_POW: - return 5; - - default: - return 6; - } + case COpcode::O_MUL: + case COpcode::O_DIV: + case COpcode::O_MOD: + case COpcode::O_TS_POW: + return 5; + + default: + return 6; + } } CFalloutScript::Assoc CFalloutScript::GetAssociation(WORD wOperator) { - switch(wOperator) { - case COpcode::O_GREATER: - case COpcode::O_LESS: - case COpcode::O_GREATER_EQUAL: - case COpcode::O_LESS_EQUAL: - case COpcode::O_EQUAL: - case COpcode::O_NOT_EQUAL: - return CFalloutScript::NON_ASSOC; + switch(wOperator) { + case COpcode::O_GREATER: + case COpcode::O_LESS: + case COpcode::O_GREATER_EQUAL: + case COpcode::O_LESS_EQUAL: + case COpcode::O_EQUAL: + case COpcode::O_NOT_EQUAL: + return CFalloutScript::NON_ASSOC; - case COpcode::O_OR: - case COpcode::O_AND: - case COpcode::O_ADD: - case COpcode::O_SUB: - case COpcode::O_BWXOR: - case COpcode::O_BWOR: - case COpcode::O_BWAND: - case COpcode::O_MUL: - case COpcode::O_DIV: - case COpcode::O_MOD: - return CFalloutScript::LEFT_ASSOC; - - default: - return CFalloutScript::NON_ASSOC; - } + case COpcode::O_OR: + case COpcode::O_AND: + case COpcode::O_ADD: + case COpcode::O_SUB: + case COpcode::O_BWXOR: + case COpcode::O_BWOR: + case COpcode::O_BWAND: + case COpcode::O_MUL: + case COpcode::O_DIV: + case COpcode::O_MOD: + return CFalloutScript::LEFT_ASSOC; + + default: + return CFalloutScript::NON_ASSOC; + } } diff --git a/Hacks/CArchive.cpp b/Hacks/CArchive.cpp index eb56072..9663851 100644 --- a/Hacks/CArchive.cpp +++ b/Hacks/CArchive.cpp @@ -26,6 +26,5 @@ ULONG CArchive::Read(char *buffer, ULONG size) { ULONG count; count = _file->_istream.readsome(buffer, size); - //_file->_istream.seekg(_file->_istream.tellg(), std::ios_base::beg); return count; } diff --git a/Namespace.cpp b/Namespace.cpp index 31b0dd0..ba42e5a 100644 --- a/Namespace.cpp +++ b/Namespace.cpp @@ -16,7 +16,7 @@ CNamespace::CNamespace() { - m_Map.InitHashTable(128); + m_Map.InitHashTable(128); } CNamespace::~CNamespace() @@ -29,98 +29,98 @@ void CNamespace::Serialize(CArchive& ar) if (false) { //ASSERT(FALSE); - } - else { - m_Map.RemoveAll(); - m_Order.RemoveAll(); + } + else { + m_Map.RemoveAll(); + m_Order.RemoveAll(); - ULONG ulLength; + ULONG ulLength; if (ReadMSBULong(ar, ulLength) != 4) { - printf("Error: Unable read length of namespace\n"); - AfxThrowUserException(); - } + printf("Error: Unable read length of namespace\n"); + AfxThrowUserException(); + } if (ulLength != 0xFFFFFFFF) { - ULONG ulTotalRead = 0; - WORD wLengthOfString; + ULONG ulTotalRead = 0; + WORD wLengthOfString; LPTSTR lpszNewString; while(ulTotalRead < ulLength) { CString strNewString; - if (ReadMSBWord(ar, wLengthOfString) != 2) { - printf("Error: Unable read length of string\n"); - AfxThrowUserException(); - }; + if (ReadMSBWord(ar, wLengthOfString) != 2) { + printf("Error: Unable read length of string\n"); + AfxThrowUserException(); + }; - if ((wLengthOfString < 2) || (wLengthOfString & 0x0001)) { - printf("Error: Invalid length of string\n"); - AfxThrowUserException(); - } + if ((wLengthOfString < 2) || (wLengthOfString & 0x0001)) { + printf("Error: Invalid length of string\n"); + AfxThrowUserException(); + } lpszNewString = strNewString.GetBuffer(wLengthOfString); - if (ar.Read(lpszNewString, wLengthOfString) != wLengthOfString) { - strNewString.ReleaseBufferSetLength(0); - printf("Error: Unable read string in namespace\n"); - AfxThrowUserException(); - } + if (ar.Read(lpszNewString, wLengthOfString) != wLengthOfString) { + strNewString.ReleaseBufferSetLength(0); + printf("Error: Unable read string in namespace\n"); + AfxThrowUserException(); + } - if ((lpszNewString[wLengthOfString - 1] != '\x00') && (lpszNewString[wLengthOfString - 2] != '\x00')) { - strNewString.ReleaseBufferSetLength(0); - printf("Error: Invalid end of string in namespace\n"); - AfxThrowUserException(); - } + if ((lpszNewString[wLengthOfString - 1] != '\x00') && (lpszNewString[wLengthOfString - 2] != '\x00')) { + strNewString.ReleaseBufferSetLength(0); + printf("Error: Invalid end of string in namespace\n"); + AfxThrowUserException(); + } std::string tmpString(lpszNewString); strNewString = tmpString.c_str();//.ReleaseBuffer(); - // Convert Nongraphic Characters to Escape sequence - CString strNonGraph("\\\a\b\f\n\r\t\""); - CString strEscape("\\abfnrt\""); + // Convert Nongraphic Characters to Escape sequence + CString strNonGraph("\\\a\b\f\n\r\t\""); + CString strEscape("\\abfnrt\""); for(int i = 0; i < strNonGraph.GetLength(); i++) { strNewString.Replace(CString(strNonGraph[i]), CString("\\" + strEscape[i])); - } + } - m_Map.SetAt(ulTotalRead + 6, strNewString); - m_Order.Add(ulTotalRead + 6); + m_Map.SetAt(ulTotalRead + 6, strNewString); + m_Order.Add(ulTotalRead + 6); - ulTotalRead += (2 + wLengthOfString); - } + ulTotalRead += (2 + wLengthOfString); + } - ULONG ulTerminator; + ULONG ulTerminator; if (ReadMSBULong(ar, ulTerminator) != 4) { - printf("Error: Unable read terminator of namespace\n"); - AfxThrowUserException(); - } + printf("Error: Unable read terminator of namespace\n"); + AfxThrowUserException(); + } - if (ulTerminator != 0xFFFFFFFF) { - printf("Error: Invalid terminator of namespace\n"); - AfxThrowUserException(); - } + if (ulTerminator != 0xFFFFFFFF) { + printf("Error: Invalid terminator of namespace\n"); + AfxThrowUserException(); + } -// //For debugging only -// for(INT_PTR i = 0; i < GetSize(); i++) { -// printf("Offset: 0x%08X (%9d), string: %s\n", m_Order[i], m_Order[i], GetStringByIndex(i)); -// } +// //For debugging only +// for(INT_PTR i = 0; i < GetSize(); i++) { +// printf("Offset: 0x%08X (%9d), string: %s\n", m_Order[i], m_Order[i], GetStringByIndex(i)); +// } // -// printf("\n"); - } - } +// printf("\n"); + } + } } INT_PTR CNamespace::GetSize() const { - return m_Map.GetSize(); + return m_Map.GetSize(); } CString CNamespace::GetStringByIndex(INT_PTR nIndex) @@ -135,35 +135,35 @@ ULONG CNamespace::GetOffsetByIndex(INT_PTR nIndex) void CNamespace::Dump(CArchive& ar) { - CString strOutLine; + CString strOutLine; if (m_Order.IsEmpty()) { - ar.WriteString("Empty\n"); - } + ar.WriteString("Empty\n"); + } else { for(unsigned int i = 0; i < m_Order.GetSize(); i++) { strOutLine.Format("0x%08X: \"%s\"\n", m_Order.at(i), GetStringByIndex(i).c_str()); - ar.WriteString(strOutLine); - } + ar.WriteString(strOutLine); + } - ar.WriteString("==================\n"); - strOutLine.Format("%d item(s)\n", m_Order.GetSize()); - ar.WriteString(strOutLine); - } + ar.WriteString("==================\n"); + strOutLine.Format("%d item(s)\n", m_Order.GetSize()); + ar.WriteString(strOutLine); + } } CString CNamespace::operator [] (ULONG ulOffset) const { - CString strResult; + CString strResult; if (!m_Map.Lookup(ulOffset, strResult)) { - printf("Error: No string at offset 0x%08x\n", ulOffset); - AfxThrowUserException(); - } + printf("Error: No string at offset 0x%08x\n", ulOffset); + AfxThrowUserException(); + } - return strResult; + return strResult; } diff --git a/Namespace.h b/Namespace.h index 625673a..344cafa 100644 --- a/Namespace.h +++ b/Namespace.h @@ -9,28 +9,28 @@ // CNamespace class CNamespace : public CObject { public: - CNamespace(); - virtual ~CNamespace(); + CNamespace(); + virtual ~CNamespace(); public: - virtual void Serialize(CArchive& ar); + virtual void Serialize(CArchive& ar); public: - INT_PTR GetSize() const; + INT_PTR GetSize() const; CString GetStringByIndex(INT_PTR nIndex) ; ULONG GetOffsetByIndex(INT_PTR nIndex) ; - void Dump(CArchive& ar); + void Dump(CArchive& ar); public: - CString operator [] (ULONG ulOffset) const; + CString operator [] (ULONG ulOffset) const; private: - // CMapDWordToString - typedef CMap CMapDWordToString; + // CMapDWordToString + typedef CMap CMapDWordToString; - CMapDWordToString m_Map; - CDWordArray m_Order; + CMapDWordToString m_Map; + CDWordArray m_Order; }; #endif diff --git a/Node.cpp b/Node.cpp index ce15f1e..f97411a 100644 --- a/Node.cpp +++ b/Node.cpp @@ -8,18 +8,18 @@ // CNode CNode::CNode(Type type) : - m_ulOffset(0), - m_Type(type) + m_ulOffset(0), + m_Type(type) { } CNode::CNode(const CNode& node) : - m_ulOffset(node.m_ulOffset), - m_Opcode(node.m_Opcode), - m_Type(node.m_Type) + m_ulOffset(node.m_ulOffset), + m_Opcode(node.m_Opcode), + m_Type(node.m_Type) { - m_Arguments.Copy(node.m_Arguments); + m_Arguments.Copy(node.m_Arguments); } CNode::~CNode() @@ -28,90 +28,90 @@ CNode::~CNode() CNode& CNode::operator = (const CNode& node) { - if (&node != this) { - m_ulOffset = node.m_ulOffset; - m_Opcode = node.m_Opcode; - m_Type = node.m_Type; - m_Arguments.Copy(node.m_Arguments); - } + if (&node != this) { + m_ulOffset = node.m_ulOffset; + m_Opcode = node.m_Opcode; + m_Type = node.m_Type; + m_Arguments.Copy(node.m_Arguments); + } - return (*this); + return (*this); } void CNode::StoreTree(CArchive& ar, int nIndent, int nIndex) { - // Indent - if (nIndex != 0) { - ar.WriteString(" "); + // Indent + if (nIndex != 0) { + ar.WriteString(" "); - for(int i = 0; i < nIndent; i++) { - ar.WriteString(" "); - } - } + for(int i = 0; i < nIndent; i++) { + ar.WriteString(" "); + } + } - switch(m_Type) { - case TYPE_BEGIN_OF_BLOCK: - ar.WriteString("========= begin of block =========\n"); - return; + switch(m_Type) { + case TYPE_BEGIN_OF_BLOCK: + ar.WriteString("========= begin of block =========\n"); + return; - case TYPE_END_OF_BLOCK: - ar.WriteString("========= end of block =========\n"); - return; - } + case TYPE_END_OF_BLOCK: + ar.WriteString("========= end of block =========\n"); + return; + } - // Node - CString strOutLine; - WORD wOperator = m_Opcode.GetOperator(); - ULONG ulArgument = m_Opcode.GetArgument(); + // Node + CString strOutLine; + WORD wOperator = m_Opcode.GetOperator(); + ULONG ulArgument = m_Opcode.GetArgument(); - switch(wOperator) { - case COpcode::O_STRINGOP: - case COpcode::O_INTOP: - strOutLine.Format("0x%04X 0x%08x ", - wOperator, - ulArgument); - ar.WriteString(strOutLine); - break; + switch(wOperator) { + case COpcode::O_STRINGOP: + case COpcode::O_INTOP: + strOutLine.Format("0x%04X 0x%08x ", + wOperator, + ulArgument); + ar.WriteString(strOutLine); + break; - case COpcode::O_FLOATOP: - strOutLine.Format("0x%04X 0x%08X ", - wOperator, - ulArgument); - ar.WriteString(strOutLine); - break; + case COpcode::O_FLOATOP: + strOutLine.Format("0x%04X 0x%08X ", + wOperator, + ulArgument); + ar.WriteString(strOutLine); + break; - default: - strOutLine.Format("0x%04X .......... ", - wOperator); - ar.WriteString(strOutLine); - } - if (!m_Arguments.IsEmpty()) { - for(int i = 0; i < m_Arguments.GetSize(); i++) { + default: + strOutLine.Format("0x%04X .......... ", + wOperator); + ar.WriteString(strOutLine); + } + if (!m_Arguments.IsEmpty()) { + for(int i = 0; i < m_Arguments.GetSize(); i++) { m_Arguments.at(i).StoreTree(ar, nIndent + 1, i); - } - } - else { - ar.WriteString("\n"); - } + } + } + else { + ar.WriteString("\n"); + } } ULONG CNode::GetTopOffset() { - if (m_Arguments.GetSize() > 0) + if (m_Arguments.GetSize() > 0) return m_Arguments.at(0).GetTopOffset(); - else - return m_ulOffset; + else + return m_ulOffset; } bool CNode::IsExpression() const { - return (m_Opcode.GetAttributes().m_Type == COpcode::COpcodeAttributes::TYPE_EXPRESSION - || m_Type == TYPE_CONDITIONAL_EXPRESSION); + return (m_Opcode.GetAttributes().m_Type == COpcode::COpcodeAttributes::TYPE_EXPRESSION + || m_Type == TYPE_CONDITIONAL_EXPRESSION); } bool CNode::IsInfix() const { - return (m_Opcode.GetAttributes().m_Category == COpcode::COpcodeAttributes::CATEGORY_INFIX - || m_Type == TYPE_CONDITIONAL_EXPRESSION); + return (m_Opcode.GetAttributes().m_Category == COpcode::COpcodeAttributes::CATEGORY_INFIX + || m_Type == TYPE_CONDITIONAL_EXPRESSION); } diff --git a/Node.h b/Node.h index dfea829..9b4495b 100644 --- a/Node.h +++ b/Node.h @@ -18,37 +18,37 @@ typedef CArray CNodeArray; // CNode class CNode : public CObject { public: - enum Type { - TYPE_NORMAL, - TYPE_BEGIN_OF_BLOCK, - TYPE_END_OF_BLOCK, - TYPE_OMITTED_ARGUMENT, - TYPE_BREAK, - TYPE_CONTINUE, - TYPE_FOR_LOOP, - TYPE_CONDITIONAL_EXPRESSION - }; + enum Type { + TYPE_NORMAL, + TYPE_BEGIN_OF_BLOCK, + TYPE_END_OF_BLOCK, + TYPE_OMITTED_ARGUMENT, + TYPE_BREAK, + TYPE_CONTINUE, + TYPE_FOR_LOOP, + TYPE_CONDITIONAL_EXPRESSION + }; public: - CNode(Type type = TYPE_NORMAL); - CNode(const CNode& node); - virtual ~CNode(); + CNode(Type type = TYPE_NORMAL); + CNode(const CNode& node); + virtual ~CNode(); public: - CNode& operator = (const CNode& node); + CNode& operator = (const CNode& node); public: - void StoreTree(CArchive& ar, int nIndent, int nIndex); - ULONG GetTopOffset(); - bool IsExpression() const; - bool IsInfix() const; + void StoreTree(CArchive& ar, int nIndent, int nIndex); + ULONG GetTopOffset(); + bool IsExpression() const; + bool IsInfix() const; public: - ULONG m_ulOffset; - COpcode m_Opcode; + ULONG m_ulOffset; + COpcode m_Opcode; - Type m_Type; - CNodeArray m_Arguments; + Type m_Type; + CNodeArray m_Arguments; }; diff --git a/ObjectAttributes.h b/ObjectAttributes.h index cb925d0..823f7c1 100644 --- a/ObjectAttributes.h +++ b/ObjectAttributes.h @@ -6,21 +6,21 @@ // ProcedureAttributes enum ProcAttributes { - P_TIMED = 0x01, - P_CONDITIONAL = 0x02, - P_IMPORT = 0x04, - P_EXPORT = 0x08, - P_CRITICAL = 0x10, + P_TIMED = 0x01, + P_CONDITIONAL = 0x02, + P_IMPORT = 0x04, + P_EXPORT = 0x08, + P_CRITICAL = 0x10, - P_NOTIMPLEMENTED = 0x80000000 + P_NOTIMPLEMENTED = 0x80000000 }; // VariableAtributes enum VariableAtributes { - V_GLOBAL = 0x00010000, - V_IMPORT = 0x00020000, - V_EXPORT = 0x00040000 + V_GLOBAL = 0x00010000, + V_IMPORT = 0x00020000, + V_EXPORT = 0x00040000 }; #endif diff --git a/Opcode.cpp b/Opcode.cpp index 3d73b0c..6e2c4d4 100644 --- a/Opcode.cpp +++ b/Opcode.cpp @@ -15,14 +15,14 @@ extern int g_nFalloutVersion; // COpcode COpcode::COpcode() : - m_wOperator(O_NOOP), - m_ulArgument(0) + m_wOperator(O_NOOP), + m_ulArgument(0) { } COpcode::COpcode(const COpcode& opcode) : - m_wOperator(opcode.m_wOperator), - m_ulArgument(opcode.m_ulArgument) + m_wOperator(opcode.m_wOperator), + m_ulArgument(opcode.m_ulArgument) { } @@ -33,130 +33,130 @@ COpcode::~COpcode() COpcode& COpcode::operator = (const COpcode& opcode) { - m_wOperator = opcode.m_wOperator; - m_ulArgument = opcode.m_ulArgument; + m_wOperator = opcode.m_wOperator; + m_ulArgument = opcode.m_ulArgument; - return (*this); + return (*this); } void COpcode::Serialize(CArchive& ar) { - if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE) { + if (ReadMSBWord(ar, m_wOperator) != OPERATOR_SIZE) { - printf("Error: Unable read opcode\n"); - AfxThrowUserException(); - } + printf("Error: Unable read opcode\n"); + AfxThrowUserException(); + } - if ((m_wOperator < O_OPERATOR) || - ((m_wOperator >= O_END_OP) && - (m_wOperator != O_STRINGOP) && - (m_wOperator != O_FLOATOP)&& - (m_wOperator != O_INTOP))) { - ar.Flush(); - printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2); - AfxThrowUserException(); - } + if ((m_wOperator < O_OPERATOR) || + ((m_wOperator >= O_END_OP) && + (m_wOperator != O_STRINGOP) && + (m_wOperator != O_FLOATOP)&& + (m_wOperator != O_INTOP))) { + ar.Flush(); + printf("Error: Invalid opcode at 0x%08x\n", ar.GetFile()->GetPosition() - 2); + AfxThrowUserException(); + } - if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) { - if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE) { - printf("Error: Unable read opcode argument\n"); - AfxThrowUserException(); - } - } + if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) { + if (ReadMSBULong(ar, m_ulArgument) != ARGUMENT_SIZE) { + printf("Error: Unable read opcode argument\n"); + AfxThrowUserException(); + } + } } void COpcode::Expect(CArchive& ar, WORD wOperator, BOOL bArgumentFound, ULONG ulArgument) { - Serialize(ar); + Serialize(ar); - if (m_wOperator != wOperator) { - printf("Error: Unexpected opcode (0x%04X expected, but 0x%04X found)\n", wOperator, m_wOperator); - AfxThrowUserException(); - } + if (m_wOperator != wOperator) { + printf("Error: Unexpected opcode (0x%04X expected, but 0x%04X found)\n", wOperator, m_wOperator); + AfxThrowUserException(); + } - if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))) { - if (m_ulArgument != ulArgument) { - printf("Error: Unexpected argument of opcode. (0x%08X expected, but 0x%08X found)\n", ulArgument, m_ulArgument); - AfxThrowUserException(); - } - } + if (bArgumentFound && ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP))) { + if (m_ulArgument != ulArgument) { + printf("Error: Unexpected argument of opcode. (0x%08X expected, but 0x%08X found)\n", ulArgument, m_ulArgument); + AfxThrowUserException(); + } + } } void COpcode::Expect(CArchive& ar, int nCount, WORD pwOperators[]) { - Serialize(ar); - BOOL bFound = FALSE; + Serialize(ar); + BOOL bFound = FALSE; - for(int i = 0; i < nCount; i++) { - if (m_wOperator == pwOperators[i]) { - bFound = TRUE; - break; - } - } + for(int i = 0; i < nCount; i++) { + if (m_wOperator == pwOperators[i]) { + bFound = TRUE; + break; + } + } - if (!bFound) { - printf("Error: Unexpected opcode ("); + if (!bFound) { + printf("Error: Unexpected opcode ("); - for(int i = 0; i < nCount; i++) { - if (i != 0) { - printf(" or "); - } + for(int i = 0; i < nCount; i++) { + if (i != 0) { + printf(" or "); + } - printf("0x%04X", pwOperators[i]); - } + printf("0x%04X", pwOperators[i]); + } - printf(" expected, but 0x%04X found)\n", m_wOperator); - AfxThrowUserException(); - } + printf(" expected, but 0x%04X found)\n", m_wOperator); + AfxThrowUserException(); + } } BOOL COpcode::HasArgument() const { - return ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)); + return ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)); } int COpcode::GetSize() const { - if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) { - return OPERATOR_SIZE + ARGUMENT_SIZE; - } - else { - return OPERATOR_SIZE; - } + if ((m_wOperator == O_STRINGOP) || (m_wOperator == O_FLOATOP) || (m_wOperator == O_INTOP)) { + return OPERATOR_SIZE + ARGUMENT_SIZE; + } + else { + return OPERATOR_SIZE; + } } WORD COpcode::GetOperator() const { - return m_wOperator; + return m_wOperator; } void COpcode::SetOperator(WORD op) { - m_wOperator = op; + m_wOperator = op; } ULONG COpcode::GetArgument() const { - return m_ulArgument; + return m_ulArgument; } const COpcode::COpcodeAttributes COpcode::GetAttributes() const { - static CF1OpcodeAttributesMap f1OpcodeAttributes; - static CF2OpcodeAttributesMap f2OpcodeAttributes; - - COpcodeAttributes result; + static CF1OpcodeAttributesMap f1OpcodeAttributes; + static CF2OpcodeAttributesMap f2OpcodeAttributes; + + COpcodeAttributes result; - if (g_nFalloutVersion == 1) { - if (f1OpcodeAttributes.Lookup(m_wOperator, result)) { - return result; - } - } + if (g_nFalloutVersion == 1) { + if (f1OpcodeAttributes.Lookup(m_wOperator, result)) { + return result; + } + } - if (!f2OpcodeAttributes.Lookup(m_wOperator, result)) { - printf("Error: Attempt to obtain attributes of unknown opcode\n"); - AfxThrowUserException(); - } + if (!f2OpcodeAttributes.Lookup(m_wOperator, result)) { + printf("Error: Attempt to obtain attributes of unknown opcode\n"); + AfxThrowUserException(); + } - return result; + return result; } diff --git a/Opcode.h b/Opcode.h index af0e5e8..5fbd382 100644 --- a/Opcode.h +++ b/Opcode.h @@ -9,775 +9,775 @@ class COpcode { public: - enum Size { - OPERATOR_SIZE = 2, - ARGUMENT_SIZE = 4 - }; + enum Size { + OPERATOR_SIZE = 2, + ARGUMENT_SIZE = 4 + }; - enum O_Base { - O_STRING = 0x1000, - O_FLOAT = 0x2000, - O_INT = 0x4000, - O_OPERATOR = 0x8000 - }; + enum O_Base { + O_STRING = 0x1000, + O_FLOAT = 0x2000, + O_INT = 0x4000, + O_OPERATOR = 0x8000 + }; - // const O_IF_EXPR = 1000; + // const O_IF_EXPR = 1000; - enum O_Core { - O_NOOP = O_OPERATOR, - O_CONST, - O_CRITICAL_START, - O_CRITICAL_DONE, - O_JMP, - O_CALL, - O_CALL_AT, // timed function calls - O_CALL_CONDITION, - O_CALLSTART, - O_EXEC, - O_SPAWN, - O_FORK, - O_A_TO_D, - O_D_TO_A, - O_EXIT, // exit prog and purge it from process queue - O_DETACH, // detach spawned process from its parent. - O_EXIT_PROG, // exit program but leave it in process queue - O_STOP_PROG, - O_FETCH_GLOBAL, - O_STORE_GLOBAL, - O_FETCH_EXTERNAL, - O_STORE_EXTERNAL, - O_EXPORT_VAR, - O_EXPORT_PROC, - O_SWAP, - O_SWAPA, - O_POP, - O_DUP, - O_POP_RETURN, - O_POP_EXIT, - O_POP_ADDRESS, - O_POP_FLAGS, - O_POP_FLAGS_RETURN, - O_POP_FLAGS_EXIT, - O_POP_FLAGS_RETURN_EXTERN, - O_POP_FLAGS_EXIT_EXTERN, - O_POP_FLAGS_RETURN_VAL_EXTERN, + enum O_Core { + O_NOOP = O_OPERATOR, + O_CONST, + O_CRITICAL_START, + O_CRITICAL_DONE, + O_JMP, + O_CALL, + O_CALL_AT, // timed function calls + O_CALL_CONDITION, + O_CALLSTART, + O_EXEC, + O_SPAWN, + O_FORK, + O_A_TO_D, + O_D_TO_A, + O_EXIT, // exit prog and purge it from process queue + O_DETACH, // detach spawned process from its parent. + O_EXIT_PROG, // exit program but leave it in process queue + O_STOP_PROG, + O_FETCH_GLOBAL, + O_STORE_GLOBAL, + O_FETCH_EXTERNAL, + O_STORE_EXTERNAL, + O_EXPORT_VAR, + O_EXPORT_PROC, + O_SWAP, + O_SWAPA, + O_POP, + O_DUP, + O_POP_RETURN, + O_POP_EXIT, + O_POP_ADDRESS, + O_POP_FLAGS, + O_POP_FLAGS_RETURN, + O_POP_FLAGS_EXIT, + O_POP_FLAGS_RETURN_EXTERN, + O_POP_FLAGS_EXIT_EXTERN, + O_POP_FLAGS_RETURN_VAL_EXTERN, - // return from a procedure called from C, leaving the return value - // on the stack. - O_POP_FLAGS_RETURN_VAL_EXIT, - O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, + // return from a procedure called from C, leaving the return value + // on the stack. + O_POP_FLAGS_RETURN_VAL_EXIT, + O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, - O_CHECK_ARG_COUNT, // call to do a run-time check of arguments to functions - O_LOOKUP_STRING_PROC, // call to lookup a procedure index given a string - O_POP_BASE, - O_POP_TO_BASE, - O_PUSH_BASE, - O_SET_GLOBAL, - O_FETCH_PROC_ADDRESS, - O_DUMP, - O_IF, - O_WHILE, - O_STORE, - O_FETCH, - O_EQUAL, - O_NOT_EQUAL, - O_LESS_EQUAL, - O_GREATER_EQUAL, - O_LESS, - O_GREATER, - O_ADD, - O_SUB, - O_MUL, - O_DIV, - O_MOD, - O_AND, - O_OR, - O_BWAND, - O_BWOR, - O_BWXOR, - O_BWNOT, - O_FLOOR, - O_NOT, - O_NEGATE, - O_WAIT, - O_CANCEL, - O_CANCELALL, + O_CHECK_ARG_COUNT, // call to do a run-time check of arguments to functions + O_LOOKUP_STRING_PROC, // call to lookup a procedure index given a string + O_POP_BASE, + O_POP_TO_BASE, + O_PUSH_BASE, + O_SET_GLOBAL, + O_FETCH_PROC_ADDRESS, + O_DUMP, + O_IF, + O_WHILE, + O_STORE, + O_FETCH, + O_EQUAL, + O_NOT_EQUAL, + O_LESS_EQUAL, + O_GREATER_EQUAL, + O_LESS, + O_GREATER, + O_ADD, + O_SUB, + O_MUL, + O_DIV, + O_MOD, + O_AND, + O_OR, + O_BWAND, + O_BWOR, + O_BWXOR, + O_BWNOT, + O_FLOOR, + O_NOT, + O_NEGATE, + O_WAIT, + O_CANCEL, + O_CANCELALL, - O_STARTCRITICAL, - O_ENDCRITICAL, + O_STARTCRITICAL, + O_ENDCRITICAL, - O_END_CORE // don't use this anywhere, or you'll die - }; + O_END_CORE // don't use this anywhere, or you'll die + }; - enum O_Lib { - O_SAYQUIT = O_END_CORE, - O_SAYEND, - O_SAYSTART, - O_SAYSTARTPOS, - O_SAYREPLYTITLE, - O_SAYGOTOREPLY, - O_SAYREPLY, - O_SAYOPTION, - O_SAYMESSAGE, - O_SAYREPLYWINDOW, // sayreplywindow(sx, sy, w, h, "fill3x3 pattern"); - O_SAYOPTIONWINDOW, // sayoptionwindow '' - O_SAYBORDER, // sayoptionborder(x, y) - O_SAYSCROLLUP, - O_SAYSCROLLDOWN, - O_SAYSETSPACING, - O_SAYOPTIONCOLOR, - O_SAYREPLYCOLOR, - O_SAYRESTART, - O_SAYGETLASTPOS, - O_SAYREPLYFLAGS, - O_SAYOPTIONFLAGS, - O_SAYMESSAGETIMEOUT, // removes sayMsg in x time, unless x = 0 + enum O_Lib { + O_SAYQUIT = O_END_CORE, + O_SAYEND, + O_SAYSTART, + O_SAYSTARTPOS, + O_SAYREPLYTITLE, + O_SAYGOTOREPLY, + O_SAYREPLY, + O_SAYOPTION, + O_SAYMESSAGE, + O_SAYREPLYWINDOW, // sayreplywindow(sx, sy, w, h, "fill3x3 pattern"); + O_SAYOPTIONWINDOW, // sayoptionwindow '' + O_SAYBORDER, // sayoptionborder(x, y) + O_SAYSCROLLUP, + O_SAYSCROLLDOWN, + O_SAYSETSPACING, + O_SAYOPTIONCOLOR, + O_SAYREPLYCOLOR, + O_SAYRESTART, + O_SAYGETLASTPOS, + O_SAYREPLYFLAGS, + O_SAYOPTIONFLAGS, + O_SAYMESSAGETIMEOUT, // removes sayMsg in x time, unless x = 0 - O_CREATEWIN, - O_DELETEWIN, - O_SELECTWIN, - O_RESIZEWIN, - O_SCALEWIN, - O_SHOWWIN, - O_FILLWIN, - O_FILLRECT, - O_FILLWIN3X3, - O_DISPLAY, - O_DISPLAYGFX, - O_DISPLAYRAW, - O_LOADPALETTETABLE, - O_FADEIN, - O_FADEOUT, - O_GOTOXY, - O_PRINT, - O_FORMAT, - O_PRINTRECT, - O_SETFONT, - O_SETTEXTFLAGS, - O_SETTEXTCOLOR, - O_SETHIGHLIGHTCOLOR, - O_STOPMOVIE, - O_PLAYMOVIE, - O_MOVIEFLAGS, - O_PLAYMOVIERECT, - O_PLAYMOVIEALPHA, - O_PLAYMOVIEALPHARECT, - O_ADDREGION, - O_ADDREGIONFLAG, - O_ADDREGIONPROC, - O_ADDREGIONRIGHTPROC, - O_DELETEREGION, - O_ACTIVATEREGION, - O_CHECKREGION, // returns if a region exists or not + O_CREATEWIN, + O_DELETEWIN, + O_SELECTWIN, + O_RESIZEWIN, + O_SCALEWIN, + O_SHOWWIN, + O_FILLWIN, + O_FILLRECT, + O_FILLWIN3X3, + O_DISPLAY, + O_DISPLAYGFX, + O_DISPLAYRAW, + O_LOADPALETTETABLE, + O_FADEIN, + O_FADEOUT, + O_GOTOXY, + O_PRINT, + O_FORMAT, + O_PRINTRECT, + O_SETFONT, + O_SETTEXTFLAGS, + O_SETTEXTCOLOR, + O_SETHIGHLIGHTCOLOR, + O_STOPMOVIE, + O_PLAYMOVIE, + O_MOVIEFLAGS, + O_PLAYMOVIERECT, + O_PLAYMOVIEALPHA, + O_PLAYMOVIEALPHARECT, + O_ADDREGION, + O_ADDREGIONFLAG, + O_ADDREGIONPROC, + O_ADDREGIONRIGHTPROC, + O_DELETEREGION, + O_ACTIVATEREGION, + O_CHECKREGION, // returns if a region exists or not - O_ADDBUTTON, - O_ADDBUTTONTEXT, - O_ADDBUTTONFLAG, - O_ADDBUTTONGFX, - O_ADDBUTTONPROC, - O_ADDBUTTONRIGHTPROC, - O_DELETEBUTTON, + O_ADDBUTTON, + O_ADDBUTTONTEXT, + O_ADDBUTTONFLAG, + O_ADDBUTTONGFX, + O_ADDBUTTONPROC, + O_ADDBUTTONRIGHTPROC, + O_DELETEBUTTON, - O_HIDEMOUSE, - O_SHOWMOUSE, - O_MOUSESHAPE, - O_REFRESHMOUSE, - O_SETGLOBALMOUSEFUNC, + O_HIDEMOUSE, + O_SHOWMOUSE, + O_MOUSESHAPE, + O_REFRESHMOUSE, + O_SETGLOBALMOUSEFUNC, - O_ADDNAMEDEVENT, - O_ADDNAMEDHANDLER, - O_CLEARNAMED, - O_SIGNALNAMED, + O_ADDNAMEDEVENT, + O_ADDNAMEDHANDLER, + O_CLEARNAMED, + O_SIGNALNAMED, - O_ADDKEY, - O_DELETEKEY, + O_ADDKEY, + O_DELETEKEY, - O_SOUNDPLAY, - O_SOUNDPAUSE, - O_SOUNDRESUME, - O_SOUNDSTOP, - O_SOUNDREWIND, - O_SOUNDDELETE, - O_SETONEOPTPAUSE, + O_SOUNDPLAY, + O_SOUNDPAUSE, + O_SOUNDRESUME, + O_SOUNDSTOP, + O_SOUNDREWIND, + O_SOUNDDELETE, + O_SETONEOPTPAUSE, - O_SELECTFILELIST, + O_SELECTFILELIST, - O_TOKENIZE, - O_END_LIB // don't use this anywhere or your head will explode - }; + O_TOKENIZE, + O_END_LIB // don't use this anywhere or your head will explode + }; - enum O_Extra { - // define any user-specific opcodes here, starting at O_END_LIB - // ending with O_END_OP - O_GIVE_EXP_POINTS = O_END_LIB, - O_SCR_RETURN, - O_PLAY_SFX, - O_OBJ_NAME, - O_SFX_BUILD_OPEN_NAME, - O_GET_PC_STAT, - O_TILE_CONTAINS_PID_OBJ, - O_SET_MAP_START, - O_OVERRIDE_MAP_START, - O_HAS_SKILL, - O_USING_SKILL, - O_ROLL_VS_SKILL, - O_SKILL_CONTEST, - O_DO_CHECK, - O_IS_SUCCESS, - O_IS_CRITICAL, - O_HOW_MUCH, - O_MARK_AREA_KNOWN, - O_REACTION_INFLUENCE, - O_RANDOM, - O_ROLL_DICE, - O_MOVE_TO, - O_CREATE_OBJECT_SID, - O_DISPLAY_MSG, - O_SCRIPT_OVERRIDES, - O_OBJ_IS_CARRYING_OBJ_PID, - O_TILE_CONTAINS_OBJ_PID, - O_SELF_OBJ, - O_SOURCE_OBJ, - O_TARGET_OBJ, - O_DUDE_OBJ, - O_OBJ_BEING_USED_WITH, - O_LOCAL_VAR, - O_SET_LOCAL_VAR, - O_MAP_VAR, - O_SET_MAP_VAR, - O_GLOBAL_VAR, - O_SET_GLOBAL_VAR, - O_SCRIPT_ACTION, - O_OBJ_TYPE, - O_OBJ_ITEM_SUBTYPE, - O_GET_CRITTER_STAT, - O_SET_CRITTER_STAT, - O_ANIMATE_STAND_OBJ, - O_ANIMATE_STAND_REVERSE_OBJ, - O_ANIMATE_MOVE_OBJ_TO_TILE, - O_TILE_IN_TILE_RECT, - O_ATTACK_COMPLEX, - O_MAKE_DAYTIME, - O_TILE_DISTANCE, - O_TILE_DISTANCE_OBJS, - O_TILE_NUM, - O_TILE_NUM_IN_DIRECTION, - O_PICKUP_OBJ, - O_DROP_OBJ, - O_ADD_OBJ_TO_INVEN, - O_RM_OBJ_FROM_INVEN, - O_WIELD_OBJ_CRITTER, - O_USE_OBJ, - O_OBJ_CAN_SEE_OBJ, - O_ATTACK, - O_START_GDIALOG, - O_END_DIALOGUE, - O_DIALOGUE_REACTION, - O_METARULE3, - O_SET_MAP_MUSIC, - O_SET_OBJ_VISIBILITY, - O_LOAD_MAP, - O_WM_AREA_SET_POS, - O_SET_EXIT_GRIDS, - O_ANIM_BUSY, - O_CRITTER_HEAL, - O_SET_LIGHT_LEVEL, - O_GAME_TIME, - O_GAME_TIME_IN_SECONDS, - O_ELEVATION, - O_KILL_CRITTER, - O_KILL_CRITTER_TYPE, - O_CRITTER_DMG, - O_ADD_TIMER_EVENT, - O_RM_TIMER_EVENT, - O_GAME_TICKS, - O_HAS_TRAIT, - O_DESTROY_OBJECT, - O_OBJ_CAN_HEAR_OBJ, - O_GAME_TIME_HOUR, - O_FIXED_PARAM, - O_TILE_IS_VISIBLE, - O_DIALOGUE_SYSTEM_ENTER, - O_ACTION_BEING_USED, - O_CRITTER_STATE, - O_GAME_TIME_ADVANCE, - O_RADIATION_INC, - O_RADIATION_DEC, - O_CRITTER_ATTEMPT_PLACEMENT, - O_OBJ_PID, - O_CUR_MAP_INDEX, - O_CRITTER_ADD_TRAIT, - O_CRITTER_RM_TRAIT, - O_PROTO_DATA, - O_MESSAGE_STR, - O_CRITTER_INVEN_OBJ, - O_OBJ_SET_LIGHT_LEVEL, - O_WORLD_MAP, - O_INVEN_CMDS, - O_FLOAT_MSG, - O_METARULE, - O_ANIM, - O_OBJ_CARRYING_PID_OBJ, - O_REG_ANIM_FUNC, - O_REG_ANIM_ANIMATE, - O_REG_ANIM_ANIMATE_REVERSE, - O_REG_ANIM_OBJ_MOVE_TO_OBJ, - O_REG_ANIM_OBJ_RUN_TO_OBJ, - O_REG_ANIM_OBJ_MOVE_TO_TILE, - O_REG_ANIM_OBJ_RUN_TO_TILE, - O_PLAY_GMOVIE, - O_ADD_MULT_OBJS_TO_INVEN, - O_RM_MULT_OBJS_FROM_INVEN, - O_GET_MONTH, - O_GET_DAY, - O_EXPLOSION, - O_DAYS_SINCE_VISITED, - O_GSAY_START, - O_GSAY_END, - O_GSAY_REPLY, - O_GSAY_OPTION, - O_GSAY_MESSAGE, - O_GIQ_OPTION, - O_POISON, - O_GET_POISON, - O_PARTY_ADD, - O_PARTY_REMOVE, - O_REG_ANIM_ANIMATE_FOREVER, - O_CRITTER_INJURE, - O_COMBAT_IS_INITIALIZED, - O_GDIALOG_MOD_BARTER, - O_DIFFICULTY_LEVEL, - O_RUNNING_BURNING_GUY, - O_INVEN_UNWIELD, - O_OBJ_IS_LOCKED, - O_OBJ_LOCK, - O_OBJ_UNLOCK, - O_OBJ_IS_OPEN, - O_OBJ_OPEN, - O_OBJ_CLOSE, - O_GAME_UI_DISABLE, - O_GAME_UI_ENABLE, - O_GAME_UI_IS_DISABLED, - O_GFADE_OUT, - O_GFADE_IN, - O_ITEM_CAPS_TOTAL, - O_ITEM_CAPS_ADJUST, - O_ANIM_ACTION_FRAME, - O_REG_ANIM_PLAY_SFX, - O_CRITTER_MOD_SKILL, - O_SFX_BUILD_CHAR_NAME, - O_SFX_BUILD_AMBIENT_NAME, - O_SFX_BUILD_INTERFACE_NAME, - O_SFX_BUILD_ITEM_NAME, - O_SFX_BUILD_WEAPON_NAME, - O_SFX_BUILD_SCENERY_NAME, - O_ATTACK_SETUP, - O_DESTROY_MULT_OBJS, - O_USE_OBJ_ON_OBJ, - O_ENDGAME_SLIDESHOW, - O_MOVE_OBJ_INVEN_TO_OBJ, - O_ENDGAME_MOVIE, - O_OBJ_ART_FID, - O_ART_ANIM, - O_PARTY_MEMBER_OBJ, - O_ROTATION_TO_TILE, - O_JAM_LOCK, - O_GDIALOG_SET_BARTER_MOD, - O_COMBAT_DIFFICULTY, - O_OBJ_ON_SCREEN, - O_CRITTER_IS_FLEEING, - O_CRITTER_SET_FLEE_STATE, - O_TERMINATE_COMBAT, - O_DEBUG_MSG, - O_CRITTER_STOP_ATTACKING, + enum O_Extra { + // define any user-specific opcodes here, starting at O_END_LIB + // ending with O_END_OP + O_GIVE_EXP_POINTS = O_END_LIB, + O_SCR_RETURN, + O_PLAY_SFX, + O_OBJ_NAME, + O_SFX_BUILD_OPEN_NAME, + O_GET_PC_STAT, + O_TILE_CONTAINS_PID_OBJ, + O_SET_MAP_START, + O_OVERRIDE_MAP_START, + O_HAS_SKILL, + O_USING_SKILL, + O_ROLL_VS_SKILL, + O_SKILL_CONTEST, + O_DO_CHECK, + O_IS_SUCCESS, + O_IS_CRITICAL, + O_HOW_MUCH, + O_MARK_AREA_KNOWN, + O_REACTION_INFLUENCE, + O_RANDOM, + O_ROLL_DICE, + O_MOVE_TO, + O_CREATE_OBJECT_SID, + O_DISPLAY_MSG, + O_SCRIPT_OVERRIDES, + O_OBJ_IS_CARRYING_OBJ_PID, + O_TILE_CONTAINS_OBJ_PID, + O_SELF_OBJ, + O_SOURCE_OBJ, + O_TARGET_OBJ, + O_DUDE_OBJ, + O_OBJ_BEING_USED_WITH, + O_LOCAL_VAR, + O_SET_LOCAL_VAR, + O_MAP_VAR, + O_SET_MAP_VAR, + O_GLOBAL_VAR, + O_SET_GLOBAL_VAR, + O_SCRIPT_ACTION, + O_OBJ_TYPE, + O_OBJ_ITEM_SUBTYPE, + O_GET_CRITTER_STAT, + O_SET_CRITTER_STAT, + O_ANIMATE_STAND_OBJ, + O_ANIMATE_STAND_REVERSE_OBJ, + O_ANIMATE_MOVE_OBJ_TO_TILE, + O_TILE_IN_TILE_RECT, + O_ATTACK_COMPLEX, + O_MAKE_DAYTIME, + O_TILE_DISTANCE, + O_TILE_DISTANCE_OBJS, + O_TILE_NUM, + O_TILE_NUM_IN_DIRECTION, + O_PICKUP_OBJ, + O_DROP_OBJ, + O_ADD_OBJ_TO_INVEN, + O_RM_OBJ_FROM_INVEN, + O_WIELD_OBJ_CRITTER, + O_USE_OBJ, + O_OBJ_CAN_SEE_OBJ, + O_ATTACK, + O_START_GDIALOG, + O_END_DIALOGUE, + O_DIALOGUE_REACTION, + O_METARULE3, + O_SET_MAP_MUSIC, + O_SET_OBJ_VISIBILITY, + O_LOAD_MAP, + O_WM_AREA_SET_POS, + O_SET_EXIT_GRIDS, + O_ANIM_BUSY, + O_CRITTER_HEAL, + O_SET_LIGHT_LEVEL, + O_GAME_TIME, + O_GAME_TIME_IN_SECONDS, + O_ELEVATION, + O_KILL_CRITTER, + O_KILL_CRITTER_TYPE, + O_CRITTER_DMG, + O_ADD_TIMER_EVENT, + O_RM_TIMER_EVENT, + O_GAME_TICKS, + O_HAS_TRAIT, + O_DESTROY_OBJECT, + O_OBJ_CAN_HEAR_OBJ, + O_GAME_TIME_HOUR, + O_FIXED_PARAM, + O_TILE_IS_VISIBLE, + O_DIALOGUE_SYSTEM_ENTER, + O_ACTION_BEING_USED, + O_CRITTER_STATE, + O_GAME_TIME_ADVANCE, + O_RADIATION_INC, + O_RADIATION_DEC, + O_CRITTER_ATTEMPT_PLACEMENT, + O_OBJ_PID, + O_CUR_MAP_INDEX, + O_CRITTER_ADD_TRAIT, + O_CRITTER_RM_TRAIT, + O_PROTO_DATA, + O_MESSAGE_STR, + O_CRITTER_INVEN_OBJ, + O_OBJ_SET_LIGHT_LEVEL, + O_WORLD_MAP, + O_INVEN_CMDS, + O_FLOAT_MSG, + O_METARULE, + O_ANIM, + O_OBJ_CARRYING_PID_OBJ, + O_REG_ANIM_FUNC, + O_REG_ANIM_ANIMATE, + O_REG_ANIM_ANIMATE_REVERSE, + O_REG_ANIM_OBJ_MOVE_TO_OBJ, + O_REG_ANIM_OBJ_RUN_TO_OBJ, + O_REG_ANIM_OBJ_MOVE_TO_TILE, + O_REG_ANIM_OBJ_RUN_TO_TILE, + O_PLAY_GMOVIE, + O_ADD_MULT_OBJS_TO_INVEN, + O_RM_MULT_OBJS_FROM_INVEN, + O_GET_MONTH, + O_GET_DAY, + O_EXPLOSION, + O_DAYS_SINCE_VISITED, + O_GSAY_START, + O_GSAY_END, + O_GSAY_REPLY, + O_GSAY_OPTION, + O_GSAY_MESSAGE, + O_GIQ_OPTION, + O_POISON, + O_GET_POISON, + O_PARTY_ADD, + O_PARTY_REMOVE, + O_REG_ANIM_ANIMATE_FOREVER, + O_CRITTER_INJURE, + O_COMBAT_IS_INITIALIZED, + O_GDIALOG_MOD_BARTER, + O_DIFFICULTY_LEVEL, + O_RUNNING_BURNING_GUY, + O_INVEN_UNWIELD, + O_OBJ_IS_LOCKED, + O_OBJ_LOCK, + O_OBJ_UNLOCK, + O_OBJ_IS_OPEN, + O_OBJ_OPEN, + O_OBJ_CLOSE, + O_GAME_UI_DISABLE, + O_GAME_UI_ENABLE, + O_GAME_UI_IS_DISABLED, + O_GFADE_OUT, + O_GFADE_IN, + O_ITEM_CAPS_TOTAL, + O_ITEM_CAPS_ADJUST, + O_ANIM_ACTION_FRAME, + O_REG_ANIM_PLAY_SFX, + O_CRITTER_MOD_SKILL, + O_SFX_BUILD_CHAR_NAME, + O_SFX_BUILD_AMBIENT_NAME, + O_SFX_BUILD_INTERFACE_NAME, + O_SFX_BUILD_ITEM_NAME, + O_SFX_BUILD_WEAPON_NAME, + O_SFX_BUILD_SCENERY_NAME, + O_ATTACK_SETUP, + O_DESTROY_MULT_OBJS, + O_USE_OBJ_ON_OBJ, + O_ENDGAME_SLIDESHOW, + O_MOVE_OBJ_INVEN_TO_OBJ, + O_ENDGAME_MOVIE, + O_OBJ_ART_FID, + O_ART_ANIM, + O_PARTY_MEMBER_OBJ, + O_ROTATION_TO_TILE, + O_JAM_LOCK, + O_GDIALOG_SET_BARTER_MOD, + O_COMBAT_DIFFICULTY, + O_OBJ_ON_SCREEN, + O_CRITTER_IS_FLEEING, + O_CRITTER_SET_FLEE_STATE, + O_TERMINATE_COMBAT, + O_DEBUG_MSG, + O_CRITTER_STOP_ATTACKING, //sfall start - O_READ_BYTE, - O_READ_SHORT, - O_READ_INT, - O_READ_STRING, - O_SET_PC_BASE_STAT, - O_SET_PC_EXTRA_STAT, - O_GET_PC_BASE_STAT, - O_GET_PC_EXTRA_STAT, - O_SET_CRITTER_BASE_STAT, - O_SET_CRITTER_EXTRA_STAT, - O_GET_CRITTER_BASE_STAT, - O_GET_CRITTER_EXTRA_STAT, - O_TAP_KEY, - O_GET_YEAR, - O_GAME_LOADED, - O_GRAPHICS_FUNCS_AVAILABLE, - O_LOAD_SHADER, - O_FREE_SHADER, - O_ACTIVATE_SHADER, - O_DEACTIVATE_SHADER, - O_SET_GLOBAL_SCRIPT_REPEAT, - O_INPUT_FUNCS_AVAILABLE, - O_KEY_PRESSED, + O_READ_BYTE, + O_READ_SHORT, + O_READ_INT, + O_READ_STRING, + O_SET_PC_BASE_STAT, + O_SET_PC_EXTRA_STAT, + O_GET_PC_BASE_STAT, + O_GET_PC_EXTRA_STAT, + O_SET_CRITTER_BASE_STAT, + O_SET_CRITTER_EXTRA_STAT, + O_GET_CRITTER_BASE_STAT, + O_GET_CRITTER_EXTRA_STAT, + O_TAP_KEY, + O_GET_YEAR, + O_GAME_LOADED, + O_GRAPHICS_FUNCS_AVAILABLE, + O_LOAD_SHADER, + O_FREE_SHADER, + O_ACTIVATE_SHADER, + O_DEACTIVATE_SHADER, + O_SET_GLOBAL_SCRIPT_REPEAT, + O_INPUT_FUNCS_AVAILABLE, + O_KEY_PRESSED, - O_SET_SHADER_INT, - O_SET_SHADER_FLOAT, - O_SET_SHADER_VECTOR, - O_IN_WORLD_MAP, - O_FORCE_ENCOUNTER, - O_SET_WORLD_MAP_POS, - O_GET_WORLD_MAP_X_POS, - O_GET_WORLD_MAP_Y_POS, + O_SET_SHADER_INT, + O_SET_SHADER_FLOAT, + O_SET_SHADER_VECTOR, + O_IN_WORLD_MAP, + O_FORCE_ENCOUNTER, + O_SET_WORLD_MAP_POS, + O_GET_WORLD_MAP_X_POS, + O_GET_WORLD_MAP_Y_POS, - O_SET_DM_MODEL, - O_SET_DF_MODEL, - O_SET_MOVIE_PATH, + O_SET_DM_MODEL, + O_SET_DF_MODEL, + O_SET_MOVIE_PATH, - O_SET_PERK_IMAGE, - O_SET_PERK_RANKS, - O_SET_PERK_LEVEL, - O_SET_PERK_STAT, - O_SET_PERK_STAT_MAG, - O_SET_PERK_SKILL1, - O_SET_PERK_SKILl1_MAG, - O_SET_PERK_TYPE, - O_SET_PERK_SKILL2, - O_SET_PERK_SKILL2_MAG, - O_SET_PERK_STR, - O_SET_PERK_PER, - O_SET_PERK_END, - O_SET_PERK_CHR, - O_SET_PERK_INT, - O_SET_PERK_AGL, - O_SET_PERK_LCK, - O_SET_PERK_NAME, - O_SET_PERK_DESC, + O_SET_PERK_IMAGE, + O_SET_PERK_RANKS, + O_SET_PERK_LEVEL, + O_SET_PERK_STAT, + O_SET_PERK_STAT_MAG, + O_SET_PERK_SKILL1, + O_SET_PERK_SKILl1_MAG, + O_SET_PERK_TYPE, + O_SET_PERK_SKILL2, + O_SET_PERK_SKILL2_MAG, + O_SET_PERK_STR, + O_SET_PERK_PER, + O_SET_PERK_END, + O_SET_PERK_CHR, + O_SET_PERK_INT, + O_SET_PERK_AGL, + O_SET_PERK_LCK, + O_SET_PERK_NAME, + O_SET_PERK_DESC, - O_SET_PIPBOY_AVAILABLE, + O_SET_PIPBOY_AVAILABLE, - O_GET_KILL_COUNTER, - O_MOD_KILL_COUNTER, + O_GET_KILL_COUNTER, + O_MOD_KILL_COUNTER, - O_GET_PERK_OWED, - O_SET_PERK_OWED, - O_GET_PERK_AVAILABLE, + O_GET_PERK_OWED, + O_SET_PERK_OWED, + O_GET_PERK_AVAILABLE, - O_GET_CRITTER_AP, - O_SET_CRITTER_AP, + O_GET_CRITTER_AP, + O_SET_CRITTER_AP, - O_GET_ACTIVE_HAND, - O_TOGGLE_ACTIVE_HAND, + O_GET_ACTIVE_HAND, + O_TOGGLE_ACTIVE_HAND, - O_SET_WEAPON_KNOCKBACK, - O_SET_TARGET_KNOCKBACK, - O_SET_ATTACKER_KNOCKBACK, - O_REMOVE_WEAPON_KNOCKBACK, - O_REMOVE_TARGET_KNOCKBACK, - O_REMOVE_ATTACKER_KNOCKBACK, + O_SET_WEAPON_KNOCKBACK, + O_SET_TARGET_KNOCKBACK, + O_SET_ATTACKER_KNOCKBACK, + O_REMOVE_WEAPON_KNOCKBACK, + O_REMOVE_TARGET_KNOCKBACK, + O_REMOVE_ATTACKER_KNOCKBACK, - O_SET_GLOBAL_SCRIPT_TYPE, - O_AVAILABLE_GLOBAL_SCRIPT_TYPES, + O_SET_GLOBAL_SCRIPT_TYPE, + O_AVAILABLE_GLOBAL_SCRIPT_TYPES, - O_SET_SFALL_GLOBAL, - O_GET_SFALL_GLOBAL_INT, - O_GET_SFALL_GLOBAL_FLOAT, + O_SET_SFALL_GLOBAL, + O_GET_SFALL_GLOBAL_INT, + O_GET_SFALL_GLOBAL_FLOAT, - O_SET_PICKPOCKET_MAX, - O_SET_HIT_CHANCE_MAX, - O_SET_SKILL_MAX, + O_SET_PICKPOCKET_MAX, + O_SET_HIT_CHANCE_MAX, + O_SET_SKILL_MAX, - O_EAX_AVAILABLE, - O_SET_EAX_ENVIRONMENT, + O_EAX_AVAILABLE, + O_SET_EAX_ENVIRONMENT, - O_INC_NPC_LEVEL, + O_INC_NPC_LEVEL, - O_GET_VIEWPORT_X, - O_GET_VIEWPORT_Y, - O_SET_VIEWPORT_X, - O_SET_VIEWPORT_Y, + O_GET_VIEWPORT_X, + O_GET_VIEWPORT_Y, + O_SET_VIEWPORT_X, + O_SET_VIEWPORT_Y, - O_SET_XP_MOD, - O_SET_PERK_LEVEL_MOD, + O_SET_XP_MOD, + O_SET_PERK_LEVEL_MOD, - O_GET_INI_SETTING, + O_GET_INI_SETTING, - O_GET_SHADER_VERSION, - O_SET_SHADER_MODE, + O_GET_SHADER_VERSION, + O_SET_SHADER_MODE, - O_GET_GAME_MODE, + O_GET_GAME_MODE, - O_FORCE_GRAPHICS_REFRESH, - O_GET_SHADER_TEXTURE, - O_SET_SHADER_TEXTURE, + O_FORCE_GRAPHICS_REFRESH, + O_GET_SHADER_TEXTURE, + O_SET_SHADER_TEXTURE, - O_GET_UPTIME, + O_GET_UPTIME, - O_SET_STAT_MAX, - O_SET_STAT_MIN, + O_SET_STAT_MAX, + O_SET_STAT_MIN, - O_SET_CAR_CURRENT_TOWN, + O_SET_CAR_CURRENT_TOWN, - O_SET_PC_STAT_MAX, - O_SET_PC_STAT_MIN, - O_SET_NPC_STAT_MAX, - O_SET_NPC_STAT_MIN, + O_SET_PC_STAT_MAX, + O_SET_PC_STAT_MIN, + O_SET_NPC_STAT_MAX, + O_SET_NPC_STAT_MIN, - O_SET_FAKE_PERK, - O_SET_FAKE_TRAIT, - O_SET_SELECTABLE_PERK, - O_SET_PERKBOX_TITLE, - O_HIDE_REAL_PERKS, - O_SHOW_REAL_PERKS, - O_HAS_FAKE_PERK, - O_HAS_FAKE_TRAIT, - O_PERK_ADD_MODE, - O_CLEAR_SELECTABLE_PERKS, + O_SET_FAKE_PERK, + O_SET_FAKE_TRAIT, + O_SET_SELECTABLE_PERK, + O_SET_PERKBOX_TITLE, + O_HIDE_REAL_PERKS, + O_SHOW_REAL_PERKS, + O_HAS_FAKE_PERK, + O_HAS_FAKE_TRAIT, + O_PERK_ADD_MODE, + O_CLEAR_SELECTABLE_PERKS, - O_SET_CRITTER_HIT_CHANCE_MOD, - O_SET_BASE_HIT_CHANCE_MOD, - O_SET_CRITTER_SKILL_MOD, - O_SET_BASE_SKILL_MOD, - O_SET_CRITTER_PICKPOCKET_MOD, - O_SET_BASE_PICKPOCKET_MOD, + O_SET_CRITTER_HIT_CHANCE_MOD, + O_SET_BASE_HIT_CHANCE_MOD, + O_SET_CRITTER_SKILL_MOD, + O_SET_BASE_SKILL_MOD, + O_SET_CRITTER_PICKPOCKET_MOD, + O_SET_BASE_PICKPOCKET_MOD, - O_SET_PYROMANIAC_MOD, - O_APPLY_HEAVEHO_FIX, - O_SET_SWIFTLEARNER_MOD, - O_SET_HP_LEVEL_MOD, + O_SET_PYROMANIAC_MOD, + O_APPLY_HEAVEHO_FIX, + O_SET_SWIFTLEARNER_MOD, + O_SET_HP_LEVEL_MOD, - O_WRITE_BYTE, - O_WRITE_SHORT, - O_WRITE_INT, + O_WRITE_BYTE, + O_WRITE_SHORT, + O_WRITE_INT, - O_CALL_OFFSET_V0, - O_CALL_OFFSET_V1, - O_CALL_OFFSET_V2, - O_CALL_OFFSET_V3, - O_CALL_OFFSET_V4, - O_CALL_OFFSET_R0, - O_CALL_OFFSET_R1, - O_CALL_OFFSET_R2, - O_CALL_OFFSET_R3, - O_CALL_OFFSET_R4, + O_CALL_OFFSET_V0, + O_CALL_OFFSET_V1, + O_CALL_OFFSET_V2, + O_CALL_OFFSET_V3, + O_CALL_OFFSET_V4, + O_CALL_OFFSET_R0, + O_CALL_OFFSET_R1, + O_CALL_OFFSET_R2, + O_CALL_OFFSET_R3, + O_CALL_OFFSET_R4, - O_SHOW_IFACE_TAG, - O_HIDE_IFACE_TAG, - O_IS_IFACE_TAG_ACTIVE, - O_GET_BODYPART_HIT_MODIFIER, - O_SET_BODYPART_HIT_MODIFIER, + O_SHOW_IFACE_TAG, + O_HIDE_IFACE_TAG, + O_IS_IFACE_TAG_ACTIVE, + O_GET_BODYPART_HIT_MODIFIER, + O_SET_BODYPART_HIT_MODIFIER, - O_SET_CRITICAL_TABLE, - O_GET_CRITICAL_TABLE, - O_RESET_CRITICAL_TABLE, - O_GET_SFALL_ARG, - O_SET_SFALL_RETURN, - O_SET_UNSPENT_AP_BONUS, - O_GET_UNSPENT_AP_BONUS, - O_SET_UNSPENT_AP_PERK_BONUS, - O_GET_UNSPENT_AP_PERK_BONUS, - O_INIT_HOOK, - O_GET_INI_STRING, + O_SET_CRITICAL_TABLE, + O_GET_CRITICAL_TABLE, + O_RESET_CRITICAL_TABLE, + O_GET_SFALL_ARG, + O_SET_SFALL_RETURN, + O_SET_UNSPENT_AP_BONUS, + O_GET_UNSPENT_AP_BONUS, + O_SET_UNSPENT_AP_PERK_BONUS, + O_GET_UNSPENT_AP_PERK_BONUS, + O_INIT_HOOK, + O_GET_INI_STRING, - O_SQRT, - O_ABS, - O_SIN, - O_COS, - O_TAN, - O_ARCTAN, - O_SET_PALETTE, + O_SQRT, + O_ABS, + O_SIN, + O_COS, + O_TAN, + O_ARCTAN, + O_SET_PALETTE, - O_REMOVE_SCRIPT, - O_SET_SCRIPT, - O_GET_SCRIPT, - O_NB_CREATE_CHAR, - O_FS_CREATE, - O_FS_COPY, - O_FS_FIND, - O_FS_WRITE_BYTE, - O_FS_WRITE_SHORT, - O_FS_WRITE_INT, - O_FS_WRITE_FLOAT, - O_FS_WRITE_STRING, - O_FS_DELETE, - O_FS_SIZE, - O_FS_POS, - O_FS_SEEK, - O_FS_RESIZE, - O_GET_PROTO_DATA, + O_REMOVE_SCRIPT, + O_SET_SCRIPT, + O_GET_SCRIPT, + O_NB_CREATE_CHAR, + O_FS_CREATE, + O_FS_COPY, + O_FS_FIND, + O_FS_WRITE_BYTE, + O_FS_WRITE_SHORT, + O_FS_WRITE_INT, + O_FS_WRITE_FLOAT, + O_FS_WRITE_STRING, + O_FS_DELETE, + O_FS_SIZE, + O_FS_POS, + O_FS_SEEK, + O_FS_RESIZE, + O_GET_PROTO_DATA, - O_SET_PROTO_DATA, - O_SET_SELF, - O_REGISTER_HOOK, - O_FS_WRITE_BSTRING, - O_FS_READ_BYTE, - O_FS_READ_SHORT, - O_FS_READ_INT, - O_FS_READ_FLOAT, - O_LIST_BEGIN, - O_LIST_NEXT, - O_LIST_END, + O_SET_PROTO_DATA, + O_SET_SELF, + O_REGISTER_HOOK, + O_FS_WRITE_BSTRING, + O_FS_READ_BYTE, + O_FS_READ_SHORT, + O_FS_READ_INT, + O_FS_READ_FLOAT, + O_LIST_BEGIN, + O_LIST_NEXT, + O_LIST_END, - O_SFALL_VER_MAJOR, - O_SFALL_VER_MINOR, - O_SFALL_VER_BUILD, + O_SFALL_VER_MAJOR, + O_SFALL_VER_MINOR, + O_SFALL_VER_BUILD, - O_HERO_SELECT_WIN, - O_SET_HERO_RACE, - O_SET_HERO_STYLE, + O_HERO_SELECT_WIN, + O_SET_HERO_RACE, + O_SET_HERO_STYLE, - O_SET_CRITTER_BURST_DISABLE, + O_SET_CRITTER_BURST_DISABLE, - O_GET_WEAPON_AMMO_PID, - O_SET_WEAPON_AMMO_PID, - O_GET_WEAPON_AMMO_COUNT, - O_SET_WEAPON_AMMO_COUNT, - O_WRITE_STRING, - O_GET_MOUSE_X, - O_GET_MOUSE_Y, - O_GET_MOUSE_BUTTONS, - O_GET_WINDOW_UNDER_MOUSE, - O_GET_SCREEN_WIDTH, - O_GET_SCREEN_HEIGHT, - O_STOP_GAME, - O_RESUME_GAME, - O_CREATE_MESSAGE_WINDOW, - O_REMOVE_TRAIT, - O_GET_LIGHT_LEVEL, - O_REFRESH_PC_ART, - O_GET_ATTACK_TYPE, - O_FORCE_ENCOUNTER_WITH_FLAGS, - O_SET_MAP_TIME_MULTI, - O_PLAY_SFALL_SOUND, - O_STOP_SFALL_SOUND, - O_CREATE_ARRAY, - O_SET_ARRAY, - O_GET_ARRAY, - O_FREE_ARRAY, + O_GET_WEAPON_AMMO_PID, + O_SET_WEAPON_AMMO_PID, + O_GET_WEAPON_AMMO_COUNT, + O_SET_WEAPON_AMMO_COUNT, + O_WRITE_STRING, + O_GET_MOUSE_X, + O_GET_MOUSE_Y, + O_GET_MOUSE_BUTTONS, + O_GET_WINDOW_UNDER_MOUSE, + O_GET_SCREEN_WIDTH, + O_GET_SCREEN_HEIGHT, + O_STOP_GAME, + O_RESUME_GAME, + O_CREATE_MESSAGE_WINDOW, + O_REMOVE_TRAIT, + O_GET_LIGHT_LEVEL, + O_REFRESH_PC_ART, + O_GET_ATTACK_TYPE, + O_FORCE_ENCOUNTER_WITH_FLAGS, + O_SET_MAP_TIME_MULTI, + O_PLAY_SFALL_SOUND, + O_STOP_SFALL_SOUND, + O_CREATE_ARRAY, + O_SET_ARRAY, + O_GET_ARRAY, + O_FREE_ARRAY, - O_TS_LEN_ARRAY, - O_TS_RESIZE_ARRAY, - O_TS_TEMP_ARRAY, - O_TS_FIX_ARRAY, + O_TS_LEN_ARRAY, + O_TS_RESIZE_ARRAY, + O_TS_TEMP_ARRAY, + O_TS_FIX_ARRAY, - O_TS_STRING_SPLIT, + O_TS_STRING_SPLIT, - O_TS_LIST_AS_ARRAY, + O_TS_LIST_AS_ARRAY, - O_TS_ATOI, - O_TS_ATOF, + O_TS_ATOI, + O_TS_ATOF, - O_TS_SCAN_ARRAY, + O_TS_SCAN_ARRAY, - O_TS_TILE_PID, + O_TS_TILE_PID, - O_TS_MODIFIED_INI, + O_TS_MODIFIED_INI, - O_TS_GET_SFALL_ARGS, + O_TS_GET_SFALL_ARGS, - O_TS_SET_SFALL_ARG, + O_TS_SET_SFALL_ARG, - O_TS_FORCE_AIMED_SHOTS, - O_TS_DISABLE_AIMED_SHOTS, + O_TS_FORCE_AIMED_SHOTS, + O_TS_DISABLE_AIMED_SHOTS, - O_TS_MARK_MOVIE_PLAYED, + O_TS_MARK_MOVIE_PLAYED, - O_TS_GET_NPC_LEVEL, + O_TS_GET_NPC_LEVEL, - O_TS_SET_CRITTER_SKILL_POINTS, - O_TS_GET_CRITTER_SKILL_POINTS, - O_TS_SET_AVAILABLE_SKILL_POINTS, - O_TS_GET_AVAILABLE_SKILL_POINTS, - O_TS_MOD_SKILL_POINTS_PER_LEVEL, - O_TS_SET_PERK_FREQ, + O_TS_SET_CRITTER_SKILL_POINTS, + O_TS_GET_CRITTER_SKILL_POINTS, + O_TS_SET_AVAILABLE_SKILL_POINTS, + O_TS_GET_AVAILABLE_SKILL_POINTS, + O_TS_MOD_SKILL_POINTS_PER_LEVEL, + O_TS_SET_PERK_FREQ, - O_TS_GET_LAST_ATTACKER, - O_TS_GET_LAST_TARGET, - O_TS_BLOCK_COMBAT, + O_TS_GET_LAST_ATTACKER, + O_TS_GET_LAST_TARGET, + O_TS_BLOCK_COMBAT, - O_TS_TILE_UNDER_CURSOR, - O_TS_GET_BARTER_MOD, - O_TS_SET_INVEN_AP_COST, + O_TS_TILE_UNDER_CURSOR, + O_TS_GET_BARTER_MOD, + O_TS_SET_INVEN_AP_COST, - O_TS_SUBSTR, - O_TS_STRLEN, - O_TS_SPRINTF, - O_TS_ORD, - O_TS_RESERVD2, - O_TS_TYPEOF, + O_TS_SUBSTR, + O_TS_STRLEN, + O_TS_SPRINTF, + O_TS_ORD, + O_TS_RESERVD2, + O_TS_TYPEOF, - O_TS_SAVE_ARRAY, - O_TS_LOAD_ARRAY, - O_TS_GET_ARRAY_KEY, - O_TS_STACK_ARRAY, + O_TS_SAVE_ARRAY, + O_TS_LOAD_ARRAY, + O_TS_GET_ARRAY_KEY, + O_TS_STACK_ARRAY, - O_TS_RESERVD3, - O_TS_RESERVD4, + O_TS_RESERVD3, + O_TS_RESERVD4, - O_TS_REG_ANIM_DESTROY, - O_TS_REG_ANIM_ANIMATE_AND_HIDE, - O_TS_REG_ANIM_COMBAT_CHECK, - O_TS_REG_ANIM_LIGHT, - O_TS_REG_ANIM_CHANGE_FID, - O_TS_REG_ANIM_TAKE_OUT, - O_TS_REG_ANIM_TURN_TOWARDS, + O_TS_REG_ANIM_DESTROY, + O_TS_REG_ANIM_ANIMATE_AND_HIDE, + O_TS_REG_ANIM_COMBAT_CHECK, + O_TS_REG_ANIM_LIGHT, + O_TS_REG_ANIM_CHANGE_FID, + O_TS_REG_ANIM_TAKE_OUT, + O_TS_REG_ANIM_TURN_TOWARDS, - O_TS_EXPLOSIONS_METARULE, - O_TS_REGISTER_HOOK_PROC, - - O_TS_POW, - O_TS_LOG, - O_TS_EXP, - O_TS_CEIL, - O_TS_ROUND, + O_TS_EXPLOSIONS_METARULE, + O_TS_REGISTER_HOOK_PROC, + + O_TS_POW, + O_TS_LOG, + O_TS_EXP, + O_TS_CEIL, + O_TS_ROUND, - O_TS_RESERVD5, - O_TS_RESERVD6, - O_TS_RESERVD7, + O_TS_RESERVD5, + O_TS_RESERVD6, + O_TS_RESERVD7, - O_TS_MESSAGE_STR_GAME, - O_TS_SNEAK_SUCCESS, - O_TS_TILE_LIGHT, + O_TS_MESSAGE_STR_GAME, + O_TS_SNEAK_SUCCESS, + O_TS_TILE_LIGHT, - O_TS_MAKE_STRAIGHT_PATH, - O_TS_OBJ_BLOCKING_AT, - O_TS_TILE_GET_OBJECTS, - O_TS_GET_PARTY_MEMBERS, - O_TS_PATH_FIND, - O_TS_CREATE_SPATIAL, - O_TS_ART_EXISTS, - O_TS_OBJ_IS_CARRYING_OBJ, + O_TS_MAKE_STRAIGHT_PATH, + O_TS_OBJ_BLOCKING_AT, + O_TS_TILE_GET_OBJECTS, + O_TS_GET_PARTY_MEMBERS, + O_TS_PATH_FIND, + O_TS_CREATE_SPATIAL, + O_TS_ART_EXISTS, + O_TS_OBJ_IS_CARRYING_OBJ, //sfall end - O_END_OP - }; + O_END_OP + }; - enum O_DataType { - O_STRINGOP = (O_CONST | O_STRING), // 0x9001 - O_FLOATOP = (O_CONST | O_FLOAT), // 0xA001 - O_INTOP = (O_CONST | O_INT) // 0xC001 - }; + enum O_DataType { + O_STRINGOP = (O_CONST | O_STRING), // 0x9001 + O_FLOATOP = (O_CONST | O_FLOAT), // 0xA001 + O_INTOP = (O_CONST | O_INT) // 0xC001 + }; - enum O_F1_Specific { - O_REACTION = 0x80B2, - O_ANIMATE_JUMP = 0x80CF, - O_TURN_OFF_OBJS_IN_AREA = 0x80E1, - O_TURN_ON_OBJS_IN_AREA = 0x80E2, - O_BARTER_OFFER = 0x80E5, - O_BARTER_ASKING = 0x80E6, - O_TOWN_MAP = 0x8109 - }; + enum O_F1_Specific { + O_REACTION = 0x80B2, + O_ANIMATE_JUMP = 0x80CF, + O_TURN_OFF_OBJS_IN_AREA = 0x80E1, + O_TURN_ON_OBJS_IN_AREA = 0x80E2, + O_BARTER_OFFER = 0x80E5, + O_BARTER_ASKING = 0x80E6, + O_TOWN_MAP = 0x8109 + }; - // COpcodeAttributes + // COpcodeAttributes class COpcodeAttributes { - public: - enum Type { - TYPE_STATEMENT, - TYPE_EXPRESSION - }; + public: + enum Type { + TYPE_STATEMENT, + TYPE_EXPRESSION + }; - enum Category { - CATEGORY_PREFIX, - CATEGORY_INFIX - }; + enum Category { + CATEGORY_PREFIX, + CATEGORY_INFIX + }; - public: + public: COpcodeAttributes(std::string mnemonic = "", std::string name = "", ULONG ulNumArgs = 0, @@ -785,57 +785,57 @@ public: Category category = CATEGORY_PREFIX, ULONG* procArgs = NULL, ULONG numProcArgs = 0); - COpcodeAttributes(const COpcodeAttributes& attributes); - COpcodeAttributes& operator = (const COpcodeAttributes& attributes); - void InitAttributes(); + COpcodeAttributes(const COpcodeAttributes& attributes); + COpcodeAttributes& operator = (const COpcodeAttributes& attributes); + void InitAttributes(); - public: - CString m_strMnemonic; - CString m_strName; - ULONG m_ulNumArgs; - Type m_Type; - Category m_Category; - ULONG *m_procArgs; - ULONG m_numProcArgs; - }; + public: + CString m_strMnemonic; + CString m_strName; + ULONG m_ulNumArgs; + Type m_Type; + Category m_Category; + ULONG *m_procArgs; + ULONG m_numProcArgs; + }; - // CF2OpcodeAttributesMap - class CF2OpcodeAttributesMap : public CMap { - public: - CF2OpcodeAttributesMap(); - }; + // CF2OpcodeAttributesMap + class CF2OpcodeAttributesMap : public CMap { + public: + CF2OpcodeAttributesMap(); + }; - // C12OpcodeAttributesMap - class CF1OpcodeAttributesMap : public CMap { - public: - CF1OpcodeAttributesMap(); - }; + // C12OpcodeAttributesMap + class CF1OpcodeAttributesMap : public CMap { + public: + CF1OpcodeAttributesMap(); + }; public: - COpcode(); - COpcode(const COpcode& opcode); - virtual ~COpcode(); + COpcode(); + COpcode(const COpcode& opcode); + virtual ~COpcode(); public: - COpcode& operator = (const COpcode& opcode); + COpcode& operator = (const COpcode& opcode); public: - virtual void Serialize(CArchive& ar); - void Expect(CArchive& ar, WORD wOperator, BOOL bArgumentFound = FALSE, ULONG ulArgument = 0); - void Expect(CArchive& ar, int nCount, WORD pwOperators[]); + virtual void Serialize(CArchive& ar); + void Expect(CArchive& ar, WORD wOperator, BOOL bArgumentFound = FALSE, ULONG ulArgument = 0); + void Expect(CArchive& ar, int nCount, WORD pwOperators[]); - BOOL HasArgument() const; - int GetSize() const; + BOOL HasArgument() const; + int GetSize() const; - WORD GetOperator() const; - void SetOperator(WORD op); - ULONG GetArgument() const; + WORD GetOperator() const; + void SetOperator(WORD op); + ULONG GetArgument() const; - const COpcodeAttributes GetAttributes() const; + const COpcodeAttributes GetAttributes() const; private: - WORD m_wOperator; - ULONG m_ulArgument; + WORD m_wOperator; + ULONG m_ulArgument; }; // COpcodeArray diff --git a/OpcodeAttributes.cpp b/OpcodeAttributes.cpp index e7c016a..d423aae 100644 --- a/OpcodeAttributes.cpp +++ b/OpcodeAttributes.cpp @@ -19,55 +19,55 @@ COpcode::COpcodeAttributes::COpcodeAttributes(std::string mnemonic, ULONG numProcArgs) : m_strMnemonic(mnemonic), m_strName(name), - m_ulNumArgs(ulNumArgs), - m_Type(type), - m_Category(category), - m_procArgs(procArgs), - m_numProcArgs(numProcArgs) + m_ulNumArgs(ulNumArgs), + m_Type(type), + m_Category(category), + m_procArgs(procArgs), + m_numProcArgs(numProcArgs) { } COpcode::COpcodeAttributes::COpcodeAttributes(const COpcodeAttributes& attributes) : - m_strMnemonic(attributes.m_strMnemonic), - m_strName(attributes.m_strName), - m_ulNumArgs(attributes.m_ulNumArgs), - m_Type(attributes.m_Type), - m_Category(attributes.m_Category), - m_procArgs(attributes.m_procArgs), - m_numProcArgs(attributes.m_numProcArgs) + m_strMnemonic(attributes.m_strMnemonic), + m_strName(attributes.m_strName), + m_ulNumArgs(attributes.m_ulNumArgs), + m_Type(attributes.m_Type), + m_Category(attributes.m_Category), + m_procArgs(attributes.m_procArgs), + m_numProcArgs(attributes.m_numProcArgs) { } COpcode::COpcodeAttributes& COpcode::COpcodeAttributes::operator = (const COpcodeAttributes& attributes) { - if (&attributes != this) { - m_strMnemonic = attributes.m_strMnemonic; - m_strName = attributes.m_strName; - m_ulNumArgs = attributes.m_ulNumArgs; - m_Type = attributes.m_Type; - m_Category = attributes.m_Category; - m_procArgs = attributes.m_procArgs; - m_numProcArgs = attributes.m_numProcArgs; - } + if (&attributes != this) { + m_strMnemonic = attributes.m_strMnemonic; + m_strName = attributes.m_strName; + m_ulNumArgs = attributes.m_ulNumArgs; + m_Type = attributes.m_Type; + m_Category = attributes.m_Category; + m_procArgs = attributes.m_procArgs; + m_numProcArgs = attributes.m_numProcArgs; + } - return (*this); + return (*this); } // COpcode::CF1OpcodeAttributesMap COpcode::CF1OpcodeAttributesMap::CF1OpcodeAttributesMap() { - COpcode::COpcodeAttributes::Type expression = COpcode::COpcodeAttributes::TYPE_EXPRESSION; - COpcode::COpcodeAttributes::Category infix = COpcode::COpcodeAttributes::CATEGORY_INFIX; + COpcode::COpcodeAttributes::Type expression = COpcode::COpcodeAttributes::TYPE_EXPRESSION; + COpcode::COpcodeAttributes::Category infix = COpcode::COpcodeAttributes::CATEGORY_INFIX; - InitHashTable(32); - - SetAt(O_REACTION, COpcodeAttributes("O_REACTION", "reaction", 3, expression)); - SetAt(O_ANIMATE_JUMP, COpcodeAttributes("O_ANIMATE_JUMP", "animate_jump", 0)); - SetAt(O_TURN_OFF_OBJS_IN_AREA, COpcodeAttributes("O_TURN_OFF_OBJS_IN_AREA", "turn_off_objs_in_area", 4)); - SetAt(O_TURN_ON_OBJS_IN_AREA, COpcodeAttributes("O_TURN_ON_OBJS_IN_AREA", "turn_on_objs_in_area", 4)); - SetAt(O_BARTER_OFFER, COpcodeAttributes("O_BARTER_OFFER", "barter_offer", 3)); - SetAt(O_BARTER_ASKING, COpcodeAttributes("O_BARTER_ASKING", "barter_asking", 3)); - SetAt(O_TOWN_MAP, COpcodeAttributes("O_TOWN_MAP", "town_map", 0)); + InitHashTable(32); + + SetAt(O_REACTION, COpcodeAttributes("O_REACTION", "reaction", 3, expression)); + SetAt(O_ANIMATE_JUMP, COpcodeAttributes("O_ANIMATE_JUMP", "animate_jump", 0)); + SetAt(O_TURN_OFF_OBJS_IN_AREA, COpcodeAttributes("O_TURN_OFF_OBJS_IN_AREA", "turn_off_objs_in_area", 4)); + SetAt(O_TURN_ON_OBJS_IN_AREA, COpcodeAttributes("O_TURN_ON_OBJS_IN_AREA", "turn_on_objs_in_area", 4)); + SetAt(O_BARTER_OFFER, COpcodeAttributes("O_BARTER_OFFER", "barter_offer", 3)); + SetAt(O_BARTER_ASKING, COpcodeAttributes("O_BARTER_ASKING", "barter_asking", 3)); + SetAt(O_TOWN_MAP, COpcodeAttributes("O_TOWN_MAP", "town_map", 0)); } ULONG procArgs_register_hook_proc[1] = {2}; @@ -75,719 +75,719 @@ ULONG procArgs_register_hook_proc[1] = {2}; // COpcode::CF2OpcodeAttributesMap COpcode::CF2OpcodeAttributesMap::CF2OpcodeAttributesMap() { - COpcode::COpcodeAttributes::Type expression = COpcode::COpcodeAttributes::TYPE_EXPRESSION; - COpcode::COpcodeAttributes::Category infix = COpcode::COpcodeAttributes::CATEGORY_INFIX; - - InitHashTable(512); - - SetAt(O_NOOP, COpcodeAttributes("O_NOOP", "/* O_NOOP */", 0)); - SetAt(O_CONST, COpcodeAttributes("O_CONST", "/* O_CONST */", 0)); - SetAt(O_CRITICAL_START, COpcodeAttributes("O_CRITICAL_START", "/* O_CRITICAL_START */", 0)); - SetAt(O_CRITICAL_DONE, COpcodeAttributes("O_CRITICAL_DONE", "/* O_CRITICAL_START */", 0)); - SetAt(O_JMP, COpcodeAttributes("O_JMP", "// O_JMP ", 1)); - SetAt(O_CALL, COpcodeAttributes("O_CALL", "/* O_CALL */", 0, expression)); - SetAt(O_CALL_AT, COpcodeAttributes("O_CALL_AT", "/* O_CALL_AT */", 2)); - SetAt(O_CALL_CONDITION, COpcodeAttributes("O_CALL_CONDITION", "/* O_CALL_CONDITION */", 2)); - SetAt(O_CALLSTART, COpcodeAttributes("O_CALLSTART", "callStart", 1)); - SetAt(O_EXEC, COpcodeAttributes("O_EXEC", "exec", 1)); - SetAt(O_SPAWN, COpcodeAttributes("O_SPAWN", "spawn", 1)); - SetAt(O_FORK, COpcodeAttributes("O_FORK", "fork", 1)); - SetAt(O_A_TO_D, COpcodeAttributes("O_A_TO_D", "/* O_A_TO_D */", 0)); - SetAt(O_D_TO_A, COpcodeAttributes("O_D_TO_A", "/* O_D_TO_A */", 0)); - SetAt(O_EXIT, COpcodeAttributes("O_EXIT", "exit", 0)); - SetAt(O_DETACH, COpcodeAttributes("O_DETACH", "detach", 0)); - SetAt(O_EXIT_PROG, COpcodeAttributes("O_EXIT_PROG", "/* O_EXIT_PROG */", 0)); - SetAt(O_STOP_PROG, COpcodeAttributes("O_STOP_PROG", "/* O_STOP_PROG */", 0)); - SetAt(O_FETCH_GLOBAL, COpcodeAttributes("O_FETCH_GLOBAL", "/* O_FETCH_GLOBAL */", 1, expression)); - SetAt(O_STORE_GLOBAL, COpcodeAttributes("O_STORE_GLOBAL", ":=", 2)); - SetAt(O_FETCH_EXTERNAL, COpcodeAttributes("O_FETCH_EXTERNAL", "/* O_FETCH_EXTERNAL */", 1, expression)); - SetAt(O_STORE_EXTERNAL, COpcodeAttributes("O_STORE_EXTERNAL", ":=", 2)); - SetAt(O_EXPORT_VAR, COpcodeAttributes("O_EXPORT_VAR", "/* O_EXPORT_VAR */", 0)); - SetAt(O_EXPORT_PROC, COpcodeAttributes("O_EXPORT_PROC", "/* O_EXPORT_PROC */", 0)); - SetAt(O_SWAP, COpcodeAttributes("O_SWAP", "/* O_SWAP */", 0)); - SetAt(O_SWAPA, COpcodeAttributes("O_SWAPA", "/* O_SWAPA */", 0)); - SetAt(O_POP, COpcodeAttributes("O_POP", "/* O_POP */", 1)); - SetAt(O_DUP, COpcodeAttributes("O_DUP", "/* O_DUP */", 0)); - SetAt(O_POP_RETURN, COpcodeAttributes("O_POP_RETURN", "return", 1)); - SetAt(O_POP_EXIT, COpcodeAttributes("O_POP_EXIT", "/* O_POP_EXIT */", 0)); - SetAt(O_POP_ADDRESS, COpcodeAttributes("O_POP_ADDRESS", "/* O_POP_ADDRESS */", 0)); - SetAt(O_POP_FLAGS, COpcodeAttributes("O_POP_FLAGS", "/* O_POP_FLAGS */", 0)); - SetAt(O_POP_FLAGS_RETURN, COpcodeAttributes("O_POP_FLAGS_RETURN", "/* O_POP_FLAGS_RETURN */", 0)); - SetAt(O_POP_FLAGS_EXIT, COpcodeAttributes("O_POP_FLAGS_EXIT", "/* O_POP_FLAGS_EXIT */", 0)); - SetAt(O_POP_FLAGS_RETURN_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_EXTERN", "/* O_POP_FLAGS_RETURN_EXTERN */", 0)); - SetAt(O_POP_FLAGS_EXIT_EXTERN, COpcodeAttributes("O_POP_FLAGS_EXIT_EXTERN", "/* O_POP_FLAGS_EXIT_EXTERN */", 0)); - SetAt(O_POP_FLAGS_RETURN_VAL_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXTERN", "/* O_POP_FLAGS_RETURN_VAL_EXTERN */", 0)); - SetAt(O_POP_FLAGS_RETURN_VAL_EXIT, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXIT", "/* O_POP_FLAGS_RETURN_VAL_EXIT */", 0)); - SetAt(O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN", "/* O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN */", 0)); - SetAt(O_CHECK_ARG_COUNT, COpcodeAttributes("O_CHECK_ARG_COUNT", "/* O_CHECK_ARG_COUNT */", 0)); - SetAt(O_LOOKUP_STRING_PROC, COpcodeAttributes("O_LOOKUP_STRING_PROC", "/* O_LOOKUP_STRING_PROC */", 1, expression)); - SetAt(O_POP_BASE, COpcodeAttributes("O_POP_BASE", "/* O_POP_BASE */", 0)); - SetAt(O_POP_TO_BASE, COpcodeAttributes("O_POP_TO_BASE", "/* O_POP_TO_BASE */", 0)); - SetAt(O_PUSH_BASE, COpcodeAttributes("O_PUSH_BASE", "/* O_PUSH_BASE */", 0)); - SetAt(O_SET_GLOBAL, COpcodeAttributes("O_SET_GLOBAL", "/* O_SET_GLOBAL */", 0)); - SetAt(O_FETCH_PROC_ADDRESS, COpcodeAttributes("O_FETCH_PROC_ADDRESS", "/* O_FETCH_PROC_ADDRESS */", 0)); - SetAt(O_DUMP, COpcodeAttributes("O_DUMP", "/* O_DUMP */", 0)); - SetAt(O_IF, COpcodeAttributes("O_IF", "if", 2)); - SetAt(O_WHILE, COpcodeAttributes("O_WHILE", "while", 2)); - SetAt(O_STORE, COpcodeAttributes("O_STORE", ":=", 2)); - SetAt(O_FETCH, COpcodeAttributes("O_FETCH", "/* O_FETCH */", 1, expression)); - SetAt(O_EQUAL, COpcodeAttributes("O_EQUAL", "==", 2, expression, infix)); - SetAt(O_NOT_EQUAL, COpcodeAttributes("O_NOT_EQUAL", "!=", 2, expression, infix)); - SetAt(O_LESS_EQUAL, COpcodeAttributes("O_LESS_EQUAL", "<=", 2, expression, infix)); - SetAt(O_GREATER_EQUAL, COpcodeAttributes("O_GREATER_EQUAL", ">=", 2, expression, infix)); - SetAt(O_LESS, COpcodeAttributes("O_LESS", "<", 2, expression, infix)); - SetAt(O_GREATER, COpcodeAttributes("O_GREATER", ">", 2, expression, infix)); - SetAt(O_ADD, COpcodeAttributes("O_ADD", "+", 2, expression, infix)); - SetAt(O_SUB, COpcodeAttributes("O_SUB", "-", 2, expression, infix)); - SetAt(O_MUL, COpcodeAttributes("O_MUL", "*", 2, expression, infix)); - SetAt(O_DIV, COpcodeAttributes("O_DIV", "/", 2, expression, infix)); - SetAt(O_MOD, COpcodeAttributes("O_MOD", "%", 2, expression, infix)); - SetAt(O_AND, COpcodeAttributes("O_AND", "and", 2, expression, infix)); - SetAt(O_OR, COpcodeAttributes("O_OR", "or", 2, expression, infix)); - SetAt(O_BWAND, COpcodeAttributes("O_BWAND", "bwand", 2, expression, infix)); - SetAt(O_BWOR, COpcodeAttributes("O_BWOR", "bwor", 2, expression, infix)); - SetAt(O_BWXOR, COpcodeAttributes("O_BWXOR", "bwxor", 2, expression, infix)); - SetAt(O_BWNOT, COpcodeAttributes("O_BWNOT", "bwnot", 1, expression)); - SetAt(O_FLOOR, COpcodeAttributes("O_FLOOR", "floor", 1, expression)); - SetAt(O_NOT, COpcodeAttributes("O_NOT", "not", 1, expression)); - SetAt(O_NEGATE, COpcodeAttributes("O_NEGATE", "-", 1, expression)); - SetAt(O_WAIT, COpcodeAttributes("O_WAIT", "wait", 1)); - SetAt(O_CANCEL, COpcodeAttributes("O_CANCEL", "cancel", 1)); - SetAt(O_CANCELALL, COpcodeAttributes("O_CANCELALL", "cancelAll", 0)); - SetAt(O_STARTCRITICAL, COpcodeAttributes("O_STARTCRITICAL", "startCritical", 0)); - SetAt(O_ENDCRITICAL, COpcodeAttributes("O_ENDCRITICAL", "endCritical", 0)); - SetAt(O_SAYQUIT, COpcodeAttributes("O_SAYQUIT", "sayQuit", 0)); - SetAt(O_SAYEND, COpcodeAttributes("O_SAYEND", "sayEnd", 0)); - SetAt(O_SAYSTART, COpcodeAttributes("O_SAYSTART", "sayStart", 0)); - SetAt(O_SAYSTARTPOS, COpcodeAttributes("O_SAYSTARTPOS", "sayStartPos", 1)); - SetAt(O_SAYREPLYTITLE, COpcodeAttributes("O_SAYREPLYTITLE", "sayReplyTitle", 1)); - SetAt(O_SAYGOTOREPLY, COpcodeAttributes("O_SAYGOTOREPLY", "sayGotoReply", 1)); - SetAt(O_SAYREPLY, COpcodeAttributes("O_SAYREPLY", "sayReply", 2)); - SetAt(O_SAYOPTION, COpcodeAttributes("O_SAYOPTION", "sayOption", 2)); - SetAt(O_SAYMESSAGE, COpcodeAttributes("O_SAYMESSAGE", "sayMessage", 2)); - SetAt(O_SAYREPLYWINDOW, COpcodeAttributes("O_SAYREPLYWINDOW", "sayReplyWindow", 5)); - SetAt(O_SAYOPTIONWINDOW, COpcodeAttributes("O_SAYOPTIONWINDOW", "sayOptionWindow", 5)); - SetAt(O_SAYBORDER, COpcodeAttributes("O_SAYBORDER", "sayBorder", 2)); - SetAt(O_SAYSCROLLUP, COpcodeAttributes("O_SAYSCROLLUP", "sayScrollUp", 6)); - SetAt(O_SAYSCROLLDOWN, COpcodeAttributes("O_SAYSCROLLDOWN", "sayScrollDown", 6)); - SetAt(O_SAYSETSPACING, COpcodeAttributes("O_SAYSETSPACING", "saySetSpacing", 1)); - SetAt(O_SAYOPTIONCOLOR, COpcodeAttributes("O_SAYOPTIONCOLOR", "sayOptionColor", 3)); - SetAt(O_SAYREPLYCOLOR, COpcodeAttributes("O_SAYREPLYCOLOR", "sayReplyColor", 3)); - SetAt(O_SAYRESTART, COpcodeAttributes("O_SAYRESTART", "sayRestart", 0)); - SetAt(O_SAYGETLASTPOS, COpcodeAttributes("O_SAYGETLASTPOS", "sayGetLastPos", 0, expression)); - SetAt(O_SAYREPLYFLAGS, COpcodeAttributes("O_SAYREPLYFLAGS", "sayReplyFlags", 1)); - SetAt(O_SAYOPTIONFLAGS, COpcodeAttributes("O_SAYOPTIONFLAGS", "sayOptionFlags", 1)); - SetAt(O_SAYMESSAGETIMEOUT, COpcodeAttributes("O_SAYMESSAGETIMEOUT", "sayMessageTimeout", 1)); - SetAt(O_CREATEWIN, COpcodeAttributes("O_CREATEWIN", "createWin", 5)); - SetAt(O_DELETEWIN, COpcodeAttributes("O_DELETEWIN", "deleteWin", 1)); - SetAt(O_SELECTWIN, COpcodeAttributes("O_SELECTWIN", "selectWin", 1)); - SetAt(O_RESIZEWIN, COpcodeAttributes("O_RESIZEWIN", "resizeWin", 5)); - SetAt(O_SCALEWIN, COpcodeAttributes("O_SCALEWIN", "scaleWin", 5)); - SetAt(O_SHOWWIN, COpcodeAttributes("O_SHOWWIN", "showWin", 0)); - SetAt(O_FILLWIN, COpcodeAttributes("O_FILLWIN", "fillWin", 3)); - SetAt(O_FILLRECT, COpcodeAttributes("O_FILLRECT", "fillRect", 7)); - SetAt(O_FILLWIN3X3, COpcodeAttributes("O_FILLWIN3X3", "fillWin3x3", 1)); - SetAt(O_DISPLAY, COpcodeAttributes("O_DISPLAY", "display", 1)); - SetAt(O_DISPLAYGFX, COpcodeAttributes("O_DISPLAYGFX", "displayGfx", 5)); - SetAt(O_DISPLAYRAW, COpcodeAttributes("O_DISPLAYRAW", "displayRaw", 1)); - SetAt(O_LOADPALETTETABLE, COpcodeAttributes("O_LOADPALETTETABLE", "loadPaletteTable", 1)); - SetAt(O_FADEIN, COpcodeAttributes("O_FADEIN", "fadeIn", 1)); - SetAt(O_FADEOUT, COpcodeAttributes("O_FADEOUT", "fadeOut", 1)); - SetAt(O_GOTOXY, COpcodeAttributes("O_GOTOXY", "gotoXY", 2)); - SetAt(O_PRINT, COpcodeAttributes("O_PRINT", "print", 1)); - SetAt(O_FORMAT, COpcodeAttributes("O_FORMAT", "format", 6)); - SetAt(O_PRINTRECT, COpcodeAttributes("O_PRINTRECT", "printRect", 3)); - SetAt(O_SETFONT, COpcodeAttributes("O_SETFONT", "setFont", 1)); - SetAt(O_SETTEXTFLAGS, COpcodeAttributes("O_SETTEXTFLAGS", "setTextFlags", 1)); - SetAt(O_SETTEXTCOLOR, COpcodeAttributes("O_SETTEXTCOLOR", "setTextColor", 3)); - SetAt(O_SETHIGHLIGHTCOLOR, COpcodeAttributes("O_SETHIGHLIGHTCOLOR", "setHighlightColor", 3)); - SetAt(O_STOPMOVIE, COpcodeAttributes("O_STOPMOVIE", "stopMovie", 0)); - SetAt(O_PLAYMOVIE, COpcodeAttributes("O_PLAYMOVIE", "playMovie", 1)); - SetAt(O_MOVIEFLAGS, COpcodeAttributes("O_MOVIEFLAGS", "movieFlags", 1)); - SetAt(O_PLAYMOVIERECT, COpcodeAttributes("O_PLAYMOVIERECT", "playMovieRect", 5)); - SetAt(O_PLAYMOVIEALPHA, COpcodeAttributes("O_PLAYMOVIEALPHA", "playmoviealpha", 2)); - SetAt(O_PLAYMOVIEALPHARECT, COpcodeAttributes("O_PLAYMOVIEALPHARECT", "playMovieAlphaRect", 6)); - SetAt(O_ADDREGION, COpcodeAttributes("O_ADDREGION", "addRegion", 5, expression)); - SetAt(O_ADDREGIONFLAG, COpcodeAttributes("O_ADDREGIONFLAG", "addRegionFlag", 2)); - SetAt(O_ADDREGIONPROC, COpcodeAttributes("O_ADDREGIONPROC", "addRegionProc", 5)); - SetAt(O_ADDREGIONRIGHTPROC, COpcodeAttributes("O_ADDREGIONRIGHTPROC", "addRegionRightProc", 3)); - SetAt(O_DELETEREGION, COpcodeAttributes("O_DELETEREGION", "deleteRegion", 1)); - SetAt(O_ACTIVATEREGION, COpcodeAttributes("O_ACTIVATEREGION", "activateRegion", 2)); - SetAt(O_CHECKREGION, COpcodeAttributes("O_CHECKREGION", "checkRegion", 1, expression)); - SetAt(O_ADDBUTTON, COpcodeAttributes("O_ADDBUTTON", "addButton", 5)); - SetAt(O_ADDBUTTONTEXT, COpcodeAttributes("O_ADDBUTTONTEXT", "addButtonText", 2)); - SetAt(O_ADDBUTTONFLAG, COpcodeAttributes("O_ADDBUTTONFLAG", "addButtonFlag", 2)); - SetAt(O_ADDBUTTONGFX, COpcodeAttributes("O_ADDBUTTONGFX", "addButtonGfx", 4)); - SetAt(O_ADDBUTTONPROC, COpcodeAttributes("O_ADDBUTTONPROC", "addButtonProc", 5)); - SetAt(O_ADDBUTTONRIGHTPROC, COpcodeAttributes("O_ADDBUTTONRIGHTPROC", "addButtonRightProc", 3)); - SetAt(O_DELETEBUTTON, COpcodeAttributes("O_DELETEBUTTON", "deleteButton", 1)); - SetAt(O_HIDEMOUSE, COpcodeAttributes("O_HIDEMOUSE", "hideMouse", 0)); - SetAt(O_SHOWMOUSE, COpcodeAttributes("O_SHOWMOUSE", "showMouse", 0)); - SetAt(O_MOUSESHAPE, COpcodeAttributes("O_MOUSESHAPE", "mouseShape", 3)); - SetAt(O_REFRESHMOUSE, COpcodeAttributes("O_REFRESHMOUSE", "refreshMouse", 1)); - SetAt(O_SETGLOBALMOUSEFUNC, COpcodeAttributes("O_SETGLOBALMOUSEFUNC", "setGlobalMouseFunc", 4)); - SetAt(O_ADDNAMEDEVENT, COpcodeAttributes("O_ADDNAMEDEVENT", "addNamedEvent", 2)); - SetAt(O_ADDNAMEDHANDLER, COpcodeAttributes("O_ADDNAMEDHANDLER", "addNamedHandler", 2)); - SetAt(O_CLEARNAMED, COpcodeAttributes("O_CLEARNAMED", "clearNamed", 1)); - SetAt(O_SIGNALNAMED, COpcodeAttributes("O_SIGNALNAMED", "signalNamed", 1)); - SetAt(O_ADDKEY, COpcodeAttributes("O_ADDKEY", "addKey", 2)); - SetAt(O_DELETEKEY, COpcodeAttributes("O_DELETEKEY", "deleteKey", 1)); - SetAt(O_SOUNDPLAY, COpcodeAttributes("O_SOUNDPLAY", "soundPlay", 2, expression)); - SetAt(O_SOUNDPAUSE, COpcodeAttributes("O_SOUNDPAUSE", "soundPause", 1)); - SetAt(O_SOUNDRESUME, COpcodeAttributes("O_SOUNDRESUME", "soundResume", 1)); - SetAt(O_SOUNDSTOP, COpcodeAttributes("O_SOUNDSTOP", "soundStop", 1)); - SetAt(O_SOUNDREWIND, COpcodeAttributes("O_SOUNDREWIND", "soundRewind", 1)); - SetAt(O_SOUNDDELETE, COpcodeAttributes("O_SOUNDDELETE", "soundDelete", 1)); - SetAt(O_SETONEOPTPAUSE, COpcodeAttributes("O_SETONEOPTPAUSE", "setOneOptPause", 1)); - SetAt(O_SELECTFILELIST, COpcodeAttributes("O_SELECTFILELIST", "selectFileList", 2, expression)); - SetAt(O_TOKENIZE, COpcodeAttributes("O_TOKENIZE", "tokenize", 3, expression)); - SetAt(O_GIVE_EXP_POINTS, COpcodeAttributes("O_GIVE_EXP_POINTS", "give_exp_points", 1)); - SetAt(O_SCR_RETURN, COpcodeAttributes("O_SCR_RETURN", "scr_return", 1)); - SetAt(O_PLAY_SFX, COpcodeAttributes("O_PLAY_SFX", "play_sfx", 1)); - SetAt(O_OBJ_NAME, COpcodeAttributes("O_OBJ_NAME", "obj_name", 1, expression)); - SetAt(O_SFX_BUILD_OPEN_NAME, COpcodeAttributes("O_SFX_BUILD_OPEN_NAME", "sfx_build_open_name", 2, expression)); - SetAt(O_GET_PC_STAT, COpcodeAttributes("O_GET_PC_STAT", "get_pc_stat", 1, expression)); - SetAt(O_TILE_CONTAINS_PID_OBJ, COpcodeAttributes("O_TILE_CONTAINS_PID_OBJ", "tile_contains_pid_obj", 3, expression)); - SetAt(O_SET_MAP_START, COpcodeAttributes("O_SET_MAP_START", "set_map_start", 4)); - SetAt(O_OVERRIDE_MAP_START, COpcodeAttributes("O_OVERRIDE_MAP_START", "override_map_start", 4)); - SetAt(O_HAS_SKILL, COpcodeAttributes("O_HAS_SKILL", "has_skill", 2, expression)); - SetAt(O_USING_SKILL, COpcodeAttributes("O_USING_SKILL", "using_skill", 2, expression)); - SetAt(O_ROLL_VS_SKILL, COpcodeAttributes("O_ROLL_VS_SKILL", "roll_vs_skill", 3, expression)); - SetAt(O_SKILL_CONTEST, COpcodeAttributes("O_SKILL_CONTEST", "skill_contest", 3, expression)); - SetAt(O_DO_CHECK, COpcodeAttributes("O_DO_CHECK", "do_check", 3, expression)); - SetAt(O_IS_SUCCESS, COpcodeAttributes("O_IS_SUCCESS", "is_success", 1, expression)); - SetAt(O_IS_CRITICAL, COpcodeAttributes("O_IS_CRITICAL", "is_critical", 1, expression)); - SetAt(O_HOW_MUCH, COpcodeAttributes("O_HOW_MUCH", "how_much", 0, expression)); - SetAt(O_MARK_AREA_KNOWN, COpcodeAttributes("O_MARK_AREA_KNOWN", "mark_area_known", 3)); - SetAt(O_REACTION_INFLUENCE, COpcodeAttributes("O_REACTION_INFLUENCE", "reaction_influence", 3, expression)); - SetAt(O_RANDOM, COpcodeAttributes("O_RANDOM", "random", 2, expression)); - SetAt(O_ROLL_DICE, COpcodeAttributes("O_ROLL_DICE", "roll_dice", 2, expression)); - SetAt(O_MOVE_TO, COpcodeAttributes("O_MOVE_TO", "move_to", 3, expression)); - SetAt(O_CREATE_OBJECT_SID, COpcodeAttributes("O_CREATE_OBJECT_SID", "create_object_sid", 4, expression)); - SetAt(O_DISPLAY_MSG, COpcodeAttributes("O_DISPLAY_MSG", "display_msg", 1)); - SetAt(O_SCRIPT_OVERRIDES, COpcodeAttributes("O_SCRIPT_OVERRIDES", "script_overrides", 0)); - SetAt(O_OBJ_IS_CARRYING_OBJ_PID, COpcodeAttributes("O_OBJ_IS_CARRYING_OBJ_PID", "obj_is_carrying_obj_pid", 2, expression)); - SetAt(O_TILE_CONTAINS_OBJ_PID, COpcodeAttributes("O_TILE_CONTAINS_OBJ_PID", "tile_contains_obj_pid", 3, expression)); - SetAt(O_SELF_OBJ, COpcodeAttributes("O_SELF_OBJ", "self_obj", 0, expression)); - SetAt(O_SOURCE_OBJ, COpcodeAttributes("O_SOURCE_OBJ", "source_obj", 0, expression)); - SetAt(O_TARGET_OBJ, COpcodeAttributes("O_TARGET_OBJ", "target_obj", 0, expression)); - SetAt(O_DUDE_OBJ, COpcodeAttributes("O_DUDE_OBJ", "dude_obj", 0, expression)); - SetAt(O_OBJ_BEING_USED_WITH, COpcodeAttributes("O_OBJ_BEING_USED_WITH", "obj_being_used_with", 0, expression)); - SetAt(O_LOCAL_VAR, COpcodeAttributes("O_LOCAL_VAR", "local_var", 1, expression)); - SetAt(O_SET_LOCAL_VAR, COpcodeAttributes("O_SET_LOCAL_VAR", "set_local_var", 2)); - SetAt(O_MAP_VAR, COpcodeAttributes("O_MAP_VAR", "map_var", 1, expression)); - SetAt(O_SET_MAP_VAR, COpcodeAttributes("O_SET_MAP_VAR", "set_map_var", 2)); - SetAt(O_GLOBAL_VAR, COpcodeAttributes("O_GLOBAL_VAR", "global_var", 1, expression)); - SetAt(O_SET_GLOBAL_VAR, COpcodeAttributes("O_SET_GLOBAL_VAR", "set_global_var", 2)); - SetAt(O_SCRIPT_ACTION, COpcodeAttributes("O_SCRIPT_ACTION", "script_action", 0, expression)); - SetAt(O_OBJ_TYPE, COpcodeAttributes("O_OBJ_TYPE", "obj_type", 1, expression)); - SetAt(O_OBJ_ITEM_SUBTYPE, COpcodeAttributes("O_OBJ_ITEM_SUBTYPE", "obj_item_subtype", 1, expression)); - SetAt(O_GET_CRITTER_STAT, COpcodeAttributes("O_GET_CRITTER_STAT", "get_critter_stat", 2, expression)); - SetAt(O_SET_CRITTER_STAT, COpcodeAttributes("O_SET_CRITTER_STAT", "set_critter_stat", 3, expression)); - SetAt(O_ANIMATE_STAND_OBJ, COpcodeAttributes("O_ANIMATE_STAND_OBJ", "animate_stand_obj", 1)); - SetAt(O_ANIMATE_STAND_REVERSE_OBJ, COpcodeAttributes("O_ANIMATE_STAND_REVERSE_OBJ", "animate_stand_reverse_obj", 1)); - SetAt(O_ANIMATE_MOVE_OBJ_TO_TILE, COpcodeAttributes("O_ANIMATE_MOVE_OBJ_TO_TILE", "animate_move_obj_to_tile", 3)); - SetAt(O_TILE_IN_TILE_RECT, COpcodeAttributes("O_TILE_IN_TILE_RECT", "tile_in_tile_rect", 5, expression)); - SetAt(O_ATTACK_COMPLEX, COpcodeAttributes("O_ATTACK_COMPLEX", "attack_complex", 8)); - SetAt(O_MAKE_DAYTIME, COpcodeAttributes("O_MAKE_DAYTIME", "make_daytime", 0)); - SetAt(O_TILE_DISTANCE, COpcodeAttributes("O_TILE_DISTANCE", "tile_distance", 2, expression)); - SetAt(O_TILE_DISTANCE_OBJS, COpcodeAttributes("O_TILE_DISTANCE_OBJS", "tile_distance_objs", 2, expression)); - SetAt(O_TILE_NUM, COpcodeAttributes("O_TILE_NUM", "tile_num", 1, expression)); - SetAt(O_TILE_NUM_IN_DIRECTION, COpcodeAttributes("O_TILE_NUM_IN_DIRECTION", "tile_num_in_direction", 3, expression)); - SetAt(O_PICKUP_OBJ, COpcodeAttributes("O_PICKUP_OBJ", "pickup_obj", 1)); - SetAt(O_DROP_OBJ, COpcodeAttributes("O_DROP_OBJ", "drop_obj", 1)); - SetAt(O_ADD_OBJ_TO_INVEN, COpcodeAttributes("O_ADD_OBJ_TO_INVEN", "add_obj_to_inven", 2)); - SetAt(O_RM_OBJ_FROM_INVEN, COpcodeAttributes("O_RM_OBJ_FROM_INVEN", "rm_obj_from_inven", 2)); - SetAt(O_WIELD_OBJ_CRITTER, COpcodeAttributes("O_WIELD_OBJ_CRITTER", "wield_obj_critter", 2)); - SetAt(O_USE_OBJ, COpcodeAttributes("O_USE_OBJ", "use_obj", 1)); - SetAt(O_OBJ_CAN_SEE_OBJ, COpcodeAttributes("O_OBJ_CAN_SEE_OBJ", "obj_can_see_obj", 2, expression)); - SetAt(O_ATTACK, COpcodeAttributes("O_ATTACK", "attack", 8)); - SetAt(O_START_GDIALOG, COpcodeAttributes("O_START_GDIALOG", "start_gdialog", 5)); - SetAt(O_END_DIALOGUE, COpcodeAttributes("O_END_DIALOGUE", "end_dialogue", 0)); - SetAt(O_DIALOGUE_REACTION, COpcodeAttributes("O_DIALOGUE_REACTION", "dialogue_reaction", 1)); - SetAt(O_METARULE3, COpcodeAttributes("O_METARULE3", "metarule3", 4, expression)); - SetAt(O_SET_MAP_MUSIC, COpcodeAttributes("O_SET_MAP_MUSIC", "set_map_music", 2)); - SetAt(O_SET_OBJ_VISIBILITY, COpcodeAttributes("O_SET_OBJ_VISIBILITY", "set_obj_visibility", 2)); - SetAt(O_LOAD_MAP, COpcodeAttributes("O_LOAD_MAP", "load_map", 2)); - SetAt(O_WM_AREA_SET_POS, COpcodeAttributes("O_WM_AREA_SET_POS", "wm_area_set_pos", 3)); - SetAt(O_SET_EXIT_GRIDS, COpcodeAttributes("O_SET_EXIT_GRIDS", "set_exit_grids", 5)); - SetAt(O_ANIM_BUSY, COpcodeAttributes("O_ANIM_BUSY", "anim_busy", 1, expression)); - SetAt(O_CRITTER_HEAL, COpcodeAttributes("O_CRITTER_HEAL", "critter_heal", 2, expression)); - SetAt(O_SET_LIGHT_LEVEL, COpcodeAttributes("O_SET_LIGHT_LEVEL", "set_light_level", 1)); - SetAt(O_GAME_TIME, COpcodeAttributes("O_GAME_TIME", "game_time", 0, expression)); - SetAt(O_GAME_TIME_IN_SECONDS, COpcodeAttributes("O_GAME_TIME_IN_SECONDS", "game_time_in_seconds", 0, expression)); - SetAt(O_ELEVATION, COpcodeAttributes("O_ELEVATION", "elevation", 1, expression)); - SetAt(O_KILL_CRITTER, COpcodeAttributes("O_KILL_CRITTER", "kill_critter", 2)); - SetAt(O_KILL_CRITTER_TYPE, COpcodeAttributes("O_KILL_CRITTER_TYPE", "kill_critter_type", 2)); - SetAt(O_CRITTER_DMG, COpcodeAttributes("O_CRITTER_DMG", "critter_dmg", 3)); - SetAt(O_ADD_TIMER_EVENT, COpcodeAttributes("O_ADD_TIMER_EVENT", "add_timer_event", 3)); - SetAt(O_RM_TIMER_EVENT, COpcodeAttributes("O_RM_TIMER_EVENT", "rm_timer_event", 1)); - SetAt(O_GAME_TICKS, COpcodeAttributes("O_GAME_TICKS", "game_ticks", 1, expression)); - SetAt(O_HAS_TRAIT, COpcodeAttributes("O_HAS_TRAIT", "has_trait", 3, expression)); - SetAt(O_DESTROY_OBJECT, COpcodeAttributes("O_DESTROY_OBJECT", "destroy_object", 1)); - SetAt(O_OBJ_CAN_HEAR_OBJ, COpcodeAttributes("O_OBJ_CAN_HEAR_OBJ", "obj_can_hear_obj", 2, expression)); - SetAt(O_GAME_TIME_HOUR, COpcodeAttributes("O_GAME_TIME_HOUR", "game_time_hour", 0, expression)); - SetAt(O_FIXED_PARAM, COpcodeAttributes("O_FIXED_PARAM", "fixed_param", 0, expression)); - SetAt(O_TILE_IS_VISIBLE, COpcodeAttributes("O_TILE_IS_VISIBLE", "tile_is_visible", 1, expression)); - SetAt(O_DIALOGUE_SYSTEM_ENTER, COpcodeAttributes("O_DIALOGUE_SYSTEM_ENTER", "dialogue_system_enter", 0)); - SetAt(O_ACTION_BEING_USED, COpcodeAttributes("O_ACTION_BEING_USED", "action_being_used", 0, expression)); - SetAt(O_CRITTER_STATE, COpcodeAttributes("O_CRITTER_STATE", "critter_state", 1, expression)); - SetAt(O_GAME_TIME_ADVANCE, COpcodeAttributes("O_GAME_TIME_ADVANCE", "game_time_advance", 1)); - SetAt(O_RADIATION_INC, COpcodeAttributes("O_RADIATION_INC", "radiation_inc", 2)); - SetAt(O_RADIATION_DEC, COpcodeAttributes("O_RADIATION_DEC", "radiation_dec", 2)); - SetAt(O_CRITTER_ATTEMPT_PLACEMENT, COpcodeAttributes("O_CRITTER_ATTEMPT_PLACEMENT", "critter_attempt_placement", 3, expression)); - SetAt(O_OBJ_PID, COpcodeAttributes("O_OBJ_PID", "obj_pid", 1, expression)); - SetAt(O_CUR_MAP_INDEX, COpcodeAttributes("O_CUR_MAP_INDEX", "cur_map_index", 0, expression)); - SetAt(O_CRITTER_ADD_TRAIT, COpcodeAttributes("O_CRITTER_ADD_TRAIT", "critter_add_trait", 4, expression)); - SetAt(O_CRITTER_RM_TRAIT, COpcodeAttributes("O_CRITTER_RM_TRAIT", "critter_rm_trait", 4, expression)); - SetAt(O_PROTO_DATA, COpcodeAttributes("O_PROTO_DATA", "proto_data", 2, expression)); - SetAt(O_MESSAGE_STR, COpcodeAttributes("O_MESSAGE_STR", "message_str", 2, expression)); - SetAt(O_CRITTER_INVEN_OBJ, COpcodeAttributes("O_CRITTER_INVEN_OBJ", "critter_inven_obj", 2, expression)); - SetAt(O_OBJ_SET_LIGHT_LEVEL, COpcodeAttributes("O_OBJ_SET_LIGHT_LEVEL", "obj_set_light_level", 3)); - SetAt(O_WORLD_MAP, COpcodeAttributes("O_WORLD_MAP", "world_map", 0)); - SetAt(O_INVEN_CMDS, COpcodeAttributes("O_INVEN_CMDS", "inven_cmds", 3, expression)); - SetAt(O_FLOAT_MSG, COpcodeAttributes("O_FLOAT_MSG", "float_msg", 3)); - SetAt(O_METARULE, COpcodeAttributes("O_METARULE", "metarule", 2, expression)); - SetAt(O_ANIM, COpcodeAttributes("O_ANIM", "anim", 3)); - SetAt(O_OBJ_CARRYING_PID_OBJ, COpcodeAttributes("O_OBJ_CARRYING_PID_OBJ", "obj_carrying_pid_obj", 2, expression)); - SetAt(O_REG_ANIM_FUNC, COpcodeAttributes("O_REG_ANIM_FUNC", "reg_anim_func", 2)); - SetAt(O_REG_ANIM_ANIMATE, COpcodeAttributes("O_REG_ANIM_ANIMATE", "reg_anim_animate", 3)); - SetAt(O_REG_ANIM_ANIMATE_REVERSE, COpcodeAttributes("O_REG_ANIM_ANIMATE_REVERSE", "reg_anim_animate_reverse", 3)); - SetAt(O_REG_ANIM_OBJ_MOVE_TO_OBJ, COpcodeAttributes("O_REG_ANIM_OBJ_MOVE_TO_OBJ", "reg_anim_obj_move_to_obj", 3)); - SetAt(O_REG_ANIM_OBJ_RUN_TO_OBJ, COpcodeAttributes("O_REG_ANIM_OBJ_RUN_TO_OBJ", "reg_anim_obj_run_to_obj", 3)); - SetAt(O_REG_ANIM_OBJ_MOVE_TO_TILE, COpcodeAttributes("O_REG_ANIM_OBJ_MOVE_TO_TILE", "reg_anim_obj_move_to_tile", 3)); - SetAt(O_REG_ANIM_OBJ_RUN_TO_TILE, COpcodeAttributes("O_REG_ANIM_OBJ_RUN_TO_TILE", "reg_anim_obj_run_to_tile", 3)); - SetAt(O_PLAY_GMOVIE, COpcodeAttributes("O_PLAY_GMOVIE", "play_gmovie", 1)); - SetAt(O_ADD_MULT_OBJS_TO_INVEN, COpcodeAttributes("O_ADD_MULT_OBJS_TO_INVEN", "add_mult_objs_to_inven", 3)); - SetAt(O_RM_MULT_OBJS_FROM_INVEN, COpcodeAttributes("O_RM_MULT_OBJS_FROM_INVEN", "rm_mult_objs_from_inven", 3, expression)); - SetAt(O_GET_MONTH, COpcodeAttributes("O_GET_MONTH", "get_month", 0, expression)); - SetAt(O_GET_DAY, COpcodeAttributes("O_GET_DAY", "get_day", 0, expression)); - SetAt(O_EXPLOSION, COpcodeAttributes("O_EXPLOSION", "explosion", 3)); - SetAt(O_DAYS_SINCE_VISITED, COpcodeAttributes("O_DAYS_SINCE_VISITED", "days_since_visited", 0, expression)); - SetAt(O_GSAY_START, COpcodeAttributes("O_GSAY_START", "gsay_start", 0)); - SetAt(O_GSAY_END, COpcodeAttributes("O_GSAY_END", "gsay_end", 0)); - SetAt(O_GSAY_REPLY, COpcodeAttributes("O_GSAY_REPLY", "gsay_reply", 2)); - SetAt(O_GSAY_OPTION, COpcodeAttributes("O_GSAY_OPTION", "gsay_option", 4)); - SetAt(O_GSAY_MESSAGE, COpcodeAttributes("O_GSAY_MESSAGE", "gsay_message", 3)); - SetAt(O_GIQ_OPTION, COpcodeAttributes("O_GIQ_OPTION", "giq_option", 5)); - SetAt(O_POISON, COpcodeAttributes("O_POISON", "poison", 2)); - SetAt(O_GET_POISON, COpcodeAttributes("O_GET_POISON", "get_poison", 1, expression)); - SetAt(O_PARTY_ADD, COpcodeAttributes("O_PARTY_ADD", "party_add", 1)); - SetAt(O_PARTY_REMOVE, COpcodeAttributes("O_PARTY_REMOVE", "party_remove", 1)); - SetAt(O_REG_ANIM_ANIMATE_FOREVER, COpcodeAttributes("O_REG_ANIM_ANIMATE_FOREVER", "reg_anim_animate_forever", 2)); - SetAt(O_CRITTER_INJURE, COpcodeAttributes("O_CRITTER_INJURE", "critter_injure", 2)); - SetAt(O_COMBAT_IS_INITIALIZED, COpcodeAttributes("O_COMBAT_IS_INITIALIZED", "combat_is_initialized", 0, expression)); - SetAt(O_GDIALOG_MOD_BARTER, COpcodeAttributes("O_GDIALOG_MOD_BARTER", "gdialog_mod_barter", 1)); - SetAt(O_DIFFICULTY_LEVEL, COpcodeAttributes("O_DIFFICULTY_LEVEL", "difficulty_level", 0, expression)); - SetAt(O_RUNNING_BURNING_GUY, COpcodeAttributes("O_RUNNING_BURNING_GUY", "running_burning_guy", 0, expression)); - SetAt(O_INVEN_UNWIELD, COpcodeAttributes("O_INVEN_UNWIELD", "inven_unwield", 0)); - SetAt(O_OBJ_IS_LOCKED, COpcodeAttributes("O_OBJ_IS_LOCKED", "obj_is_locked", 1, expression)); - SetAt(O_OBJ_LOCK, COpcodeAttributes("O_OBJ_LOCK", "obj_lock", 1)); - SetAt(O_OBJ_UNLOCK, COpcodeAttributes("O_OBJ_UNLOCK", "obj_unlock", 1)); - SetAt(O_OBJ_IS_OPEN, COpcodeAttributes("O_OBJ_IS_OPEN", "obj_is_open", 1, expression)); - SetAt(O_OBJ_OPEN, COpcodeAttributes("O_OBJ_OPEN", "obj_open", 1)); - SetAt(O_OBJ_CLOSE, COpcodeAttributes("O_OBJ_CLOSE", "obj_close", 1)); - SetAt(O_GAME_UI_DISABLE, COpcodeAttributes("O_GAME_UI_DISABLE", "game_ui_disable", 0)); - SetAt(O_GAME_UI_ENABLE, COpcodeAttributes("O_GAME_UI_ENABLE", "game_ui_enable", 0)); - SetAt(O_GAME_UI_IS_DISABLED, COpcodeAttributes("O_GAME_UI_IS_DISABLED", "game_ui_is_disabled", 0, expression)); - SetAt(O_GFADE_OUT, COpcodeAttributes("O_GFADE_OUT", "gfade_out", 1)); - SetAt(O_GFADE_IN, COpcodeAttributes("O_GFADE_IN", "gfade_in", 1)); - SetAt(O_ITEM_CAPS_TOTAL, COpcodeAttributes("O_ITEM_CAPS_TOTAL", "item_caps_total", 1, expression)); - SetAt(O_ITEM_CAPS_ADJUST, COpcodeAttributes("O_ITEM_CAPS_ADJUST", "item_caps_adjust", 2, expression)); - SetAt(O_ANIM_ACTION_FRAME, COpcodeAttributes("O_ANIM_ACTION_FRAME", "anim_action_frame", 2, expression)); - SetAt(O_REG_ANIM_PLAY_SFX, COpcodeAttributes("O_REG_ANIM_PLAY_SFX", "reg_anim_play_sfx", 3)); - SetAt(O_CRITTER_MOD_SKILL, COpcodeAttributes("O_CRITTER_MOD_SKILL", "critter_mod_skill", 3)); - SetAt(O_SFX_BUILD_CHAR_NAME, COpcodeAttributes("O_SFX_BUILD_CHAR_NAME", "sfx_build_char_name", 3, expression)); - SetAt(O_SFX_BUILD_AMBIENT_NAME, COpcodeAttributes("O_SFX_BUILD_AMBIENT_NAME", "sfx_build_ambient_name", 1, expression)); - SetAt(O_SFX_BUILD_INTERFACE_NAME, COpcodeAttributes("O_SFX_BUILD_INTERFACE_NAME", "sfx_build_interface_name", 1, expression)); - SetAt(O_SFX_BUILD_ITEM_NAME, COpcodeAttributes("O_SFX_BUILD_ITEM_NAME", "sfx_build_item_name", 1, expression)); - SetAt(O_SFX_BUILD_WEAPON_NAME, COpcodeAttributes("O_SFX_BUILD_WEAPON_NAME", "sfx_build_weapon_name", 4, expression)); - SetAt(O_SFX_BUILD_SCENERY_NAME, COpcodeAttributes("O_SFX_BUILD_SCENERY_NAME", "sfx_build_scenery_name", 3, expression)); - SetAt(O_ATTACK_SETUP, COpcodeAttributes("O_ATTACK_SETUP", "attack_setup", 2)); - SetAt(O_DESTROY_MULT_OBJS, COpcodeAttributes("O_DESTROY_MULT_OBJS", "destroy_mult_objs", 2, expression)); - SetAt(O_USE_OBJ_ON_OBJ, COpcodeAttributes("O_USE_OBJ_ON_OBJ", "use_obj_on_obj", 2)); - SetAt(O_ENDGAME_SLIDESHOW, COpcodeAttributes("O_ENDGAME_SLIDESHOW", "endgame_slideshow", 0)); - SetAt(O_MOVE_OBJ_INVEN_TO_OBJ, COpcodeAttributes("O_MOVE_OBJ_INVEN_TO_OBJ", "move_obj_inven_to_obj", 2)); - SetAt(O_ENDGAME_MOVIE, COpcodeAttributes("O_ENDGAME_MOVIE", "endgame_movie", 0)); - SetAt(O_OBJ_ART_FID, COpcodeAttributes("O_OBJ_ART_FID", "obj_art_fid", 1, expression)); - SetAt(O_ART_ANIM, COpcodeAttributes("O_ART_ANIM", "art_anim", 1, expression)); - SetAt(O_PARTY_MEMBER_OBJ, COpcodeAttributes("O_PARTY_MEMBER_OBJ", "party_member_obj", 1, expression)); - SetAt(O_ROTATION_TO_TILE, COpcodeAttributes("O_ROTATION_TO_TILE", "rotation_to_tile", 2, expression)); - SetAt(O_JAM_LOCK, COpcodeAttributes("O_JAM_LOCK", "jam_lock", 1)); - SetAt(O_GDIALOG_SET_BARTER_MOD, COpcodeAttributes("O_GDIALOG_SET_BARTER_MOD", "gdialog_set_barter_mod", 1)); - SetAt(O_COMBAT_DIFFICULTY, COpcodeAttributes("O_COMBAT_DIFFICULTY", "combat_difficulty", 0, expression)); - SetAt(O_OBJ_ON_SCREEN, COpcodeAttributes("O_OBJ_ON_SCREEN", "obj_on_screen", 1, expression)); - SetAt(O_CRITTER_IS_FLEEING, COpcodeAttributes("O_CRITTER_IS_FLEEING", "critter_is_fleeing", 1, expression)); - SetAt(O_CRITTER_SET_FLEE_STATE, COpcodeAttributes("O_CRITTER_SET_FLEE_STATE", "critter_set_flee_state", 2)); - SetAt(O_TERMINATE_COMBAT, COpcodeAttributes("O_TERMINATE_COMBAT", "terminate_combat", 0)); - SetAt(O_DEBUG_MSG, COpcodeAttributes("O_DEBUG_MSG", "debug_msg", 1)); - SetAt(O_CRITTER_STOP_ATTACKING, COpcodeAttributes("O_CRITTER_STOP_ATTACKING", "critter_stop_attacking", 1)); - - //sall start - - SetAt(O_READ_BYTE, COpcodeAttributes("O_READ_BYTE", "read_byte", 1, expression)); - SetAt(O_READ_SHORT, COpcodeAttributes("O_READ_SHORT", "read_short", 1, expression)); - SetAt(O_READ_INT, COpcodeAttributes("O_READ_INT", "read_int", 1, expression)); - SetAt(O_READ_STRING, COpcodeAttributes("O_READ_STRING", "read_string", 1, expression)); - - SetAt(O_SET_PC_BASE_STAT, COpcodeAttributes("O_SET_PC_BASE_STAT", "set_pc_base_stat", 2)); - SetAt(O_SET_PC_EXTRA_STAT, COpcodeAttributes("O_SET_PC_EXTRA_STAT", "set_pc_extra_stat", 2)); - SetAt(O_GET_PC_BASE_STAT, COpcodeAttributes("O_GET_PC_BASE_STAT", "get_pc_base_stat", 1, expression)); - SetAt(O_GET_PC_EXTRA_STAT, COpcodeAttributes("O_GET_PC_EXTRA_STAT", "get_pc_extra_stat", 1, expression)); - - SetAt(O_SET_CRITTER_BASE_STAT, COpcodeAttributes("O_SET_CRITTER_BASE_STAT", "set_critter_base_stat", 3)); - SetAt(O_SET_CRITTER_EXTRA_STAT, COpcodeAttributes("O_SET_CRITTER_EXTRA_STAT", "set_critter_extra_stat", 3)); - SetAt(O_GET_CRITTER_BASE_STAT, COpcodeAttributes("O_GET_CRITTER_BASE_STAT", "get_critter_base_stat", 2, expression)); - SetAt(O_GET_CRITTER_EXTRA_STAT, COpcodeAttributes("O_GET_CRITTER_EXTRA_STAT", "get_critter_extra_stat", 2, expression)); - - SetAt(O_TAP_KEY, COpcodeAttributes("O_TAP_KEY", "tap_key", 1)); - SetAt(O_GET_YEAR, COpcodeAttributes("O_GET_YEAR", "get_year", 0, expression)); - - SetAt(O_GAME_LOADED, COpcodeAttributes("O_GAME_LOADED", "game_loaded", 0, expression)); - SetAt(O_GRAPHICS_FUNCS_AVAILABLE, COpcodeAttributes("O_GRAPHICS_FUNCS_AVAILABLE", "graphics_funcs_available", 0, expression)); - SetAt(O_LOAD_SHADER, COpcodeAttributes("O_LOAD_SHADER", "load_shader", 1, expression)); - SetAt(O_FREE_SHADER, COpcodeAttributes("O_FREE_SHADER", "free_shader", 1)); - SetAt(O_ACTIVATE_SHADER, COpcodeAttributes("O_ACTIVATE_SHADER", "activate_shader", 1)); - SetAt(O_DEACTIVATE_SHADER, COpcodeAttributes("O_DEACTIVATE_SHADER", "deactivate_shader", 1)); - SetAt(O_SET_GLOBAL_SCRIPT_REPEAT, COpcodeAttributes("O_SET_GLOBAL_SCRIPT_REPEAT", "set_global_script_repeat", 1)); - SetAt(O_INPUT_FUNCS_AVAILABLE, COpcodeAttributes("O_INPUT_FUNCS_AVAILABLE", "input_funcs_available", 0, expression)); - SetAt(O_KEY_PRESSED, COpcodeAttributes("O_KEY_PRESSED", "key_pressed", 1, expression)); - - SetAt(O_SET_SHADER_INT, COpcodeAttributes("O_SET_SHADER_INT", "set_shader_int", 3)); - SetAt(O_SET_SHADER_FLOAT, COpcodeAttributes("O_SET_SHADER_FLOAT", "set_shader_float", 3)); - SetAt(O_SET_SHADER_VECTOR, COpcodeAttributes("O_SET_SHADER_VECTOR", "set_shader_vector", 6)); - SetAt(O_IN_WORLD_MAP, COpcodeAttributes("O_IN_WORLD_MAP", "in_world_map", 0, expression)); - SetAt(O_FORCE_ENCOUNTER, COpcodeAttributes("O_FORCE_ENCOUNTER", "force_encounter", 1)); - SetAt(O_SET_WORLD_MAP_POS, COpcodeAttributes("O_SET_WORLD_MAP_POS", "set_world_map_pos", 2)); - SetAt(O_GET_WORLD_MAP_X_POS, COpcodeAttributes("O_GET_WORLD_MAP_X_POS", "get_world_map_x_pos", 0, expression)); - SetAt(O_GET_WORLD_MAP_Y_POS, COpcodeAttributes("O_GET_WORLD_MAP_Y_POS", "get_world_map_y_pos", 0, expression)); - - SetAt(O_SET_DM_MODEL, COpcodeAttributes("O_SET_DM_MODEL", "set_dm_model", 1)); - SetAt(O_SET_DF_MODEL, COpcodeAttributes("O_SET_DF_MODEL", "set_df_model", 1)); - SetAt(O_SET_MOVIE_PATH, COpcodeAttributes("O_SET_MOVIE_PATH", "set_movie_path", 2)); - - SetAt(O_SET_PERK_IMAGE, COpcodeAttributes("O_SET_PERK_IMAGE", "set_perk_image", 2)); - SetAt(O_SET_PERK_RANKS, COpcodeAttributes("O_SET_PERK_RANKS", "set_perk_ranks", 2)); - SetAt(O_SET_PERK_LEVEL, COpcodeAttributes("O_SET_PERK_LEVEL", "set_perk_level", 2)); - SetAt(O_SET_PERK_STAT, COpcodeAttributes("O_SET_PERK_STAT", "set_perk_stat", 2)); - SetAt(O_SET_PERK_STAT_MAG, COpcodeAttributes("O_SET_PERK_STAT_MAG", "set_perk_stat_mag", 2)); - SetAt(O_SET_PERK_SKILL1, COpcodeAttributes("O_SET_PERK_SKILL1", "set_perk_skill1", 2)); - SetAt(O_SET_PERK_SKILl1_MAG, COpcodeAttributes("O_SET_PERK_SKILl1_MAG", "set_perk_skill1_mag", 2)); - SetAt(O_SET_PERK_TYPE, COpcodeAttributes("O_SET_PERK_TYPE", "set_perk_type", 2)); - SetAt(O_SET_PERK_SKILL2, COpcodeAttributes("O_SET_PERK_SKILL2", "set_perk_skill2", 2)); - SetAt(O_SET_PERK_SKILL2_MAG, COpcodeAttributes("O_SET_PERK_SKILL2_MAG", "set_perk_skill2_mag", 2)); - SetAt(O_SET_PERK_STR, COpcodeAttributes("O_SET_PERK_STR", "set_perk_str", 2)); - SetAt(O_SET_PERK_PER, COpcodeAttributes("O_SET_PERK_PER", "set_perk_per", 2)); - SetAt(O_SET_PERK_END, COpcodeAttributes("O_SET_PERK_END", "set_perk_end", 2)); - SetAt(O_SET_PERK_CHR, COpcodeAttributes("O_SET_PERK_CHR", "set_perk_chr", 2)); - SetAt(O_SET_PERK_INT, COpcodeAttributes("O_SET_PERK_INT", "set_perk_int", 2)); - SetAt(O_SET_PERK_AGL, COpcodeAttributes("O_SET_PERK_AGL", "set_perk_agl", 2)); - SetAt(O_SET_PERK_LCK, COpcodeAttributes("O_SET_PERK_LCK", "set_perk_lck", 2)); - SetAt(O_SET_PERK_NAME, COpcodeAttributes("O_SET_PERK_NAME", "set_perk_name", 2)); - SetAt(O_SET_PERK_DESC, COpcodeAttributes("O_SET_PERK_DESC", "set_perk_desc", 2)); - - SetAt(O_SET_PIPBOY_AVAILABLE, COpcodeAttributes("O_SET_PIPBOY_AVAILABLE", "set_pipboy_available", 1)); - - SetAt(O_GET_KILL_COUNTER, COpcodeAttributes("O_GET_KILL_COUNTER", "get_kill_counter", 1, expression)); - SetAt(O_MOD_KILL_COUNTER, COpcodeAttributes("O_MOD_KILL_COUNTER", "mod_kill_counter", 2)); - - SetAt(O_GET_PERK_OWED, COpcodeAttributes("O_GET_PERK_OWED", "get_perk_owed", 0, expression)); - SetAt(O_SET_PERK_OWED, COpcodeAttributes("O_SET_PERK_OWED", "set_perk_owed", 1)); - SetAt(O_GET_PERK_AVAILABLE, COpcodeAttributes("O_GET_PERK_AVAILABLE", "get_perk_available", 1, expression)); - - SetAt(O_GET_CRITTER_AP, COpcodeAttributes("O_GET_CRITTER_AP", "get_critter_current_ap", 1, expression)); - SetAt(O_SET_CRITTER_AP, COpcodeAttributes("O_SET_CRITTER_AP", "set_critter_current_ap", 2)); - - SetAt(O_GET_ACTIVE_HAND, COpcodeAttributes("O_GET_ACTIVE_HAND", "active_hand", 0, expression)); - SetAt(O_TOGGLE_ACTIVE_HAND, COpcodeAttributes("O_TOGGLE_ACTIVE_HAND", "toggle_active_hand", 0)); - - SetAt(O_SET_WEAPON_KNOCKBACK, COpcodeAttributes("O_SET_WEAPON_KNOCKBACK", "set_weapon_knockback", 3)); - SetAt(O_SET_TARGET_KNOCKBACK, COpcodeAttributes("O_SET_TARGET_KNOCKBACK", "set_target_knockback", 3)); - SetAt(O_SET_ATTACKER_KNOCKBACK, COpcodeAttributes("O_SET_ATTACKER_KNOCKBACK", "set_attacker_knockback", 3)); - SetAt(O_REMOVE_WEAPON_KNOCKBACK, COpcodeAttributes("O_REMOVE_WEAPON_KNOCKBACK", "remove_weapon_knockback", 1)); - SetAt(O_REMOVE_TARGET_KNOCKBACK, COpcodeAttributes("O_REMOVE_TARGET_KNOCKBACK", "remove_target_knockback", 1)); - SetAt(O_REMOVE_ATTACKER_KNOCKBACK, COpcodeAttributes("O_REMOVE_ATTACKER_KNOCKBACK", "remove_attacker_knockback", 1)); - - SetAt(O_SET_GLOBAL_SCRIPT_TYPE, COpcodeAttributes("O_SET_GLOBAL_SCRIPT_TYPE", "set_global_script_type", 1)); - SetAt(O_AVAILABLE_GLOBAL_SCRIPT_TYPES, COpcodeAttributes("O_AVAILABLE_GLOBAL_SCRIPT_TYPES", "available_global_script_types", 0, expression)); - - SetAt(O_SET_SFALL_GLOBAL, COpcodeAttributes("O_SET_SFALL_GLOBAL", "set_sfall_global", 2)); - SetAt(O_GET_SFALL_GLOBAL_INT, COpcodeAttributes("O_GET_SFALL_GLOBAL_INT", "get_sfall_global_int", 1, expression)); - SetAt(O_GET_SFALL_GLOBAL_FLOAT, COpcodeAttributes("O_GET_SFALL_GLOBAL_FLOAT", "get_sfall_global_float", 1, expression)); - - SetAt(O_SET_PICKPOCKET_MAX, COpcodeAttributes("O_SET_PICKPOCKET_MAX", "set_pickpocket_max", 1)); - SetAt(O_SET_HIT_CHANCE_MAX, COpcodeAttributes("O_SET_HIT_CHANCE_MAX", "set_hit_chance_max", 1)); - SetAt(O_SET_SKILL_MAX, COpcodeAttributes("O_SET_SKILL_MAX", "set_skill_max", 1)); - - SetAt(O_EAX_AVAILABLE, COpcodeAttributes("O_EAX_AVAILABLE", "eax_available", 0, expression)); - SetAt(O_SET_EAX_ENVIRONMENT, COpcodeAttributes("O_SET_EAX_ENVIRONMENT", "set_eax_environment", 1)); - - SetAt(O_INC_NPC_LEVEL, COpcodeAttributes("O_INC_NPC_LEVEL", "inc_npc_level", 1)); - - SetAt(O_GET_VIEWPORT_X, COpcodeAttributes("O_GET_VIEWPORT_X", "get_viewport_x", 0, expression)); - SetAt(O_GET_VIEWPORT_Y, COpcodeAttributes("O_GET_VIEWPORT_Y", "get_viewport_y", 0, expression)); - SetAt(O_SET_VIEWPORT_X, COpcodeAttributes("O_SET_VIEWPORT_X", "set_viewport_x", 1)); - SetAt(O_SET_VIEWPORT_Y, COpcodeAttributes("O_SET_VIEWPORT_Y", "set_viewport_y", 1)); - - SetAt(O_SET_XP_MOD, COpcodeAttributes("O_SET_XP_MOD", "set_xp_mod", 1)); - SetAt(O_SET_PERK_LEVEL_MOD, COpcodeAttributes("O_SET_PERK_LEVEL_MOD", "set_perk_level_mod", 1)); - - SetAt(O_GET_INI_SETTING, COpcodeAttributes("O_GET_INI_SETTING", "get_ini_setting", 1, expression)); - - SetAt(O_GET_SHADER_VERSION, COpcodeAttributes("O_GET_SHADER_VERSION", "get_shader_version", 0, expression)); - SetAt(O_SET_SHADER_MODE, COpcodeAttributes("O_SET_SHADER_MODE", "set_shader_mode", 2)); - - SetAt(O_GET_GAME_MODE, COpcodeAttributes("O_GET_GAME_MODE", "get_game_mode", 0, expression)); - - SetAt(O_FORCE_GRAPHICS_REFRESH, COpcodeAttributes("O_FORCE_GRAPHICS_REFRESH", "force_graphics_refresh", 1)); - SetAt(O_GET_SHADER_TEXTURE, COpcodeAttributes("O_GET_SHADER_TEXTURE", "get_shader_texture", 2, expression)); - SetAt(O_SET_SHADER_TEXTURE, COpcodeAttributes("O_SET_SHADER_TEXTURE", "set_shader_texture", 3)); - - SetAt(O_GET_UPTIME, COpcodeAttributes("O_GET_UPTIME", "get_uptime", 0, expression)); - - SetAt(O_SET_STAT_MAX, COpcodeAttributes("O_SET_STAT_MAX", "set_stat_max", 2)); - SetAt(O_SET_STAT_MIN, COpcodeAttributes("O_SET_STAT_MIN", "set_stat_min", 2)); - - SetAt(O_SET_CAR_CURRENT_TOWN, COpcodeAttributes("O_SET_CAR_CURRENT_TOWN", "set_car_current_town", 1)); - - SetAt(O_SET_PC_STAT_MAX, COpcodeAttributes("O_SET_PC_STAT_MAX", "set_pc_stat_max", 2)); - SetAt(O_SET_PC_STAT_MIN, COpcodeAttributes("O_SET_PC_STAT_MIN", "set_pc_stat_min", 2)); - SetAt(O_SET_NPC_STAT_MAX, COpcodeAttributes("O_SET_NPC_STAT_MAX", "set_npc_stat_max", 2)); - SetAt(O_SET_NPC_STAT_MIN, COpcodeAttributes("O_SET_NPC_STAT_MIN", "set_npc_stat_min", 2)); - - SetAt(O_SET_FAKE_PERK, COpcodeAttributes("O_SET_FAKE_PERK", "set_fake_perk", 4)); - SetAt(O_SET_FAKE_TRAIT, COpcodeAttributes("O_SET_FAKE_TRAIT", "set_fake_trait", 4)); - SetAt(O_SET_SELECTABLE_PERK, COpcodeAttributes("O_SET_SELECTABLE_PERK", "set_selectable_perk", 4)); - SetAt(O_SET_PERKBOX_TITLE, COpcodeAttributes("O_SET_PERKBOX_TITLE", "set_perkbox_title", 1)); - SetAt(O_HIDE_REAL_PERKS, COpcodeAttributes("O_HIDE_REAL_PERKS", "hide_real_perks", 0)); - SetAt(O_SHOW_REAL_PERKS, COpcodeAttributes("O_SHOW_REAL_PERKS", "show_real_perks", 0)); - SetAt(O_HAS_FAKE_PERK, COpcodeAttributes("O_HAS_FAKE_PERK", "has_fake_perk", 1, expression)); - SetAt(O_HAS_FAKE_TRAIT, COpcodeAttributes("O_HAS_FAKE_TRAIT", "has_fake_trait", 1, expression)); - SetAt(O_PERK_ADD_MODE, COpcodeAttributes("O_PERK_ADD_MODE", "perk_add_mode", 1)); - SetAt(O_CLEAR_SELECTABLE_PERKS, COpcodeAttributes("O_CLEAR_SELECTABLE_PERKS", "clear_selectable_perks", 0)); - - SetAt(O_SET_CRITTER_HIT_CHANCE_MOD, COpcodeAttributes("O_SET_CRITTER_HIT_CHANCE_MOD", "set_critter_hit_chance_mod", 3)); - SetAt(O_SET_BASE_HIT_CHANCE_MOD, COpcodeAttributes("O_SET_BASE_HIT_CHANCE_MOD", "set_base_hit_chance_mod", 2)); - SetAt(O_SET_CRITTER_SKILL_MOD, COpcodeAttributes("O_SET_CRITTER_SKILL_MOD", "set_critter_skill_mod", 2)); - SetAt(O_SET_BASE_SKILL_MOD, COpcodeAttributes("O_SET_BASE_SKILL_MOD", "set_base_skill_mod", 1)); - SetAt(O_SET_CRITTER_PICKPOCKET_MOD, COpcodeAttributes("O_SET_CRITTER_PICKPOCKET_MOD", "set_critter_pickpocket_mod", 3)); - SetAt(O_SET_BASE_PICKPOCKET_MOD, COpcodeAttributes("O_SET_BASE_PICKPOCKET_MOD", "set_base_pickpocket_mod", 2)); - - SetAt(O_SET_PYROMANIAC_MOD, COpcodeAttributes("O_SET_PYROMANIAC_MOD", "set_pyromaniac_mod", 1)); - SetAt(O_APPLY_HEAVEHO_FIX, COpcodeAttributes("O_APPLY_HEAVEHO_FIX", "apply_heaveho_fix", 0)); - SetAt(O_SET_SWIFTLEARNER_MOD, COpcodeAttributes("O_SET_SWIFTLEARNER_MOD", "set_swiftlearner_mod", 1)); - SetAt(O_SET_HP_LEVEL_MOD, COpcodeAttributes("O_SET_HP_LEVEL_MOD", "set_hp_per_level_mod", 1)); - - SetAt(O_WRITE_BYTE, COpcodeAttributes("O_WRITE_BYTE", "write_byte", 2)); - SetAt(O_WRITE_SHORT, COpcodeAttributes("O_WRITE_SHORT", "write_short", 2)); - SetAt(O_WRITE_INT, COpcodeAttributes("O_WRITE_INT", "write_int", 2)); - - SetAt(O_CALL_OFFSET_V0, COpcodeAttributes("O_CALL_OFFSET_V0", "call_offset_v0", 1)); - SetAt(O_CALL_OFFSET_V1, COpcodeAttributes("O_CALL_OFFSET_V1", "call_offset_v1", 2)); - SetAt(O_CALL_OFFSET_V2, COpcodeAttributes("O_CALL_OFFSET_V2", "call_offset_v2", 3)); - SetAt(O_CALL_OFFSET_V3, COpcodeAttributes("O_CALL_OFFSET_V3", "call_offset_v3", 4)); - SetAt(O_CALL_OFFSET_V4, COpcodeAttributes("O_CALL_OFFSET_V4", "call_offset_v4", 5)); - SetAt(O_CALL_OFFSET_R0, COpcodeAttributes("O_CALL_OFFSET_R0", "call_offset_r0", 1, expression)); - SetAt(O_CALL_OFFSET_R1, COpcodeAttributes("O_CALL_OFFSET_R1", "call_offset_r1", 2, expression)); - SetAt(O_CALL_OFFSET_R2, COpcodeAttributes("O_CALL_OFFSET_R2", "call_offset_r2", 3, expression)); - SetAt(O_CALL_OFFSET_R3, COpcodeAttributes("O_CALL_OFFSET_R3", "call_offset_r3", 4, expression)); - SetAt(O_CALL_OFFSET_R4, COpcodeAttributes("O_CALL_OFFSET_R4", "call_offset_r4", 5, expression)); - - SetAt(O_SHOW_IFACE_TAG, COpcodeAttributes("O_SHOW_IFACE_TAG", "show_iface_tag", 1)); - SetAt(O_HIDE_IFACE_TAG, COpcodeAttributes("O_HIDE_IFACE_TAG", "hide_iface_tag", 1)); - SetAt(O_IS_IFACE_TAG_ACTIVE, COpcodeAttributes("O_IS_IFACE_TAG_ACTIVE", "is_iface_tag_active", 1, expression)); - - SetAt(O_GET_BODYPART_HIT_MODIFIER, COpcodeAttributes("O_GET_BODYPART_HIT_MODIFIER", "get_bodypart_hit_modifier", 1, expression)); - SetAt(O_SET_BODYPART_HIT_MODIFIER, COpcodeAttributes("O_SET_BODYPART_HIT_MODIFIER", "set_bodypart_hit_modifier", 2)); - - - - //1.41 - SetAt(O_SET_CRITICAL_TABLE, COpcodeAttributes("O_SET_CRITICAL_TABLE", "set_critical_table", 5)); - SetAt(O_GET_CRITICAL_TABLE, COpcodeAttributes("O_GET_CRITICAL_TABLE", "get_critical_table", 4, expression)); - SetAt(O_RESET_CRITICAL_TABLE, COpcodeAttributes("O_RESET_CRITICAL_TABLE", "reset_critical_table", 4)); - SetAt(O_GET_SFALL_ARG, COpcodeAttributes("O_GET_SFALL_ARG", "get_sfall_arg", 0, expression)); - SetAt(O_SET_SFALL_RETURN, COpcodeAttributes("O_SET_SFALL_RETURN", "set_sfall_return", 1)); - SetAt(O_SET_UNSPENT_AP_BONUS, COpcodeAttributes("O_SET_UNSPENT_AP_BONUS", "set_unspent_ap_bonus", 1)); - SetAt(O_GET_UNSPENT_AP_BONUS, COpcodeAttributes("O_GET_UNSPENT_AP_BONUS", "get_unspent_ap_bonus", 0, expression)); - SetAt(O_SET_UNSPENT_AP_PERK_BONUS, COpcodeAttributes("O_SET_UNSPENT_AP_PERK_BONUS", "set_unspent_ap_perk_bonus", 1)); - SetAt(O_GET_UNSPENT_AP_PERK_BONUS, COpcodeAttributes("O_GET_UNSPENT_AP_PERK_BONUS", "get_unspent_ap_perk_bonus", 0, expression)); - SetAt(O_INIT_HOOK, COpcodeAttributes("O_INIT_HOOK", "init_hook", 0, expression)); - SetAt(O_GET_INI_STRING, COpcodeAttributes("O_GET_INI_STRING", "get_ini_string", 1, expression)); - - //1.42 - SetAt(O_SQRT, COpcodeAttributes("O_SQRT", "sqrt", 1, expression)); - SetAt(O_ABS, COpcodeAttributes("O_ABS", "abs", 1, expression)); - SetAt(O_SIN, COpcodeAttributes("O_SIN", "sin", 1, expression)); - SetAt(O_COS, COpcodeAttributes("O_COS", "cos", 1, expression)); - SetAt(O_TAN, COpcodeAttributes("O_TAN", "tan", 1, expression)); - SetAt(O_ARCTAN, COpcodeAttributes("O_ARCTAN", "arctan", 2, expression)); - SetAt(O_SET_PALETTE, COpcodeAttributes("O_SET_PALETTE", "set_palette", 1)); - - //1.46b - SetAt(O_REMOVE_SCRIPT, COpcodeAttributes("O_REMOVE_SCRIPT", "remove_script", 1)); - SetAt(O_SET_SCRIPT, COpcodeAttributes("O_SET_SCRIPT", "set_script", 2)); - SetAt(O_GET_SCRIPT, COpcodeAttributes("O_GET_SCRIPT", "get_script", 1, expression)); - SetAt(O_NB_CREATE_CHAR, COpcodeAttributes("O_NB_CREATE_CHAR", "nb_create_char", 0, expression)); - SetAt(O_FS_CREATE, COpcodeAttributes("O_FS_CREATE", "fs_create", 2, expression)); - SetAt(O_FS_COPY, COpcodeAttributes("O_FS_COPY", "fs_copy", 2, expression)); - SetAt(O_FS_FIND, COpcodeAttributes("O_FS_FIND", "fs_find", 1, expression)); - SetAt(O_FS_WRITE_BYTE, COpcodeAttributes("O_FS_WRITE_BYTE", "fs_write_byte", 2)); - SetAt(O_FS_WRITE_SHORT, COpcodeAttributes("O_FS_WRITE_SHORT", "fs_write_short", 2)); - SetAt(O_FS_WRITE_INT, COpcodeAttributes("O_FS_WRITE_INT", "fs_write_int", 2)); - SetAt(O_FS_WRITE_FLOAT, COpcodeAttributes("O_FS_WRITE_FLOAT", "fs_write_float", 2)); - SetAt(O_FS_WRITE_STRING,COpcodeAttributes("O_FS_WRITE_STRING","fs_write_string",2)); - SetAt(O_FS_DELETE, COpcodeAttributes("O_FS_DELETE", "fs_delete", 1)); - SetAt(O_FS_SIZE, COpcodeAttributes("O_FS_SIZE", "fs_size", 1, expression)); - SetAt(O_FS_POS, COpcodeAttributes("O_FS_POS", "fs_pos", 1, expression)); - SetAt(O_FS_SEEK, COpcodeAttributes("O_FS_SEEK", "fs_seek", 2)); - SetAt(O_FS_RESIZE, COpcodeAttributes("O_FS_RESIZE", "fs_resize", 2)); - SetAt(O_GET_PROTO_DATA, COpcodeAttributes("O_GET_PROTO_DATA", "get_proto_data", 2, expression)); - - //1.47b - SetAt(O_SET_PROTO_DATA, COpcodeAttributes("O_SET_PROTO_DATA", "set_proto_data", 3)); - SetAt(O_SET_SELF, COpcodeAttributes("O_SET_SELF", "set_self", 1)); - SetAt(O_REGISTER_HOOK, COpcodeAttributes("O_REGISTER_HOOK", "register_hook", 1)); - - SetAt(O_FS_WRITE_BSTRING, COpcodeAttributes("O_FS_WRITE_BSTRING", "fs_write_bstring", 2)); - SetAt(O_FS_READ_BYTE, COpcodeAttributes("O_FS_READ_BYTE", "fs_read_byte", 1, expression)); - SetAt(O_FS_READ_SHORT, COpcodeAttributes("O_FS_READ_SHORT", "fs_read_short", 1, expression)); - SetAt(O_FS_READ_INT, COpcodeAttributes("O_FS_READ_INT", "fs_read_int", 1, expression)); - SetAt(O_FS_READ_FLOAT, COpcodeAttributes("O_FS_READ_FLOAT", "fs_read_float", 1, expression)); - - - SetAt(O_LIST_BEGIN, COpcodeAttributes("O_LIST_BEGIN", "list_begin", 1, expression)); - SetAt(O_LIST_NEXT, COpcodeAttributes("O_LIST_NEXT", "list_next", 1, expression)); - SetAt(O_LIST_END, COpcodeAttributes("O_LIST_END", "list_end", 1)); - - //1.49d - SetAt(O_SFALL_VER_MAJOR, COpcodeAttributes("O_SFALL_VER_MAJOR", "sfall_ver_major", 0, expression)); - SetAt(O_SFALL_VER_MINOR, COpcodeAttributes("O_SFALL_VER_MINOR", "sfall_ver_minor", 0, expression)); - SetAt(O_SFALL_VER_BUILD, COpcodeAttributes("O_SFALL_VER_BUILD", "sfall_ver_build", 0, expression)); - - SetAt(O_HERO_SELECT_WIN, COpcodeAttributes("O_HERO_SELECT_WIN", "hero_select_win", 1)); - SetAt(O_SET_HERO_RACE, COpcodeAttributes("O_SET_HERO_RACE", "set_hero_race", 1)); - SetAt(O_SET_HERO_STYLE, COpcodeAttributes("O_SET_HERO_STYLE", "set_hero_style", 1)); - - SetAt(O_SET_CRITTER_BURST_DISABLE, COpcodeAttributes("O_SET_CRITTER_BURST_DISABLE", "set_critter_burst_disable", 2)); - - - - SetAt(O_GET_WEAPON_AMMO_PID, COpcodeAttributes("O_GET_WEAPON_AMMO_PID", "get_weapon_ammo_pid", 1, expression)); - SetAt(O_SET_WEAPON_AMMO_PID, COpcodeAttributes("O_SET_WEAPON_AMMO_PID", "set_weapon_ammo_pid", 2)); - SetAt(O_GET_WEAPON_AMMO_COUNT, COpcodeAttributes("O_GET_WEAPON_AMMO_COUNT", "get_weapon_ammo_count", 1, expression)); - SetAt(O_SET_WEAPON_AMMO_COUNT, COpcodeAttributes("O_SET_WEAPON_AMMO_COUNT", "set_weapon_ammo_count", 2)); - SetAt(O_WRITE_STRING, COpcodeAttributes("O_WRITE_STRING", "write_String", 2)); - SetAt(O_GET_MOUSE_X, COpcodeAttributes("O_GET_MOUSE_X", "get_mouse_x", 0, expression)); - SetAt(O_GET_MOUSE_Y, COpcodeAttributes("O_GET_MOUSE_Y", "get_mouse_y", 0, expression)); - SetAt(O_GET_MOUSE_BUTTONS, COpcodeAttributes("O_GET_MOUSE_BUTTONS", "get_mouse_buttons", 0, expression)); - SetAt(O_GET_WINDOW_UNDER_MOUSE, COpcodeAttributes("O_GET_WINDOW_UNDER_MOUSE", "get_window_under_mouse", 0, expression)); - SetAt(O_GET_SCREEN_WIDTH, COpcodeAttributes("O_GET_SCREEN_WIDTH", "get_screen_width", 0, expression)); - SetAt(O_GET_SCREEN_HEIGHT, COpcodeAttributes("O_GET_SCREEN_HEIGHT", "get_screen_height", 0, expression)); - SetAt(O_STOP_GAME, COpcodeAttributes("O_STOP_GAME", "stop_game", 0)); - SetAt(O_RESUME_GAME, COpcodeAttributes("O_RESUME_GAME", "resume_game", 0)); - SetAt(O_CREATE_MESSAGE_WINDOW, COpcodeAttributes("O_CREATE_MESSAGE_WINDOW", "create_message_window", 1)); - SetAt(O_REMOVE_TRAIT, COpcodeAttributes("O_REMOVE_TRAIT", "remove_trait", 1)); - SetAt(O_GET_LIGHT_LEVEL, COpcodeAttributes("O_GET_LIGHT_LEVEL", "get_light_level", 0, expression)); - SetAt(O_REFRESH_PC_ART, COpcodeAttributes("O_REFRESH_PC_ART", "refresh_pc_art", 0)); - SetAt(O_GET_ATTACK_TYPE, COpcodeAttributes("O_GET_ATTACK_TYPE", "get_attack_type", 0, expression)); - SetAt(O_FORCE_ENCOUNTER_WITH_FLAGS, COpcodeAttributes("O_FORCE_ENCOUNTER_WITH_FLAGS", "force_encounter_with_flags", 2)); - SetAt(O_SET_MAP_TIME_MULTI, COpcodeAttributes("O_SET_MAP_TIME_MULTI", "set_map_time_multi", 1)); - SetAt(O_PLAY_SFALL_SOUND, COpcodeAttributes("O_PLAY_SFALL_SOUND", "play_sfall_sound", 2, expression)); - SetAt(O_STOP_SFALL_SOUND, COpcodeAttributes("O_STOP_SFALL_SOUND", "stop_sfall_sound", 1)); - SetAt(O_CREATE_ARRAY, COpcodeAttributes("O_CREATE_ARRAY", "create_array", 2, expression)); - SetAt(O_SET_ARRAY, COpcodeAttributes("O_SET_ARRAY", "set_array", 3)); - SetAt(O_GET_ARRAY, COpcodeAttributes("O_GET_ARRAY", "get_array", 2, expression)); - SetAt(O_FREE_ARRAY, COpcodeAttributes("O_FREE_ARRAY", "free_array", 1)); - - //sfall vrs 2.8 - SetAt(O_TS_LEN_ARRAY, COpcodeAttributes("O_TS_LEN_ARRAY", "len_array", 1, expression)); - SetAt(O_TS_RESIZE_ARRAY, COpcodeAttributes("O_TS_RESIZE_ARRAY", "resize_array", 2)); - SetAt(O_TS_TEMP_ARRAY, COpcodeAttributes("O_TS_TEMP_ARRAY", "temp_array", 2, expression)); - SetAt(O_TS_FIX_ARRAY, COpcodeAttributes("O_TS_FIX_ARRAY", "fix_array", 1)); - SetAt(O_TS_STRING_SPLIT, COpcodeAttributes("O_TS_STRING_SPLIT", "string_split", 2, expression)); - SetAt(O_TS_LIST_AS_ARRAY, COpcodeAttributes("O_TS_LIST_AS_ARRAY", "list_as_array", 1, expression)); - - // sfall 2.8b - SetAt(O_TS_ATOI, COpcodeAttributes("O_TS_ATOI", "atoi", 1, expression)); - SetAt(O_TS_ATOF, COpcodeAttributes("O_TS_ATOF", "atof", 1, expression)); - - // sfall 2.9a - SetAt(O_TS_SCAN_ARRAY, COpcodeAttributes("O_TS_SCAN_ARRAY", "scan_array", 2, expression)); - SetAt(O_TS_TILE_PID, COpcodeAttributes("O_TS_TILE_PID", "get_tile_fid", 1, expression)); - SetAt(O_TS_MODIFIED_INI, COpcodeAttributes("O_TS_MODIFIED_INI", "modified_ini", 0, expression)); - SetAt(O_TS_GET_SFALL_ARGS, COpcodeAttributes("O_TS_GET_SFALL_ARGS", "get_sfall_args", 0, expression)); - - // sfall 2.12 - SetAt(O_TS_SET_SFALL_ARG, COpcodeAttributes("O_TS_GET_SFALL_ARG", "set_sfall_arg", 2)); - - // sfall 2.16 - SetAt(O_TS_FORCE_AIMED_SHOTS, COpcodeAttributes("O_TS_FORCE_AIMED_SHOTS", "force_aimed_shots", 1)); - SetAt(O_TS_DISABLE_AIMED_SHOTS, COpcodeAttributes("O_TS_DISABLE_AIMED_SHOTS", "disable_aimed_shots", 1)); - SetAt(O_TS_MARK_MOVIE_PLAYED, COpcodeAttributes("O_TS_MARK_MOVIE_PLAYED", "mark_movie_played", 1)); - - // sfall 2.17 - SetAt(O_TS_GET_NPC_LEVEL, COpcodeAttributes("O_TS_GET_NPC_LEVEL", "get_npc_level", 1, expression)); - - // sfall 3.0 - SetAt(O_TS_SET_CRITTER_SKILL_POINTS, COpcodeAttributes("O_TS_SET_CRITTER_SKILL_POINTS", "set_critter_skill_points", 3)); - SetAt(O_TS_GET_CRITTER_SKILL_POINTS, COpcodeAttributes("O_TS_GET_CRITTER_SKILL_POINTS", "get_critter_skill_points", 2, expression)); - SetAt(O_TS_SET_AVAILABLE_SKILL_POINTS, COpcodeAttributes("O_TS_SET_AVAILABLE_SKILL_POINTS", "set_available_skill_points", 1)); - SetAt(O_TS_GET_AVAILABLE_SKILL_POINTS, COpcodeAttributes("O_TS_GET_AVAILABLE_SKILL_POINTS", "get_available_skill_points", 0, expression)); - SetAt(O_TS_MOD_SKILL_POINTS_PER_LEVEL, COpcodeAttributes("O_TS_MOD_SKILL_POINTS_PER_LEVEL", "mod_skill_points_per_level", 1)); - SetAt(O_TS_SET_PERK_FREQ, COpcodeAttributes("O_TS_SET_PERK_FREQ", "set_perk_freq", 1)); - SetAt(O_TS_GET_LAST_TARGET, COpcodeAttributes("O_TS_GET_LAST_TARGET", "get_last_attacker", 1, expression)); - SetAt(O_TS_GET_LAST_ATTACKER, COpcodeAttributes("O_TS_GET_LAST_ATTACKER", "get_last_target", 1, expression)); - SetAt(O_TS_BLOCK_COMBAT, COpcodeAttributes("O_TS_BLOCK_COMBAT", "block_combat", 1)); - - // sfall 3.3 - SetAt(O_TS_TILE_UNDER_CURSOR, COpcodeAttributes("O_TS_TILE_UNDER_CURSOR", "tile_under_cursor", 0, expression)); - SetAt(O_TS_GET_BARTER_MOD, COpcodeAttributes("O_TS_GET_BARTER_MOD", "gdialog_get_barter_mod", 0, expression)); - SetAt(O_TS_SET_INVEN_AP_COST, COpcodeAttributes("O_TS_SET_INVEN_AP_COST", "set_inven_ap_cost", 1)); - - // sfall 3.4 - SetAt(O_TS_SUBSTR, COpcodeAttributes("O_TS_SUBSTR", "substr", 3, expression)); - SetAt(O_TS_STRLEN, COpcodeAttributes("O_TS_STRLEN", "strlen", 1, expression)); - SetAt(O_TS_SPRINTF, COpcodeAttributes("O_TS_SPRINTF", "sprintf", 2, expression)); - SetAt(O_TS_ORD, COpcodeAttributes("O_TS_ORD", "charcode", 1, expression)); // sfall 3.5 - //SetAt(O_TS_RESERVD2, COpcodeAttributes("O_TS_RESERVD2", "substr", 3, expression)); - SetAt(O_TS_TYPEOF, COpcodeAttributes("O_TS_TYPEOF", "typeof", 1, expression)); - SetAt(O_TS_LOG, COpcodeAttributes("O_TS_LOG", "log", 1, expression)); // sfall 3.5 - SetAt(O_TS_EXP, COpcodeAttributes("O_TS_EXP", "exponent", 1, expression)); // sfall 3.5 - //SetAt(O_TS_CEIL, COpcodeAttributes("O_TS_CEIL", "ceil", 1, expression)); - SetAt(O_TS_ROUND, COpcodeAttributes("O_TS_ROUND", "round", 1, expression)); // sfall 3.5 - SetAt(O_TS_SAVE_ARRAY, COpcodeAttributes("O_TS_SAVE_ARRAY", "save_array", 2)); - SetAt(O_TS_LOAD_ARRAY, COpcodeAttributes("O_TS_LOAD_ARRAY", "load_array", 1, expression)); - SetAt(O_TS_GET_ARRAY_KEY, COpcodeAttributes("O_TS_GET_ARRAY_KEY", "array_key", 2, expression)); - SetAt(O_TS_STACK_ARRAY, COpcodeAttributes("O_TS_STACK_ARRAY", "arrayexpr", 2, expression)); - - SetAt(O_TS_REG_ANIM_DESTROY, COpcodeAttributes("O_TS_REG_ANIM_DESTROY", "reg_anim_destroy", 1)); - SetAt(O_TS_REG_ANIM_ANIMATE_AND_HIDE, COpcodeAttributes("O_TS_REG_ANIM_ANIMATE_AND_HIDE", "reg_anim_animate_and_hide", 3)); - SetAt(O_TS_REG_ANIM_COMBAT_CHECK, COpcodeAttributes("O_TS_REG_ANIM_COMBAT_CHECK", "reg_anim_combat_check", 1)); - SetAt(O_TS_REG_ANIM_LIGHT, COpcodeAttributes("O_TS_REG_ANIM_LIGHT", "reg_anim_light", 3)); - SetAt(O_TS_REG_ANIM_CHANGE_FID, COpcodeAttributes("O_TS_REG_ANIM_CHANGE_FID", "reg_anim_change_fid", 3)); - SetAt(O_TS_REG_ANIM_TAKE_OUT, COpcodeAttributes("O_TS_REG_ANIM_TAKE_OUT", "reg_anim_take_out", 3)); - SetAt(O_TS_REG_ANIM_TURN_TOWARDS, COpcodeAttributes("O_TS_REG_ANIM_TURN_TOWARDS", "reg_anim_turn_towards", 3)); - - SetAt(O_TS_EXPLOSIONS_METARULE, COpcodeAttributes("O_TS_EXPLOSIONS_METARULE", "metarule2_explosions", 3, expression)); - - // sfall 3.5 - SetAt(O_TS_REGISTER_HOOK_PROC, COpcodeAttributes("O_TS_REGISTER_HOOK_PROC", "register_hook_proc", 2, COpcodeAttributes::TYPE_STATEMENT, COpcodeAttributes::CATEGORY_PREFIX, procArgs_register_hook_proc, 1)); - SetAt(O_TS_POW, COpcodeAttributes("O_POW", "^", 2, expression, infix)); - SetAt(O_TS_MESSAGE_STR_GAME, COpcodeAttributes("O_TS_MESSAGE_STR_GAME", "message_str_game", 2, expression)); - SetAt(O_TS_SNEAK_SUCCESS, COpcodeAttributes("O_TS_SNEAK_SUCCESS", "sneak_success", 0, expression)); - SetAt(O_TS_TILE_LIGHT, COpcodeAttributes("O_TS_SNEAK_SUCCESS", "tile_light", 2, expression)); - SetAt(O_TS_MAKE_STRAIGHT_PATH, COpcodeAttributes("O_TS_MAKE_STRAIGHT_PATH", "obj_blocking_line", 3, expression)); - SetAt(O_TS_OBJ_BLOCKING_AT, COpcodeAttributes("O_TS_OBJ_BLOCKING_AT", "obj_blocking_tile", 3, expression)); - SetAt(O_TS_TILE_GET_OBJECTS, COpcodeAttributes("O_TS_TILE_GET_OBJECTS", "tile_get_objs", 2, expression)); - SetAt(O_TS_GET_PARTY_MEMBERS, COpcodeAttributes("O_TS_GET_PARTY_MEMBERS", "party_member_list", 1, expression)); - SetAt(O_TS_PATH_FIND, COpcodeAttributes("O_TS_PATH_FIND", "path_find_to", 3, expression)); - SetAt(O_TS_CREATE_SPATIAL, COpcodeAttributes("O_TS_CREATE_SPATIAL", "create_spatial", 4, expression)); - SetAt(O_TS_ART_EXISTS, COpcodeAttributes("O_TS_ART_EXISTS", "art_exists", 1, expression)); - SetAt(O_TS_OBJ_IS_CARRYING_OBJ, COpcodeAttributes("O_TS_OBJ_IS_CARRYING_OBJ", "obj_is_carrying_obj", 2, expression)); - //sfall end - - SetAt(O_STRINGOP, COpcodeAttributes("O_STRINGOP", "", 0, expression)); - SetAt(O_FLOATOP, COpcodeAttributes("O_FLOATOP", "", 0, expression)); - SetAt(O_INTOP, COpcodeAttributes("O_INTOP", "", 0, expression)); + COpcode::COpcodeAttributes::Type expression = COpcode::COpcodeAttributes::TYPE_EXPRESSION; + COpcode::COpcodeAttributes::Category infix = COpcode::COpcodeAttributes::CATEGORY_INFIX; + + InitHashTable(512); + + SetAt(O_NOOP, COpcodeAttributes("O_NOOP", "/* O_NOOP */", 0)); + SetAt(O_CONST, COpcodeAttributes("O_CONST", "/* O_CONST */", 0)); + SetAt(O_CRITICAL_START, COpcodeAttributes("O_CRITICAL_START", "/* O_CRITICAL_START */", 0)); + SetAt(O_CRITICAL_DONE, COpcodeAttributes("O_CRITICAL_DONE", "/* O_CRITICAL_START */", 0)); + SetAt(O_JMP, COpcodeAttributes("O_JMP", "// O_JMP ", 1)); + SetAt(O_CALL, COpcodeAttributes("O_CALL", "/* O_CALL */", 0, expression)); + SetAt(O_CALL_AT, COpcodeAttributes("O_CALL_AT", "/* O_CALL_AT */", 2)); + SetAt(O_CALL_CONDITION, COpcodeAttributes("O_CALL_CONDITION", "/* O_CALL_CONDITION */", 2)); + SetAt(O_CALLSTART, COpcodeAttributes("O_CALLSTART", "callStart", 1)); + SetAt(O_EXEC, COpcodeAttributes("O_EXEC", "exec", 1)); + SetAt(O_SPAWN, COpcodeAttributes("O_SPAWN", "spawn", 1)); + SetAt(O_FORK, COpcodeAttributes("O_FORK", "fork", 1)); + SetAt(O_A_TO_D, COpcodeAttributes("O_A_TO_D", "/* O_A_TO_D */", 0)); + SetAt(O_D_TO_A, COpcodeAttributes("O_D_TO_A", "/* O_D_TO_A */", 0)); + SetAt(O_EXIT, COpcodeAttributes("O_EXIT", "exit", 0)); + SetAt(O_DETACH, COpcodeAttributes("O_DETACH", "detach", 0)); + SetAt(O_EXIT_PROG, COpcodeAttributes("O_EXIT_PROG", "/* O_EXIT_PROG */", 0)); + SetAt(O_STOP_PROG, COpcodeAttributes("O_STOP_PROG", "/* O_STOP_PROG */", 0)); + SetAt(O_FETCH_GLOBAL, COpcodeAttributes("O_FETCH_GLOBAL", "/* O_FETCH_GLOBAL */", 1, expression)); + SetAt(O_STORE_GLOBAL, COpcodeAttributes("O_STORE_GLOBAL", ":=", 2)); + SetAt(O_FETCH_EXTERNAL, COpcodeAttributes("O_FETCH_EXTERNAL", "/* O_FETCH_EXTERNAL */", 1, expression)); + SetAt(O_STORE_EXTERNAL, COpcodeAttributes("O_STORE_EXTERNAL", ":=", 2)); + SetAt(O_EXPORT_VAR, COpcodeAttributes("O_EXPORT_VAR", "/* O_EXPORT_VAR */", 0)); + SetAt(O_EXPORT_PROC, COpcodeAttributes("O_EXPORT_PROC", "/* O_EXPORT_PROC */", 0)); + SetAt(O_SWAP, COpcodeAttributes("O_SWAP", "/* O_SWAP */", 0)); + SetAt(O_SWAPA, COpcodeAttributes("O_SWAPA", "/* O_SWAPA */", 0)); + SetAt(O_POP, COpcodeAttributes("O_POP", "/* O_POP */", 1)); + SetAt(O_DUP, COpcodeAttributes("O_DUP", "/* O_DUP */", 0)); + SetAt(O_POP_RETURN, COpcodeAttributes("O_POP_RETURN", "return", 1)); + SetAt(O_POP_EXIT, COpcodeAttributes("O_POP_EXIT", "/* O_POP_EXIT */", 0)); + SetAt(O_POP_ADDRESS, COpcodeAttributes("O_POP_ADDRESS", "/* O_POP_ADDRESS */", 0)); + SetAt(O_POP_FLAGS, COpcodeAttributes("O_POP_FLAGS", "/* O_POP_FLAGS */", 0)); + SetAt(O_POP_FLAGS_RETURN, COpcodeAttributes("O_POP_FLAGS_RETURN", "/* O_POP_FLAGS_RETURN */", 0)); + SetAt(O_POP_FLAGS_EXIT, COpcodeAttributes("O_POP_FLAGS_EXIT", "/* O_POP_FLAGS_EXIT */", 0)); + SetAt(O_POP_FLAGS_RETURN_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_EXTERN", "/* O_POP_FLAGS_RETURN_EXTERN */", 0)); + SetAt(O_POP_FLAGS_EXIT_EXTERN, COpcodeAttributes("O_POP_FLAGS_EXIT_EXTERN", "/* O_POP_FLAGS_EXIT_EXTERN */", 0)); + SetAt(O_POP_FLAGS_RETURN_VAL_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXTERN", "/* O_POP_FLAGS_RETURN_VAL_EXTERN */", 0)); + SetAt(O_POP_FLAGS_RETURN_VAL_EXIT, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXIT", "/* O_POP_FLAGS_RETURN_VAL_EXIT */", 0)); + SetAt(O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, COpcodeAttributes("O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN", "/* O_POP_FLAGS_RETURN_VAL_EXIT_EXTERN */", 0)); + SetAt(O_CHECK_ARG_COUNT, COpcodeAttributes("O_CHECK_ARG_COUNT", "/* O_CHECK_ARG_COUNT */", 0)); + SetAt(O_LOOKUP_STRING_PROC, COpcodeAttributes("O_LOOKUP_STRING_PROC", "/* O_LOOKUP_STRING_PROC */", 1, expression)); + SetAt(O_POP_BASE, COpcodeAttributes("O_POP_BASE", "/* O_POP_BASE */", 0)); + SetAt(O_POP_TO_BASE, COpcodeAttributes("O_POP_TO_BASE", "/* O_POP_TO_BASE */", 0)); + SetAt(O_PUSH_BASE, COpcodeAttributes("O_PUSH_BASE", "/* O_PUSH_BASE */", 0)); + SetAt(O_SET_GLOBAL, COpcodeAttributes("O_SET_GLOBAL", "/* O_SET_GLOBAL */", 0)); + SetAt(O_FETCH_PROC_ADDRESS, COpcodeAttributes("O_FETCH_PROC_ADDRESS", "/* O_FETCH_PROC_ADDRESS */", 0)); + SetAt(O_DUMP, COpcodeAttributes("O_DUMP", "/* O_DUMP */", 0)); + SetAt(O_IF, COpcodeAttributes("O_IF", "if", 2)); + SetAt(O_WHILE, COpcodeAttributes("O_WHILE", "while", 2)); + SetAt(O_STORE, COpcodeAttributes("O_STORE", ":=", 2)); + SetAt(O_FETCH, COpcodeAttributes("O_FETCH", "/* O_FETCH */", 1, expression)); + SetAt(O_EQUAL, COpcodeAttributes("O_EQUAL", "==", 2, expression, infix)); + SetAt(O_NOT_EQUAL, COpcodeAttributes("O_NOT_EQUAL", "!=", 2, expression, infix)); + SetAt(O_LESS_EQUAL, COpcodeAttributes("O_LESS_EQUAL", "<=", 2, expression, infix)); + SetAt(O_GREATER_EQUAL, COpcodeAttributes("O_GREATER_EQUAL", ">=", 2, expression, infix)); + SetAt(O_LESS, COpcodeAttributes("O_LESS", "<", 2, expression, infix)); + SetAt(O_GREATER, COpcodeAttributes("O_GREATER", ">", 2, expression, infix)); + SetAt(O_ADD, COpcodeAttributes("O_ADD", "+", 2, expression, infix)); + SetAt(O_SUB, COpcodeAttributes("O_SUB", "-", 2, expression, infix)); + SetAt(O_MUL, COpcodeAttributes("O_MUL", "*", 2, expression, infix)); + SetAt(O_DIV, COpcodeAttributes("O_DIV", "/", 2, expression, infix)); + SetAt(O_MOD, COpcodeAttributes("O_MOD", "%", 2, expression, infix)); + SetAt(O_AND, COpcodeAttributes("O_AND", "and", 2, expression, infix)); + SetAt(O_OR, COpcodeAttributes("O_OR", "or", 2, expression, infix)); + SetAt(O_BWAND, COpcodeAttributes("O_BWAND", "bwand", 2, expression, infix)); + SetAt(O_BWOR, COpcodeAttributes("O_BWOR", "bwor", 2, expression, infix)); + SetAt(O_BWXOR, COpcodeAttributes("O_BWXOR", "bwxor", 2, expression, infix)); + SetAt(O_BWNOT, COpcodeAttributes("O_BWNOT", "bwnot", 1, expression)); + SetAt(O_FLOOR, COpcodeAttributes("O_FLOOR", "floor", 1, expression)); + SetAt(O_NOT, COpcodeAttributes("O_NOT", "not", 1, expression)); + SetAt(O_NEGATE, COpcodeAttributes("O_NEGATE", "-", 1, expression)); + SetAt(O_WAIT, COpcodeAttributes("O_WAIT", "wait", 1)); + SetAt(O_CANCEL, COpcodeAttributes("O_CANCEL", "cancel", 1)); + SetAt(O_CANCELALL, COpcodeAttributes("O_CANCELALL", "cancelAll", 0)); + SetAt(O_STARTCRITICAL, COpcodeAttributes("O_STARTCRITICAL", "startCritical", 0)); + SetAt(O_ENDCRITICAL, COpcodeAttributes("O_ENDCRITICAL", "endCritical", 0)); + SetAt(O_SAYQUIT, COpcodeAttributes("O_SAYQUIT", "sayQuit", 0)); + SetAt(O_SAYEND, COpcodeAttributes("O_SAYEND", "sayEnd", 0)); + SetAt(O_SAYSTART, COpcodeAttributes("O_SAYSTART", "sayStart", 0)); + SetAt(O_SAYSTARTPOS, COpcodeAttributes("O_SAYSTARTPOS", "sayStartPos", 1)); + SetAt(O_SAYREPLYTITLE, COpcodeAttributes("O_SAYREPLYTITLE", "sayReplyTitle", 1)); + SetAt(O_SAYGOTOREPLY, COpcodeAttributes("O_SAYGOTOREPLY", "sayGotoReply", 1)); + SetAt(O_SAYREPLY, COpcodeAttributes("O_SAYREPLY", "sayReply", 2)); + SetAt(O_SAYOPTION, COpcodeAttributes("O_SAYOPTION", "sayOption", 2)); + SetAt(O_SAYMESSAGE, COpcodeAttributes("O_SAYMESSAGE", "sayMessage", 2)); + SetAt(O_SAYREPLYWINDOW, COpcodeAttributes("O_SAYREPLYWINDOW", "sayReplyWindow", 5)); + SetAt(O_SAYOPTIONWINDOW, COpcodeAttributes("O_SAYOPTIONWINDOW", "sayOptionWindow", 5)); + SetAt(O_SAYBORDER, COpcodeAttributes("O_SAYBORDER", "sayBorder", 2)); + SetAt(O_SAYSCROLLUP, COpcodeAttributes("O_SAYSCROLLUP", "sayScrollUp", 6)); + SetAt(O_SAYSCROLLDOWN, COpcodeAttributes("O_SAYSCROLLDOWN", "sayScrollDown", 6)); + SetAt(O_SAYSETSPACING, COpcodeAttributes("O_SAYSETSPACING", "saySetSpacing", 1)); + SetAt(O_SAYOPTIONCOLOR, COpcodeAttributes("O_SAYOPTIONCOLOR", "sayOptionColor", 3)); + SetAt(O_SAYREPLYCOLOR, COpcodeAttributes("O_SAYREPLYCOLOR", "sayReplyColor", 3)); + SetAt(O_SAYRESTART, COpcodeAttributes("O_SAYRESTART", "sayRestart", 0)); + SetAt(O_SAYGETLASTPOS, COpcodeAttributes("O_SAYGETLASTPOS", "sayGetLastPos", 0, expression)); + SetAt(O_SAYREPLYFLAGS, COpcodeAttributes("O_SAYREPLYFLAGS", "sayReplyFlags", 1)); + SetAt(O_SAYOPTIONFLAGS, COpcodeAttributes("O_SAYOPTIONFLAGS", "sayOptionFlags", 1)); + SetAt(O_SAYMESSAGETIMEOUT, COpcodeAttributes("O_SAYMESSAGETIMEOUT", "sayMessageTimeout", 1)); + SetAt(O_CREATEWIN, COpcodeAttributes("O_CREATEWIN", "createWin", 5)); + SetAt(O_DELETEWIN, COpcodeAttributes("O_DELETEWIN", "deleteWin", 1)); + SetAt(O_SELECTWIN, COpcodeAttributes("O_SELECTWIN", "selectWin", 1)); + SetAt(O_RESIZEWIN, COpcodeAttributes("O_RESIZEWIN", "resizeWin", 5)); + SetAt(O_SCALEWIN, COpcodeAttributes("O_SCALEWIN", "scaleWin", 5)); + SetAt(O_SHOWWIN, COpcodeAttributes("O_SHOWWIN", "showWin", 0)); + SetAt(O_FILLWIN, COpcodeAttributes("O_FILLWIN", "fillWin", 3)); + SetAt(O_FILLRECT, COpcodeAttributes("O_FILLRECT", "fillRect", 7)); + SetAt(O_FILLWIN3X3, COpcodeAttributes("O_FILLWIN3X3", "fillWin3x3", 1)); + SetAt(O_DISPLAY, COpcodeAttributes("O_DISPLAY", "display", 1)); + SetAt(O_DISPLAYGFX, COpcodeAttributes("O_DISPLAYGFX", "displayGfx", 5)); + SetAt(O_DISPLAYRAW, COpcodeAttributes("O_DISPLAYRAW", "displayRaw", 1)); + SetAt(O_LOADPALETTETABLE, COpcodeAttributes("O_LOADPALETTETABLE", "loadPaletteTable", 1)); + SetAt(O_FADEIN, COpcodeAttributes("O_FADEIN", "fadeIn", 1)); + SetAt(O_FADEOUT, COpcodeAttributes("O_FADEOUT", "fadeOut", 1)); + SetAt(O_GOTOXY, COpcodeAttributes("O_GOTOXY", "gotoXY", 2)); + SetAt(O_PRINT, COpcodeAttributes("O_PRINT", "print", 1)); + SetAt(O_FORMAT, COpcodeAttributes("O_FORMAT", "format", 6)); + SetAt(O_PRINTRECT, COpcodeAttributes("O_PRINTRECT", "printRect", 3)); + SetAt(O_SETFONT, COpcodeAttributes("O_SETFONT", "setFont", 1)); + SetAt(O_SETTEXTFLAGS, COpcodeAttributes("O_SETTEXTFLAGS", "setTextFlags", 1)); + SetAt(O_SETTEXTCOLOR, COpcodeAttributes("O_SETTEXTCOLOR", "setTextColor", 3)); + SetAt(O_SETHIGHLIGHTCOLOR, COpcodeAttributes("O_SETHIGHLIGHTCOLOR", "setHighlightColor", 3)); + SetAt(O_STOPMOVIE, COpcodeAttributes("O_STOPMOVIE", "stopMovie", 0)); + SetAt(O_PLAYMOVIE, COpcodeAttributes("O_PLAYMOVIE", "playMovie", 1)); + SetAt(O_MOVIEFLAGS, COpcodeAttributes("O_MOVIEFLAGS", "movieFlags", 1)); + SetAt(O_PLAYMOVIERECT, COpcodeAttributes("O_PLAYMOVIERECT", "playMovieRect", 5)); + SetAt(O_PLAYMOVIEALPHA, COpcodeAttributes("O_PLAYMOVIEALPHA", "playmoviealpha", 2)); + SetAt(O_PLAYMOVIEALPHARECT, COpcodeAttributes("O_PLAYMOVIEALPHARECT", "playMovieAlphaRect", 6)); + SetAt(O_ADDREGION, COpcodeAttributes("O_ADDREGION", "addRegion", 5, expression)); + SetAt(O_ADDREGIONFLAG, COpcodeAttributes("O_ADDREGIONFLAG", "addRegionFlag", 2)); + SetAt(O_ADDREGIONPROC, COpcodeAttributes("O_ADDREGIONPROC", "addRegionProc", 5)); + SetAt(O_ADDREGIONRIGHTPROC, COpcodeAttributes("O_ADDREGIONRIGHTPROC", "addRegionRightProc", 3)); + SetAt(O_DELETEREGION, COpcodeAttributes("O_DELETEREGION", "deleteRegion", 1)); + SetAt(O_ACTIVATEREGION, COpcodeAttributes("O_ACTIVATEREGION", "activateRegion", 2)); + SetAt(O_CHECKREGION, COpcodeAttributes("O_CHECKREGION", "checkRegion", 1, expression)); + SetAt(O_ADDBUTTON, COpcodeAttributes("O_ADDBUTTON", "addButton", 5)); + SetAt(O_ADDBUTTONTEXT, COpcodeAttributes("O_ADDBUTTONTEXT", "addButtonText", 2)); + SetAt(O_ADDBUTTONFLAG, COpcodeAttributes("O_ADDBUTTONFLAG", "addButtonFlag", 2)); + SetAt(O_ADDBUTTONGFX, COpcodeAttributes("O_ADDBUTTONGFX", "addButtonGfx", 4)); + SetAt(O_ADDBUTTONPROC, COpcodeAttributes("O_ADDBUTTONPROC", "addButtonProc", 5)); + SetAt(O_ADDBUTTONRIGHTPROC, COpcodeAttributes("O_ADDBUTTONRIGHTPROC", "addButtonRightProc", 3)); + SetAt(O_DELETEBUTTON, COpcodeAttributes("O_DELETEBUTTON", "deleteButton", 1)); + SetAt(O_HIDEMOUSE, COpcodeAttributes("O_HIDEMOUSE", "hideMouse", 0)); + SetAt(O_SHOWMOUSE, COpcodeAttributes("O_SHOWMOUSE", "showMouse", 0)); + SetAt(O_MOUSESHAPE, COpcodeAttributes("O_MOUSESHAPE", "mouseShape", 3)); + SetAt(O_REFRESHMOUSE, COpcodeAttributes("O_REFRESHMOUSE", "refreshMouse", 1)); + SetAt(O_SETGLOBALMOUSEFUNC, COpcodeAttributes("O_SETGLOBALMOUSEFUNC", "setGlobalMouseFunc", 4)); + SetAt(O_ADDNAMEDEVENT, COpcodeAttributes("O_ADDNAMEDEVENT", "addNamedEvent", 2)); + SetAt(O_ADDNAMEDHANDLER, COpcodeAttributes("O_ADDNAMEDHANDLER", "addNamedHandler", 2)); + SetAt(O_CLEARNAMED, COpcodeAttributes("O_CLEARNAMED", "clearNamed", 1)); + SetAt(O_SIGNALNAMED, COpcodeAttributes("O_SIGNALNAMED", "signalNamed", 1)); + SetAt(O_ADDKEY, COpcodeAttributes("O_ADDKEY", "addKey", 2)); + SetAt(O_DELETEKEY, COpcodeAttributes("O_DELETEKEY", "deleteKey", 1)); + SetAt(O_SOUNDPLAY, COpcodeAttributes("O_SOUNDPLAY", "soundPlay", 2, expression)); + SetAt(O_SOUNDPAUSE, COpcodeAttributes("O_SOUNDPAUSE", "soundPause", 1)); + SetAt(O_SOUNDRESUME, COpcodeAttributes("O_SOUNDRESUME", "soundResume", 1)); + SetAt(O_SOUNDSTOP, COpcodeAttributes("O_SOUNDSTOP", "soundStop", 1)); + SetAt(O_SOUNDREWIND, COpcodeAttributes("O_SOUNDREWIND", "soundRewind", 1)); + SetAt(O_SOUNDDELETE, COpcodeAttributes("O_SOUNDDELETE", "soundDelete", 1)); + SetAt(O_SETONEOPTPAUSE, COpcodeAttributes("O_SETONEOPTPAUSE", "setOneOptPause", 1)); + SetAt(O_SELECTFILELIST, COpcodeAttributes("O_SELECTFILELIST", "selectFileList", 2, expression)); + SetAt(O_TOKENIZE, COpcodeAttributes("O_TOKENIZE", "tokenize", 3, expression)); + SetAt(O_GIVE_EXP_POINTS, COpcodeAttributes("O_GIVE_EXP_POINTS", "give_exp_points", 1)); + SetAt(O_SCR_RETURN, COpcodeAttributes("O_SCR_RETURN", "scr_return", 1)); + SetAt(O_PLAY_SFX, COpcodeAttributes("O_PLAY_SFX", "play_sfx", 1)); + SetAt(O_OBJ_NAME, COpcodeAttributes("O_OBJ_NAME", "obj_name", 1, expression)); + SetAt(O_SFX_BUILD_OPEN_NAME, COpcodeAttributes("O_SFX_BUILD_OPEN_NAME", "sfx_build_open_name", 2, expression)); + SetAt(O_GET_PC_STAT, COpcodeAttributes("O_GET_PC_STAT", "get_pc_stat", 1, expression)); + SetAt(O_TILE_CONTAINS_PID_OBJ, COpcodeAttributes("O_TILE_CONTAINS_PID_OBJ", "tile_contains_pid_obj", 3, expression)); + SetAt(O_SET_MAP_START, COpcodeAttributes("O_SET_MAP_START", "set_map_start", 4)); + SetAt(O_OVERRIDE_MAP_START, COpcodeAttributes("O_OVERRIDE_MAP_START", "override_map_start", 4)); + SetAt(O_HAS_SKILL, COpcodeAttributes("O_HAS_SKILL", "has_skill", 2, expression)); + SetAt(O_USING_SKILL, COpcodeAttributes("O_USING_SKILL", "using_skill", 2, expression)); + SetAt(O_ROLL_VS_SKILL, COpcodeAttributes("O_ROLL_VS_SKILL", "roll_vs_skill", 3, expression)); + SetAt(O_SKILL_CONTEST, COpcodeAttributes("O_SKILL_CONTEST", "skill_contest", 3, expression)); + SetAt(O_DO_CHECK, COpcodeAttributes("O_DO_CHECK", "do_check", 3, expression)); + SetAt(O_IS_SUCCESS, COpcodeAttributes("O_IS_SUCCESS", "is_success", 1, expression)); + SetAt(O_IS_CRITICAL, COpcodeAttributes("O_IS_CRITICAL", "is_critical", 1, expression)); + SetAt(O_HOW_MUCH, COpcodeAttributes("O_HOW_MUCH", "how_much", 0, expression)); + SetAt(O_MARK_AREA_KNOWN, COpcodeAttributes("O_MARK_AREA_KNOWN", "mark_area_known", 3)); + SetAt(O_REACTION_INFLUENCE, COpcodeAttributes("O_REACTION_INFLUENCE", "reaction_influence", 3, expression)); + SetAt(O_RANDOM, COpcodeAttributes("O_RANDOM", "random", 2, expression)); + SetAt(O_ROLL_DICE, COpcodeAttributes("O_ROLL_DICE", "roll_dice", 2, expression)); + SetAt(O_MOVE_TO, COpcodeAttributes("O_MOVE_TO", "move_to", 3, expression)); + SetAt(O_CREATE_OBJECT_SID, COpcodeAttributes("O_CREATE_OBJECT_SID", "create_object_sid", 4, expression)); + SetAt(O_DISPLAY_MSG, COpcodeAttributes("O_DISPLAY_MSG", "display_msg", 1)); + SetAt(O_SCRIPT_OVERRIDES, COpcodeAttributes("O_SCRIPT_OVERRIDES", "script_overrides", 0)); + SetAt(O_OBJ_IS_CARRYING_OBJ_PID, COpcodeAttributes("O_OBJ_IS_CARRYING_OBJ_PID", "obj_is_carrying_obj_pid", 2, expression)); + SetAt(O_TILE_CONTAINS_OBJ_PID, COpcodeAttributes("O_TILE_CONTAINS_OBJ_PID", "tile_contains_obj_pid", 3, expression)); + SetAt(O_SELF_OBJ, COpcodeAttributes("O_SELF_OBJ", "self_obj", 0, expression)); + SetAt(O_SOURCE_OBJ, COpcodeAttributes("O_SOURCE_OBJ", "source_obj", 0, expression)); + SetAt(O_TARGET_OBJ, COpcodeAttributes("O_TARGET_OBJ", "target_obj", 0, expression)); + SetAt(O_DUDE_OBJ, COpcodeAttributes("O_DUDE_OBJ", "dude_obj", 0, expression)); + SetAt(O_OBJ_BEING_USED_WITH, COpcodeAttributes("O_OBJ_BEING_USED_WITH", "obj_being_used_with", 0, expression)); + SetAt(O_LOCAL_VAR, COpcodeAttributes("O_LOCAL_VAR", "local_var", 1, expression)); + SetAt(O_SET_LOCAL_VAR, COpcodeAttributes("O_SET_LOCAL_VAR", "set_local_var", 2)); + SetAt(O_MAP_VAR, COpcodeAttributes("O_MAP_VAR", "map_var", 1, expression)); + SetAt(O_SET_MAP_VAR, COpcodeAttributes("O_SET_MAP_VAR", "set_map_var", 2)); + SetAt(O_GLOBAL_VAR, COpcodeAttributes("O_GLOBAL_VAR", "global_var", 1, expression)); + SetAt(O_SET_GLOBAL_VAR, COpcodeAttributes("O_SET_GLOBAL_VAR", "set_global_var", 2)); + SetAt(O_SCRIPT_ACTION, COpcodeAttributes("O_SCRIPT_ACTION", "script_action", 0, expression)); + SetAt(O_OBJ_TYPE, COpcodeAttributes("O_OBJ_TYPE", "obj_type", 1, expression)); + SetAt(O_OBJ_ITEM_SUBTYPE, COpcodeAttributes("O_OBJ_ITEM_SUBTYPE", "obj_item_subtype", 1, expression)); + SetAt(O_GET_CRITTER_STAT, COpcodeAttributes("O_GET_CRITTER_STAT", "get_critter_stat", 2, expression)); + SetAt(O_SET_CRITTER_STAT, COpcodeAttributes("O_SET_CRITTER_STAT", "set_critter_stat", 3, expression)); + SetAt(O_ANIMATE_STAND_OBJ, COpcodeAttributes("O_ANIMATE_STAND_OBJ", "animate_stand_obj", 1)); + SetAt(O_ANIMATE_STAND_REVERSE_OBJ, COpcodeAttributes("O_ANIMATE_STAND_REVERSE_OBJ", "animate_stand_reverse_obj", 1)); + SetAt(O_ANIMATE_MOVE_OBJ_TO_TILE, COpcodeAttributes("O_ANIMATE_MOVE_OBJ_TO_TILE", "animate_move_obj_to_tile", 3)); + SetAt(O_TILE_IN_TILE_RECT, COpcodeAttributes("O_TILE_IN_TILE_RECT", "tile_in_tile_rect", 5, expression)); + SetAt(O_ATTACK_COMPLEX, COpcodeAttributes("O_ATTACK_COMPLEX", "attack_complex", 8)); + SetAt(O_MAKE_DAYTIME, COpcodeAttributes("O_MAKE_DAYTIME", "make_daytime", 0)); + SetAt(O_TILE_DISTANCE, COpcodeAttributes("O_TILE_DISTANCE", "tile_distance", 2, expression)); + SetAt(O_TILE_DISTANCE_OBJS, COpcodeAttributes("O_TILE_DISTANCE_OBJS", "tile_distance_objs", 2, expression)); + SetAt(O_TILE_NUM, COpcodeAttributes("O_TILE_NUM", "tile_num", 1, expression)); + SetAt(O_TILE_NUM_IN_DIRECTION, COpcodeAttributes("O_TILE_NUM_IN_DIRECTION", "tile_num_in_direction", 3, expression)); + SetAt(O_PICKUP_OBJ, COpcodeAttributes("O_PICKUP_OBJ", "pickup_obj", 1)); + SetAt(O_DROP_OBJ, COpcodeAttributes("O_DROP_OBJ", "drop_obj", 1)); + SetAt(O_ADD_OBJ_TO_INVEN, COpcodeAttributes("O_ADD_OBJ_TO_INVEN", "add_obj_to_inven", 2)); + SetAt(O_RM_OBJ_FROM_INVEN, COpcodeAttributes("O_RM_OBJ_FROM_INVEN", "rm_obj_from_inven", 2)); + SetAt(O_WIELD_OBJ_CRITTER, COpcodeAttributes("O_WIELD_OBJ_CRITTER", "wield_obj_critter", 2)); + SetAt(O_USE_OBJ, COpcodeAttributes("O_USE_OBJ", "use_obj", 1)); + SetAt(O_OBJ_CAN_SEE_OBJ, COpcodeAttributes("O_OBJ_CAN_SEE_OBJ", "obj_can_see_obj", 2, expression)); + SetAt(O_ATTACK, COpcodeAttributes("O_ATTACK", "attack", 8)); + SetAt(O_START_GDIALOG, COpcodeAttributes("O_START_GDIALOG", "start_gdialog", 5)); + SetAt(O_END_DIALOGUE, COpcodeAttributes("O_END_DIALOGUE", "end_dialogue", 0)); + SetAt(O_DIALOGUE_REACTION, COpcodeAttributes("O_DIALOGUE_REACTION", "dialogue_reaction", 1)); + SetAt(O_METARULE3, COpcodeAttributes("O_METARULE3", "metarule3", 4, expression)); + SetAt(O_SET_MAP_MUSIC, COpcodeAttributes("O_SET_MAP_MUSIC", "set_map_music", 2)); + SetAt(O_SET_OBJ_VISIBILITY, COpcodeAttributes("O_SET_OBJ_VISIBILITY", "set_obj_visibility", 2)); + SetAt(O_LOAD_MAP, COpcodeAttributes("O_LOAD_MAP", "load_map", 2)); + SetAt(O_WM_AREA_SET_POS, COpcodeAttributes("O_WM_AREA_SET_POS", "wm_area_set_pos", 3)); + SetAt(O_SET_EXIT_GRIDS, COpcodeAttributes("O_SET_EXIT_GRIDS", "set_exit_grids", 5)); + SetAt(O_ANIM_BUSY, COpcodeAttributes("O_ANIM_BUSY", "anim_busy", 1, expression)); + SetAt(O_CRITTER_HEAL, COpcodeAttributes("O_CRITTER_HEAL", "critter_heal", 2, expression)); + SetAt(O_SET_LIGHT_LEVEL, COpcodeAttributes("O_SET_LIGHT_LEVEL", "set_light_level", 1)); + SetAt(O_GAME_TIME, COpcodeAttributes("O_GAME_TIME", "game_time", 0, expression)); + SetAt(O_GAME_TIME_IN_SECONDS, COpcodeAttributes("O_GAME_TIME_IN_SECONDS", "game_time_in_seconds", 0, expression)); + SetAt(O_ELEVATION, COpcodeAttributes("O_ELEVATION", "elevation", 1, expression)); + SetAt(O_KILL_CRITTER, COpcodeAttributes("O_KILL_CRITTER", "kill_critter", 2)); + SetAt(O_KILL_CRITTER_TYPE, COpcodeAttributes("O_KILL_CRITTER_TYPE", "kill_critter_type", 2)); + SetAt(O_CRITTER_DMG, COpcodeAttributes("O_CRITTER_DMG", "critter_dmg", 3)); + SetAt(O_ADD_TIMER_EVENT, COpcodeAttributes("O_ADD_TIMER_EVENT", "add_timer_event", 3)); + SetAt(O_RM_TIMER_EVENT, COpcodeAttributes("O_RM_TIMER_EVENT", "rm_timer_event", 1)); + SetAt(O_GAME_TICKS, COpcodeAttributes("O_GAME_TICKS", "game_ticks", 1, expression)); + SetAt(O_HAS_TRAIT, COpcodeAttributes("O_HAS_TRAIT", "has_trait", 3, expression)); + SetAt(O_DESTROY_OBJECT, COpcodeAttributes("O_DESTROY_OBJECT", "destroy_object", 1)); + SetAt(O_OBJ_CAN_HEAR_OBJ, COpcodeAttributes("O_OBJ_CAN_HEAR_OBJ", "obj_can_hear_obj", 2, expression)); + SetAt(O_GAME_TIME_HOUR, COpcodeAttributes("O_GAME_TIME_HOUR", "game_time_hour", 0, expression)); + SetAt(O_FIXED_PARAM, COpcodeAttributes("O_FIXED_PARAM", "fixed_param", 0, expression)); + SetAt(O_TILE_IS_VISIBLE, COpcodeAttributes("O_TILE_IS_VISIBLE", "tile_is_visible", 1, expression)); + SetAt(O_DIALOGUE_SYSTEM_ENTER, COpcodeAttributes("O_DIALOGUE_SYSTEM_ENTER", "dialogue_system_enter", 0)); + SetAt(O_ACTION_BEING_USED, COpcodeAttributes("O_ACTION_BEING_USED", "action_being_used", 0, expression)); + SetAt(O_CRITTER_STATE, COpcodeAttributes("O_CRITTER_STATE", "critter_state", 1, expression)); + SetAt(O_GAME_TIME_ADVANCE, COpcodeAttributes("O_GAME_TIME_ADVANCE", "game_time_advance", 1)); + SetAt(O_RADIATION_INC, COpcodeAttributes("O_RADIATION_INC", "radiation_inc", 2)); + SetAt(O_RADIATION_DEC, COpcodeAttributes("O_RADIATION_DEC", "radiation_dec", 2)); + SetAt(O_CRITTER_ATTEMPT_PLACEMENT, COpcodeAttributes("O_CRITTER_ATTEMPT_PLACEMENT", "critter_attempt_placement", 3, expression)); + SetAt(O_OBJ_PID, COpcodeAttributes("O_OBJ_PID", "obj_pid", 1, expression)); + SetAt(O_CUR_MAP_INDEX, COpcodeAttributes("O_CUR_MAP_INDEX", "cur_map_index", 0, expression)); + SetAt(O_CRITTER_ADD_TRAIT, COpcodeAttributes("O_CRITTER_ADD_TRAIT", "critter_add_trait", 4, expression)); + SetAt(O_CRITTER_RM_TRAIT, COpcodeAttributes("O_CRITTER_RM_TRAIT", "critter_rm_trait", 4, expression)); + SetAt(O_PROTO_DATA, COpcodeAttributes("O_PROTO_DATA", "proto_data", 2, expression)); + SetAt(O_MESSAGE_STR, COpcodeAttributes("O_MESSAGE_STR", "message_str", 2, expression)); + SetAt(O_CRITTER_INVEN_OBJ, COpcodeAttributes("O_CRITTER_INVEN_OBJ", "critter_inven_obj", 2, expression)); + SetAt(O_OBJ_SET_LIGHT_LEVEL, COpcodeAttributes("O_OBJ_SET_LIGHT_LEVEL", "obj_set_light_level", 3)); + SetAt(O_WORLD_MAP, COpcodeAttributes("O_WORLD_MAP", "world_map", 0)); + SetAt(O_INVEN_CMDS, COpcodeAttributes("O_INVEN_CMDS", "inven_cmds", 3, expression)); + SetAt(O_FLOAT_MSG, COpcodeAttributes("O_FLOAT_MSG", "float_msg", 3)); + SetAt(O_METARULE, COpcodeAttributes("O_METARULE", "metarule", 2, expression)); + SetAt(O_ANIM, COpcodeAttributes("O_ANIM", "anim", 3)); + SetAt(O_OBJ_CARRYING_PID_OBJ, COpcodeAttributes("O_OBJ_CARRYING_PID_OBJ", "obj_carrying_pid_obj", 2, expression)); + SetAt(O_REG_ANIM_FUNC, COpcodeAttributes("O_REG_ANIM_FUNC", "reg_anim_func", 2)); + SetAt(O_REG_ANIM_ANIMATE, COpcodeAttributes("O_REG_ANIM_ANIMATE", "reg_anim_animate", 3)); + SetAt(O_REG_ANIM_ANIMATE_REVERSE, COpcodeAttributes("O_REG_ANIM_ANIMATE_REVERSE", "reg_anim_animate_reverse", 3)); + SetAt(O_REG_ANIM_OBJ_MOVE_TO_OBJ, COpcodeAttributes("O_REG_ANIM_OBJ_MOVE_TO_OBJ", "reg_anim_obj_move_to_obj", 3)); + SetAt(O_REG_ANIM_OBJ_RUN_TO_OBJ, COpcodeAttributes("O_REG_ANIM_OBJ_RUN_TO_OBJ", "reg_anim_obj_run_to_obj", 3)); + SetAt(O_REG_ANIM_OBJ_MOVE_TO_TILE, COpcodeAttributes("O_REG_ANIM_OBJ_MOVE_TO_TILE", "reg_anim_obj_move_to_tile", 3)); + SetAt(O_REG_ANIM_OBJ_RUN_TO_TILE, COpcodeAttributes("O_REG_ANIM_OBJ_RUN_TO_TILE", "reg_anim_obj_run_to_tile", 3)); + SetAt(O_PLAY_GMOVIE, COpcodeAttributes("O_PLAY_GMOVIE", "play_gmovie", 1)); + SetAt(O_ADD_MULT_OBJS_TO_INVEN, COpcodeAttributes("O_ADD_MULT_OBJS_TO_INVEN", "add_mult_objs_to_inven", 3)); + SetAt(O_RM_MULT_OBJS_FROM_INVEN, COpcodeAttributes("O_RM_MULT_OBJS_FROM_INVEN", "rm_mult_objs_from_inven", 3, expression)); + SetAt(O_GET_MONTH, COpcodeAttributes("O_GET_MONTH", "get_month", 0, expression)); + SetAt(O_GET_DAY, COpcodeAttributes("O_GET_DAY", "get_day", 0, expression)); + SetAt(O_EXPLOSION, COpcodeAttributes("O_EXPLOSION", "explosion", 3)); + SetAt(O_DAYS_SINCE_VISITED, COpcodeAttributes("O_DAYS_SINCE_VISITED", "days_since_visited", 0, expression)); + SetAt(O_GSAY_START, COpcodeAttributes("O_GSAY_START", "gsay_start", 0)); + SetAt(O_GSAY_END, COpcodeAttributes("O_GSAY_END", "gsay_end", 0)); + SetAt(O_GSAY_REPLY, COpcodeAttributes("O_GSAY_REPLY", "gsay_reply", 2)); + SetAt(O_GSAY_OPTION, COpcodeAttributes("O_GSAY_OPTION", "gsay_option", 4)); + SetAt(O_GSAY_MESSAGE, COpcodeAttributes("O_GSAY_MESSAGE", "gsay_message", 3)); + SetAt(O_GIQ_OPTION, COpcodeAttributes("O_GIQ_OPTION", "giq_option", 5)); + SetAt(O_POISON, COpcodeAttributes("O_POISON", "poison", 2)); + SetAt(O_GET_POISON, COpcodeAttributes("O_GET_POISON", "get_poison", 1, expression)); + SetAt(O_PARTY_ADD, COpcodeAttributes("O_PARTY_ADD", "party_add", 1)); + SetAt(O_PARTY_REMOVE, COpcodeAttributes("O_PARTY_REMOVE", "party_remove", 1)); + SetAt(O_REG_ANIM_ANIMATE_FOREVER, COpcodeAttributes("O_REG_ANIM_ANIMATE_FOREVER", "reg_anim_animate_forever", 2)); + SetAt(O_CRITTER_INJURE, COpcodeAttributes("O_CRITTER_INJURE", "critter_injure", 2)); + SetAt(O_COMBAT_IS_INITIALIZED, COpcodeAttributes("O_COMBAT_IS_INITIALIZED", "combat_is_initialized", 0, expression)); + SetAt(O_GDIALOG_MOD_BARTER, COpcodeAttributes("O_GDIALOG_MOD_BARTER", "gdialog_mod_barter", 1)); + SetAt(O_DIFFICULTY_LEVEL, COpcodeAttributes("O_DIFFICULTY_LEVEL", "difficulty_level", 0, expression)); + SetAt(O_RUNNING_BURNING_GUY, COpcodeAttributes("O_RUNNING_BURNING_GUY", "running_burning_guy", 0, expression)); + SetAt(O_INVEN_UNWIELD, COpcodeAttributes("O_INVEN_UNWIELD", "inven_unwield", 0)); + SetAt(O_OBJ_IS_LOCKED, COpcodeAttributes("O_OBJ_IS_LOCKED", "obj_is_locked", 1, expression)); + SetAt(O_OBJ_LOCK, COpcodeAttributes("O_OBJ_LOCK", "obj_lock", 1)); + SetAt(O_OBJ_UNLOCK, COpcodeAttributes("O_OBJ_UNLOCK", "obj_unlock", 1)); + SetAt(O_OBJ_IS_OPEN, COpcodeAttributes("O_OBJ_IS_OPEN", "obj_is_open", 1, expression)); + SetAt(O_OBJ_OPEN, COpcodeAttributes("O_OBJ_OPEN", "obj_open", 1)); + SetAt(O_OBJ_CLOSE, COpcodeAttributes("O_OBJ_CLOSE", "obj_close", 1)); + SetAt(O_GAME_UI_DISABLE, COpcodeAttributes("O_GAME_UI_DISABLE", "game_ui_disable", 0)); + SetAt(O_GAME_UI_ENABLE, COpcodeAttributes("O_GAME_UI_ENABLE", "game_ui_enable", 0)); + SetAt(O_GAME_UI_IS_DISABLED, COpcodeAttributes("O_GAME_UI_IS_DISABLED", "game_ui_is_disabled", 0, expression)); + SetAt(O_GFADE_OUT, COpcodeAttributes("O_GFADE_OUT", "gfade_out", 1)); + SetAt(O_GFADE_IN, COpcodeAttributes("O_GFADE_IN", "gfade_in", 1)); + SetAt(O_ITEM_CAPS_TOTAL, COpcodeAttributes("O_ITEM_CAPS_TOTAL", "item_caps_total", 1, expression)); + SetAt(O_ITEM_CAPS_ADJUST, COpcodeAttributes("O_ITEM_CAPS_ADJUST", "item_caps_adjust", 2, expression)); + SetAt(O_ANIM_ACTION_FRAME, COpcodeAttributes("O_ANIM_ACTION_FRAME", "anim_action_frame", 2, expression)); + SetAt(O_REG_ANIM_PLAY_SFX, COpcodeAttributes("O_REG_ANIM_PLAY_SFX", "reg_anim_play_sfx", 3)); + SetAt(O_CRITTER_MOD_SKILL, COpcodeAttributes("O_CRITTER_MOD_SKILL", "critter_mod_skill", 3)); + SetAt(O_SFX_BUILD_CHAR_NAME, COpcodeAttributes("O_SFX_BUILD_CHAR_NAME", "sfx_build_char_name", 3, expression)); + SetAt(O_SFX_BUILD_AMBIENT_NAME, COpcodeAttributes("O_SFX_BUILD_AMBIENT_NAME", "sfx_build_ambient_name", 1, expression)); + SetAt(O_SFX_BUILD_INTERFACE_NAME, COpcodeAttributes("O_SFX_BUILD_INTERFACE_NAME", "sfx_build_interface_name", 1, expression)); + SetAt(O_SFX_BUILD_ITEM_NAME, COpcodeAttributes("O_SFX_BUILD_ITEM_NAME", "sfx_build_item_name", 1, expression)); + SetAt(O_SFX_BUILD_WEAPON_NAME, COpcodeAttributes("O_SFX_BUILD_WEAPON_NAME", "sfx_build_weapon_name", 4, expression)); + SetAt(O_SFX_BUILD_SCENERY_NAME, COpcodeAttributes("O_SFX_BUILD_SCENERY_NAME", "sfx_build_scenery_name", 3, expression)); + SetAt(O_ATTACK_SETUP, COpcodeAttributes("O_ATTACK_SETUP", "attack_setup", 2)); + SetAt(O_DESTROY_MULT_OBJS, COpcodeAttributes("O_DESTROY_MULT_OBJS", "destroy_mult_objs", 2, expression)); + SetAt(O_USE_OBJ_ON_OBJ, COpcodeAttributes("O_USE_OBJ_ON_OBJ", "use_obj_on_obj", 2)); + SetAt(O_ENDGAME_SLIDESHOW, COpcodeAttributes("O_ENDGAME_SLIDESHOW", "endgame_slideshow", 0)); + SetAt(O_MOVE_OBJ_INVEN_TO_OBJ, COpcodeAttributes("O_MOVE_OBJ_INVEN_TO_OBJ", "move_obj_inven_to_obj", 2)); + SetAt(O_ENDGAME_MOVIE, COpcodeAttributes("O_ENDGAME_MOVIE", "endgame_movie", 0)); + SetAt(O_OBJ_ART_FID, COpcodeAttributes("O_OBJ_ART_FID", "obj_art_fid", 1, expression)); + SetAt(O_ART_ANIM, COpcodeAttributes("O_ART_ANIM", "art_anim", 1, expression)); + SetAt(O_PARTY_MEMBER_OBJ, COpcodeAttributes("O_PARTY_MEMBER_OBJ", "party_member_obj", 1, expression)); + SetAt(O_ROTATION_TO_TILE, COpcodeAttributes("O_ROTATION_TO_TILE", "rotation_to_tile", 2, expression)); + SetAt(O_JAM_LOCK, COpcodeAttributes("O_JAM_LOCK", "jam_lock", 1)); + SetAt(O_GDIALOG_SET_BARTER_MOD, COpcodeAttributes("O_GDIALOG_SET_BARTER_MOD", "gdialog_set_barter_mod", 1)); + SetAt(O_COMBAT_DIFFICULTY, COpcodeAttributes("O_COMBAT_DIFFICULTY", "combat_difficulty", 0, expression)); + SetAt(O_OBJ_ON_SCREEN, COpcodeAttributes("O_OBJ_ON_SCREEN", "obj_on_screen", 1, expression)); + SetAt(O_CRITTER_IS_FLEEING, COpcodeAttributes("O_CRITTER_IS_FLEEING", "critter_is_fleeing", 1, expression)); + SetAt(O_CRITTER_SET_FLEE_STATE, COpcodeAttributes("O_CRITTER_SET_FLEE_STATE", "critter_set_flee_state", 2)); + SetAt(O_TERMINATE_COMBAT, COpcodeAttributes("O_TERMINATE_COMBAT", "terminate_combat", 0)); + SetAt(O_DEBUG_MSG, COpcodeAttributes("O_DEBUG_MSG", "debug_msg", 1)); + SetAt(O_CRITTER_STOP_ATTACKING, COpcodeAttributes("O_CRITTER_STOP_ATTACKING", "critter_stop_attacking", 1)); + + //sall start + + SetAt(O_READ_BYTE, COpcodeAttributes("O_READ_BYTE", "read_byte", 1, expression)); + SetAt(O_READ_SHORT, COpcodeAttributes("O_READ_SHORT", "read_short", 1, expression)); + SetAt(O_READ_INT, COpcodeAttributes("O_READ_INT", "read_int", 1, expression)); + SetAt(O_READ_STRING, COpcodeAttributes("O_READ_STRING", "read_string", 1, expression)); + + SetAt(O_SET_PC_BASE_STAT, COpcodeAttributes("O_SET_PC_BASE_STAT", "set_pc_base_stat", 2)); + SetAt(O_SET_PC_EXTRA_STAT, COpcodeAttributes("O_SET_PC_EXTRA_STAT", "set_pc_extra_stat", 2)); + SetAt(O_GET_PC_BASE_STAT, COpcodeAttributes("O_GET_PC_BASE_STAT", "get_pc_base_stat", 1, expression)); + SetAt(O_GET_PC_EXTRA_STAT, COpcodeAttributes("O_GET_PC_EXTRA_STAT", "get_pc_extra_stat", 1, expression)); + + SetAt(O_SET_CRITTER_BASE_STAT, COpcodeAttributes("O_SET_CRITTER_BASE_STAT", "set_critter_base_stat", 3)); + SetAt(O_SET_CRITTER_EXTRA_STAT, COpcodeAttributes("O_SET_CRITTER_EXTRA_STAT", "set_critter_extra_stat", 3)); + SetAt(O_GET_CRITTER_BASE_STAT, COpcodeAttributes("O_GET_CRITTER_BASE_STAT", "get_critter_base_stat", 2, expression)); + SetAt(O_GET_CRITTER_EXTRA_STAT, COpcodeAttributes("O_GET_CRITTER_EXTRA_STAT", "get_critter_extra_stat", 2, expression)); + + SetAt(O_TAP_KEY, COpcodeAttributes("O_TAP_KEY", "tap_key", 1)); + SetAt(O_GET_YEAR, COpcodeAttributes("O_GET_YEAR", "get_year", 0, expression)); + + SetAt(O_GAME_LOADED, COpcodeAttributes("O_GAME_LOADED", "game_loaded", 0, expression)); + SetAt(O_GRAPHICS_FUNCS_AVAILABLE, COpcodeAttributes("O_GRAPHICS_FUNCS_AVAILABLE", "graphics_funcs_available", 0, expression)); + SetAt(O_LOAD_SHADER, COpcodeAttributes("O_LOAD_SHADER", "load_shader", 1, expression)); + SetAt(O_FREE_SHADER, COpcodeAttributes("O_FREE_SHADER", "free_shader", 1)); + SetAt(O_ACTIVATE_SHADER, COpcodeAttributes("O_ACTIVATE_SHADER", "activate_shader", 1)); + SetAt(O_DEACTIVATE_SHADER, COpcodeAttributes("O_DEACTIVATE_SHADER", "deactivate_shader", 1)); + SetAt(O_SET_GLOBAL_SCRIPT_REPEAT, COpcodeAttributes("O_SET_GLOBAL_SCRIPT_REPEAT", "set_global_script_repeat", 1)); + SetAt(O_INPUT_FUNCS_AVAILABLE, COpcodeAttributes("O_INPUT_FUNCS_AVAILABLE", "input_funcs_available", 0, expression)); + SetAt(O_KEY_PRESSED, COpcodeAttributes("O_KEY_PRESSED", "key_pressed", 1, expression)); + + SetAt(O_SET_SHADER_INT, COpcodeAttributes("O_SET_SHADER_INT", "set_shader_int", 3)); + SetAt(O_SET_SHADER_FLOAT, COpcodeAttributes("O_SET_SHADER_FLOAT", "set_shader_float", 3)); + SetAt(O_SET_SHADER_VECTOR, COpcodeAttributes("O_SET_SHADER_VECTOR", "set_shader_vector", 6)); + SetAt(O_IN_WORLD_MAP, COpcodeAttributes("O_IN_WORLD_MAP", "in_world_map", 0, expression)); + SetAt(O_FORCE_ENCOUNTER, COpcodeAttributes("O_FORCE_ENCOUNTER", "force_encounter", 1)); + SetAt(O_SET_WORLD_MAP_POS, COpcodeAttributes("O_SET_WORLD_MAP_POS", "set_world_map_pos", 2)); + SetAt(O_GET_WORLD_MAP_X_POS, COpcodeAttributes("O_GET_WORLD_MAP_X_POS", "get_world_map_x_pos", 0, expression)); + SetAt(O_GET_WORLD_MAP_Y_POS, COpcodeAttributes("O_GET_WORLD_MAP_Y_POS", "get_world_map_y_pos", 0, expression)); + + SetAt(O_SET_DM_MODEL, COpcodeAttributes("O_SET_DM_MODEL", "set_dm_model", 1)); + SetAt(O_SET_DF_MODEL, COpcodeAttributes("O_SET_DF_MODEL", "set_df_model", 1)); + SetAt(O_SET_MOVIE_PATH, COpcodeAttributes("O_SET_MOVIE_PATH", "set_movie_path", 2)); + + SetAt(O_SET_PERK_IMAGE, COpcodeAttributes("O_SET_PERK_IMAGE", "set_perk_image", 2)); + SetAt(O_SET_PERK_RANKS, COpcodeAttributes("O_SET_PERK_RANKS", "set_perk_ranks", 2)); + SetAt(O_SET_PERK_LEVEL, COpcodeAttributes("O_SET_PERK_LEVEL", "set_perk_level", 2)); + SetAt(O_SET_PERK_STAT, COpcodeAttributes("O_SET_PERK_STAT", "set_perk_stat", 2)); + SetAt(O_SET_PERK_STAT_MAG, COpcodeAttributes("O_SET_PERK_STAT_MAG", "set_perk_stat_mag", 2)); + SetAt(O_SET_PERK_SKILL1, COpcodeAttributes("O_SET_PERK_SKILL1", "set_perk_skill1", 2)); + SetAt(O_SET_PERK_SKILl1_MAG, COpcodeAttributes("O_SET_PERK_SKILl1_MAG", "set_perk_skill1_mag", 2)); + SetAt(O_SET_PERK_TYPE, COpcodeAttributes("O_SET_PERK_TYPE", "set_perk_type", 2)); + SetAt(O_SET_PERK_SKILL2, COpcodeAttributes("O_SET_PERK_SKILL2", "set_perk_skill2", 2)); + SetAt(O_SET_PERK_SKILL2_MAG, COpcodeAttributes("O_SET_PERK_SKILL2_MAG", "set_perk_skill2_mag", 2)); + SetAt(O_SET_PERK_STR, COpcodeAttributes("O_SET_PERK_STR", "set_perk_str", 2)); + SetAt(O_SET_PERK_PER, COpcodeAttributes("O_SET_PERK_PER", "set_perk_per", 2)); + SetAt(O_SET_PERK_END, COpcodeAttributes("O_SET_PERK_END", "set_perk_end", 2)); + SetAt(O_SET_PERK_CHR, COpcodeAttributes("O_SET_PERK_CHR", "set_perk_chr", 2)); + SetAt(O_SET_PERK_INT, COpcodeAttributes("O_SET_PERK_INT", "set_perk_int", 2)); + SetAt(O_SET_PERK_AGL, COpcodeAttributes("O_SET_PERK_AGL", "set_perk_agl", 2)); + SetAt(O_SET_PERK_LCK, COpcodeAttributes("O_SET_PERK_LCK", "set_perk_lck", 2)); + SetAt(O_SET_PERK_NAME, COpcodeAttributes("O_SET_PERK_NAME", "set_perk_name", 2)); + SetAt(O_SET_PERK_DESC, COpcodeAttributes("O_SET_PERK_DESC", "set_perk_desc", 2)); + + SetAt(O_SET_PIPBOY_AVAILABLE, COpcodeAttributes("O_SET_PIPBOY_AVAILABLE", "set_pipboy_available", 1)); + + SetAt(O_GET_KILL_COUNTER, COpcodeAttributes("O_GET_KILL_COUNTER", "get_kill_counter", 1, expression)); + SetAt(O_MOD_KILL_COUNTER, COpcodeAttributes("O_MOD_KILL_COUNTER", "mod_kill_counter", 2)); + + SetAt(O_GET_PERK_OWED, COpcodeAttributes("O_GET_PERK_OWED", "get_perk_owed", 0, expression)); + SetAt(O_SET_PERK_OWED, COpcodeAttributes("O_SET_PERK_OWED", "set_perk_owed", 1)); + SetAt(O_GET_PERK_AVAILABLE, COpcodeAttributes("O_GET_PERK_AVAILABLE", "get_perk_available", 1, expression)); + + SetAt(O_GET_CRITTER_AP, COpcodeAttributes("O_GET_CRITTER_AP", "get_critter_current_ap", 1, expression)); + SetAt(O_SET_CRITTER_AP, COpcodeAttributes("O_SET_CRITTER_AP", "set_critter_current_ap", 2)); + + SetAt(O_GET_ACTIVE_HAND, COpcodeAttributes("O_GET_ACTIVE_HAND", "active_hand", 0, expression)); + SetAt(O_TOGGLE_ACTIVE_HAND, COpcodeAttributes("O_TOGGLE_ACTIVE_HAND", "toggle_active_hand", 0)); + + SetAt(O_SET_WEAPON_KNOCKBACK, COpcodeAttributes("O_SET_WEAPON_KNOCKBACK", "set_weapon_knockback", 3)); + SetAt(O_SET_TARGET_KNOCKBACK, COpcodeAttributes("O_SET_TARGET_KNOCKBACK", "set_target_knockback", 3)); + SetAt(O_SET_ATTACKER_KNOCKBACK, COpcodeAttributes("O_SET_ATTACKER_KNOCKBACK", "set_attacker_knockback", 3)); + SetAt(O_REMOVE_WEAPON_KNOCKBACK, COpcodeAttributes("O_REMOVE_WEAPON_KNOCKBACK", "remove_weapon_knockback", 1)); + SetAt(O_REMOVE_TARGET_KNOCKBACK, COpcodeAttributes("O_REMOVE_TARGET_KNOCKBACK", "remove_target_knockback", 1)); + SetAt(O_REMOVE_ATTACKER_KNOCKBACK, COpcodeAttributes("O_REMOVE_ATTACKER_KNOCKBACK", "remove_attacker_knockback", 1)); + + SetAt(O_SET_GLOBAL_SCRIPT_TYPE, COpcodeAttributes("O_SET_GLOBAL_SCRIPT_TYPE", "set_global_script_type", 1)); + SetAt(O_AVAILABLE_GLOBAL_SCRIPT_TYPES, COpcodeAttributes("O_AVAILABLE_GLOBAL_SCRIPT_TYPES", "available_global_script_types", 0, expression)); + + SetAt(O_SET_SFALL_GLOBAL, COpcodeAttributes("O_SET_SFALL_GLOBAL", "set_sfall_global", 2)); + SetAt(O_GET_SFALL_GLOBAL_INT, COpcodeAttributes("O_GET_SFALL_GLOBAL_INT", "get_sfall_global_int", 1, expression)); + SetAt(O_GET_SFALL_GLOBAL_FLOAT, COpcodeAttributes("O_GET_SFALL_GLOBAL_FLOAT", "get_sfall_global_float", 1, expression)); + + SetAt(O_SET_PICKPOCKET_MAX, COpcodeAttributes("O_SET_PICKPOCKET_MAX", "set_pickpocket_max", 1)); + SetAt(O_SET_HIT_CHANCE_MAX, COpcodeAttributes("O_SET_HIT_CHANCE_MAX", "set_hit_chance_max", 1)); + SetAt(O_SET_SKILL_MAX, COpcodeAttributes("O_SET_SKILL_MAX", "set_skill_max", 1)); + + SetAt(O_EAX_AVAILABLE, COpcodeAttributes("O_EAX_AVAILABLE", "eax_available", 0, expression)); + SetAt(O_SET_EAX_ENVIRONMENT, COpcodeAttributes("O_SET_EAX_ENVIRONMENT", "set_eax_environment", 1)); + + SetAt(O_INC_NPC_LEVEL, COpcodeAttributes("O_INC_NPC_LEVEL", "inc_npc_level", 1)); + + SetAt(O_GET_VIEWPORT_X, COpcodeAttributes("O_GET_VIEWPORT_X", "get_viewport_x", 0, expression)); + SetAt(O_GET_VIEWPORT_Y, COpcodeAttributes("O_GET_VIEWPORT_Y", "get_viewport_y", 0, expression)); + SetAt(O_SET_VIEWPORT_X, COpcodeAttributes("O_SET_VIEWPORT_X", "set_viewport_x", 1)); + SetAt(O_SET_VIEWPORT_Y, COpcodeAttributes("O_SET_VIEWPORT_Y", "set_viewport_y", 1)); + + SetAt(O_SET_XP_MOD, COpcodeAttributes("O_SET_XP_MOD", "set_xp_mod", 1)); + SetAt(O_SET_PERK_LEVEL_MOD, COpcodeAttributes("O_SET_PERK_LEVEL_MOD", "set_perk_level_mod", 1)); + + SetAt(O_GET_INI_SETTING, COpcodeAttributes("O_GET_INI_SETTING", "get_ini_setting", 1, expression)); + + SetAt(O_GET_SHADER_VERSION, COpcodeAttributes("O_GET_SHADER_VERSION", "get_shader_version", 0, expression)); + SetAt(O_SET_SHADER_MODE, COpcodeAttributes("O_SET_SHADER_MODE", "set_shader_mode", 2)); + + SetAt(O_GET_GAME_MODE, COpcodeAttributes("O_GET_GAME_MODE", "get_game_mode", 0, expression)); + + SetAt(O_FORCE_GRAPHICS_REFRESH, COpcodeAttributes("O_FORCE_GRAPHICS_REFRESH", "force_graphics_refresh", 1)); + SetAt(O_GET_SHADER_TEXTURE, COpcodeAttributes("O_GET_SHADER_TEXTURE", "get_shader_texture", 2, expression)); + SetAt(O_SET_SHADER_TEXTURE, COpcodeAttributes("O_SET_SHADER_TEXTURE", "set_shader_texture", 3)); + + SetAt(O_GET_UPTIME, COpcodeAttributes("O_GET_UPTIME", "get_uptime", 0, expression)); + + SetAt(O_SET_STAT_MAX, COpcodeAttributes("O_SET_STAT_MAX", "set_stat_max", 2)); + SetAt(O_SET_STAT_MIN, COpcodeAttributes("O_SET_STAT_MIN", "set_stat_min", 2)); + + SetAt(O_SET_CAR_CURRENT_TOWN, COpcodeAttributes("O_SET_CAR_CURRENT_TOWN", "set_car_current_town", 1)); + + SetAt(O_SET_PC_STAT_MAX, COpcodeAttributes("O_SET_PC_STAT_MAX", "set_pc_stat_max", 2)); + SetAt(O_SET_PC_STAT_MIN, COpcodeAttributes("O_SET_PC_STAT_MIN", "set_pc_stat_min", 2)); + SetAt(O_SET_NPC_STAT_MAX, COpcodeAttributes("O_SET_NPC_STAT_MAX", "set_npc_stat_max", 2)); + SetAt(O_SET_NPC_STAT_MIN, COpcodeAttributes("O_SET_NPC_STAT_MIN", "set_npc_stat_min", 2)); + + SetAt(O_SET_FAKE_PERK, COpcodeAttributes("O_SET_FAKE_PERK", "set_fake_perk", 4)); + SetAt(O_SET_FAKE_TRAIT, COpcodeAttributes("O_SET_FAKE_TRAIT", "set_fake_trait", 4)); + SetAt(O_SET_SELECTABLE_PERK, COpcodeAttributes("O_SET_SELECTABLE_PERK", "set_selectable_perk", 4)); + SetAt(O_SET_PERKBOX_TITLE, COpcodeAttributes("O_SET_PERKBOX_TITLE", "set_perkbox_title", 1)); + SetAt(O_HIDE_REAL_PERKS, COpcodeAttributes("O_HIDE_REAL_PERKS", "hide_real_perks", 0)); + SetAt(O_SHOW_REAL_PERKS, COpcodeAttributes("O_SHOW_REAL_PERKS", "show_real_perks", 0)); + SetAt(O_HAS_FAKE_PERK, COpcodeAttributes("O_HAS_FAKE_PERK", "has_fake_perk", 1, expression)); + SetAt(O_HAS_FAKE_TRAIT, COpcodeAttributes("O_HAS_FAKE_TRAIT", "has_fake_trait", 1, expression)); + SetAt(O_PERK_ADD_MODE, COpcodeAttributes("O_PERK_ADD_MODE", "perk_add_mode", 1)); + SetAt(O_CLEAR_SELECTABLE_PERKS, COpcodeAttributes("O_CLEAR_SELECTABLE_PERKS", "clear_selectable_perks", 0)); + + SetAt(O_SET_CRITTER_HIT_CHANCE_MOD, COpcodeAttributes("O_SET_CRITTER_HIT_CHANCE_MOD", "set_critter_hit_chance_mod", 3)); + SetAt(O_SET_BASE_HIT_CHANCE_MOD, COpcodeAttributes("O_SET_BASE_HIT_CHANCE_MOD", "set_base_hit_chance_mod", 2)); + SetAt(O_SET_CRITTER_SKILL_MOD, COpcodeAttributes("O_SET_CRITTER_SKILL_MOD", "set_critter_skill_mod", 2)); + SetAt(O_SET_BASE_SKILL_MOD, COpcodeAttributes("O_SET_BASE_SKILL_MOD", "set_base_skill_mod", 1)); + SetAt(O_SET_CRITTER_PICKPOCKET_MOD, COpcodeAttributes("O_SET_CRITTER_PICKPOCKET_MOD", "set_critter_pickpocket_mod", 3)); + SetAt(O_SET_BASE_PICKPOCKET_MOD, COpcodeAttributes("O_SET_BASE_PICKPOCKET_MOD", "set_base_pickpocket_mod", 2)); + + SetAt(O_SET_PYROMANIAC_MOD, COpcodeAttributes("O_SET_PYROMANIAC_MOD", "set_pyromaniac_mod", 1)); + SetAt(O_APPLY_HEAVEHO_FIX, COpcodeAttributes("O_APPLY_HEAVEHO_FIX", "apply_heaveho_fix", 0)); + SetAt(O_SET_SWIFTLEARNER_MOD, COpcodeAttributes("O_SET_SWIFTLEARNER_MOD", "set_swiftlearner_mod", 1)); + SetAt(O_SET_HP_LEVEL_MOD, COpcodeAttributes("O_SET_HP_LEVEL_MOD", "set_hp_per_level_mod", 1)); + + SetAt(O_WRITE_BYTE, COpcodeAttributes("O_WRITE_BYTE", "write_byte", 2)); + SetAt(O_WRITE_SHORT, COpcodeAttributes("O_WRITE_SHORT", "write_short", 2)); + SetAt(O_WRITE_INT, COpcodeAttributes("O_WRITE_INT", "write_int", 2)); + + SetAt(O_CALL_OFFSET_V0, COpcodeAttributes("O_CALL_OFFSET_V0", "call_offset_v0", 1)); + SetAt(O_CALL_OFFSET_V1, COpcodeAttributes("O_CALL_OFFSET_V1", "call_offset_v1", 2)); + SetAt(O_CALL_OFFSET_V2, COpcodeAttributes("O_CALL_OFFSET_V2", "call_offset_v2", 3)); + SetAt(O_CALL_OFFSET_V3, COpcodeAttributes("O_CALL_OFFSET_V3", "call_offset_v3", 4)); + SetAt(O_CALL_OFFSET_V4, COpcodeAttributes("O_CALL_OFFSET_V4", "call_offset_v4", 5)); + SetAt(O_CALL_OFFSET_R0, COpcodeAttributes("O_CALL_OFFSET_R0", "call_offset_r0", 1, expression)); + SetAt(O_CALL_OFFSET_R1, COpcodeAttributes("O_CALL_OFFSET_R1", "call_offset_r1", 2, expression)); + SetAt(O_CALL_OFFSET_R2, COpcodeAttributes("O_CALL_OFFSET_R2", "call_offset_r2", 3, expression)); + SetAt(O_CALL_OFFSET_R3, COpcodeAttributes("O_CALL_OFFSET_R3", "call_offset_r3", 4, expression)); + SetAt(O_CALL_OFFSET_R4, COpcodeAttributes("O_CALL_OFFSET_R4", "call_offset_r4", 5, expression)); + + SetAt(O_SHOW_IFACE_TAG, COpcodeAttributes("O_SHOW_IFACE_TAG", "show_iface_tag", 1)); + SetAt(O_HIDE_IFACE_TAG, COpcodeAttributes("O_HIDE_IFACE_TAG", "hide_iface_tag", 1)); + SetAt(O_IS_IFACE_TAG_ACTIVE, COpcodeAttributes("O_IS_IFACE_TAG_ACTIVE", "is_iface_tag_active", 1, expression)); + + SetAt(O_GET_BODYPART_HIT_MODIFIER, COpcodeAttributes("O_GET_BODYPART_HIT_MODIFIER", "get_bodypart_hit_modifier", 1, expression)); + SetAt(O_SET_BODYPART_HIT_MODIFIER, COpcodeAttributes("O_SET_BODYPART_HIT_MODIFIER", "set_bodypart_hit_modifier", 2)); + + + + //1.41 + SetAt(O_SET_CRITICAL_TABLE, COpcodeAttributes("O_SET_CRITICAL_TABLE", "set_critical_table", 5)); + SetAt(O_GET_CRITICAL_TABLE, COpcodeAttributes("O_GET_CRITICAL_TABLE", "get_critical_table", 4, expression)); + SetAt(O_RESET_CRITICAL_TABLE, COpcodeAttributes("O_RESET_CRITICAL_TABLE", "reset_critical_table", 4)); + SetAt(O_GET_SFALL_ARG, COpcodeAttributes("O_GET_SFALL_ARG", "get_sfall_arg", 0, expression)); + SetAt(O_SET_SFALL_RETURN, COpcodeAttributes("O_SET_SFALL_RETURN", "set_sfall_return", 1)); + SetAt(O_SET_UNSPENT_AP_BONUS, COpcodeAttributes("O_SET_UNSPENT_AP_BONUS", "set_unspent_ap_bonus", 1)); + SetAt(O_GET_UNSPENT_AP_BONUS, COpcodeAttributes("O_GET_UNSPENT_AP_BONUS", "get_unspent_ap_bonus", 0, expression)); + SetAt(O_SET_UNSPENT_AP_PERK_BONUS, COpcodeAttributes("O_SET_UNSPENT_AP_PERK_BONUS", "set_unspent_ap_perk_bonus", 1)); + SetAt(O_GET_UNSPENT_AP_PERK_BONUS, COpcodeAttributes("O_GET_UNSPENT_AP_PERK_BONUS", "get_unspent_ap_perk_bonus", 0, expression)); + SetAt(O_INIT_HOOK, COpcodeAttributes("O_INIT_HOOK", "init_hook", 0, expression)); + SetAt(O_GET_INI_STRING, COpcodeAttributes("O_GET_INI_STRING", "get_ini_string", 1, expression)); + + //1.42 + SetAt(O_SQRT, COpcodeAttributes("O_SQRT", "sqrt", 1, expression)); + SetAt(O_ABS, COpcodeAttributes("O_ABS", "abs", 1, expression)); + SetAt(O_SIN, COpcodeAttributes("O_SIN", "sin", 1, expression)); + SetAt(O_COS, COpcodeAttributes("O_COS", "cos", 1, expression)); + SetAt(O_TAN, COpcodeAttributes("O_TAN", "tan", 1, expression)); + SetAt(O_ARCTAN, COpcodeAttributes("O_ARCTAN", "arctan", 2, expression)); + SetAt(O_SET_PALETTE, COpcodeAttributes("O_SET_PALETTE", "set_palette", 1)); + + //1.46b + SetAt(O_REMOVE_SCRIPT, COpcodeAttributes("O_REMOVE_SCRIPT", "remove_script", 1)); + SetAt(O_SET_SCRIPT, COpcodeAttributes("O_SET_SCRIPT", "set_script", 2)); + SetAt(O_GET_SCRIPT, COpcodeAttributes("O_GET_SCRIPT", "get_script", 1, expression)); + SetAt(O_NB_CREATE_CHAR, COpcodeAttributes("O_NB_CREATE_CHAR", "nb_create_char", 0, expression)); + SetAt(O_FS_CREATE, COpcodeAttributes("O_FS_CREATE", "fs_create", 2, expression)); + SetAt(O_FS_COPY, COpcodeAttributes("O_FS_COPY", "fs_copy", 2, expression)); + SetAt(O_FS_FIND, COpcodeAttributes("O_FS_FIND", "fs_find", 1, expression)); + SetAt(O_FS_WRITE_BYTE, COpcodeAttributes("O_FS_WRITE_BYTE", "fs_write_byte", 2)); + SetAt(O_FS_WRITE_SHORT, COpcodeAttributes("O_FS_WRITE_SHORT", "fs_write_short", 2)); + SetAt(O_FS_WRITE_INT, COpcodeAttributes("O_FS_WRITE_INT", "fs_write_int", 2)); + SetAt(O_FS_WRITE_FLOAT, COpcodeAttributes("O_FS_WRITE_FLOAT", "fs_write_float", 2)); + SetAt(O_FS_WRITE_STRING,COpcodeAttributes("O_FS_WRITE_STRING","fs_write_string",2)); + SetAt(O_FS_DELETE, COpcodeAttributes("O_FS_DELETE", "fs_delete", 1)); + SetAt(O_FS_SIZE, COpcodeAttributes("O_FS_SIZE", "fs_size", 1, expression)); + SetAt(O_FS_POS, COpcodeAttributes("O_FS_POS", "fs_pos", 1, expression)); + SetAt(O_FS_SEEK, COpcodeAttributes("O_FS_SEEK", "fs_seek", 2)); + SetAt(O_FS_RESIZE, COpcodeAttributes("O_FS_RESIZE", "fs_resize", 2)); + SetAt(O_GET_PROTO_DATA, COpcodeAttributes("O_GET_PROTO_DATA", "get_proto_data", 2, expression)); + + //1.47b + SetAt(O_SET_PROTO_DATA, COpcodeAttributes("O_SET_PROTO_DATA", "set_proto_data", 3)); + SetAt(O_SET_SELF, COpcodeAttributes("O_SET_SELF", "set_self", 1)); + SetAt(O_REGISTER_HOOK, COpcodeAttributes("O_REGISTER_HOOK", "register_hook", 1)); + + SetAt(O_FS_WRITE_BSTRING, COpcodeAttributes("O_FS_WRITE_BSTRING", "fs_write_bstring", 2)); + SetAt(O_FS_READ_BYTE, COpcodeAttributes("O_FS_READ_BYTE", "fs_read_byte", 1, expression)); + SetAt(O_FS_READ_SHORT, COpcodeAttributes("O_FS_READ_SHORT", "fs_read_short", 1, expression)); + SetAt(O_FS_READ_INT, COpcodeAttributes("O_FS_READ_INT", "fs_read_int", 1, expression)); + SetAt(O_FS_READ_FLOAT, COpcodeAttributes("O_FS_READ_FLOAT", "fs_read_float", 1, expression)); + + + SetAt(O_LIST_BEGIN, COpcodeAttributes("O_LIST_BEGIN", "list_begin", 1, expression)); + SetAt(O_LIST_NEXT, COpcodeAttributes("O_LIST_NEXT", "list_next", 1, expression)); + SetAt(O_LIST_END, COpcodeAttributes("O_LIST_END", "list_end", 1)); + + //1.49d + SetAt(O_SFALL_VER_MAJOR, COpcodeAttributes("O_SFALL_VER_MAJOR", "sfall_ver_major", 0, expression)); + SetAt(O_SFALL_VER_MINOR, COpcodeAttributes("O_SFALL_VER_MINOR", "sfall_ver_minor", 0, expression)); + SetAt(O_SFALL_VER_BUILD, COpcodeAttributes("O_SFALL_VER_BUILD", "sfall_ver_build", 0, expression)); + + SetAt(O_HERO_SELECT_WIN, COpcodeAttributes("O_HERO_SELECT_WIN", "hero_select_win", 1)); + SetAt(O_SET_HERO_RACE, COpcodeAttributes("O_SET_HERO_RACE", "set_hero_race", 1)); + SetAt(O_SET_HERO_STYLE, COpcodeAttributes("O_SET_HERO_STYLE", "set_hero_style", 1)); + + SetAt(O_SET_CRITTER_BURST_DISABLE, COpcodeAttributes("O_SET_CRITTER_BURST_DISABLE", "set_critter_burst_disable", 2)); + + + + SetAt(O_GET_WEAPON_AMMO_PID, COpcodeAttributes("O_GET_WEAPON_AMMO_PID", "get_weapon_ammo_pid", 1, expression)); + SetAt(O_SET_WEAPON_AMMO_PID, COpcodeAttributes("O_SET_WEAPON_AMMO_PID", "set_weapon_ammo_pid", 2)); + SetAt(O_GET_WEAPON_AMMO_COUNT, COpcodeAttributes("O_GET_WEAPON_AMMO_COUNT", "get_weapon_ammo_count", 1, expression)); + SetAt(O_SET_WEAPON_AMMO_COUNT, COpcodeAttributes("O_SET_WEAPON_AMMO_COUNT", "set_weapon_ammo_count", 2)); + SetAt(O_WRITE_STRING, COpcodeAttributes("O_WRITE_STRING", "write_String", 2)); + SetAt(O_GET_MOUSE_X, COpcodeAttributes("O_GET_MOUSE_X", "get_mouse_x", 0, expression)); + SetAt(O_GET_MOUSE_Y, COpcodeAttributes("O_GET_MOUSE_Y", "get_mouse_y", 0, expression)); + SetAt(O_GET_MOUSE_BUTTONS, COpcodeAttributes("O_GET_MOUSE_BUTTONS", "get_mouse_buttons", 0, expression)); + SetAt(O_GET_WINDOW_UNDER_MOUSE, COpcodeAttributes("O_GET_WINDOW_UNDER_MOUSE", "get_window_under_mouse", 0, expression)); + SetAt(O_GET_SCREEN_WIDTH, COpcodeAttributes("O_GET_SCREEN_WIDTH", "get_screen_width", 0, expression)); + SetAt(O_GET_SCREEN_HEIGHT, COpcodeAttributes("O_GET_SCREEN_HEIGHT", "get_screen_height", 0, expression)); + SetAt(O_STOP_GAME, COpcodeAttributes("O_STOP_GAME", "stop_game", 0)); + SetAt(O_RESUME_GAME, COpcodeAttributes("O_RESUME_GAME", "resume_game", 0)); + SetAt(O_CREATE_MESSAGE_WINDOW, COpcodeAttributes("O_CREATE_MESSAGE_WINDOW", "create_message_window", 1)); + SetAt(O_REMOVE_TRAIT, COpcodeAttributes("O_REMOVE_TRAIT", "remove_trait", 1)); + SetAt(O_GET_LIGHT_LEVEL, COpcodeAttributes("O_GET_LIGHT_LEVEL", "get_light_level", 0, expression)); + SetAt(O_REFRESH_PC_ART, COpcodeAttributes("O_REFRESH_PC_ART", "refresh_pc_art", 0)); + SetAt(O_GET_ATTACK_TYPE, COpcodeAttributes("O_GET_ATTACK_TYPE", "get_attack_type", 0, expression)); + SetAt(O_FORCE_ENCOUNTER_WITH_FLAGS, COpcodeAttributes("O_FORCE_ENCOUNTER_WITH_FLAGS", "force_encounter_with_flags", 2)); + SetAt(O_SET_MAP_TIME_MULTI, COpcodeAttributes("O_SET_MAP_TIME_MULTI", "set_map_time_multi", 1)); + SetAt(O_PLAY_SFALL_SOUND, COpcodeAttributes("O_PLAY_SFALL_SOUND", "play_sfall_sound", 2, expression)); + SetAt(O_STOP_SFALL_SOUND, COpcodeAttributes("O_STOP_SFALL_SOUND", "stop_sfall_sound", 1)); + SetAt(O_CREATE_ARRAY, COpcodeAttributes("O_CREATE_ARRAY", "create_array", 2, expression)); + SetAt(O_SET_ARRAY, COpcodeAttributes("O_SET_ARRAY", "set_array", 3)); + SetAt(O_GET_ARRAY, COpcodeAttributes("O_GET_ARRAY", "get_array", 2, expression)); + SetAt(O_FREE_ARRAY, COpcodeAttributes("O_FREE_ARRAY", "free_array", 1)); + + //sfall vrs 2.8 + SetAt(O_TS_LEN_ARRAY, COpcodeAttributes("O_TS_LEN_ARRAY", "len_array", 1, expression)); + SetAt(O_TS_RESIZE_ARRAY, COpcodeAttributes("O_TS_RESIZE_ARRAY", "resize_array", 2)); + SetAt(O_TS_TEMP_ARRAY, COpcodeAttributes("O_TS_TEMP_ARRAY", "temp_array", 2, expression)); + SetAt(O_TS_FIX_ARRAY, COpcodeAttributes("O_TS_FIX_ARRAY", "fix_array", 1)); + SetAt(O_TS_STRING_SPLIT, COpcodeAttributes("O_TS_STRING_SPLIT", "string_split", 2, expression)); + SetAt(O_TS_LIST_AS_ARRAY, COpcodeAttributes("O_TS_LIST_AS_ARRAY", "list_as_array", 1, expression)); + + // sfall 2.8b + SetAt(O_TS_ATOI, COpcodeAttributes("O_TS_ATOI", "atoi", 1, expression)); + SetAt(O_TS_ATOF, COpcodeAttributes("O_TS_ATOF", "atof", 1, expression)); + + // sfall 2.9a + SetAt(O_TS_SCAN_ARRAY, COpcodeAttributes("O_TS_SCAN_ARRAY", "scan_array", 2, expression)); + SetAt(O_TS_TILE_PID, COpcodeAttributes("O_TS_TILE_PID", "get_tile_fid", 1, expression)); + SetAt(O_TS_MODIFIED_INI, COpcodeAttributes("O_TS_MODIFIED_INI", "modified_ini", 0, expression)); + SetAt(O_TS_GET_SFALL_ARGS, COpcodeAttributes("O_TS_GET_SFALL_ARGS", "get_sfall_args", 0, expression)); + + // sfall 2.12 + SetAt(O_TS_SET_SFALL_ARG, COpcodeAttributes("O_TS_GET_SFALL_ARG", "set_sfall_arg", 2)); + + // sfall 2.16 + SetAt(O_TS_FORCE_AIMED_SHOTS, COpcodeAttributes("O_TS_FORCE_AIMED_SHOTS", "force_aimed_shots", 1)); + SetAt(O_TS_DISABLE_AIMED_SHOTS, COpcodeAttributes("O_TS_DISABLE_AIMED_SHOTS", "disable_aimed_shots", 1)); + SetAt(O_TS_MARK_MOVIE_PLAYED, COpcodeAttributes("O_TS_MARK_MOVIE_PLAYED", "mark_movie_played", 1)); + + // sfall 2.17 + SetAt(O_TS_GET_NPC_LEVEL, COpcodeAttributes("O_TS_GET_NPC_LEVEL", "get_npc_level", 1, expression)); + + // sfall 3.0 + SetAt(O_TS_SET_CRITTER_SKILL_POINTS, COpcodeAttributes("O_TS_SET_CRITTER_SKILL_POINTS", "set_critter_skill_points", 3)); + SetAt(O_TS_GET_CRITTER_SKILL_POINTS, COpcodeAttributes("O_TS_GET_CRITTER_SKILL_POINTS", "get_critter_skill_points", 2, expression)); + SetAt(O_TS_SET_AVAILABLE_SKILL_POINTS, COpcodeAttributes("O_TS_SET_AVAILABLE_SKILL_POINTS", "set_available_skill_points", 1)); + SetAt(O_TS_GET_AVAILABLE_SKILL_POINTS, COpcodeAttributes("O_TS_GET_AVAILABLE_SKILL_POINTS", "get_available_skill_points", 0, expression)); + SetAt(O_TS_MOD_SKILL_POINTS_PER_LEVEL, COpcodeAttributes("O_TS_MOD_SKILL_POINTS_PER_LEVEL", "mod_skill_points_per_level", 1)); + SetAt(O_TS_SET_PERK_FREQ, COpcodeAttributes("O_TS_SET_PERK_FREQ", "set_perk_freq", 1)); + SetAt(O_TS_GET_LAST_TARGET, COpcodeAttributes("O_TS_GET_LAST_TARGET", "get_last_attacker", 1, expression)); + SetAt(O_TS_GET_LAST_ATTACKER, COpcodeAttributes("O_TS_GET_LAST_ATTACKER", "get_last_target", 1, expression)); + SetAt(O_TS_BLOCK_COMBAT, COpcodeAttributes("O_TS_BLOCK_COMBAT", "block_combat", 1)); + + // sfall 3.3 + SetAt(O_TS_TILE_UNDER_CURSOR, COpcodeAttributes("O_TS_TILE_UNDER_CURSOR", "tile_under_cursor", 0, expression)); + SetAt(O_TS_GET_BARTER_MOD, COpcodeAttributes("O_TS_GET_BARTER_MOD", "gdialog_get_barter_mod", 0, expression)); + SetAt(O_TS_SET_INVEN_AP_COST, COpcodeAttributes("O_TS_SET_INVEN_AP_COST", "set_inven_ap_cost", 1)); + + // sfall 3.4 + SetAt(O_TS_SUBSTR, COpcodeAttributes("O_TS_SUBSTR", "substr", 3, expression)); + SetAt(O_TS_STRLEN, COpcodeAttributes("O_TS_STRLEN", "strlen", 1, expression)); + SetAt(O_TS_SPRINTF, COpcodeAttributes("O_TS_SPRINTF", "sprintf", 2, expression)); + SetAt(O_TS_ORD, COpcodeAttributes("O_TS_ORD", "charcode", 1, expression)); // sfall 3.5 + //SetAt(O_TS_RESERVD2, COpcodeAttributes("O_TS_RESERVD2", "substr", 3, expression)); + SetAt(O_TS_TYPEOF, COpcodeAttributes("O_TS_TYPEOF", "typeof", 1, expression)); + SetAt(O_TS_LOG, COpcodeAttributes("O_TS_LOG", "log", 1, expression)); // sfall 3.5 + SetAt(O_TS_EXP, COpcodeAttributes("O_TS_EXP", "exponent", 1, expression)); // sfall 3.5 + //SetAt(O_TS_CEIL, COpcodeAttributes("O_TS_CEIL", "ceil", 1, expression)); + SetAt(O_TS_ROUND, COpcodeAttributes("O_TS_ROUND", "round", 1, expression)); // sfall 3.5 + SetAt(O_TS_SAVE_ARRAY, COpcodeAttributes("O_TS_SAVE_ARRAY", "save_array", 2)); + SetAt(O_TS_LOAD_ARRAY, COpcodeAttributes("O_TS_LOAD_ARRAY", "load_array", 1, expression)); + SetAt(O_TS_GET_ARRAY_KEY, COpcodeAttributes("O_TS_GET_ARRAY_KEY", "array_key", 2, expression)); + SetAt(O_TS_STACK_ARRAY, COpcodeAttributes("O_TS_STACK_ARRAY", "arrayexpr", 2, expression)); + + SetAt(O_TS_REG_ANIM_DESTROY, COpcodeAttributes("O_TS_REG_ANIM_DESTROY", "reg_anim_destroy", 1)); + SetAt(O_TS_REG_ANIM_ANIMATE_AND_HIDE, COpcodeAttributes("O_TS_REG_ANIM_ANIMATE_AND_HIDE", "reg_anim_animate_and_hide", 3)); + SetAt(O_TS_REG_ANIM_COMBAT_CHECK, COpcodeAttributes("O_TS_REG_ANIM_COMBAT_CHECK", "reg_anim_combat_check", 1)); + SetAt(O_TS_REG_ANIM_LIGHT, COpcodeAttributes("O_TS_REG_ANIM_LIGHT", "reg_anim_light", 3)); + SetAt(O_TS_REG_ANIM_CHANGE_FID, COpcodeAttributes("O_TS_REG_ANIM_CHANGE_FID", "reg_anim_change_fid", 3)); + SetAt(O_TS_REG_ANIM_TAKE_OUT, COpcodeAttributes("O_TS_REG_ANIM_TAKE_OUT", "reg_anim_take_out", 3)); + SetAt(O_TS_REG_ANIM_TURN_TOWARDS, COpcodeAttributes("O_TS_REG_ANIM_TURN_TOWARDS", "reg_anim_turn_towards", 3)); + + SetAt(O_TS_EXPLOSIONS_METARULE, COpcodeAttributes("O_TS_EXPLOSIONS_METARULE", "metarule2_explosions", 3, expression)); + + // sfall 3.5 + SetAt(O_TS_REGISTER_HOOK_PROC, COpcodeAttributes("O_TS_REGISTER_HOOK_PROC", "register_hook_proc", 2, COpcodeAttributes::TYPE_STATEMENT, COpcodeAttributes::CATEGORY_PREFIX, procArgs_register_hook_proc, 1)); + SetAt(O_TS_POW, COpcodeAttributes("O_POW", "^", 2, expression, infix)); + SetAt(O_TS_MESSAGE_STR_GAME, COpcodeAttributes("O_TS_MESSAGE_STR_GAME", "message_str_game", 2, expression)); + SetAt(O_TS_SNEAK_SUCCESS, COpcodeAttributes("O_TS_SNEAK_SUCCESS", "sneak_success", 0, expression)); + SetAt(O_TS_TILE_LIGHT, COpcodeAttributes("O_TS_SNEAK_SUCCESS", "tile_light", 2, expression)); + SetAt(O_TS_MAKE_STRAIGHT_PATH, COpcodeAttributes("O_TS_MAKE_STRAIGHT_PATH", "obj_blocking_line", 3, expression)); + SetAt(O_TS_OBJ_BLOCKING_AT, COpcodeAttributes("O_TS_OBJ_BLOCKING_AT", "obj_blocking_tile", 3, expression)); + SetAt(O_TS_TILE_GET_OBJECTS, COpcodeAttributes("O_TS_TILE_GET_OBJECTS", "tile_get_objs", 2, expression)); + SetAt(O_TS_GET_PARTY_MEMBERS, COpcodeAttributes("O_TS_GET_PARTY_MEMBERS", "party_member_list", 1, expression)); + SetAt(O_TS_PATH_FIND, COpcodeAttributes("O_TS_PATH_FIND", "path_find_to", 3, expression)); + SetAt(O_TS_CREATE_SPATIAL, COpcodeAttributes("O_TS_CREATE_SPATIAL", "create_spatial", 4, expression)); + SetAt(O_TS_ART_EXISTS, COpcodeAttributes("O_TS_ART_EXISTS", "art_exists", 1, expression)); + SetAt(O_TS_OBJ_IS_CARRYING_OBJ, COpcodeAttributes("O_TS_OBJ_IS_CARRYING_OBJ", "obj_is_carrying_obj", 2, expression)); + //sfall end + + SetAt(O_STRINGOP, COpcodeAttributes("O_STRINGOP", "", 0, expression)); + SetAt(O_FLOATOP, COpcodeAttributes("O_FLOATOP", "", 0, expression)); + SetAt(O_INTOP, COpcodeAttributes("O_INTOP", "", 0, expression)); } diff --git a/ProcTable.cpp b/ProcTable.cpp index 357cce7..6b94f09 100644 --- a/ProcTable.cpp +++ b/ProcTable.cpp @@ -12,22 +12,22 @@ // CProcDescriptor CProcDescriptor::CProcDescriptor() : - m_ulNameOffset(0), - m_ulType(0), - m_ulTime(0), - m_ulExpressionOffset(0), - m_ulBodyOffset(0), - m_ulNumArgs(0) + m_ulNameOffset(0), + m_ulType(0), + m_ulTime(0), + m_ulExpressionOffset(0), + m_ulBodyOffset(0), + m_ulNumArgs(0) { } CProcDescriptor::CProcDescriptor(const CProcDescriptor& Item) : - m_ulNameOffset(Item.m_ulNameOffset), - m_ulType(Item.m_ulType), - m_ulTime(Item.m_ulTime), - m_ulExpressionOffset(Item.m_ulExpressionOffset), - m_ulBodyOffset(Item.m_ulBodyOffset), - m_ulNumArgs(Item.m_ulNumArgs) + m_ulNameOffset(Item.m_ulNameOffset), + m_ulType(Item.m_ulType), + m_ulTime(Item.m_ulTime), + m_ulExpressionOffset(Item.m_ulExpressionOffset), + m_ulBodyOffset(Item.m_ulBodyOffset), + m_ulNumArgs(Item.m_ulNumArgs) { } @@ -38,16 +38,16 @@ CProcDescriptor::~CProcDescriptor() CProcDescriptor& CProcDescriptor::operator = (const CProcDescriptor& Item) { - if (&Item != this) { - m_ulNameOffset = Item.m_ulNameOffset; - m_ulType = Item.m_ulType; - m_ulTime = Item.m_ulTime; - m_ulExpressionOffset = Item.m_ulExpressionOffset; - m_ulBodyOffset = Item.m_ulBodyOffset; - m_ulNumArgs = Item.m_ulNumArgs; - } + if (&Item != this) { + m_ulNameOffset = Item.m_ulNameOffset; + m_ulType = Item.m_ulType; + m_ulTime = Item.m_ulTime; + m_ulExpressionOffset = Item.m_ulExpressionOffset; + m_ulBodyOffset = Item.m_ulBodyOffset; + m_ulNumArgs = Item.m_ulNumArgs; + } - return (*this); + return (*this); } void CProcDescriptor::Serialize(CArchive& ar) @@ -55,85 +55,85 @@ void CProcDescriptor::Serialize(CArchive& ar) //if (ar.IsStoring()) { if (false) { - // ASSERT(FALSE); - } - else { - UINT uiTotalRead; + // ASSERT(FALSE); + } + else { + UINT uiTotalRead; - uiTotalRead = ReadMSBULong(ar, m_ulNameOffset); - uiTotalRead += ReadMSBULong(ar, m_ulType); - uiTotalRead += ReadMSBULong(ar, m_ulTime); - uiTotalRead += ReadMSBULong(ar, m_ulExpressionOffset); - uiTotalRead += ReadMSBULong(ar, m_ulBodyOffset); - uiTotalRead += ReadMSBULong(ar, m_ulNumArgs); + uiTotalRead = ReadMSBULong(ar, m_ulNameOffset); + uiTotalRead += ReadMSBULong(ar, m_ulType); + uiTotalRead += ReadMSBULong(ar, m_ulTime); + uiTotalRead += ReadMSBULong(ar, m_ulExpressionOffset); + uiTotalRead += ReadMSBULong(ar, m_ulBodyOffset); + uiTotalRead += ReadMSBULong(ar, m_ulNumArgs); -// printf("=================\n"); -// printf("uiTotalRead = %u\n", uiTotalRead); -// printf("m_ulNameOffset = 0x%08X\n", m_ulNameOffset); -// printf("m_ulType = 0x%08X\n", m_ulType); -// printf("m_ulTime = 0x%08X\n", m_ulTime); -// printf("m_ulExpressionOffset = 0x%08X\n", m_ulExpressionOffset); -// printf("m_ulBodyOffset = 0x%08X\n", m_ulBodyOffset); -// printf("m_ulNumArgs = 0x%08X\n", m_ulNumArgs); +// printf("=================\n"); +// printf("uiTotalRead = %u\n", uiTotalRead); +// printf("m_ulNameOffset = 0x%08X\n", m_ulNameOffset); +// printf("m_ulType = 0x%08X\n", m_ulType); +// printf("m_ulTime = 0x%08X\n", m_ulTime); +// printf("m_ulExpressionOffset = 0x%08X\n", m_ulExpressionOffset); +// printf("m_ulBodyOffset = 0x%08X\n", m_ulBodyOffset); +// printf("m_ulNumArgs = 0x%08X\n", m_ulNumArgs); - if (uiTotalRead != (sizeof(ULONG) * 6)) { - printf("Error: Unable read procedure descriptor\n"); - AfxThrowUserException(); - } - } + if (uiTotalRead != (sizeof(ULONG) * 6)) { + printf("Error: Unable read procedure descriptor\n"); + AfxThrowUserException(); + } + } } void CProcDescriptor::Dump(CArchive& ar) { - CString strOutLine; - CString strType; + CString strOutLine; + CString strType; if (m_ulType != 0x00000000) { - strType = "( "; + strType = "( "; if (m_ulType & P_TIMED) { - strType += "timed "; - } + strType += "timed "; + } if (m_ulType & P_CONDITIONAL) { - strType += "conditional "; - } + strType += "conditional "; + } if (m_ulType & P_IMPORT) { - strType += "import "; - } + strType += "import "; + } - if (m_ulType & P_EXPORT) { - strType += "export "; - } + if (m_ulType & P_EXPORT) { + strType += "export "; + } - if (m_ulType & P_CRITICAL) { - strType += "critical "; - } + if (m_ulType & P_CRITICAL) { + strType += "critical "; + } - strType += ")"; - } - else { - strType = "No special types"; - } + strType += ")"; + } + else { + strType = "No special types"; + } - strOutLine.Format("Name offset: 0x%08X\n", m_ulNameOffset); - ar.WriteString(strOutLine); + strOutLine.Format("Name offset: 0x%08X\n", m_ulNameOffset); + ar.WriteString(strOutLine); strOutLine.Format("Type: 0x%08X // %s\n", m_ulType, strType.c_str()); - ar.WriteString(strOutLine); - strOutLine.Format("Time: 0x%08X // %d\n", m_ulTime, m_ulTime); - ar.WriteString(strOutLine); - strOutLine.Format("Expression offset: 0x%08X\n", m_ulExpressionOffset); - ar.WriteString(strOutLine); - strOutLine.Format("Body offset: 0x%08X\n", m_ulBodyOffset); - ar.WriteString(strOutLine); - strOutLine.Format("Number of args: 0x%08X // %d\n", m_ulNumArgs, m_ulNumArgs); - ar.WriteString(strOutLine); + ar.WriteString(strOutLine); + strOutLine.Format("Time: 0x%08X // %d\n", m_ulTime, m_ulTime); + ar.WriteString(strOutLine); + strOutLine.Format("Expression offset: 0x%08X\n", m_ulExpressionOffset); + ar.WriteString(strOutLine); + strOutLine.Format("Body offset: 0x%08X\n", m_ulBodyOffset); + ar.WriteString(strOutLine); + strOutLine.Format("Number of args: 0x%08X // %d\n", m_ulNumArgs, m_ulNumArgs); + ar.WriteString(strOutLine); } @@ -148,32 +148,32 @@ CProcTable::~CProcTable() } struct ProcBodyOffset { - ULONG m_ulProcIndex; - ULONG m_ulBodyOffset; + ULONG m_ulProcIndex; + ULONG m_ulBodyOffset; }; int compareProcBodyOffsets(const void* elem0, const void* elem1) { - ProcBodyOffset offset0 = *((ProcBodyOffset*)elem0); - ProcBodyOffset offset1 = *((ProcBodyOffset*)elem1); + ProcBodyOffset offset0 = *((ProcBodyOffset*)elem0); + ProcBodyOffset offset1 = *((ProcBodyOffset*)elem1); - if (offset0.m_ulBodyOffset < offset1.m_ulBodyOffset) { - return -1; - } - else if (offset0.m_ulBodyOffset > offset1.m_ulBodyOffset) { - return 1; - } - else { - if (offset0.m_ulProcIndex < offset1.m_ulProcIndex) { - return -1; - } - else if (offset0.m_ulProcIndex > offset1.m_ulProcIndex) { - return 1; - } - else { - return 0; - } - } + if (offset0.m_ulBodyOffset < offset1.m_ulBodyOffset) { + return -1; + } + else if (offset0.m_ulBodyOffset > offset1.m_ulBodyOffset) { + return 1; + } + else { + if (offset0.m_ulProcIndex < offset1.m_ulProcIndex) { + return -1; + } + else if (offset0.m_ulProcIndex > offset1.m_ulProcIndex) { + return 1; + } + else { + return 0; + } + } } void CProcTable::Serialize(CArchive& ar) @@ -181,132 +181,132 @@ void CProcTable::Serialize(CArchive& ar) //if (ar.IsStoring()) { if(false) { - // ASSERT(FALSE); - } - else { - m_Table.RemoveAll(); - m_ProcSize.RemoveAll(); + // ASSERT(FALSE); + } + else { + m_Table.RemoveAll(); + m_ProcSize.RemoveAll(); - ULONG ulSizeOfTable; - ULONG ulRead; + ULONG ulSizeOfTable; + ULONG ulRead; - ar.Flush(); - ULONG ulSizeOfFile = ULONG(ar.GetFile()->GetLength()); + ar.Flush(); + ULONG ulSizeOfFile = ULONG(ar.GetFile()->GetLength()); - ulRead = ReadMSBULong(ar, ulSizeOfTable); + ulRead = ReadMSBULong(ar, ulSizeOfTable); if (ulRead != sizeof(ulSizeOfTable)) { - printf("Error: Unable read size of procedures table\n"); - AfxThrowUserException(); - } + printf("Error: Unable read size of procedures table\n"); + AfxThrowUserException(); + } - m_Table.SetSize(ulSizeOfTable); - m_ProcSize.SetSize(ulSizeOfTable); + m_Table.SetSize(ulSizeOfTable); + m_ProcSize.SetSize(ulSizeOfTable); - ULONG ulIndexOfProcOffset = 0; - ProcBodyOffset* pOffsets = new ProcBodyOffset[ulSizeOfTable + 1]; + ULONG ulIndexOfProcOffset = 0; + ProcBodyOffset* pOffsets = new ProcBodyOffset[ulSizeOfTable + 1]; - if (pOffsets == NULL) { -// AfxThrowMemoryException(); + if (pOffsets == NULL) { +// AfxThrowMemoryException(); throw 1; - } + } - for(ULONG i = 0; i < ulSizeOfTable; i++) { -// printf("======== %u =========\n", i); + 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_ProcSize.at(i) = 0; // Initialize size of procedure if (!(m_Table.at(i).m_ulType & P_IMPORT)) { if ((m_Table.at(i).m_ulBodyOffset != 0) && (m_Table.at(i).m_ulBodyOffset != ulSizeOfFile)) { - pOffsets[ulIndexOfProcOffset].m_ulProcIndex = i; + pOffsets[ulIndexOfProcOffset].m_ulProcIndex = i; pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = m_Table.at(i).m_ulBodyOffset; - ulIndexOfProcOffset++; - } - else { + ulIndexOfProcOffset++; + } + else { m_Table.at(i).m_ulType |= P_NOTIMPLEMENTED; - } - } - } + } + } + } - pOffsets[ulIndexOfProcOffset].m_ulProcIndex = ulIndexOfProcOffset + 1; - pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = ulSizeOfFile; + pOffsets[ulIndexOfProcOffset].m_ulProcIndex = ulIndexOfProcOffset + 1; + pOffsets[ulIndexOfProcOffset].m_ulBodyOffset = ulSizeOfFile; - qsort(pOffsets, ulIndexOfProcOffset, sizeof(ProcBodyOffset), compareProcBodyOffsets); + qsort(pOffsets, ulIndexOfProcOffset, sizeof(ProcBodyOffset), compareProcBodyOffsets); - // Sizes of procedures - for(ULONG i = 0; i < ulIndexOfProcOffset; i++) { - if (pOffsets[i + 1].m_ulBodyOffset >= pOffsets[i].m_ulBodyOffset) { + // Sizes of procedures + for(ULONG i = 0; i < ulIndexOfProcOffset; i++) { + 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; - } - else { - printf("Error: Procedures are not sorted in ascending address order\n"); - AfxThrowUserException(); - } - } + } + else { + printf("Error: Procedures are not sorted in ascending address order\n"); + AfxThrowUserException(); + } + } - delete [] pOffsets; + delete [] pOffsets; - for(ULONG i = 0; i < ulSizeOfTable; i++) { + for(ULONG i = 0; i < ulSizeOfTable; i++) { if (m_Table.at(i).m_ulBodyOffset != 0) { m_ulOffsetOfProcSection = m_Table.at(i).m_ulBodyOffset; - break; - } - } + break; + } + } -// // For debugging only -// printf("Total: %d\n", m_Table.GetSize()); +// // For debugging only +// printf("Total: %d\n", m_Table.GetSize()); // -// for(i = 0; i < ulSizeOfTable; i++) { -// printf("Offset: 0x%08X, size: 0x%08X\n", m_Table.at(i).m_ulBodyOffset, m_ProcSize.at(i)); -// } +// 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("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection); - } +// printf("m_ulOffsetOfProcSection: 0x%08X\n", m_ulOffsetOfProcSection); + } } INT_PTR CProcTable::GetSize() { - return m_Table.GetSize(); + return m_Table.GetSize(); } ULONG CProcTable::GetSizeOfProc(INT_PTR nIndex) { - if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { - printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex); - AfxThrowUserException(); - } + if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { + printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex); + AfxThrowUserException(); + } return m_ProcSize.at(nIndex); } ULONG CProcTable::GetOffsetOfProcSection() { - return m_ulOffsetOfProcSection; + return m_ulOffsetOfProcSection; } void CProcTable::Dump(CArchive& ar) { - CString strOutLine; + CString strOutLine; for(unsigned int i = 0; i < m_Table.GetSize(); i++) { - strOutLine.Format("======== Procedure %d ========\n", i); + strOutLine.Format("======== Procedure %d ========\n", i); - ar.WriteString(strOutLine); + ar.WriteString(strOutLine); m_Table.at(i).Dump(ar); - ar.WriteString("\n"); - } + ar.WriteString("\n"); + } } CProcDescriptor& CProcTable::operator [] (INT_PTR nIndex) { - if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { - printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex); - AfxThrowUserException(); - } + if ((nIndex < 0) || (nIndex > m_ProcSize.GetUpperBound())) { + printf("Warning: Invalid index of procedure (%d). Exception will be thrown\n", nIndex); + AfxThrowUserException(); + } return m_Table.at(nIndex); } diff --git a/ProcTable.h b/ProcTable.h index 710b42b..0d1987b 100644 --- a/ProcTable.h +++ b/ProcTable.h @@ -8,53 +8,53 @@ // CProcDescriptor class CProcDescriptor : public CObject { public: - CProcDescriptor(); - CProcDescriptor(const CProcDescriptor& Item); - virtual ~CProcDescriptor(); + CProcDescriptor(); + CProcDescriptor(const CProcDescriptor& Item); + virtual ~CProcDescriptor(); public: - virtual void Serialize(CArchive& ar); + virtual void Serialize(CArchive& ar); - void Dump(CArchive& ar); + void Dump(CArchive& ar); public: - CProcDescriptor& operator = (const CProcDescriptor& Item); + 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 + 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 }; // CProcTable class CProcTable : public CObject { public: - CProcTable(); - virtual ~CProcTable(); + CProcTable(); + virtual ~CProcTable(); public: - virtual void Serialize(CArchive& ar); + virtual void Serialize(CArchive& ar); - INT_PTR GetSize(); - ULONG GetSizeOfProc(INT_PTR nIndex); - ULONG GetOffsetOfProcSection(); + INT_PTR GetSize(); + ULONG GetSizeOfProc(INT_PTR nIndex); + ULONG GetOffsetOfProcSection(); - void Dump(CArchive& ar); + void Dump(CArchive& ar); public: - CProcDescriptor& operator [] (INT_PTR nIndex); + CProcDescriptor& operator [] (INT_PTR nIndex); private: - // CProcTableArray - typedef CArray CProcTableArray; + // CProcTableArray + typedef CArray CProcTableArray; - CProcTableArray m_Table; - CDWordArray m_ProcSize; - ULONG m_ulOffsetOfProcSection; + CProcTableArray m_Table; + CDWordArray m_ProcSize; + ULONG m_ulOffsetOfProcSection; }; #endif diff --git a/StartupCode.h b/StartupCode.h index 11b8b02..0aaeba7 100644 --- a/StartupCode.h +++ b/StartupCode.h @@ -11,16 +11,16 @@ class CStartupCode { public: - enum Defaults { - c_nDefaultSize = 42 - }; + enum Defaults { + c_nDefaultSize = 42 + }; - CStartupCode(); - virtual ~CStartupCode(); - virtual void Serialize(CArchive& ar); + CStartupCode(); + virtual ~CStartupCode(); + virtual void Serialize(CArchive& ar); private: - COpcode m_Code[17]; + COpcode m_Code[17]; }; #endif diff --git a/Utility.cpp b/Utility.cpp index 2b82fa9..a47c07a 100644 --- a/Utility.cpp +++ b/Utility.cpp @@ -5,12 +5,12 @@ UINT ReadMSBWord(CArchive& ar, WORD& wValue) { char* pBuffer = reinterpret_cast(&wValue); - return (ar.Read(pBuffer + 1, 1) + ar.Read(pBuffer, 1)); + return (ar.Read(pBuffer + 1, 1) + ar.Read(pBuffer, 1)); } UINT ReadMSBULong(CArchive& ar, ULONG& ulValue) { char* pBuffer = reinterpret_cast(&ulValue); - return (ar.Read(pBuffer + 3, 1) + ar.Read(pBuffer + 2, 1) + - ar.Read(pBuffer + 1, 1) + ar.Read(pBuffer, 1)); + return (ar.Read(pBuffer + 3, 1) + ar.Read(pBuffer + 2, 1) + + ar.Read(pBuffer + 1, 1) + ar.Read(pBuffer, 1)); } diff --git a/main.cpp b/main.cpp index 581e344..8cd097b 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,3 @@ -// int2ssl.cpp : Defines the entry point for the console application. -// #include "stdafx.h" #include "FalloutScript.h" #include "XGetopt.h" @@ -7,11 +5,7 @@ using namespace std; -// The one and only application object - // Globals - - BOOL g_bDump = FALSE; int g_nFalloutVersion = 2; CString g_strIndentFill("\t"); @@ -29,220 +23,233 @@ BOOL ProcessCommandLine(int argc, char* argv[]); int main(int argc, char* argv[]) { - int nRetCode = 0; + int nRetCode = 0; - printf("Fallout script decompiler, version 8.3.0 (sfall edition)\n"); - printf("Copyright (C) Anchorite (TeamX), 2005-2009\n"); - printf("anchorite2001@yandex.ru\n"); - printf("Continued by Nirran, phobos2077 (2014-2015)\n"); - printf("Usage: int2ssl.exe [options] [-s value] file.int [file.ssl]\n"); - printf("Example: int2ssl.exe -d-1-a-b-e-s3 random.int\n"); - printf(" -d: dump file\n"); - printf(" -1: input file is Fallout 1 script\n"); - printf(" -a: ignore wrong number of arguments\n"); - printf(" -b: insert omitted arguments backward\n"); - printf(" -s: use Space instead of tab to indent\n"); - printf(" -e: stop decompiling on error\n"); - printf(" --: end of options\n"); - printf("\n"); + printf("Fallout script decompiler, version 8.3.0 (sfall edition)\n"); + printf("Copyright (C) Anchorite (TeamX), 2005-2009\n"); + printf("anchorite2001@yandex.ru\n"); + printf("Continued by Nirran, phobos2077 (2014-2015)\n"); + printf("Usage: int2ssl.exe [options] [-s value] file.int [file.ssl]\n"); + printf("Example: int2ssl.exe -d-1-a-b-e-s3 random.int\n"); + printf(" -d: dump file\n"); + printf(" -1: input file is Fallout 1 script\n"); + printf(" -a: ignore wrong number of arguments\n"); + printf(" -b: insert omitted arguments backward\n"); + printf(" -s: use Space instead of tab to indent\n"); + printf(" -e: stop decompiling on error\n"); + 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; + CFile fileInput; + CFile fileOutput; - //if (fileInput.Open(g_strInputFileName, CFile::modeRead | CFile::shareDenyWrite)) { - if (fileInput.Open(CString("BECA.int"), CFile::modeRead | CFile::shareDenyWrite)) + g_strInputFileName = "BECA.int"; + g_strOutputFileName = "BECA.int.ssl"; + + if (!fileInput.Open(g_strInputFileName, CFile::modeRead | CFile::shareDenyWrite)) + { + printf("Error: Unable open input file %s.\n", g_strInputFileName.c_str()); + if (g_bStopOnError == TRUE) { - //if (fileOutput.Open(g_strOutputFileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) { - if (fileOutput.Open(CString("BECA.int.ssl"), CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) - { - try - { - CArchive arInput(&fileInput, CArchive::load); - CFalloutScript Script; - - printf("Loading file %s...\n", g_strInputFileName.c_str()); - Script.Serialize(arInput); - - printf("File %s loaded successfuly\n", g_strInputFileName.c_str()); - printf("\n"); - - CArchive arOutput(&fileOutput, CArchive::store); - - if (g_bDump) - //if (true) - { - printf("Dumping...\n", g_strInputFileName.c_str()); - Script.Dump(arOutput); - - printf("File %s dumped successfuly\n", g_strInputFileName.c_str()); - } - else - { - printf("Decompiling...\n"); - - printf(" Init definitions\n"); - Script.InitDefinitions(); - - printf(" Processing code\n"); - Script.ProcessCode(); - - printf(" Storing sources\n"); - Script.StoreSource(arOutput); - printf("File %s decompiled successfuly\n", g_strInputFileName.c_str()); - } - } - - catch (const UserException& e) - { - // Error message already displayed - if (g_bStopOnError == TRUE) { - printf("Press ENTER to continue.\n"); - cin.get(); - } - return 1; - } - - catch(...) { - return 1; - /* - const int c_nErrMsgLen = 1024; - TCHAR lpszErrMsg[c_nErrMsgLen]; - e->GetErrorMessage(lpszErrMsg, c_nErrMsgLen); - printf("Error: %s.\n", lpszErrMsg); - if (g_bStopOnError == TRUE) { - printf("Press ENTER to continue.\n"); - cin.get(); - } - return 1;*/ - } - - return 0; - } - else { - printf("Error: Unable open file %s.\n", g_strOutputFileName.c_str()); - if (g_bStopOnError == TRUE) { - printf("Press ENTER to continue.\n"); - cin.get(); - } - return 1; - } - } - else { - printf("Error: Unable open file %s.\n", g_strInputFileName.c_str()); - if (g_bStopOnError == TRUE) { - printf("Press ENTER to continue.\n"); + printf("Press ENTER to continue.\n"); cin.get(); - } - return 1; - } - + } + return 1; + } + + if (!fileOutput.Open(g_strOutputFileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) + { + printf("Error: Unable open output file %s.\n", g_strOutputFileName.c_str()); + if (g_bStopOnError == TRUE) + { + printf("Press ENTER to continue.\n"); + cin.get(); + } + return 1; + } + + try + { + CArchive arInput(&fileInput, CArchive::load); + CFalloutScript Script; + + printf("Loading file %s...\n", g_strInputFileName.c_str()); + Script.Serialize(arInput); + + printf("File %s loaded successfuly\n", g_strInputFileName.c_str()); + printf("\n"); + + CArchive arOutput(&fileOutput, CArchive::store); + + if (g_bDump) + { + printf("Dumping...\n", g_strInputFileName.c_str()); + Script.Dump(arOutput); + + printf("File %s dumped successfuly\n", g_strInputFileName.c_str()); + } + else + { + printf("Decompiling...\n"); + + printf(" Init definitions\n"); + Script.InitDefinitions(); + + printf(" Processing code\n"); + Script.ProcessCode(); + + printf(" Storing sources\n"); + Script.StoreSource(arOutput); + printf("File %s decompiled successfuly\n", g_strInputFileName.c_str()); + } + } + + catch (const UserException& e) + { + // Error message already displayed + if (g_bStopOnError == TRUE) + { + printf("Press ENTER to continue.\n"); + cin.get(); + } + return 1; + } + + catch(...) + { + return 1; + +// const int c_nErrMsgLen = 1024; +// TCHAR lpszErrMsg[c_nErrMsgLen]; +// e->GetErrorMessage(lpszErrMsg, c_nErrMsgLen); +// printf("Error: %s.\n", lpszErrMsg); +// if (g_bStopOnError == TRUE) +// { +// printf("Press ENTER to continue.\n"); +// cin.get(); +// } +// return 1; + } + + return 0; } void PrintUsage(char* lpszFileName) { - printf("Usage: int2ssl.exe [options] [-s value] file.int [file.ssl]\n"); - printf("Example: int2ssl.exe -d-1-a-b-e-s3 random.int\n"); - printf("\n"); - printf("Options\n"); - printf(" -d: dump file\n"); - printf(" -1: input file is Fallout 1 script\n"); - printf(" -a: ignore wrong number of arguments\n"); - printf(" -b: insert omitted arguments backward\n"); - printf(" -s: use Space instead of tab to indent\n"); - printf(" -e: stop decompiling on error\n"); - printf(" --: end of options\n"); + printf("Usage: int2ssl.exe [options] [-s value] file.int [file.ssl]\n"); + printf("Example: int2ssl.exe -d-1-a-b-e-s3 random.int\n"); + printf("\n"); + printf("Options\n"); + printf(" -d: dump file\n"); + printf(" -1: input file is Fallout 1 script\n"); + printf(" -a: ignore wrong number of arguments\n"); + printf(" -b: insert omitted arguments backward\n"); + printf(" -s: use Space instead of tab to indent\n"); + printf(" -e: stop decompiling on error\n"); + printf(" --: end of options\n"); } BOOL ProcessCommandLine(int argc, char* argv[]) { - int c; - int nIndentWidth; + int c; + int nIndentWidth; - while((c = getopt(argc, argv, "d1abes:")) != EOF) { - switch (c) { - case 'd': - g_bDump = TRUE; - printf("dump file is on.\n"); - break; + while((c = getopt(argc, argv, "d1abes:")) != EOF) + { + switch (c) + { + case 'd': + g_bDump = TRUE; + printf("dump file is on.\n"); + break; - case '1': - g_nFalloutVersion = 1; - printf("int2ssl is using Fallout 1 code.\n"); - break; + case '1': + g_nFalloutVersion = 1; + printf("int2ssl is using Fallout 1 code.\n"); + break; - case 'a': - g_bIgnoreWrongNumOfArgs = TRUE; - printf("ignore wrong number of arguments is on.\n"); - break; + case 'a': + g_bIgnoreWrongNumOfArgs = TRUE; + printf("ignore wrong number of arguments is on.\n"); + break; - case 'b': - g_bInsOmittedArgsBackward = TRUE; - printf("insert omitted arguments backward is on.\n"); - break; + case 'b': + g_bInsOmittedArgsBackward = TRUE; + printf("insert omitted arguments backward is on.\n"); + break; - case 'e': - g_bStopOnError = TRUE; - printf("stop decompiling on error is on.\n"); - break; + case 'e': + g_bStopOnError = TRUE; + printf("stop decompiling on error is on.\n"); + break; - case 's': - nIndentWidth = atoi(optarg); + case 's': + nIndentWidth = atoi(optarg); - if (nIndentWidth <= 0) { - printf("Warning: Invalid indent width. Indent set 3\n"); - nIndentWidth = 3; - } + if (nIndentWidth <= 0) + { + printf("Warning: Invalid indent width. Indent set 3\n"); + nIndentWidth = 3; + } - g_strIndentFill = ""; + g_strIndentFill = ""; - for(; nIndentWidth > 0; nIndentWidth--) - g_strIndentFill += " "; - - break; - } - } - - if (optind == argc) { - printf("Error: Input file name omitted\n"); - if (g_bStopOnError == TRUE) { - printf("Press ENTER to continue.\n"); - cin.get(); - } - return FALSE; - } - - g_strInputFileName = argv[optind]; - optind++; - - if (optind < argc) { - g_strOutputFileName = argv[optind]; - } - else { - g_strOutputFileName = g_strInputFileName; - - /* - if (g_strOutputFileName.Right(4).MakeLower() == ".int") { - g_strOutputFileName = g_strOutputFileName.Left(g_strOutputFileName.GetLength() - 4); + for(; nIndentWidth > 0; nIndentWidth--) + { + g_strIndentFill += " "; + } + break; } - */ + } - if (g_bDump) { - g_strOutputFileName += ".dump"; - } - else { - g_strOutputFileName += ".ssl"; - } - } - return TRUE; + if (optind == argc) + { + printf("Error: Input file name omitted\n"); + if (g_bStopOnError == TRUE) + { + printf("Press ENTER to continue.\n"); + cin.get(); + } + return FALSE; + } + + g_strInputFileName = argv[optind]; + optind++; + + if (optind < argc) + { + g_strOutputFileName = argv[optind]; + } + else + { + g_strOutputFileName = g_strInputFileName; + +// if (g_strOutputFileName.Right(4).MakeLower() == ".int") +// { +// g_strOutputFileName = g_strOutputFileName.Left(g_strOutputFileName.GetLength() - 4); +// } + + if (g_bDump) + { + g_strOutputFileName += ".dump"; + } + else + { + g_strOutputFileName += ".ssl"; + } + } + return TRUE; }