fixing the code to work on ubuntu

This commit is contained in:
Enno Rehling 2008-12-20 18:54:55 +00:00
parent aa2d227f39
commit 1cab3ce7f1
9 changed files with 92 additions and 27 deletions

View File

@ -4,9 +4,9 @@ LINK = gcc ;
MSPACES = 1 ;
# BINDING = LUABIND ;
if ! $(BINDING) {
BINDING = TOLUA ;
# BINDINGS = LUABIND ;
if ! $(BINDINGS) {
BINDINGS = TOLUA ;
}
if ! $(LUA_VERSION) {
@ -104,14 +104,17 @@ rule zlib
LINKLIBS on $(<) += -lz ;
}
rule luabind
rule liblua
{
LINKLIBS on $(<) += -L$(LUABIND_ROOT)/lib ;
if $(LUA_VERSION) = 5.1 {
LINKLIBS on $(<) += -llua5.1 ;
} else {
LINKLIBS on $(<) += -llua50 -llualib50 ;
}
}
rule libluabind
{
LINKLIBS on $(<) += -lm -lluabind ;
}
@ -120,6 +123,23 @@ rule libxml2
LINKLIBS on $(<) += -lxml2 ;
}
rule libtolua
{
LINKLIBS on $(<) += -ltolua ;
}
rule libcurses
{
LINKLIBS on $(<) += -lncurses ;
}
rule libmcheck
{
if $(DEBUG) = 1 {
LINKLIBS on $(<) += -lmcheck ;
}
}
rule UsingLuabind
{
SubDirHdrs $(LUABIND_ROOT)/include ;

View File

@ -14,7 +14,9 @@
#ifndef H_KRNL_BUILDING
#define H_KRNL_BUILDING
#include <kernel/types.h>
#include <util/variant.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -12,7 +12,12 @@ UsingLuabind ;
SEARCH_SOURCE += [ FDirName $(TOP) common iniparser ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) curses ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) lua ] ;
if $(BINDINGS) = LUABIND {
SEARCH_SOURCE += [ FDirName $(SUBDIR) lua ] ;
}
if $(BINDINGS) = TOLUA {
SEARCH_SOURCE += [ FDirName $(SUBDIR) tolua ] ;
}
SubDirC++Flags -DHAVE_LUA ;
SubDirHdrs $(XMLHDRS) ;
@ -21,7 +26,20 @@ LUASERVER = eressea-lua ;
SERVER_SOURCES = main.c korrektur.c ;
SHARED_BINDINGS =
TOLUA_SOURCES =
<tolua>bindings.c
<tolua>helpers.c
<tolua>bind_unit.c
<tolua>bind_ship.c
<tolua>bind_faction.c
<tolua>bind_region.c
<tolua>bind_message.c
<tolua>bind_hashtable.c
<tolua>bind_building.c
<tolua>bind_gmtool.c
;
LUABIND_SOURCES =
<lua>alliance.cpp
<lua>building.cpp
<lua>eressea.cpp
@ -35,15 +53,23 @@ SHARED_BINDINGS =
<lua>unit.cpp
<lua>item.cpp
<lua>test.cpp
;
Library luabindings : $(SHARED_BINDINGS) ;
LUASERVER_SOURCES =
<common!iniparser>iniparser.c
<lua>gm.cpp
<lua>script.cpp
<lua>gamecode.cpp
;
if $(BINDINGS) = LUABIND {
Library bindings : $(LUABIND_SOURCES) ;
libluabind $(LUASERVER) ;
}
if $(BINDINGS) = TOLUA {
Library bindings : $(TOLUA_SOURCES) ;
libtolua $(LUASERVER) ;
}
liblua $(LUASERVER) ;
LUASERVER_SOURCES =
<common!iniparser>iniparser.c
<curses>listbox.c
server.cpp
korrektur.c
@ -54,11 +80,10 @@ LUASERVER_SOURCES =
# eressea-server with lua scripting
LinkLibraries $(LUASERVER) :
luabindings gamecode items spells kernel modules attributes races triggers util ;
luabind $(LUASERVER) ;
bindings gamecode items spells kernel modules attributes races triggers util ;
libxml2 $(LUASERVER) ;
LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ -lncurses ;
if $(DEBUG) = 1 {
LINKLIBS on $(LUASERVER) += -lmcheck ;
}
libcurses $(LUASERVER) ;
libmcheck $(LUASERVER) ;
LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ ;
Main $(LUASERVER) : $(LUASERVER_SOURCES) ;

View File

@ -17,6 +17,7 @@ extern "C" {
struct lua_State;
struct selection;
struct state;
struct region;
extern int gmmain(int argc, char *argv[]);
extern int curses_readline(struct lua_State * L, const char * prompt);

View File

@ -52,7 +52,8 @@ msg_create_message(const char *type)
return lmsg;
}
static void
/*
static void
msg_destroy_message(lua_message * msg)
{
if (msg->msg) msg_release(msg->msg);
@ -65,7 +66,7 @@ msg_destroy_message(lua_message * msg)
}
}
}
*/
int
msg_set_resource(lua_message * msg, const char * param, const char * resname)
{

View File

@ -244,6 +244,7 @@ tolua_region_open(lua_State* tolua_S)
tolua_function(tolua_S, "get_resource", tolua_region_get_resource);
tolua_function(tolua_S, "set_resource", tolua_region_set_resource);
tolua_function(tolua_S, "get_flag", tolua_region_get_flag);
tolua_function(tolua_S, "set_flag", tolua_region_set_flag);
tolua_function(tolua_S, "create", tolua_region_create);
tolua_function(tolua_S, "get_key", tolua_region_getkey);

View File

@ -46,6 +46,8 @@ without prior permission by the authors of Eressea.
#include <lua.h>
#include <tolua.h>
#include <limits.h>
static int
tolua_unit_get_objects(lua_State* tolua_S)
{

View File

@ -280,9 +280,21 @@ tolua_dice_rand(lua_State * tolua_S)
}
static int
lua_addequipment(const char * eqname, const char * iname, const char * value)
tolua_addequipment(lua_State * tolua_S)
{
return 0;
const char * eqname = tolua_tostring(tolua_S, 1, 0);
const char * iname = tolua_tostring(tolua_S, 2, 0);
const char * value = tolua_tostring(tolua_S, 3, 0);
int result = -1;
if (iname!=NULL) {
const struct item_type * itype = it_find(iname);
if (itype!=NULL) {
equipment_setitem(create_equipment(eqname), itype, value);
result = 0;
}
}
lua_pushnumber(tolua_S, (lua_Number)result);
return 1;
}
static int
@ -345,7 +357,7 @@ tolua_get_nmrs(lua_State * tolua_S)
}
static int
tolua_lua_equipunit(lua_State * tolua_S)
tolua_equipunit(lua_State * tolua_S)
{
unit * u = (unit *)tolua_tousertype(tolua_S, 1, 0);
const char * eqname = tolua_tostring(tolua_S, 2, 0);
@ -709,7 +721,7 @@ tolua_eressea_open(lua_State* tolua_S)
{
tolua_variable(tolua_S, "name", tolua_get_alliance_name, tolua_set_alliance_name);
tolua_variable(tolua_S, "id", tolua_get_alliance_id, NULL);
tolua_variable(tolua_S, "factions", tolua_get_alliance_factions, NULL);
tolua_variable(tolua_S, "factions", &tolua_get_alliance_factions, NULL);
tolua_function(tolua_S, "create", tolua_alliance_create);
}
tolua_endmodule(tolua_S);
@ -763,7 +775,8 @@ tolua_eressea_open(lua_State* tolua_S)
tolua_function(tolua_S, "get_season", tolua_get_season);
tolua_function(tolua_S, "equipment_setitem", tolua_equipment_setitem);
tolua_function(tolua_S, "equip_unit", tolua_lua_equipunit);
tolua_function(tolua_S, "equip_unit", tolua_equipunit);
tolua_function(tolua_S, "add_equipment", tolua_addequipment);
tolua_function(tolua_S, "atoi36", tolua_atoi36);
tolua_function(tolua_S, "itoa36", tolua_itoa36);