Conflicts:
	plugins/Dfusion/dfusion.cpp
develop
Petr Mrázek 2011-08-13 14:44:54 +02:00
commit 9ecbaecc13
7 changed files with 39 additions and 27 deletions

@ -2263,6 +2263,7 @@
<Address name="current_menu_state" value="0x14f5fac" /> <Address name="current_menu_state" value="0x14f5fac" />
</Group> </Group>
<Group name="Creatures"> <Group name="Creatures">
<Address name="current_race" value="0x14F0C28" />
<Group name="creature"> <Group name="creature">
<Offset name="flags3" value="0xE8"/> <Offset name="flags3" value="0xE8"/>
</Group> </Group>

@ -77,7 +77,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
catch(lua::exception &e) catch(lua::exception &e)
{ {
c->con.printerr("Error OnTick:%s\n",e.what()); c->con.printerr("Error OnTick:%s\n",e.what());
c->con.printerr("%s",lua::DebugDump(lua::glua::Get()).c_str()); c->con.printerr("%s\n",lua::DebugDump(lua::glua::Get()).c_str());
c->con.msleep(1000); c->con.msleep(1000);
} }
} }
@ -105,7 +105,7 @@ void InterpreterLoop(Core* c)
catch(lua::exception &e) catch(lua::exception &e)
{ {
con.printerr("Error:%s\n",e.what()); con.printerr("Error:%s\n",e.what());
c->con.printerr("%s",lua::DebugDump(lua::glua::Get()).c_str()); c->con.printerr("%s\n",lua::DebugDump(lua::glua::Get()).c_str());
s.settop(0); s.settop(0);
} }
con.lineedit(">>",curline,hist); con.lineedit(">>",curline,hist);
@ -126,7 +126,7 @@ DFhackCExport command_result lua_run (Core * c, vector <string> & parameters)
catch(lua::exception &e) catch(lua::exception &e)
{ {
con.printerr("Error:%s\n",e.what()); con.printerr("Error:%s\n",e.what());
c->con.printerr("%s",lua::DebugDump(lua::glua::Get()).c_str()); c->con.printerr("%s\n",lua::DebugDump(lua::glua::Get()).c_str());
} }
} }
else else
@ -151,7 +151,7 @@ DFhackCExport command_result dfusion (Core * c, vector <string> & parameters)
catch(lua::exception &e) catch(lua::exception &e)
{ {
con.printerr("Error:%s\n",e.what()); con.printerr("Error:%s\n",e.what());
c->con.printerr("%s",lua::DebugDump(lua::glua::Get()).c_str()); c->con.printerr("%s\n",lua::DebugDump(lua::glua::Get()).c_str());
} }
s.settop(0);// clean up s.settop(0);// clean up
mymutex->unlock(); mymutex->unlock();

@ -321,7 +321,9 @@ function findVectors()
end end
function GetRaceToken(p) --actually gets token... function GetRaceToken(p) --actually gets token...
local vec=engine.peek(offsets.getEx('CreatureGloss'),ptr_vector) print(string.format("%x vs %x",offsets.getEx('CreatureGloss'),VersionInfo.getGroup("Materials"):getAddress("creature_type_vector")))
--local vec=engine.peek(offsets.getEx('CreatureGloss'),ptr_vector)
local vec=engine.peek(VersionInfo.getGroup("Materials"):getAddress("creature_type_vector"),ptr_vector)
--print("Vector ok") --print("Vector ok")
local off=vec:getval(p) local off=vec:getval(p)
--print("Offset:"..off) --print("Offset:"..off)

@ -41,7 +41,7 @@ function embark(names)
count=MakeTable(modpos,modsize,names) --just remake tables count=MakeTable(modpos,modsize,names) --just remake tables
else else
tofind=offsets.getEx('CurrentRace') tofind=VersionInfo.getGroup("Creatures"):getAddress("current_race")--offsets.getEx('CurrentRace')
loc=offsets.find(stoff,0xa1,DWORD_,tofind) loc=offsets.find(stoff,0xa1,DWORD_,tofind)

@ -1,6 +1,6 @@
function friendship_in.patch() function friendship_in.patch()
pos=GetTextRegion().start pos=GetTextRegion().start
local crace=offsets.getEx("CurrentRace") local crace=add_race --offsets.getEx("CurrentRace")
hits={} hits={}
i=1 i=1
repeat repeat

@ -40,10 +40,15 @@ end
Two more compares are missing. There are calls instead (same function) Two more compares are missing. There are calls instead (same function)
]]-- ]]--
if not(FILE) then if not(FILE) then
print("race num:"..engine.peekw(offsets.getEx("CurrentRace"))) --print("race num:"..engine.peekw(offsets.getEx("CurrentRace")))
print("Your current race is:"..GetRaceToken(engine.peekw(offsets.getEx('CurrentRace')))) --print(string.format("%x vs %x",offsets.getEx("CurrentRace"),VersionInfo.getGroup("Creatures"):getAddress("current_race")))
print("If this is wrong please quit now (by ctrl+c)") add_race=VersionInfo.getGroup("Creatures"):getAddress("current_race")
io.stdin:read() print("Race num:"..engine.peekw(add_race))
print("Your current race is:"..GetRaceToken(engine.peekw(add_race)))
print("If this is wrong please type 'q'")
if(io.stdin:read()=='q') then
return
end
end end
friendship_in={} friendship_in={}
dofile("dfusion/friendship/install.lua") dofile("dfusion/friendship/install.lua")

@ -9,46 +9,47 @@ OffsetGroup::OffsetGroup(lua_State *L,int id):tblid(id)
int OffsetGroup::getOffset(lua_State *L) int OffsetGroup::getOffset(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
int32_t ret=p->getOffset(st.as<std::string>(2)); int32_t ret=p->getOffset(st.as<std::string>(1));
st.push(ret); st.push(ret);
return 1; return 1;
} }
int OffsetGroup::getAddress(lua_State *L) int OffsetGroup::getAddress(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
uint32_t ret=p->getAddress(st.as<std::string>(2)); uint32_t ret=p->getAddress(st.as<std::string>(1));
st.push(ret); st.push(ret);
return 1; return 1;
} }
int OffsetGroup::getHexValue(lua_State *L) int OffsetGroup::getHexValue(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
uint32_t ret=p->getHexValue(st.as<std::string>(2)); uint32_t ret=p->getHexValue(st.as<std::string>(1));
st.push(ret); st.push(ret);
return 1; return 1;
} }
int OffsetGroup::getString(lua_State *L) int OffsetGroup::getString(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
std::string ret=p->getString(st.as<std::string>(2)); std::string ret=p->getString(st.as<std::string>(1));
st.push(ret); st.push(ret);
return 1; return 1;
} }
int OffsetGroup::getGroup(lua_State *L) int OffsetGroup::getGroup(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
DFHack::OffsetGroup* t= p->getGroup(st.as<std::string>(2)); DFHack::OffsetGroup* t= p->getGroup(st.as<std::string>(1));
st.getglobal("OffsetGroup"); st.getglobal("OffsetGroup");
st.getfield("new"); st.getfield("new");
st.getglobal("OffsetGroup");
st.pushlightuserdata(t); st.pushlightuserdata(t);
st.pcall(1,1); st.pcall(2,1);
return 1; return 1;
} }
int OffsetGroup::getSafeOffset(lua_State *L) int OffsetGroup::getSafeOffset(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
int32_t out; int32_t out;
bool ret=p->getSafeOffset(st.as<std::string>(2),out); bool ret=p->getSafeOffset(st.as<std::string>(1),out);
st.push(ret); st.push(ret);
st.push(out); st.push(out);
return 2; return 2;
@ -57,7 +58,7 @@ int OffsetGroup::getSafeAddress(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
uint32_t out; uint32_t out;
bool ret=p->getSafeAddress(st.as<std::string>(2),out); bool ret=p->getSafeAddress(st.as<std::string>(1),out);
st.push(ret); st.push(ret);
st.push(out); st.push(out);
return 2; return 2;
@ -66,7 +67,7 @@ int OffsetGroup::PrintOffsets(lua_State *L)
{ {
lua::state st(L); lua::state st(L);
std::string output; std::string output;
output=p->PrintOffsets(st.as<int>(2)); output=p->PrintOffsets(st.as<int>(1));
st.push(output); st.push(output);
return 1; return 1;
} }
@ -90,8 +91,9 @@ int OffsetGroup::getParent(lua_State *L)
DFHack::OffsetGroup* t= p->getParent(); DFHack::OffsetGroup* t= p->getParent();
st.getglobal("OffsetGroup"); st.getglobal("OffsetGroup");
st.getfield("new"); st.getfield("new");
st.getglobal("OffsetGroup");
st.pushlightuserdata(t); st.pushlightuserdata(t);
st.pcall(1,1); st.pcall(2,1);
return 1; return 1;
} }
} }
@ -324,11 +326,12 @@ static int __lua_getHexValue(lua_State *S)
static int __lua_getGroup(lua_State *S) static int __lua_getGroup(lua_State *S)
{ {
lua::state st(S); lua::state st(S);
DFHack::OffsetGroup* t= DFHack::Core::getInstance().vinfo->getGroup(st.as<std::string>(2)); DFHack::OffsetGroup* t= DFHack::Core::getInstance().vinfo->getGroup(st.as<std::string>(1));
st.getglobal("OffsetGroup"); st.getglobal("OffsetGroup");
st.getfield("new"); st.getfield("new");
st.getglobal("OffsetGroup");
st.pushlightuserdata(t); st.pushlightuserdata(t);
st.pcall(1,1); st.pcall(2,1);
return 1; return 1;
} }
static int __lua_getParent(lua_State *S) static int __lua_getParent(lua_State *S)
@ -337,8 +340,9 @@ static int __lua_getParent(lua_State *S)
DFHack::OffsetGroup* t= DFHack::Core::getInstance().vinfo->getParent(); DFHack::OffsetGroup* t= DFHack::Core::getInstance().vinfo->getParent();
st.getglobal("OffsetGroup"); st.getglobal("OffsetGroup");
st.getfield("new"); st.getfield("new");
st.getglobal("OffsetGroup");
st.pushlightuserdata(t); st.pushlightuserdata(t);
st.pcall(1,1); st.pcall(2,1);
return 1; return 1;
} }
static int __lua_getSafeOffset(lua_State *S) static int __lua_getSafeOffset(lua_State *S)