few small bugs (embark caste selection) and moved runsaved to non-auto.

develop
Warmist 2012-03-18 03:02:16 +02:00
parent 943c4abe76
commit 5367d28110
3 changed files with 28 additions and 14 deletions

@ -152,7 +152,9 @@ command_result lua_run (color_ostream &out, std::vector <std::string> &parameter
{ {
try{ try{
s.loadfile(parameters[0]); //load file s.loadfile(parameters[0]); //load file
s.pcall(0,0);// run it for(size_t i=1;i<parameters.size();i++)
s.push(parameters[i]);
s.pcall(parameters.size()-1,0);// run it
} }
catch(lua::exception &e) catch(lua::exception &e)
{ {
@ -168,7 +170,7 @@ command_result lua_run (color_ostream &out, std::vector <std::string> &parameter
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
void RunDfusion(color_ostream &out) void RunDfusion(color_ostream &out, std::vector <std::string> &parameters)
{ {
mymutex->lock(); mymutex->lock();
lua::state s=lua::glua::Get(); lua::state s=lua::glua::Get();
@ -176,8 +178,9 @@ void RunDfusion(color_ostream &out)
s.getglobal("err"); s.getglobal("err");
int errpos=s.gettop(); int errpos=s.gettop();
s.loadfile("dfusion/init.lua"); //load script s.loadfile("dfusion/init.lua"); //load script
for(size_t i=0;i<parameters.size();i++)
s.pcall(0,0,errpos);// run it s.push(parameters[i]);
s.pcall(parameters.size(),0,errpos);// run it
} }
catch(lua::exception &e) catch(lua::exception &e)
{ {
@ -193,7 +196,7 @@ command_result dfuse(color_ostream &out, std::vector <std::string> &parameters)
lua::SetConsole(s,out); lua::SetConsole(s,out);
s.push(1); s.push(1);
s.setglobal("INIT"); s.setglobal("INIT");
RunDfusion(out); RunDfusion(out,parameters);
return CR_OK; return CR_OK;
} }
command_result dfusion (color_ostream &out, std::vector <std::string> &parameters) command_result dfusion (color_ostream &out, std::vector <std::string> &parameters)
@ -202,6 +205,6 @@ command_result dfusion (color_ostream &out, std::vector <std::string> &parameter
lua::SetConsole(s,out); lua::SetConsole(s,out);
s.push(); s.push();
s.setglobal("INIT"); s.setglobal("INIT");
RunDfusion(out); RunDfusion(out,parameters);
return CR_OK; return CR_OK;
} }

@ -16,7 +16,7 @@ function MakeTable(modpos,modsize,names)
if RaceTable[line] == nil then if RaceTable[line] == nil then
error("Failure, "..line.." not found!") error("Failure, "..line.." not found!")
end end
print("adding:"..line.." id:"..RaceTable[line]) --print("adding:"..line.." id:"..RaceTable[line])
engine.pokew(modpos+modsize+count*2,RaceTable[line]) -- add race engine.pokew(modpos+modsize+count*2,RaceTable[line]) -- add race
count = count + 1 count = count + 1
end end
@ -48,6 +48,13 @@ function embark(names)
print(string.format("found:%x",loc)) print(string.format("found:%x",loc))
if((loc~=0)and(loc-stoff<1000)) then if((loc~=0)and(loc-stoff<1000)) then
loc2=offsets.find(loc,0x83,0xc8,0xff) -- or eax, ffffff (for caste)
if loc2== 0 then
error ("Location for caste nulling not found!")
end
engine.pokeb(loc2,0x90)
engine.pokeb(loc2+1,0x90)
engine.pokeb(loc2+2,0x90)
ModData=engine.installMod("dfusion/embark/embark.o","Embark",256) ModData=engine.installMod("dfusion/embark/embark.o","Embark",256)
modpos=ModData.pos modpos=ModData.pos
modsize=ModData.size modsize=ModData.size
@ -66,6 +73,7 @@ function embark(names)
engine.pokeb(loc+2,0xe8) engine.pokeb(loc+2,0xe8)
engine.poked(loc+3,modpos-loc-7) engine.poked(loc+3,modpos-loc-7)
--engine.pokeb(loc+5,0x90) --engine.pokeb(loc+5,0x90)
SetExecute(modpos) SetExecute(modpos)
else else
error("did not find patch location, failing...") error("did not find patch location, failing...")

@ -66,15 +66,18 @@ table.insert(plugins,{"triggers","a function calling plug (discontinued...)"})
table.insert(plugins,{"migrants","multi race imigrations"}) table.insert(plugins,{"migrants","multi race imigrations"})
table.insert(plugins,{"onfunction","run lua on some df function"})--]=] table.insert(plugins,{"onfunction","run lua on some df function"})--]=]
table.insert(plugins,{"editor","edit internals of df",EditDF}) table.insert(plugins,{"editor","edit internals of df",EditDF})
table.insert(plugins,{"saves","run current worlds's init.lua",RunSaved})
loadall(plugins) loadall(plugins)
dofile_silent("dfusion/initcustom.lua") dofile_silent("dfusion/initcustom.lua")
print("Locating saves...") function RunSaved()
local str=df.world.cur_savegame.save_dir print("Locating saves...")
print("Current region:"..str) local str=df.world.cur_savegame.save_dir
str="data/save/"..str.."/dfusion/init.lua" print("Current region:"..str)
dofile_silent(str) str="data/save/"..str.."/dfusion/init.lua"
print("Trying to run:"..str)
dofile_silent(str)
end
if not INIT then if not INIT then
mainmenu(plugins) mainmenu(plugins)
end end