Files
int2ssl/FalloutScriptDump.cpp
T

164 lines
6.2 KiB
C++
Raw Normal View History

2015-02-13 16:59:11 +03:00
#include "stdafx.h"
#include "FalloutScript.h"
2015-02-15 16:16:45 +03:00
#include "Utility.h"
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-14 13:39:47 +03:00
ULONG 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-13 23:09:21 +03:00
if (m_GlobalVar.IsEmpty())
{
2015-02-14 13:39:47 +03:00
ar.WriteString("Not found\n");
}
2015-02-13 23:09:21 +03:00
else
{
for(unsigned int i = 0; i < m_GlobalVar.GetSize(); i++)
{
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-14 14:38:14 +03:00
if (m_ExportedVarValue.IsEmpty())
{
2015-02-14 13:39:47 +03:00
ar.WriteString("Not found\n");
}
2015-02-14 14:38:14 +03:00
else
{
for(INT_PTR i = 0; i < m_ExportedVarValue.GetSize(); i += 2)
{
2015-02-14 23:18:15 +03:00
wOperator = m_ExportedVarValue[i].GetOperator();
ulArgument = m_ExportedVarValue[i].GetArgument();
ULONG 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-14 14:38:14 +03:00
for(INT_PTR nIndexOfProc = 0; nIndexOfProc < m_ProcTable.GetSize(); nIndexOfProc++)
{
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-14 23:18:15 +03:00
for(INT_PTR i = 0; i < m_ProcBodies[nIndexOfProc].GetSize(); 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
}