Commit 67f6d60c authored by nanahira's avatar nanahira

test roomlist

parent db728403
......@@ -37,6 +37,7 @@ 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)
......@@ -357,6 +358,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);
unsigned short temp1[20];
unsigned short temp2[41];
for(unsigned short i = 0; i < count; ++i) {
wchar_t roomname[20];
wchar_t player1[41];
wchar_t player2[41];
wchar_t hoststr[1024];
memcpy(temp1, pdata, 40);
pdata += 40;
BufferIO::CopyWStr(roomname, temp1, 20);
unsigned char room_status = BufferIO::ReadUInt8(pdata);
char room_duel_count = BufferIO::ReadInt8(pdata);
char room_turn_count = BufferIO::ReadInt8(pdata);
memcpy(temp2, pdata, 82);
pdata += 82;
BufferIO::CopyWStr(player1, temp2, 41);
char player1_score = BufferIO::ReadInt8(pdata);
int player1_lp = BufferIO::ReadInt32(pdata);
memcpy(temp2, pdata, 82);
pdata += 82;
BufferIO::CopyWStr(player2, temp2, 41);
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;
......@@ -3922,6 +3979,7 @@ void DuelClient::BeginRefreshHost() {
if(is_refreshing)
return;
is_refreshing = true;
DuelClient::is_srvpro = false;
mainGame->btnLanRefresh->setEnabled(false);
mainGame->lstHostList->clear();
remotes.clear();
......
......@@ -79,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
......
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