Commit ce4de69e authored by fallenstardust's avatar fallenstardust

update gframe

parent 8cf2c0e2
...@@ -121,7 +121,7 @@ using namespace gui; ...@@ -121,7 +121,7 @@ using namespace gui;
using namespace os; using namespace os;
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
extern int enable_log; extern unsigned int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
extern bool bot_mode; extern bool bot_mode;
#endif #endif
......
...@@ -142,24 +142,30 @@ bool DataManager::LoadStrings(IReadFile* reader) { ...@@ -142,24 +142,30 @@ bool DataManager::LoadStrings(IReadFile* reader) {
void DataManager::ReadStringConfLine(const char* linebuf) { void DataManager::ReadStringConfLine(const char* linebuf) {
if(linebuf[0] != '!') if(linebuf[0] != '!')
return; return;
char strbuf[256]; char strbuf[256]{};
int value; int value{};
wchar_t strBuffer[4096]; wchar_t strBuffer[4096]{};
sscanf(linebuf, "!%s", strbuf); if (sscanf(linebuf, "!%63s", strbuf) != 1)
return;
if(!strcmp(strbuf, "system")) { if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf); if (sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer; _sysStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "victory")) { } else if(!strcmp(strbuf, "victory")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf); if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer; _victoryStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "counter")) { } else if(!strcmp(strbuf, "counter")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf); if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer; _counterStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "setname")) { } else if(!strcmp(strbuf, "setname")) {
sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf);//using tab for comment //using tab for comment
if (sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer); BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer; _setnameStrings[value] = strBuffer;
} }
......
...@@ -12,15 +12,16 @@ DeckManager deckManager; ...@@ -12,15 +12,16 @@ DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) { void DeckManager::LoadLFListSingle(const char* path) {
LFList* cur = nullptr; LFList* cur = nullptr;
FILE* fp = fopen(path, "r"); FILE* fp = fopen(path, "r");
char linebuf[256]; char linebuf[256]{};
wchar_t strBuffer[256]; wchar_t strBuffer[256]{};
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
continue; continue;
if(linebuf[0] == '!') { if(linebuf[0] == '!') {
int sa = BufferIO::DecodeUTF8(&linebuf[1], strBuffer); int sa = BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) sa--; while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' )
sa--;
strBuffer[sa] = 0; strBuffer[sa] = 0;
LFList newlist; LFList newlist;
_lfList.push_back(newlist); _lfList.push_back(newlist);
...@@ -29,20 +30,18 @@ void DeckManager::LoadLFListSingle(const char* path) { ...@@ -29,20 +30,18 @@ void DeckManager::LoadLFListSingle(const char* path) {
cur->hash = 0x7dfcee6a; cur->hash = 0x7dfcee6a;
continue; continue;
} }
int p = 0; if(linebuf[0] == 0)
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
if(linebuf[p] == 0)
continue; continue;
linebuf[p++] = 0; int code = 0;
int sa = p; int count = -1;
int code = atoi(linebuf); if (sscanf(linebuf, "%d %d", &code, &count) != 2)
if(code == 0) continue;
if (code <= 0 || code > 99999999)
continue;
if (count < 0 || count > 2)
continue;
if (!cur)
continue; continue;
while(linebuf[p] == ' ' || linebuf[p] == '\t') p++;
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
linebuf[p] = 0;
int count = atoi(&linebuf[sa]);
if(!cur) continue;
cur->content[code] = count; cur->content[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count))); cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
} }
......
...@@ -212,6 +212,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -212,6 +212,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->is_building = false; mainGame->is_building = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
...@@ -375,6 +376,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -375,6 +376,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
case STOC_CHANGE_SIDE: { case STOC_CHANGE_SIDE: {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->is_building = true; mainGame->is_building = true;
mainGame->is_siding = true; mainGame->is_siding = true;
...@@ -406,6 +408,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -406,6 +408,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break; break;
} }
case STOC_WAITING_SIDE: { case STOC_WAITING_SIDE: {
mainGame->dInfo.isInDuel = false;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->stHintMsg->setText(dataManager.GetSysString(1409)); mainGame->stHintMsg->setText(dataManager.GetSysString(1409));
...@@ -683,6 +686,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -683,6 +686,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
...@@ -763,28 +767,17 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -763,28 +767,17 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
case STOC_CHAT: { case STOC_CHAT: {
STOC_Chat* pkt = (STOC_Chat*)pdata; STOC_Chat* pkt = (STOC_Chat*)pdata;
int player = pkt->player; int player = pkt->player;
auto play_sound = false;
if(player < 4) { if(player < 4) {
if(mainGame->chkIgnore1->isChecked()) if(mainGame->chkIgnore1->isChecked())
break; break;
if(!mainGame->dInfo.isTag) { auto localplayer = mainGame->ChatLocalPlayer(player);
if(mainGame->dInfo.isStarted) player = localplayer & 0xf;
player = mainGame->LocalPlayer(player); if(!(localplayer & 0x10))
} else { play_sound = true;
if(mainGame->dInfo.isStarted && !mainGame->dInfo.isFirst)
player ^= 2;
if(player == 0)
player = 0;
else if(player == 1)
player = 2;
else if(player == 2)
player = 1;
else if(player == 3)
player = 3;
else
player = 10;
}
} else { } else {
if(player == 8) { //system custom message. if(player == 8) { //system custom message.
play_sound = true;
if(mainGame->chkIgnore1->isChecked()) if(mainGame->chkIgnore1->isChecked())
break; break;
} else if(player < 11 || player > 19) { } else if(player < 11 || player > 19) {
...@@ -796,7 +789,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) { ...@@ -796,7 +789,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
wchar_t msg[256]; wchar_t msg[256];
BufferIO::CopyWStr(pkt->msg, msg, 256); BufferIO::CopyWStr(pkt->msg, msg, 256);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->AddChatMsg(msg, player); mainGame->AddChatMsg(msg, player, play_sound);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
break; break;
} }
...@@ -1010,6 +1003,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1010,6 +1003,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
......
...@@ -23,7 +23,6 @@ private: ...@@ -23,7 +23,6 @@ private:
static unsigned char response_buf[SIZE_RETURN_VALUE]; static unsigned char response_buf[SIZE_RETURN_VALUE];
static unsigned int response_len; static unsigned int response_len;
static unsigned int watching; static unsigned int watching;
static unsigned char selftype;
static bool is_host; static bool is_host;
static event_base* client_base; static event_base* client_base;
static bufferevent* client_bev; static bufferevent* client_bev;
...@@ -39,6 +38,7 @@ private: ...@@ -39,6 +38,7 @@ private:
static wchar_t event_string[256]; static wchar_t event_string[256];
static mt19937 rnd; static mt19937 rnd;
public: public:
static unsigned char selftype;
static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true); static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true);
static void ConnectTimeout(evutil_socket_t fd, short events, void* arg); static void ConnectTimeout(evutil_socket_t fd, short events, void* arg);
static void StopClient(bool is_exiting = false); static void StopClient(bool is_exiting = false);
......
...@@ -132,6 +132,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -132,6 +132,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->dInfo.player_type == 7) { if(mainGame->dInfo.player_type == 7) {
DuelClient::StopClient(); DuelClient::StopClient();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->CloseDuelWindow(); mainGame->CloseDuelWindow();
......
...@@ -29,6 +29,7 @@ Game *mainGame; ...@@ -29,6 +29,7 @@ Game *mainGame;
void DuelInfo::Clear() { void DuelInfo::Clear() {
isStarted = false; isStarted = false;
isInDuel = false;
isFinished = false; isFinished = false;
isReplay = false; isReplay = false;
isReplaySkiping = false; isReplaySkiping = false;
...@@ -1705,23 +1706,29 @@ void Game::RefreshBot() { ...@@ -1705,23 +1706,29 @@ void Game::RefreshBot() {
return; return;
botInfo.clear(); botInfo.clear();
FILE* fp = fopen("bot.conf", "r"); FILE* fp = fopen("bot.conf", "r");
char linebuf[256]; char linebuf[256]{};
char strbuf[256]; char strbuf[256]{};
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
continue; continue;
if(linebuf[0] == '!') { if(linebuf[0] == '!') {
BotInfo newinfo; BotInfo newinfo;
sscanf(linebuf, "!%240[^\n]", strbuf); if (sscanf(linebuf, "!%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.name); BufferIO::DecodeUTF8(strbuf, newinfo.name);
fgets(linebuf, 256, fp); if (!fgets(linebuf, 256, fp))
sscanf(linebuf, "%240[^\n]", strbuf); break;
if (sscanf(linebuf, "%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.command); BufferIO::DecodeUTF8(strbuf, newinfo.command);
fgets(linebuf, 256, fp); if (!fgets(linebuf, 256, fp))
sscanf(linebuf, "%240[^\n]", strbuf); break;
if (sscanf(linebuf, "%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.desc); BufferIO::DecodeUTF8(strbuf, newinfo.desc);
fgets(linebuf, 256, fp); if (!fgets(linebuf, 256, fp))
break;
newinfo.support_master_rule_3 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_3"); newinfo.support_master_rule_3 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_3");
newinfo.support_new_master_rule = !!strstr(linebuf, "SUPPORT_NEW_MASTER_RULE"); newinfo.support_new_master_rule = !!strstr(linebuf, "SUPPORT_NEW_MASTER_RULE");
newinfo.support_master_rule_2020 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_2020"); newinfo.support_master_rule_2020 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_2020");
...@@ -1745,7 +1752,8 @@ void Game::RefreshBot() { ...@@ -1745,7 +1752,8 @@ void Game::RefreshBot() {
} }
if(botInfo.size() == 0) { if(botInfo.size() == 0) {
SetStaticText(stBotInfo, 200, guiFont, dataManager.GetSysString(1385)); SetStaticText(stBotInfo, 200, guiFont, dataManager.GetSysString(1385));
} else { }
else {
RefreshCategoryDeck(cbBotDeckCategory, cbBotDeck); RefreshCategoryDeck(cbBotDeckCategory, cbBotDeck);
deckBuilder.prev_category = mainGame->cbBotDeckCategory->getSelected(); deckBuilder.prev_category = mainGame->cbBotDeckCategory->getSelected();
deckBuilder.prev_deck = mainGame->cbBotDeck->getSelected(); deckBuilder.prev_deck = mainGame->cbBotDeck->getSelected();
...@@ -1968,7 +1976,7 @@ void Game::AddLog(const wchar_t* msg, int param) { ...@@ -1968,7 +1976,7 @@ void Game::AddLog(const wchar_t* msg, int param) {
lstLog->setSelected(-1); lstLog->setSelected(-1);
} }
} }
void Game::AddChatMsg(const wchar_t* msg, int player) { void Game::AddChatMsg(const wchar_t* msg, int player, bool play_sound) {
for(int i = 7; i > 0; --i) { for(int i = 7; i > 0; --i) {
chatMsg[i] = chatMsg[i - 1]; chatMsg[i] = chatMsg[i - 1];
chatTiming[i] = chatTiming[i - 1]; chatTiming[i] = chatTiming[i - 1];
...@@ -1979,23 +1987,22 @@ void Game::AddChatMsg(const wchar_t* msg, int player) { ...@@ -1979,23 +1987,22 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatType[0] = player; chatType[0] = player;
if(gameConf.hide_player_name && player < 4) if(gameConf.hide_player_name && player < 4)
player = 10; player = 10;
if(play_sound)
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
switch(player) { switch(player) {
case 0: //from host case 0: //from host
chatMsg[0].append(dInfo.hostname); chatMsg[0].append(dInfo.hostname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 1: //from client case 1: //from client
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.clientname); chatMsg[0].append(dInfo.clientname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 2: //host tag case 2: //host tag
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.hostname_tag); chatMsg[0].append(dInfo.hostname_tag);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 3: //client tag case 3: //client tag
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(dInfo.clientname_tag); chatMsg[0].append(dInfo.clientname_tag);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
...@@ -2004,7 +2011,6 @@ void Game::AddChatMsg(const wchar_t* msg, int player) { ...@@ -2004,7 +2011,6 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 8: //system custom message, no prefix. case 8: //system custom message, no prefix.
soundManager->PlaySoundEffect(SoundManager::SFX::CHAT);
chatMsg[0].append(L"[System]: "); chatMsg[0].append(L"[System]: ");
break; break;
case 9: //error message case 9: //error message
...@@ -2128,6 +2134,40 @@ int Game::LocalPlayer(int player) const { ...@@ -2128,6 +2134,40 @@ int Game::LocalPlayer(int player) const {
int pid = player ? 1 : 0; int pid = player ? 1 : 0;
return dInfo.isFirst ? pid : 1 - pid; return dInfo.isFirst ? pid : 1 - pid;
} }
int Game::OppositePlayer(int player) {
auto player_side_bit = dInfo.isTag ? 0x2 : 0x1;
return player ^ player_side_bit;
}
int Game::ChatLocalPlayer(int player) {
if(player > 3)
return player;
bool is_self;
if(dInfo.isStarted || is_siding) {
if(dInfo.isInDuel)
// when in duel
player = mainGame->dInfo.isFirst ? player : OppositePlayer(player);
else {
// when changing side or waiting tp result
auto selftype_boundary = dInfo.isTag ? 2 : 1;
if(DuelClient::selftype >= selftype_boundary && DuelClient::selftype < 4)
player = OppositePlayer(player);
}
if (DuelClient::selftype >= 4) {
is_self = false;
} else if (dInfo.isTag) {
is_self = (player & 0x2) == 0 && (player & 0x1) == (DuelClient::selftype & 0x1);
} else {
is_self = player == 0;
}
} else {
// when in lobby
is_self = player == DuelClient::selftype;
}
if(dInfo.isTag && (player == 1 || player == 2)) {
player = 3 - player;
}
return player | (is_self ? 0x10 : 0);
}
const wchar_t* Game::LocalName(int local_player) { const wchar_t* Game::LocalName(int local_player) {
return local_player == 0 ? dInfo.hostname : dInfo.clientname; return local_player == 0 ? dInfo.hostname : dInfo.clientname;
} }
......
...@@ -75,7 +75,8 @@ struct Config { ...@@ -75,7 +75,8 @@ struct Config {
struct DuelInfo { struct DuelInfo {
bool isStarted{ false }; bool isStarted{ false };
bool isFinished{ false }; bool isInDuel{ false };
bool isFinished{false};
bool isReplay{ false }; bool isReplay{ false };
bool isReplaySkiping{ false }; bool isReplaySkiping{ false };
bool isFirst{ false }; bool isFirst{ false };
...@@ -179,7 +180,7 @@ public: ...@@ -179,7 +180,7 @@ public:
void ShowCardInfo(int code); void ShowCardInfo(int code);
void ClearCardInfo(int player = 0); void ClearCardInfo(int player = 0);
void AddLog(const wchar_t* msg, int param = 0); void AddLog(const wchar_t* msg, int param = 0);
void AddChatMsg(const wchar_t* msg, int player); void AddChatMsg(const wchar_t* msg, int player, bool play_sound = false);
void ClearChatMsg(); void ClearChatMsg();
void AddDebugMsg(const char* msgbuf); void AddDebugMsg(const char* msgbuf);
void ErrorLog(const char* msgbuf); void ErrorLog(const char* msgbuf);
...@@ -194,6 +195,8 @@ public: ...@@ -194,6 +195,8 @@ public:
void ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITexture* image, irr::video::ITexture* pressedImage, irr::gui::CGUITTFont* font=0); void ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITexture* image, irr::video::ITexture* pressedImage, irr::gui::CGUITTFont* font=0);
int LocalPlayer(int player) const; int LocalPlayer(int player) const;
int OppositePlayer(int player);
int ChatLocalPlayer(int player);
const wchar_t* LocalName(int local_player); const wchar_t* LocalName(int local_player);
bool HasFocus(EGUI_ELEMENT_TYPE type) const { bool HasFocus(EGUI_ELEMENT_TYPE type) const {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <event2/thread.h> #include <event2/thread.h>
#include <memory> #include <memory>
int enable_log = 0; unsigned int enable_log = 0x3;
bool exit_on_return = false; bool exit_on_return = false;
bool bot_mode = false; bool bot_mode = false;
......
...@@ -254,6 +254,7 @@ void ReplayMode::EndDuel() { ...@@ -254,6 +254,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false; mainGame->dInfo.isReplay = false;
mainGame->dInfo.isSingleMode = false; mainGame->dInfo.isSingleMode = false;
...@@ -273,6 +274,7 @@ void ReplayMode::EndDuel() { ...@@ -273,6 +274,7 @@ void ReplayMode::EndDuel() {
void ReplayMode::Restart(bool refresh) { void ReplayMode::Restart(bool refresh) {
end_duel(pduel); end_duel(pduel);
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dField.Clear(); mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField); //mainGame->device->setEventReceiver(&mainGame->dField);
......
...@@ -148,6 +148,7 @@ int SingleMode::SinglePlayThread() { ...@@ -148,6 +148,7 @@ int SingleMode::SinglePlayThread() {
if(!is_closing) { if(!is_closing) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isInDuel = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.isSingleMode = false; mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
......
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