Files
int2ssl/FalloutScriptDump.cpp
T

177 lines
6.5 KiB
C++
Raw Normal View History

2015-02-15 18:53:04 +03:00
/**
*
* Copyright (c) 2005-2009 Anchorite (TeamX), <anchorite2001@yandex.ru>
* Copyright (c) 20014-2015 Nirran, phobos2077
* Copyright (c) 20015 alexeevdv <mail@alexeevdv.ru>
* Distributed under the GNU GPL v3. For full terms see the file license.txt
*
*/
// C++ standard includes
// int2ssl includes
2015-02-13 16:59:11 +03:00
#include "FalloutScript.h"
2015-02-15 16:16:45 +03:00
#include "Utility.h"
2015-02-13 16:59:11 +03:00
2015-02-15 18:53:04 +03:00
// Third party includes
2015-02-13 16:59:11 +03:00
void CFalloutScript::Dump(CArchive& ar)
{
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Procedures table ==================\n");
ar.WriteString("\n");
m_ProcTable.Dump(ar);
ar.WriteString("\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Namespace ==================\n");
m_Namespace.Dump(ar);
ar.WriteString("\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Stringspace ==================\n");
m_Stringspace.Dump(ar);
ar.WriteString("\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-15 16:16:45 +03:00
std::string strOutLine;
2015-02-15 18:10:01 +03:00
uint16_t wOperator;
2015-02-15 18:28:27 +03:00
uint32_t ulArgument = 0;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Global variables values ==================\n");
2015-02-13 16:59:11 +03:00
2015-02-15 21:30:47 +03:00
if (m_GlobalVar.empty())
2015-02-13 23:09:21 +03:00
{
2015-02-14 13:39:47 +03:00
ar.WriteString("Not found\n");
}
2015-02-13 23:09:21 +03:00
else
{
2015-02-15 21:30:47 +03:00
for(unsigned int i = 0; i < m_GlobalVar.size(); i++)
2015-02-13 23:09:21 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_GlobalVar[i].GetOperator();
ulArgument = m_GlobalVar[i].GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-13 23:09:21 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
case COpcode::O_INTOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("%d: %s(0x%08x) // %u (%d)\n",
2015-02-14 13:39:47 +03:00
i,
2015-02-14 23:18:15 +03:00
m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(),
2015-02-13 16:59:11 +03:00
ulArgument,
ulArgument,
ulArgument);
2015-02-14 13:39:47 +03:00
ar.WriteString(strOutLine);
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("%d: %s(0x%08x) // %05f\n",
2015-02-14 13:39:47 +03:00
i,
2015-02-14 23:18:15 +03:00
m_GlobalVar[i].GetAttributes().m_strMnemonic.c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
*((float*)(&ulArgument)));
ar.WriteString(strOutLine);
}
}
}
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Exported variables ==================\n");
2015-02-13 16:59:11 +03:00
2015-02-15 21:30:47 +03:00
if (m_ExportedVarValue.empty())
2015-02-14 14:38:14 +03:00
{
2015-02-14 13:39:47 +03:00
ar.WriteString("Not found\n");
}
2015-02-14 14:38:14 +03:00
else
{
2015-02-15 21:30:47 +03:00
for(int32_t i = 0; i < m_ExportedVarValue.size(); i += 2)
2015-02-14 14:38:14 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_ExportedVarValue[i].GetOperator();
ulArgument = m_ExportedVarValue[i].GetArgument();
2015-02-15 18:28:27 +03:00
uint32_t ulNameArgument = m_ExportedVarValue[i + 1].GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-14 14:38:14 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("%s := \"%s\"\n",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
m_Stringspace[ulArgument].c_str());
2015-02-14 13:39:47 +03:00
ar.WriteString(strOutLine);
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_INTOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("%s := %u (%d)\n",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
ulArgument);
ar.WriteString(strOutLine);
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("%s := %05f\n",
2015-02-13 16:59:11 +03:00
m_Namespace[ulNameArgument].c_str(),
2015-02-14 13:39:47 +03:00
*((float*)(&ulArgument)));
ar.WriteString(strOutLine);
}
}
}
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("============== Procedures ==================\n");
ar.WriteString("\n");
2015-02-13 16:59:11 +03:00
2015-02-15 19:05:45 +03:00
for(int32_t nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++)
2015-02-14 14:38:14 +03:00
{
2015-02-15 16:16:45 +03:00
strOutLine = format("%d: %s (0x%08x)\n", nIndexOfProc,
2015-02-13 16:59:11 +03:00
m_Namespace[m_ProcTable[nIndexOfProc].m_ulNameOffset].c_str(),
2015-02-14 14:38:14 +03:00
m_ProcTable[nIndexOfProc].m_ulBodyOffset);
2015-02-14 13:39:47 +03:00
ar.WriteString(strOutLine);
ar.WriteString("===============================\n");
2015-02-13 16:59:11 +03:00
2015-02-15 21:30:47 +03:00
for(int32_t i = 0; i < m_ProcBodies[nIndexOfProc].size(); i++)
2015-02-14 14:38:14 +03:00
{
2015-02-14 23:18:15 +03:00
wOperator = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetOperator();
ulArgument = m_ProcBodies[nIndexOfProc][i].m_Opcode.GetArgument();
2015-02-13 16:59:11 +03:00
2015-02-14 14:38:14 +03:00
switch(wOperator)
{
2015-02-14 13:39:47 +03:00
case COpcode::O_STRINGOP:
case COpcode::O_INTOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("0x%08X: 0x%04X 0x%08x - %s(0x%08x) // %u (%d)\n",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
ulArgument,
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(),
2015-02-14 13:39:47 +03:00
ulArgument,
ulArgument,
ulArgument);
ar.WriteString(strOutLine);
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
case COpcode::O_FLOATOP:
2015-02-15 16:16:45 +03:00
strOutLine = format("0x%08X: 0x%04X 0x%08X - %s // %05f\n",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
ulArgument,
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str(),
2015-02-14 13:39:47 +03:00
*((float*)(&ulArgument)));
ar.WriteString(strOutLine);
break;
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
default:
2015-02-15 16:16:45 +03:00
strOutLine = format("0x%08X: 0x%04X - %s\n",
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_ulOffset,
2015-02-14 13:39:47 +03:00
wOperator,
2015-02-14 23:18:15 +03:00
m_ProcBodies[nIndexOfProc][i].m_Opcode.GetAttributes().m_strMnemonic.c_str());
2015-02-14 13:39:47 +03:00
ar.WriteString(strOutLine);
}
}
2015-02-13 16:59:11 +03:00
2015-02-14 13:39:47 +03:00
ar.WriteString("\n");
}
2015-02-13 16:59:11 +03:00
}