Commit 7e09ab94 authored by salix5's avatar salix5 Committed by GitHub

use int32 playerid (#613)

* use int32 if possible

* remove include in effectset.h

* use int32 playerid

* update playerid in class effect

* update playerid in class field
parent b053acb9
......@@ -657,7 +657,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
}
return FALSE;
}
void effect::dec_count(uint32 playerid) {
void effect::dec_count(uint8 playerid) {
if(!is_flag(EFFECT_FLAG_COUNT_LIMIT))
return;
if(count_limit == 0)
......
......@@ -89,7 +89,7 @@ public:
int32 is_chainable(uint8 tp);
int32 is_hand_trigger();
int32 reset(uint32 reset_level, uint32 reset_type);
void dec_count(uint32 playerid = 2);
void dec_count(uint8 playerid = PLAYER_NONE);
void recharge();
int32 get_value(uint32 extraargs = 0);
int32 get_value(card* pcard, uint32 extraargs = 0);
......
......@@ -8,7 +8,6 @@
#ifndef EFFECTSET_H_
#define EFFECTSET_H_
#include <stdlib.h>
#include <array>
#include <vector>
#include <algorithm>
......
......@@ -513,8 +513,8 @@ void field::set_control(card* pcard, uint8 playerid, uint16 reset_phase, uint8 r
pcard->current.controler = playerid;
}
card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
switch(location) {
card* field::get_field_card(uint8 playerid, uint32 general_location, uint8 sequence) {
switch(general_location) {
case LOCATION_MZONE: {
if(sequence < player[playerid].list_mzone.size())
return player[playerid].list_mzone[sequence];
......@@ -585,9 +585,9 @@ card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
}
return nullptr;
}
int32 field::is_location_useable(uint32 playerid, uint32 location, uint32 sequence) {
int32 field::is_location_useable(uint8 playerid, uint32 general_location, uint8 sequence) {
uint32 flag = player[playerid].disabled_location | player[playerid].used_location;
if (location == LOCATION_MZONE) {
if (general_location == LOCATION_MZONE) {
if(flag & (0x1u << sequence))
return FALSE;
if(sequence >= 5) {
......@@ -595,13 +595,13 @@ int32 field::is_location_useable(uint32 playerid, uint32 location, uint32 sequen
if(oppo & (0x1u << (11 - sequence)))
return FALSE;
}
} else if (location == LOCATION_SZONE) {
} else if (general_location == LOCATION_SZONE) {
if(flag & (0x100u << sequence))
return FALSE;
} else if (location == LOCATION_FZONE) {
} else if (general_location == LOCATION_FZONE) {
if(flag & (0x100u << (5 + sequence)))
return FALSE;
} else if (location == LOCATION_PZONE) {
} else if (general_location == LOCATION_PZONE) {
if(core.duel_rule >= 4) {
if(flag & (0x100u << (sequence * 4)))
return FALSE;
......@@ -1016,7 +1016,7 @@ void field::shuffle(uint8 playerid, uint8 location) {
void field::reset_sequence(uint8 playerid, uint8 location) {
if(location & (LOCATION_ONFIELD))
return;
uint32 i = 0;
int32 i = 0;
switch(location) {
case LOCATION_DECK:
for(auto& pcard : player[playerid].list_main)
......
......@@ -393,8 +393,8 @@ public:
void swap_card(card* pcard1, card* pcard2, uint8 new_sequence1, uint8 new_sequence2);
void swap_card(card* pcard1, card* pcard2);
void set_control(card* pcard, uint8 playerid, uint16 reset_phase, uint8 reset_count);
card* get_field_card(uint32 playerid, uint32 location, uint32 sequence);
int32 is_location_useable(uint32 playerid, uint32 location, uint32 sequence);
card* get_field_card(uint8 playerid, uint32 general_location, uint8 sequence);
int32 is_location_useable(uint8 playerid, uint32 general_location, uint8 sequence);
int32 get_useable_count(card* pcard, uint8 playerid, uint8 location, uint8 uplayer, uint32 reason, uint32 zone = 0xff, uint32* list = nullptr);
int32 get_useable_count_fromex(card* pcard, uint8 playerid, uint8 uplayer, uint32 zone = 0xff, uint32* list = nullptr);
int32 get_spsummonable_count(card* pcard, uint8 playerid, uint32 zone = 0xff, uint32* list = nullptr);
......
......@@ -2971,7 +2971,7 @@ int32 scriptlib::card_is_can_remove_counter(lua_State *L) {
check_param_count(L, 5);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1)
return 0;
uint32 countertype = (uint32)lua_tointeger(L, 3);
......
......@@ -72,10 +72,10 @@ int32 scriptlib::debug_add_card(lua_State *L) {
int32 scriptlib::debug_set_player_info(lua_State *L) {
check_param_count(L, 4);
duel* pduel = interpreter::get_duel_info(L);
uint32 playerid = (uint32)lua_tointeger(L, 1);
uint32 lp = (uint32)lua_tointeger(L, 2);
uint32 startcount = (uint32)lua_tointeger(L, 3);
uint32 drawcount = (uint32)lua_tointeger(L, 4);
int32 playerid = (int32)lua_tointeger(L, 1);
int32 lp = (int32)lua_tointeger(L, 2);
int32 startcount = (int32)lua_tointeger(L, 3);
int32 drawcount = (int32)lua_tointeger(L, 4);
if(playerid != 0 && playerid != 1)
return 0;
pduel->game_field->player[playerid].lp = lp;
......
This diff is collapsed.
......@@ -97,7 +97,7 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) {
check_param_count(L, 4);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
uint32 s = (uint32)lua_tointeger(L, 3);
uint32 o = (uint32)lua_tointeger(L, 4);
if(playerid == 0) {
......@@ -292,7 +292,7 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 p = (uint32)lua_tointeger(L, 2);
int32 p = (int32)lua_tointeger(L, 2);
if(p != 0 && p != 1)
return 0;
peffect->effect_owner = p;
......@@ -502,7 +502,7 @@ int32 scriptlib::effect_is_has_type(lua_State *L) {
int32 scriptlib::effect_is_activatable(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 neglect_loc = 0;
uint32 neglect_target = 0;
......@@ -554,7 +554,7 @@ int32 scriptlib::effect_check_count_limit(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 p = (uint32)lua_tointeger(L, 2);
int32 p = (int32)lua_tointeger(L, 2);
lua_pushboolean(L, peffect->check_count_limit(p));
return 1;
}
......@@ -562,12 +562,12 @@ int32 scriptlib::effect_use_count_limit(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 p = (uint32)lua_tointeger(L, 2);
uint32 count = 1;
uint32 oath_only = 0;
int32 p = (int32)lua_tointeger(L, 2);
int32 count = 1;
int32 oath_only = 0;
uint32 code = peffect->count_code;
if(lua_gettop(L) > 2) {
count = (uint32)lua_tointeger(L, 3);
count = (int32)lua_tointeger(L, 3);
if (lua_gettop(L) > 3)
oath_only = lua_toboolean(L, 4);
}
......
......@@ -214,7 +214,7 @@ int32 scriptlib::group_filter_select(lua_State *L) {
cset.erase(pcard);
}
duel* pduel = pgroup->pduel;
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1)
return 0;
uint32 min = (uint32)lua_tointeger(L, 4);
......@@ -252,7 +252,7 @@ int32 scriptlib::group_select(lua_State *L) {
cset.erase(pcard);
}
duel* pduel = pgroup->pduel;
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1)
return 0;
uint32 min = (uint32)lua_tointeger(L, 3);
......@@ -282,7 +282,7 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
unselect_group = *(group**)lua_touserdata(L, 2);
duel* pduel = select_group->pduel;
uint32 playerid = (uint32)lua_tointeger(L, 3);
int32 playerid = (int32)lua_tointeger(L, 3);
if(playerid != 0 && playerid != 1)
return 0;
if(select_group->container.size() == 0 && (!unselect_group || unselect_group->container.size() == 0))
......@@ -390,7 +390,7 @@ int32 scriptlib::group_cancelable_select(lua_State *L) {
cset.erase(pcard);
}
duel* pduel = pgroup->pduel;
uint32 playerid = (uint32)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1)
return 0;
uint32 min = (uint32)lua_tointeger(L, 3);
......
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