Commit 4b0db6ca authored by salix5's avatar salix5 Committed by GitHub

update card::attacker_map (#610)

* update card::attacker_map

* update effect::reset_count

* fix warning C4244
parent c1628d82
......@@ -134,12 +134,12 @@ bool card::card_operation_sort(card* c1, card* c2) {
}
}
void card::attacker_map::addcard(card* pcard) {
uint16 fid = pcard ? pcard->fieldid_r : 0;
auto fid = pcard ? pcard->fieldid_r : 0;
auto pr = emplace(fid, std::make_pair(pcard, 0));
++pr.first->second.second;
}
uint32 card::attacker_map::findcard(card* pcard) {
uint16 fid = pcard ? pcard->fieldid_r : 0;
auto fid = pcard ? pcard->fieldid_r : 0;
auto it = find(fid);
if(it == end())
return 0;
......@@ -1914,7 +1914,7 @@ int32 card::add_effect(effect* peffect) {
if(peffect->reset_flag & RESET_PHASE) {
pduel->game_field->effects.pheff.insert(peffect);
if(peffect->reset_count == 0)
peffect->reset_count += 1;
peffect->reset_count = 1;
}
if(peffect->reset_flag & RESET_CHAIN)
pduel->game_field->effects.cheff.insert(peffect);
......@@ -2021,14 +2021,14 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
}
pduel->game_field->core.reseted_effects.insert(peffect);
}
int32 card::copy_effect(uint32 code, uint32 reset, uint32 count) {
int32 card::copy_effect(uint32 code, uint32 reset, int32 count) {
card_data cdata;
::read_card(code, &cdata);
if(cdata.type & TYPE_NORMAL)
return -1;
set_status(STATUS_COPYING_EFFECT, TRUE);
uint32 cr = pduel->game_field->core.copy_reset;
uint8 crc = pduel->game_field->core.copy_reset_count;
auto cr = pduel->game_field->core.copy_reset;
auto crc = pduel->game_field->core.copy_reset_count;
pduel->game_field->core.copy_reset = reset;
pduel->game_field->core.copy_reset_count = count;
pduel->lua->add_param(this, PARAM_TYPE_CARD);
......@@ -2057,7 +2057,7 @@ int32 card::copy_effect(uint32 code, uint32 reset, uint32 count) {
}
return pduel->game_field->infos.copy_id - 1;
}
int32 card::replace_effect(uint32 code, uint32 reset, uint32 count) {
int32 card::replace_effect(uint32 code, uint32 reset, int32 count) {
card_data cdata;
::read_card(code, &cdata);
if(cdata.type & TYPE_NORMAL)
......@@ -2071,8 +2071,8 @@ int32 card::replace_effect(uint32 code, uint32 reset, uint32 count) {
if (peffect->is_flag(EFFECT_FLAG_INITIAL | EFFECT_FLAG_COPY_INHERIT))
remove_effect(peffect, it);
}
uint32 cr = pduel->game_field->core.copy_reset;
uint8 crc = pduel->game_field->core.copy_reset_count;
auto cr = pduel->game_field->core.copy_reset;
auto crc = pduel->game_field->core.copy_reset_count;
pduel->game_field->core.copy_reset = reset;
pduel->game_field->core.copy_reset_count = count;
set_status(STATUS_INITIALIZING | STATUS_COPYING_EFFECT, TRUE);
......@@ -2355,7 +2355,7 @@ int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8
uint16 cttype = countertype;
auto pr = counters.emplace(cttype, 0);
auto cmit = pr.first;
int32 pcount = count;
auto pcount = count;
if(singly) {
effect_set eset;
int32 limit = 0;
......@@ -2367,7 +2367,7 @@ int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8
if (mcount < 0)
mcount = 0;
if (pcount > mcount)
pcount = mcount;
pcount = (uint16)mcount;
}
}
cmit->second += pcount;
......@@ -2385,7 +2385,7 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
auto cmit = counters.find(countertype);
if(cmit == counters.end())
return FALSE;
int32 remove_count = count;
auto remove_count = count;
if (cmit->second <= count) {
remove_count = cmit->second;
counters.erase(cmit);
......@@ -3917,9 +3917,11 @@ int32 card::is_capable_cost_to_grave(uint8 playerid) {
sendto_param.location = dest;
if(current.location & LOCATION_ONFIELD)
redirect = leave_field_redirect(REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
redirect = destination_redirect(dest, REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
sendto_param = op_param;
if(dest != LOCATION_GRAVE)
return FALSE;
......@@ -3940,9 +3942,11 @@ int32 card::is_capable_cost_to_hand(uint8 playerid) {
sendto_param.location = dest;
if(current.location & LOCATION_ONFIELD)
redirect = leave_field_redirect(REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
redirect = destination_redirect(dest, REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
sendto_param = op_param;
if(dest != LOCATION_HAND)
return FALSE;
......@@ -3963,9 +3967,11 @@ int32 card::is_capable_cost_to_deck(uint8 playerid) {
sendto_param.location = dest;
if(current.location & LOCATION_ONFIELD)
redirect = leave_field_redirect(REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
redirect = destination_redirect(dest, REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
sendto_param = op_param;
if(dest != LOCATION_DECK)
return FALSE;
......@@ -3986,9 +3992,11 @@ int32 card::is_capable_cost_to_extra(uint8 playerid) {
sendto_param.location = dest;
if(current.location & LOCATION_ONFIELD)
redirect = leave_field_redirect(REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
redirect = destination_redirect(dest, REASON_COST) & 0xffff;
if(redirect) dest = redirect;
if(redirect)
dest = redirect;
sendto_param = op_param;
if(dest != LOCATION_DECK)
return FALSE;
......
......@@ -121,7 +121,7 @@ public:
using relation_map = std::unordered_map<card*, uint32>;
using counter_map = std::map<uint16, uint16>;
using effect_count = std::map<uint32, int32>;
class attacker_map : public std::unordered_map<uint16, std::pair<card*, uint32>> {
class attacker_map : public std::unordered_map<uint32, std::pair<card*, uint32>> {
public:
void addcard(card* pcard);
uint32 findcard(card* pcard);
......@@ -287,8 +287,8 @@ public:
int32 add_effect(effect* peffect);
void remove_effect(effect* peffect);
void remove_effect(effect* peffect, effect_container::iterator it);
int32 copy_effect(uint32 code, uint32 reset, uint32 count);
int32 replace_effect(uint32 code, uint32 reset, uint32 count);
int32 copy_effect(uint32 code, uint32 reset, int32 count);
int32 replace_effect(uint32 code, uint32 reset, int32 count);
void reset(uint32 id, uint32 reset_type);
void reset_effect_count();
void refresh_disable_status();
......
......@@ -43,7 +43,7 @@ public:
uint16 o_range{ 0 };
uint8 count_limit{ 0 };
uint8 count_limit_max{ 0 };
uint16 reset_count{ 0 };
int32 reset_count{ 0 };
uint32 reset_flag{ 0 };
uint32 count_code{ 0 };
uint32 category{ 0 };
......
......@@ -307,7 +307,7 @@ struct processor {
int32 duel_options{ 0 };
int32 duel_rule{ CURRENT_RULE };
uint32 copy_reset{ 0 };
uint8 copy_reset_count{ 0 };
int32 copy_reset_count{ 0 };
uint32 last_control_changed_id{ 0 };
uint32 set_group_used_zones{ 0 };
uint8 set_group_seq[7]{};
......
......@@ -1869,7 +1869,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1);
int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT;
int32 reset = (int32)lua_tointeger(L, 3);
int32 flag = (int32)lua_tointeger(L, 4);
uint32 flag = (uint32)lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 5);
int32 lab = 0;
int32 desc = 0;
......@@ -2045,7 +2045,7 @@ int32 scriptlib::card_copy_effect(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 code = (uint32)lua_tointeger(L, 2);
uint32 reset = (uint32)lua_tointeger(L, 3);
uint32 count = (uint32)lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 4);
if(count == 0)
count = 1;
if(reset & RESET_PHASE && !(reset & (RESET_SELF_TURN | RESET_OPPO_TURN)))
......@@ -2059,7 +2059,7 @@ int32 scriptlib::card_replace_effect(lua_State * L) {
card* pcard = *(card**)lua_touserdata(L, 1);
uint32 code = (uint32)lua_tointeger(L, 2);
uint32 reset = (uint32)lua_tointeger(L, 3);
uint32 count = (uint32)lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 4);
if(count == 0)
count = 1;
if(reset & RESET_PHASE && !(reset & (RESET_SELF_TURN | RESET_OPPO_TURN)))
......
......@@ -126,7 +126,7 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 countertype = (uint32)lua_tointeger(L, 2);
uint32 count = (uint32)lua_tointeger(L, 3);
uint16 count = (uint16)lua_tointeger(L, 3);
uint16 cttype = countertype;
auto pr = pcard->counters.emplace(cttype, 0);
auto cmit = pr.first;
......
......@@ -97,7 +97,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
return 0;
int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT;
int32 reset = (int32)lua_tointeger(L, 3);
int32 flag = (int32)lua_tointeger(L, 4);
uint32 flag = (uint32)lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 5);
int32 lab = 0;
if(lua_gettop(L) >= 6)
......@@ -2358,8 +2358,8 @@ int32 scriptlib::duel_skip_phase(lua_State *L) {
return 0;
uint32 phase = (uint32)lua_tointeger(L, 2);
uint32 reset = (uint32)lua_tointeger(L, 3);
uint32 count = (uint32)lua_tointeger(L, 4);
uint32 value = (uint32)lua_tointeger(L, 5);
int32 count = (int32)lua_tointeger(L, 4);
int32 value = (int32)lua_tointeger(L, 5);
if(count <= 0)
count = 1;
duel* pduel = interpreter::get_duel_info(L);
......
......@@ -133,7 +133,7 @@ int32 scriptlib::effect_set_reset(lua_State *L) {
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 v = (uint32)lua_tointeger(L, 2);
uint32 c = (uint32)lua_tointeger(L, 3);
int32 c = (int32)lua_tointeger(L, 3);
if(c == 0)
c = 1;
if(v & (RESET_PHASE) && !(v & (RESET_SELF_TURN | RESET_OPPO_TURN)))
......
......@@ -293,7 +293,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
duel* ptduel = (duel*)pduel;
byte* p = buf;
*p++ = MSG_RELOAD_FIELD;
*p++ = ptduel->game_field->core.duel_rule;
*p++ = (uint8)ptduel->game_field->core.duel_rule;
for(int playerid = 0; playerid < 2; ++playerid) {
auto& player = ptduel->game_field->player[playerid];
buffer_write<int32_t>(p, player.lp);
......
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