Commit 21229426 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into server

parents 098fc21a c8fd6335
...@@ -7,9 +7,13 @@ namespace ygo { ...@@ -7,9 +7,13 @@ namespace ygo {
ClientCard::~ClientCard() { ClientCard::~ClientCard() {
ClearTarget(); ClearTarget();
if (equipTarget) if (equipTarget) {
equipTarget->is_showequip = false;
equipTarget->equipped.erase(this); equipTarget->equipped.erase(this);
for (auto card : equipped) { equipTarget = nullptr;
}
for (auto& card : equipped) {
card->is_showequip = false;
card->equipTarget = nullptr; card->equipTarget = nullptr;
} }
equipped.clear(); equipped.clear();
...@@ -21,8 +25,9 @@ ClientCard::~ClientCard() { ...@@ -21,8 +25,9 @@ ClientCard::~ClientCard() {
else else
++it; ++it;
} }
overlayTarget = nullptr;
} }
for (auto card : overlayed) { for (auto& card : overlayed) {
card->overlayTarget = nullptr; card->overlayTarget = nullptr;
} }
overlayed.clear(); overlayed.clear();
...@@ -206,10 +211,6 @@ void ClientCard::ClearData() { ...@@ -206,10 +211,6 @@ void ClientCard::ClearData() {
rscstring[0] = 0; rscstring[0] = 0;
lscstring[0] = 0; lscstring[0] = 0;
counters.clear(); counters.clear();
for (auto card : equipped) {
card->equipTarget = nullptr;
}
equipped.clear();
} }
bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
if(c1->is_selected != c2->is_selected) if(c1->is_selected != c2->is_selected)
...@@ -220,23 +221,26 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { ...@@ -220,23 +221,26 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
return cp1 < cp2; return cp1 < cp2;
if(c1->location != c2->location) if(c1->location != c2->location)
return c1->location < c2->location; return c1->location < c2->location;
if(c1->location & LOCATION_OVERLAY) if (c1->location & LOCATION_OVERLAY) {
if(c1->overlayTarget != c2->overlayTarget) if (c1->overlayTarget != c2->overlayTarget)
return c1->overlayTarget->sequence < c2->overlayTarget->sequence; return c1->overlayTarget->sequence < c2->overlayTarget->sequence;
else return c1->sequence < c2->sequence; else
return c1->sequence < c2->sequence;
}
else { else {
if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) { if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const auto& ch) { auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const ChainInfo& ch) {
return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end(); return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end();
}); });
auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const auto& ch) { auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const ChainInfo& ch) {
return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end(); return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end();
}); });
if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) { if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) {
return it1 < it2; return it1 < it2;
} }
return c1->sequence > c2->sequence; return c1->sequence > c2->sequence;
} else }
else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
} }
......
...@@ -93,12 +93,12 @@ public: ...@@ -93,12 +93,12 @@ public:
std::set<ClientCard*> ownerTarget; std::set<ClientCard*> ownerTarget;
std::map<int, int> counters; std::map<int, int> counters;
std::map<int, int> desc_hints; std::map<int, int> desc_hints;
wchar_t atkstring[16]{ 0 }; wchar_t atkstring[16]{};
wchar_t defstring[16]{ 0 }; wchar_t defstring[16]{};
wchar_t lvstring[16]{ 0 }; wchar_t lvstring[16]{};
wchar_t linkstring[16]{ 0 }; wchar_t linkstring[16]{};
wchar_t lscstring[16]{ 0 }; wchar_t lscstring[16]{};
wchar_t rscstring[16]{ 0 }; wchar_t rscstring[16]{};
ClientCard() = default; ClientCard() = default;
~ClientCard(); ~ClientCard();
......
...@@ -19,39 +19,39 @@ ClientField::ClientField() { ...@@ -19,39 +19,39 @@ ClientField::ClientField() {
} }
ClientField::~ClientField() { ClientField::~ClientField() {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
for (auto card : deck[i]) { for (auto& card : deck[i]) {
delete card; delete card;
} }
deck[i].clear(); deck[i].clear();
for (auto card : hand[i]) { for (auto& card : hand[i]) {
delete card; delete card;
} }
hand[i].clear(); hand[i].clear();
for (auto card : mzone[i]) { for (auto& card : mzone[i]) {
if (card) if (card)
delete card; delete card;
card = nullptr; card = nullptr;
} }
for (auto card : szone[i]) { for (auto& card : szone[i]) {
if (card) if (card)
delete card; delete card;
card = nullptr; card = nullptr;
} }
for (auto card : grave[i]) { for (auto& card : grave[i]) {
delete card; delete card;
} }
grave[i].clear(); grave[i].clear();
for (auto card : remove[i]) { for (auto& card : remove[i]) {
delete card; delete card;
} }
remove[i].clear(); remove[i].clear();
for (auto card : extra[i]) { for (auto& card : extra[i]) {
delete card; delete card;
} }
extra[i].clear(); extra[i].clear();
} }
for (auto card : overlay_cards) { for (auto& card : overlay_cards) {
delete card; delete card;
} }
overlay_cards.clear(); overlay_cards.clear();
......
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
std::vector<int> select_options; std::vector<int> select_options;
std::vector<int> select_options_index; std::vector<int> select_options_index;
std::vector<ChainInfo> chains; std::vector<ChainInfo> chains;
int extra_p_count[2]{ 0 }; int extra_p_count[2]{};
size_t selected_option{ 0 }; size_t selected_option{ 0 };
ClientCard* attacker{ nullptr }; ClientCard* attacker{ nullptr };
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
bool remove_act{ false }; bool remove_act{ false };
bool deck_act{ false }; bool deck_act{ false };
bool extra_act{ false }; bool extra_act{ false };
bool pzone_act[2]{ false }; bool pzone_act[2]{};
bool conti_act{ false }; bool conti_act{ false };
bool chain_forced{ false }; bool chain_forced{ false };
ChainInfo current_chain; ChainInfo current_chain;
......
...@@ -2176,6 +2176,7 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -2176,6 +2176,7 @@ void ClientField::GetHoverField(int x, int y) {
hovered_location = LOCATION_REMOVED; hovered_location = LOCATION_REMOVED;
} }
} else if(rule == 1 && boardx >= matManager.vFieldSzone[1][7][rule][1].Pos.X && boardx <= matManager.vFieldSzone[1][7][rule][2].Pos.X) { } else if(rule == 1 && boardx >= matManager.vFieldSzone[1][7][rule][1].Pos.X && boardx <= matManager.vFieldSzone[1][7][rule][2].Pos.X) {
// deprecated szone[7]
if(boardy >= matManager.vFieldSzone[1][7][rule][2].Pos.Y && boardy <= matManager.vFieldSzone[1][7][rule][0].Pos.Y) { if(boardy >= matManager.vFieldSzone[1][7][rule][2].Pos.Y && boardy <= matManager.vFieldSzone[1][7][rule][0].Pos.Y) {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_SZONE; hovered_location = LOCATION_SZONE;
...@@ -2207,7 +2208,8 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -2207,7 +2208,8 @@ void ClientField::GetHoverField(int x, int y) {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_EXTRA; hovered_location = LOCATION_EXTRA;
} }
} else if(rule == 0 && boardx >= matManager.vFieldSzone[0][7][rule][0].Pos.X && boardx <= matManager.vFieldSzone[0][7][rule][1].Pos.X) { } else if(rule == 1 && boardx >= matManager.vFieldSzone[0][7][rule][0].Pos.X && boardx <= matManager.vFieldSzone[0][7][rule][1].Pos.X) {
// deprecated szone[7]
if(boardy >= matManager.vFieldSzone[0][7][rule][0].Pos.Y && boardy <= matManager.vFieldSzone[0][7][rule][2].Pos.Y) { if(boardy >= matManager.vFieldSzone[0][7][rule][0].Pos.Y && boardy <= matManager.vFieldSzone[0][7][rule][2].Pos.Y) {
hovered_controler = 0; hovered_controler = 0;
hovered_location = LOCATION_SZONE; hovered_location = LOCATION_SZONE;
......
...@@ -125,9 +125,6 @@ bool Game::Initialize() { ...@@ -125,9 +125,6 @@ bool Game::Initialize() {
is_building = false; is_building = false;
menuHandler.prev_operation = 0; menuHandler.prev_operation = 0;
menuHandler.prev_sel = -1; menuHandler.prev_sel = -1;
for (auto i : chatTiming) {
i = 0;
}
deckManager.LoadLFList(); deckManager.LoadLFList();
driver = device->getVideoDriver(); driver = device->getVideoDriver();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
...@@ -1291,7 +1288,7 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo ...@@ -1291,7 +1288,7 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo
} }
void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem) { void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem) {
if(!mywcsncasecmp(deckpath, L"./pack", 6)) { if(!mywcsncasecmp(deckpath, L"./pack", 6)) {
for(auto pack : deckBuilder.expansionPacks) { for(auto& pack : deckBuilder.expansionPacks) {
additem(pack.substr(5, pack.size() - 9).c_str()); additem(pack.substr(5, pack.size() - 9).c_str());
} }
} }
...@@ -1378,57 +1375,6 @@ void Game::LoadConfig() { ...@@ -1378,57 +1375,6 @@ void Game::LoadConfig() {
char strbuf[32]; char strbuf[32];
char valbuf[256]; char valbuf[256];
wchar_t wstr[256]; wchar_t wstr[256];
gameConf.use_d3d = 0;
gameConf.use_image_scale = 1;
gameConf.antialias = 0;
gameConf.serverport = 7911;
gameConf.textfontsize = 14;
gameConf.nickname[0] = 0;
gameConf.gamename[0] = 0;
gameConf.lastcategory[0] = 0;
gameConf.lastdeck[0] = 0;
gameConf.numfont[0] = 0;
gameConf.textfont[0] = 0;
gameConf.lasthost[0] = 0;
gameConf.lastport[0] = 0;
gameConf.roompass[0] = 0;
gameConf.bot_deck_path[0] = 0;
//settings
gameConf.chkMAutoPos = 0;
gameConf.chkSTAutoPos = 1;
gameConf.chkRandomPos = 0;
gameConf.chkAutoChain = 0;
gameConf.chkWaitChain = 0;
gameConf.chkDefaultShowChain = 0;
gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0;
gameConf.use_lflist = 1;
gameConf.default_lflist = 0;
gameConf.default_rule = DEFAULT_DUEL_RULE;
gameConf.hide_setname = 0;
gameConf.hide_hint_button = 0;
gameConf.control_mode = 0;
gameConf.draw_field_spell = 1;
gameConf.separate_clear_button = 1;
gameConf.auto_search_limit = -1;
gameConf.search_multiple_keywords = 1;
gameConf.chkIgnoreDeckChanges = 0;
gameConf.defaultOT = 1;
gameConf.enable_bot_mode = 0;
gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0;
gameConf.draw_single_chain = 0;
gameConf.hide_player_name = 0;
gameConf.prefer_expansion_script = 0;
gameConf.enable_sound = true;
gameConf.sound_volume = 0.5;
gameConf.enable_music = true;
gameConf.music_volume = 0.5;
gameConf.music_mode = 1;
gameConf.window_maximized = false;
gameConf.window_width = 1024;
gameConf.window_height = 640;
gameConf.resize_popup_menu = false;
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf); sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) { if(!strcmp(strbuf, "antialias")) {
......
...@@ -13,61 +13,63 @@ ...@@ -13,61 +13,63 @@
#include <vector> #include <vector>
#include <list> #include <list>
#define DEFAULT_DUEL_RULE 5
namespace ygo { namespace ygo {
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
struct Config { struct Config {
bool use_d3d; bool use_d3d{ false };
bool use_image_scale; bool use_image_scale{ true };
unsigned short antialias; unsigned short antialias{ 0 };
unsigned short serverport; unsigned short serverport{ 7911 };
unsigned char textfontsize; unsigned char textfontsize{ 14 };
wchar_t lasthost[100]; wchar_t lasthost[100]{};
wchar_t lastport[10]; wchar_t lastport[10]{};
wchar_t nickname[20]; wchar_t nickname[20]{};
wchar_t gamename[20]; wchar_t gamename[20]{};
wchar_t lastcategory[64]; wchar_t lastcategory[64]{};
wchar_t lastdeck[64]; wchar_t lastdeck[64]{};
wchar_t textfont[256]; wchar_t textfont[256]{};
wchar_t numfont[256]; wchar_t numfont[256]{};
wchar_t roompass[20]; wchar_t roompass[20]{};
wchar_t bot_deck_path[64]; wchar_t bot_deck_path[64]{};
//settings //settings
int chkMAutoPos; int chkMAutoPos{ 0 };
int chkSTAutoPos; int chkSTAutoPos{ 1 };
int chkRandomPos; int chkRandomPos{ 0 };
int chkAutoChain; int chkAutoChain{ 0 };
int chkWaitChain; int chkWaitChain{ 0 };
int chkDefaultShowChain; int chkDefaultShowChain{ 0 };
int chkIgnore1; int chkIgnore1{ 0 };
int chkIgnore2; int chkIgnore2{ 0 };
int use_lflist; int use_lflist{ 1 };
int default_lflist; int default_lflist{ 0 };
int default_rule; int default_rule{ DEFAULT_DUEL_RULE };
int hide_setname; int hide_setname{ 0 };
int hide_hint_button; int hide_hint_button{ 0 };
int control_mode; int control_mode{ 0 };
int draw_field_spell; int draw_field_spell{ 1 };
int separate_clear_button; int separate_clear_button{ 1 };
int auto_search_limit; int auto_search_limit{ -1 };
int search_multiple_keywords; int search_multiple_keywords{ 1 };
int chkIgnoreDeckChanges; int chkIgnoreDeckChanges{ 0 };
int defaultOT; int defaultOT{ 1 };
int enable_bot_mode; int enable_bot_mode{ 0 };
int quick_animation; int quick_animation{ 0 };
int auto_save_replay; int auto_save_replay{ 0 };
int draw_single_chain; int draw_single_chain{ 0 };
int hide_player_name; int hide_player_name{ 0 };
int prefer_expansion_script; int prefer_expansion_script{ 0 };
bool enable_sound; bool enable_sound{ true };
bool enable_music; bool enable_music{ true };
double sound_volume; double sound_volume{ 0.5 };
double music_volume; double music_volume{ 0.5 };
int music_mode; int music_mode{ 1 };
bool window_maximized; bool window_maximized{ false };
int window_width; int window_width{ 1024 };
int window_height; int window_height{ 640 };
bool resize_popup_menu; bool resize_popup_menu{ false };
}; };
struct DuelInfo { struct DuelInfo {
...@@ -79,35 +81,35 @@ struct DuelInfo { ...@@ -79,35 +81,35 @@ struct DuelInfo {
bool isTag{ false }; bool isTag{ false };
bool isSingleMode{ false }; bool isSingleMode{ false };
bool is_shuffling{ false }; bool is_shuffling{ false };
bool tag_player[2]{ false }; bool tag_player[2]{};
bool isReplaySwapped{ false }; bool isReplaySwapped{ false };
int lp[2]{ 0 }; int lp[2]{};
int start_lp{ 0 }; int start_lp{ 0 };
int duel_rule{ 0 }; int duel_rule{ 0 };
int turn{ 0 }; int turn{ 0 };
short curMsg{ 0 }; short curMsg{ 0 };
wchar_t hostname[20]{ 0 }; wchar_t hostname[20]{};
wchar_t clientname[20]{ 0 }; wchar_t clientname[20]{};
wchar_t hostname_tag[20]{ 0 }; wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{ 0 }; wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{ 0 }; wchar_t strLP[2][16]{};
wchar_t* vic_string{ 0 }; wchar_t* vic_string{ nullptr };
unsigned char player_type{ 0 }; unsigned char player_type{ 0 };
unsigned char time_player{ 0 }; unsigned char time_player{ 0 };
unsigned short time_limit{ 0 }; unsigned short time_limit{ 0 };
unsigned short time_left[2]{ 0 }; unsigned short time_left[2]{};
void Clear(); void Clear();
}; };
struct BotInfo { struct BotInfo {
wchar_t name[256]; wchar_t name[256]{};
wchar_t command[256]; wchar_t command[256]{};
wchar_t desc[256]; wchar_t desc[256]{};
bool support_master_rule_3; bool support_master_rule_3{ false };
bool support_new_master_rule; bool support_new_master_rule{ false };
bool support_master_rule_2020; bool support_master_rule_2020{ false };
bool select_deckfile; bool select_deckfile{ false };
}; };
struct FadingUnit { struct FadingUnit {
...@@ -226,8 +228,8 @@ public: ...@@ -226,8 +228,8 @@ public:
int hideChatTimer; int hideChatTimer;
bool hideChat; bool hideChat;
int chatTiming[8]; int chatTiming[8]{};
int chatType[8]; int chatType[8]{};
unsigned short linePatternD3D; unsigned short linePatternD3D;
unsigned short linePatternGL; unsigned short linePatternGL;
int waitFrame; int waitFrame;
...@@ -846,8 +848,6 @@ extern unsigned int pre_seed[3]; ...@@ -846,8 +848,6 @@ extern unsigned int pre_seed[3];
#define AVAIL_SC 0x8 #define AVAIL_SC 0x8
#define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG) #define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG)
#define DEFAULT_DUEL_RULE 5
#define CARD_ARTWORK_VERSIONS_OFFSET 10 #define CARD_ARTWORK_VERSIONS_OFFSET 10
#define MAX_LAYER_COUNT 6 #define MAX_LAYER_COUNT 6
#endif // GAME_H #endif // GAME_H
...@@ -21,11 +21,11 @@ public: ...@@ -21,11 +21,11 @@ public:
S3DVertex vFieldSpell2[4]; S3DVertex vFieldSpell2[4];
//S3DVertex vBackLine[76]; //S3DVertex vBackLine[76];
S3DVertex vFieldDeck[2][4]; S3DVertex vFieldDeck[2][4];
S3DVertex vFieldGrave[2][2][4]; S3DVertex vFieldGrave[2][2][4]; //[player][rule], rule = 0: dule_rule <= 3, 1: dule_rule >= 4
S3DVertex vFieldExtra[2][4]; S3DVertex vFieldExtra[2][4];
S3DVertex vFieldRemove[2][2][4]; S3DVertex vFieldRemove[2][2][4]; //[player][rule]
S3DVertex vFieldMzone[2][7][4]; S3DVertex vFieldMzone[2][7][4]; //[player][sequence]
S3DVertex vFieldSzone[2][8][2][4]; S3DVertex vFieldSzone[2][8][2][4]; //[player][sequence][rule]
irr::core::vector3df vFieldContiAct[4]; irr::core::vector3df vFieldContiAct[4];
S3DVertex vArrow[40]; S3DVertex vArrow[40];
SColor c2d[4]; SColor c2d[4];
......
...@@ -99,9 +99,8 @@ struct STOC_HS_WatchChange { ...@@ -99,9 +99,8 @@ struct STOC_HS_WatchChange {
class DuelMode; class DuelMode;
struct DuelPlayer { struct DuelPlayer {
unsigned short name[20]{ 0 }; unsigned short name[20]{};
DuelMode* game{ nullptr }; DuelMode* game{ nullptr };
unsigned char player_id{ 0xff };
unsigned char type{ 0 }; unsigned char type{ 0 };
unsigned char state{ 0 }; unsigned char state{ 0 };
bufferevent* bev{ 0 }; bufferevent* bev{ 0 };
......
...@@ -293,7 +293,7 @@ void ReplayMode::Restart(bool refresh) { ...@@ -293,7 +293,7 @@ void ReplayMode::Restart(bool refresh) {
std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname); std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname);
std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag); std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag);
} }
skip_turn = 0; skip_turn = 0;
} }
void ReplayMode::Undo() { void ReplayMode::Undo() {
if(skip_step > 0 || current_step == 0) if(skip_step > 0 || current_step == 0)
......
...@@ -461,8 +461,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) { ...@@ -461,8 +461,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
hand_result[1] = 0; hand_result[1] = 0;
players[0]->state = CTOS_HAND_RESULT; players[0]->state = CTOS_HAND_RESULT;
players[1]->state = CTOS_HAND_RESULT; players[1]->state = CTOS_HAND_RESULT;
players[0]->player_id = 0;
players[1]->player_id = 1;
duel_stage = DUEL_STAGE_FINGER; duel_stage = DUEL_STAGE_FINGER;
} }
void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) { void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) {
...@@ -513,6 +511,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -513,6 +511,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
return; return;
duel_stage = DUEL_STAGE_DUELING; duel_stage = DUEL_STAGE_DUELING;
bool swapped = false; bool swapped = false;
pplayer[0] = players[0];
pplayer[1] = players[1];
if((tp && dp->type == 1) || (!tp && dp->type == 0)) { if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0]; DuelPlayer* p = players[0];
players[0] = players[1]; players[0] = players[1];
...@@ -686,6 +686,15 @@ void SingleDuel::DuelEndProc() { ...@@ -686,6 +686,15 @@ void SingleDuel::DuelEndProc() {
duel_stage = DUEL_STAGE_END; duel_stage = DUEL_STAGE_END;
#endif #endif
} else { } else {
if(players[0] != pplayer[0]) {
players[0] = pplayer[0];
players[1] = pplayer[1];
players[0]->type = 0;
players[1]->type = 1;
Deck d = pdeck[0];
pdeck[0] = pdeck[1];
pdeck[1] = d;
}
ready[0] = false; ready[0] = false;
ready[1] = false; ready[1] = false;
players[0]->state = CTOS_UPDATE_DECK; players[0]->state = CTOS_UPDATE_DECK;
...@@ -705,7 +714,7 @@ void SingleDuel::DuelEndProc() { ...@@ -705,7 +714,7 @@ void SingleDuel::DuelEndProc() {
} }
} }
void SingleDuel::Surrender(DuelPlayer* dp) { void SingleDuel::Surrender(DuelPlayer* dp) {
if (dp->type > 1 || dp->player_id > 1 || !pduel) if(dp->type > 1 || !pduel)
return; return;
unsigned char wbuf[3]; unsigned char wbuf[3];
uint32 player = dp->type; uint32 player = dp->type;
...@@ -719,9 +728,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) { ...@@ -719,9 +728,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) {
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
NetServer::ReSendToPlayers(cache_recorder, replay_recorder); NetServer::ReSendToPlayers(cache_recorder, replay_recorder);
#endif #endif
match_result[duel_count] = 1 - dp->player_id; if(players[player] == pplayer[player]) {
++duel_count; match_result[duel_count++] = 1 - player;
tp_player = player; tp_player = player;
} else {
match_result[duel_count++] = player;
tp_player = 1 - player;
}
EndDuel(); EndDuel();
DuelEndProc(); DuelEndProc();
event_del(etimer); event_del(etimer);
...@@ -792,14 +805,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -792,14 +805,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayers(cache_recorder, replay_recorder); NetServer::ReSendToPlayers(cache_recorder, replay_recorder);
#endif #endif
if(player > 1) { if(player > 1) {
match_result[duel_count] = 2; match_result[duel_count++] = 2;
tp_player = 1 - tp_player; tp_player = 1 - tp_player;
} } else if(players[player] == pplayer[player]) {
else { match_result[duel_count++] = player;
match_result[duel_count] = players[player]->player_id;
tp_player = 1 - player; tp_player = 1 - player;
} else {
match_result[duel_count++] = 1 - player;
tp_player = player;
} }
++duel_count;
EndDuel(); EndDuel();
return 2; return 2;
} }
...@@ -2183,9 +2197,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) { ...@@ -2183,9 +2197,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
NetServer::ReSendToPlayers(sd->cache_recorder, sd->replay_recorder); NetServer::ReSendToPlayers(sd->cache_recorder, sd->replay_recorder);
#endif #endif
sd->match_result[sd->duel_count] = sd->players[1 - player]->player_id; if(sd->players[player] == sd->pplayer[player]) {
++sd->duel_count; sd->match_result[sd->duel_count++] = 1 - player;
sd->tp_player = player; sd->tp_player = player;
} else {
sd->match_result[sd->duel_count++] = player;
sd->tp_player = 1 - player;
}
sd->EndDuel(); sd->EndDuel();
sd->DuelEndProc(); sd->DuelEndProc();
event_del(sd->etimer); event_del(sd->etimer);
......
...@@ -57,11 +57,12 @@ private: ...@@ -57,11 +57,12 @@ private:
int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache); int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache);
protected: protected:
DuelPlayer* players[2]{ nullptr }; DuelPlayer* players[2]{};
bool ready[2]{ false }; DuelPlayer* pplayer[2]{};
bool ready[2]{};
Deck pdeck[2]; Deck pdeck[2];
int deck_error[2]{ 0 }; int deck_error[2]{};
unsigned char hand_result[2]{ 0 }; unsigned char hand_result[2]{};
unsigned char last_response{ 0 }; unsigned char last_response{ 0 };
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
...@@ -75,8 +76,8 @@ protected: ...@@ -75,8 +76,8 @@ protected:
int match_kill{ 0 }; int match_kill{ 0 };
unsigned char duel_count{ 0 }; unsigned char duel_count{ 0 };
unsigned char tp_player{ 0 }; unsigned char tp_player{ 0 };
unsigned char match_result[3]{ 0 }; unsigned char match_result[3]{};
short time_limit[2]{ 0 }; short time_limit[2]{};
short time_elapsed{ 0 }; short time_elapsed{ 0 };
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
short time_compensator[2]; short time_compensator[2];
......
#[2024.1][2024.1 TCG][2023.10][2023.7][2023.4][2023.1][2022.10][2022.7][2022.4][2022.1][2021.10][2021.7][2021.4][2021.1][2020.10][2020.7][2020.4][2020.1][2019.10][2019.7][2019.4][2019.1][2018.10][2018.7][2018.4][2018.1][2017.10][2017.7][2017.4][2017.1][2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2023.9 TCG][2023.6 TCG][2023.2 TCG][2022.12 TCG][2022.10 TCG][2022.5 TCG][2022.2 TCG][2021.10 TCG][2021.7 TCG][2021.3 TCG][2020.12 TCG][2020.9 TCG][2020.6 TCG][2020.4 TCG][2020.1 TCG][2019.10 TCG][2019.7 TCG][2019.4 TCG][2019.1 TCG][2018.12 TCG][2018.9 TCG][2018.5 TCG][2018.2 TCG][2017.11 TCG][2017.9 TCG][2017.6 TCG][2017.3 TCG][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1] #[2024.1][2024.1 TCG][2023.10][2023.7][2023.4][2023.1][2022.10][2022.7][2022.4][2022.1][2021.10][2021.7][2021.4][2021.1][2020.10][2020.7][2020.4][2020.1][2019.10][2019.7][2019.4][2019.1][2018.10][2018.7][2018.4][2018.1][2017.10][2017.7][2017.4][2017.1][2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2023.9 TCG][2023.6 TCG][2023.2 TCG][2022.12 TCG][2022.10 TCG][2022.5 TCG][2022.2 TCG][2021.10 TCG][2021.7 TCG][2021.3 TCG][2020.12 TCG][2020.9 TCG][2020.6 TCG][2020.4 TCG][2020.1 TCG][2019.10 TCG][2019.7 TCG][2019.4 TCG][2019.1 TCG][2018.12 TCG][2018.9 TCG][2018.5 TCG][2018.2 TCG][2017.11 TCG][2017.9 TCG][2017.6 TCG][2017.3 TCG][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1]
!2024.1 !2024.1
#forbidden #forbidden
91869203 0 --アマゾネスの射手 91869203 0 --アマゾネスの射手
......
Subproject commit c22a313eacfeb9987dc9fb03523f18a90620fba6 Subproject commit 52e79efa0da5294cf5218c107de224a0af264965
...@@ -318,8 +318,8 @@ ...@@ -318,8 +318,8 @@
!system 1260 大师规则 !system 1260 大师规则
!system 1261 大师规则2 !system 1261 大师规则2
!system 1262 大师规则3 !system 1262 大师规则3
!system 1263 新大师规则 !system 1263 新大师规则2017
!system 1264 大师规则2020 !system 1264 大师规则2020
!system 1270 卡片信息 !system 1270 卡片信息
!system 1271 消息记录 !system 1271 消息记录
!system 1272 清除记录 !system 1272 清除记录
...@@ -1206,3 +1206,4 @@ ...@@ -1206,3 +1206,4 @@
!setname 0x1a5 于贝尔 ユベル !setname 0x1a5 于贝尔 ユベル
!setname 0x1a6 肃声 粛声 !setname 0x1a6 肃声 粛声
!setname 0x1a7 白斗气 ホワイト・オーラ !setname 0x1a7 白斗气 ホワイト・オーラ
!setname 0x1a8 玩具 トイ
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