Commit 135fa84e authored by nanahira's avatar nanahira

Merge branch 'master' into another

parents cd3d79a7 12f0c719
......@@ -12,11 +12,21 @@ public:
p += 4;
return ret;
}
inline static unsigned int ReadUInt32(char*& p) {
unsigned int ret = *(unsigned int*)p;
p += 4;
return ret;
}
inline static short ReadInt16(char*& p) {
short ret = *(short*)p;
p += 2;
return ret;
}
inline static unsigned short ReadUInt16(char*& p) {
unsigned short ret = *(unsigned short*)p;
p += 2;
return ret;
}
inline static char ReadInt8(char*& p) {
char ret = *(char*)p;
p++;
......
......@@ -719,6 +719,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
return false;
}
void DeckBuilder::GetHoveredCard() {
int pre_code = hovered_code;
hovered_pos = 0;
hovered_code = 0;
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
......@@ -727,7 +728,6 @@ void DeckBuilder::GetHoveredCard() {
position2di pos = mainGame->ResizeReverse(mouse_pos.X, mouse_pos.Y);
int x = pos.X;
int y = pos.Y;
int pre_code = hovered_code;
is_lastcard = 0;
if(x >= 314 && x <= 794) {
if(y >= 164 && y <= 435) {
......
......@@ -24,18 +24,21 @@ char DuelClient::duel_client_read[0x2000];
char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false;
int DuelClient::select_hint = 0;
int DuelClient::select_unselect_hint = 0;
wchar_t DuelClient::event_string[256];
mtrandom DuelClient::rnd;
bool DuelClient::is_refreshing = false;
int DuelClient::match_kill = 0;
std::vector<HostPacket> DuelClient::hosts;
std::vector<std::wstring> DuelClient::hosts_srvpro;
std::set<unsigned int> DuelClient::remotes;
event* DuelClient::resp_event = 0;
unsigned int DuelClient::temp_ip = 0;
unsigned short DuelClient::temp_port = 0;
unsigned short DuelClient::temp_ver = 0;
bool DuelClient::try_needed = false;
bool DuelClient::is_srvpro = false;
bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_game) {
if(connect_state)
......@@ -356,6 +359,62 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
break;
}
case STOC_SRVPRO_ROOMLIST: {
is_srvpro = true;
mainGame->gMutex.Lock();
mainGame->lstHostList->clear();
hosts_srvpro.clear();
unsigned short count = BufferIO::ReadUInt16(pdata);
char temp1[64];
char temp2[128];
for(unsigned short i = 0; i < count; ++i) {
wchar_t roomname[32];
wchar_t player1[64];
wchar_t player2[64];
wchar_t hoststr[1024];
memcpy(temp1, pdata, 64);
pdata += 64;
BufferIO::DecodeUTF8(temp1, roomname);
unsigned char room_status = BufferIO::ReadUInt8(pdata);
char room_duel_count = BufferIO::ReadInt8(pdata);
char room_turn_count = BufferIO::ReadInt8(pdata);
memcpy(temp2, pdata, 128);
pdata += 128;
BufferIO::DecodeUTF8(temp2, player1);
char player1_score = BufferIO::ReadInt8(pdata);
int player1_lp = BufferIO::ReadInt32(pdata);
memcpy(temp2, pdata, 128);
pdata += 128;
BufferIO::DecodeUTF8(temp2, player2);
char player2_score = BufferIO::ReadInt8(pdata);
int player2_lp = BufferIO::ReadInt32(pdata);
hosts_srvpro.push_back(std::wstring(roomname));
switch(room_status) {
case 0: {
myswprintf(hoststr, L"[SRVPro][Waiting][%ls] %ls VS %ls", roomname, player1, player2);
break;
}
case 1: {
myswprintf(hoststr, L"[SRVPro][G%d,T%d][%ls] (%d,LP%d) %ls VS %ls (%d,LP%d)", room_duel_count, room_turn_count, roomname, player1_score, player1_lp, player1, player2, player2_score, player2_lp);
break;
}
case 2: {
myswprintf(hoststr, L"[SRVPro][G%d,Siding][%ls] (%d) %ls VS %ls (%d)", room_duel_count, roomname, player1_score, player1, player2, player2_score);
break;
}
}
mainGame->lstHostList->addItem(hoststr);
}
mainGame->gMutex.Unlock();
break;
}
case STOC_SELECT_HAND: {
mainGame->wHand->setVisible(true);
break;
......@@ -1587,7 +1646,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(select_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_hint),
select_unselect_hint = select_hint;
if(select_unselect_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_unselect_hint),
mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0;
......@@ -3963,6 +4024,7 @@ void DuelClient::BeginRefreshHost() {
if(is_refreshing)
return;
is_refreshing = true;
DuelClient::is_srvpro = false;
mainGame->btnLanRefresh->setEnabled(false);
mainGame->lstHostList->clear();
remotes.clear();
......
......@@ -30,6 +30,7 @@ private:
static char duel_client_write[0x2000];
static bool is_closing;
static int select_hint;
static int select_unselect_hint;
static wchar_t event_string[256];
static mtrandom rnd;
public:
......@@ -78,6 +79,8 @@ protected:
static std::set<unsigned int> remotes;
public:
static std::vector<HostPacket> hosts;
static std::vector<std::wstring> hosts_srvpro;
static bool is_srvpro;
static void BeginRefreshHost();
static int RefreshThread(void* arg);
static void BroadcastReply(evutil_socket_t fd, short events, void* arg);
......
......@@ -456,6 +456,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstHostList->getSelected();
if(sel == -1)
break;
if(DuelClient::is_srvpro) {
mainGame->ebJoinPass->setText(DuelClient::hosts_srvpro[sel].c_str());
break;
}
int addr = DuelClient::hosts[sel].ipaddr;
int port = DuelClient::hosts[sel].port;
wchar_t buf[20];
......
......@@ -196,6 +196,7 @@ public:
#define STOC_HS_PLAYER_ENTER 0x20
#define STOC_HS_PLAYER_CHANGE 0x21
#define STOC_HS_WATCH_CHANGE 0x22
#define STOC_SRVPRO_ROOMLIST 0x31
#define PLAYERCHANGE_OBSERVE 0x8
#define PLAYERCHANGE_READY 0x9
......
Subproject commit c05ef926dc271320d8ad53226a4c8ace674a2af5
Subproject commit 9b9aecd333d4ba49d6d32e7992fe8085a887b37e
Subproject commit 75c5095177a7109882886ba600a64fc18db6644c
Subproject commit 268e72a55da4fbf1a6aa951d00b72c784927c51b
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