Commit eb62b494 authored by mercury233's avatar mercury233

Merge branch 'fh' into patch-show-pack

parents 929e6b4e 26d7f2fe
...@@ -141,6 +141,7 @@ public: ...@@ -141,6 +141,7 @@ public:
virtual bool OnCommonEvent(const irr::SEvent& event); virtual bool OnCommonEvent(const irr::SEvent& event);
void GetHoverField(int x, int y); void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y); void ShowMenu(int flag, int x, int y);
void HideMenu();
void UpdateChainButtons(); void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable); void SetShowMark(ClientCard* pcard, bool enable);
......
...@@ -34,7 +34,7 @@ mt19937 DuelClient::rnd; ...@@ -34,7 +34,7 @@ mt19937 DuelClient::rnd;
bool DuelClient::is_refreshing = false; bool DuelClient::is_refreshing = false;
int DuelClient::match_kill = 0; int DuelClient::match_kill = 0;
std::vector<HostPacket> DuelClient::hosts; std::vector<HostPacket> DuelClient::hosts;
std::set<unsigned int> DuelClient::remotes; std::set<std::pair<unsigned int, unsigned short>> DuelClient::remotes;
event* DuelClient::resp_event = 0; event* DuelClient::resp_event = 0;
bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_game) { bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_game) {
...@@ -603,6 +603,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -603,6 +603,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
if(!mainGame->chkIgnore1->isChecked()) if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
if(mainGame->chkDefaultShowChain->isChecked()) {
mainGame->always_chain = true;
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
}
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) { if(!mainGame->dInfo.isTag) {
if(selftype > 1) { if(selftype > 1) {
...@@ -874,7 +879,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -874,7 +879,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
memcpy(last_successful_msg, msg, len); memcpy(last_successful_msg, msg, len);
last_successful_msg_length = len; last_successful_msg_length = len;
} }
mainGame->wCmdMenu->setVisible(false); mainGame->dField.HideMenu();
if(!mainGame->dInfo.isReplay && mainGame->dInfo.curMsg != MSG_WAITING && mainGame->dInfo.curMsg != MSG_CARD_SELECTED) { if(!mainGame->dInfo.isReplay && mainGame->dInfo.curMsg != MSG_WAITING && mainGame->dInfo.curMsg != MSG_CARD_SELECTED) {
mainGame->waitFrame = -1; mainGame->waitFrame = -1;
mainGame->stHintMsg->setVisible(false); mainGame->stHintMsg->setVisible(false);
...@@ -4033,11 +4038,16 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) { ...@@ -4033,11 +4038,16 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
socklen_t sz = sizeof(sockaddr_in); socklen_t sz = sizeof(sockaddr_in);
char buf[256]; char buf[256];
/*int ret = */recvfrom(fd, buf, 256, 0, (sockaddr*)&bc_addr, &sz); /*int ret = */recvfrom(fd, buf, 256, 0, (sockaddr*)&bc_addr, &sz);
unsigned int ipaddr = bc_addr.sin_addr.s_addr;
HostPacket* pHP = (HostPacket*)buf; HostPacket* pHP = (HostPacket*)buf;
if(!is_closing && pHP->identifier == NETWORK_SERVER_ID && pHP->version == PRO_VERSION && remotes.find(ipaddr) == remotes.end() ) { if(is_closing || pHP->identifier != NETWORK_SERVER_ID)
return;
if(pHP->version != PRO_VERSION)
return;
unsigned int ipaddr = bc_addr.sin_addr.s_addr;
const auto remote = std::make_pair(ipaddr, pHP->port);
if(remotes.find(remote) == remotes.end()) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
remotes.insert(ipaddr); remotes.insert(remote);
pHP->ipaddr = ipaddr; pHP->ipaddr = ipaddr;
hosts.push_back(*pHP); hosts.push_back(*pHP);
std::wstring hoststr; std::wstring hoststr;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <utility>
#include <event2/event.h> #include <event2/event.h>
#include <event2/listener.h> #include <event2/listener.h>
#include <event2/bufferevent.h> #include <event2/bufferevent.h>
...@@ -76,7 +77,7 @@ protected: ...@@ -76,7 +77,7 @@ protected:
static bool is_refreshing; static bool is_refreshing;
static int match_kill; static int match_kill;
static event* resp_event; static event* resp_event;
static std::set<unsigned int> remotes; static std::set<std::pair<unsigned int, unsigned short>> remotes;
public: public:
static std::vector<HostPacket> hosts; static std::vector<HostPacket> hosts;
static void BeginRefreshHost(); static void BeginRefreshHost();
......
...@@ -363,7 +363,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -363,7 +363,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_ACTIVATE: case BUTTON_CMD_ACTIVATE:
case BUTTON_CMD_RESET: { case BUTTON_CMD_RESET: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
ShowCancelOrFinishButton(0); ShowCancelOrFinishButton(0);
if(!list_command) { if(!list_command) {
if(!menu_card) if(!menu_card)
...@@ -449,7 +449,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -449,7 +449,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_SUMMON: { case BUTTON_CMD_SUMMON: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!menu_card) if(!menu_card)
break; break;
for(size_t i = 0; i < summonable_cards.size(); ++i) { for(size_t i = 0; i < summonable_cards.size(); ++i) {
...@@ -463,7 +463,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -463,7 +463,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_SPSUMMON: { case BUTTON_CMD_SPSUMMON: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!list_command) { if(!list_command) {
if(!menu_card) if(!menu_card)
break; break;
...@@ -506,7 +506,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -506,7 +506,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_MSET: { case BUTTON_CMD_MSET: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!menu_card) if(!menu_card)
break; break;
for(size_t i = 0; i < msetable_cards.size(); ++i) { for(size_t i = 0; i < msetable_cards.size(); ++i) {
...@@ -519,7 +519,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -519,7 +519,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_SSET: { case BUTTON_CMD_SSET: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!menu_card) if(!menu_card)
break; break;
for(size_t i = 0; i < ssetable_cards.size(); ++i) { for(size_t i = 0; i < ssetable_cards.size(); ++i) {
...@@ -532,7 +532,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -532,7 +532,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_REPOS: { case BUTTON_CMD_REPOS: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!menu_card) if(!menu_card)
break; break;
for(size_t i = 0; i < reposable_cards.size(); ++i) { for(size_t i = 0; i < reposable_cards.size(); ++i) {
...@@ -545,7 +545,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -545,7 +545,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_ATTACK: { case BUTTON_CMD_ATTACK: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(!menu_card) if(!menu_card)
break; break;
for(size_t i = 0; i < attackable_cards.size(); ++i) { for(size_t i = 0; i < attackable_cards.size(); ++i) {
...@@ -558,7 +558,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -558,7 +558,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CMD_SHOWLIST: { case BUTTON_CMD_SHOWLIST: {
mainGame->wCmdMenu->setVisible(false); HideMenu();
selectable_cards.clear(); selectable_cards.clear();
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
switch(command_location) { switch(command_location) {
...@@ -1074,7 +1074,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1074,7 +1074,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateChainButtons(); UpdateChainButtons();
} }
if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(mousepos)) if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(mousepos))
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(mainGame->btnBP->isVisible() && mainGame->btnBP->getAbsolutePosition().isPointInside(mousepos))
break;
if(mainGame->btnM2->isVisible() && mainGame->btnM2->getAbsolutePosition().isPointInside(mousepos))
break;
if(panel && panel->isVisible()) if(panel && panel->isVisible())
break; break;
GetHoverField(x, y); GetHoverField(x, y);
...@@ -1480,7 +1484,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1480,7 +1484,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateChainButtons(); UpdateChainButtons();
} }
mainGame->HideElement(mainGame->wSurrender); mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(mainGame->fadingList.size()) if(mainGame->fadingList.size())
break; break;
CancelOrFinish(); CancelOrFinish();
...@@ -1563,7 +1567,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1563,7 +1567,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
if(mcard) { if(mcard) {
if(mcard != menu_card) if(mcard != menu_card)
mainGame->wCmdMenu->setVisible(false); HideMenu();
if(hovered_location == LOCATION_HAND) { if(hovered_location == LOCATION_HAND) {
mcard->is_hovered = true; mcard->is_hovered = true;
MoveCard(mcard, 5); MoveCard(mcard, 5);
...@@ -2248,7 +2252,7 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -2248,7 +2252,7 @@ void ClientField::GetHoverField(int x, int y) {
} }
void ClientField::ShowMenu(int flag, int x, int y) { void ClientField::ShowMenu(int flag, int x, int y) {
if(!flag) { if(!flag) {
mainGame->wCmdMenu->setVisible(false); HideMenu();
return; return;
} }
menu_card = clicked_card; menu_card = clicked_card;
...@@ -2316,11 +2320,20 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -2316,11 +2320,20 @@ void ClientField::ShowMenu(int flag, int x, int y) {
} else mainGame->btnReset->setVisible(false); } else mainGame->btnReset->setVisible(false);
panel = mainGame->wCmdMenu; panel = mainGame->wCmdMenu;
mainGame->wCmdMenu->setVisible(true); mainGame->wCmdMenu->setVisible(true);
mainGame->btnBP->setEnabled(false);
mainGame->btnM2->setEnabled(false);
mainGame->btnEP->setEnabled(false);
if(mainGame->gameConf.resize_popup_menu) if(mainGame->gameConf.resize_popup_menu)
mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x - 20, y - 20, x + 80, y - 20, 0, -height, 0, 0)); mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x - 20, y - 20, x + 80, y - 20, 0, -height, 0, 0));
else else
mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x, y, x, y, -20, -(20 + height), 80, -20)); mainGame->wCmdMenu->setRelativePosition(mainGame->Resize(x, y, x, y, -20, -(20 + height), 80, -20));
} }
void ClientField::HideMenu() {
mainGame->wCmdMenu->setVisible(false);
mainGame->btnBP->setEnabled(true);
mainGame->btnM2->setEnabled(true);
mainGame->btnEP->setEnabled(true);
}
void ClientField::UpdateChainButtons() { void ClientField::UpdateChainButtons() {
if(mainGame->btnChainAlways->isVisible()) { if(mainGame->btnChainAlways->isVisible()) {
mainGame->btnChainIgnore->setPressed(mainGame->ignore_chain); mainGame->btnChainIgnore->setPressed(mainGame->ignore_chain);
......
...@@ -368,6 +368,9 @@ bool Game::Initialize() { ...@@ -368,6 +368,9 @@ bool Game::Initialize() {
chkWaitChain = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1277)); chkWaitChain = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1277));
chkWaitChain->setChecked(gameConf.chkWaitChain != 0); chkWaitChain->setChecked(gameConf.chkWaitChain != 0);
posY += 30; posY += 30;
chkDefaultShowChain = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1354));
chkDefaultShowChain->setChecked(gameConf.chkDefaultShowChain != 0);
posY += 30;
chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299)); chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299));
chkQuickAnimation->setChecked(gameConf.quick_animation != 0); chkQuickAnimation->setChecked(gameConf.quick_animation != 0);
posY += 30; posY += 30;
...@@ -1298,6 +1301,7 @@ void Game::LoadConfig() { ...@@ -1298,6 +1301,7 @@ void Game::LoadConfig() {
gameConf.chkRandomPos = 0; gameConf.chkRandomPos = 0;
gameConf.chkAutoChain = 0; gameConf.chkAutoChain = 0;
gameConf.chkWaitChain = 0; gameConf.chkWaitChain = 0;
gameConf.chkDefaultShowChain = 0;
gameConf.chkIgnore1 = 0; gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0; gameConf.chkIgnore2 = 0;
gameConf.use_lflist = 1; gameConf.use_lflist = 1;
...@@ -1366,6 +1370,8 @@ void Game::LoadConfig() { ...@@ -1366,6 +1370,8 @@ void Game::LoadConfig() {
gameConf.chkAutoChain = atoi(valbuf); gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) { } else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf); gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "showchain")) {
gameConf.chkDefaultShowChain = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_opponent")) { } else if(!strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = atoi(valbuf); gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_spectators")) { } else if(!strcmp(strbuf, "mute_spectators")) {
...@@ -1481,6 +1487,7 @@ void Game::SaveConfig() { ...@@ -1481,6 +1487,7 @@ void Game::SaveConfig() {
fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0)); fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0));
fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0)); fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0));
fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0)); fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
fprintf(fp, "showchain = %d\n", (chkDefaultShowChain->isChecked() ? 1 : 0));
fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0)); fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0)); fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist); fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist);
......
...@@ -33,6 +33,7 @@ struct Config { ...@@ -33,6 +33,7 @@ struct Config {
int chkRandomPos; int chkRandomPos;
int chkAutoChain; int chkAutoChain;
int chkWaitChain; int chkWaitChain;
int chkDefaultShowChain;
int chkIgnore1; int chkIgnore1;
int chkIgnore2; int chkIgnore2;
int use_lflist; int use_lflist;
...@@ -290,6 +291,7 @@ public: ...@@ -290,6 +291,7 @@ public:
irr::gui::IGUICheckBox* chkRandomPos; irr::gui::IGUICheckBox* chkRandomPos;
irr::gui::IGUICheckBox* chkAutoChain; irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain; irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkDefaultShowChain;
irr::gui::IGUICheckBox* chkQuickAnimation; irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay; irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkDrawSingleChain; irr::gui::IGUICheckBox* chkDrawSingleChain;
......
...@@ -42,6 +42,7 @@ bool NetServer::StartBroadcast() { ...@@ -42,6 +42,7 @@ bool NetServer::StartBroadcast() {
SOCKET udp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); SOCKET udp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
BOOL opt = TRUE; BOOL opt = TRUE;
setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof(BOOL)); setsockopt(udp, SOL_SOCKET, SO_BROADCAST, (const char*)&opt, sizeof(BOOL));
setsockopt(udp, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof(BOOL));
sockaddr_in addr; sockaddr_in addr;
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
......
...@@ -401,6 +401,7 @@ ...@@ -401,6 +401,7 @@
!system 1351 投降 !system 1351 投降
!system 1352 主要信息: !system 1352 主要信息:
!system 1353 播放起始于回合: !system 1353 播放起始于回合:
!system 1354 开局默认显示所有时点
!system 1356 此操作将放弃对当前卡组的修改,是否继续? !system 1356 此操作将放弃对当前卡组的修改,是否继续?
!system 1357 不提示保留对卡组的修改 !system 1357 不提示保留对卡组的修改
!system 1358 键入关键字后自动进行搜索 !system 1358 键入关键字后自动进行搜索
...@@ -1157,3 +1158,6 @@ ...@@ -1157,3 +1158,6 @@
!setname 0x188 深渊之兽 ビーステッド !setname 0x188 深渊之兽 ビーステッド
!setname 0x189 俱舍怒威族 クシャトリラ !setname 0x189 俱舍怒威族 クシャトリラ
!setname 0x18a 魊影 Ghoti !setname 0x18a 魊影 Ghoti
!setname 0x18b 救援ACERACE
!setname 0x18c 纯爱妖精 ピュアリィ
!setname 0x18d 御巫
...@@ -18,6 +18,7 @@ autospellpos = 0 ...@@ -18,6 +18,7 @@ autospellpos = 0
randompos = 0 randompos = 0
autochain = 0 autochain = 0
waitchain = 0 waitchain = 0
showchain = 0
mute_opponent = 0 mute_opponent = 0
mute_spectators = 0 mute_spectators = 0
use_lflist = 1 use_lflist = 1
......
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