replace pushnumber with pushinteger where applicable (prep for Lua 5.3).

also kill an unreferenced string.
This commit is contained in:
Enno Rehling 2015-06-08 20:53:40 +02:00
parent 69a23d58c9
commit 2967cd59cf
13 changed files with 66 additions and 71 deletions

View File

@ -275,11 +275,6 @@
</string> </string>
</namespace> </namespace>
<string name="Tresen">
<text locale="de">Tresen</text>
<text locale="en">counter</text>
</string>
<string name="wenige"> <string name="wenige">
<text locale="de">wenige</text> <text locale="de">wenige</text>
<text locale="en">few</text> <text locale="en">few</text>

View File

@ -114,7 +114,7 @@ static int tolua_building_set_name(lua_State * L)
static int tolua_building_get_size(lua_State * L) static int tolua_building_get_size(lua_State * L)
{ {
building *self = (building *)tolua_tousertype(L, 1, 0); building *self = (building *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, self->size); lua_pushinteger(L, self->size);
return 1; return 1;
} }
@ -145,7 +145,7 @@ static int tolua_building_get_units(lua_State * L)
static int tolua_building_get_id(lua_State * L) static int tolua_building_get_id(lua_State * L)
{ {
building *self = (building *)tolua_tousertype(L, 1, 0); building *self = (building *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no); lua_pushinteger(L, self->no);
return 1; return 1;
} }

View File

@ -84,28 +84,28 @@ int tolua_faction_add_item(lua_State * L)
static int tolua_faction_get_maxheroes(lua_State * L) static int tolua_faction_get_maxheroes(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)maxheroes(self)); lua_pushinteger(L, maxheroes(self));
return 1; return 1;
} }
static int tolua_faction_get_heroes(lua_State * L) static int tolua_faction_get_heroes(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)countheroes(self)); lua_pushinteger(L, countheroes(self));
return 1; return 1;
} }
static int tolua_faction_get_score(lua_State * L) static int tolua_faction_get_score(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->score); lua_pushinteger(L, self->score);
return 1; return 1;
} }
static int tolua_faction_get_id(lua_State * L) static int tolua_faction_get_id(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no); lua_pushinteger(L, self->no);
return 1; return 1;
} }
@ -148,7 +148,7 @@ static int tolua_faction_set_magic(lua_State * L)
static int tolua_faction_get_age(lua_State * L) static int tolua_faction_get_age(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->age); lua_pushinteger(L, self->age);
return 1; return 1;
} }
@ -163,7 +163,7 @@ static int tolua_faction_set_age(lua_State * L)
static int tolua_faction_get_flags(lua_State * L) static int tolua_faction_get_flags(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->flags); lua_pushinteger(L, self->flags);
return 1; return 1;
} }
@ -178,7 +178,7 @@ static int tolua_faction_set_flags(lua_State * L)
static int tolua_faction_get_options(lua_State * L) static int tolua_faction_get_options(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->options); lua_pushinteger(L, self->options);
return 1; return 1;
} }
@ -193,7 +193,7 @@ static int tolua_faction_set_options(lua_State * L)
static int tolua_faction_get_lastturn(lua_State * L) static int tolua_faction_get_lastturn(lua_State * L)
{ {
faction *self = (faction *)tolua_tousertype(L, 1, 0); faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->lastorders); lua_pushinteger(L, self->lastorders);
return 1; return 1;
} }
@ -245,7 +245,7 @@ static int tolua_faction_get_policy(lua_State * L)
} }
} }
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -283,8 +283,8 @@ static int tolua_faction_normalize(lua_State * L)
int nx = r->x, ny = r->y; int nx = r->x, ny = r->y;
pnormalize(&nx, &ny, pl); pnormalize(&nx, &ny, pl);
adjust_coordinates(f, &nx, &ny, pl); adjust_coordinates(f, &nx, &ny, pl);
tolua_pushnumber(L, (lua_Number)nx); lua_pushinteger(L, nx);
tolua_pushnumber(L, (lua_Number)ny); lua_pushinteger(L, ny);
return 2; return 2;
} }
return 0; return 0;
@ -319,8 +319,8 @@ static int tolua_faction_get_origin(lua_State * L)
y = 0; y = 0;
} }
tolua_pushnumber(L, (lua_Number)x); lua_pushinteger(L, x);
tolua_pushnumber(L, (lua_Number)y); lua_pushinteger(L, y);
return 2; return 2;
} }
@ -443,7 +443,7 @@ static int tolua_faction_set_name(lua_State * L)
static int tolua_faction_get_uid(lua_State * L) static int tolua_faction_get_uid(lua_State * L)
{ {
faction *f = (faction *)tolua_tousertype(L, 1, 0); faction *f = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, f->subscription); lua_pushinteger(L, f->subscription);
return 1; return 1;
} }

View File

@ -153,7 +153,7 @@ static int tolua_make_island(lua_State * L)
int n = (int)tolua_tonumber(L, 4, s / 3); int n = (int)tolua_tonumber(L, 4, s / 3);
n = build_island_e3(NULL, x, y, n, s); n = build_island_e3(NULL, x, y, n, s);
tolua_pushnumber(L, n); lua_pushinteger(L, n);
return 1; return 1;
} }
@ -166,8 +166,8 @@ static void lua_paint_info(struct window *wnd, const struct state *st)
int nx = st->cursor.x, ny = st->cursor.y; int nx = st->cursor.x, ny = st->cursor.y;
pnormalize(&nx, &ny, st->cursor.pl); pnormalize(&nx, &ny, st->cursor.pl);
lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle); lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle);
tolua_pushnumber(L, nx); lua_pushinteger(L, nx);
tolua_pushnumber(L, ny); lua_pushinteger(L, ny);
if (lua_pcall(L, 2, 1, 0) != 0) { if (lua_pcall(L, 2, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
log_error("paint function failed: %s\n", error); log_error("paint function failed: %s\n", error);

View File

@ -214,7 +214,7 @@ static int tolua_msg_set_string(lua_State * L)
const char *param = tolua_tostring(L, 2, 0); const char *param = tolua_tostring(L, 2, 0);
const char *value = tolua_tostring(L, 3, 0); const char *value = tolua_tostring(L, 3, 0);
int result = msg_set_string(lmsg, param, value); int result = msg_set_string(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -224,7 +224,7 @@ static int tolua_msg_set_int(lua_State * L)
const char *param = tolua_tostring(L, 2, 0); const char *param = tolua_tostring(L, 2, 0);
int value = (int)tolua_tonumber(L, 3, 0); int value = (int)tolua_tonumber(L, 3, 0);
int result = msg_set_int(lmsg, param, value); int result = msg_set_int(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -234,7 +234,7 @@ static int tolua_msg_set_resource(lua_State * L)
const char *param = tolua_tostring(L, 2, 0); const char *param = tolua_tostring(L, 2, 0);
const char *value = tolua_tostring(L, 3, 0); const char *value = tolua_tostring(L, 3, 0);
int result = msg_set_resource(lmsg, param, value); int result = msg_set_resource(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -244,7 +244,7 @@ static int tolua_msg_set_unit(lua_State * L)
const char *param = tolua_tostring(L, 2, 0); const char *param = tolua_tostring(L, 2, 0);
unit *value = (unit *)tolua_tousertype(L, 3, 0); unit *value = (unit *)tolua_tousertype(L, 3, 0);
int result = msg_set_unit(lmsg, param, value); int result = msg_set_unit(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -254,7 +254,7 @@ static int tolua_msg_set_region(lua_State * L)
const char *param = tolua_tostring(L, 2, 0); const char *param = tolua_tostring(L, 2, 0);
region *value = (region *)tolua_tousertype(L, 3, 0); region *value = (region *)tolua_tousertype(L, 3, 0);
int result = msg_set_region(lmsg, param, value); int result = msg_set_region(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -270,7 +270,7 @@ static int tolua_msg_set(lua_State * L)
else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) { else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) {
return tolua_msg_set_unit(L); return tolua_msg_set_unit(L);
} }
tolua_pushnumber(L, (lua_Number)-1); lua_pushinteger(L, -1);
return 1; return 1;
} }
@ -279,7 +279,7 @@ static int tolua_msg_send_region(lua_State * L)
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0); lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
region *r = (region *)tolua_tousertype(L, 2, 0); region *r = (region *)tolua_tousertype(L, 2, 0);
int result = msg_send_region(lmsg, r); int result = msg_send_region(lmsg, r);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -293,7 +293,7 @@ static int tolua_msg_report_action(lua_State * L)
lmsg->msg = msg_create(lmsg->mtype, lmsg->args); lmsg->msg = msg_create(lmsg->mtype, lmsg->args);
} }
result = report_action(r, u, lmsg->msg, flags); result = report_action(r, u, lmsg->msg, flags);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -303,7 +303,7 @@ static int tolua_msg_send_faction(lua_State * L)
faction *f = (faction *)tolua_tousertype(L, 2, 0); faction *f = (faction *)tolua_tousertype(L, 2, 0);
if (f && lmsg) { if (f && lmsg) {
int result = msg_send_faction(lmsg, f); int result = msg_send_faction(lmsg, f);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
return 0; return 0;

View File

@ -21,7 +21,7 @@ static int tolua_levitate_ship(lua_State * L)
float power = (float)tolua_tonumber(L, 3, 0); float power = (float)tolua_tonumber(L, 3, 0);
int duration = (int)tolua_tonumber(L, 4, 0); int duration = (int)tolua_tonumber(L, 4, 0);
int cno = levitate_ship(sh, mage, power, duration); int cno = levitate_ship(sh, mage, power, duration);
tolua_pushnumber(L, (lua_Number)cno); lua_pushinteger(L, cno);
return 1; return 1;
} }

View File

@ -62,7 +62,7 @@ int tolua_regionlist_next(lua_State * L)
static int tolua_region_get_id(lua_State * L) static int tolua_region_get_id(lua_State * L)
{ {
region *self = (region *)tolua_tousertype(L, 1, 0); region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->uid); lua_pushinteger(L, self->uid);
return 1; return 1;
} }
@ -85,14 +85,14 @@ static int tolua_region_set_blocked(lua_State * L)
static int tolua_region_get_x(lua_State * L) static int tolua_region_get_x(lua_State * L)
{ {
region *self = (region *)tolua_tousertype(L, 1, 0); region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->x); lua_pushinteger(L, self->x);
return 1; return 1;
} }
static int tolua_region_get_y(lua_State * L) static int tolua_region_get_y(lua_State * L)
{ {
region *self = (region *)tolua_tousertype(L, 1, 0); region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->y); lua_pushinteger(L, self->y);
return 1; return 1;
} }
@ -199,7 +199,7 @@ static int tolua_region_set_name(lua_State * L)
static int tolua_region_get_morale(lua_State * L) static int tolua_region_get_morale(lua_State * L)
{ {
region *r = (region *)tolua_tousertype(L, 1, 0); region *r = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, region_get_morale(r)); lua_pushinteger(L, region_get_morale(r));
return 1; return 1;
} }
@ -323,7 +323,7 @@ static int tolua_region_get_resourcelevel(lua_State * L)
const rawmaterial *rm; const rawmaterial *rm;
for (rm = r->resources; rm; rm = rm->next) { for (rm = r->resources; rm; rm = rm->next) {
if (rm->type->rtype == rtype) { if (rm->type->rtype == rtype) {
tolua_pushnumber(L, (lua_Number)rm->level); lua_pushinteger(L, rm->level);
return 1; return 1;
} }
} }
@ -389,7 +389,7 @@ static int tolua_region_get_resource(lua_State * L)
} }
} }
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -613,7 +613,7 @@ static int tolua_plane_set_name(lua_State * L)
static int tolua_plane_get_id(lua_State * L) static int tolua_plane_get_id(lua_State * L)
{ {
plane *self = (plane *)tolua_tousertype(L, 1, 0); plane *self = (plane *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->id); lua_pushinteger(L, self->id);
return 1; return 1;
} }
@ -623,8 +623,8 @@ static int tolua_plane_normalize(lua_State * L)
int x = (int)tolua_tonumber(L, 2, 0); int x = (int)tolua_tonumber(L, 2, 0);
int y = (int)tolua_tonumber(L, 3, 0); int y = (int)tolua_tonumber(L, 3, 0);
pnormalize(&x, &y, self); pnormalize(&x, &y, self);
tolua_pushnumber(L, (lua_Number)x); lua_pushinteger(L, x);
tolua_pushnumber(L, (lua_Number)y); lua_pushinteger(L, y);
return 2; return 2;
} }

View File

@ -45,7 +45,7 @@ int tolua_shiplist_next(lua_State * L)
static int tolua_ship_get_id(lua_State * L) static int tolua_ship_get_id(lua_State * L)
{ {
ship *self = (ship *)tolua_tousertype(L, 1, 0); ship *self = (ship *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no); lua_pushinteger(L, self->no);
return 1; return 1;
} }
@ -152,7 +152,7 @@ tolua_ship_tostring(lua_State * L)
static int tolua_ship_get_flags(lua_State * L) static int tolua_ship_get_flags(lua_State * L)
{ {
ship *self = (ship *)tolua_tousertype(L, 1, 0); ship *self = (ship *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->flags); lua_pushinteger(L, self->flags);
return 1; return 1;
} }
@ -179,7 +179,7 @@ static int tolua_ship_get_coast(lua_State * L)
{ {
ship *self = (ship *)tolua_tousertype(L, 1, 0); ship *self = (ship *)tolua_tousertype(L, 1, 0);
if (self->coast) { if (self->coast) {
tolua_pushnumber(L, self->coast); lua_pushinteger(L, self->coast);
return 1; return 1;
} }
return 0; return 0;

View File

@ -44,7 +44,7 @@ static int tolua_db_execute(lua_State * L)
int res = sqlite3_exec(db, sql, 0, 0, 0); int res = sqlite3_exec(db, sql, 0, 0, 0);
tolua_pushnumber(L, (LUA_NUMBER)res); lua_pushinteger(L, res);
return 1; return 1;
} }

View File

@ -77,7 +77,7 @@ static int tolua_storage_read_float(lua_State * L)
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
float num; float num;
READ_FLT(data->store, &num); READ_FLT(data->store, &num);
tolua_pushnumber(L, (lua_Number)num); lua_pushnumber(L, num);
return 1; return 1;
} }
@ -86,7 +86,7 @@ static int tolua_storage_read_int(lua_State * L)
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
int num; int num;
READ_INT(data->store, &num); READ_INT(data->store, &num);
tolua_pushnumber(L, (lua_Number)num); lua_pushinteger(L, num);
return 1; return 1;
} }

View File

@ -160,7 +160,7 @@ static int tolua_unit_set_group(lua_State * L)
{ {
unit *self = (unit *)tolua_tousertype(L, 1, 0); unit *self = (unit *)tolua_tousertype(L, 1, 0);
int result = join_group(self, tolua_tostring(L, 2, 0)); int result = join_group(self, tolua_tostring(L, 2, 0));
tolua_pushnumber(L, result); lua_pushinteger(L, result);
return 1; return 1;
} }

View File

@ -123,7 +123,7 @@ static int tolua_quicklist_iter(lua_State * L)
void *data = ql_get(ql, index); void *data = ql_get(ql, index);
tolua_pushusertype(L, data, TOLUA_CAST type); tolua_pushusertype(L, data, TOLUA_CAST type);
ql_advance(qlp, &index, 1); ql_advance(qlp, &index, 1);
tolua_pushnumber(L, index); lua_pushinteger(L, index);
lua_replace(L, lua_upvalueindex(2)); lua_replace(L, lua_upvalueindex(2));
return 1; return 1;
} }
@ -282,14 +282,14 @@ static int tolua_set_turn(lua_State * L)
static int tolua_get_turn(lua_State * L) static int tolua_get_turn(lua_State * L)
{ {
tolua_pushnumber(L, (lua_Number)turn); lua_pushinteger(L, turn);
return 1; return 1;
} }
static int tolua_atoi36(lua_State * L) static int tolua_atoi36(lua_State * L)
{ {
const char *s = tolua_tostring(L, 1, 0); const char *s = tolua_tostring(L, 1, 0);
tolua_pushnumber(L, (lua_Number)atoi36(s)); lua_pushinteger(L, atoi36(s));
return 1; return 1;
} }
@ -303,7 +303,7 @@ static int tolua_itoa36(lua_State * L)
static int tolua_dice_rand(lua_State * L) static int tolua_dice_rand(lua_State * L)
{ {
const char *s = tolua_tostring(L, 1, 0); const char *s = tolua_tostring(L, 1, 0);
tolua_pushnumber(L, dice_rand(s)); lua_pushinteger(L, dice_rand(s));
return 1; return 1;
} }
@ -320,7 +320,7 @@ static int tolua_addequipment(lua_State * L)
result = 0; result = 0;
} }
} }
lua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -426,7 +426,7 @@ static int tolua_get_nmrs(lua_State * L)
} }
result = nmrs[n]; result = nmrs[n];
} }
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -451,7 +451,7 @@ static int tolua_equipment_setitem(lua_State * L)
result = 0; result = 0;
} }
} }
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -465,7 +465,7 @@ static int tolua_spawn_braineaters(lua_State * L)
static int tolua_init_reports(lua_State * L) static int tolua_init_reports(lua_State * L)
{ {
int result = init_reports(); int result = init_reports();
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -475,7 +475,7 @@ static int tolua_write_report(lua_State * L)
if (f) { if (f) {
time_t ltime = time(0); time_t ltime = time(0);
int result = write_reports(f, ltime); int result = write_reports(f, ltime);
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
} }
else { else {
tolua_pushstring(L, "function expects a faction, got nil"); tolua_pushstring(L, "function expects a faction, got nil");
@ -488,7 +488,7 @@ static int tolua_write_reports(lua_State * L)
int result; int result;
init_reports(); init_reports();
result = reports(); result = reports();
tolua_pushnumber(L, (lua_Number)result); lua_pushinteger(L, result);
return 1; return 1;
} }
@ -568,7 +568,7 @@ static int tolua_write_map(lua_State * L)
static int tolua_read_turn(lua_State * L) static int tolua_read_turn(lua_State * L)
{ {
int cturn = current_turn(); int cturn = current_turn();
tolua_pushnumber(L, (lua_Number)cturn); lua_pushinteger(L, cturn);
return 1; return 1;
} }
@ -661,7 +661,7 @@ static int tolua_get_alliance_factions(lua_State * L)
static int tolua_get_alliance_id(lua_State * L) static int tolua_get_alliance_id(lua_State * L)
{ {
alliance *self = (alliance *)tolua_tousertype(L, 1, 0); alliance *self = (alliance *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->id); lua_pushinteger(L, self->id);
return 1; return 1;
} }
@ -1069,7 +1069,7 @@ static void parse_inifile(lua_State * L, dictionary * d, const char *section)
tolua_pushstring(L, str_value); tolua_pushstring(L, str_value);
} }
else { else {
tolua_pushnumber(L, num_value); lua_pushnumber(L, num_value);
} }
lua_rawset(L, -3); lua_rawset(L, -3);
} }

View File

@ -58,7 +58,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o
tolua_pushusertype(L, s, TOLUA_CAST "unit"); tolua_pushusertype(L, s, TOLUA_CAST "unit");
tolua_pushusertype(L, d, TOLUA_CAST "unit"); tolua_pushusertype(L, d, TOLUA_CAST "unit");
tolua_pushstring(L, iname); tolua_pushstring(L, iname);
tolua_pushnumber(L, (lua_Number)n); lua_pushinteger(L, n);
if (lua_pcall(L, 4, 1, 0) != 0) { if (lua_pcall(L, 4, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
@ -121,7 +121,7 @@ produce_resource(region * r, const resource_type * rtype, int norders)
lua_getglobal(L, fname); lua_getglobal(L, fname);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region"); tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
tolua_pushnumber(L, (lua_Number)norders); lua_pushinteger(L, norders);
if (lua_pcall(L, 2, 0, 0) != 0) { if (lua_pcall(L, 2, 0, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
@ -177,8 +177,8 @@ static int lua_callspell(castorder * co)
int nparam = 4; int nparam = 4;
tolua_pushusertype(L, r, TOLUA_CAST "region"); tolua_pushusertype(L, r, TOLUA_CAST "region");
tolua_pushusertype(L, caster, TOLUA_CAST "unit"); tolua_pushusertype(L, caster, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)co->level); lua_pushinteger(L, co->level);
tolua_pushnumber(L, (lua_Number)co->force); lua_pushnumber(L, co->force);
if (co->sp->parameter && co->par->length) { if (co->sp->parameter && co->par->length) {
const char *synp = co->sp->parameter; const char *synp = co->sp->parameter;
int i = 0; int i = 0;
@ -267,7 +267,7 @@ lua_changeresource(unit * u, const struct resource_type *rtype, int delta)
lua_getglobal(L, fname); lua_getglobal(L, fname);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
tolua_pushusertype(L, u, TOLUA_CAST "unit"); tolua_pushusertype(L, u, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)delta); lua_pushinteger(L, delta);
if (lua_pcall(L, 2, 1, 0) != 0) { if (lua_pcall(L, 2, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
@ -363,7 +363,7 @@ lua_wage(const region * r, const faction * f, const race * rc, int in_turn)
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region"); tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction"); tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
tolua_pushstring(L, rc ? rc->_name : 0); tolua_pushstring(L, rc ? rc->_name : 0);
tolua_pushnumber(L, (lua_Number)in_turn); lua_pushinteger(L, in_turn);
if (lua_pcall(L, 3, 1, 0) != 0) { if (lua_pcall(L, 3, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
@ -416,7 +416,7 @@ static double lua_building_taxes(building * b, int level)
lua_getglobal(L, fname); lua_getglobal(L, fname);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building"); tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
tolua_pushnumber(L, level); lua_pushinteger(L, level);
if (lua_pcall(L, 2, 1, 0) != 0) { if (lua_pcall(L, 2, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
@ -508,7 +508,7 @@ struct order *ord)
lua_getglobal(L, fname); lua_getglobal(L, fname);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit"); tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
tolua_pushnumber(L, (lua_Number)amount); lua_pushinteger(L, amount);
if (lua_pcall(L, 2, 1, 0) != 0) { if (lua_pcall(L, 2, 1, 0) != 0) {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);