- Timestamp:
- Jan 29, 2014, 2:06:36 AM (11 years ago)
- Branches:
- master
- Children:
- 8826eed
- Parents:
- d6b5f74
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rd6b5f74 r64a1f4e 7 7 #include <fstream> 8 8 #include <cstring> 9 #include <cmath>10 9 11 10 #include <vector> … … 336 335 cout << "new player id: " << p->getId() << endl; 337 336 p->setAddr(from); 338 p->currentGame = NULL;339 340 // choose a random team (either 0 or 1)341 p->team = rand() % 2;342 337 343 338 serverMsg.type = MSG_TYPE_PLAYER; … … 696 691 697 692 Player* p = findPlayerByAddr(mapPlayers, from); 698 p->team = rand() % 2; // choose a random team (either 0 or 1)699 p->currentGame = g;700 693 701 694 // tell the new player about all map objects … … 723 716 msgProcessor.sendMessage(&serverMsg, &from); 724 717 718 719 map<unsigned int, Player*>& oldPlayers = g->getPlayers(); 720 g->addPlayer(p); 721 725 722 // send info to other players 726 723 serverMsg.type = MSG_TYPE_PLAYER_JOIN_GAME; 727 724 p->serialize(serverMsg.buffer); 728 725 cout << "Should be broadcasting the message" << endl; 729 msgProcessor.broadcastMessage(serverMsg, g->getPlayers()); 730 731 g->addPlayer(p); 726 msgProcessor.broadcastMessage(serverMsg, oldPlayers); 732 727 733 728 … … 735 730 cout << "Sending other players to new player" << endl; 736 731 serverMsg.type = MSG_TYPE_PLAYER_JOIN_GAME; 737 738 732 739 733 map<unsigned int, Player*>& allPlayers = g->getPlayers(); … … 747 741 msgProcessor.sendMessage(&serverMsg, &from); 748 742 } 743 749 744 750 745 int numPlayers = g->getNumPlayers();
Note:
See TracChangeset
for help on using the changeset viewer.