Commit 1852d138 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro-core

parents 08861e17 132db217
......@@ -382,6 +382,8 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_PIERCE 203
#define EFFECT_BATTLE_DESTROY_REDIRECT 204
#define EFFECT_BATTLE_DAMAGE_TO_EFFECT 205
#define EFFECT_BOTH_BATTLE_DAMAGE 206
#define EFFECT_ALSO_BATTLE_DAMAGE 207
#define EFFECT_TOSS_COIN_REPLACE 220
#define EFFECT_TOSS_DICE_REPLACE 221
#define EFFECT_FUSION_MATERIAL 230
......
......@@ -1150,7 +1150,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--;
......@@ -1169,8 +1169,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);
......@@ -1203,8 +1205,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);
......
......@@ -2077,7 +2077,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
return 0;
duel* pduel = interpreter::get_duel_info(L);
uint32 uplayer = pduel->game_field->core.reason_player;
if(lua_gettop(L) >= 2)
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2))
uplayer = lua_tointeger(L, 2);
bool swapped = false;
card* mcard = 0;
......
......@@ -300,6 +300,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));
}
......
This diff is collapsed.
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