Commit 8568c8f3 authored by salix5's avatar salix5 Committed by GitHub

add duel::buffer_size() (#653)

* add duel::buffer_size()

* fix warning C4267 about size
parent 3d92ce96
...@@ -98,9 +98,10 @@ void duel::delete_effect(effect* peffect) { ...@@ -98,9 +98,10 @@ void duel::delete_effect(effect* peffect) {
delete peffect; delete peffect;
} }
int32 duel::read_buffer(byte* buf) { int32 duel::read_buffer(byte* buf) {
if(message_buffer.size()) auto size = buffer_size();
std::memcpy(buf, message_buffer.data(), message_buffer.size()); if (size)
return (int32)message_buffer.size(); std::memcpy(buf, message_buffer.data(), size);
return (int32)size;
} }
void duel::release_script_group() { void duel::release_script_group() {
for(auto& pgroup : sgroups) { for(auto& pgroup : sgroups) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "mtrandom.h" #include "mtrandom.h"
#include <set> #include <set>
#include <unordered_set> #include <unordered_set>
#include <vector>
class card; class card;
class group; class group;
...@@ -40,6 +41,9 @@ public: ...@@ -40,6 +41,9 @@ public:
~duel(); ~duel();
void clear(); void clear();
uint32 buffer_size() const {
return (uint32)message_buffer.size() & PROCESSOR_BUFFER_LEN;
}
card* new_card(uint32 code); card* new_card(uint32 code);
group* new_group(); group* new_group();
group* new_group(card* pcard); group* new_group(card* pcard);
......
...@@ -627,7 +627,7 @@ public: ...@@ -627,7 +627,7 @@ public:
int32 toss_dice(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count1, uint8 count2); int32 toss_dice(uint16 step, effect* reason_effect, uint8 reason_player, uint8 playerid, uint8 count1, uint8 count2);
int32 rock_paper_scissors(uint16 step, uint8 repeat); int32 rock_paper_scissors(uint16 step, uint8 repeat);
bool check_response(int32 vector_size, int32 min_len, int32 max_len) const; bool check_response(size_t vector_size, int32 min_len, int32 max_len) const;
int32 select_battle_command(uint16 step, uint8 playerid); int32 select_battle_command(uint16 step, uint8 playerid);
int32 select_idle_command(uint16 step, uint8 playerid); int32 select_idle_command(uint16 step, uint8 playerid);
int32 select_effect_yes_no(uint16 step, uint8 playerid, uint32 description, card* pcard); int32 select_effect_yes_no(uint16 step, uint8 playerid, uint32 description, card* pcard);
......
...@@ -4367,7 +4367,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4367,7 +4367,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
raise_single_event(pcard, 0, EVENT_DESTROYED, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_DESTROYED, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} }
if(pcard->xyz_materials.size()) { if(pcard->xyz_materials.size()) {
pcard->xyz_materials_previous_count_onfield = pcard->xyz_materials.size(); pcard->xyz_materials_previous_count_onfield = (int32)pcard->xyz_materials.size();
for(auto& mcard : pcard->xyz_materials) for(auto& mcard : pcard->xyz_materials)
overlays.insert(mcard); overlays.insert(mcard);
} else { } else {
...@@ -4711,7 +4711,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4711,7 +4711,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
} }
if(target->xyz_materials.size()) { if(target->xyz_materials.size()) {
target->xyz_materials_previous_count_onfield = target->xyz_materials.size(); target->xyz_materials_previous_count_onfield = (int32)target->xyz_materials.size();
card_set overlays; card_set overlays;
overlays.insert(target->xyz_materials.begin(), target->xyz_materials.end()); overlays.insert(target->xyz_materials.begin(), target->xyz_materials.end());
send_to(&overlays, 0, REASON_LOST_OVERLAY + REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); send_to(&overlays, 0, REASON_LOST_OVERLAY + REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
#include <algorithm> #include <algorithm>
#include <stack> #include <stack>
bool field::check_response(int32 vector_size, int32 min_len, int32 max_len) const { bool field::check_response(size_t vector_size, int32 min_len, int32 max_len) const {
const int32 len = returns.bvalue[0]; const int32 len = returns.bvalue[0];
if (len < min_len || len > max_len) if (len < min_len || len > max_len)
return false; return false;
std::set<uint8> index_set; std::set<uint8> index_set;
for (int32 i = 0; i < len; ++i) { for (int32 i = 0; i < len; ++i) {
uint8 index = returns.bvalue[1 + i]; uint8 index = returns.bvalue[1 + i];
if (index >=vector_size || index_set.count(index)) { if (index >= (int32)vector_size || index_set.count(index)) {
return false; return false;
} }
index_set.insert(index); index_set.insert(index);
......
...@@ -36,7 +36,7 @@ uint32 field::process() { ...@@ -36,7 +36,7 @@ uint32 field::process() {
if (core.subunits.size()) if (core.subunits.size())
core.units.splice(core.units.begin(), core.subunits); core.units.splice(core.units.begin(), core.subunits);
if (core.units.size() == 0) if (core.units.size() == 0)
return PROCESSOR_END | pduel->message_buffer.size(); return PROCESSOR_END | pduel->buffer_size();
auto it = core.units.begin(); auto it = core.units.begin();
switch (it->type) { switch (it->type) {
case PROCESSOR_ADJUST: { case PROCESSOR_ADJUST: {
...@@ -45,151 +45,151 @@ uint32 field::process() { ...@@ -45,151 +45,151 @@ uint32 field::process() {
else { else {
++it->step; ++it->step;
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_TURN: { case PROCESSOR_TURN: {
if (process_turn(it->step, it->arg1)) if (process_turn(it->step, it->arg1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_WAIT: { case PROCESSOR_WAIT: {
core.units.pop_front(); core.units.pop_front();
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
case PROCESSOR_REFRESH_LOC: { case PROCESSOR_REFRESH_LOC: {
if (refresh_location_info(it->step)) if (refresh_location_info(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELECT_BATTLECMD: { case PROCESSOR_SELECT_BATTLECMD: {
if (select_battle_command(it->step, it->arg1)) { if (select_battle_command(it->step, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_IDLECMD: { case PROCESSOR_SELECT_IDLECMD: {
if (select_idle_command(it->step, it->arg1)) { if (select_idle_command(it->step, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_EFFECTYN: { case PROCESSOR_SELECT_EFFECTYN: {
if (select_effect_yes_no(it->step, it->arg1, it->arg2, (card*)it->ptarget)) { if (select_effect_yes_no(it->step, it->arg1, it->arg2, (card*)it->ptarget)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_YESNO: { case PROCESSOR_SELECT_YESNO: {
if (select_yes_no(it->step, it->arg1, it->arg2)) { if (select_yes_no(it->step, it->arg1, it->arg2)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_OPTION: { case PROCESSOR_SELECT_OPTION: {
if (select_option(it->step, it->arg1)) { if (select_option(it->step, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_CARD: { case PROCESSOR_SELECT_CARD: {
if (select_card(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff)) { if (select_card(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_UNSELECT_CARD: { case PROCESSOR_SELECT_UNSELECT_CARD: {
if (select_unselect_card(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff, (it->arg3) & 0xff)) { if (select_unselect_card(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff, (it->arg3) & 0xff)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_CHAIN: { case PROCESSOR_SELECT_CHAIN: {
if (select_chain(it->step, it->arg1, (it->arg2 & 0xffff), it->arg2 >> 16)) { if (select_chain(it->step, it->arg1, (it->arg2 & 0xffff), it->arg2 >> 16)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_DISFIELD: case PROCESSOR_SELECT_DISFIELD:
case PROCESSOR_SELECT_PLACE: { case PROCESSOR_SELECT_PLACE: {
if (select_place(it->step, it->arg1, it->arg2, it->arg3)) { if (select_place(it->step, it->arg1, it->arg2, it->arg3)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_POSITION: { case PROCESSOR_SELECT_POSITION: {
if (select_position(it->step, it->arg1 & 0xffff, it->arg2, (it->arg1 >> 16) & 0xffff)) { if (select_position(it->step, it->arg1 & 0xffff, it->arg2, (it->arg1 >> 16) & 0xffff)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_TRIBUTE_P: { case PROCESSOR_SELECT_TRIBUTE_P: {
if (select_tribute(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff)) { if (select_tribute(it->step, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_COUNTER: { case PROCESSOR_SELECT_COUNTER: {
if (select_counter(it->step, it->arg1, it->arg2, it->arg3, it->arg4 >> 8, it->arg4 & 0xff)) { if (select_counter(it->step, it->arg1, it->arg2, it->arg3, it->arg4 >> 8, it->arg4 & 0xff)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_SUM: { case PROCESSOR_SELECT_SUM: {
if (select_with_sum_limit(it->step, it->arg2, it->arg1, it->arg3, it->arg4)) { if (select_with_sum_limit(it->step, it->arg2, it->arg1, it->arg3, it->arg4)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SORT_CARD: { case PROCESSOR_SORT_CARD: {
if (sort_card(it->step, it->arg1)) { if (sort_card(it->step, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} else { } else {
it->step = 1; it->step = 1;
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
} }
case PROCESSOR_SELECT_RELEASE: { case PROCESSOR_SELECT_RELEASE: {
...@@ -197,77 +197,77 @@ uint32 field::process() { ...@@ -197,77 +197,77 @@ uint32 field::process() {
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELECT_TRIBUTE: { case PROCESSOR_SELECT_TRIBUTE: {
if (select_tribute_cards(it->step, (card*)it->ptarget, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff, it->arg3, it->arg4)) if (select_tribute_cards(it->step, (card*)it->ptarget, it->arg1 & 0xff, (it->arg1 >> 16) & 0xff, (it->arg2) & 0xff, (it->arg2 >> 16) & 0xff, it->arg3, it->arg4))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_POINT_EVENT: { case PROCESSOR_POINT_EVENT: {
if(process_point_event(it->step, it->arg1 & 0xff, (it->arg1 >> 8) & 0xff, it->arg2)) if(process_point_event(it->step, it->arg1 & 0xff, (it->arg1 >> 8) & 0xff, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_QUICK_EFFECT: { case PROCESSOR_QUICK_EFFECT: {
if(process_quick_effect(it->step, it->arg1, it->arg2)) if(process_quick_effect(it->step, it->arg1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_IDLE_COMMAND: { case PROCESSOR_IDLE_COMMAND: {
if(process_idle_command(it->step)) if(process_idle_command(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_PHASE_EVENT: { case PROCESSOR_PHASE_EVENT: {
if(process_phase_event(it->step, it->arg1)) if(process_phase_event(it->step, it->arg1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_BATTLE_COMMAND: { case PROCESSOR_BATTLE_COMMAND: {
if(process_battle_command(it->step)) if(process_battle_command(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DAMAGE_STEP: { case PROCESSOR_DAMAGE_STEP: {
if(process_damage_step(it->step, it->arg2)) if(process_damage_step(it->step, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_ADD_CHAIN: { case PROCESSOR_ADD_CHAIN: {
if (add_chain(it->step)) if (add_chain(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SOLVE_CHAIN: { case PROCESSOR_SOLVE_CHAIN: {
if (solve_chain(it->step, it->arg1, it->arg2)) if (solve_chain(it->step, it->arg1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SOLVE_CONTINUOUS: { case PROCESSOR_SOLVE_CONTINUOUS: {
if (solve_continuous(it->step)) if (solve_continuous(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_EXECUTE_COST: { case PROCESSOR_EXECUTE_COST: {
if (execute_cost(it->step, it->peffect, it->arg1)) { if (execute_cost(it->step, it->peffect, it->arg1)) {
...@@ -275,7 +275,7 @@ uint32 field::process() { ...@@ -275,7 +275,7 @@ uint32 field::process() {
core.solving_event.pop_front(); core.solving_event.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_EXECUTE_OPERATION: { case PROCESSOR_EXECUTE_OPERATION: {
if (execute_operation(it->step, it->peffect, it->arg1)) { if (execute_operation(it->step, it->peffect, it->arg1)) {
...@@ -283,7 +283,7 @@ uint32 field::process() { ...@@ -283,7 +283,7 @@ uint32 field::process() {
core.solving_event.pop_front(); core.solving_event.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_EXECUTE_TARGET: { case PROCESSOR_EXECUTE_TARGET: {
if (execute_target(it->step, it->peffect, it->arg1)) { if (execute_target(it->step, it->peffect, it->arg1)) {
...@@ -291,140 +291,140 @@ uint32 field::process() { ...@@ -291,140 +291,140 @@ uint32 field::process() {
core.solving_event.pop_front(); core.solving_event.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DESTROY: { case PROCESSOR_DESTROY: {
if (destroy(it->step, it->ptarget, it->peffect, it->arg1, it->arg2)) if (destroy(it->step, it->ptarget, it->peffect, it->arg1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_RELEASE: { case PROCESSOR_RELEASE: {
if (release(it->step, it->ptarget, it->peffect, it->arg1, it->arg2)) if (release(it->step, it->ptarget, it->peffect, it->arg1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SENDTO: { case PROCESSOR_SENDTO: {
if (send_to(it->step, it->ptarget, it->peffect, it->arg1, it->arg2, it->arg3)) if (send_to(it->step, it->ptarget, it->peffect, it->arg1, it->arg2, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DESTROY_REPLACE: { case PROCESSOR_DESTROY_REPLACE: {
if(destroy_replace(it->step, it->ptarget, (card*)it->ptr1, it->arg2)) if(destroy_replace(it->step, it->ptarget, (card*)it->ptr1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_RELEASE_REPLACE: { case PROCESSOR_RELEASE_REPLACE: {
if (release_replace(it->step, it->ptarget, (card*)it->ptr1)) if (release_replace(it->step, it->ptarget, (card*)it->ptr1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SENDTO_REPLACE: { case PROCESSOR_SENDTO_REPLACE: {
if (send_replace(it->step, it->ptarget, (card*)it->ptr1)) if (send_replace(it->step, it->ptarget, (card*)it->ptr1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_MOVETOFIELD: { case PROCESSOR_MOVETOFIELD: {
if (move_to_field(it->step, (card*)it->ptarget, it->arg1, it->arg2 & 0xff, (it->arg2 >> 8) & 0xff, it->arg3)) if (move_to_field(it->step, (card*)it->ptarget, it->arg1, it->arg2 & 0xff, (it->arg2 >> 8) & 0xff, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_CHANGEPOS: { case PROCESSOR_CHANGEPOS: {
if (change_position(it->step, it->ptarget, it->peffect, it->arg1, it->arg2)) if (change_position(it->step, it->ptarget, it->peffect, it->arg1, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_OPERATION_REPLACE: { case PROCESSOR_OPERATION_REPLACE: {
if (operation_replace(it->step, it->peffect, it->ptarget, (card*)it->ptr1, it->arg1)) if (operation_replace(it->step, it->peffect, it->ptarget, (card*)it->ptr1, it->arg1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_ACTIVATE_EFFECT: { case PROCESSOR_ACTIVATE_EFFECT: {
if (activate_effect(it->step, it->peffect)) if (activate_effect(it->step, it->peffect))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SUMMON_RULE: { case PROCESSOR_SUMMON_RULE: {
if (summon(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2)) if (summon(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SPSUMMON_RULE: { case PROCESSOR_SPSUMMON_RULE: {
if (special_summon_rule(it->step, it->arg1, (card*)it->ptarget, it->arg2, it->arg3)) if (special_summon_rule(it->step, it->arg1, (card*)it->ptarget, it->arg2, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SPSUMMON: { case PROCESSOR_SPSUMMON: {
if (special_summon(it->step, it->peffect, it->arg1, it->ptarget, it->arg2)) if (special_summon(it->step, it->peffect, it->arg1, it->ptarget, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_FLIP_SUMMON: { case PROCESSOR_FLIP_SUMMON: {
if (flip_summon(it->step, it->arg1, (card*)(it->ptarget), it->arg2)) if (flip_summon(it->step, it->arg1, (card*)(it->ptarget), it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_MSET: { case PROCESSOR_MSET: {
if (mset(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2)) if (mset(it->step, it->arg1 & 0xff, (card*)it->ptarget, it->peffect, (it->arg1 >> 8) & 0xff, (it->arg1 >> 16) & 0xff, (it->arg1 >> 24) & 0xff, it->arg2))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SSET: { case PROCESSOR_SSET: {
if (sset(it->step, it->arg1, it->arg2, (card*)(it->ptarget), it->peffect)) if (sset(it->step, it->arg1, it->arg2, (card*)(it->ptarget), it->peffect))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SPSUMMON_STEP: { case PROCESSOR_SPSUMMON_STEP: {
if (special_summon_step(it->step, it->ptarget, (card*)(it->ptr1), it->arg1)) if (special_summon_step(it->step, it->ptarget, (card*)(it->ptr1), it->arg1))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SSET_G: { case PROCESSOR_SSET_G: {
if (sset_g(it->step, it->arg1, it->arg2, it->ptarget, it->arg3, it->peffect)) { if (sset_g(it->step, it->arg1, it->arg2, it->ptarget, it->arg3, it->peffect)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DRAW : { case PROCESSOR_DRAW : {
if (draw(it->step, it->peffect, it->arg1, (it->arg2 >> 4) & 0xf, (it->arg2) & 0xf, it->arg3)) if (draw(it->step, it->peffect, it->arg1, (it->arg2 >> 4) & 0xf, (it->arg2) & 0xf, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DAMAGE: { case PROCESSOR_DAMAGE: {
int32 reason = it->arg1; int32 reason = it->arg1;
...@@ -442,7 +442,7 @@ uint32 field::process() { ...@@ -442,7 +442,7 @@ uint32 field::process() {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_RECOVER: { case PROCESSOR_RECOVER: {
if (recover(it->step, it->peffect, it->arg1, (it->arg2 >> 2) & 0x3, (it->arg2) & 0x3, it->arg3, (it->arg2 >> 4) & 0x1)) { if (recover(it->step, it->peffect, it->arg1, (it->arg2 >> 2) & 0x3, (it->arg2) & 0x3, it->arg3, (it->arg2 >> 4) & 0x1)) {
...@@ -453,56 +453,56 @@ uint32 field::process() { ...@@ -453,56 +453,56 @@ uint32 field::process() {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_EQUIP: { case PROCESSOR_EQUIP: {
if (equip(it->step, it->arg2 & 0xffff, (card*)it->ptr1, (card*)it->ptarget, (it->arg2 >> 16) & 0xff, (it->arg2 >> 24) & 0xff)) if (equip(it->step, it->arg2 & 0xffff, (card*)it->ptr1, (card*)it->ptarget, (it->arg2 >> 16) & 0xff, (it->arg2 >> 24) & 0xff))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_GET_CONTROL: { case PROCESSOR_GET_CONTROL: {
if (get_control(it->step, it->peffect, (it->arg2 >> 28) & 0xf, it->ptarget, (it->arg2 >> 24) & 0xf, (it->arg2 >> 8) & 0x3ff, it->arg2 & 0xff, it->arg3)) { if (get_control(it->step, it->peffect, (it->arg2 >> 28) & 0xf, it->ptarget, (it->arg2 >> 24) & 0xf, (it->arg2 >> 8) & 0x3ff, it->arg2 & 0xff, it->arg3)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SWAP_CONTROL: { case PROCESSOR_SWAP_CONTROL: {
if (swap_control(it->step, it->peffect, it->arg1, it->ptarget, (group*)it->ptr1, it->arg2, it->arg3)) { if (swap_control(it->step, it->peffect, it->arg1, it->ptarget, (group*)it->ptr1, it->arg2, it->arg3)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELF_DESTROY: { case PROCESSOR_SELF_DESTROY: {
if (self_destroy(it->step, (card*)it->ptr1, it->arg1)) { if (self_destroy(it->step, (card*)it->ptr1, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_TRAP_MONSTER_ADJUST: { case PROCESSOR_TRAP_MONSTER_ADJUST: {
if (trap_monster_adjust(it->step)) if (trap_monster_adjust(it->step))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_PAY_LPCOST: { case PROCESSOR_PAY_LPCOST: {
if (pay_lp_cost(it->step, it->arg1, it->arg2, it->arg3)) if (pay_lp_cost(it->step, it->arg1, it->arg2, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_REMOVE_COUNTER: { case PROCESSOR_REMOVE_COUNTER: {
if (remove_counter(it->step, it->arg4, (card*)it->ptarget, (it->arg1 >> 16) & 0xff, (it->arg1 >> 8) & 0xff, it->arg1 & 0xff, it->arg2, it->arg3)) { if (remove_counter(it->step, it->arg4, (card*)it->ptarget, (it->arg1 >> 16) & 0xff, (it->arg1 >> 8) & 0xff, it->arg1 & 0xff, it->arg2, it->arg3)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_ATTACK_DISABLE: { case PROCESSOR_ATTACK_DISABLE: {
if(it->step == 0) { if(it->step == 0) {
...@@ -529,7 +529,7 @@ uint32 field::process() { ...@@ -529,7 +529,7 @@ uint32 field::process() {
returns.ivalue[0] = 1; returns.ivalue[0] = 1;
core.units.pop_front(); core.units.pop_front();
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_ANNOUNCE_RACE: { case PROCESSOR_ANNOUNCE_RACE: {
if(announce_race(it->step, it->arg1 & 0xffff, it->arg1 >> 16, it->arg2)) { if(announce_race(it->step, it->arg1 & 0xffff, it->arg1 >> 16, it->arg2)) {
...@@ -537,7 +537,7 @@ uint32 field::process() { ...@@ -537,7 +537,7 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
case PROCESSOR_ANNOUNCE_ATTRIB: { case PROCESSOR_ANNOUNCE_ATTRIB: {
if(announce_attribute(it->step, it->arg1 & 0xffff, it->arg1 >> 16, it->arg2)) { if(announce_attribute(it->step, it->arg1 & 0xffff, it->arg1 >> 16, it->arg2)) {
...@@ -545,7 +545,7 @@ uint32 field::process() { ...@@ -545,7 +545,7 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
case PROCESSOR_ANNOUNCE_CARD: { case PROCESSOR_ANNOUNCE_CARD: {
if(announce_card(it->step, it->arg1)) { if(announce_card(it->step, it->arg1)) {
...@@ -553,7 +553,7 @@ uint32 field::process() { ...@@ -553,7 +553,7 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
case PROCESSOR_ANNOUNCE_NUMBER: { case PROCESSOR_ANNOUNCE_NUMBER: {
if(announce_number(it->step, it->arg1)) { if(announce_number(it->step, it->arg1)) {
...@@ -561,28 +561,28 @@ uint32 field::process() { ...@@ -561,28 +561,28 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return PROCESSOR_WAITING | pduel->message_buffer.size(); return PROCESSOR_WAITING | pduel->buffer_size();
} }
case PROCESSOR_TOSS_DICE: { case PROCESSOR_TOSS_DICE: {
if(toss_dice(it->step, it->peffect, it->arg1 >> 16, it->arg1 & 0xff, it->arg2 & 0xff, it->arg2 >> 16)) { if(toss_dice(it->step, it->peffect, it->arg1 >> 16, it->arg1 & 0xff, it->arg2 & 0xff, it->arg2 >> 16)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_TOSS_COIN: { case PROCESSOR_TOSS_COIN: {
if (toss_coin(it->step, it->peffect, (it->arg1 >> 16), it->arg1 & 0xff, it->arg2)) { if (toss_coin(it->step, it->peffect, (it->arg1 >> 16), it->arg1 & 0xff, it->arg2)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_ROCK_PAPER_SCISSORS: { case PROCESSOR_ROCK_PAPER_SCISSORS: {
if (rock_paper_scissors(it->step, it->arg1)) { if (rock_paper_scissors(it->step, it->arg1)) {
core.units.pop_front(); core.units.pop_front();
} else } else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELECT_FUSION: { case PROCESSOR_SELECT_FUSION: {
if(it->step == 0) { if(it->step == 0) {
...@@ -593,7 +593,7 @@ uint32 field::process() { ...@@ -593,7 +593,7 @@ uint32 field::process() {
core.fusion_materials.clear(); core.fusion_materials.clear();
if(!it->peffect) { if(!it->peffect) {
core.units.pop_front(); core.units.pop_front();
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
core.not_material = it->arg2; core.not_material = it->arg2;
core.sub_solving_event.push_back(e); core.sub_solving_event.push_back(e);
...@@ -605,7 +605,7 @@ uint32 field::process() { ...@@ -605,7 +605,7 @@ uint32 field::process() {
core.not_material = 0; core.not_material = 0;
core.units.pop_front(); core.units.pop_front();
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELECT_SYNCHRO: { case PROCESSOR_SELECT_SYNCHRO: {
int32 ret = TRUE; int32 ret = TRUE;
...@@ -617,14 +617,14 @@ uint32 field::process() { ...@@ -617,14 +617,14 @@ uint32 field::process() {
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SELECT_XMATERIAL: { case PROCESSOR_SELECT_XMATERIAL: {
if (select_xyz_material(it->step, it->arg1 & 0xffff, it->arg1 >> 16, (card*)it->ptarget, it->arg2 & 0xffff, it->arg2 >> 16)) if (select_xyz_material(it->step, it->arg1 & 0xffff, it->arg1 >> 16, (card*)it->ptarget, it->arg2 & 0xffff, it->arg2 >> 16))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DISCARD_HAND: { case PROCESSOR_DISCARD_HAND: {
if(it->step == 0) { if(it->step == 0) {
...@@ -651,7 +651,7 @@ uint32 field::process() { ...@@ -651,7 +651,7 @@ uint32 field::process() {
} else { } else {
core.units.pop_front(); core.units.pop_front();
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_DISCARD_DECK: { case PROCESSOR_DISCARD_DECK: {
if(discard_deck(it->step, it->arg1 & 0xff, it->arg1 >> 16, it->arg2)) { if(discard_deck(it->step, it->arg1 & 0xff, it->arg1 >> 16, it->arg2)) {
...@@ -659,7 +659,7 @@ uint32 field::process() { ...@@ -659,7 +659,7 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_SORT_DECK: { case PROCESSOR_SORT_DECK: {
uint8 sort_player = it->arg1 & 0xffff; uint8 sort_player = it->arg1 & 0xffff;
...@@ -710,7 +710,7 @@ uint32 field::process() { ...@@ -710,7 +710,7 @@ uint32 field::process() {
} }
core.units.pop_front(); core.units.pop_front();
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
case PROCESSOR_REMOVE_OVERLAY: { case PROCESSOR_REMOVE_OVERLAY: {
if(remove_overlay_card(it->step, it->arg3, (card*)(it->ptarget), it->arg1 >> 16, if(remove_overlay_card(it->step, it->arg3, (card*)(it->ptarget), it->arg1 >> 16,
...@@ -719,10 +719,10 @@ uint32 field::process() { ...@@ -719,10 +719,10 @@ uint32 field::process() {
} else { } else {
++it->step; ++it->step;
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
} }
return pduel->message_buffer.size(); return pduel->buffer_size();
} }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
......
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