diff --git a/src/eressea/tolua/bind_building.c b/src/eressea/tolua/bind_building.c index 2afffa2c4..3926fe905 100644 --- a/src/eressea/tolua/bind_building.c +++ b/src/eressea/tolua/bind_building.c @@ -21,12 +21,12 @@ without prior permission by the authors of Eressea. #include #include -int tolua_buildinglist_next(lua_State *tolua_S) +int tolua_buildinglist_next(lua_State *L) { - building** building_ptr = (building **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + building** building_ptr = (building **)lua_touserdata(L, lua_upvalueindex(1)); building * u = *building_ptr; if (u != NULL) { - tolua_pushusertype(tolua_S, (void*)u, "building"); + tolua_pushusertype(L, (void*)u, "building"); *building_ptr = u->next; return 1; } @@ -35,11 +35,11 @@ int tolua_buildinglist_next(lua_State *tolua_S) static int -tolua_building_addaction(lua_State* tolua_S) +tolua_building_addaction(lua_State* L) { - building* self = (building*)tolua_tousertype(tolua_S, 1, 0); - const char * fname = tolua_tostring(tolua_S, 2, 0); - const char * param = tolua_tostring(tolua_S, 3, 0); + building* self = (building*)tolua_tousertype(L, 1, 0); + const char * fname = tolua_tostring(L, 2, 0); + const char * param = tolua_tostring(L, 3, 0); building_addaction(self, fname, param); @@ -47,133 +47,133 @@ tolua_building_addaction(lua_State* tolua_S) } static int -tolua_building_get_objects(lua_State* tolua_S) +tolua_building_get_objects(lua_State* L) { - building * self = (building *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)&self->attribs, "hashtable"); + building * self = (building *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)&self->attribs, "hashtable"); return 1; } -static int tolua_building_get_region(lua_State* tolua_S) +static int tolua_building_get_region(lua_State* L) { - building* self = (building*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, building_getregion(self), "region"); + building* self = (building*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, building_getregion(self), "region"); return 1; } -static int tolua_building_set_region(lua_State* tolua_S) +static int tolua_building_set_region(lua_State* L) { - building* self = (building*)tolua_tousertype(tolua_S, 1, 0); - building_setregion(self, (region*)tolua_tousertype(tolua_S, 2, 0)); + building* self = (building*)tolua_tousertype(L, 1, 0); + building_setregion(self, (region*)tolua_tousertype(L, 2, 0)); return 0; } -static int tolua_building_get_name(lua_State* tolua_S) +static int tolua_building_get_name(lua_State* L) { - building* self = (building*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, building_getname(self)); + building* self = (building*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, building_getname(self)); return 1; } -static int tolua_building_set_name(lua_State* tolua_S) +static int tolua_building_set_name(lua_State* L) { - building* self = (building*)tolua_tousertype(tolua_S, 1, 0); - building_setname(self, tolua_tostring(tolua_S, 2, 0)); + building* self = (building*)tolua_tousertype(L, 1, 0); + building_setname(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_building_get_size(lua_State* tolua_S) +static int tolua_building_get_size(lua_State* L) { - building* self = (building*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, self->size); + building* self = (building*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, self->size); return 1; } -static int tolua_building_set_size(lua_State* tolua_S) +static int tolua_building_set_size(lua_State* L) { - building* self = (building*)tolua_tousertype(tolua_S, 1, 0); - self->size = (int)tolua_tonumber(tolua_S, 2, 0); + building* self = (building*)tolua_tousertype(L, 1, 0); + self->size = (int)tolua_tonumber(L, 2, 0); return 0; } static int -tolua_building_get_units(lua_State* tolua_S) +tolua_building_get_units(lua_State* L) { - building * self = (building *)tolua_tousertype(tolua_S, 1, 0); - unit ** unit_ptr = (unit**)lua_newuserdata(tolua_S, sizeof(unit *)); + building * self = (building *)tolua_tousertype(L, 1, 0); + unit ** unit_ptr = (unit**)lua_newuserdata(L, sizeof(unit *)); unit * u = self->region->units; while (u && u->building!=self) u = u->next; - luaL_getmetatable(tolua_S, "unit"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "unit"); + lua_setmetatable(L, -2); *unit_ptr = u; - lua_pushcclosure(tolua_S, tolua_unitlist_nextb, 1); + lua_pushcclosure(L, tolua_unitlist_nextb, 1); return 1; } static int -tolua_building_get_id(lua_State* tolua_S) +tolua_building_get_id(lua_State* L) { - building * self = (building *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->no); + building * self = (building *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->no); return 1; } static int -tolua_building_create(lua_State* tolua_S) +tolua_building_create(lua_State* L) { - region * r = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * bname = tolua_tostring(tolua_S, 2, 0); + region * r = (region *)tolua_tousertype(L, 1, 0); + const char * bname = tolua_tostring(L, 2, 0); if (bname) { const building_type * btype = bt_find(bname); building * b = new_building(btype, r, NULL); - tolua_pushusertype(tolua_S, (void*)b, "building"); + tolua_pushusertype(L, (void*)b, "building"); return 1; } return 0; } static int -tolua_building_tostring(lua_State *tolua_S) +tolua_building_tostring(lua_State *L) { - building * self = (building *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, buildingname(self)); + building * self = (building *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, buildingname(self)); return 1; } void -tolua_building_open(lua_State* tolua_S) +tolua_building_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "building"); - tolua_usertype(tolua_S, "building_list"); + tolua_usertype(L, "building"); + tolua_usertype(L, "building_list"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "building", "building", "", NULL); - tolua_beginmodule(tolua_S, "building"); + tolua_cclass(L, "building", "building", "", NULL); + tolua_beginmodule(L, "building"); { - tolua_function(tolua_S, "__tostring", tolua_building_tostring); + tolua_function(L, "__tostring", tolua_building_tostring); - tolua_variable(tolua_S, "id", tolua_building_get_id, NULL); - tolua_variable(tolua_S, "name", tolua_building_get_name, tolua_building_set_name); - tolua_variable(tolua_S, "units", tolua_building_get_units, NULL); - tolua_variable(tolua_S, "region", tolua_building_get_region, tolua_building_set_region); - tolua_variable(tolua_S, "size", tolua_building_get_size, tolua_building_set_size); - tolua_function(tolua_S, "add_action", tolua_building_addaction); + tolua_variable(L, "id", tolua_building_get_id, 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); #ifdef TODO .property("type", &building_gettype) .def_readwrite("size", &building::size) #endif - tolua_variable(tolua_S, "objects", tolua_building_get_objects, 0); + tolua_variable(L, "objects", tolua_building_get_objects, 0); - tolua_function(tolua_S, "create", tolua_building_create); + tolua_function(L, "create", tolua_building_create); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_building.h b/src/eressea/tolua/bind_building.h index 58e20d2a1..a6168b66c 100644 --- a/src/eressea/tolua/bind_building.h +++ b/src/eressea/tolua/bind_building.h @@ -15,8 +15,8 @@ extern "C" { #endif struct lua_State; - int tolua_buildinglist_next(struct lua_State *tolua_S); - void tolua_building_open(struct lua_State *tolua_S); + int tolua_buildinglist_next(struct lua_State *L); + void tolua_building_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_faction.c b/src/eressea/tolua/bind_faction.c index ad5c581e2..87af21945 100644 --- a/src/eressea/tolua/bind_faction.c +++ b/src/eressea/tolua/bind_faction.c @@ -28,49 +28,49 @@ without prior permission by the authors of Eressea. #include -int tolua_factionlist_next(lua_State *tolua_S) +int tolua_factionlist_next(lua_State *L) { - faction** faction_ptr = (faction **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + faction** faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1)); faction * f = *faction_ptr; if (f != NULL) { - tolua_pushusertype(tolua_S, (void*)f, "faction"); + tolua_pushusertype(L, (void*)f, "faction"); *faction_ptr = f->next; return 1; } else return 0; /* no more values to return */ } -int tolua_factionlist_iter(lua_State *tolua_S) +int tolua_factionlist_iter(lua_State *L) { - faction_list** faction_ptr = (faction_list **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + faction_list** faction_ptr = (faction_list **)lua_touserdata(L, lua_upvalueindex(1)); faction_list* flist = *faction_ptr; if (flist != NULL) { - tolua_pushusertype(tolua_S, (void*)flist->data, "faction"); + tolua_pushusertype(L, (void*)flist->data, "faction"); *faction_ptr = flist->next; return 1; } else return 0; /* no more values to return */ } -static int tolua_faction_get_units(lua_State* tolua_S) +static int tolua_faction_get_units(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - unit ** unit_ptr = (unit**)lua_newuserdata(tolua_S, sizeof(unit *)); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + unit ** unit_ptr = (unit**)lua_newuserdata(L, sizeof(unit *)); - luaL_getmetatable(tolua_S, "unit"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "unit"); + lua_setmetatable(L, -2); *unit_ptr = self->units; - lua_pushcclosure(tolua_S, tolua_unitlist_nextf, 1); + lua_pushcclosure(L, tolua_unitlist_nextf, 1); return 1; } -int tolua_faction_add_item(lua_State *tolua_S) +int tolua_faction_add_item(lua_State *L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - const char * iname = tolua_tostring(tolua_S, 2, 0); - int number = (int)tolua_tonumber(tolua_S, 3, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); + int number = (int)tolua_tonumber(L, 3, 0); int result = -1; if (iname!=NULL) { @@ -80,121 +80,121 @@ int tolua_faction_add_item(lua_State *tolua_S) result = i?i->number:0; } // if (itype!=NULL) } - lua_pushnumber(tolua_S, result); + lua_pushnumber(L, result); return 1; } static int -tolua_faction_get_maxheroes(lua_State* tolua_S) +tolua_faction_get_maxheroes(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)maxheroes(self)); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)maxheroes(self)); return 1; } static int -tolua_faction_get_heroes(lua_State* tolua_S) +tolua_faction_get_heroes(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)countheroes(self)); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)countheroes(self)); return 1; } static int -tolua_faction_get_score(lua_State* tolua_S) +tolua_faction_get_score(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->score); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->score); return 1; } static int -tolua_faction_get_id(lua_State* tolua_S) +tolua_faction_get_id(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->no); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->no); return 1; } static int -tolua_faction_set_id(lua_State* tolua_S) +tolua_faction_set_id(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - int id = (int)tolua_tonumber(tolua_S, 2, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + int id = (int)tolua_tonumber(L, 2, 0); if (findfaction(id)==NULL) { renumber_faction(self, id); - lua_pushboolean(tolua_S, 1); + lua_pushboolean(L, 1); } else { - lua_pushboolean(tolua_S, 0); + lua_pushboolean(L, 0); } return 1; } static int -tolua_faction_get_age(lua_State* tolua_S) +tolua_faction_get_age(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->age); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->age); return 1; } static int -tolua_faction_set_age(lua_State* tolua_S) +tolua_faction_set_age(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - int age = (int)tolua_tonumber(tolua_S, 2, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + int age = (int)tolua_tonumber(L, 2, 0); self->age = age; return 0; } static int -tolua_faction_get_flags(lua_State* tolua_S) +tolua_faction_get_flags(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->flags); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->flags); return 1; } static int -tolua_faction_get_options(lua_State* tolua_S) +tolua_faction_get_options(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->options); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->options); return 1; } static int -tolua_faction_get_lastturn(lua_State* tolua_S) +tolua_faction_get_lastturn(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->lastorders); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->lastorders); return 1; } static int -tolua_faction_renumber(lua_State* tolua_S) +tolua_faction_renumber(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - int no = (int)tolua_tonumber(tolua_S, 2, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + int no = (int)tolua_tonumber(L, 2, 0); renumber_faction(self, no); return 0; } static int -tolua_faction_get_objects(lua_State* tolua_S) +tolua_faction_get_objects(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)&self->attribs, "hashtable"); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)&self->attribs, "hashtable"); return 1; } static int -tolua_faction_get_policy(lua_State* tolua_S) +tolua_faction_get_policy(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - faction * other = (faction *)tolua_tousertype(tolua_S, 2, 0); - const char * policy = tolua_tostring(tolua_S, 3, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + faction * other = (faction *)tolua_tousertype(L, 2, 0); + const char * policy = tolua_tostring(L, 3, 0); int result = 0, mode; for (mode=0;helpmodes[mode].name!=NULL;++mode) { @@ -204,18 +204,18 @@ tolua_faction_get_policy(lua_State* tolua_S) } } - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_faction_set_policy(lua_State* tolua_S) +tolua_faction_set_policy(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - faction * other = (faction *)tolua_tousertype(tolua_S, 2, 0); - const char * policy = tolua_tostring(tolua_S, 3, 0); - int value = tolua_toboolean(tolua_S, 4, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + faction * other = (faction *)tolua_tousertype(L, 2, 0); + const char * policy = tolua_tostring(L, 3, 0); + int value = tolua_toboolean(L, 4, 0); int mode; for (mode=0;helpmodes[mode].name!=NULL;++mode) { @@ -233,9 +233,9 @@ tolua_faction_set_policy(lua_State* tolua_S) } static int -tolua_faction_get_origin(lua_State* tolua_S) +tolua_faction_get_origin(lua_State* L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); + faction * self = (faction *)tolua_tousertype(L, 1, 0); ursprung * origin = self->ursprung; int x, y; @@ -250,17 +250,17 @@ tolua_faction_get_origin(lua_State* tolua_S) y = 0; } - tolua_pushnumber(tolua_S, (lua_Number)x); - tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(L, (lua_Number)x); + tolua_pushnumber(L, (lua_Number)y); return 2; } static int -tolua_faction_create(lua_State* tolua_S) +tolua_faction_create(lua_State* L) { - const char * email = tolua_tostring(tolua_S, 1, 0); - const char * racename = tolua_tostring(tolua_S, 2, 0); - const char * lang = tolua_tostring(tolua_S, 3, 0); + const char * email = tolua_tostring(L, 1, 0); + const char * racename = tolua_tostring(L, 2, 0); + const char * lang = tolua_tostring(L, 3, 0); struct locale * loc = find_locale(lang); faction * f = NULL; const struct race * frace = findrace(racename, default_locale); @@ -269,64 +269,64 @@ tolua_faction_create(lua_State* tolua_S) if (frace!=NULL) { f = addfaction(email, NULL, frace, loc, 0); } - tolua_pushusertype(tolua_S, f, "faction"); + tolua_pushusertype(L, f, "faction"); return 1; } -static int tolua_faction_get_password(lua_State* tolua_S) +static int tolua_faction_get_password(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, faction_getpassword(self)); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, faction_getpassword(self)); return 1; } -static int tolua_faction_set_password(lua_State* tolua_S) +static int tolua_faction_set_password(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - faction_setpassword(self, tolua_tostring(tolua_S, 2, 0)); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + faction_setpassword(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_faction_get_email(lua_State* tolua_S) +static int tolua_faction_get_email(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, faction_getemail(self)); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, faction_getemail(self)); return 1; } -static int tolua_faction_set_email(lua_State* tolua_S) +static int tolua_faction_set_email(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - faction_setemail(self, tolua_tostring(tolua_S, 2, 0)); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + faction_setemail(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_faction_get_locale(lua_State* tolua_S) +static int tolua_faction_get_locale(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, locale_name(self->locale)); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, locale_name(self->locale)); return 1; } -static int tolua_faction_set_locale(lua_State* tolua_S) +static int tolua_faction_set_locale(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); self->locale = find_locale(name); return 0; } -static int tolua_faction_get_race(lua_State* tolua_S) +static int tolua_faction_get_race(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, self->race->_name[0]); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, self->race->_name[0]); return 1; } -static int tolua_faction_set_race(lua_State* tolua_S) +static int tolua_faction_set_race(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); race * rc = rc_find(name); if (rc!=NULL) { self->race = rc; @@ -335,45 +335,45 @@ static int tolua_faction_set_race(lua_State* tolua_S) return 0; } -static int tolua_faction_get_name(lua_State* tolua_S) +static int tolua_faction_get_name(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, faction_getname(self)); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, faction_getname(self)); return 1; } -static int tolua_faction_set_name(lua_State* tolua_S) +static int tolua_faction_set_name(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - faction_setname(self, tolua_tostring(tolua_S, 2, 0)); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + faction_setname(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_faction_get_info(lua_State* tolua_S) +static int tolua_faction_get_info(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, faction_getbanner(self)); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, faction_getbanner(self)); return 1; } -static int tolua_faction_set_info(lua_State* tolua_S) +static int tolua_faction_set_info(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - faction_setbanner(self, tolua_tostring(tolua_S, 2, 0)); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + faction_setbanner(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_faction_get_alliance(lua_State* tolua_S) +static int tolua_faction_get_alliance(lua_State* L) { - faction* self = (faction*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, self->alliance, "alliance"); + faction* self = (faction*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, self->alliance, "alliance"); return 1; } -static int tolua_faction_set_alliance(lua_State* tolua_S) +static int tolua_faction_set_alliance(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - alliance* alli = (alliance*)tolua_tousertype(tolua_S, 2, 0); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + alliance* alli = (alliance*)tolua_tousertype(L, 2, 0); if (!self->alliance) { setalliance(self, alli); @@ -382,89 +382,89 @@ static int tolua_faction_set_alliance(lua_State* tolua_S) return 0; } -static int tolua_faction_get_items(lua_State* tolua_S) +static int tolua_faction_get_items(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); - item ** item_ptr = (item **)lua_newuserdata(tolua_S, sizeof(item *)); + faction* self = (faction*)tolua_tousertype(L, 1, 0); + item ** item_ptr = (item **)lua_newuserdata(L, sizeof(item *)); - luaL_getmetatable(tolua_S, "item"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "item"); + lua_setmetatable(L, -2); *item_ptr = self->items; - lua_pushcclosure(tolua_S, tolua_itemlist_next, 1); + lua_pushcclosure(L, tolua_itemlist_next, 1); return 1; } static int -tolua_faction_tostring(lua_State *tolua_S) +tolua_faction_tostring(lua_State *L) { - faction * self = (faction *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, factionname(self)); + faction * self = (faction *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, factionname(self)); return 1; } -static int tolua_faction_get_spells(lua_State* tolua_S) +static int tolua_faction_get_spells(lua_State* L) { - faction* self = (faction*)tolua_tousertype(tolua_S, 1, 0); + faction* self = (faction*)tolua_tousertype(L, 1, 0); spell_list * slist = self->spellbook; if (slist) { - spell_list ** spell_ptr = (spell_list **)lua_newuserdata(tolua_S, sizeof(spell_list *)); - luaL_getmetatable(tolua_S, "spell_list"); - lua_setmetatable(tolua_S, -2); + spell_list ** spell_ptr = (spell_list **)lua_newuserdata(L, sizeof(spell_list *)); + luaL_getmetatable(L, "spell_list"); + lua_setmetatable(L, -2); *spell_ptr = slist; - lua_pushcclosure(tolua_S, tolua_spelllist_next, 1); + lua_pushcclosure(L, tolua_spelllist_next, 1); return 1; } - lua_pushnil(tolua_S); + lua_pushnil(L); return 1; } void -tolua_faction_open(lua_State* tolua_S) +tolua_faction_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "faction"); - tolua_usertype(tolua_S, "faction_list"); + tolua_usertype(L, "faction"); + tolua_usertype(L, "faction_list"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "faction", "faction", "", NULL); - tolua_beginmodule(tolua_S, "faction"); + tolua_cclass(L, "faction", "faction", "", NULL); + tolua_beginmodule(L, "faction"); { - tolua_function(tolua_S, "__tostring", tolua_faction_tostring); + tolua_function(L, "__tostring", tolua_faction_tostring); - tolua_variable(tolua_S, "name", tolua_faction_get_name, tolua_faction_set_name); - tolua_variable(tolua_S, "info", tolua_faction_get_info, tolua_faction_set_info); - tolua_variable(tolua_S, "units", tolua_faction_get_units, NULL); - tolua_variable(tolua_S, "heroes", tolua_faction_get_heroes, NULL); - tolua_variable(tolua_S, "spells", tolua_faction_get_spells, 0); - tolua_variable(tolua_S, "maxheroes", tolua_faction_get_maxheroes, NULL); - tolua_variable(tolua_S, "password", tolua_faction_get_password, tolua_faction_set_password); - tolua_variable(tolua_S, "email", tolua_faction_get_email, tolua_faction_set_email); - tolua_variable(tolua_S, "locale", tolua_faction_get_locale, tolua_faction_set_locale); - tolua_variable(tolua_S, "race", tolua_faction_get_race, tolua_faction_set_race); - tolua_variable(tolua_S, "alliance", tolua_faction_get_alliance, tolua_faction_set_alliance); - tolua_variable(tolua_S, "score", tolua_faction_get_score, NULL); - tolua_variable(tolua_S, "id", tolua_faction_get_id, tolua_faction_set_id); - tolua_variable(tolua_S, "age", tolua_faction_get_age, tolua_faction_set_age); - tolua_variable(tolua_S, "options", tolua_faction_get_options, NULL); - tolua_variable(tolua_S, "flags", tolua_faction_get_flags, NULL); - tolua_variable(tolua_S, "lastturn", tolua_faction_get_lastturn, NULL); + 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, NULL); + tolua_variable(L, "flags", tolua_faction_get_flags, NULL); + tolua_variable(L, "lastturn", tolua_faction_get_lastturn, NULL); - tolua_function(tolua_S, "set_policy", tolua_faction_set_policy); - tolua_function(tolua_S, "get_policy", tolua_faction_get_policy); - tolua_function(tolua_S, "get_origin", tolua_faction_get_origin); + 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(tolua_S, "add_item", tolua_faction_add_item); - tolua_variable(tolua_S, "items", tolua_faction_get_items, NULL); + tolua_function(L, "add_item", tolua_faction_add_item); + tolua_variable(L, "items", tolua_faction_get_items, NULL); - tolua_function(tolua_S, "renumber", tolua_faction_renumber); - tolua_function(tolua_S, "create", tolua_faction_create); + tolua_function(L, "renumber", tolua_faction_renumber); + tolua_function(L, "create", tolua_faction_create); #ifdef TODO def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)), @@ -475,9 +475,9 @@ tolua_faction_open(lua_State* tolua_S) .def("add_notice", &faction_addnotice) #endif - tolua_variable(tolua_S, "objects", tolua_faction_get_objects, NULL); + tolua_variable(L, "objects", tolua_faction_get_objects, NULL); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_faction.h b/src/eressea/tolua/bind_faction.h index d504f0281..c89750062 100644 --- a/src/eressea/tolua/bind_faction.h +++ b/src/eressea/tolua/bind_faction.h @@ -15,9 +15,9 @@ extern "C" { #endif struct lua_State; - int tolua_factionlist_next(struct lua_State *tolua_S); - int tolua_factionlist_iter(struct lua_State *tolua_S); - void tolua_faction_open(struct lua_State *tolua_S); + int tolua_factionlist_next(struct lua_State *L); + int tolua_factionlist_iter(struct lua_State *L); + void tolua_faction_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_gmtool.c b/src/eressea/tolua/bind_gmtool.c index fac6eccf7..941ea6453 100644 --- a/src/eressea/tolua/bind_gmtool.c +++ b/src/eressea/tolua/bind_gmtool.c @@ -10,36 +10,36 @@ #include static int -tolua_run_mapper(lua_State* tolua_S) +tolua_run_mapper(lua_State* L) { run_mapper(); return 0; } static int -tolua_highlight_region(lua_State* tolua_S) +tolua_highlight_region(lua_State* L) { - region * r = tolua_tousertype(tolua_S, 1, 0); - int select = tolua_toboolean(tolua_S, 2, 0); + region * r = tolua_tousertype(L, 1, 0); + int select = tolua_toboolean(L, 2, 0); highlight_region(r, select); return 0; } static int -tolua_current_region(lua_State* tolua_S) +tolua_current_region(lua_State* L) { map_region * mr = cursor_region(¤t_state->display, ¤t_state->cursor); - tolua_pushusertype(tolua_S, mr?mr->r:NULL, "region"); + tolua_pushusertype(L, mr?mr->r:NULL, "region"); return 1; } static int -tolua_select_coordinate(lua_State* tolua_S) +tolua_select_coordinate(lua_State* L) { - int x = (int)tolua_tonumber(tolua_S, 1, 0); - int y = (int)tolua_tonumber(tolua_S, 2, 0); - int select = tolua_toboolean(tolua_S, 3, 0); + int x = (int)tolua_tonumber(L, 1, 0); + int y = (int)tolua_tonumber(L, 2, 0); + int select = tolua_toboolean(L, 3, 0); if (current_state) { select_coordinate(current_state->selected, x, y, select); } @@ -47,10 +47,10 @@ tolua_select_coordinate(lua_State* tolua_S) } static int -tolua_select_region(lua_State* tolua_S) +tolua_select_region(lua_State* L) { - region * r = tolua_tousertype(tolua_S, 1, 0); - int select = tolua_toboolean(tolua_S, 2, 0); + region * r = tolua_tousertype(L, 1, 0); + int select = tolua_toboolean(L, 2, 0); if (current_state) { select_coordinate(current_state->selected, r->x, r->y, select); } @@ -105,11 +105,11 @@ tag_rewind(tag_iterator * iter) } static int -tolua_tags_next(lua_State *tolua_S) +tolua_tags_next(lua_State *L) { - tag_iterator * iter = (tag_iterator *)lua_touserdata(tolua_S, lua_upvalueindex(1)); + tag_iterator * iter = (tag_iterator *)lua_touserdata(L, lua_upvalueindex(1)); if (iter->node) { - tolua_pushusertype(tolua_S, (void*)iter->r, "region"); + tolua_pushusertype(L, (void*)iter->r, "region"); tag_advance(iter); return 1; } @@ -119,59 +119,59 @@ tolua_tags_next(lua_State *tolua_S) } static int -tolua_selected_regions(lua_State* tolua_S) +tolua_selected_regions(lua_State* L) { - tag_iterator * iter = (tag_iterator*)lua_newuserdata(tolua_S, sizeof(tag_iterator)); + tag_iterator * iter = (tag_iterator*)lua_newuserdata(L, sizeof(tag_iterator)); - luaL_getmetatable(tolua_S, "tag_iterator"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "tag_iterator"); + lua_setmetatable(L, -2); iter->list = current_state->selected; tag_rewind(iter); - lua_pushcclosure(tolua_S, tolua_tags_next, 1); + lua_pushcclosure(L, tolua_tags_next, 1); return 1; } static int -tolua_state_open(lua_State* tolua_S) +tolua_state_open(lua_State* L) { - unused(tolua_S); + unused(L); state_open(); return 0; } static int -tolua_state_close(lua_State* tolua_S) +tolua_state_close(lua_State* L) { - unused(tolua_S); + unused(L); state_close(current_state); return 0; } void -tolua_gmtool_open(lua_State* tolua_S) +tolua_gmtool_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "tag_iterator"); + tolua_usertype(L, "tag_iterator"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_module(tolua_S, "gmtool", 0); - tolua_beginmodule(tolua_S, "gmtool"); + tolua_module(L, "gmtool", 0); + tolua_beginmodule(L, "gmtool"); { - tolua_function(tolua_S, "open", tolua_state_open); - tolua_function(tolua_S, "close", tolua_state_close); + tolua_function(L, "open", tolua_state_open); + tolua_function(L, "close", tolua_state_close); - tolua_function(tolua_S, "editor", tolua_run_mapper); - tolua_function(tolua_S, "get_selection", tolua_selected_regions); - tolua_function(tolua_S, "get_cursor", tolua_current_region); - tolua_function(tolua_S, "highlight", tolua_highlight_region); - tolua_function(tolua_S, "select", tolua_select_region); - tolua_function(tolua_S, "select_at", tolua_select_coordinate); + 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_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_gmtool.h b/src/eressea/tolua/bind_gmtool.h index fcde8059b..415fe3d58 100644 --- a/src/eressea/tolua/bind_gmtool.h +++ b/src/eressea/tolua/bind_gmtool.h @@ -3,7 +3,7 @@ extern "C" { #endif struct lua_State; - void tolua_gmtool_open(struct lua_State *tolua_S); + void tolua_gmtool_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_hashtable.c b/src/eressea/tolua/bind_hashtable.c index f9dbed01e..b6568f4ce 100644 --- a/src/eressea/tolua/bind_hashtable.c +++ b/src/eressea/tolua/bind_hashtable.c @@ -29,10 +29,10 @@ without prior permission by the authors of Eressea. #include static int -tolua_hashtable_get(lua_State* tolua_S) +tolua_hashtable_get(lua_State* L) { - hashtable self = (hashtable) tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + hashtable self = (hashtable) tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); attrib * a = a_find(*self, &at_object); for (; a && a->type == &at_object; a = a->next) { @@ -44,28 +44,28 @@ tolua_hashtable_get(lua_State* tolua_S) object_get(a, &type, &val); switch (type) { case TNONE: - lua_pushnil(tolua_S); + lua_pushnil(L); break; case TINTEGER: - lua_pushnumber(tolua_S, (lua_Number)val.i); + lua_pushnumber(L, (lua_Number)val.i); break; case TREAL: - lua_pushnumber(tolua_S, (lua_Number)val.f); + lua_pushnumber(L, (lua_Number)val.f); break; case TREGION: - tolua_pushusertype(tolua_S, val.v, "region"); + tolua_pushusertype(L, val.v, "region"); break; case TBUILDING: - tolua_pushusertype(tolua_S, val.v, "building"); + tolua_pushusertype(L, val.v, "building"); break; case TUNIT: - tolua_pushusertype(tolua_S, val.v, "unit"); + tolua_pushusertype(L, val.v, "unit"); break; case TSHIP: - tolua_pushusertype(tolua_S, val.v, "ship"); + tolua_pushusertype(L, val.v, "ship"); break; case TSTRING: - tolua_pushstring(tolua_S, (const char*) val.v); + tolua_pushstring(L, (const char*) val.v); break; default: assert(!"not implemented"); @@ -73,16 +73,16 @@ tolua_hashtable_get(lua_State* tolua_S) return 1; } } - lua_pushnil(tolua_S); + lua_pushnil(L); return 1; } static int -tolua_hashtable_set_number(lua_State* tolua_S) +tolua_hashtable_set_number(lua_State* L) { - hashtable self = (hashtable) tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); - lua_Number value = tolua_tonumber(tolua_S, 3, 0); + hashtable self = (hashtable) tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + lua_Number value = tolua_tonumber(L, 3, 0); attrib * a = a_find(*self, &at_object); variant val; @@ -100,11 +100,11 @@ tolua_hashtable_set_number(lua_State* tolua_S) } static int -tolua_hashtable_set_string(lua_State* tolua_S) +tolua_hashtable_set_string(lua_State* L) { - hashtable self = (hashtable) tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); - const char * value = tolua_tostring(tolua_S, 3, 0); + hashtable self = (hashtable) tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + const char * value = tolua_tostring(L, 3, 0); attrib * a = a_find(*self, &at_object); variant val; @@ -122,11 +122,11 @@ tolua_hashtable_set_string(lua_State* tolua_S) } static int -tolua_hashtable_set_usertype(lua_State* tolua_S, int type) +tolua_hashtable_set_usertype(lua_State* L, int type) { - hashtable self = (hashtable) tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); - unit * value = tolua_tousertype(tolua_S, 3, 0); + hashtable self = (hashtable) tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + unit * value = tolua_tousertype(L, 3, 0); attrib * a = a_find(*self, &at_object); variant val; @@ -145,43 +145,43 @@ tolua_hashtable_set_usertype(lua_State* tolua_S, int type) static int -tolua_hashtable_set(lua_State* tolua_S) +tolua_hashtable_set(lua_State* L) { tolua_Error tolua_err; - if (tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { - return tolua_hashtable_set_number(tolua_S); - } else if (tolua_isusertype(tolua_S, 3, "unit", 0, &tolua_err)) { - return tolua_hashtable_set_usertype(tolua_S, TUNIT); - } else if (tolua_isusertype(tolua_S, 3, "faction", 0, &tolua_err)) { - return tolua_hashtable_set_usertype(tolua_S, TFACTION); - } else if (tolua_isusertype(tolua_S, 3, "ship", 0, &tolua_err)) { - return tolua_hashtable_set_usertype(tolua_S, TSHIP); - } else if (tolua_isusertype(tolua_S, 3, "building", 0, &tolua_err)) { - return tolua_hashtable_set_usertype(tolua_S, TBUILDING); - } else if (tolua_isusertype(tolua_S, 3, "region", 0, &tolua_err)) { - return tolua_hashtable_set_usertype(tolua_S, TREGION); + if (tolua_isnumber(L, 3, 0, &tolua_err)) { + return tolua_hashtable_set_number(L); + } else if (tolua_isusertype(L, 3, "unit", 0, &tolua_err)) { + return tolua_hashtable_set_usertype(L, TUNIT); + } else if (tolua_isusertype(L, 3, "faction", 0, &tolua_err)) { + return tolua_hashtable_set_usertype(L, TFACTION); + } else if (tolua_isusertype(L, 3, "ship", 0, &tolua_err)) { + return tolua_hashtable_set_usertype(L, TSHIP); + } else if (tolua_isusertype(L, 3, "building", 0, &tolua_err)) { + return tolua_hashtable_set_usertype(L, TBUILDING); + } else if (tolua_isusertype(L, 3, "region", 0, &tolua_err)) { + return tolua_hashtable_set_usertype(L, TREGION); } - return tolua_hashtable_set_string(tolua_S); + return tolua_hashtable_set_string(L); } void -tolua_hashtable_open(lua_State* tolua_S) +tolua_hashtable_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "hashtable"); + tolua_usertype(L, "hashtable"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "hashtable", "hashtable", "", NULL); - tolua_beginmodule(tolua_S, "hashtable"); + tolua_cclass(L, "hashtable", "hashtable", "", NULL); + tolua_beginmodule(L, "hashtable"); { - tolua_function(tolua_S, "get", tolua_hashtable_get); - tolua_function(tolua_S, "set", tolua_hashtable_set); + tolua_function(L, "get", tolua_hashtable_get); + tolua_function(L, "set", tolua_hashtable_set); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_hashtable.h b/src/eressea/tolua/bind_hashtable.h index fc08801db..d137638f2 100644 --- a/src/eressea/tolua/bind_hashtable.h +++ b/src/eressea/tolua/bind_hashtable.h @@ -15,7 +15,7 @@ extern "C" { #endif struct lua_State; - void tolua_hashtable_open(struct lua_State *tolua_S); + void tolua_hashtable_open(struct lua_State *L); typedef struct attrib ** hashtable; diff --git a/src/eressea/tolua/bind_message.c b/src/eressea/tolua/bind_message.c index cbfe75a57..69f2e3ef2 100644 --- a/src/eressea/tolua/bind_message.c +++ b/src/eressea/tolua/bind_message.c @@ -195,129 +195,129 @@ msg_send_region(lua_message * lmsg, region * r) static int -tolua_msg_create(lua_State * tolua_S) +tolua_msg_create(lua_State * L) { - const char * type = tolua_tostring(tolua_S, 1, 0); + const char * type = tolua_tostring(L, 1, 0); lua_message * lmsg = msg_create_message(type); - tolua_pushusertype(tolua_S, (void*)lmsg, "message"); + tolua_pushusertype(L, (void*)lmsg, "message"); return 1; } static int -tolua_msg_set_string(lua_State * tolua_S) +tolua_msg_set_string(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - const char * param = tolua_tostring(tolua_S, 2, 0); - const char * value = tolua_tostring(tolua_S, 3, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + const char * param = tolua_tostring(L, 2, 0); + const char * value = tolua_tostring(L, 3, 0); int result = msg_set_string(lmsg, param, value); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_set_int(lua_State * tolua_S) +tolua_msg_set_int(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - const char * param = tolua_tostring(tolua_S, 2, 0); - int value = (int)tolua_tonumber(tolua_S, 3, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + const char * param = tolua_tostring(L, 2, 0); + int value = (int)tolua_tonumber(L, 3, 0); int result = msg_set_int(lmsg, param, value); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_set_resource(lua_State * tolua_S) +tolua_msg_set_resource(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - const char * param = tolua_tostring(tolua_S, 2, 0); - const char * value = tolua_tostring(tolua_S, 3, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + const char * param = tolua_tostring(L, 2, 0); + const char * value = tolua_tostring(L, 3, 0); int result = msg_set_resource(lmsg, param, value); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_set_unit(lua_State * tolua_S) +tolua_msg_set_unit(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - const char * param = tolua_tostring(tolua_S, 2, 0); - unit * value = (unit *)tolua_tousertype(tolua_S, 3, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + const char * param = tolua_tostring(L, 2, 0); + unit * value = (unit *)tolua_tousertype(L, 3, 0); int result = msg_set_unit(lmsg, param, value); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_set_region(lua_State * tolua_S) +tolua_msg_set_region(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - const char * param = tolua_tostring(tolua_S, 2, 0); - region * value = (region *)tolua_tousertype(tolua_S, 3, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + const char * param = tolua_tostring(L, 2, 0); + region * value = (region *)tolua_tousertype(L, 3, 0); int result = msg_set_region(lmsg, param, value); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_set(lua_State * tolua_S) +tolua_msg_set(lua_State * L) { tolua_Error err; - if (tolua_isnumber(tolua_S, 3, 0, &err)) { - return tolua_msg_set_int(tolua_S); - } else if (tolua_isusertype(tolua_S, 3, "region", 0, &err)) { - return tolua_msg_set_region(tolua_S); - } else if (tolua_isusertype(tolua_S, 3, "unit", 0, &err)) { - return tolua_msg_set_unit(tolua_S); + if (tolua_isnumber(L, 3, 0, &err)) { + return tolua_msg_set_int(L); + } else if (tolua_isusertype(L, 3, "region", 0, &err)) { + return tolua_msg_set_region(L); + } else if (tolua_isusertype(L, 3, "unit", 0, &err)) { + return tolua_msg_set_unit(L); } - tolua_pushnumber(tolua_S, (lua_Number)-1); + tolua_pushnumber(L, (lua_Number)-1); return 1; } static int -tolua_msg_send_region(lua_State * tolua_S) +tolua_msg_send_region(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - region * r = (region *)tolua_tousertype(tolua_S, 2, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + region * r = (region *)tolua_tousertype(L, 2, 0); int result = msg_send_region(lmsg, r); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_msg_send_faction(lua_State * tolua_S) +tolua_msg_send_faction(lua_State * L) { - lua_message * lmsg = (lua_message *)tolua_tousertype(tolua_S, 1, 0); - faction * f = (faction *)tolua_tousertype(tolua_S, 2, 0); + lua_message * lmsg = (lua_message *)tolua_tousertype(L, 1, 0); + faction * f = (faction *)tolua_tousertype(L, 2, 0); int result = msg_send_faction(lmsg, f); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } void -tolua_message_open(lua_State* tolua_S) +tolua_message_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "message"); + tolua_usertype(L, "message"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_function(tolua_S, "message", tolua_msg_create); + tolua_function(L, "message", tolua_msg_create); - tolua_cclass(tolua_S, "message", "message", "", NULL); - tolua_beginmodule(tolua_S, "message"); + tolua_cclass(L, "message", "message", "", NULL); + tolua_beginmodule(L, "message"); { - tolua_function(tolua_S, "set", tolua_msg_set); - tolua_function(tolua_S, "set_unit", tolua_msg_set_unit); - tolua_function(tolua_S, "set_region", tolua_msg_set_region); - tolua_function(tolua_S, "set_resource", tolua_msg_set_resource); - tolua_function(tolua_S, "set_int", tolua_msg_set_int); - tolua_function(tolua_S, "set_string", tolua_msg_set_string); - tolua_function(tolua_S, "send_faction", tolua_msg_send_faction); - tolua_function(tolua_S, "send_region", tolua_msg_send_region); + 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(tolua_S, "create", tolua_msg_create); + tolua_function(L, "create", tolua_msg_create); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_message.h b/src/eressea/tolua/bind_message.h index d93d6d640..ed9aab133 100644 --- a/src/eressea/tolua/bind_message.h +++ b/src/eressea/tolua/bind_message.h @@ -15,7 +15,7 @@ extern "C" { #endif struct lua_State; - void tolua_message_open(struct lua_State *tolua_S); + void tolua_message_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_region.c b/src/eressea/tolua/bind_region.c index 27f1d6615..392d418fb 100644 --- a/src/eressea/tolua/bind_region.c +++ b/src/eressea/tolua/bind_region.c @@ -35,12 +35,12 @@ without prior permission by the authors of Eressea. #include #include -int tolua_regionlist_next(lua_State *tolua_S) +int tolua_regionlist_next(lua_State *L) { - region** region_ptr = (region **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + region** region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1)); region * u = *region_ptr; if (u != NULL) { - tolua_pushusertype(tolua_S, (void*)u, "region"); + tolua_pushusertype(L, (void*)u, "region"); *region_ptr = u->next; return 1; } @@ -48,90 +48,90 @@ int tolua_regionlist_next(lua_State *tolua_S) } static int -tolua_region_get_id(lua_State* tolua_S) +tolua_region_get_id(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->uid); + region * self = (region *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->uid); return 1; } static int -tolua_region_get_x(lua_State* tolua_S) +tolua_region_get_x(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->x); + region * self = (region *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->x); return 1; } static int -tolua_region_get_y(lua_State* tolua_S) +tolua_region_get_y(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->y); + region * self = (region *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->y); return 1; } static int -tolua_region_get_terrain(lua_State* tolua_S) +tolua_region_get_terrain(lua_State* L) { - region* self = (region*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, self->terrain->_name); + region* self = (region*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, self->terrain->_name); return 1; } -static int tolua_region_get_info(lua_State* tolua_S) +static int tolua_region_get_info(lua_State* L) { - region* self = (region*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, region_getinfo(self)); + region* self = (region*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, region_getinfo(self)); return 1; } -static int tolua_region_set_info(lua_State* tolua_S) +static int tolua_region_set_info(lua_State* L) { - region* self = (region*)tolua_tousertype(tolua_S, 1, 0); - region_setinfo(self, tolua_tostring(tolua_S, 2, 0)); + region* self = (region*)tolua_tousertype(L, 1, 0); + region_setinfo(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_region_get_name(lua_State* tolua_S) +static int tolua_region_get_name(lua_State* L) { - region* self = (region*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, region_getname(self)); + region* self = (region*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, region_getname(self)); return 1; } -static int tolua_region_set_name(lua_State* tolua_S) +static int tolua_region_set_name(lua_State* L) { - region* self = (region*)tolua_tousertype(tolua_S, 1, 0); - region_setname(self, tolua_tostring(tolua_S, 2, 0)); + region* self = (region*)tolua_tousertype(L, 1, 0); + region_setname(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_region_get_flag(lua_State* tolua_S) +static int tolua_region_get_flag(lua_State* L) { - region* self = (region*)tolua_tousertype(tolua_S, 1, 0); - int bit = (int)tolua_tonumber(tolua_S, 2, 0); + region* self = (region*)tolua_tousertype(L, 1, 0); + int bit = (int)tolua_tonumber(L, 2, 0); - lua_pushboolean(tolua_S, (self->flags & (1<flags & (1<flags |= (1<flags &= ~(1<resources;rm;rm=rm->next) { if (rm->type->rtype==rtype) { - tolua_pushnumber(tolua_S, (lua_Number)rm->level); + tolua_pushnumber(L, (lua_Number)rm->level); return 1; } } @@ -157,10 +157,10 @@ tolua_region_get_resourcelevel(lua_State* tolua_S) } static int -tolua_region_get_resource(lua_State* tolua_S) +tolua_region_get_resource(lua_State* L) { - region * r = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * type = tolua_tostring(tolua_S, 2, 0); + region * r = (region *)tolua_tousertype(L, 1, 0); + const char * type = tolua_tostring(L, 2, 0); const resource_type * rtype = rt_find(type); int result = 0; @@ -174,16 +174,16 @@ tolua_region_get_resource(lua_State* tolua_S) result = region_getresource(r, rtype); } - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_region_set_resource(lua_State* tolua_S) +tolua_region_set_resource(lua_State* L) { - region * r = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * type = tolua_tostring(tolua_S, 2, 0); - int value = (int)tolua_tonumber(tolua_S, 3, 0); + region * r = (region *)tolua_tousertype(L, 1, 0); + const char * type = tolua_tostring(L, 2, 0); + int value = (int)tolua_tonumber(L, 3, 0); const resource_type * rtype = rt_find(type); if (rtype!=NULL) { @@ -207,19 +207,19 @@ tolua_region_set_resource(lua_State* tolua_S) } static int -tolua_region_get_objects(lua_State* tolua_S) +tolua_region_get_objects(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)&self->attribs, "hashtable"); + region * self = (region *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)&self->attribs, "hashtable"); return 1; } static int -tolua_region_create(lua_State* tolua_S) +tolua_region_create(lua_State* L) { - short x = (short)tolua_tonumber(tolua_S, 1, 0); - short y = (short)tolua_tonumber(tolua_S, 2, 0); - const char * tname = tolua_tostring(tolua_S, 3, 0); + short x = (short)tolua_tonumber(L, 1, 0); + short y = (short)tolua_tonumber(L, 2, 0); + const char * tname = tolua_tostring(L, 3, 0); const terrain_type * terrain = get_terrain(tname); region * r = findregion(x, y); @@ -241,82 +241,82 @@ tolua_region_create(lua_State* tolua_S) } fix_demand(result); - tolua_pushusertype(tolua_S, result, "region"); + tolua_pushusertype(L, result, "region"); return 1; } -static int tolua_region_get_units(lua_State* tolua_S) +static int tolua_region_get_units(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - unit ** unit_ptr = (unit**)lua_newuserdata(tolua_S, sizeof(unit *)); + region * self = (region *)tolua_tousertype(L, 1, 0); + unit ** unit_ptr = (unit**)lua_newuserdata(L, sizeof(unit *)); - luaL_getmetatable(tolua_S, "unit"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "unit"); + lua_setmetatable(L, -2); *unit_ptr = self->units; - lua_pushcclosure(tolua_S, tolua_unitlist_next, 1); + lua_pushcclosure(L, tolua_unitlist_next, 1); return 1; } -static int tolua_region_get_buildings(lua_State* tolua_S) +static int tolua_region_get_buildings(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - building ** building_ptr = (building**)lua_newuserdata(tolua_S, sizeof(building *)); + region * self = (region *)tolua_tousertype(L, 1, 0); + building ** building_ptr = (building**)lua_newuserdata(L, sizeof(building *)); - luaL_getmetatable(tolua_S, "building"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "building"); + lua_setmetatable(L, -2); *building_ptr = self->buildings; - lua_pushcclosure(tolua_S, tolua_buildinglist_next, 1); + lua_pushcclosure(L, tolua_buildinglist_next, 1); return 1; } -static int tolua_region_get_ships(lua_State* tolua_S) +static int tolua_region_get_ships(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - ship ** ship_ptr = (ship**)lua_newuserdata(tolua_S, sizeof(ship *)); + region * self = (region *)tolua_tousertype(L, 1, 0); + ship ** ship_ptr = (ship**)lua_newuserdata(L, sizeof(ship *)); - luaL_getmetatable(tolua_S, "ship"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "ship"); + lua_setmetatable(L, -2); *ship_ptr = self->ships; - lua_pushcclosure(tolua_S, tolua_shiplist_next, 1); + lua_pushcclosure(L, tolua_shiplist_next, 1); return 1; } -static int tolua_region_get_age(lua_State* tolua_S) +static int tolua_region_get_age(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); + region * self = (region *)tolua_tousertype(L, 1, 0); if (self) { - lua_pushnumber(tolua_S, self->age); + lua_pushnumber(L, self->age); return 1; } return 0; } static int -tolua_region_getkey(lua_State* tolua_S) +tolua_region_getkey(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + region * self = (region *)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); int flag = atoi36(name); attrib * a = find_key(self->attribs, flag); - lua_pushboolean(tolua_S, a!=NULL); + lua_pushboolean(L, a!=NULL); return 1; } static int -tolua_region_setkey(lua_State* tolua_S) +tolua_region_setkey(lua_State* L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); - int value = tolua_toboolean(tolua_S, 3, 0); + region * self = (region *)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + int value = tolua_toboolean(L, 3, 0); int flag = atoi36(name); attrib * a = find_key(self->attribs, flag); @@ -329,47 +329,47 @@ tolua_region_setkey(lua_State* tolua_S) } static int -tolua_region_tostring(lua_State *tolua_S) +tolua_region_tostring(lua_State *L) { - region * self = (region *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, regionname(self, NULL)); + region * self = (region *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, regionname(self, NULL)); return 1; } void -tolua_region_open(lua_State* tolua_S) +tolua_region_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "region"); + tolua_usertype(L, "region"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "region", "region", "", NULL); - tolua_beginmodule(tolua_S, "region"); + tolua_cclass(L, "region", "region", "", NULL); + tolua_beginmodule(L, "region"); { - tolua_function(tolua_S, "create", tolua_region_create); - tolua_function(tolua_S, "__tostring", tolua_region_tostring); + tolua_function(L, "create", tolua_region_create); + tolua_function(L, "__tostring", tolua_region_tostring); - tolua_variable(tolua_S, "id", tolua_region_get_id, NULL); - tolua_variable(tolua_S, "x", tolua_region_get_x, NULL); - tolua_variable(tolua_S, "y", tolua_region_get_y, NULL); - tolua_variable(tolua_S, "name", tolua_region_get_name, tolua_region_set_name); - tolua_variable(tolua_S, "info", tolua_region_get_info, tolua_region_set_info); - tolua_variable(tolua_S, "units", tolua_region_get_units, NULL); - tolua_variable(tolua_S, "ships", tolua_region_get_ships, NULL); - tolua_variable(tolua_S, "age", tolua_region_get_age, NULL); - tolua_variable(tolua_S, "buildings", tolua_region_get_buildings, NULL); - tolua_variable(tolua_S, "terrain", tolua_region_get_terrain, NULL); - tolua_function(tolua_S, "get_resourcelevel", tolua_region_get_resourcelevel); - 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, "next", tolua_region_get_adj); + 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_function(tolua_S, "get_key", tolua_region_getkey); - tolua_function(tolua_S, "set_key", tolua_region_setkey); + tolua_function(L, "get_key", tolua_region_getkey); + tolua_function(L, "set_key", tolua_region_setkey); #if 0 .property("owner", &lua_region_getowner, &lua_region_setowner) .property("herbtype", ®ion_getherbtype, ®ion_setherbtype) @@ -383,9 +383,9 @@ tolua_region_open(lua_State* tolua_S) .property("items", ®ion_items, return_stl_iterator) .property("plane_id", ®ion_plane) #endif - tolua_variable(tolua_S, "objects", tolua_region_get_objects, 0); + tolua_variable(L, "objects", tolua_region_get_objects, 0); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_region.h b/src/eressea/tolua/bind_region.h index 61e9958d4..f8d0c8e2a 100644 --- a/src/eressea/tolua/bind_region.h +++ b/src/eressea/tolua/bind_region.h @@ -15,8 +15,8 @@ extern "C" { #endif struct lua_State; - void tolua_region_open(struct lua_State *tolua_S); - int tolua_regionlist_next(struct lua_State *tolua_S); + void tolua_region_open(struct lua_State *L); + int tolua_regionlist_next(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_ship.c b/src/eressea/tolua/bind_ship.c index e236c37e6..c9853d32b 100644 --- a/src/eressea/tolua/bind_ship.c +++ b/src/eressea/tolua/bind_ship.c @@ -24,12 +24,12 @@ without prior permission by the authors of Eressea. #include #include -int tolua_shiplist_next(lua_State *tolua_S) +int tolua_shiplist_next(lua_State *L) { - ship** ship_ptr = (ship **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + ship** ship_ptr = (ship **)lua_touserdata(L, lua_upvalueindex(1)); ship * u = *ship_ptr; if (u != NULL) { - tolua_pushusertype(tolua_S, (void*)u, "ship"); + tolua_pushusertype(L, (void*)u, "ship"); *ship_ptr = u->next; return 1; } @@ -37,83 +37,83 @@ int tolua_shiplist_next(lua_State *tolua_S) } static int -tolua_ship_get_id(lua_State* tolua_S) +tolua_ship_get_id(lua_State* L) { - ship * self = (ship *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->no); + ship * self = (ship *)tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->no); return 1; } -static int tolua_ship_get_name(lua_State* tolua_S) +static int tolua_ship_get_name(lua_State* L) { - ship* self = (ship*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, ship_getname(self)); + ship* self = (ship*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, ship_getname(self)); return 1; } -static int tolua_ship_get_region(lua_State* tolua_S) +static int tolua_ship_get_region(lua_State* L) { - ship* self = (ship*) tolua_tousertype(tolua_S, 1, 0); + ship* self = (ship*) tolua_tousertype(L, 1, 0); if (self) { - tolua_pushusertype(tolua_S, self->region, "region"); + tolua_pushusertype(L, self->region, "region"); return 1; } return 0; } -static int tolua_ship_set_region(lua_State* tolua_S) +static int tolua_ship_set_region(lua_State* L) { - ship* self = (ship*) tolua_tousertype(tolua_S, 1, 0); - region * r = (region*) tolua_tousertype(tolua_S, 1, 0); + ship* self = (ship*) tolua_tousertype(L, 1, 0); + region * r = (region*) tolua_tousertype(L, 1, 0); if (self) { move_ship(self, self->region, r, NULL); } return 0; } -static int tolua_ship_set_name(lua_State* tolua_S) +static int tolua_ship_set_name(lua_State* L) { - ship* self = (ship*)tolua_tousertype(tolua_S, 1, 0); - ship_setname(self, tolua_tostring(tolua_S, 2, 0)); + ship* self = (ship*)tolua_tousertype(L, 1, 0); + ship_setname(self, tolua_tostring(L, 2, 0)); return 0; } static int -tolua_ship_get_units(lua_State* tolua_S) +tolua_ship_get_units(lua_State* L) { - ship * self = (ship *)tolua_tousertype(tolua_S, 1, 0); - unit ** unit_ptr = (unit**)lua_newuserdata(tolua_S, sizeof(unit *)); + ship * self = (ship *)tolua_tousertype(L, 1, 0); + unit ** unit_ptr = (unit**)lua_newuserdata(L, sizeof(unit *)); unit * u = self->region->units; while (u && u->ship!=self) u = u->next; - luaL_getmetatable(tolua_S, "unit"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "unit"); + lua_setmetatable(L, -2); *unit_ptr = u; - lua_pushcclosure(tolua_S, tolua_unitlist_nexts, 1); + lua_pushcclosure(L, tolua_unitlist_nexts, 1); return 1; } static int -tolua_ship_get_objects(lua_State* tolua_S) +tolua_ship_get_objects(lua_State* L) { - ship * self = (ship *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)&self->attribs, "hashtable"); + ship * self = (ship *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)&self->attribs, "hashtable"); return 1; } static int -tolua_ship_create(lua_State* tolua_S) +tolua_ship_create(lua_State* L) { - region * r = (region *)tolua_tousertype(tolua_S, 1, 0); - const char * sname = tolua_tostring(tolua_S, 2, 0); + region * r = (region *)tolua_tousertype(L, 1, 0); + const char * sname = tolua_tostring(L, 2, 0); if (sname) { const ship_type * stype = st_find(sname); if (stype) { ship * sh = new_ship(stype, NULL, r); sh->size = stype->construction->maxsize; - tolua_pushusertype(tolua_S, (void*)sh, "ship"); + tolua_pushusertype(L, (void*)sh, "ship"); return 1; } } @@ -121,30 +121,31 @@ tolua_ship_create(lua_State* tolua_S) } static int -tolua_ship_tostring(lua_State *tolua_S) + +tolua_ship_tostring(lua_State *L) { - ship * self = (ship *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, shipname(self)); + ship * self = (ship *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, shipname(self)); return 1; } void -tolua_ship_open(lua_State* tolua_S) +tolua_ship_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "ship"); + tolua_usertype(L, "ship"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "ship", "ship", "", NULL); - tolua_beginmodule(tolua_S, "ship"); + tolua_cclass(L, "ship", "ship", "", NULL); + tolua_beginmodule(L, "ship"); { - tolua_function(tolua_S, "__tostring", tolua_ship_tostring); - tolua_variable(tolua_S, "id", tolua_ship_get_id, NULL); - tolua_variable(tolua_S, "name", tolua_ship_get_name, tolua_ship_set_name); - tolua_variable(tolua_S, "units", tolua_ship_get_units, NULL); - tolua_variable(tolua_S, "region", tolua_ship_get_region, tolua_ship_set_region); + 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); #ifdef TODO .property("type", &ship_gettype) .property("weight", &ship_getweight) @@ -155,11 +156,11 @@ tolua_ship_open(lua_State* tolua_S) .def_readwrite("size", &ship::size) .def_readwrite("coast", &ship::coast) #endif - tolua_variable(tolua_S, "objects", tolua_ship_get_objects, 0); + tolua_variable(L, "objects", tolua_ship_get_objects, 0); - tolua_function(tolua_S, "create", tolua_ship_create); + tolua_function(L, "create", tolua_ship_create); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_ship.h b/src/eressea/tolua/bind_ship.h index 4461194eb..7c9426fce 100644 --- a/src/eressea/tolua/bind_ship.h +++ b/src/eressea/tolua/bind_ship.h @@ -15,8 +15,8 @@ extern "C" { #endif struct lua_State; - int tolua_shiplist_next(struct lua_State *tolua_S); - void tolua_ship_open(struct lua_State *tolua_S); + int tolua_shiplist_next(struct lua_State *L); + void tolua_ship_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_storage.c b/src/eressea/tolua/bind_storage.c index d4494b19c..995f10306 100644 --- a/src/eressea/tolua/bind_storage.c +++ b/src/eressea/tolua/bind_storage.c @@ -25,10 +25,10 @@ without prior permission by the authors of Eressea. static int -tolua_storage_create(lua_State* tolua_S) +tolua_storage_create(lua_State* L) { - const char * filename = tolua_tostring(tolua_S, 1, 0); - const char * type = tolua_tostring(tolua_S, 2, "rb"); + const char * filename = tolua_tostring(L, 1, 0); + const char * type = tolua_tostring(L, 2, "rb"); storage * store = 0; int mode = IO_READ; if (strchr(type, 't')) { @@ -41,53 +41,53 @@ tolua_storage_create(lua_State* tolua_S) if (strchr(type, 'r')) mode = IO_READ; if (strchr(type, 'w')) mode = IO_WRITE; store->open(store, filename, mode); - tolua_pushusertype(tolua_S, (void*)store, "storage"); + tolua_pushusertype(L, (void*)store, "storage"); return 1; } static int -tolua_storage_read_unit(lua_State *tolua_S) +tolua_storage_read_unit(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); struct unit * u = read_unit(self); - tolua_pushusertype(tolua_S, (void*)u, "unit"); + tolua_pushusertype(L, (void*)u, "unit"); return 1; } static int -tolua_storage_write_unit(lua_State *tolua_S) +tolua_storage_write_unit(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); - struct unit * u = (struct unit *)tolua_tousertype(tolua_S, 2, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); + struct unit * u = (struct unit *)tolua_tousertype(L, 2, 0); write_unit(self, u); return 0; } static int -tolua_storage_read_float(lua_State *tolua_S) +tolua_storage_read_float(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); float num = self->r_flt(self); - tolua_pushnumber(tolua_S, (lua_Number)num); + tolua_pushnumber(L, (lua_Number)num); return 1; } static int -tolua_storage_read_int(lua_State *tolua_S) +tolua_storage_read_int(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); int num = self->r_int(self); - tolua_pushnumber(tolua_S, (lua_Number)num); + tolua_pushnumber(L, (lua_Number)num); return 1; } static int -tolua_storage_write(lua_State *tolua_S) +tolua_storage_write(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); - if (tolua_isnumber(tolua_S, 2, 0, 0)) { - lua_Number num = tolua_tonumber(tolua_S, 2, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); + if (tolua_isnumber(L, 2, 0, 0)) { + lua_Number num = tolua_tonumber(L, 2, 0); double n; if (modf(num, &n)==0.0) { self->w_int(self, (int)num); @@ -99,45 +99,45 @@ tolua_storage_write(lua_State *tolua_S) } static int -tolua_storage_tostring(lua_State *tolua_S) +tolua_storage_tostring(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); char name[64]; snprintf(name, sizeof(name), "", self->encoding, self->version); - lua_pushstring(tolua_S, name); + lua_pushstring(L, name); return 1; } static int -tolua_storage_close(lua_State *tolua_S) +tolua_storage_close(lua_State *L) { - storage * self = (storage *)tolua_tousertype(tolua_S, 1, 0); + storage * self = (storage *)tolua_tousertype(L, 1, 0); self->close(self); return 0; } void -tolua_storage_open(lua_State* tolua_S) +tolua_storage_open(lua_State* L) { /* register user types */ - tolua_usertype(tolua_S, "storage"); + tolua_usertype(L, "storage"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "storage", "storage", "", NULL); - tolua_beginmodule(tolua_S, "storage"); + tolua_cclass(L, "storage", "storage", "", NULL); + tolua_beginmodule(L, "storage"); { - tolua_function(tolua_S, "__tostring", tolua_storage_tostring); - tolua_function(tolua_S, "write", tolua_storage_write); - tolua_function(tolua_S, "read_int", tolua_storage_read_int); - tolua_function(tolua_S, "read_float", tolua_storage_read_float); - tolua_function(tolua_S, "write_unit", tolua_storage_write_unit); - tolua_function(tolua_S, "read_unit", tolua_storage_read_unit); - tolua_function(tolua_S, "close", tolua_storage_close); - tolua_function(tolua_S, "create", tolua_storage_create); + 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_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_storage.h b/src/eressea/tolua/bind_storage.h index 99a969420..fd79c7ca8 100644 --- a/src/eressea/tolua/bind_storage.h +++ b/src/eressea/tolua/bind_storage.h @@ -15,7 +15,7 @@ extern "C" { #endif struct lua_State; - void tolua_storage_open(struct lua_State *tolua_S); + void tolua_storage_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bind_unit.c b/src/eressea/tolua/bind_unit.c index dd648598a..5b3ee81c9 100644 --- a/src/eressea/tolua/bind_unit.c +++ b/src/eressea/tolua/bind_unit.c @@ -50,32 +50,32 @@ without prior permission by the authors of Eressea. #include static int -tolua_unit_get_objects(lua_State* tolua_S) +tolua_unit_get_objects(lua_State* L) { - unit * self = (unit *)tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)&self->attribs, "hashtable"); + unit * self = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)&self->attribs, "hashtable"); return 1; } -int tolua_unitlist_nextf(lua_State *tolua_S) +int tolua_unitlist_nextf(lua_State *L) { - unit** unit_ptr = (unit **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1)); unit * u = *unit_ptr; if (u != NULL) { - tolua_pushusertype(tolua_S, (void*)u, "unit"); + tolua_pushusertype(L, (void*)u, "unit"); *unit_ptr = u->nextF; return 1; } else return 0; /* no more values to return */ } -int tolua_unitlist_nextb(lua_State *tolua_S) +int tolua_unitlist_nextb(lua_State *L) { - unit** unit_ptr = (unit **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1)); unit * u = *unit_ptr; if (u != NULL) { unit * unext = u->next; - tolua_pushusertype(tolua_S, (void*)u, "unit"); + tolua_pushusertype(L, (void*)u, "unit"); while (unext && unext->building!=u->building) { unext = unext->next; @@ -87,13 +87,13 @@ int tolua_unitlist_nextb(lua_State *tolua_S) else return 0; /* no more values to return */ } -int tolua_unitlist_nexts(lua_State *tolua_S) +int tolua_unitlist_nexts(lua_State *L) { - unit** unit_ptr = (unit **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1)); unit * u = *unit_ptr; if (u != NULL) { unit * unext = u->next; - tolua_pushusertype(tolua_S, (void*)u, "unit"); + tolua_pushusertype(L, (void*)u, "unit"); while (unext && unext->ship!=u->ship) { unext = unext->next; @@ -105,12 +105,12 @@ int tolua_unitlist_nexts(lua_State *tolua_S) else return 0; /* no more values to return */ } -int tolua_unitlist_next(lua_State *tolua_S) +int tolua_unitlist_next(lua_State *L) { - unit** unit_ptr = (unit **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + unit** unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1)); unit * u = *unit_ptr; if (u != NULL) { - tolua_pushusertype(tolua_S, (void*)u, "unit"); + tolua_pushusertype(L, (void*)u, "unit"); *unit_ptr = u->next; return 1; } @@ -118,80 +118,80 @@ int tolua_unitlist_next(lua_State *tolua_S) } -static int tolua_unit_get_name(lua_State* tolua_S) +static int tolua_unit_get_name(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, self->name); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, self->name); return 1; } -static int tolua_unit_set_name(lua_State* tolua_S) +static int tolua_unit_set_name(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setname(self, tolua_tostring(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setname(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_unit_get_info(lua_State* tolua_S) +static int tolua_unit_get_info(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, unit_getinfo(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, unit_getinfo(self)); return 1; } -static int tolua_unit_set_info(lua_State* tolua_S) +static int tolua_unit_set_info(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setinfo(self, tolua_tostring(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setinfo(self, tolua_tostring(L, 2, 0)); return 0; } -static int tolua_unit_get_id(lua_State* tolua_S) +static int tolua_unit_get_id(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_getid(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_getid(self)); return 1; } -static int tolua_unit_set_id(lua_State* tolua_S) +static int tolua_unit_set_id(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setid(self, (int)tolua_tonumber(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setid(self, (int)tolua_tonumber(L, 2, 0)); return 0; } -static int tolua_unit_get_hpmax(lua_State* tolua_S) +static int tolua_unit_get_hpmax(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_max_hp(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_max_hp(self)); return 1; } -static int tolua_unit_get_hp(lua_State* tolua_S) +static int tolua_unit_get_hp(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_gethp(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_gethp(self)); return 1; } -static int tolua_unit_set_hp(lua_State* tolua_S) +static int tolua_unit_set_hp(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_sethp(self, (int)tolua_tonumber(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_sethp(self, (int)tolua_tonumber(L, 2, 0)); return 0; } -static int tolua_unit_get_number(lua_State* tolua_S) +static int tolua_unit_get_number(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->number); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->number); return 1; } -static int tolua_unit_set_number(lua_State* tolua_S) +static int tolua_unit_set_number(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - int number = (int)tolua_tonumber(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + int number = (int)tolua_tonumber(L, 2, 0); if (self->number==0) { set_number(self, number); self->hp = unit_max_hp(self) * number; @@ -201,17 +201,17 @@ static int tolua_unit_set_number(lua_State* tolua_S) return 0; } -static int tolua_unit_get_flags(lua_State* tolua_S) +static int tolua_unit_get_flags(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->flags); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->flags); return 1; } -static int tolua_unit_set_flags(lua_State* tolua_S) +static int tolua_unit_set_flags(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - self->flags = (int)tolua_tonumber(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + self->flags = (int)tolua_tonumber(L, 2, 0); return 0; } @@ -222,10 +222,10 @@ unit_getmagic(const unit * u) return mage?magic_school[mage->magietyp]:NULL; } -static int tolua_unit_get_magic(lua_State* tolua_S) +static int tolua_unit_get_magic(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, unit_getmagic(self)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + lua_pushstring(L, unit_getmagic(self)); return 1; } @@ -243,61 +243,61 @@ unit_setmagic(unit * u, const char * type) } } -static int tolua_unit_set_magic(lua_State* tolua_S) +static int tolua_unit_set_magic(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * type = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * type = tolua_tostring(L, 2, 0); unit_setmagic(self, type); return 0; } -static int tolua_unit_get_aura(lua_State* tolua_S) +static int tolua_unit_get_aura(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)get_spellpoints(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)get_spellpoints(self)); return 1; } -static int tolua_unit_set_aura(lua_State* tolua_S) +static int tolua_unit_set_aura(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - set_spellpoints(self, (int)tolua_tonumber(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + set_spellpoints(self, (int)tolua_tonumber(L, 2, 0)); return 0; } -static int tolua_unit_get_age(lua_State* tolua_S) +static int tolua_unit_get_age(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->age); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->age); return 1; } -static int tolua_unit_set_age(lua_State* tolua_S) +static int tolua_unit_set_age(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - self->age = (short)tolua_tonumber(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + self->age = (short)tolua_tonumber(L, 2, 0); return 0; } -static int tolua_unit_get_status(lua_State* tolua_S) +static int tolua_unit_get_status(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_getstatus(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_getstatus(self)); return 1; } -static int tolua_unit_set_status(lua_State* tolua_S) +static int tolua_unit_set_status(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setstatus(self, (status_t)tolua_tonumber(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setstatus(self, (status_t)tolua_tonumber(L, 2, 0)); return 0; } static int -tolua_unit_get_item(lua_State* tolua_S) +tolua_unit_get_item(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * iname = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); int result = -1; if (iname!=NULL) { @@ -306,16 +306,16 @@ tolua_unit_get_item(lua_State* tolua_S) result = i_get(self->items, itype); } } - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_unit_add_item(lua_State* tolua_S) +tolua_unit_add_item(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * iname = tolua_tostring(tolua_S, 2, 0); - int number = (int)tolua_tonumber(tolua_S, 3, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); + int number = (int)tolua_tonumber(L, 3, 0); int result = -1; if (iname!=NULL) { @@ -325,15 +325,15 @@ tolua_unit_add_item(lua_State* tolua_S) result = i?i->number:0; } } - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_unit_getskill(lua_State* tolua_S) +tolua_unit_getskill(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * skname = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * skname = tolua_tostring(L, 2, 0); skill_t sk = sk_find(skname); int value = -1; if (sk!=NOSKILL) { @@ -343,18 +343,18 @@ tolua_unit_getskill(lua_State* tolua_S) } else value = 0; } - lua_pushnumber(tolua_S, (lua_Number)value); + lua_pushnumber(L, (lua_Number)value); return 1; } static int -tolua_unit_effskill(lua_State* tolua_S) +tolua_unit_effskill(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * skname = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * skname = tolua_tostring(L, 2, 0); skill_t sk = sk_find(skname); int value = (sk==NOSKILL)?-1:eff_skill(self, sk, self->region); - lua_pushnumber(tolua_S, (lua_Number)value); + lua_pushnumber(L, (lua_Number)value); return 1; } @@ -424,24 +424,24 @@ trigger_lua(struct unit * u, int handle) } static int -tolua_unit_addhandler(lua_State* tolua_S) +tolua_unit_addhandler(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * ename = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * ename = tolua_tostring(L, 2, 0); int handle; - lua_pushvalue(tolua_S, 3); - handle = luaL_ref(tolua_S, LUA_REGISTRYINDEX); + lua_pushvalue(L, 3); + handle = luaL_ref(L, LUA_REGISTRYINDEX); add_trigger(&self->attribs, ename, trigger_lua(self, handle)); return 0; } static int -tolua_unit_addnotice(lua_State* tolua_S) +tolua_unit_addnotice(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); addmessage(self->region, self->faction, str, MSG_MESSAGE, ML_IMPORTANT); return 0; @@ -477,10 +477,10 @@ unit_castspell(unit * u, const char * name) } static int -tolua_unit_castspell(lua_State* tolua_S) +tolua_unit_castspell(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); unit_castspell(self, str); return 0; } @@ -505,10 +505,10 @@ unit_addspell(unit * u, const char * name) } static int -tolua_unit_addspell(lua_State* tolua_S) +tolua_unit_addspell(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); unit_addspell(self, str); return 0; } @@ -530,66 +530,66 @@ unit_removespell(unit * u, const spell * sp) } static int -tolua_unit_removespell(lua_State* tolua_S) +tolua_unit_removespell(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - spell * sp = (spell*)tolua_tousertype(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + spell * sp = (spell*)tolua_tousertype(L, 2, 0); unit_removespell(self, sp); return 0; } static int -tolua_unit_setracename(lua_State* tolua_S) +tolua_unit_setracename(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); set_racename(&self->attribs, str); return 0; } static int -tolua_unit_setskill(lua_State* tolua_S) +tolua_unit_setskill(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * skname = tolua_tostring(tolua_S, 2, 0); - int level = (int)tolua_tonumber(tolua_S, 3, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * skname = tolua_tostring(L, 2, 0); + int level = (int)tolua_tonumber(L, 3, 0); skill_t sk = sk_find(skname); if (sk!=NOSKILL) { set_level(self, sk, level); } else { level = -1; } - lua_pushnumber(tolua_S, (lua_Number)level); + lua_pushnumber(L, (lua_Number)level); return 1; } static int -tolua_unit_use_pooled(lua_State* tolua_S) +tolua_unit_use_pooled(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * iname = tolua_tostring(tolua_S, 2, 0); - int number = (int)tolua_tonumber(tolua_S, 3, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); + int number = (int)tolua_tonumber(L, 3, 0); const resource_type * rtype = rt_find(iname); int result = -1; if (rtype!=NULL) { result = use_pooled(self, rtype, GET_DEFAULT, number); } - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_unit_get_pooled(lua_State* tolua_S) +tolua_unit_get_pooled(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * iname = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); const resource_type * rtype = rt_find(iname); int result = -1; if (rtype!=NULL) { result = get_pooled(self, rtype, GET_DEFAULT, INT_MAX); } - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 1; } @@ -603,24 +603,24 @@ unit_getfamiliar(const unit * u) return NULL; } -static int tolua_unit_get_familiar(lua_State* tolua_S) +static int tolua_unit_get_familiar(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, unit_getfamiliar(self), "unit"); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, unit_getfamiliar(self), "unit"); return 1; } -static int tolua_unit_set_familiar(lua_State* tolua_S) +static int tolua_unit_set_familiar(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - create_newfamiliar(self, (unit *)tolua_tousertype(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + create_newfamiliar(self, (unit *)tolua_tousertype(L, 2, 0)); return 0; } -static int tolua_unit_get_building(lua_State* tolua_S) +static int tolua_unit_get_building(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, self->building, "building"); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, self->building, "building"); return 1; } @@ -634,17 +634,17 @@ unit_setbuilding(unit * u, building * b) u->building = b; } -static int tolua_unit_set_building(lua_State* tolua_S) +static int tolua_unit_set_building(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setbuilding(self, (building *)tolua_tousertype(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setbuilding(self, (building *)tolua_tousertype(L, 2, 0)); return 0; } -static int tolua_unit_get_ship(lua_State* tolua_S) +static int tolua_unit_get_ship(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, self->ship, "ship"); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, self->ship, "ship"); return 1; } @@ -658,17 +658,17 @@ unit_setship(unit * u, ship * s) u->ship = s; } -static int tolua_unit_set_ship(lua_State* tolua_S) +static int tolua_unit_set_ship(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setship(self, (ship *)tolua_tousertype(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setship(self, (ship *)tolua_tousertype(L, 2, 0)); return 0; } -static int tolua_unit_get_region(lua_State* tolua_S) +static int tolua_unit_get_region(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, self->region, "region"); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, self->region, "region"); return 1; } @@ -678,99 +678,99 @@ unit_setregion(unit * u, region * r) move_unit(u, r, NULL); } -static int tolua_unit_set_region(lua_State* tolua_S) +static int tolua_unit_set_region(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - unit_setregion(self, (region *)tolua_tousertype(tolua_S, 2, 0)); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + unit_setregion(self, (region *)tolua_tousertype(L, 2, 0)); return 0; } -static int tolua_unit_add_order(lua_State* tolua_S) +static int tolua_unit_add_order(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); order * ord = parse_order(str, self->faction->locale); unit_addorder(self, ord); return 0; } -static int tolua_unit_clear_orders(lua_State* tolua_S) +static int tolua_unit_clear_orders(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); free_orders(&self->orders); return 0; } -static int tolua_unit_get_items(lua_State* tolua_S) +static int tolua_unit_get_items(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); - item ** item_ptr = (item **)lua_newuserdata(tolua_S, sizeof(item *)); + item ** item_ptr = (item **)lua_newuserdata(L, sizeof(item *)); - luaL_getmetatable(tolua_S, "item"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "item"); + lua_setmetatable(L, -2); *item_ptr = self->items; - lua_pushcclosure(tolua_S, tolua_itemlist_next, 1); + lua_pushcclosure(L, tolua_itemlist_next, 1); return 1; } -static int tolua_unit_get_spells(lua_State* tolua_S) +static int tolua_unit_get_spells(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); sc_mage * mage = get_mage(self); if (mage) { spell_list ** slist = get_spelllist(mage, self->faction); assert(slist); if (slist) { - spell_list ** spell_ptr = (spell_list **)lua_newuserdata(tolua_S, sizeof(spell_list *)); - luaL_getmetatable(tolua_S, "spell_list"); - lua_setmetatable(tolua_S, -2); + spell_list ** spell_ptr = (spell_list **)lua_newuserdata(L, sizeof(spell_list *)); + luaL_getmetatable(L, "spell_list"); + lua_setmetatable(L, -2); *spell_ptr = *slist; - lua_pushcclosure(tolua_S, tolua_spelllist_next, 1); + lua_pushcclosure(L, tolua_spelllist_next, 1); return 1; } } - lua_pushnil(tolua_S); + lua_pushnil(L); return 1; } -static int tolua_unit_get_orders(lua_State* tolua_S) +static int tolua_unit_get_orders(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); - order ** order_ptr = (order **)lua_newuserdata(tolua_S, sizeof(order *)); + order ** order_ptr = (order **)lua_newuserdata(L, sizeof(order *)); - luaL_getmetatable(tolua_S, "order"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "order"); + lua_setmetatable(L, -2); *order_ptr = self->orders; - lua_pushcclosure(tolua_S, tolua_orderlist_next, 1); + lua_pushcclosure(L, tolua_orderlist_next, 1); return 1; } -static int tolua_unit_get_flag(lua_State* tolua_S) +static int tolua_unit_get_flag(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); int flag = atoi36(name); attrib * a = find_key(self->attribs, flag); - lua_pushboolean(tolua_S, (a!=NULL)); + lua_pushboolean(L, (a!=NULL)); return 1; } -static int tolua_unit_set_flag(lua_State* tolua_S) +static int tolua_unit_set_flag(lua_State* L) { - unit* self = (unit*)tolua_tousertype(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); - int value = (int)tolua_tonumber(tolua_S, 3, 0); + unit* self = (unit*)tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); attrib * a = find_key(self->attribs, flag); if (a==NULL && value) { @@ -781,46 +781,46 @@ static int tolua_unit_set_flag(lua_State* tolua_S) return 0; } -static int tolua_unit_get_weight(lua_State* tolua_S) +static int tolua_unit_get_weight(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_getweight(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_getweight(self)); return 1; } -static int tolua_unit_get_capacity(lua_State* tolua_S) +static int tolua_unit_get_capacity(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)unit_getcapacity(self)); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)unit_getcapacity(self)); return 1; } -static int tolua_unit_get_faction(lua_State* tolua_S) +static int tolua_unit_get_faction(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushusertype(tolua_S, (void*)self->faction, "faction"); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void*)self->faction, "faction"); return 1; } -static int tolua_unit_set_faction(lua_State* tolua_S) +static int tolua_unit_set_faction(lua_State* L) { - unit * self = (unit*) tolua_tousertype(tolua_S, 1, 0); - faction * f = (faction *)tolua_tousertype(tolua_S, 2, 0); + unit * self = (unit*) tolua_tousertype(L, 1, 0); + faction * f = (faction *)tolua_tousertype(L, 2, 0); u_setfaction(self, f); return 0; } -static int tolua_unit_get_race(lua_State* tolua_S) +static int tolua_unit_get_race(lua_State* L) { - unit* self = (unit*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, self->race->_name[0]); + unit* self = (unit*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, self->race->_name[0]); return 1; } -static int tolua_unit_set_race(lua_State* tolua_S) +static int tolua_unit_set_race(lua_State* L) { - unit * self = (unit*) tolua_tousertype(tolua_S, 1, 0); - const char * rcname = tolua_tostring(tolua_S, 2, 0); + unit * self = (unit*) tolua_tousertype(L, 1, 0); + const char * rcname = tolua_tostring(L, 2, 0); race * rc = rc_find(rcname); if (rc!=NULL) { if (self->irace==self->race) self->irace = rc; @@ -830,18 +830,18 @@ static int tolua_unit_set_race(lua_State* tolua_S) } static int -tolua_unit_create(lua_State* tolua_S) +tolua_unit_create(lua_State* L) { - faction * f = (faction *)tolua_tousertype(tolua_S, 1, 0); - region * r = (region *)tolua_tousertype(tolua_S, 2, 0); - int num = (int)tolua_tonumber(tolua_S, 3, 0); + faction * f = (faction *)tolua_tousertype(L, 1, 0); + region * r = (region *)tolua_tousertype(L, 2, 0); + int num = (int)tolua_tonumber(L, 3, 0); if (f && r) { const race * rc = f->race; - const char * rcname = tolua_tostring(tolua_S, 4, NULL); + const char * rcname = tolua_tostring(L, 4, NULL); if (rcname) rc = rc_find(rcname); if (rc) { unit * u = create_unit(r, f, num, rc, 0, NULL, NULL); - tolua_pushusertype(tolua_S, u, "unit"); + tolua_pushusertype(L, u, "unit"); return 1; } } @@ -849,127 +849,127 @@ tolua_unit_create(lua_State* tolua_S) } static int -tolua_unit_tostring(lua_State *tolua_S) +tolua_unit_tostring(lua_State *L) { - unit * self = (unit *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, unitname(self)); + unit * self = (unit *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, unitname(self)); return 1; } static int -tolua_event_gettype(lua_State *tolua_S) +tolua_event_gettype(lua_State *L) { - event * self = (event *)tolua_tousertype(tolua_S, 1, 0); - int index = (int)tolua_tonumber(tolua_S, 2, 0); - lua_pushstring(tolua_S, self->args[index].type); + event * self = (event *)tolua_tousertype(L, 1, 0); + int index = (int)tolua_tonumber(L, 2, 0); + lua_pushstring(L, self->args[index].type); return 1; } static int -tolua_event_get(lua_State *tolua_S) +tolua_event_get(lua_State *L) { - struct event * self = (struct event *)tolua_tousertype(tolua_S, 1, 0); - int index = (int)tolua_tonumber(tolua_S, 2, 0); + struct event * self = (struct event *)tolua_tousertype(L, 1, 0); + int index = (int)tolua_tonumber(L, 2, 0); event_arg * arg = self->args+index; if (arg->type) { if (strcmp(arg->type, "string")==0) { - tolua_pushstring(tolua_S, (const char *)arg->data.v); + tolua_pushstring(L, (const char *)arg->data.v); } else if (strcmp(arg->type, "int")==0) { - tolua_pushnumber(tolua_S, (lua_Number)arg->data.i); + tolua_pushnumber(L, (lua_Number)arg->data.i); } else if (strcmp(arg->type, "float")==0) { - tolua_pushnumber(tolua_S, (lua_Number)arg->data.f); + tolua_pushnumber(L, (lua_Number)arg->data.f); } else { /* this is pretty lazy */ - tolua_pushusertype(tolua_S, (void*)arg->data.v, arg->type); + tolua_pushusertype(L, (void*)arg->data.v, arg->type); } return 1; } - tolua_error(tolua_S, "invalid type argument for event", NULL); + tolua_error(L, "invalid type argument for event", NULL); return 0; } void -tolua_unit_open(lua_State * tolua_S) +tolua_unit_open(lua_State * L) { /* register user types */ - tolua_usertype(tolua_S, "unit"); - tolua_usertype(tolua_S, "unit_list"); + tolua_usertype(L, "unit"); + tolua_usertype(L, "unit_list"); - tolua_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "event", "event", "", NULL); - tolua_beginmodule(tolua_S, "event"); + tolua_cclass(L, "event", "event", "", NULL); + tolua_beginmodule(L, "event"); { - tolua_function(tolua_S, "get_type", tolua_event_gettype); - tolua_function(tolua_S, "get", tolua_event_get); + tolua_function(L, "get_type", tolua_event_gettype); + tolua_function(L, "get", tolua_event_get); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); - tolua_cclass(tolua_S, "unit", "unit", "", NULL); - tolua_beginmodule(tolua_S, "unit"); + tolua_cclass(L, "unit", "unit", "", NULL); + tolua_beginmodule(L, "unit"); { - tolua_function(tolua_S, "__tostring", tolua_unit_tostring); - tolua_function(tolua_S, "create", tolua_unit_create); + tolua_function(L, "__tostring", tolua_unit_tostring); + tolua_function(L, "create", tolua_unit_create); - tolua_variable(tolua_S, "name", tolua_unit_get_name, tolua_unit_set_name); - tolua_variable(tolua_S, "faction", tolua_unit_get_faction, tolua_unit_set_faction); - tolua_variable(tolua_S, "id", tolua_unit_get_id, tolua_unit_set_id); - tolua_variable(tolua_S, "info", tolua_unit_get_info, tolua_unit_set_info); - tolua_variable(tolua_S, "hp", tolua_unit_get_hp, tolua_unit_set_hp); - tolua_variable(tolua_S, "status", tolua_unit_get_status, tolua_unit_set_status); - tolua_variable(tolua_S, "familiar", tolua_unit_get_familiar, tolua_unit_set_familiar); + 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(tolua_S, "weight", tolua_unit_get_weight, 0); - tolua_variable(tolua_S, "capacity", tolua_unit_get_capacity, 0); + tolua_variable(L, "weight", tolua_unit_get_weight, 0); + tolua_variable(L, "capacity", tolua_unit_get_capacity, 0); - tolua_function(tolua_S, "add_order", tolua_unit_add_order); - tolua_function(tolua_S, "clear_orders", tolua_unit_clear_orders); - tolua_variable(tolua_S, "orders", tolua_unit_get_orders, 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); // key-attributes for named flags: - tolua_function(tolua_S, "set_flag", tolua_unit_set_flag); - tolua_function(tolua_S, "get_flag", tolua_unit_get_flag); - tolua_variable(tolua_S, "flags", tolua_unit_get_flags, tolua_unit_set_flags); - tolua_variable(tolua_S, "age", tolua_unit_get_age, tolua_unit_set_age); + 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); // items: - tolua_function(tolua_S, "get_item", tolua_unit_get_item); - tolua_function(tolua_S, "add_item", tolua_unit_add_item); - tolua_variable(tolua_S, "items", tolua_unit_get_items, 0); - tolua_function(tolua_S, "get_pooled", tolua_unit_get_pooled); - tolua_function(tolua_S, "use_pooled", tolua_unit_use_pooled); + 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); // skills: - tolua_function(tolua_S, "get_skill", tolua_unit_getskill); - tolua_function(tolua_S, "eff_skill", tolua_unit_effskill); - tolua_function(tolua_S, "set_skill", tolua_unit_setskill); + 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(tolua_S, "add_notice", tolua_unit_addnotice); + tolua_function(L, "add_notice", tolua_unit_addnotice); // npc logic: - tolua_function(tolua_S, "add_handler", tolua_unit_addhandler); + tolua_function(L, "add_handler", tolua_unit_addhandler); - tolua_function(tolua_S, "set_racename", tolua_unit_setracename); - tolua_function(tolua_S, "add_spell", tolua_unit_addspell); - tolua_function(tolua_S, "remove_spell", tolua_unit_removespell); - tolua_function(tolua_S, "cast_spell", tolua_unit_castspell); + tolua_function(L, "set_racename", tolua_unit_setracename); + 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(tolua_S, "magic", tolua_unit_get_magic, tolua_unit_set_magic); - tolua_variable(tolua_S, "aura", tolua_unit_get_aura, tolua_unit_set_aura); - tolua_variable(tolua_S, "building", tolua_unit_get_building, tolua_unit_set_building); - tolua_variable(tolua_S, "ship", tolua_unit_get_ship, tolua_unit_set_ship); - tolua_variable(tolua_S, "region", tolua_unit_get_region, tolua_unit_set_region); - tolua_variable(tolua_S, "spells", tolua_unit_get_spells, 0); - tolua_variable(tolua_S, "number", tolua_unit_get_number, tolua_unit_set_number); - tolua_variable(tolua_S, "race", tolua_unit_get_race, tolua_unit_set_race); - tolua_variable(tolua_S, "hp_max", tolua_unit_get_hpmax, 0); + 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(tolua_S, "objects", tolua_unit_get_objects, 0); + tolua_variable(L, "objects", tolua_unit_get_objects, 0); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); } diff --git a/src/eressea/tolua/bind_unit.h b/src/eressea/tolua/bind_unit.h index 3666dec77..767f4bfd6 100644 --- a/src/eressea/tolua/bind_unit.h +++ b/src/eressea/tolua/bind_unit.h @@ -15,11 +15,11 @@ extern "C" { #endif struct lua_State; - int tolua_unitlist_nextb(struct lua_State *tolua_S); - int tolua_unitlist_nexts(struct lua_State *tolua_S); - int tolua_unitlist_nextf(struct lua_State *tolua_S); - int tolua_unitlist_next(struct lua_State *tolua_S); - void tolua_unit_open(struct lua_State *tolua_S); + int tolua_unitlist_nextb(struct lua_State *L); + int tolua_unitlist_nexts(struct lua_State *L); + int tolua_unitlist_nextf(struct lua_State *L); + int tolua_unitlist_next(struct lua_State *L); + void tolua_unit_open(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/bindings.c b/src/eressea/tolua/bindings.c index 58755b090..890ed6d6b 100644 --- a/src/eressea/tolua/bindings.c +++ b/src/eressea/tolua/bindings.c @@ -61,38 +61,38 @@ without prior permission by the authors of Eressea. #include #include -int tolua_orderlist_next(lua_State *tolua_S) +int tolua_orderlist_next(lua_State *L) { - order** order_ptr = (order **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + order** order_ptr = (order **)lua_touserdata(L, lua_upvalueindex(1)); order* ord = *order_ptr; if (ord != NULL) { char cmd[8192]; write_order(ord, cmd, sizeof(cmd)); - tolua_pushstring(tolua_S, cmd); + tolua_pushstring(L, cmd); *order_ptr = ord->next; return 1; } else return 0; /* no more values to return */ } -int tolua_spelllist_next(lua_State *tolua_S) +int tolua_spelllist_next(lua_State *L) { - spell_list** spell_ptr = (spell_list **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + spell_list** spell_ptr = (spell_list **)lua_touserdata(L, lua_upvalueindex(1)); spell_list* slist = *spell_ptr; if (slist != NULL) { - tolua_pushusertype(tolua_S, slist->data, "spell"); + tolua_pushusertype(L, slist->data, "spell"); *spell_ptr = slist->next; return 1; } else return 0; /* no more values to return */ } -int tolua_itemlist_next(lua_State *tolua_S) +int tolua_itemlist_next(lua_State *L) { - item** item_ptr = (item **)lua_touserdata(tolua_S, lua_upvalueindex(1)); + item** item_ptr = (item **)lua_touserdata(L, lua_upvalueindex(1)); item* itm = *item_ptr; if (itm != NULL) { - tolua_pushstring(tolua_S, itm->type->rtype->_name[0]); + tolua_pushstring(L, itm->type->rtype->_name[0]); *item_ptr = itm->next; return 1; } @@ -100,10 +100,10 @@ int tolua_itemlist_next(lua_State *tolua_S) } static int -tolua_autoseed(lua_State * tolua_S) +tolua_autoseed(lua_State * L) { - const char * filename = tolua_tostring(tolua_S, 1, 0); - int new_island = tolua_toboolean(tolua_S, 2, 0); + const char * filename = tolua_tostring(L, 1, 0); + int new_island = tolua_toboolean(L, 2, 0); newfaction * players = read_newfactions(filename); if (players!=NULL) { @@ -122,22 +122,22 @@ tolua_autoseed(lua_State * tolua_S) static int -tolua_getkey(lua_State* tolua_S) +tolua_getkey(lua_State* L) { - const char * name = tolua_tostring(tolua_S, 1, 0); + const char * name = tolua_tostring(L, 1, 0); int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); - lua_pushboolean(tolua_S, a!=NULL); + lua_pushboolean(L, a!=NULL); return 1; } static int -tolua_setkey(lua_State* tolua_S) +tolua_setkey(lua_State* L) { - const char * name = tolua_tostring(tolua_S, 1, 0); - int value = tolua_toboolean(tolua_S, 2, 0); + const char * name = tolua_tostring(L, 1, 0); + int value = tolua_toboolean(L, 2, 0); int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); @@ -151,53 +151,53 @@ tolua_setkey(lua_State* tolua_S) } static int -tolua_rng_int(lua_State* tolua_S) +tolua_rng_int(lua_State* L) { - lua_pushnumber(tolua_S, (lua_Number)rng_int()); + lua_pushnumber(L, (lua_Number)rng_int()); return 1; } static int -tolua_read_orders(lua_State* tolua_S) +tolua_read_orders(lua_State* L) { - const char * filename = tolua_tostring(tolua_S, 1, 0); + const char * filename = tolua_tostring(L, 1, 0); int result = readorders(filename); - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_message_unit(lua_State* tolua_S) +tolua_message_unit(lua_State* L) { - unit * sender = (unit *)tolua_tousertype(tolua_S, 1, 0); - unit * target = (unit *)tolua_tousertype(tolua_S, 2, 0); - const char * str = tolua_tostring(tolua_S, 3, 0); - if (!target) tolua_error(tolua_S, "target is nil", NULL); - if (!sender) tolua_error(tolua_S, "sender is nil", NULL); + 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); deliverMail(target->faction, sender->region, sender, str, target); return 0; } static int -tolua_message_faction(lua_State * tolua_S) +tolua_message_faction(lua_State * L) { - unit * sender = (unit *)tolua_tousertype(tolua_S, 1, 0); - faction * target = (faction *)tolua_tousertype(tolua_S, 2, 0); - const char * str = tolua_tostring(tolua_S, 3, 0); - if (!target) tolua_error(tolua_S, "target is nil", NULL); - if (!sender) tolua_error(tolua_S, "sender is nil", NULL); + 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); deliverMail(target, sender->region, sender, str, NULL); return 0; } static int -tolua_message_region(lua_State * tolua_S) +tolua_message_region(lua_State * L) { - unit * sender = (unit *)tolua_tousertype(tolua_S, 1, 0); - const char * str = tolua_tostring(tolua_S, 2, 0); + unit * sender = (unit *)tolua_tousertype(L, 1, 0); + const char * str = tolua_tostring(L, 2, 0); - if (!sender) tolua_error(tolua_S, "sender is nil", NULL); + if (!sender) tolua_error(L, "sender is nil", NULL); ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message", sender, str)); return 0; @@ -235,61 +235,61 @@ call_script(lua_State * L, struct unit * u) } static void -setscript(lua_State * tolua_S, struct attrib ** ap) +setscript(lua_State * L, struct attrib ** ap) { attrib * a = a_find(*ap, &at_script); if (a == NULL) { a = a_add(ap, a_new(&at_script)); } else if (a->data.i>0) { - luaL_unref(tolua_S, LUA_REGISTRYINDEX, a->data.i); + luaL_unref(L, LUA_REGISTRYINDEX, a->data.i); } - a->data.i = luaL_ref(tolua_S, LUA_REGISTRYINDEX); + a->data.i = luaL_ref(L, LUA_REGISTRYINDEX); } static int -tolua_update_guards(lua_State * tolua_S) +tolua_update_guards(lua_State * L) { update_guards(); return 0; } static int -tolua_get_turn(lua_State * tolua_S) +tolua_get_turn(lua_State * L) { - tolua_pushnumber(tolua_S, (lua_Number)turn); + tolua_pushnumber(L, (lua_Number)turn); return 1; } static int -tolua_atoi36(lua_State * tolua_S) +tolua_atoi36(lua_State * L) { - const char * s = tolua_tostring(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)atoi36(s)); + const char * s = tolua_tostring(L, 1, 0); + tolua_pushnumber(L, (lua_Number)atoi36(s)); return 1; } static int -tolua_itoa36(lua_State * tolua_S) +tolua_itoa36(lua_State * L) { - int i = (int)tolua_tonumber(tolua_S, 1, 0); - tolua_pushstring(tolua_S, itoa36(i)); + int i = (int)tolua_tonumber(L, 1, 0); + tolua_pushstring(L, itoa36(i)); return 1; } static int -tolua_dice_rand(lua_State * tolua_S) +tolua_dice_rand(lua_State * L) { - const char * s = tolua_tostring(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, dice_rand(s)); + const char * s = tolua_tostring(L, 1, 0); + tolua_pushnumber(L, dice_rand(s)); return 1; } static int -tolua_addequipment(lua_State * tolua_S) +tolua_addequipment(lua_State * L) { - 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); + const char * eqname = tolua_tostring(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); + const char * value = tolua_tostring(L, 3, 0); int result = -1; if (iname!=NULL) { const struct item_type * itype = it_find(iname); @@ -298,26 +298,26 @@ tolua_addequipment(lua_State * tolua_S) result = 0; } } - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_get_season(lua_State * tolua_S) +tolua_get_season(lua_State * L) { - int turnno = (int)tolua_tonumber(tolua_S, 1, 0); + int turnno = (int)tolua_tonumber(L, 1, 0); gamedate gd; get_gamedate(turnno, &gd); - tolua_pushstring(tolua_S, seasonnames[gd.season]); + tolua_pushstring(L, seasonnames[gd.season]); return 1; } static int -tolua_learn_skill(lua_State * tolua_S) +tolua_learn_skill(lua_State * L) { - unit * u = (unit *)tolua_tousertype(tolua_S, 1, 0); - const char * skname = tolua_tostring(tolua_S, 2, 0); - float chances = (float)tolua_tonumber(tolua_S, 3, 0); + unit * u = (unit *)tolua_tousertype(L, 1, 0); + const char * skname = tolua_tostring(L, 2, 0); + float chances = (float)tolua_tonumber(L, 3, 0); skill_t sk = sk_find(skname); if (sk!=NOSKILL) { learn_skill(u, sk, chances); @@ -326,14 +326,14 @@ tolua_learn_skill(lua_State * tolua_S) } static int -tolua_update_scores(lua_State * tolua_S) +tolua_update_scores(lua_State * L) { score(); return 0; } static int -tolua_update_owners(lua_State * tolua_S) +tolua_update_owners(lua_State * L) { region * r; for (r=regions;r;r=r->next) { @@ -343,39 +343,39 @@ tolua_update_owners(lua_State * tolua_S) } static int -tolua_update_subscriptions(lua_State * tolua_S) +tolua_update_subscriptions(lua_State * L) { update_subscriptions(); return 0; } static int -tolua_remove_empty_units(lua_State * tolua_S) +tolua_remove_empty_units(lua_State * L) { remove_empty_units(); return 0; } static int -tolua_get_nmrs(lua_State * tolua_S) +tolua_get_nmrs(lua_State * L) { int result = -1; - int n = (int)tolua_tonumber(tolua_S, 1, 0); + int n = (int)tolua_tonumber(L, 1, 0); if (n<=NMRTimeout()) { if (nmrs==NULL) { update_nmrs(); result = nmrs[n]; } } - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_equipunit(lua_State * tolua_S) +tolua_equipunit(lua_State * L) { - unit * u = (unit *)tolua_tousertype(tolua_S, 1, 0); - const char * eqname = tolua_tostring(tolua_S, 2, 0); + unit * u = (unit *)tolua_tousertype(L, 1, 0); + const char * eqname = tolua_tostring(L, 2, 0); equip_unit(u, get_equipment(eqname)); @@ -383,12 +383,12 @@ tolua_equipunit(lua_State * tolua_S) } static int -tolua_equipment_setitem(lua_State * tolua_S) +tolua_equipment_setitem(lua_State * L) { int result = -1; - 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); + const char * eqname = tolua_tostring(L, 1, 0); + const char * iname = tolua_tostring(L, 2, 0); + const char * value = tolua_tostring(L, 3, 0); if (iname!=NULL) { const struct item_type * itype = it_find(iname); if (itype!=NULL) { @@ -396,72 +396,72 @@ tolua_equipment_setitem(lua_State * tolua_S) result = 0; } } - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_levitate_ship(lua_State * tolua_S) +tolua_levitate_ship(lua_State * L) { - ship * sh = (ship *)tolua_tousertype(tolua_S, 1, 0); - unit * mage = (unit *)tolua_tousertype(tolua_S, 2, 0); - double power = (double)tolua_tonumber(tolua_S, 3, 0); - int duration = (int)tolua_tonumber(tolua_S, 4, 0); + ship * sh = (ship *)tolua_tousertype(L, 1, 0); + unit * mage = (unit *)tolua_tousertype(L, 2, 0); + double power = (double)tolua_tonumber(L, 3, 0); + int duration = (int)tolua_tonumber(L, 4, 0); int cno = levitate_ship(sh, mage, power, duration); - tolua_pushnumber(tolua_S, (lua_Number)cno); + tolua_pushnumber(L, (lua_Number)cno); return 1; } static int -tolua_set_unitscript(lua_State * tolua_S) +tolua_set_unitscript(lua_State * L) { - struct unit * u = (struct unit *)tolua_tousertype(tolua_S, 1, 0); + struct unit * u = (struct unit *)tolua_tousertype(L, 1, 0); if (u) { - lua_pushvalue(tolua_S, 2); - setscript(tolua_S, &u->attribs); - lua_pop(tolua_S, 1); + lua_pushvalue(L, 2); + setscript(L, &u->attribs); + lua_pop(L, 1); } return 0; } static int -tolua_set_racescript(lua_State * tolua_S) +tolua_set_racescript(lua_State * L) { - const char * rcname = tolua_tostring(tolua_S, 1, 0); + const char * rcname = tolua_tostring(L, 1, 0); race * rc = rc_find(rcname); if (rc!=NULL) { - lua_pushvalue(tolua_S, 2); - setscript(tolua_S, &rc->attribs); - lua_pop(tolua_S, 1); + lua_pushvalue(L, 2); + setscript(L, &rc->attribs); + lua_pop(L, 1); } return 0; } static int -tolua_spawn_dragons(lua_State * tolua_S) +tolua_spawn_dragons(lua_State * L) { spawn_dragons(); return 0; } static int -tolua_spawn_undead(lua_State * tolua_S) +tolua_spawn_undead(lua_State * L) { spawn_undead(); return 0; } static int -tolua_spawn_braineaters(lua_State * tolua_S) +tolua_spawn_braineaters(lua_State * L) { - float chance = (float)tolua_tonumber(tolua_S, 1, 0); + float chance = (float)tolua_tonumber(L, 1, 0); spawn_braineaters(chance); return 0; } static int -tolua_planmonsters(lua_State * tolua_S) +tolua_planmonsters(lua_State * L) { faction * f = get_monsters(); @@ -469,7 +469,7 @@ tolua_planmonsters(lua_State * tolua_S) unit * u; plan_monsters(); for (u=f->units;u;u=u->nextF) { - call_script(tolua_S, u); + call_script(L, u); } } @@ -477,61 +477,61 @@ tolua_planmonsters(lua_State * tolua_S) } static int -tolua_init_reports(lua_State* tolua_S) +tolua_init_reports(lua_State* L) { int result = init_reports(); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_write_report(lua_State* tolua_S) +tolua_write_report(lua_State* L) { - faction * f = (faction * )tolua_tousertype(tolua_S, 1, 0); + faction * f = (faction * )tolua_tousertype(L, 1, 0); time_t ltime = time(0); int result = write_reports(f, ltime); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_write_reports(lua_State* tolua_S) +tolua_write_reports(lua_State* L) { int result; init_reports(); result = reports(); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_process_orders(lua_State* tolua_S) +tolua_process_orders(lua_State* L) { ++turn; processorders(); return 0; } static int -tolua_write_passwords(lua_State* tolua_S) +tolua_write_passwords(lua_State* L) { int result = writepasswd(); - lua_pushnumber(tolua_S, (lua_Number)result); + lua_pushnumber(L, (lua_Number)result); return 0; } static struct summary * sum_begin = 0; static int -tolua_init_summary(lua_State* tolua_S) +tolua_init_summary(lua_State* L) { sum_begin = make_summary(); return 0; } static int -tolua_write_summary(lua_State* tolua_S) +tolua_write_summary(lua_State* L) { if (sum_begin) { struct summary * sum_end = make_summary(); @@ -543,185 +543,185 @@ tolua_write_summary(lua_State* tolua_S) } static int -tolua_free_game(lua_State* tolua_S) +tolua_free_game(lua_State* L) { free_gamedata(); return 0; } static int -tolua_write_game(lua_State* tolua_S) +tolua_write_game(lua_State* L) { - const char * filename = tolua_tostring(tolua_S, 1, 0); - const char * mode = tolua_tostring(tolua_S, 2, 0); + const char * filename = tolua_tostring(L, 1, 0); + const char * mode = tolua_tostring(L, 2, 0); int result, m = IO_BINARY; if (mode && strcmp(mode, "text")==0) m = IO_TEXT; remove_empty_factions(true); result = writegame(filename, m); - tolua_pushnumber(tolua_S, (lua_Number)result); + tolua_pushnumber(L, (lua_Number)result); return 1; } static int -tolua_read_game(lua_State* tolua_S) +tolua_read_game(lua_State* L) { - const char * filename = tolua_tostring(tolua_S, 1, 0); - const char * mode = tolua_tostring(tolua_S, 2, 0); + const char * filename = tolua_tostring(L, 1, 0); + const char * mode = tolua_tostring(L, 2, 0); int rv, m = IO_BINARY; if (mode && strcmp(mode, "text")==0) m = IO_TEXT; rv = readgame(filename, m, false); - tolua_pushnumber(tolua_S, (lua_Number)rv); + tolua_pushnumber(L, (lua_Number)rv); return 1; } static int -tolua_get_faction(lua_State* tolua_S) +tolua_get_faction(lua_State* L) { - int no = tolua_toid(tolua_S, 1, 0); + int no = tolua_toid(L, 1, 0); faction * f = findfaction(no); - tolua_pushusertype(tolua_S, f, "faction"); + tolua_pushusertype(L, f, "faction"); return 1; } static int -tolua_get_region(lua_State* tolua_S) +tolua_get_region(lua_State* L) { - short x = (short)tolua_tonumber(tolua_S, 1, 0); - short y = (short)tolua_tonumber(tolua_S, 2, 0); + short x = (short)tolua_tonumber(L, 1, 0); + short y = (short)tolua_tonumber(L, 2, 0); region * r = findregion(x, y); - tolua_pushusertype(tolua_S, r, "region"); + tolua_pushusertype(L, r, "region"); return 1; } static int -tolua_get_region_byid(lua_State* tolua_S) +tolua_get_region_byid(lua_State* L) { - int uid = (int)tolua_tonumber(tolua_S, 1, 0); + int uid = (int)tolua_tonumber(L, 1, 0); region * r = findregionbyid(uid); - tolua_pushusertype(tolua_S, r, "region"); + tolua_pushusertype(L, r, "region"); return 1; } static int -tolua_get_building(lua_State* tolua_S) +tolua_get_building(lua_State* L) { - int no = tolua_toid(tolua_S, 1, 0); + int no = tolua_toid(L, 1, 0); building * b = findbuilding(no); - tolua_pushusertype(tolua_S, b, "building"); + tolua_pushusertype(L, b, "building"); return 1; } static int -tolua_get_ship(lua_State* tolua_S) +tolua_get_ship(lua_State* L) { - int no = tolua_toid(tolua_S, 1, 0); + int no = tolua_toid(L, 1, 0); ship * sh = findship(no); - tolua_pushusertype(tolua_S, sh, "ship"); + tolua_pushusertype(L, sh, "ship"); return 1; } static int -tolua_get_alliance(lua_State* tolua_S) +tolua_get_alliance(lua_State* L) { - int no = tolua_toid(tolua_S, 1, 0); + int no = tolua_toid(L, 1, 0); alliance * f = findalliance(no); - tolua_pushusertype(tolua_S, f, "alliance"); + tolua_pushusertype(L, f, "alliance"); return 1; } static int -tolua_get_unit(lua_State* tolua_S) +tolua_get_unit(lua_State* L) { - int no = tolua_toid(tolua_S, 1, 0); + int no = tolua_toid(L, 1, 0); unit * u = findunit(no); - tolua_pushusertype(tolua_S, u, "unit"); + tolua_pushusertype(L, u, "unit"); return 1; } static int -tolua_alliance_create(lua_State* tolua_S) +tolua_alliance_create(lua_State* L) { - int id = (int)tolua_tonumber(tolua_S, 1, 0); - const char * name = tolua_tostring(tolua_S, 2, 0); + int id = (int)tolua_tonumber(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); alliance * alli = makealliance(id, name); - tolua_pushusertype(tolua_S, alli, "alliance"); + tolua_pushusertype(L, alli, "alliance"); return 1; } static int -tolua_get_regions(lua_State* tolua_S) +tolua_get_regions(lua_State* L) { - region ** region_ptr = (region**)lua_newuserdata(tolua_S, sizeof(region *)); + region ** region_ptr = (region**)lua_newuserdata(L, sizeof(region *)); - luaL_getmetatable(tolua_S, "region"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "region"); + lua_setmetatable(L, -2); *region_ptr = regions; - lua_pushcclosure(tolua_S, tolua_regionlist_next, 1); + lua_pushcclosure(L, tolua_regionlist_next, 1); return 1; } static int -tolua_get_factions(lua_State* tolua_S) +tolua_get_factions(lua_State* L) { - faction ** faction_ptr = (faction**)lua_newuserdata(tolua_S, sizeof(faction *)); + faction ** faction_ptr = (faction**)lua_newuserdata(L, sizeof(faction *)); - luaL_getmetatable(tolua_S, "faction"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "faction"); + lua_setmetatable(L, -2); *faction_ptr = factions; - lua_pushcclosure(tolua_S, tolua_factionlist_next, 1); + lua_pushcclosure(L, tolua_factionlist_next, 1); return 1; } static int -tolua_get_alliance_factions(lua_State* tolua_S) +tolua_get_alliance_factions(lua_State* L) { - alliance * self = (alliance *)tolua_tousertype(tolua_S, 1, 0); - faction_list ** faction_ptr = (faction_list**)lua_newuserdata(tolua_S, sizeof(faction_list *)); + alliance * self = (alliance *)tolua_tousertype(L, 1, 0); + faction_list ** faction_ptr = (faction_list**)lua_newuserdata(L, sizeof(faction_list *)); - luaL_getmetatable(tolua_S, "faction_list"); - lua_setmetatable(tolua_S, -2); + luaL_getmetatable(L, "faction_list"); + lua_setmetatable(L, -2); *faction_ptr = self->members; - lua_pushcclosure(tolua_S, tolua_factionlist_iter, 1); + lua_pushcclosure(L, tolua_factionlist_iter, 1); return 1; } -static int tolua_get_alliance_id(lua_State* tolua_S) +static int tolua_get_alliance_id(lua_State* L) { - alliance* self = (alliance*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushnumber(tolua_S, (lua_Number)self->id); + alliance* self = (alliance*) tolua_tousertype(L, 1, 0); + tolua_pushnumber(L, (lua_Number)self->id); return 1; } -static int tolua_get_alliance_name(lua_State* tolua_S) +static int tolua_get_alliance_name(lua_State* L) { - alliance* self = (alliance*) tolua_tousertype(tolua_S, 1, 0); - tolua_pushstring(tolua_S, self->name); + alliance* self = (alliance*) tolua_tousertype(L, 1, 0); + tolua_pushstring(L, self->name); return 1; } -static int tolua_set_alliance_name(lua_State* tolua_S) +static int tolua_set_alliance_name(lua_State* L) { - alliance* self = (alliance*)tolua_tousertype(tolua_S, 1, 0); - alliance_setname(self, tolua_tostring(tolua_S, 2, 0)); + alliance* self = (alliance*)tolua_tousertype(L, 1, 0); + alliance_setname(self, tolua_tostring(L, 2, 0)); return 0; } @@ -731,7 +731,7 @@ static int tolua_set_alliance_name(lua_State* tolua_S) #include static int -tolua_write_spells(lua_State* tolua_S) +tolua_write_spells(lua_State* L) { spell_f fun = (spell_f)get_function("lua_castspell"); const char * filename = "magic.xml"; @@ -788,169 +788,169 @@ tolua_write_spells(lua_State* tolua_S) } static int -tolua_get_spell_text(lua_State *tolua_S) +tolua_get_spell_text(lua_State *L) { const struct locale * loc = default_locale; - spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, spell_info(self, loc)); + spell * self = (spell *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, spell_info(self, loc)); return 1; } static int -tolua_get_spell_school(lua_State *tolua_S) +tolua_get_spell_school(lua_State *L) { - spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, magic_school[self->magietyp]); + spell * self = (spell *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, magic_school[self->magietyp]); return 1; } static int -tolua_get_spell_level(lua_State *tolua_S) +tolua_get_spell_level(lua_State *L) { - spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); - lua_pushnumber(tolua_S, self->level); + spell * self = (spell *)tolua_tousertype(L, 1, 0); + lua_pushnumber(L, self->level); return 1; } static int -tolua_get_spell_name(lua_State *tolua_S) +tolua_get_spell_name(lua_State *L) { const struct locale * lang = default_locale; - spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); - lua_pushstring(tolua_S, spell_name(self, lang)); + spell * self = (spell *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, spell_name(self, lang)); return 1; } -static int tolua_get_spells(lua_State* tolua_S) +static int tolua_get_spells(lua_State* L) { spell_list * slist = spells; if (slist) { - spell_list ** spell_ptr = (spell_list **)lua_newuserdata(tolua_S, sizeof(spell_list *)); - luaL_getmetatable(tolua_S, "spell_list"); - lua_setmetatable(tolua_S, -2); + spell_list ** spell_ptr = (spell_list **)lua_newuserdata(L, sizeof(spell_list *)); + luaL_getmetatable(L, "spell_list"); + lua_setmetatable(L, -2); *spell_ptr = slist; - lua_pushcclosure(tolua_S, tolua_spelllist_next, 1); + lua_pushcclosure(L, tolua_spelllist_next, 1); return 1; } - lua_pushnil(tolua_S); + lua_pushnil(L); return 1; } int -tolua_eressea_open(lua_State* tolua_S) +tolua_eressea_open(lua_State* L) { - tolua_open(tolua_S); + tolua_open(L); /* register user types */ - tolua_usertype(tolua_S, "spell"); - tolua_usertype(tolua_S, "spell_list"); - tolua_usertype(tolua_S, "order"); - tolua_usertype(tolua_S, "item"); - tolua_usertype(tolua_S, "alliance"); - tolua_usertype(tolua_S, "event"); + 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_module(tolua_S, NULL, 0); - tolua_beginmodule(tolua_S, NULL); + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); { - tolua_cclass(tolua_S, "alliance", "alliance", "", NULL); - tolua_beginmodule(tolua_S, "alliance"); + tolua_cclass(L, "alliance", "alliance", "", NULL); + tolua_beginmodule(L, "alliance"); { - 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_function(tolua_S, "create", tolua_alliance_create); + 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_endmodule(tolua_S); + tolua_endmodule(L); - tolua_cclass(tolua_S, "spell", "spell", "", NULL); - tolua_beginmodule(tolua_S, "spell"); + tolua_cclass(L, "spell", "spell", "", NULL); + tolua_beginmodule(L, "spell"); { - tolua_function(tolua_S, "__tostring", tolua_get_spell_name); - tolua_variable(tolua_S, "name", tolua_get_spell_name, 0); - tolua_variable(tolua_S, "school", tolua_get_spell_school, 0); - tolua_variable(tolua_S, "level", tolua_get_spell_level, 0); - tolua_variable(tolua_S, "text", tolua_get_spell_text, 0); + 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_endmodule(tolua_S); + tolua_endmodule(L); - tolua_function(tolua_S, "get_region_by_id", tolua_get_region_byid); + tolua_function(L, "get_region_by_id", tolua_get_region_byid); - tolua_function(tolua_S, "get_faction", tolua_get_faction); - tolua_function(tolua_S, "get_unit", tolua_get_unit); - tolua_function(tolua_S, "get_alliance", tolua_get_alliance); - tolua_function(tolua_S, "get_ship", tolua_get_ship), - tolua_function(tolua_S, "get_building", tolua_get_building), - tolua_function(tolua_S, "get_region", tolua_get_region), + 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), - // deprecated_function(tolua_S, "add_faction"); - // deprecated_function(tolua_S, "faction_origin"); - tolua_function(tolua_S, "factions", tolua_get_factions); - tolua_function(tolua_S, "regions", tolua_get_regions); + // deprecated_function(L, "add_faction"); + // deprecated_function(L, "faction_origin"); + tolua_function(L, "factions", tolua_get_factions); + tolua_function(L, "regions", tolua_get_regions); - tolua_function(tolua_S, "read_game", tolua_read_game); - tolua_function(tolua_S, "write_game", tolua_write_game); - tolua_function(tolua_S, "free_game", tolua_free_game); + 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(tolua_S, "read_orders", tolua_read_orders); - tolua_function(tolua_S, "process_orders", tolua_process_orders); + tolua_function(L, "read_orders", tolua_read_orders); + tolua_function(L, "process_orders", tolua_process_orders); - tolua_function(tolua_S, "init_reports", tolua_init_reports); - tolua_function(tolua_S, "write_reports", tolua_write_reports); - tolua_function(tolua_S, "write_report", tolua_write_report); + 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(tolua_S, "init_summary", tolua_init_summary); - tolua_function(tolua_S, "write_summary", tolua_write_summary); - tolua_function(tolua_S, "write_passwords", tolua_write_passwords), + 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(tolua_S, "message_unit", tolua_message_unit); - tolua_function(tolua_S, "message_faction", tolua_message_faction); - tolua_function(tolua_S, "message_region", tolua_message_region); + tolua_function(L, "message_unit", tolua_message_unit); + tolua_function(L, "message_faction", tolua_message_faction); + tolua_function(L, "message_region", tolua_message_region); /* scripted monsters */ - tolua_function(tolua_S, "plan_monsters", tolua_planmonsters); - tolua_function(tolua_S, "spawn_braineaters", tolua_spawn_braineaters); - tolua_function(tolua_S, "spawn_undead", tolua_spawn_undead); - tolua_function(tolua_S, "spawn_dragons", tolua_spawn_dragons); + 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(tolua_S, "set_race_brain", tolua_set_racescript); - tolua_function(tolua_S, "set_unit_brain", tolua_set_unitscript); + tolua_function(L, "set_race_brain", tolua_set_racescript); + tolua_function(L, "set_unit_brain", tolua_set_unitscript); /* spells and stuff */ - tolua_function(tolua_S, "levitate_ship", tolua_levitate_ship); + tolua_function(L, "levitate_ship", tolua_levitate_ship); - tolua_function(tolua_S, "update_guards", tolua_update_guards); + tolua_function(L, "update_guards", tolua_update_guards); - tolua_function(tolua_S, "get_turn", tolua_get_turn); - tolua_function(tolua_S, "get_season", tolua_get_season); + tolua_function(L, "get_turn", tolua_get_turn); + tolua_function(L, "get_season", tolua_get_season); - tolua_function(tolua_S, "equipment_setitem", tolua_equipment_setitem); - tolua_function(tolua_S, "equip_unit", tolua_equipunit); - tolua_function(tolua_S, "add_equipment", tolua_addequipment); + tolua_function(L, "equipment_setitem", tolua_equipment_setitem); + tolua_function(L, "equip_unit", tolua_equipunit); + tolua_function(L, "add_equipment", tolua_addequipment); - tolua_function(tolua_S, "atoi36", tolua_atoi36); - tolua_function(tolua_S, "itoa36", tolua_itoa36); - tolua_function(tolua_S, "dice_roll", tolua_dice_rand); + tolua_function(L, "atoi36", tolua_atoi36); + tolua_function(L, "itoa36", tolua_itoa36); + tolua_function(L, "dice_roll", tolua_dice_rand); - tolua_function(tolua_S, "get_nmrs", tolua_get_nmrs); - tolua_function(tolua_S, "remove_empty_units", tolua_remove_empty_units); + tolua_function(L, "get_nmrs", tolua_get_nmrs); + tolua_function(L, "remove_empty_units", tolua_remove_empty_units); - tolua_function(tolua_S, "update_subscriptions", tolua_update_subscriptions); - tolua_function(tolua_S, "update_scores", tolua_update_scores); - tolua_function(tolua_S, "update_owners", tolua_update_owners); + 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(tolua_S, "learn_skill", tolua_learn_skill); + tolua_function(L, "learn_skill", tolua_learn_skill); - tolua_function(tolua_S, "autoseed", tolua_autoseed); + tolua_function(L, "autoseed", tolua_autoseed); - tolua_function(tolua_S, "get_key", tolua_getkey); - tolua_function(tolua_S, "set_key", tolua_setkey); + tolua_function(L, "get_key", tolua_getkey); + tolua_function(L, "set_key", tolua_setkey); - tolua_function(tolua_S, "rng_int", tolua_rng_int); + tolua_function(L, "rng_int", tolua_rng_int); - tolua_function(tolua_S, "spells", tolua_get_spells); - tolua_function(tolua_S, "write_spells", tolua_write_spells); + tolua_function(L, "spells", tolua_get_spells); + tolua_function(L, "write_spells", tolua_write_spells); } - tolua_endmodule(tolua_S); + tolua_endmodule(L); return 1; } diff --git a/src/eressea/tolua/bindings.h b/src/eressea/tolua/bindings.h index 84539f654..61a879159 100644 --- a/src/eressea/tolua/bindings.h +++ b/src/eressea/tolua/bindings.h @@ -15,10 +15,10 @@ extern "C" { #endif struct lua_State; - int tolua_eressea_open(struct lua_State* tolua_S); - int tolua_spelllist_next(struct lua_State *tolua_S); - int tolua_itemlist_next(struct lua_State *tolua_S); - int tolua_orderlist_next(struct lua_State *tolua_S); + int tolua_eressea_open(struct lua_State* L); + int tolua_spelllist_next(struct lua_State *L); + int tolua_itemlist_next(struct lua_State *L); + int tolua_orderlist_next(struct lua_State *L); #ifdef __cplusplus } diff --git a/src/eressea/tolua/helpers.c b/src/eressea/tolua/helpers.c index 9b83c2a23..661f4742e 100644 --- a/src/eressea/tolua/helpers.c +++ b/src/eressea/tolua/helpers.c @@ -530,14 +530,14 @@ lua_recruit(struct unit * u, const struct archetype * arch, int amount) } int -tolua_toid(lua_State* tolua_S, int idx, int def) +tolua_toid(lua_State* L, int idx, int def) { int no = 0; - int type = lua_type(tolua_S, idx); + int type = lua_type(L, idx); if (type==LUA_TNUMBER) { - no = (int)tolua_tonumber(tolua_S, idx, def); + no = (int)tolua_tonumber(L, idx, def); } else { - const char * str = tolua_tostring(tolua_S, idx, NULL); + const char * str = tolua_tostring(L, idx, NULL); no = str?atoi36(str):def; } return no; diff --git a/src/eressea/tolua/helpers.h b/src/eressea/tolua/helpers.h index 9a0470517..0f22386d9 100644 --- a/src/eressea/tolua/helpers.h +++ b/src/eressea/tolua/helpers.h @@ -15,7 +15,7 @@ extern "C" { #endif void register_tolua_helpers(void); - int tolua_toid(struct lua_State* tolua_S, int idx, int def); + int tolua_toid(struct lua_State* L, int idx, int def); #ifdef __cplusplus }