@@ -307,55 +307,34 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
307307 }
308308 }
309309
310- // See if there's room
311- // First get the number of players currently in the room.
312- Int numPlayers = 0 ;
313- for (player = 0 ; player < MAX_SLOTS; ++player)
310+ for (player = 0 ; canJoin && player<MAX_SLOTS; ++player)
314311 {
315- if (m_currentGame->getLANSlot (player)->isOccupied ()
316- && !(m_currentGame->getLANSlot (player)->getPlayerTemplate () == PLAYERTEMPLATE_OBSERVER))
312+ if (m_currentGame->getLANSlot (player)->isOpen ())
317313 {
318- ++numPlayers;
319- }
320- }
314+ // OK, add him in.
315+ reply.LANMessageType = LANMessage::MSG_JOIN_ACCEPT;
316+ wcsncpy (reply.GameJoined .gameName , m_currentGame->getName ().str (), g_lanGameNameLength);
317+ reply.GameJoined .gameName [g_lanGameNameLength] = 0 ;
318+ reply.GameJoined .slotPosition = player;
319+ reply.GameJoined .gameIP = m_localIP;
320+ reply.GameJoined .playerIP = senderIP;
321+
322+ LANGameSlot newSlot;
323+ newSlot.setState (SLOT_PLAYER, UnicodeString (msg->name ));
324+ newSlot.setIP (senderIP);
325+ newSlot.setPort (NETWORK_BASE_PORT_NUMBER);
326+ newSlot.setLastHeard (timeGetTime ());
327+ newSlot.setSerial (msg->GameToJoin .serial );
328+ m_currentGame->setSlot (player,newSlot);
329+ DEBUG_LOG ((" LANAPI::handleRequestJoin - added player %ls at ip 0x%08x to the game" , msg->name , senderIP));
330+
331+ OnPlayerJoin (player, UnicodeString (msg->name ));
332+ responseIP = 0 ;
321333
322- // now get the number of starting spots on the map.
323- Int numStartingSpots = MAX_SLOTS;
324- const MapMetaData *md = TheMapCache->findMap (m_currentGame->getMap ());
325- if (md != NULL )
326- {
327- numStartingSpots = md->m_numPlayers ;
328- }
329-
330- if (numPlayers < numStartingSpots) {
331- for (player = 0 ; canJoin && player<MAX_SLOTS; ++player)
332- {
333- if (m_currentGame->getLANSlot (player)->isOpen ())
334- {
335- // OK, add him in.
336- reply.LANMessageType = LANMessage::MSG_JOIN_ACCEPT;
337- wcsncpy (reply.GameJoined .gameName , m_currentGame->getName ().str (), g_lanGameNameLength);
338- reply.GameJoined .gameName [g_lanGameNameLength] = 0 ;
339- reply.GameJoined .slotPosition = player;
340- reply.GameJoined .gameIP = m_localIP;
341- reply.GameJoined .playerIP = senderIP;
342-
343- LANGameSlot newSlot;
344- newSlot.setState (SLOT_PLAYER, UnicodeString (msg->name ));
345- newSlot.setIP (senderIP);
346- newSlot.setPort (NETWORK_BASE_PORT_NUMBER);
347- newSlot.setLastHeard (timeGetTime ());
348- newSlot.setSerial (msg->GameToJoin .serial );
349- m_currentGame->setSlot (player,newSlot);
350- DEBUG_LOG ((" LANAPI::handleRequestJoin - added player %ls at ip 0x%08x to the game" , msg->name , senderIP));
351-
352- OnPlayerJoin (player, UnicodeString (msg->name ));
353- responseIP = 0 ;
354-
355- break ;
356- }
334+ break ;
357335 }
358336 }
337+
359338 if (canJoin && player == MAX_SLOTS)
360339 {
361340 reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
0 commit comments