mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 07:33:40 +00:00
Correct the calls instead
Do not change the released Lua source code. Lua is written as standard C, but we compile it as C++ so we can use exceptions. Change the call sites to avoid the warnings about using a C cast instead of static_cast<int>(). NB: The changes to Wesnoth C++ code will be required to upgrade to Lua 5.3, anyway. This reverts: commit cee3ab208401a439e15004b79b4fa5c5bf9a9e5a Author: Mark de Wever <koraq@xs4all.nl> Date: Sun Feb 5 19:55:32 2012 +0000 Fix compiler warnings.
This commit is contained in:
parent
f88c3b22b8
commit
b8244b0694
@ -113,10 +113,10 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
|
||||
((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
|
||||
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
|
||||
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
|
||||
#define luaL_checkint(L,n) (static_cast<int>(luaL_checkinteger(L, (n))))
|
||||
#define luaL_optint(L,n,d) (static_cast<int>(luaL_optinteger(L, (n), (d))))
|
||||
#define luaL_checklong(L,n) (static_cast<long>(luaL_checkinteger(L, (n))))
|
||||
#define luaL_optlong(L,n,d) (static_cast<long>(luaL_optinteger(L, (n), (d))))
|
||||
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
|
||||
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
|
||||
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
|
||||
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
|
||||
|
||||
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
|
||||
|
||||
|
@ -93,7 +93,7 @@ static int intf_describe_plugins(lua_State * L)
|
||||
|
||||
static int intf_delay(lua_State* L)
|
||||
{
|
||||
unsigned int delay = static_cast<unsigned int>(luaL_checkint(L, 1));
|
||||
unsigned int delay = static_cast<unsigned int>(luaL_checkinteger(L, 1));
|
||||
SDL_Delay(delay);
|
||||
return 0;
|
||||
}
|
||||
|
@ -788,8 +788,8 @@ int game_lua_kernel::intf_highlight_hex(lua_State *L)
|
||||
*/
|
||||
int game_lua_kernel::intf_is_enemy(lua_State *L)
|
||||
{
|
||||
unsigned side_1 = luaL_checkint(L, 1) - 1;
|
||||
unsigned side_2 = luaL_checkint(L, 2) - 1;
|
||||
unsigned side_1 = luaL_checkinteger(L, 1) - 1;
|
||||
unsigned side_2 = luaL_checkinteger(L, 2) - 1;
|
||||
if (side_1 >= teams().size() || side_2 >= teams().size()) return 0;
|
||||
lua_pushboolean(L, teams()[side_1].is_enemy(side_2 + 1));
|
||||
return 1;
|
||||
@ -926,7 +926,7 @@ int game_lua_kernel::intf_get_time_of_day(lua_State *L)
|
||||
|
||||
if(lua_isnumber(L, arg)) {
|
||||
++arg;
|
||||
for_turn = luaL_checkint(L, 1);
|
||||
for_turn = luaL_checkinteger(L, 1);
|
||||
int number_of_turns = tod_man().number_of_turns();
|
||||
if(for_turn < 1 || (number_of_turns != -1 && for_turn > number_of_turns)) {
|
||||
return luaL_argerror(L, 1, "turn number out of range");
|
||||
@ -997,7 +997,7 @@ int game_lua_kernel::intf_get_village_owner(lua_State *L)
|
||||
int game_lua_kernel::intf_set_village_owner(lua_State *L)
|
||||
{
|
||||
map_location loc = luaW_checklocation(L, 1);
|
||||
int new_side = lua_isnoneornil(L, 2) ? 0 : luaL_checkint(L, 2);
|
||||
int new_side = lua_isnoneornil(L, 2) ? 0 : luaL_checkinteger(L, 2);
|
||||
|
||||
if (!board().map().is_village(loc))
|
||||
return 0;
|
||||
@ -1076,7 +1076,7 @@ int game_lua_kernel::intf_get_selected_tile(lua_State *L)
|
||||
*/
|
||||
int game_lua_kernel::intf_get_starting_location(lua_State* L)
|
||||
{
|
||||
const int side = luaL_checkint(L, 1);
|
||||
const int side = luaL_checkinteger(L, 1);
|
||||
if(side < 1 || static_cast<int>(teams().size()) < side)
|
||||
return luaL_argerror(L, 1, "out of bounds");
|
||||
const map_location& starting_pos = board().map().starting_position(side);
|
||||
|
@ -49,13 +49,13 @@ int intf_get_direction(lua_State* L)
|
||||
|
||||
int n = 1;
|
||||
if (nargs == 3) {
|
||||
n = luaL_checkint(L, -1);
|
||||
n = luaL_checkinteger(L, -1);
|
||||
lua_pop(L,1);
|
||||
}
|
||||
|
||||
map_location::DIRECTION d;
|
||||
if (lua_isnumber(L, -1)) {
|
||||
d = map_location::rotate_right(map_location::NORTH, luaL_checkint(L, -1)); //easiest way to correctly convert int to direction
|
||||
d = map_location::rotate_right(map_location::NORTH, static_cast<int>(luaL_checkinteger(L, -1))); //easiest way to correctly convert int to direction
|
||||
lua_pop(L,1);
|
||||
} else if (lua_isstring(L, -1)) {
|
||||
d = map_location::parse_direction(luaL_checkstring(L,-1));
|
||||
@ -114,7 +114,7 @@ int intf_vector_zero(lua_State* L)
|
||||
*/
|
||||
int intf_rotate_right_around_center(lua_State* L)
|
||||
{
|
||||
int k = luaL_checkint(L, -1);
|
||||
int k = luaL_checkinteger(L, -1);
|
||||
lua_pop(L,1);
|
||||
map_location center, loc;
|
||||
if(!luaW_tolocation(L, 1, loc) || !luaW_tolocation(L, 2, center)) {
|
||||
@ -228,7 +228,7 @@ int intf_parse_direction(lua_State* L)
|
||||
*/
|
||||
int intf_write_direction(lua_State* L)
|
||||
{
|
||||
int d = luaL_checkint(L, -1);
|
||||
int d = luaL_checkinteger(L, -1);
|
||||
if (d >= 0 && d < map_location::NDIRECTIONS) {
|
||||
lua_pushstring(L, map_location::write_direction(static_cast<map_location::DIRECTION>(d)).c_str());
|
||||
return 1;
|
||||
|
@ -407,7 +407,7 @@ static int impl_unit_set(lua_State *L)
|
||||
|
||||
if(strcmp(m, "upkeep") == 0) {
|
||||
if(lua_isnumber(L, 3)) {
|
||||
u.set_upkeep(luaL_checkint(L, 3));
|
||||
u.set_upkeep(luaL_checkinteger(L, 3));
|
||||
return 0;
|
||||
}
|
||||
const char* v = luaL_checkstring(L, 3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user