2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
|
|
|
#include <Console.h>
|
|
|
|
#include <Export.h>
|
|
|
|
#include <PluginManager.h>
|
2011-07-20 19:26:52 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2011-12-31 04:48:42 -07:00
|
|
|
#include <modules/Notes.h>
|
2011-07-20 19:26:52 -06:00
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
DFhackCExport command_result df_notes (Core * c, vector <string> & parameters);
|
|
|
|
|
|
|
|
DFhackCExport const char * plugin_name ( void )
|
|
|
|
{
|
|
|
|
return "notes";
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back(PluginCommand("dumpnotes",
|
|
|
|
"Dumps in-game notes",
|
|
|
|
df_notes));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result df_notes (Core * c, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
Console & con = c->con;
|
|
|
|
c->Suspend();
|
|
|
|
|
|
|
|
DFHack::Notes * note_mod = c->getNotes();
|
2011-07-22 19:25:42 -06:00
|
|
|
std::vector<t_note*>* note_list = note_mod->notes;
|
2011-07-20 19:26:52 -06:00
|
|
|
|
|
|
|
if (note_list == NULL)
|
|
|
|
{
|
2011-07-22 19:25:42 -06:00
|
|
|
con.printerr("Notes are not supported under this version of DF.\n");
|
2011-07-20 19:26:52 -06:00
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (note_list->empty())
|
|
|
|
{
|
2011-07-22 19:25:42 -06:00
|
|
|
con << "There are no notes." << std::endl;
|
2011-07-20 19:26:52 -06:00
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < note_list->size(); i++)
|
|
|
|
{
|
|
|
|
t_note* note = (*note_list)[i];
|
|
|
|
|
2011-07-22 19:25:42 -06:00
|
|
|
con.print("Note %x at: %d/%d/%d\n",note, note->x, note->y, note->z);
|
2011-07-20 19:26:52 -06:00
|
|
|
con.print("Note id: %d\n", note->id);
|
|
|
|
con.print("Note symbol: '%c'\n", note->symbol);
|
|
|
|
|
|
|
|
if (note->name.length() > 0)
|
|
|
|
con << "Note name: " << (note->name) << std::endl;
|
|
|
|
if (note->text.length() > 0)
|
|
|
|
con << "Note text: " << (note->text) << std::endl;
|
|
|
|
|
|
|
|
if (note->unk1 != 0)
|
|
|
|
con.print("unk1: %x\n", note->unk1);
|
|
|
|
if (note->unk2 != 0)
|
|
|
|
con.print("unk2: %x\n", note->unk2);
|
|
|
|
|
|
|
|
con << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
}
|