Petr Mrázek 2011-08-08 23:21:09 +02:00
commit aa2ad1b64c
8 changed files with 43 additions and 22 deletions

@ -98,9 +98,9 @@ ENDMACRO(DFHACK_PLUGIN)
#RECURSE_DIRS()
# Dfusion plugin (Windows only right now)
# Dfusion plugin
OPTION(BUILD_DFUSION "Build DFusion." ON)
if(NOT UNIX AND BUILD_DFUSION)
if(BUILD_DFUSION)
add_subdirectory (Dfusion)
endif()

@ -0,0 +1,10 @@
#ifndef LUA_VERSIONINFO_H
#define LUA_VERSIONINFO_H
#include <dfhack/Core.h>
#include <dfhack/VersionInfo.h>
namespace lua
{
}
#endif

@ -249,7 +249,7 @@ private:
static int index_T(lua_State *L) // calls with (table, key), return value
{
lua::state st(L);
string key=st.as<string>(-1);
std::string key=st.as<std::string>(-1);
T *p=check(L,1);
GetTable(L,p);
st.insert(-2);

@ -18,9 +18,11 @@ function adv_tools.ressurect()
engine.poke(vector:getval(indx),ptr_Creature.bloodlvl,60000) --give blood
engine.poke(vector:getval(indx),ptr_Creature.bleedlvl,0) --stop some bleeding...
local flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
flg:set(1,false) --ALIVE
flg:set(1,false) --ALIVE
flg:set(39,false) -- leave body yet again
flg:set(37,false) -- something todo with wounds- lets you walk again.
flg:set(58,true) -- makes them able to breathe
flg:set(61,true) -- gives them sight
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
end

@ -1,5 +1,11 @@
#include "functioncall.h"
#define __F_TDEF(CONV,CONV_,tag) typedef int(CONV_ *F_TYPE##CONV##tag)
#ifdef LINUX_BUILD
#define __F_TDEF(CONV,CONV_,tag) typedef int(__attribute__ ( (CONV_) ) *F_TYPE##CONV##tag)
#else
#define __F_TDEF(CONV,CONV_,tag) typedef int(__ ## CONV_ *F_TYPE##CONV##tag)
#endif
#define __F_T(CONV,tag) F_TYPE##CONV##tag
#define __F_TYPEDEFS(CONV,CONV_) __F_TDEF(CONV,CONV_,1)(int);\
__F_TDEF(CONV,CONV_,2)(int,int);\
@ -57,7 +63,7 @@
(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8],arguments[9]);}*/
int FunctionCaller::CallF(size_t count,callconv conv,void* f,const vector<int> &arguments)//more complex but not more error safe
/*int FunctionCaller::CallF(size_t count,callconv conv,void* f,const vector<int> &arguments)//more complex but not more error safe
{
__F_TYPEDEFS(STD_CALL,__stdcall);
__F_TYPEDEFS(FAST_CALL,__fastcall);
@ -69,13 +75,13 @@ int FunctionCaller::CallF(size_t count,callconv conv,void* f,const vector<int> &
__FCALLEX(THIS_CALL,__thiscall);
__FCALLEX(CDECL_CALL,__cdecl);
}
}
}*/
int FunctionCaller::CallFunction(size_t func_ptr,callconv conv,const vector<int> &arguments)
{
//nasty nasty code...
#ifdef LINUX_BUILD //quick fix
if(conv==THIS_CALL)
conv=STD_CALL
conv=STD_CALL;
#endif
void* f= reinterpret_cast<void*>(func_ptr+base_);
size_t count=arguments.size();
@ -83,15 +89,15 @@ int FunctionCaller::CallFunction(size_t func_ptr,callconv conv,const vector<int>
return (reinterpret_cast<int (*)()>(f))(); //does not matter how we call it...
int ret=0;
//typedefs
__F_TYPEDEFS(STD_CALL,__stdcall);
__F_TYPEDEFS(FAST_CALL,__fastcall);
__F_TYPEDEFS(THIS_CALL,__thiscall);
__F_TYPEDEFS(CDECL_CALL,__cdecl);
__F_TYPEDEFS(STD_CALL,stdcall);
__F_TYPEDEFS(FAST_CALL,fastcall);
__F_TYPEDEFS(THIS_CALL,thiscall);
__F_TYPEDEFS(CDECL_CALL,cdecl);
//calls
__FCALL(STD_CALL,__stdcall);
__FCALL(FAST_CALL,__fastcall);
__FCALL(THIS_CALL,__thiscall);
__FCALL(CDECL_CALL,__cdecl);
__FCALL(STD_CALL,stdcall);
__FCALL(FAST_CALL,fastcall);
__FCALL(THIS_CALL,thiscall);
__FCALL(CDECL_CALL,cdecl);
return -1; //incorect type. Should probably throw...
//return CallF(count,conv,f,arguments);
/*//testing part{ worked some time ago..., put where DFHack::Core is accesible
@ -112,4 +118,4 @@ int FunctionCaller::CallFunction(size_t func_ptr,callconv conv,const vector<int>
#undef __FCALL
#undef __FCALLEX
#undef __F_TYPEDEFS
#undef __F_T
#undef __F_T

@ -49,7 +49,7 @@ LUNE_METHODS_START(lua::Hexsearch)
method(lua::Hexsearch,findall),
method(lua::Hexsearch,reset),
LUNE_METHODS_END();
#define __ADDCONST(name) st.push(::Hexsearch:: ## name); st.setglobal(#name)
#define __ADDCONST(name) st.push(::Hexsearch:: name); st.setglobal(#name)
void lua::RegisterHexsearch(lua::state &st)
{
@ -58,4 +58,4 @@ void lua::RegisterHexsearch(lua::state &st)
__ADDCONST(ANYDWORD);
__ADDCONST(DWORD_);
}
#undef __ADDCONST
#undef __ADDCONST

@ -1,5 +1,7 @@
#include "lua_Offsets.h"
#include <string.h>
//TODO make a seperate module with peeks/pokes and page permisions (linux/windows spec)
//TODO maybe remove alltogether- use DFHack::Process instead?
unsigned char peekb(size_t offset)
{
return *((unsigned char*)(offset));
@ -18,7 +20,7 @@ void peekarb(size_t offset, void *mem,size_t size)
}
void peekstr(size_t offset, char* buf, size_t maxsize)
{
strcpy_s(buf,maxsize,(char*)offset);
strncpy(buf,(char*)offset,maxsize);
}
void pokeb(size_t offset,unsigned char val)
{
@ -38,7 +40,7 @@ void pokearb(size_t offset, void *mem,size_t size)
}
void pokestr(size_t offset, char* buf, size_t maxsize)
{
strcpy_s((char*)offset,maxsize,buf);
strncpy((char*)offset,buf,maxsize);
}
template <typename T>
T peek(size_t offset) //prob lower performance
@ -153,4 +155,4 @@ void lua::RegisterEngine(lua::state &st)
}
lua::RegFunctionsLocal(st,lua_engine_func);
st.setglobal("engine");
}
}

@ -0,0 +1 @@
#include "lua_VersionInfo.h"