merged item patch from belal

develop
Petr Mrázek 2010-01-01 01:49:32 +00:00
parent 843237f7ae
commit 117fcce0d9
5 changed files with 38 additions and 2 deletions

@ -811,6 +811,36 @@ int32_t API::ReadCreatureInBox (int32_t index, t_creature & furball,
return -1;
}
void API::getItemIndexesInBox(vector<uint32_t> &indexes,
const uint16_t &x1, const uint16_t &y1, const uint16_t &z1,
const uint16_t &x2, const uint16_t &y2, const uint16_t &z2)
{
assert(d->itemsInited);
indexes.clear();
uint32_t size = d->p_itm->getSize();
struct temp2{
uint16_t coords[3];
uint32_t flags;
};
temp2 temp2;
for(int i =0;i<size;i++){
uint32_t temp = *(uint32_t *) d->p_itm->at(i);
Mread(temp+sizeof(uint32_t),5 * sizeof(uint16_t), (uint8_t *) &temp2);
if(temp2.flags & (1 << 0)){
if (temp2.coords[0] >= x1 && temp2.coords[0] < x2)
{
if (temp2.coords[1] >= y1 && temp2.coords[1] < y2)
{
if (temp2.coords[2] >= z1 && temp2.coords[2] < z2)
{
indexes.push_back(i);
}
}
}
}
}
}
bool API::ReadCreature (const int32_t &index, t_creature & furball)
{
assert (d->creaturesInited);

@ -180,6 +180,9 @@ namespace DFHack
bool getWindowSize(int32_t & width, int32_t & height);
bool setWindowSize(const int32_t & width, const int32_t & height);
void getItemIndexesInBox(vector<uint32_t> &indexes,
const uint16_t &x1, const uint16_t &y1, const uint16_t &z1,
const uint16_t &x2, const uint16_t &y2, const uint16_t &z2);
/*
// FIXME: add a real creature class, move these
string getLastName(const uint32_t &index, bool);

@ -23,6 +23,7 @@ distribution.
*/
#include "DFCommonInternal.h"
#include <errno.h>
#include <sys/ptrace.h>
using namespace DFHack;
class NormalProcess::Private

@ -522,8 +522,9 @@ struct t_item_df40d
uint16_t x;
uint16_t y;
uint16_t z;
uint32_t unk1;
//uint32_t unk1;
uint32_t flags;
uint32_t unk1;
uint32_t unk2;
uint32_t ID;
// not complete

@ -78,12 +78,13 @@ int main ()
DF.ReadCreatureMatgloss(mat.creatureMat);
vector <string> buildingtypes;
DF.InitReadBuildings(buildingtypes);
DF.InitViewAndCursor();
cout << "q to quit, anything else to look up items at that location\n";
while(1)
{
string input;
DF.Resume();
DF.ForceResume();
getline (cin, input);
DF.Suspend();
uint32_t numItems = DF.InitReadItems();