Added getKeys to OffsetGroup (for easy lua access to all things that memory.xml has)

develop
Warmist 2011-12-24 13:53:59 +02:00
parent 2008ac5564
commit dc78e99f75
4 changed files with 60 additions and 3 deletions

@ -598,7 +598,48 @@ void OffsetGroup::setInvalid(INVAL_TYPE invalidity)
(*iter4).second->setInvalid(invalidity); (*iter4).second->setInvalid(invalidity);
} }
} }
std::vector<OffsetKey> OffsetGroup::getKeys() const
{
std::vector<OffsetKey> ret;
OffsetKey K;
K.keytype=IS_ADDRESS;
for(uint32_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_OFFSET;
for(int32_Iter iter = OGd->offsets.begin(); iter != OGd->offsets.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_HEX_VAL;
for(uint32_Iter iter = OGd->hexvals.begin(); iter != OGd->hexvals.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_STRING;
for(strings_Iter iter = OGd->strings.begin(); iter != OGd->strings.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_GROUP;
K.inval=IS_VALID;
for(groups_Iter iter = OGd->groups.begin(); iter != OGd->groups.end(); iter++)
{
K.key=iter->first;
ret.push_back(K);
}
return ret;
}
/* /*
* Private data * Private data
*/ */

@ -52,7 +52,20 @@ namespace DFHack
IS_INVALID, IS_INVALID,
IS_VALID IS_VALID
}; };
enum KEY_TYPE
{
IS_OFFSET,
IS_ADDRESS,
IS_HEX_VAL,
IS_STRING,
IS_GROUP
};
struct OffsetKey
{
std::string key;
INVAL_TYPE inval;
KEY_TYPE keytype;
};
/* /*
* Offset Group * Offset Group
*/ */
@ -96,6 +109,8 @@ namespace DFHack
std::string getFullName(); std::string getFullName();
OffsetGroup * getParent(); OffsetGroup * getParent();
void setInvalid(INVAL_TYPE arg1); void setInvalid(INVAL_TYPE arg1);
std::vector<OffsetKey> getKeys() const;
}; };
/* /*

@ -7,6 +7,7 @@ if WINDOWS then --windows function defintions
onfunction.AddFunction(0x3d4301+offsets.base(),"Make_Item",{item_type="esp"}) onfunction.AddFunction(0x3d4301+offsets.base(),"Make_Item",{item_type="esp"})
onfunction.AddFunction(0x5af826+offsets.base(),"Hurt",{target="esi",attacker={off=0x74,rtype=DWORD,reg="esp"}}) onfunction.AddFunction(0x5af826+offsets.base(),"Hurt",{target="esi",attacker={off=0x74,rtype=DWORD,reg="esp"}})
onfunction.AddFunction(0x3D5886+offsets.base(),"Flip",{building="esi"}) onfunction.AddFunction(0x3D5886+offsets.base(),"Flip",{building="esi"})
onfunction.AddFunction(0x35E340+offsets.base(),"ItemCreate")
else --linux else --linux
onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch... onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same

@ -1 +1 @@
function findVectorsSized(size) local ret={} local text=GetTextRegion() for k,v in pairs(offsets.getvectors()) do if GetRegionIn2(k)~=nil then --if v>4 then local tv=engine.peek(k,ptr_vector) if tv.size() == size then print(string.format("%x is size %d",k,size)) table.insert(ret,k) end end end return ret end function findMaterial(mattype,matname) --currently only stones local tbl=BuildMaterialTable() return tbl[matname] end function findVectorsSized(size) local ret={} local text=GetTextRegion() for k,v in pairs(offsets.getvectors()) do if GetRegionIn2(k)~=nil then --if v>4 then local tv=engine.peek(k,ptr_vector) if tv:size() == size then print(string.format("%x is size %d",k,size)) table.insert(ret,k) end end end return ret end function findMaterial(mattype,matname) --currently only stones local tbl=BuildMaterialTable() return tbl[matname] end