Commit 61d65745 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent f64b2f8a
......@@ -35,7 +35,7 @@ unsigned char draw_count;
void Game::MainServerLoop(int bDuel_mode) {
deckManager.LoadLFList();
dataManager.LoadDB("cards.cdb");
NetServer::StartServer(aServerPort);
aServerPort = NetServer::StartServer(aServerPort);
printf("%u\n", aServerPort);
NetServer::Initduel(bDuel_mode);
while(NetServer::net_evbase) {
......
......@@ -56,7 +56,7 @@ void NetServer::Initduel(int bDuel_mode)
bool NetServer::StartServer(unsigned short port) {
unsigned short NetServer::StartServer(unsigned short port) {
if(net_evbase)
return false;
net_evbase = event_base_new();
......@@ -75,9 +75,13 @@ bool NetServer::StartServer(unsigned short port) {
net_evbase = 0;
return false;
}
evutil_socket_t fd=evconnlistener_get_fd(listener);
socklen_t addrlen=sizeof(struct sockaddr);
struct sockaddr_in addr;
getsockname(fd,(struct sockaddr*)&addr,&addrlen);
evconnlistener_set_error_cb(listener, ServerAcceptError);
Thread::NewThread(ServerThread, net_evbase);
return true;
return ntohs(addr.sin_port);
}
bool NetServer::StartBroadcast() {
if(!net_evbase)
......
......@@ -25,7 +25,7 @@ private:
public:
static event_base* net_evbase;
static void Initduel(int duel_mode);
static bool StartServer(unsigned short port);
static unsigned short StartServer(unsigned short port);
static bool StartBroadcast();
static void StopServer();
static void StopBroadcast();
......
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