Commit 132db217 authored by DailyShana's avatar DailyShana

use lua_tointeger if it's actually an interger

parent 256d78bf
......@@ -1031,7 +1031,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
}
return OPERATION_FAIL;
}
int32 result = std::round(lua_tonumber(current_state, -1));
int32 result = lua_isinteger(current_state, -1) ? lua_tointeger(current_state, -1) : std::round(lua_tonumber(current_state, -1));
lua_pop(current_state, 1);
no_action--;
call_depth--;
......@@ -1050,8 +1050,10 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
call_depth++;
if (call_function(f, param_count, 1)) {
int32 result = 0;
if (lua_isboolean(current_state, -1))
if(lua_isboolean(current_state, -1))
result = lua_toboolean(current_state, -1);
else if(lua_isinteger(current_state, -1))
result = lua_tointeger(current_state, -1);
else
result = std::round(lua_tonumber(current_state, -1));
lua_pop(current_state, 1);
......@@ -1084,8 +1086,10 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
int32 stack_newtop = lua_gettop(current_state);
for (int32 index = stack_top + 1; index <= stack_newtop; ++index) {
int32 return_value = 0;
if (lua_isboolean(current_state, index))
if(lua_isboolean(current_state, index))
return_value = lua_toboolean(current_state, index);
else if(lua_isinteger(current_state, index))
return_value = lua_tointeger(current_state, index);
else
return_value = std::round(lua_tonumber(current_state, index));
result->push_back(return_value);
......
......@@ -266,6 +266,8 @@ int32 scriptlib::effect_set_value(lua_State *L) {
peffect->flag[0] &= ~EFFECT_FLAG_FUNC_VALUE;
if(lua_isboolean(L, 2))
peffect->value = lua_toboolean(L, 2);
else if(lua_isinteger(L, 2))
peffect->value = lua_tointeger(L, 2);
else
peffect->value = std::round(lua_tonumber(L, 2));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment