Skip to content

Commit

Permalink
update left shift (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
salix5 authored Nov 9, 2024
1 parent 101ed0b commit 3d92ce9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 40 deletions.
8 changes: 4 additions & 4 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ uint32 card::get_info_location() const {
uint32 l = overlay_target->current.location | LOCATION_OVERLAY;
uint32 s = overlay_target->current.sequence;
uint32 ss = current.sequence;
return c + (l << 8) + (s << 16) + (ss << 24);
return c | (l << 8) | (s << 16) | (ss << 24);
} else {
uint32 c = current.controler;
uint32 l = current.location;
uint32 s = current.sequence;
uint32 ss = current.position;
return c + (l << 8) + (s << 16) + (ss << 24);
return c | (l << 8) | (s << 16) | (ss << 24);
}
}
// get the printed code on card
Expand Down Expand Up @@ -1347,8 +1347,8 @@ uint32 card::get_mutual_linked_zone() {
int32 p = current.controler;
int32 s = current.sequence;
uint32 linked_zone = get_linked_zone();
uint32 icheck = 0x1;
for(uint32 i = 0; i < 7; ++i, icheck <<= 1) {
uint32 icheck = 0x1U;
for(int32 i = 0; i < 7; ++i, icheck <<= 1) {
if(icheck & linked_zone) {
card* pcard = pduel->game_field->player[p].list_mzone[i];
if(pcard && (pcard->get_linked_zone() & (1u << s)))
Expand Down
14 changes: 7 additions & 7 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,31 +567,31 @@ int32 field::is_location_useable(uint8 playerid, uint32 general_location, uint8
if (general_location == LOCATION_MZONE) {
if (sequence >= (int32)player[playerid].list_mzone.size())
return FALSE;
if(flag & (0x1u << sequence))
if(flag & (0x1U << sequence))
return FALSE;
if(sequence >= 5) {
uint32 oppo = player[1 - playerid].disabled_location | player[1 - playerid].used_location;
if(oppo & (0x1u << (11 - sequence)))
if(oppo & (0x1U << (11 - sequence)))
return FALSE;
}
} else if (general_location == LOCATION_SZONE) {
if (sequence >= player[playerid].szone_size)
return FALSE;
if(flag & (0x100u << sequence))
if(flag & (0x100U << sequence))
return FALSE;
} else if (general_location == LOCATION_FZONE) {
if (sequence >= 1)
return FALSE;
if(flag & (0x100u << (5 + sequence)))
if(flag & (0x100U << (5 + sequence)))
return FALSE;
} else if (general_location == LOCATION_PZONE) {
if (sequence >= 2)
return FALSE;
if(core.duel_rule >= NEW_MASTER_RULE) {
if(flag & (0x100u << (sequence * 4)))
if(flag & (0x100U << (sequence * 4)))
return FALSE;
} else {
if(flag & (0x100u << (6 + sequence)))
if(flag & (0x100U << (6 + sequence)))
return FALSE;
}
}
Expand Down Expand Up @@ -1334,7 +1334,7 @@ void field::add_effect_code(uint32 code, uint32 playerid) {
count_map = &core.effect_count_code_duel;
else if(code & EFFECT_COUNT_CODE_CHAIN)
count_map = &core.effect_count_code_chain;
++(*count_map)[code + (playerid << 30)];
(*count_map)[code + (playerid << 30)]++;
}
uint32 field::get_effect_code(uint32 code, uint32 playerid) {
auto* count_map = &core.effect_count_code;
Expand Down
24 changes: 12 additions & 12 deletions libduel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ int32 scriptlib::duel_move_to_field(lua_State *L) {
zone = (uint32)lua_tointeger(L, 7);
if(destination == LOCATION_FZONE) {
destination = LOCATION_SZONE;
zone = 0x1 << 5;
zone = 0x1U << 5;
}
uint32 pzone = FALSE;
if(destination == LOCATION_PZONE) {
Expand Down Expand Up @@ -1984,7 +1984,7 @@ int32 scriptlib::duel_get_mzone_count(lua_State *L) {
} else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2);
for(int32 p = 0; p < 2; p++) {
uint32 digit = 1;
uint32 digit = 0x1U;
for(auto& pcard : pduel->game_field->player[p].list_mzone) {
if(pcard && pcard != mcard && !(mgroup && mgroup->container.find(pcard) != mgroup->container.end())) {
used_location[p] |= digit;
Expand Down Expand Up @@ -3846,11 +3846,11 @@ int32 scriptlib::duel_select_disable_field(lua_State * L) {
}
if((location1 & LOCATION_MZONE) && (location2 & LOCATION_MZONE) && pduel->game_field->core.duel_rule >= NEW_MASTER_RULE) {
if(pduel->game_field->is_location_useable(playerid, LOCATION_MZONE, 5)) {
flag &= ~(0x1 << 5);
flag &= ~(0x1U << 5);
ct1 += 1;
}
if(pduel->game_field->is_location_useable(playerid, LOCATION_MZONE, 6)) {
flag &= ~(0x1 << 6);
flag &= ~(0x1U << 6);
ct1 += 1;
}
}
Expand All @@ -3870,13 +3870,13 @@ int32 scriptlib::duel_select_disable_field(lua_State * L) {
uint8 p = pduel->game_field->returns.bvalue[pa];
uint8 l = pduel->game_field->returns.bvalue[pa + 1];
uint8 s = pduel->game_field->returns.bvalue[pa + 2];
dfflag |= 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
dfflag |= 0x1U << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
pa += 3;
}
if(dfflag & (0x1 << 5))
dfflag |= 0x1 << (16 + 6);
if(dfflag & (0x1U << 5))
dfflag |= 0x1U << (16 + 6);
if(dfflag & (0x1 << 6))
dfflag |= 0x1 << (16 + 5);
dfflag |= 0x1U << (16 + 5);
lua_pushinteger(L, dfflag);
return 1;
});
Expand Down Expand Up @@ -3937,10 +3937,10 @@ int32 scriptlib::duel_select_field(lua_State* L) {
dfflag |= 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
pa += 3;
}
if(dfflag & (0x1 << 5))
dfflag |= 0x1 << (16 + 6);
if(dfflag & (0x1 << 6))
dfflag |= 0x1 << (16 + 5);
if(dfflag & (0x1U << 5))
dfflag |= 0x1U << (16 + 6);
if(dfflag & (0x1U << 6))
dfflag |= 0x1U << (16 + 5);
lua_pushinteger(L, dfflag);
return 1;
});
Expand Down
26 changes: 13 additions & 13 deletions operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@ int32 field::swap_control(uint16 step, effect* reason_effect, uint8 reason_playe
uint32 flag;
get_useable_count(nullptr, p1, LOCATION_MZONE, reason_player, LOCATION_REASON_CONTROL, 0xff, &flag);
if(reason_player == p1)
flag = (flag & ~(1 << s1) & 0xff) | ~0x1f;
flag = (flag & ~(0x1U << s1) & 0xff) | ~0x1f;
else
flag = ((flag & ~(1 << s1)) << 16 & 0xff0000) | ~0x1f0000;
flag = ((flag & ~(0x1U << s1)) << 16 & 0xff0000) | ~0x1f0000;
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(reason_player);
Expand All @@ -1102,9 +1102,9 @@ int32 field::swap_control(uint16 step, effect* reason_effect, uint8 reason_playe
uint32 flag;
get_useable_count(nullptr, p2, LOCATION_MZONE, reason_player, LOCATION_REASON_CONTROL, 0xff, &flag);
if(reason_player == p2)
flag = (flag & ~(1 << s2) & 0xff) | ~0x1f;
flag = (flag & ~(0x1U << s2) & 0xff) | ~0x1f;
else
flag = ((flag & ~(1 << s2)) << 16 & 0xff0000) | ~0x1f0000;
flag = ((flag & ~(0x1U << s2)) << 16 & 0xff0000) | ~0x1f0000;
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(reason_player);
Expand Down Expand Up @@ -2465,7 +2465,7 @@ int32 field::sset(uint16 step, uint8 setplayer, uint8 toplayer, card * target, e
}
case 2: {
target->enable_field_effect(false);
move_to_field(target, setplayer, toplayer, LOCATION_SZONE, POS_FACEDOWN, FALSE, 0, FALSE, 0x1 << target->to_field_param);
move_to_field(target, setplayer, toplayer, LOCATION_SZONE, POS_FACEDOWN, FALSE, 0, FALSE, 0x1U << target->to_field_param);
return FALSE;
}
case 3: {
Expand Down Expand Up @@ -2568,7 +2568,7 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget
uint32 seq = returns.bvalue[2];
core.set_group_seq[core.set_group_pre_set.size()] = seq;
core.set_group_pre_set.insert(target);
core.set_group_used_zones |= (1 << seq);
core.set_group_used_zones |= (0x1U << seq);
set_cards->erase(target);
if(!set_cards->empty())
core.units.begin()->step = 0;
Expand All @@ -2582,10 +2582,10 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget
target->enable_field_effect(false);
uint32 zone;
if(target->data.type & TYPE_FIELD) {
zone = 1 << 5;
zone = 0x1U << 5;
} else {
for(uint32 i = 0; i < 7; i++) {
zone = 1 << i;
for(int32 i = 0; i < 7; i++) {
zone = 0x1U << i;
if(core.set_group_used_zones & zone) {
core.set_group_used_zones &= ~zone;
break;
Expand Down Expand Up @@ -2649,7 +2649,7 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget
core.operated_set.insert(pcard);
}
uint8 ct = (uint8)core.operated_set.size();
if(core.set_group_used_zones & (1 << 5))
if(core.set_group_used_zones & (0x1U << 5))
--ct;
if(ct <= 1)
return FALSE;
Expand Down Expand Up @@ -4554,7 +4554,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
returns.ivalue[0] = FALSE;
if((ret == RETURN_TEMP_REMOVE_TO_FIELD) && (!(target->current.reason & REASON_TEMPORARY) || (target->current.reason_effect->owner != core.reason_effect->owner)))
return TRUE;
if(location == LOCATION_SZONE && zone == 0x1 << 5 && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) {
if(location == LOCATION_SZONE && zone == 0x1U << 5 && (target->data.type & TYPE_FIELD) && (target->data.type & TYPE_SPELL)) {
card* pcard = get_field_card(playerid, LOCATION_SZONE, 5);
if(pcard) {
if(core.duel_rule >= 3)
Expand Down Expand Up @@ -4599,8 +4599,8 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
return FALSE;
}
if((zone & zone - 1) == 0) {
for(uint8 seq = 0; seq < 8; seq++) {
if((1 << seq) & zone) {
for(uint8 seq = 0; seq < 8; ++seq) {
if((0x1U << seq) & zone) {
returns.bvalue[2] = seq;
return FALSE;
}
Expand Down
7 changes: 4 additions & 3 deletions playerop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ int32 field::sort_card(int16 step, uint8 playerid) {
int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 available) {
if(step == 0) {
int32 scount = 0;
for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) {
for(uint32 ft = 0x1; ft < (0x1U << RACES_COUNT); ft <<= 1) {
if(ft & available)
++scount;
}
Expand All @@ -803,8 +803,9 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
} else {
int32 rc = returns.ivalue[0];
int32 sel = 0;
for(int32 ft = 0x1; ft < (1 << RACES_COUNT); ft <<= 1) {
if(!(ft & rc)) continue;
for(uint32 ft = 0x1; ft < (0x1U << RACES_COUNT); ft <<= 1) {
if(!(ft & rc))
continue;
if(!(ft & available)) {
pduel->write_buffer8(MSG_RETRY);
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4019,7 +4019,7 @@ int32 field::add_chain(uint16 step) {
phandler->enable_field_effect(false);
phandler->set_status(STATUS_ACT_FROM_HAND, TRUE);
if(phandler->data.type & TYPE_FIELD)
zone = 0x1 << 5;
zone = 0x1U << 5;
move_to_field(phandler, phandler->current.controler, phandler->current.controler, LOCATION_SZONE, POS_FACEUP, FALSE, 0, (phandler->data.type & TYPE_PENDULUM) ? TRUE : FALSE, zone);
} else {
phandler->set_status(STATUS_ACT_FROM_HAND, FALSE);
Expand Down

0 comments on commit 3d92ce9

Please sign in to comment.