From: Brian Bosak Date: Mon, 2 Sep 2013 03:34:12 +0000 (-0500) Subject: Updated lobby protocol. Chat support (sending messages) temporarily removed until... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4353eec63ca1202aec3b495357326e8489344050;p=xonotic%2Fdarkplaces.git Updated lobby protocol. Chat support (sending messages) temporarily removed until future update on backend server. --- diff --git a/lobby_gameroom.c b/lobby_gameroom.c index a537a386..a1ac7eb6 100644 --- a/lobby_gameroom.c +++ b/lobby_gameroom.c @@ -19,6 +19,20 @@ typedef struct { int port; void(*connectDgate)(int); } hostinfo; +typedef struct { + char* name; + char** mods; + int32_t modcount; + int32_t playercount; + int32_t playermax; + int32_t index; + void* next; +} lobby_room; + + + + + static mempool_t* idwpool; static void printmsg_chat(void* msg) { @@ -82,23 +96,6 @@ if(dispatchFunc !=0) { } Thread_UnlockMutex(syncmtx); } -static void msgloop(int sock) { - unsigned char buffer[2048]; - while(recv(sock,buffer,sizeof(buffer),0)>0) { - unsigned char* ptr = buffer; - if(*ptr == 0) { - runOnMainThread(printmsg,"Server found!"); - //TODO: Connect to the server - }else { - if(*ptr == 1) { - //Chat message (process) - ptr++; - runOnMainThread(printmsg_chat,(char*)ptr); - } - } - - } -} static unsigned char xmitpacket[2048]; static unsigned char* OpenStream() { return xmitpacket; @@ -114,6 +111,95 @@ static void writeString(const char* data,unsigned char** stream) { (*stream)+=sz+1; } + + + + + + +//ROOM FUNCTIONS +static lobby_room* rooms = 0; + + + + +static void room_add(lobby_room* room) { + if(rooms == 0) { + rooms = Mem_Alloc(idwpool,sizeof(lobby_room)); + memcpy(rooms,room,sizeof(lobby_room)); + room->next = 0; + }else { + lobby_room* prevnext = rooms->next; + rooms->next = Mem_Alloc(idwpool,sizeof(lobby_room)); + memcpy(rooms->next,room,sizeof(lobby_room)); + ((lobby_room*)rooms->next)->next = prevnext; + } + + +} + +static int room_iter(lobby_room** room) { + if(*room == 0) { + *room = rooms; + }else { + *room = (*room)->next; + } + return *room !=0; +} + +static void room_clear() { + while(rooms != 0) { + int i; + Mem_Free(rooms->name); + for(i = 0;imodcount;i++) { + Mem_Free(rooms->mods[i]); + } + Mem_Free(rooms->mods); + rooms = rooms->next; + } +} + + + + +//END ROOM FUNCTIONS + + + +static void msgloop(int sock) { + + while(recv(sock,xmitpacket,sizeof(xmitpacket),0)>0) { + unsigned char* ptr = OpenStream(); + if(*ptr == 0) { + ptr++; + int32_t modcount = *getInt(&ptr); + lobby_room room; + room.modcount = modcount; + room.mods = Mem_Alloc(idwpool,sizeof(void*)*modcount); + int i; + for(i = 0;i