Kill the Engravings module

develop
Quietust 2012-01-24 11:53:49 -06:00
parent cc7c7795a1
commit f8ce959402
5 changed files with 23 additions and 151 deletions

@ -1088,7 +1088,6 @@ TYPE * Core::get##TYPE() \
return s_mods.p##TYPE;\ return s_mods.p##TYPE;\
} }
MODULE_GETTER(Engravings);
MODULE_GETTER(Gui); MODULE_GETTER(Gui);
MODULE_GETTER(World); MODULE_GETTER(World);
MODULE_GETTER(Materials); MODULE_GETTER(Materials);

@ -52,7 +52,6 @@ namespace DFHack
{ {
class Process; class Process;
class Module; class Module;
class Engravings;
class Gui; class Gui;
class World; class World;
class Materials; class Materials;
@ -95,8 +94,6 @@ namespace DFHack
/// Is everything OK? /// Is everything OK?
bool isValid(void) { return !errorstate; } bool isValid(void) { return !errorstate; }
/// get the engravings module
Engravings * getEngravings();
/// get the gui module /// get the gui module
Gui * getGui(); Gui * getGui();
/// get the world module /// get the world module
@ -155,7 +152,6 @@ namespace DFHack
// Module storage // Module storage
struct struct
{ {
Engravings * pEngravings;
Gui * pGui; Gui * pGui;
World * pWorld; World * pWorld;
Materials * pMaterials; Materials * pMaterials;

@ -30,7 +30,6 @@ distribution.
namespace DFHack namespace DFHack
{ {
class Module; class Module;
Module* createEngravings();
Module* createGui(); Module* createGui();
Module* createWorld(); Module* createWorld();
Module* createMaterials(); Module* createMaterials();

@ -29,94 +29,22 @@ distribution.
* DF engravings * DF engravings
*/ */
#include "Export.h" #include "Export.h"
#include "Module.h" #include "DataDefs.h"
#include "df/world.h"
/** /**
* \defgroup grp_engraving Engraving module parts * \defgroup grp_engraving Engraving module parts
* @ingroup grp_modules * @ingroup grp_modules
*/ */
namespace DFHack namespace DFHack
{ {
/** namespace Simple
* engraving flags {
* \ingroup grp_engraving namespace Engravings
*/ {
struct flg_engraving DFHACK_EXPORT bool isValid();
{ DFHACK_EXPORT uint32_t getCount();
// there are 9 directions an engraving can have. DFHACK_EXPORT df::engraving *getEngraving (const int32_t index);
// unfortunately, a tile can't be engraved from more than one direction by the game }
unsigned int floor : 1; // engraved on a floor 0x1 }
unsigned int west : 1; // engraved from west 0x2
unsigned int east : 1; // engraved from east 0x4
unsigned int north : 1; // engraved from north 0x8
unsigned int south : 1; // engraved from south 0x10
unsigned int hidden : 1; // hide the engraving 0x20
unsigned int northwest : 1; // engraved from... 0x40
unsigned int northeast : 1; // engraved from... 0x80
unsigned int southwest : 1; // engraved from... 0x100
unsigned int southeast : 1; // engraved from... 0x200
unsigned int rest : 22; // probably unused
};
/**
* type the engraving is made of
* \ingroup grp_engraving
*/
struct t_engraving
{
//0
int32_t artistIdx; /*!< Index of the artist in some global vector */
// 4
int32_t unknownIdx; // likes to stay -1
// 8
uint32_t unknown1; // likes to stay 1
// C
uint16_t x; /*!< X coordinate */
uint16_t y; /*!< Y coordinate */
// 10
uint16_t z; /*!< Z coordinate */
uint16_t padding; /*!< Could be used for hiding values. */
// 14
flg_engraving flags; // 0x20 = hide symbol
// 18
uint8_t display_character; // really? 4 bytes for that?
uint8_t padding2[3];
// 1C
uint32_t type; // possibly an enum, decides what vectors to use for imagery
// 20
int16_t subtype_idx; // index in a vector kind of deal related to previous value
uint16_t quality; // from 0 to 5
// 24
uint32_t unknown2;
// 28 = length
};
/**
* structure for holding a DF engraving
* \ingroup grp_engraving
*/
struct dfh_engraving
{
t_engraving s;
t_engraving * origin;
};
/**
* The Engravings module - allows reading engravings :D
* \ingroup grp_modules
* \ingroup grp_engraving
*/
class DFHACK_EXPORT Engravings : public Module
{
public:
Engravings();
~Engravings();
bool Start(uint32_t & numEngravings);
bool Read (const uint32_t index, dfh_engraving & engr);
bool Write (const dfh_engraving & engr);
bool Finish();
private:
struct Private;
Private *d;
};
} }
#endif #endif

@ -33,77 +33,27 @@ using namespace std;
#include "VersionInfo.h" #include "VersionInfo.h"
#include "MemAccess.h" #include "MemAccess.h"
#include "Types.h" #include "Types.h"
#include "modules/Engravings.h"
#include "ModuleFactory.h"
#include "Core.h" #include "Core.h"
using namespace DFHack; #include "modules/Engravings.h"
struct Engravings::Private
{
uint32_t engraving_vector;
vector <t_engraving *> * p_engr;
Process * owner;
bool Inited;
bool Started;
};
Module* DFHack::createEngravings()
{
return new Engravings();
}
Engravings::Engravings()
{
Core & c = Core::getInstance();
d = new Private;
d->owner = c.p;
d->Inited = d->Started = false;
d->p_engr = (decltype(d->p_engr)) c.vinfo->getGroup("Engravings")->getAddress ("vector");
d->Inited = true;
}
Engravings::~Engravings()
{
if(d->Started)
Finish();
delete d;
}
bool Engravings::Start(uint32_t & numengravings)
{
if(!d->Inited)
return false;
numengravings = d->p_engr->size();
d->Started = true;
return true;
}
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
bool Engravings::Read (const uint32_t index, dfh_engraving & engraving) bool Engravings::isValid()
{ {
if(!d->Started) return false; return (world->engravings.size() > 0);
// read pointer from vector at position
engraving.s = *d->p_engr->at (index);
// transform
engraving.origin = d->p_engr->at (index);
return true;
} }
bool Engravings::Write (const dfh_engraving & engraving) uint32_t Engravings::getCount()
{ {
if(!d->Started) return false; return world->engravings.size();
//write engraving to memory
d->owner->write (engraving.origin, sizeof (t_engraving), (uint8_t *) &(engraving.s));
return true;
} }
bool Engravings::Finish() df::engraving *Engravings::getEngraving(const int32_t index)
{ {
d->Started = false; if (index < 0 || index >= getCount())
return true; return NULL;
return world->engravings[index];
} }