Commit 780e3abd authored by fallenstardust's avatar fallenstardust

update Gframe

parent 64eb4ed8
...@@ -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)
......
...@@ -92,12 +92,12 @@ public: ...@@ -92,12 +92,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();
......
...@@ -31,39 +31,39 @@ ClientField::ClientField() { ...@@ -31,39 +31,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();
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,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 };
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,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;
......
...@@ -213,9 +213,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -213,9 +213,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
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(options); deckManager.LoadLFList(options);
driver = device->getVideoDriver(); driver = device->getVideoDriver();
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -1664,7 +1661,7 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo ...@@ -1664,7 +1661,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(!wcsncasecmp(deckpath, L"./pack", 6)) { if(!wcsncasecmp(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());
} }
} }
...@@ -1744,8 +1741,6 @@ void Game::RefreshBot() { ...@@ -1744,8 +1741,6 @@ void Game::RefreshBot() {
} }
void Game::LoadConfig() { void Game::LoadConfig() {
wchar_t wstr[256]; wchar_t wstr[256];
if(gameConf._init)return;
gameConf._init = TRUE;
gameConf.antialias = 1; gameConf.antialias = 1;
gameConf.serverport = 7911; gameConf.serverport = 7911;
gameConf.textfontsize = android::getIntSetting(appMain, "textfontsize", 18);; gameConf.textfontsize = android::getIntSetting(appMain, "textfontsize", 18);;
...@@ -1790,7 +1785,6 @@ void Game::LoadConfig() { ...@@ -1790,7 +1785,6 @@ void Game::LoadConfig() {
//defult Setting without checked //defult Setting without checked
gameConf.default_rule = DEFAULT_DUEL_RULE; gameConf.default_rule = DEFAULT_DUEL_RULE;
gameConf.hide_setname = 0; gameConf.hide_setname = 0;
gameConf.hide_hint_button = 0;
gameConf.separate_clear_button = 1; gameConf.separate_clear_button = 1;
gameConf.search_multiple_keywords = 1; gameConf.search_multiple_keywords = 1;
gameConf.defaultOT = 1; gameConf.defaultOT = 1;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <vector> #include <vector>
#include <list> #include <list>
#define DEFAULT_DUEL_RULE 5
namespace ygo { namespace ygo {
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
...@@ -21,54 +23,53 @@ namespace ygo { ...@@ -21,54 +23,53 @@ namespace ygo {
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG ,__VA_ARGS__) #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG ,__VA_ARGS__)
#endif #endif
struct Config { struct Config {
bool _init; bool use_d3d{ false };
bool use_d3d; bool use_image_scale{ true };
bool use_image_scale; unsigned short antialias{ 1 };
unsigned short antialias; unsigned short serverport{ 7911 };
unsigned short serverport; unsigned char textfontsize{ 18 };
unsigned char textfontsize; 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{ 0 };
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 };
//sound //sound
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 };
double music_mode; double music_mode;
}; };
...@@ -81,24 +82,24 @@ struct DuelInfo { ...@@ -81,24 +82,24 @@ 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();
int card_count[2]; int card_count[2];
...@@ -112,13 +113,13 @@ struct DuelInfo { ...@@ -112,13 +113,13 @@ struct DuelInfo {
}; };
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 {
...@@ -229,8 +230,8 @@ public: ...@@ -229,8 +230,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;
...@@ -941,8 +942,6 @@ extern Game* mainGame; ...@@ -941,8 +942,6 @@ extern Game* mainGame;
#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
......
...@@ -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 };
......
...@@ -340,8 +340,6 @@ void SingleDuel::StartDuel(DuelPlayer* dp) { ...@@ -340,8 +340,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) {
...@@ -389,6 +387,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -389,6 +387,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];
...@@ -529,6 +529,15 @@ void SingleDuel::DuelEndProc() { ...@@ -529,6 +529,15 @@ void SingleDuel::DuelEndProc() {
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
duel_stage = DUEL_STAGE_END; duel_stage = DUEL_STAGE_END;
} 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;
...@@ -542,7 +551,7 @@ void SingleDuel::DuelEndProc() { ...@@ -542,7 +551,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;
...@@ -553,9 +562,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) { ...@@ -553,9 +562,13 @@ void SingleDuel::Surrender(DuelPlayer* dp) {
NetServer::ReSendToPlayer(players[1]); NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
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);
...@@ -614,14 +627,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) { ...@@ -614,14 +627,15 @@ int SingleDuel::Analyze(unsigned char* msgbuffer, unsigned int len) {
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
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;
} }
...@@ -1580,9 +1594,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) { ...@@ -1580,9 +1594,13 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
NetServer::ReSendToPlayer(sd->players[1]); NetServer::ReSendToPlayer(sd->players[1]);
for(auto oit = sd->observers.begin(); oit != sd->observers.end(); ++oit) for(auto oit = sd->observers.begin(); oit != sd->observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
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);
......
...@@ -45,11 +45,12 @@ private: ...@@ -45,11 +45,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;
Replay last_replay; Replay last_replay;
...@@ -57,8 +58,8 @@ protected: ...@@ -57,8 +58,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 };
}; };
......
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