- tolua defautl installations have very broken char* parameters.

- fixed non-combined compilation
This commit is contained in:
Enno Rehling 2009-07-07 23:48:34 +00:00
parent 9f8038ad6e
commit 1c2bbbc21e
20 changed files with 381 additions and 371 deletions

View file

@ -1,7 +1,7 @@
SubDir TOP ;
#SubInclude TOP common ;
#SubInclude TOP eressea ;
SubInclude TOP common ;
SubInclude TOP eressea ;
SubInclude TOP combined ;
# SubInclude TOP tools ;
SubInclude TOP tools ;

View file

@ -275,5 +275,6 @@ extern char * strdup(const char *s);
# define INLINE_FUNCTION
#endif
#define TOLUA_CAST (char*)
#endif

View file

@ -16,6 +16,7 @@ SOURCES =
items.c
laws.c
luck.c
market.c
monster.c
randenc.c
report.c

View file

@ -3251,7 +3251,7 @@ static void fishing(region * r) {
int cap = shipcapacity(sh);
getshipweight(sh, &weight, &cabins);
if (cap>weight) {
int fishes = min(cap-weight, sh->type->fishing*i_silver->weight);
int fishes = MIN(cap-weight, sh->type->fishing*i_silver->weight);
fishes /= i_silver->weight;
i_change(&u->items, i_silver, fishes);
ADDMSG(&u->faction->msgs, msg_message("income_fishing",

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <kernel/eressea.h>
#include <attributes/racename.h>
#include "terrain.h"
#include "terrainid.h"
@ -30,6 +31,7 @@
#include "resources.h"
#include <util/log.h>
#include <util/attrib.h>
/* libc includes */
#include <assert.h>

View file

@ -29,6 +29,7 @@
#include <kernel/spellid.h>
#include <kernel/race.h>
#include <kernel/skill.h>
#include <kernel/terrain.h>
/* util includes */
#include <util/attrib.h>

View file

@ -31,6 +31,7 @@ TOLUA_SOURCES =
<tolua>helpers.c
<tolua>bind_unit.c
<tolua>bind_ship.c
<tolua>bind_storage.c
<tolua>bind_faction.c
<tolua>bind_region.c
<tolua>bind_message.c
@ -71,7 +72,7 @@ liblua $(LUASERVER) ;
LUASERVER_SOURCES =
<common!iniparser>iniparser.c
<curses>listbox.c
server.cpp
server.c
korrektur.c
console.c
editing.c

View file

@ -13,6 +13,7 @@
#include "editing.h"
#include <kernel/region.h>
#include <kernel/plane.h>
#include <modules/autoseed.h>
#include <util/rng.h>
#include <util/lists.h>

View file

@ -11,6 +11,7 @@
#ifndef GM_EDITING
#define GM_EDITING
struct terrain_type;
extern void make_block(int x, int y, int radius, const struct terrain_type * terrain);
extern void make_island(int x, int y, int size);
extern void seed_players(const char * filename, boolean new_island);

View file

@ -26,7 +26,7 @@ int tolua_buildinglist_next(lua_State *L)
building** building_ptr = (building **)lua_touserdata(L, lua_upvalueindex(1));
building * u = *building_ptr;
if (u != NULL) {
tolua_pushusertype(L, (void*)u, "building");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "building");
*building_ptr = u->next;
return 1;
}
@ -50,14 +50,14 @@ static int
tolua_building_get_objects(lua_State* L)
{
building * self = (building *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)&self->attribs, "hashtable");
tolua_pushusertype(L, (void*)&self->attribs, TOLUA_CAST "hashtable");
return 1;
}
static int tolua_building_get_region(lua_State* L)
{
building* self = (building*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, building_getregion(self), "region");
tolua_pushusertype(L, building_getregion(self), TOLUA_CAST "region");
return 1;
}
@ -138,7 +138,7 @@ tolua_building_create(lua_State* L)
if (bname) {
const building_type * btype = bt_find(bname);
building * b = new_building(btype, r, NULL);
tolua_pushusertype(L, (void*)b, "building");
tolua_pushusertype(L, (void*)b, TOLUA_CAST "building");
return 1;
}
return 0;
@ -164,31 +164,31 @@ void
tolua_building_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "building");
tolua_usertype(L, "building_list");
tolua_usertype(L, TOLUA_CAST "building");
tolua_usertype(L, TOLUA_CAST "building_list");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "building", "building", "", NULL);
tolua_beginmodule(L, "building");
tolua_cclass(L, TOLUA_CAST "building", TOLUA_CAST "building", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "building");
{
tolua_function(L, "create", tolua_building_create);
tolua_function(L, "destroy", tolua_building_destroy);
tolua_function(L, "__tostring", tolua_building_tostring);
tolua_function(L, TOLUA_CAST "create", tolua_building_create);
tolua_function(L, TOLUA_CAST "destroy", tolua_building_destroy);
tolua_function(L, TOLUA_CAST "__tostring", tolua_building_tostring);
tolua_variable(L, "id", tolua_building_get_id, NULL);
tolua_variable(L, "type", tolua_building_get_type, NULL);
tolua_variable(L, "name", tolua_building_get_name, tolua_building_set_name);
tolua_variable(L, "units", tolua_building_get_units, NULL);
tolua_variable(L, "region", tolua_building_get_region, tolua_building_set_region);
tolua_variable(L, "size", tolua_building_get_size, tolua_building_set_size);
tolua_function(L, "add_action", tolua_building_addaction);
tolua_variable(L, TOLUA_CAST "id", tolua_building_get_id, NULL);
tolua_variable(L, TOLUA_CAST "type", tolua_building_get_type, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_building_get_name, tolua_building_set_name);
tolua_variable(L, TOLUA_CAST "units", tolua_building_get_units, NULL);
tolua_variable(L, TOLUA_CAST "region", tolua_building_get_region, tolua_building_set_region);
tolua_variable(L, TOLUA_CAST "size", tolua_building_get_size, tolua_building_set_size);
tolua_function(L, TOLUA_CAST "add_action", tolua_building_addaction);
#ifdef TODO
.property("type", &building_gettype)
.def_readwrite("size", &building::size)
#endif
tolua_variable(L, "objects", tolua_building_get_objects, 0);
tolua_variable(L, TOLUA_CAST "objects", tolua_building_get_objects, 0);
}
tolua_endmodule(L);

View file

@ -33,7 +33,7 @@ int tolua_factionlist_next(lua_State *L)
faction** faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1));
faction * f = *faction_ptr;
if (f != NULL) {
tolua_pushusertype(L, (void*)f, "faction");
tolua_pushusertype(L, (void*)f, TOLUA_CAST "faction");
*faction_ptr = f->next;
return 1;
}
@ -45,7 +45,7 @@ int tolua_factionlist_iter(lua_State *L)
faction_list** faction_ptr = (faction_list **)lua_touserdata(L, lua_upvalueindex(1));
faction_list* flist = *faction_ptr;
if (flist != NULL) {
tolua_pushusertype(L, (void*)flist->data, "faction");
tolua_pushusertype(L, (void*)flist->data, TOLUA_CAST "faction");
*faction_ptr = flist->next;
return 1;
}
@ -57,7 +57,7 @@ static int tolua_faction_get_units(lua_State* L)
faction * self = (faction *)tolua_tousertype(L, 1, 0);
unit ** unit_ptr = (unit**)lua_newuserdata(L, sizeof(unit *));
luaL_getmetatable(L, "unit");
luaL_getmetatable(L, TOLUA_CAST "unit");
lua_setmetatable(L, -2);
*unit_ptr = self->units;
@ -194,7 +194,7 @@ static int
tolua_faction_get_objects(lua_State* L)
{
faction * self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)&self->attribs, "hashtable");
tolua_pushusertype(L, (void*)&self->attribs, TOLUA_CAST "hashtable");
return 1;
}
@ -278,7 +278,7 @@ tolua_faction_create(lua_State* L)
if (frace!=NULL) {
f = addfaction(email, NULL, frace, loc, 0);
}
tolua_pushusertype(L, f, "faction");
tolua_pushusertype(L, f, TOLUA_CAST "faction");
return 1;
}
@ -375,7 +375,7 @@ static int tolua_faction_set_info(lua_State* L)
static int tolua_faction_get_alliance(lua_State* L)
{
faction* self = (faction*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, self->alliance, "alliance");
tolua_pushusertype(L, self->alliance, TOLUA_CAST "alliance");
return 1;
}
@ -396,7 +396,7 @@ static int tolua_faction_get_items(lua_State* L)
faction* self = (faction*)tolua_tousertype(L, 1, 0);
item ** item_ptr = (item **)lua_newuserdata(L, sizeof(item *));
luaL_getmetatable(L, "item");
luaL_getmetatable(L, TOLUA_CAST "item");
lua_setmetatable(L, -2);
*item_ptr = self->items;
@ -420,7 +420,7 @@ static int tolua_faction_get_spells(lua_State* L)
spell_list * slist = self->spellbook;
if (slist) {
spell_list ** spell_ptr = (spell_list **)lua_newuserdata(L, sizeof(spell_list *));
luaL_getmetatable(L, "spell_list");
luaL_getmetatable(L, TOLUA_CAST "spell_list");
lua_setmetatable(L, -2);
*spell_ptr = slist;
@ -436,44 +436,44 @@ void
tolua_faction_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "faction");
tolua_usertype(L, "faction_list");
tolua_usertype(L, TOLUA_CAST "faction");
tolua_usertype(L, TOLUA_CAST "faction_list");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "faction", "faction", "", NULL);
tolua_beginmodule(L, "faction");
tolua_cclass(L, TOLUA_CAST "faction", TOLUA_CAST "faction", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "faction");
{
tolua_function(L, "__tostring", tolua_faction_tostring);
tolua_function(L, TOLUA_CAST "__tostring", tolua_faction_tostring);
tolua_variable(L, "name", tolua_faction_get_name, tolua_faction_set_name);
tolua_variable(L, "info", tolua_faction_get_info, tolua_faction_set_info);
tolua_variable(L, "units", tolua_faction_get_units, NULL);
tolua_variable(L, "heroes", tolua_faction_get_heroes, NULL);
tolua_variable(L, "spells", tolua_faction_get_spells, 0);
tolua_variable(L, "maxheroes", tolua_faction_get_maxheroes, NULL);
tolua_variable(L, "password", tolua_faction_get_password, tolua_faction_set_password);
tolua_variable(L, "email", tolua_faction_get_email, tolua_faction_set_email);
tolua_variable(L, "locale", tolua_faction_get_locale, tolua_faction_set_locale);
tolua_variable(L, "race", tolua_faction_get_race, tolua_faction_set_race);
tolua_variable(L, "alliance", tolua_faction_get_alliance, tolua_faction_set_alliance);
tolua_variable(L, "score", tolua_faction_get_score, NULL);
tolua_variable(L, "id", tolua_faction_get_id, tolua_faction_set_id);
tolua_variable(L, "age", tolua_faction_get_age, tolua_faction_set_age);
tolua_variable(L, "options", tolua_faction_get_options, tolua_faction_set_options);
tolua_variable(L, "flags", tolua_faction_get_flags, NULL);
tolua_variable(L, "lastturn", tolua_faction_get_lastturn, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_faction_get_name, tolua_faction_set_name);
tolua_variable(L, TOLUA_CAST "info", tolua_faction_get_info, tolua_faction_set_info);
tolua_variable(L, TOLUA_CAST "units", tolua_faction_get_units, NULL);
tolua_variable(L, TOLUA_CAST "heroes", tolua_faction_get_heroes, NULL);
tolua_variable(L, TOLUA_CAST "spells", tolua_faction_get_spells, 0);
tolua_variable(L, TOLUA_CAST "maxheroes", tolua_faction_get_maxheroes, NULL);
tolua_variable(L, TOLUA_CAST "password", tolua_faction_get_password, tolua_faction_set_password);
tolua_variable(L, TOLUA_CAST "email", tolua_faction_get_email, tolua_faction_set_email);
tolua_variable(L, TOLUA_CAST "locale", tolua_faction_get_locale, tolua_faction_set_locale);
tolua_variable(L, TOLUA_CAST "race", tolua_faction_get_race, tolua_faction_set_race);
tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliance, tolua_faction_set_alliance);
tolua_variable(L, TOLUA_CAST "score", tolua_faction_get_score, NULL);
tolua_variable(L, TOLUA_CAST "id", tolua_faction_get_id, tolua_faction_set_id);
tolua_variable(L, TOLUA_CAST "age", tolua_faction_get_age, tolua_faction_set_age);
tolua_variable(L, TOLUA_CAST "options", tolua_faction_get_options, tolua_faction_set_options);
tolua_variable(L, TOLUA_CAST "flags", tolua_faction_get_flags, NULL);
tolua_variable(L, TOLUA_CAST "lastturn", tolua_faction_get_lastturn, NULL);
tolua_function(L, "set_policy", tolua_faction_set_policy);
tolua_function(L, "get_policy", tolua_faction_get_policy);
tolua_function(L, "get_origin", tolua_faction_get_origin);
tolua_function(L, TOLUA_CAST "set_policy", tolua_faction_set_policy);
tolua_function(L, TOLUA_CAST "get_policy", tolua_faction_get_policy);
tolua_function(L, TOLUA_CAST "get_origin", tolua_faction_get_origin);
tolua_function(L, "add_item", tolua_faction_add_item);
tolua_variable(L, "items", tolua_faction_get_items, NULL);
tolua_function(L, TOLUA_CAST "add_item", tolua_faction_add_item);
tolua_variable(L, TOLUA_CAST "items", tolua_faction_get_items, NULL);
tolua_function(L, "renumber", tolua_faction_renumber);
tolua_function(L, "create", tolua_faction_create);
tolua_function(L, TOLUA_CAST "renumber", tolua_faction_renumber);
tolua_function(L, TOLUA_CAST "create", tolua_faction_create);
#ifdef TODO
def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)),
@ -484,7 +484,7 @@ tolua_faction_open(lua_State* L)
.def("add_notice", &faction_addnotice)
#endif
tolua_variable(L, "objects", tolua_faction_get_objects, NULL);
tolua_variable(L, TOLUA_CAST "objects", tolua_faction_get_objects, NULL);
}
tolua_endmodule(L);
}

View file

@ -32,7 +32,7 @@ static int
tolua_current_region(lua_State* L)
{
map_region * mr = cursor_region(&current_state->display, &current_state->cursor);
tolua_pushusertype(L, mr?mr->r:NULL, "region");
tolua_pushusertype(L, mr?mr->r:NULL, TOLUA_CAST "region");
return 1;
}
@ -112,7 +112,7 @@ tolua_tags_next(lua_State *L)
{
tag_iterator * iter = (tag_iterator *)lua_touserdata(L, lua_upvalueindex(1));
if (iter->node) {
tolua_pushusertype(L, (void*)iter->r, "region");
tolua_pushusertype(L, (void*)iter->r, TOLUA_CAST "region");
tag_advance(iter);
return 1;
}
@ -171,7 +171,7 @@ tolua_make_block(lua_State * L)
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
int r = (int)tolua_tonumber(L, 3, 6);
const char * str = tolua_tostring(L, 4, "ocean");
const char * str = tolua_tostring(L, 4, TOLUA_CAST "ocean");
const struct terrain_type * ter = get_terrain(str);
make_block(x, y, r, ter);
@ -182,26 +182,26 @@ void
tolua_gmtool_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "tag_iterator");
tolua_usertype(L, TOLUA_CAST "tag_iterator");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_module(L, "gmtool", 0);
tolua_beginmodule(L, "gmtool");
tolua_module(L, TOLUA_CAST "gmtool", 0);
tolua_beginmodule(L, TOLUA_CAST "gmtool");
{
tolua_function(L, "open", tolua_state_open);
tolua_function(L, "close", tolua_state_close);
tolua_function(L, TOLUA_CAST "open", tolua_state_open);
tolua_function(L, TOLUA_CAST "close", tolua_state_close);
tolua_function(L, "editor", tolua_run_mapper);
tolua_function(L, "get_selection", tolua_selected_regions);
tolua_function(L, "get_cursor", tolua_current_region);
tolua_function(L, "highlight", tolua_highlight_region);
tolua_function(L, "select", tolua_select_region);
tolua_function(L, "select_at", tolua_select_coordinate);
tolua_function(L, TOLUA_CAST "editor", tolua_run_mapper);
tolua_function(L, TOLUA_CAST "get_selection", tolua_selected_regions);
tolua_function(L, TOLUA_CAST "get_cursor", tolua_current_region);
tolua_function(L, TOLUA_CAST "highlight", tolua_highlight_region);
tolua_function(L, TOLUA_CAST "select", tolua_select_region);
tolua_function(L, TOLUA_CAST "select_at", tolua_select_coordinate);
tolua_function(L, "make_block", &tolua_make_block);
tolua_function(L, "make_island", &tolua_make_island);
tolua_function(L, TOLUA_CAST "make_block", &tolua_make_block);
tolua_function(L, TOLUA_CAST "make_island", &tolua_make_island);
}
tolua_endmodule(L);
}

View file

@ -53,16 +53,16 @@ tolua_hashtable_get(lua_State* L)
lua_pushnumber(L, (lua_Number)val.f);
break;
case TREGION:
tolua_pushusertype(L, val.v, "region");
tolua_pushusertype(L, val.v, TOLUA_CAST "region");
break;
case TBUILDING:
tolua_pushusertype(L, val.v, "building");
tolua_pushusertype(L, val.v, TOLUA_CAST "building");
break;
case TUNIT:
tolua_pushusertype(L, val.v, "unit");
tolua_pushusertype(L, val.v, TOLUA_CAST "unit");
break;
case TSHIP:
tolua_pushusertype(L, val.v, "ship");
tolua_pushusertype(L, val.v, TOLUA_CAST "ship");
break;
case TSTRING:
tolua_pushstring(L, (const char*) val.v);
@ -150,15 +150,15 @@ tolua_hashtable_set(lua_State* L)
tolua_Error tolua_err;
if (tolua_isnumber(L, 3, 0, &tolua_err)) {
return tolua_hashtable_set_number(L);
} else if (tolua_isusertype(L, 3, "unit", 0, &tolua_err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &tolua_err)) {
return tolua_hashtable_set_usertype(L, TUNIT);
} else if (tolua_isusertype(L, 3, "faction", 0, &tolua_err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "faction", 0, &tolua_err)) {
return tolua_hashtable_set_usertype(L, TFACTION);
} else if (tolua_isusertype(L, 3, "ship", 0, &tolua_err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "ship", 0, &tolua_err)) {
return tolua_hashtable_set_usertype(L, TSHIP);
} else if (tolua_isusertype(L, 3, "building", 0, &tolua_err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "building", 0, &tolua_err)) {
return tolua_hashtable_set_usertype(L, TBUILDING);
} else if (tolua_isusertype(L, 3, "region", 0, &tolua_err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "region", 0, &tolua_err)) {
return tolua_hashtable_set_usertype(L, TREGION);
}
return tolua_hashtable_set_string(L);
@ -170,16 +170,16 @@ void
tolua_hashtable_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "hashtable");
tolua_usertype(L, TOLUA_CAST "hashtable");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "hashtable", "hashtable", "", NULL);
tolua_beginmodule(L, "hashtable");
tolua_cclass(L, TOLUA_CAST "hashtable", TOLUA_CAST "hashtable", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "hashtable");
{
tolua_function(L, "get", tolua_hashtable_get);
tolua_function(L, "set", tolua_hashtable_set);
tolua_function(L, TOLUA_CAST "get", tolua_hashtable_get);
tolua_function(L, TOLUA_CAST "set", tolua_hashtable_set);
}
tolua_endmodule(L);
}

View file

@ -199,7 +199,7 @@ tolua_msg_create(lua_State * L)
{
const char * type = tolua_tostring(L, 1, 0);
lua_message * lmsg = msg_create_message(type);
tolua_pushusertype(L, (void*)lmsg, "message");
tolua_pushusertype(L, (void*)lmsg, TOLUA_CAST "message");
return 1;
}
static int
@ -263,9 +263,9 @@ tolua_msg_set(lua_State * L)
tolua_Error err;
if (tolua_isnumber(L, 3, 0, &err)) {
return tolua_msg_set_int(L);
} else if (tolua_isusertype(L, 3, "region", 0, &err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "region", 0, &err)) {
return tolua_msg_set_region(L);
} else if (tolua_isusertype(L, 3, "unit", 0, &err)) {
} else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) {
return tolua_msg_set_unit(L);
}
tolua_pushnumber(L, (lua_Number)-1);
@ -296,26 +296,26 @@ void
tolua_message_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "message");
tolua_usertype(L, TOLUA_CAST "message");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_function(L, "message", tolua_msg_create);
tolua_function(L, TOLUA_CAST "message", tolua_msg_create);
tolua_cclass(L, "message", "message", "", NULL);
tolua_beginmodule(L, "message");
tolua_cclass(L, TOLUA_CAST "message", TOLUA_CAST "message", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "message");
{
tolua_function(L, "set", tolua_msg_set);
tolua_function(L, "set_unit", tolua_msg_set_unit);
tolua_function(L, "set_region", tolua_msg_set_region);
tolua_function(L, "set_resource", tolua_msg_set_resource);
tolua_function(L, "set_int", tolua_msg_set_int);
tolua_function(L, "set_string", tolua_msg_set_string);
tolua_function(L, "send_faction", tolua_msg_send_faction);
tolua_function(L, "send_region", tolua_msg_send_region);
tolua_function(L, TOLUA_CAST "set", tolua_msg_set);
tolua_function(L, TOLUA_CAST "set_unit", tolua_msg_set_unit);
tolua_function(L, TOLUA_CAST "set_region", tolua_msg_set_region);
tolua_function(L, TOLUA_CAST "set_resource", tolua_msg_set_resource);
tolua_function(L, TOLUA_CAST "set_int", tolua_msg_set_int);
tolua_function(L, TOLUA_CAST "set_string", tolua_msg_set_string);
tolua_function(L, TOLUA_CAST "send_faction", tolua_msg_send_faction);
tolua_function(L, TOLUA_CAST "send_region", tolua_msg_send_region);
tolua_function(L, "create", tolua_msg_create);
tolua_function(L, TOLUA_CAST "create", tolua_msg_create);
}
tolua_endmodule(L);
}

View file

@ -45,7 +45,7 @@ int tolua_regionlist_next(lua_State *L)
region** region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1));
region * r = *region_ptr;
if (r != NULL) {
tolua_pushusertype(L, (void*)r, "region");
tolua_pushusertype(L, (void*)r, TOLUA_CAST "region");
*region_ptr = r->next;
return 1;
}
@ -153,7 +153,7 @@ static int tolua_region_get_adj(lua_State* L)
region* self = (region*)tolua_tousertype(L, 1, 0);
direction_t dir = (direction_t)tolua_tonumber(L, 2, 0);
tolua_pushusertype(L, (void*)r_connect(self, dir), "region");
tolua_pushusertype(L, (void*)r_connect(self, dir), TOLUA_CAST "region");
return 1;
}
@ -240,7 +240,7 @@ static int
tolua_region_get_objects(lua_State* L)
{
region * self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)&self->attribs, "hashtable");
tolua_pushusertype(L, (void*)&self->attribs, TOLUA_CAST "hashtable");
return 1;
}
@ -281,7 +281,7 @@ tolua_region_create(lua_State* L)
}
fix_demand(result);
tolua_pushusertype(L, result, "region");
tolua_pushusertype(L, result, TOLUA_CAST "region");
return 1;
}
@ -382,7 +382,7 @@ tolua_plane_get(lua_State* L)
int id = (int)tolua_tonumber(L, 1, 0);
plane * pl = getplanebyid(id);
tolua_pushusertype(L, pl, "plane");
tolua_pushusertype(L, pl, TOLUA_CAST "plane");
return 1;
}
@ -399,7 +399,7 @@ tolua_plane_create(lua_State* L)
pl = create_new_plane(id, name, x, x+width-1, y, y+height-1, 0);
tolua_pushusertype(L, pl, "plane");
tolua_pushusertype(L, pl, TOLUA_CAST "plane");
return 1;
}
@ -470,42 +470,42 @@ void
tolua_region_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "region");
tolua_usertype(L, "plane");
tolua_usertype(L, TOLUA_CAST "region");
tolua_usertype(L, TOLUA_CAST "plane");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_function(L, "distance", tolua_distance);
tolua_function(L, TOLUA_CAST "distance", tolua_distance);
tolua_cclass(L, "region", "region", "", NULL);
tolua_beginmodule(L, "region");
tolua_cclass(L, TOLUA_CAST "region", TOLUA_CAST "region", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "region");
{
tolua_function(L, "create", tolua_region_create);
tolua_function(L, "destroy", tolua_region_destroy);
tolua_function(L, "__tostring", tolua_region_tostring);
tolua_function(L, TOLUA_CAST "create", tolua_region_create);
tolua_function(L, TOLUA_CAST "destroy", tolua_region_destroy);
tolua_function(L, TOLUA_CAST "__tostring", tolua_region_tostring);
tolua_variable(L, "id", tolua_region_get_id, NULL);
tolua_variable(L, "x", tolua_region_get_x, NULL);
tolua_variable(L, "y", tolua_region_get_y, NULL);
tolua_variable(L, "name", tolua_region_get_name, tolua_region_set_name);
tolua_variable(L, "info", tolua_region_get_info, tolua_region_set_info);
tolua_variable(L, "units", tolua_region_get_units, NULL);
tolua_variable(L, "ships", tolua_region_get_ships, NULL);
tolua_variable(L, "age", tolua_region_get_age, NULL);
tolua_variable(L, "buildings", tolua_region_get_buildings, NULL);
tolua_variable(L, "terrain", tolua_region_get_terrain, NULL);
tolua_function(L, "get_resourcelevel", tolua_region_get_resourcelevel);
tolua_function(L, "get_resource", tolua_region_get_resource);
tolua_function(L, "set_resource", tolua_region_set_resource);
tolua_function(L, "get_flag", tolua_region_get_flag);
tolua_function(L, "set_flag", tolua_region_set_flag);
tolua_function(L, "next", tolua_region_get_adj);
tolua_variable(L, TOLUA_CAST "id", tolua_region_get_id, NULL);
tolua_variable(L, TOLUA_CAST "x", tolua_region_get_x, NULL);
tolua_variable(L, TOLUA_CAST "y", tolua_region_get_y, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_region_get_name, tolua_region_set_name);
tolua_variable(L, TOLUA_CAST "info", tolua_region_get_info, tolua_region_set_info);
tolua_variable(L, TOLUA_CAST "units", tolua_region_get_units, NULL);
tolua_variable(L, TOLUA_CAST "ships", tolua_region_get_ships, NULL);
tolua_variable(L, TOLUA_CAST "age", tolua_region_get_age, NULL);
tolua_variable(L, TOLUA_CAST "buildings", tolua_region_get_buildings, NULL);
tolua_variable(L, TOLUA_CAST "terrain", tolua_region_get_terrain, NULL);
tolua_function(L, TOLUA_CAST "get_resourcelevel", tolua_region_get_resourcelevel);
tolua_function(L, TOLUA_CAST "get_resource", tolua_region_get_resource);
tolua_function(L, TOLUA_CAST "set_resource", tolua_region_set_resource);
tolua_function(L, TOLUA_CAST "get_flag", tolua_region_get_flag);
tolua_function(L, TOLUA_CAST "set_flag", tolua_region_set_flag);
tolua_function(L, TOLUA_CAST "next", tolua_region_get_adj);
tolua_variable(L, "terrain_name", &tolua_region_get_terrainname, &tolua_region_set_terrainname);
tolua_variable(L, TOLUA_CAST "terrain_name", &tolua_region_get_terrainname, &tolua_region_set_terrainname);
tolua_function(L, "get_key", tolua_region_getkey);
tolua_function(L, "set_key", tolua_region_setkey);
tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey);
tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey);
#if 0
.property("owner", &lua_region_getowner, &lua_region_setowner)
.property("herbtype", &region_getherbtype, &region_setherbtype)
@ -519,20 +519,20 @@ tolua_region_open(lua_State* L)
.property("items", &region_items, return_stl_iterator)
.property("plane_id", &region_plane)
#endif
tolua_variable(L, "objects", tolua_region_get_objects, 0);
tolua_variable(L, TOLUA_CAST "objects", tolua_region_get_objects, 0);
}
tolua_endmodule(L);
tolua_cclass(L, "plane", "plane", "", NULL);
tolua_beginmodule(L, "plane");
tolua_cclass(L, TOLUA_CAST "plane", TOLUA_CAST "plane", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "plane");
{
tolua_function(L, "create", tolua_plane_create);
tolua_function(L, "get", tolua_plane_get);
tolua_function(L, "__tostring", tolua_plane_tostring);
tolua_function(L, TOLUA_CAST "create", tolua_plane_create);
tolua_function(L, TOLUA_CAST "get", tolua_plane_get);
tolua_function(L, TOLUA_CAST "__tostring", tolua_plane_tostring);
tolua_variable(L, "id", tolua_plane_get_id, NULL);
tolua_function(L, "normalize", tolua_plane_normalize);
tolua_variable(L, "name", tolua_plane_get_name, tolua_plane_set_name);
tolua_variable(L, TOLUA_CAST "id", tolua_plane_get_id, NULL);
tolua_function(L, TOLUA_CAST "normalize", tolua_plane_normalize);
tolua_variable(L, TOLUA_CAST "name", tolua_plane_get_name, tolua_plane_set_name);
}
tolua_endmodule(L);
}

View file

@ -16,6 +16,7 @@ without prior permission by the authors of Eressea.
#include <kernel/region.h>
#include <kernel/unit.h>
#include <kernel/move.h>
#include <kernel/ship.h>
#include <kernel/build.h>
@ -29,7 +30,7 @@ int tolua_shiplist_next(lua_State *L)
ship** ship_ptr = (ship **)lua_touserdata(L, lua_upvalueindex(1));
ship * u = *ship_ptr;
if (u != NULL) {
tolua_pushusertype(L, (void*)u, "ship");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "ship");
*ship_ptr = u->next;
return 1;
}
@ -55,7 +56,7 @@ static int tolua_ship_get_region(lua_State* L)
{
ship* self = (ship*) tolua_tousertype(L, 1, 0);
if (self) {
tolua_pushusertype(L, self->region, "region");
tolua_pushusertype(L, self->region, TOLUA_CAST "region");
return 1;
}
return 0;
@ -86,7 +87,7 @@ tolua_ship_get_units(lua_State* L)
unit * u = self->region->units;
while (u && u->ship!=self) u = u->next;
luaL_getmetatable(L, "unit");
luaL_getmetatable(L, TOLUA_CAST "unit");
lua_setmetatable(L, -2);
*unit_ptr = u;
@ -99,7 +100,7 @@ static int
tolua_ship_get_objects(lua_State* L)
{
ship * self = (ship *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)&self->attribs, "hashtable");
tolua_pushusertype(L, (void*)&self->attribs, TOLUA_CAST "hashtable");
return 1;
}
@ -113,7 +114,7 @@ tolua_ship_create(lua_State* L)
if (stype) {
ship * sh = new_ship(stype, NULL, r);
sh->size = stype->construction->maxsize;
tolua_pushusertype(L, (void*)sh, "ship");
tolua_pushusertype(L, (void*)sh, TOLUA_CAST "ship");
return 1;
}
}
@ -133,19 +134,19 @@ void
tolua_ship_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "ship");
tolua_usertype(L, TOLUA_CAST "ship");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "ship", "ship", "", NULL);
tolua_beginmodule(L, "ship");
tolua_cclass(L, TOLUA_CAST "ship", TOLUA_CAST "ship", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "ship");
{
tolua_function(L, "__tostring", tolua_ship_tostring);
tolua_variable(L, "id", tolua_ship_get_id, NULL);
tolua_variable(L, "name", tolua_ship_get_name, tolua_ship_set_name);
tolua_variable(L, "units", tolua_ship_get_units, NULL);
tolua_variable(L, "region", tolua_ship_get_region, tolua_ship_set_region);
tolua_function(L, TOLUA_CAST "__tostring", tolua_ship_tostring);
tolua_variable(L, TOLUA_CAST "id", tolua_ship_get_id, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_ship_get_name, tolua_ship_set_name);
tolua_variable(L, TOLUA_CAST "units", tolua_ship_get_units, NULL);
tolua_variable(L, TOLUA_CAST "region", tolua_ship_get_region, tolua_ship_set_region);
#ifdef TODO
.property("type", &ship_gettype)
.property("weight", &ship_getweight)
@ -156,9 +157,9 @@ tolua_ship_open(lua_State* L)
.def_readwrite("size", &ship::size)
.def_readwrite("coast", &ship::coast)
#endif
tolua_variable(L, "objects", tolua_ship_get_objects, 0);
tolua_variable(L, TOLUA_CAST "objects", tolua_ship_get_objects, 0);
tolua_function(L, "create", tolua_ship_create);
tolua_function(L, TOLUA_CAST "create", tolua_ship_create);
}
tolua_endmodule(L);
}

View file

@ -11,6 +11,7 @@ without prior permission by the authors of Eressea.
*/
#include <config.h>
#include <kernel/types.h>
#include "bind_storage.h"
#include <util/storage.h>
@ -41,7 +42,7 @@ tolua_storage_create(lua_State* L)
if (strchr(type, 'r')) mode = IO_READ;
if (strchr(type, 'w')) mode = IO_WRITE;
store->open(store, filename, mode);
tolua_pushusertype(L, (void*)store, "storage");
tolua_pushusertype(L, (void*)store, TOLUA_CAST "storage");
return 1;
}
@ -50,7 +51,7 @@ tolua_storage_read_unit(lua_State *L)
{
storage * self = (storage *)tolua_tousertype(L, 1, 0);
struct unit * u = read_unit(self);
tolua_pushusertype(L, (void*)u, "unit");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "unit");
return 1;
}
@ -120,22 +121,22 @@ void
tolua_storage_open(lua_State* L)
{
/* register user types */
tolua_usertype(L, "storage");
tolua_usertype(L, TOLUA_CAST "storage");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "storage", "storage", "", NULL);
tolua_beginmodule(L, "storage");
tolua_cclass(L, TOLUA_CAST "storage", TOLUA_CAST "storage", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "storage");
{
tolua_function(L, "__tostring", tolua_storage_tostring);
tolua_function(L, "write", tolua_storage_write);
tolua_function(L, "read_int", tolua_storage_read_int);
tolua_function(L, "read_float", tolua_storage_read_float);
tolua_function(L, "write_unit", tolua_storage_write_unit);
tolua_function(L, "read_unit", tolua_storage_read_unit);
tolua_function(L, "close", tolua_storage_close);
tolua_function(L, "create", tolua_storage_create);
tolua_function(L, TOLUA_CAST "__tostring", tolua_storage_tostring);
tolua_function(L, TOLUA_CAST "write", tolua_storage_write);
tolua_function(L, TOLUA_CAST "read_int", tolua_storage_read_int);
tolua_function(L, TOLUA_CAST "read_float", tolua_storage_read_float);
tolua_function(L, TOLUA_CAST "write_unit", tolua_storage_write_unit);
tolua_function(L, TOLUA_CAST "read_unit", tolua_storage_read_unit);
tolua_function(L, TOLUA_CAST "close", tolua_storage_close);
tolua_function(L, TOLUA_CAST "create", tolua_storage_create);
}
tolua_endmodule(L);
}

View file

@ -53,7 +53,7 @@ static int
tolua_unit_get_objects(lua_State* L)
{
unit * self = (unit *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)&self->attribs, "hashtable");
tolua_pushusertype(L, (void*)&self->attribs, TOLUA_CAST "hashtable");
return 1;
}
@ -62,7 +62,7 @@ int tolua_unitlist_nextf(lua_State *L)
unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
unit * u = *unit_ptr;
if (u != NULL) {
tolua_pushusertype(L, (void*)u, "unit");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "unit");
*unit_ptr = u->nextF;
return 1;
}
@ -75,7 +75,7 @@ int tolua_unitlist_nextb(lua_State *L)
unit * u = *unit_ptr;
if (u != NULL) {
unit * unext = u->next;
tolua_pushusertype(L, (void*)u, "unit");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "unit");
while (unext && unext->building!=u->building) {
unext = unext->next;
@ -93,7 +93,7 @@ int tolua_unitlist_nexts(lua_State *L)
unit * u = *unit_ptr;
if (u != NULL) {
unit * unext = u->next;
tolua_pushusertype(L, (void*)u, "unit");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "unit");
while (unext && unext->ship!=u->ship) {
unext = unext->next;
@ -110,7 +110,7 @@ int tolua_unitlist_next(lua_State *L)
unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
unit * u = *unit_ptr;
if (u != NULL) {
tolua_pushusertype(L, (void*)u, "unit");
tolua_pushusertype(L, (void*)u, TOLUA_CAST "unit");
*unit_ptr = u->next;
return 1;
}
@ -379,13 +379,13 @@ fctr_handle(struct trigger * tp, void * data)
evt.args = (event_arg*)data;
lua_rawgeti(L, LUA_REGISTRYINDEX, fd->fhandle);
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, &evt, "event");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
tolua_pushusertype(L, &evt, TOLUA_CAST "event");
if (lua_pcall(L, 2, 0, 0)!=0) {
const char* error = lua_tostring(L, -1);
log_error(("event (%s): %s\n", unitname(u), error));
lua_pop(L, 1);
tolua_error(L, "event handler call failed", NULL);
tolua_error(L, TOLUA_CAST "event handler call failed", NULL);
}
return 0;
@ -618,7 +618,7 @@ unit_getfamiliar(const unit * u)
static int tolua_unit_get_familiar(lua_State* L)
{
unit* self = (unit*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, unit_getfamiliar(self), "unit");
tolua_pushusertype(L, unit_getfamiliar(self), TOLUA_CAST "unit");
return 1;
}
@ -632,7 +632,7 @@ static int tolua_unit_set_familiar(lua_State* L)
static int tolua_unit_get_building(lua_State* L)
{
unit* self = (unit*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, self->building, "building");
tolua_pushusertype(L, self->building, TOLUA_CAST "building");
return 1;
}
@ -656,7 +656,7 @@ static int tolua_unit_set_building(lua_State* L)
static int tolua_unit_get_ship(lua_State* L)
{
unit* self = (unit*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, self->ship, "ship");
tolua_pushusertype(L, self->ship, TOLUA_CAST "ship");
return 1;
}
@ -680,7 +680,7 @@ static int tolua_unit_set_ship(lua_State* L)
static int tolua_unit_get_region(lua_State* L)
{
unit* self = (unit*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, self->region, "region");
tolua_pushusertype(L, self->region, TOLUA_CAST "region");
return 1;
}
@ -719,7 +719,7 @@ static int tolua_unit_get_items(lua_State* L)
item ** item_ptr = (item **)lua_newuserdata(L, sizeof(item *));
luaL_getmetatable(L, "item");
luaL_getmetatable(L, TOLUA_CAST "item");
lua_setmetatable(L, -2);
*item_ptr = self->items;
@ -739,7 +739,7 @@ static int tolua_unit_get_spells(lua_State* L)
assert(slist);
if (slist) {
spell_list ** spell_ptr = (spell_list **)lua_newuserdata(L, sizeof(spell_list *));
luaL_getmetatable(L, "spell_list");
luaL_getmetatable(L, TOLUA_CAST "spell_list");
lua_setmetatable(L, -2);
*spell_ptr = *slist;
@ -758,7 +758,7 @@ static int tolua_unit_get_orders(lua_State* L)
order ** order_ptr = (order **)lua_newuserdata(L, sizeof(order *));
luaL_getmetatable(L, "order");
luaL_getmetatable(L, TOLUA_CAST "order");
lua_setmetatable(L, -2);
*order_ptr = self->orders;
@ -810,7 +810,7 @@ static int tolua_unit_get_capacity(lua_State* L)
static int tolua_unit_get_faction(lua_State* L)
{
unit* self = (unit*) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void*)self->faction, "faction");
tolua_pushusertype(L, (void*)self->faction, TOLUA_CAST "faction");
return 1;
}
@ -855,7 +855,7 @@ tolua_unit_create(lua_State* L)
if (rcname) rc = rc_find(rcname);
if (rc) {
unit * u = create_unit(r, f, num, rc, 0, NULL, NULL);
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}
}
@ -896,11 +896,11 @@ tolua_event_get(lua_State *L)
tolua_pushnumber(L, (lua_Number)arg->data.f);
} else {
/* this is pretty lazy */
tolua_pushusertype(L, (void*)arg->data.v, arg->type);
tolua_pushusertype(L, (void*)arg->data.v, TOLUA_CAST arg->type);
}
return 1;
}
tolua_error(L, "invalid type argument for event", NULL);
tolua_error(L, TOLUA_CAST "invalid type argument for event", NULL);
return 0;
}
@ -908,80 +908,80 @@ void
tolua_unit_open(lua_State * L)
{
/* register user types */
tolua_usertype(L, "unit");
tolua_usertype(L, "unit_list");
tolua_usertype(L, TOLUA_CAST "unit");
tolua_usertype(L, TOLUA_CAST "unit_list");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "event", "event", "", NULL);
tolua_beginmodule(L, "event");
tolua_cclass(L, TOLUA_CAST "event", TOLUA_CAST "event", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "event");
{
tolua_function(L, "get_type", &tolua_event_gettype);
tolua_function(L, "get", &tolua_event_get);
tolua_function(L, TOLUA_CAST "get_type", &tolua_event_gettype);
tolua_function(L, TOLUA_CAST "get", &tolua_event_get);
}
tolua_endmodule(L);
tolua_cclass(L, "unit", "unit", "", NULL);
tolua_beginmodule(L, "unit");
tolua_cclass(L, TOLUA_CAST "unit", TOLUA_CAST "unit", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "unit");
{
tolua_function(L, "__tostring", &tolua_unit_tostring);
tolua_function(L, "create", &tolua_unit_create);
tolua_function(L, TOLUA_CAST "__tostring", &tolua_unit_tostring);
tolua_function(L, TOLUA_CAST "create", &tolua_unit_create);
tolua_variable(L, "name", &tolua_unit_get_name, tolua_unit_set_name);
tolua_variable(L, "faction", &tolua_unit_get_faction, tolua_unit_set_faction);
tolua_variable(L, "id", &tolua_unit_get_id, tolua_unit_set_id);
tolua_variable(L, "info", &tolua_unit_get_info, tolua_unit_set_info);
tolua_variable(L, "hp", &tolua_unit_get_hp, tolua_unit_set_hp);
tolua_variable(L, "status", &tolua_unit_get_status, tolua_unit_set_status);
tolua_variable(L, "familiar", &tolua_unit_get_familiar, tolua_unit_set_familiar);
tolua_variable(L, TOLUA_CAST "name", &tolua_unit_get_name, tolua_unit_set_name);
tolua_variable(L, TOLUA_CAST "faction", &tolua_unit_get_faction, tolua_unit_set_faction);
tolua_variable(L, TOLUA_CAST "id", &tolua_unit_get_id, tolua_unit_set_id);
tolua_variable(L, TOLUA_CAST "info", &tolua_unit_get_info, tolua_unit_set_info);
tolua_variable(L, TOLUA_CAST "hp", &tolua_unit_get_hp, tolua_unit_set_hp);
tolua_variable(L, TOLUA_CAST "status", &tolua_unit_get_status, tolua_unit_set_status);
tolua_variable(L, TOLUA_CAST "familiar", &tolua_unit_get_familiar, tolua_unit_set_familiar);
tolua_variable(L, "weight", &tolua_unit_get_weight, 0);
tolua_variable(L, "capacity", &tolua_unit_get_capacity, 0);
tolua_variable(L, TOLUA_CAST "weight", &tolua_unit_get_weight, 0);
tolua_variable(L, TOLUA_CAST "capacity", &tolua_unit_get_capacity, 0);
tolua_function(L, "add_order", &tolua_unit_add_order);
tolua_function(L, "clear_orders", &tolua_unit_clear_orders);
tolua_variable(L, "orders", &tolua_unit_get_orders, 0);
tolua_function(L, TOLUA_CAST "add_order", &tolua_unit_add_order);
tolua_function(L, TOLUA_CAST "clear_orders", &tolua_unit_clear_orders);
tolua_variable(L, TOLUA_CAST "orders", &tolua_unit_get_orders, 0);
// key-attributes for named flags:
tolua_function(L, "set_flag", &tolua_unit_set_flag);
tolua_function(L, "get_flag", &tolua_unit_get_flag);
tolua_variable(L, "flags", &tolua_unit_get_flags, tolua_unit_set_flags);
tolua_variable(L, "age", &tolua_unit_get_age, tolua_unit_set_age);
tolua_function(L, TOLUA_CAST "set_flag", &tolua_unit_set_flag);
tolua_function(L, TOLUA_CAST "get_flag", &tolua_unit_get_flag);
tolua_variable(L, TOLUA_CAST "flags", &tolua_unit_get_flags, tolua_unit_set_flags);
tolua_variable(L, TOLUA_CAST "age", &tolua_unit_get_age, tolua_unit_set_age);
// items:
tolua_function(L, "get_item", &tolua_unit_get_item);
tolua_function(L, "add_item", &tolua_unit_add_item);
tolua_variable(L, "items", &tolua_unit_get_items, 0);
tolua_function(L, "get_pooled", &tolua_unit_get_pooled);
tolua_function(L, "use_pooled", &tolua_unit_use_pooled);
tolua_function(L, TOLUA_CAST "get_item", &tolua_unit_get_item);
tolua_function(L, TOLUA_CAST "add_item", &tolua_unit_add_item);
tolua_variable(L, TOLUA_CAST "items", &tolua_unit_get_items, 0);
tolua_function(L, TOLUA_CAST "get_pooled", &tolua_unit_get_pooled);
tolua_function(L, TOLUA_CAST "use_pooled", &tolua_unit_use_pooled);
// skills:
tolua_function(L, "get_skill", &tolua_unit_getskill);
tolua_function(L, "eff_skill", &tolua_unit_effskill);
tolua_function(L, "set_skill", &tolua_unit_setskill);
tolua_function(L, TOLUA_CAST "get_skill", &tolua_unit_getskill);
tolua_function(L, TOLUA_CAST "eff_skill", &tolua_unit_effskill);
tolua_function(L, TOLUA_CAST "set_skill", &tolua_unit_setskill);
tolua_function(L, "add_notice", &tolua_unit_addnotice);
tolua_function(L, TOLUA_CAST "add_notice", &tolua_unit_addnotice);
// npc logic:
tolua_function(L, "add_handler", &tolua_unit_addhandler);
tolua_function(L, TOLUA_CAST "add_handler", &tolua_unit_addhandler);
tolua_variable(L, "race_name", &tolua_unit_get_racename, &tolua_unit_set_racename);
tolua_function(L, "add_spell", &tolua_unit_addspell);
tolua_function(L, "remove_spell", &tolua_unit_removespell);
tolua_function(L, "cast_spell", &tolua_unit_castspell);
tolua_variable(L, TOLUA_CAST "race_name", &tolua_unit_get_racename, &tolua_unit_set_racename);
tolua_function(L, TOLUA_CAST "add_spell", &tolua_unit_addspell);
tolua_function(L, TOLUA_CAST "remove_spell", &tolua_unit_removespell);
tolua_function(L, TOLUA_CAST "cast_spell", &tolua_unit_castspell);
tolua_variable(L, "magic", &tolua_unit_get_magic, tolua_unit_set_magic);
tolua_variable(L, "aura", &tolua_unit_get_aura, tolua_unit_set_aura);
tolua_variable(L, "building", &tolua_unit_get_building, tolua_unit_set_building);
tolua_variable(L, "ship", &tolua_unit_get_ship, tolua_unit_set_ship);
tolua_variable(L, "region", &tolua_unit_get_region, tolua_unit_set_region);
tolua_variable(L, "spells", &tolua_unit_get_spells, 0);
tolua_variable(L, "number", &tolua_unit_get_number, tolua_unit_set_number);
tolua_variable(L, "race", &tolua_unit_get_race, tolua_unit_set_race);
tolua_variable(L, "hp_max", &tolua_unit_get_hpmax, 0);
tolua_variable(L, TOLUA_CAST "magic", &tolua_unit_get_magic, tolua_unit_set_magic);
tolua_variable(L, TOLUA_CAST "aura", &tolua_unit_get_aura, tolua_unit_set_aura);
tolua_variable(L, TOLUA_CAST "building", &tolua_unit_get_building, tolua_unit_set_building);
tolua_variable(L, TOLUA_CAST "ship", &tolua_unit_get_ship, tolua_unit_set_ship);
tolua_variable(L, TOLUA_CAST "region", &tolua_unit_get_region, tolua_unit_set_region);
tolua_variable(L, TOLUA_CAST "spells", &tolua_unit_get_spells, 0);
tolua_variable(L, TOLUA_CAST "number", &tolua_unit_get_number, tolua_unit_set_number);
tolua_variable(L, TOLUA_CAST "race", &tolua_unit_get_race, tolua_unit_set_race);
tolua_variable(L, TOLUA_CAST "hp_max", &tolua_unit_get_hpmax, 0);
tolua_variable(L, "objects", &tolua_unit_get_objects, 0);
tolua_variable(L, TOLUA_CAST "objects", &tolua_unit_get_objects, 0);
}
tolua_endmodule(L);
}

View file

@ -82,7 +82,7 @@ int tolua_spelllist_next(lua_State *L)
spell_list** spell_ptr = (spell_list **)lua_touserdata(L, lua_upvalueindex(1));
spell_list* slist = *spell_ptr;
if (slist != NULL) {
tolua_pushusertype(L, slist->data, "spell");
tolua_pushusertype(L, slist->data, TOLUA_CAST "spell");
*spell_ptr = slist->next;
return 1;
}
@ -174,8 +174,8 @@ tolua_message_unit(lua_State* L)
unit * sender = (unit *)tolua_tousertype(L, 1, 0);
unit * target = (unit *)tolua_tousertype(L, 2, 0);
const char * str = tolua_tostring(L, 3, 0);
if (!target) tolua_error(L, "target is nil", NULL);
if (!sender) tolua_error(L, "sender is nil", NULL);
if (!target) tolua_error(L, TOLUA_CAST "target is nil", NULL);
if (!sender) tolua_error(L, TOLUA_CAST "sender is nil", NULL);
deliverMail(target->faction, sender->region, sender, str, target);
return 0;
}
@ -186,8 +186,8 @@ tolua_message_faction(lua_State * L)
unit * sender = (unit *)tolua_tousertype(L, 1, 0);
faction * target = (faction *)tolua_tousertype(L, 2, 0);
const char * str = tolua_tostring(L, 3, 0);
if (!target) tolua_error(L, "target is nil", NULL);
if (!sender) tolua_error(L, "sender is nil", NULL);
if (!target) tolua_error(L, TOLUA_CAST "target is nil", NULL);
if (!sender) tolua_error(L, TOLUA_CAST "sender is nil", NULL);
deliverMail(target, sender->region, sender, str, NULL);
return 0;
@ -199,7 +199,7 @@ tolua_message_region(lua_State * L)
unit * sender = (unit *)tolua_tousertype(L, 1, 0);
const char * str = tolua_tostring(L, 2, 0);
if (!sender) tolua_error(L, "sender is nil", NULL);
if (!sender) tolua_error(L, TOLUA_CAST "sender is nil", NULL);
ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message", sender, str));
return 0;
@ -596,7 +596,7 @@ tolua_get_faction(lua_State* L)
int no = tolua_toid(L, 1, 0);
faction * f = findfaction(no);
tolua_pushusertype(L, f, "faction");
tolua_pushusertype(L, f, TOLUA_CAST "faction");
return 1;
}
@ -610,7 +610,7 @@ tolua_get_region(lua_State* L)
assert(!pnormalize(&x, &y, pl));
r = findregion(x, y);
tolua_pushusertype(L, r, "region");
tolua_pushusertype(L, r, TOLUA_CAST "region");
return 1;
}
@ -620,7 +620,7 @@ tolua_get_region_byid(lua_State* L)
int uid = (int)tolua_tonumber(L, 1, 0);
region * r = findregionbyid(uid);
tolua_pushusertype(L, r, "region");
tolua_pushusertype(L, r, TOLUA_CAST "region");
return 1;
}
@ -630,7 +630,7 @@ tolua_get_building(lua_State* L)
int no = tolua_toid(L, 1, 0);
building * b = findbuilding(no);
tolua_pushusertype(L, b, "building");
tolua_pushusertype(L, b, TOLUA_CAST "building");
return 1;
}
@ -640,7 +640,7 @@ tolua_get_ship(lua_State* L)
int no = tolua_toid(L, 1, 0);
ship * sh = findship(no);
tolua_pushusertype(L, sh, "ship");
tolua_pushusertype(L, sh, TOLUA_CAST "ship");
return 1;
}
@ -650,7 +650,7 @@ tolua_get_alliance(lua_State* L)
int no = tolua_toid(L, 1, 0);
alliance * f = findalliance(no);
tolua_pushusertype(L, f, "alliance");
tolua_pushusertype(L, f, TOLUA_CAST "alliance");
return 1;
}
@ -660,7 +660,7 @@ tolua_get_unit(lua_State* L)
int no = tolua_toid(L, 1, 0);
unit * u = findunit(no);
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}
@ -672,7 +672,7 @@ tolua_alliance_create(lua_State* L)
alliance * alli = makealliance(id, name);
tolua_pushusertype(L, alli, "alliance");
tolua_pushusertype(L, alli, TOLUA_CAST "alliance");
return 1;
}
@ -858,114 +858,114 @@ tolua_eressea_open(lua_State* L)
tolua_open(L);
/* register user types */
tolua_usertype(L, "spell");
tolua_usertype(L, "spell_list");
tolua_usertype(L, "order");
tolua_usertype(L, "item");
tolua_usertype(L, "alliance");
tolua_usertype(L, "event");
tolua_usertype(L, TOLUA_CAST "spell");
tolua_usertype(L, TOLUA_CAST "spell_list");
tolua_usertype(L, TOLUA_CAST "order");
tolua_usertype(L, TOLUA_CAST "item");
tolua_usertype(L, TOLUA_CAST "alliance");
tolua_usertype(L, TOLUA_CAST "event");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
tolua_cclass(L, "alliance", "alliance", "", NULL);
tolua_beginmodule(L, "alliance");
tolua_cclass(L, TOLUA_CAST "alliance", TOLUA_CAST "alliance", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "alliance");
{
tolua_variable(L, "name", tolua_get_alliance_name, tolua_set_alliance_name);
tolua_variable(L, "id", tolua_get_alliance_id, NULL);
tolua_variable(L, "factions", &tolua_get_alliance_factions, NULL);
tolua_function(L, "create", tolua_alliance_create);
tolua_variable(L, TOLUA_CAST "name", tolua_get_alliance_name, tolua_set_alliance_name);
tolua_variable(L, TOLUA_CAST "id", tolua_get_alliance_id, NULL);
tolua_variable(L, TOLUA_CAST "factions", &tolua_get_alliance_factions, NULL);
tolua_function(L, TOLUA_CAST "create", tolua_alliance_create);
}
tolua_endmodule(L);
tolua_cclass(L, "spell", "spell", "", NULL);
tolua_beginmodule(L, "spell");
tolua_cclass(L, TOLUA_CAST "spell", TOLUA_CAST "spell", TOLUA_CAST "", NULL);
tolua_beginmodule(L, TOLUA_CAST "spell");
{
tolua_function(L, "__tostring", tolua_get_spell_name);
tolua_variable(L, "name", tolua_get_spell_name, 0);
tolua_variable(L, "school", tolua_get_spell_school, 0);
tolua_variable(L, "level", tolua_get_spell_level, 0);
tolua_variable(L, "text", tolua_get_spell_text, 0);
tolua_function(L, TOLUA_CAST "__tostring", tolua_get_spell_name);
tolua_variable(L, TOLUA_CAST "name", tolua_get_spell_name, 0);
tolua_variable(L, TOLUA_CAST "school", tolua_get_spell_school, 0);
tolua_variable(L, TOLUA_CAST "level", tolua_get_spell_level, 0);
tolua_variable(L, TOLUA_CAST "text", tolua_get_spell_text, 0);
}
tolua_endmodule(L);
tolua_function(L, "get_region_by_id", tolua_get_region_byid);
tolua_function(L, TOLUA_CAST "get_region_by_id", tolua_get_region_byid);
tolua_function(L, "get_faction", tolua_get_faction);
tolua_function(L, "get_unit", tolua_get_unit);
tolua_function(L, "get_alliance", tolua_get_alliance);
tolua_function(L, "get_ship", tolua_get_ship),
tolua_function(L, "get_building", tolua_get_building),
tolua_function(L, "get_region", tolua_get_region),
tolua_function(L, TOLUA_CAST "get_faction", tolua_get_faction);
tolua_function(L, TOLUA_CAST "get_unit", tolua_get_unit);
tolua_function(L, TOLUA_CAST "get_alliance", tolua_get_alliance);
tolua_function(L, TOLUA_CAST "get_ship", tolua_get_ship),
tolua_function(L, TOLUA_CAST "get_building", tolua_get_building),
tolua_function(L, TOLUA_CAST "get_region", tolua_get_region),
// deprecated_function(L, "add_faction");
// deprecated_function(L, "faction_origin");
tolua_function(L, "factions", tolua_get_factions);
tolua_function(L, "regions", tolua_get_regions);
// deprecated_function(L, TOLUA_CAST "add_faction");
// deprecated_function(L, TOLUA_CAST "faction_origin");
tolua_function(L, TOLUA_CAST "factions", tolua_get_factions);
tolua_function(L, TOLUA_CAST "regions", tolua_get_regions);
tolua_function(L, "read_game", tolua_read_game);
tolua_function(L, "write_game", tolua_write_game);
tolua_function(L, "free_game", tolua_free_game);
tolua_function(L, "write_map", &tolua_write_map);
tolua_function(L, TOLUA_CAST "read_game", tolua_read_game);
tolua_function(L, TOLUA_CAST "write_game", tolua_write_game);
tolua_function(L, TOLUA_CAST "free_game", tolua_free_game);
tolua_function(L, TOLUA_CAST "write_map", &tolua_write_map);
tolua_function(L, "read_orders", tolua_read_orders);
tolua_function(L, "process_orders", tolua_process_orders);
tolua_function(L, TOLUA_CAST "read_orders", tolua_read_orders);
tolua_function(L, TOLUA_CAST "process_orders", tolua_process_orders);
tolua_function(L, "init_reports", tolua_init_reports);
tolua_function(L, "write_reports", tolua_write_reports);
tolua_function(L, "write_report", tolua_write_report);
tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports);
tolua_function(L, TOLUA_CAST "write_reports", tolua_write_reports);
tolua_function(L, TOLUA_CAST "write_report", tolua_write_report);
tolua_function(L, "init_summary", tolua_init_summary);
tolua_function(L, "write_summary", tolua_write_summary);
tolua_function(L, "write_passwords", tolua_write_passwords),
tolua_function(L, TOLUA_CAST "init_summary", tolua_init_summary);
tolua_function(L, TOLUA_CAST "write_summary", tolua_write_summary);
tolua_function(L, TOLUA_CAST "write_passwords", tolua_write_passwords),
tolua_function(L, "message_unit", tolua_message_unit);
tolua_function(L, "message_faction", tolua_message_faction);
tolua_function(L, "message_region", tolua_message_region);
tolua_function(L, TOLUA_CAST "message_unit", tolua_message_unit);
tolua_function(L, TOLUA_CAST "message_faction", tolua_message_faction);
tolua_function(L, TOLUA_CAST "message_region", tolua_message_region);
/* scripted monsters */
tolua_function(L, "plan_monsters", tolua_planmonsters);
tolua_function(L, "spawn_braineaters", tolua_spawn_braineaters);
tolua_function(L, "spawn_undead", tolua_spawn_undead);
tolua_function(L, "spawn_dragons", tolua_spawn_dragons);
tolua_function(L, TOLUA_CAST "plan_monsters", tolua_planmonsters);
tolua_function(L, TOLUA_CAST "spawn_braineaters", tolua_spawn_braineaters);
tolua_function(L, TOLUA_CAST "spawn_undead", tolua_spawn_undead);
tolua_function(L, TOLUA_CAST "spawn_dragons", tolua_spawn_dragons);
tolua_function(L, "set_race_brain", tolua_set_racescript);
tolua_function(L, "set_unit_brain", tolua_set_unitscript);
tolua_function(L, TOLUA_CAST "set_race_brain", tolua_set_racescript);
tolua_function(L, TOLUA_CAST "set_unit_brain", tolua_set_unitscript);
/* spells and stuff */
tolua_function(L, "levitate_ship", tolua_levitate_ship);
tolua_function(L, TOLUA_CAST "levitate_ship", tolua_levitate_ship);
tolua_function(L, "update_guards", tolua_update_guards);
tolua_function(L, TOLUA_CAST "update_guards", tolua_update_guards);
tolua_function(L, "get_turn", tolua_get_turn);
tolua_function(L, "get_season", tolua_get_season);
tolua_function(L, TOLUA_CAST "get_turn", tolua_get_turn);
tolua_function(L, TOLUA_CAST "get_season", tolua_get_season);
tolua_function(L, "equipment_setitem", tolua_equipment_setitem);
tolua_function(L, "equip_unit", tolua_equipunit);
tolua_function(L, "add_equipment", tolua_addequipment);
tolua_function(L, TOLUA_CAST "equipment_setitem", tolua_equipment_setitem);
tolua_function(L, TOLUA_CAST "equip_unit", tolua_equipunit);
tolua_function(L, TOLUA_CAST "add_equipment", tolua_addequipment);
tolua_function(L, "atoi36", tolua_atoi36);
tolua_function(L, "itoa36", tolua_itoa36);
tolua_function(L, "dice_roll", tolua_dice_rand);
tolua_function(L, TOLUA_CAST "atoi36", tolua_atoi36);
tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36);
tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand);
tolua_function(L, "get_nmrs", tolua_get_nmrs);
tolua_function(L, "remove_empty_units", tolua_remove_empty_units);
tolua_function(L, TOLUA_CAST "get_nmrs", tolua_get_nmrs);
tolua_function(L, TOLUA_CAST "remove_empty_units", tolua_remove_empty_units);
tolua_function(L, "update_subscriptions", tolua_update_subscriptions);
tolua_function(L, "update_scores", tolua_update_scores);
tolua_function(L, "update_owners", tolua_update_owners);
tolua_function(L, TOLUA_CAST "update_subscriptions", tolua_update_subscriptions);
tolua_function(L, TOLUA_CAST "update_scores", tolua_update_scores);
tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners);
tolua_function(L, "learn_skill", tolua_learn_skill);
tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill);
tolua_function(L, "autoseed", tolua_autoseed);
tolua_function(L, TOLUA_CAST "autoseed", tolua_autoseed);
tolua_function(L, "get_key", tolua_getkey);
tolua_function(L, "set_key", tolua_setkey);
tolua_function(L, TOLUA_CAST "get_key", tolua_getkey);
tolua_function(L, TOLUA_CAST "set_key", tolua_setkey);
tolua_function(L, "rng_int", tolua_rng_int);
tolua_function(L, TOLUA_CAST "rng_int", tolua_rng_int);
tolua_function(L, "spells", tolua_get_spells);
tolua_function(L, "write_spells", tolua_write_spells);
tolua_function(L, TOLUA_CAST "spells", tolua_get_spells);
tolua_function(L, TOLUA_CAST "write_spells", tolua_write_spells);
}
tolua_endmodule(L);
return 1;

View file

@ -48,8 +48,8 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, s, "unit");
tolua_pushusertype(L, d, "unit");
tolua_pushusertype(L, s, TOLUA_CAST "unit");
tolua_pushusertype(L, d, TOLUA_CAST "unit");
tolua_pushstring(L, iname);
tolua_pushnumber(L, (lua_Number)n);
@ -83,7 +83,7 @@ limit_resource(const region * r, const resource_type * rtype)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)r, "region");
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -113,7 +113,7 @@ produce_resource(region * r, const resource_type * rtype, int norders)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)r, "region");
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
tolua_pushnumber(L, (lua_Number)norders);
if (lua_pcall(L, 2, 0, 0)!=0) {
@ -146,7 +146,7 @@ lc_age(struct attrib * a)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)b, "building");
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
if (fparam) {
tolua_pushstring(L, fparam);
}
@ -192,8 +192,8 @@ lua_callspell(castorder *co)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, co->rt, "region");
tolua_pushusertype(L, mage, "unit");
tolua_pushusertype(L, co->rt, TOLUA_CAST "region");
tolua_pushusertype(L, mage, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)co->level);
tolua_pushnumber(L, (lua_Number)co->force);
@ -227,7 +227,7 @@ lua_initfamiliar(unit * u)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -261,7 +261,7 @@ lua_changeresource(unit * u, const struct resource_type * rtype, int delta)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)delta);
if (lua_pcall(L, 2, 1, 0)!=0) {
@ -293,7 +293,7 @@ lua_getresource(unit * u, const struct resource_type * rtype)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, u, "unit");
tolua_pushusertype(L, u, TOLUA_CAST "unit");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -326,7 +326,7 @@ lua_canuse_item(const unit * u, const struct item_type * itype)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
tolua_pushstring(L, itype->rtype->_name[0]);
if (lua_pcall(L, 2, 1, 0)!=0) {
@ -358,8 +358,8 @@ lua_wage(const region * r, const faction * f, const race * rc)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)r, "region");
tolua_pushusertype(L, (void *)f, "faction");
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
tolua_pushstring(L, rc?rc->_name[0]:0);
if (lua_pcall(L, 3, 1, 0)!=0) {
@ -391,7 +391,7 @@ lua_agebuilding(building * b)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)b, "building");
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
if (lua_pcall(L, 1, 0, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -416,8 +416,8 @@ lua_building_protection(building * b, unit * u)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)b, "building");
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
if (lua_pcall(L, 2, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -448,7 +448,7 @@ lua_building_taxes(building * b)
lua_rawget(L, LUA_GLOBALSINDEX);
type=lua_type(L, 1);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)b, "building");
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -477,7 +477,7 @@ lua_maintenance(const unit * u)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -508,7 +508,7 @@ lua_equipmentcallback(const struct equipment * eq, unit * u)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
if (lua_pcall(L, 1, 1, 0)!=0) {
const char* error = lua_tostring(L, -1);
@ -538,7 +538,7 @@ lua_useitem(struct unit * u, const struct item_type * itype, int amount, struct
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)amount);
if (lua_pcall(L, 2, 1, 0)!=0) {
@ -570,7 +570,7 @@ lua_recruit(struct unit * u, const struct archetype * arch, int amount)
lua_pushstring(L, fname);
lua_rawget(L, LUA_GLOBALSINDEX);
if (lua_isfunction(L, 1)) {
tolua_pushusertype(L, (void *)u, "unit");
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)amount);
if (lua_pcall(L, 2, 1, 0)!=0) {
@ -609,23 +609,23 @@ register_tolua_helpers(void)
{
at_building_action.age = lc_age;
register_function((pf_generic)&lua_building_protection, "lua_building_protection");
register_function((pf_generic)&lua_building_taxes, "lua_building_taxes");
register_function((pf_generic)&lua_agebuilding, "lua_agebuilding");
register_function((pf_generic)&lua_recruit, "lua_recruit");
register_function((pf_generic)&lua_callspell, "lua_castspell");
register_function((pf_generic)&lua_initfamiliar, "lua_initfamiliar");
register_item_use(&lua_useitem, "lua_useitem");
register_function((pf_generic)&lua_getresource, "lua_getresource");
register_function((pf_generic)&lua_canuse_item, "lua_canuse_item");
register_function((pf_generic)&lua_changeresource, "lua_changeresource");
register_function((pf_generic)&lua_equipmentcallback, "lua_equip");
register_function((pf_generic)&lua_building_protection, TOLUA_CAST "lua_building_protection");
register_function((pf_generic)&lua_building_taxes, TOLUA_CAST "lua_building_taxes");
register_function((pf_generic)&lua_agebuilding, TOLUA_CAST "lua_agebuilding");
register_function((pf_generic)&lua_recruit, TOLUA_CAST "lua_recruit");
register_function((pf_generic)&lua_callspell, TOLUA_CAST "lua_castspell");
register_function((pf_generic)&lua_initfamiliar, TOLUA_CAST "lua_initfamiliar");
register_item_use(&lua_useitem, TOLUA_CAST "lua_useitem");
register_function((pf_generic)&lua_getresource, TOLUA_CAST "lua_getresource");
register_function((pf_generic)&lua_canuse_item, TOLUA_CAST "lua_canuse_item");
register_function((pf_generic)&lua_changeresource, TOLUA_CAST "lua_changeresource");
register_function((pf_generic)&lua_equipmentcallback, TOLUA_CAST "lua_equip");
register_function((pf_generic)&lua_wage, "lua_wage");
register_function((pf_generic)&lua_maintenance, "lua_maintenance");
register_function((pf_generic)&lua_wage, TOLUA_CAST "lua_wage");
register_function((pf_generic)&lua_maintenance, TOLUA_CAST "lua_maintenance");
register_function((pf_generic)produce_resource, "lua_produceresource");
register_function((pf_generic)limit_resource, "lua_limitresource");
register_item_give(lua_giveitem, "lua_giveitem");
register_function((pf_generic)produce_resource, TOLUA_CAST "lua_produceresource");
register_function((pf_generic)limit_resource, TOLUA_CAST "lua_limitresource");
register_item_give(lua_giveitem, TOLUA_CAST "lua_giveitem");
}