Commit 411112ba authored by nanahira's avatar nanahira

lua53

parent f6fe0d0e
...@@ -42,4 +42,5 @@ struct card_sort { ...@@ -42,4 +42,5 @@ struct card_sort {
bool operator()(void* const & c1, void* const & c2) const; bool operator()(void* const & c1, void* const & c2) const;
}; };
#endif /* COMMON_H_ */ #endif /* COMMON_H_ */
#define lua_tonumberint(L,i) (lua_Integer)(((lua_tonumberx(L, (i), NULL) > 0) ? 0.5 : -0.5) + lua_tonumberx(L, (i), NULL))
...@@ -1010,7 +1010,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg ...@@ -1010,7 +1010,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
} }
return OPERATION_FAIL; return OPERATION_FAIL;
} }
result = lua_tointeger(current_state, -1); result = lua_tonumberint(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -1032,7 +1032,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) { ...@@ -1032,7 +1032,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
if (lua_isboolean(current_state, -1)) if (lua_isboolean(current_state, -1))
result = lua_toboolean(current_state, -1); result = lua_toboolean(current_state, -1);
else else
result = lua_tointeger(current_state, -1); result = lua_tonumberint(current_state, -1);
lua_pop(current_state, 1); lua_pop(current_state, 1);
no_action--; no_action--;
call_depth--; call_depth--;
...@@ -1066,7 +1066,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i ...@@ -1066,7 +1066,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
if (lua_isboolean(current_state, index)) if (lua_isboolean(current_state, index))
return_value = lua_toboolean(current_state, index); return_value = lua_toboolean(current_state, index);
else else
return_value = lua_tointeger(current_state, index); return_value = lua_tonumberint(current_state, index);
result->push_back(return_value); result->push_back(return_value);
} }
lua_settop(current_state, stack_top); lua_settop(current_state, stack_top);
...@@ -1127,7 +1127,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1127,7 +1127,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
if (result == 0) { if (result == 0) {
coroutines.erase(f); coroutines.erase(f);
if(yield_value) if(yield_value)
*yield_value = lua_isboolean(rthread, -1) ? lua_toboolean(rthread, -1) : lua_tointeger(rthread, -1); *yield_value = lua_isboolean(rthread, -1) ? lua_toboolean(rthread, -1) : lua_tonumberint(rthread, -1);
current_state = lua_state; current_state = lua_state;
call_depth--; call_depth--;
if(call_depth == 0) { if(call_depth == 0) {
......
This diff is collapsed.
...@@ -25,12 +25,12 @@ int32 scriptlib::debug_message(lua_State *L) { ...@@ -25,12 +25,12 @@ int32 scriptlib::debug_message(lua_State *L) {
int32 scriptlib::debug_add_card(lua_State *L) { int32 scriptlib::debug_add_card(lua_State *L) {
check_param_count(L, 6); check_param_count(L, 6);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 code = lua_tointeger(L, 1); int32 code = lua_tonumberint(L, 1);
int32 owner = lua_tointeger(L, 2); int32 owner = lua_tonumberint(L, 2);
int32 playerid = lua_tointeger(L, 3); int32 playerid = lua_tonumberint(L, 3);
int32 location = lua_tointeger(L, 4); int32 location = lua_tonumberint(L, 4);
int32 sequence = lua_tointeger(L, 5); int32 sequence = lua_tonumberint(L, 5);
int32 position = lua_tointeger(L, 6); int32 position = lua_tonumberint(L, 6);
int32 proc = lua_toboolean(L, 7); int32 proc = lua_toboolean(L, 7);
if(owner != 0 && owner != 1) if(owner != 0 && owner != 1)
return 0; return 0;
...@@ -77,10 +77,10 @@ int32 scriptlib::debug_add_card(lua_State *L) { ...@@ -77,10 +77,10 @@ int32 scriptlib::debug_add_card(lua_State *L) {
int32 scriptlib::debug_set_player_info(lua_State *L) { int32 scriptlib::debug_set_player_info(lua_State *L) {
check_param_count(L, 4); check_param_count(L, 4);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 playerid = lua_tointeger(L, 1); uint32 playerid = lua_tonumberint(L, 1);
uint32 lp = lua_tointeger(L, 2); uint32 lp = lua_tonumberint(L, 2);
uint32 startcount = lua_tointeger(L, 3); uint32 startcount = lua_tonumberint(L, 3);
uint32 drawcount = lua_tointeger(L, 4); uint32 drawcount = lua_tonumberint(L, 4);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
pduel->game_field->player[playerid].lp = lp; pduel->game_field->player[playerid].lp = lp;
...@@ -92,10 +92,10 @@ int32 scriptlib::debug_pre_summon(lua_State *L) { ...@@ -92,10 +92,10 @@ int32 scriptlib::debug_pre_summon(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 summon_type = lua_tointeger(L, 2); uint32 summon_type = lua_tonumberint(L, 2);
uint8 summon_location = 0; uint8 summon_location = 0;
if(lua_gettop(L) > 2) if(lua_gettop(L) > 2)
summon_location = lua_tointeger(L, 3); summon_location = lua_tonumberint(L, 3);
pcard->summon_info = summon_type | (summon_location << 16); pcard->summon_info = summon_type | (summon_location << 16);
return 0; return 0;
} }
...@@ -130,8 +130,8 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) { ...@@ -130,8 +130,8 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 countertype = lua_tointeger(L, 2); uint32 countertype = lua_tonumberint(L, 2);
uint32 count = lua_tointeger(L, 3); uint32 count = lua_tonumberint(L, 3);
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE; uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = pcard->counters.insert(std::make_pair(cttype, card::counter_map::mapped_type())); auto pr = pcard->counters.insert(std::make_pair(cttype, card::counter_map::mapped_type()));
auto cmit = pr.first; auto cmit = pr.first;
...@@ -148,8 +148,8 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) { ...@@ -148,8 +148,8 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
int32 scriptlib::debug_reload_field_begin(lua_State *L) { int32 scriptlib::debug_reload_field_begin(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 flag = lua_tointeger(L, 1); uint32 flag = lua_tonumberint(L, 1);
int32 rule = lua_tointeger(L, 2); int32 rule = lua_tonumberint(L, 2);
pduel->clear(); pduel->clear();
pduel->game_field->core.duel_options = flag; pduel->game_field->core.duel_options = flag;
if (rule) if (rule)
......
This diff is collapsed.
...@@ -256,7 +256,7 @@ int32 scriptlib::effect_set_value(lua_State *L) { ...@@ -256,7 +256,7 @@ int32 scriptlib::effect_set_value(lua_State *L) {
if(lua_isboolean(L, 2)) if(lua_isboolean(L, 2))
peffect->value = lua_toboolean(L, 2); peffect->value = lua_toboolean(L, 2);
else else
peffect->value = lua_tointeger(L, 2); peffect->value = lua_tonumberint(L, 2);
} }
return 0; return 0;
} }
...@@ -450,7 +450,7 @@ int32 scriptlib::effect_is_active_type(lua_State *L) { ...@@ -450,7 +450,7 @@ int32 scriptlib::effect_is_active_type(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 tpe = lua_tointeger(L, 2); uint32 tpe = lua_tonumberint(L, 2);
uint32 atype; uint32 atype;
if(peffect->type & 0x7f0) { if(peffect->type & 0x7f0) {
if(peffect->active_type) if(peffect->active_type)
...@@ -480,7 +480,7 @@ int32 scriptlib::effect_is_has_category(lua_State *L) { ...@@ -480,7 +480,7 @@ int32 scriptlib::effect_is_has_category(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 tcate = lua_tointeger(L, 2); uint32 tcate = lua_tonumberint(L, 2);
if (peffect && (peffect->category & tcate)) if (peffect && (peffect->category & tcate))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
...@@ -491,7 +491,7 @@ int32 scriptlib::effect_is_has_type(lua_State *L) { ...@@ -491,7 +491,7 @@ int32 scriptlib::effect_is_has_type(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 ttype = lua_tointeger(L, 2); uint32 ttype = lua_tonumberint(L, 2);
if (peffect && (peffect->type & ttype)) if (peffect && (peffect->type & ttype))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
...@@ -501,7 +501,7 @@ int32 scriptlib::effect_is_has_type(lua_State *L) { ...@@ -501,7 +501,7 @@ int32 scriptlib::effect_is_has_type(lua_State *L) {
int32 scriptlib::effect_is_activatable(lua_State *L) { int32 scriptlib::effect_is_activatable(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tonumberint(L, 2);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 neglect_loc = 0; uint32 neglect_loc = 0;
if(lua_gettop(L) > 2) if(lua_gettop(L) > 2)
......
...@@ -206,11 +206,11 @@ int32 scriptlib::group_filter_select(lua_State *L) { ...@@ -206,11 +206,11 @@ int32 scriptlib::group_filter_select(lua_State *L) {
cset.erase(*cit); cset.erase(*cit);
} }
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tonumberint(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
uint32 min = lua_tointeger(L, 4); uint32 min = lua_tonumberint(L, 4);
uint32 max = lua_tointeger(L, 5); uint32 max = lua_tonumberint(L, 5);
uint32 extraargs = lua_gettop(L) - 6; uint32 extraargs = lua_gettop(L) - 6;
pduel->game_field->core.select_cards.clear(); pduel->game_field->core.select_cards.clear();
for (auto it = cset.begin(); it != cset.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
...@@ -235,11 +235,11 @@ int32 scriptlib::group_select(lua_State *L) { ...@@ -235,11 +235,11 @@ int32 scriptlib::group_select(lua_State *L) {
cset.erase(*cit); cset.erase(*cit);
} }
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tonumberint(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
uint32 min = lua_tointeger(L, 3); uint32 min = lua_tonumberint(L, 3);
uint32 max = lua_tointeger(L, 4); uint32 max = lua_tonumberint(L, 4);
pduel->game_field->core.select_cards.clear(); pduel->game_field->core.select_cards.clear();
for (auto it = cset.begin(); it != cset.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
pduel->game_field->core.select_cards.push_back(*it); pduel->game_field->core.select_cards.push_back(*it);
...@@ -251,8 +251,8 @@ int32 scriptlib::group_random_select(lua_State *L) { ...@@ -251,8 +251,8 @@ int32 scriptlib::group_random_select(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
int32 playerid = lua_tointeger(L, 2); int32 playerid = lua_tonumberint(L, 2);
int32 count = lua_tointeger(L, 3); int32 count = lua_tonumberint(L, 3);
pgroup->pduel->game_field->add_process(PROCESSOR_RANDOM_SELECT_S, 0, 0, pgroup, playerid, count); pgroup->pduel->game_field->add_process(PROCESSOR_RANDOM_SELECT_S, 0, 0, pgroup, playerid, count);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
...@@ -271,7 +271,7 @@ int32 scriptlib::group_is_exists(lua_State *L) { ...@@ -271,7 +271,7 @@ int32 scriptlib::group_is_exists(lua_State *L) {
cset.erase(*cit); cset.erase(*cit);
} }
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 count = lua_tointeger(L, 3); uint32 count = lua_tonumberint(L, 3);
uint32 extraargs = lua_gettop(L) - 4; uint32 extraargs = lua_gettop(L) - 4;
uint32 fcount = 0; uint32 fcount = 0;
uint32 result = FALSE; uint32 result = FALSE;
...@@ -293,9 +293,9 @@ int32 scriptlib::group_check_with_sum_equal(lua_State *L) { ...@@ -293,9 +293,9 @@ int32 scriptlib::group_check_with_sum_equal(lua_State *L) {
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
int32 acc = lua_tointeger(L, 3); int32 acc = lua_tonumberint(L, 3);
int32 min = lua_tointeger(L, 4); int32 min = lua_tonumberint(L, 4);
int32 max = lua_tointeger(L, 5); int32 max = lua_tonumberint(L, 5);
if(min < 0) if(min < 0)
min = 0; min = 0;
if(max < min) if(max < min)
...@@ -321,12 +321,12 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) { ...@@ -321,12 +321,12 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
check_param(L, PARAM_TYPE_FUNCTION, 3); check_param(L, PARAM_TYPE_FUNCTION, 3);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
int32 playerid = lua_tointeger(L, 2); int32 playerid = lua_tonumberint(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
int32 acc = lua_tointeger(L, 4); int32 acc = lua_tonumberint(L, 4);
int32 min = lua_tointeger(L, 5); int32 min = lua_tonumberint(L, 5);
int32 max = lua_tointeger(L, 6); int32 max = lua_tonumberint(L, 6);
if(min < 0) if(min < 0)
min = 0; min = 0;
if(max < min) if(max < min)
...@@ -357,7 +357,7 @@ int32 scriptlib::group_check_with_sum_greater(lua_State *L) { ...@@ -357,7 +357,7 @@ int32 scriptlib::group_check_with_sum_greater(lua_State *L) {
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
int32 acc = lua_tointeger(L, 3); int32 acc = lua_tonumberint(L, 3);
int32 extraargs = lua_gettop(L) - 3; int32 extraargs = lua_gettop(L) - 3;
field::card_vector cv(pduel->game_field->core.must_select_cards); field::card_vector cv(pduel->game_field->core.must_select_cards);
int32 mcount = cv.size(); int32 mcount = cv.size();
...@@ -379,10 +379,10 @@ int32 scriptlib::group_select_with_sum_greater(lua_State *L) { ...@@ -379,10 +379,10 @@ int32 scriptlib::group_select_with_sum_greater(lua_State *L) {
check_param(L, PARAM_TYPE_FUNCTION, 3); check_param(L, PARAM_TYPE_FUNCTION, 3);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
int32 playerid = lua_tointeger(L, 2); int32 playerid = lua_tonumberint(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
int32 acc = lua_tointeger(L, 4); int32 acc = lua_tonumberint(L, 4);
int32 extraargs = lua_gettop(L) - 4; int32 extraargs = lua_gettop(L) - 4;
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end()); pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
for(auto cit = pduel->game_field->core.must_select_cards.begin(); cit != pduel->game_field->core.must_select_cards.end(); ++cit) { for(auto cit = pduel->game_field->core.must_select_cards.begin(); cit != pduel->game_field->core.must_select_cards.end(); ++cit) {
......
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