Changeset eb2ad4f in network-game for client/Client/main.cpp


Ignore:
Timestamp:
Dec 28, 2013, 4:29:07 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
6054f1e
Parents:
2e63b64
Message:

gameMap removed from client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r2e63b64 reb2ad4f  
    5757void initWinSock();
    5858void shutdownWinSock();
    59 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers,
     59void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers,
    6060                    map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId);
    6161int getRefreshRate(int width, int height);
     
    205205      return -1;
    206206   }
    207 
    208    WorldMap* gameMap = WorldMap::loadMapFromFile("../../data/map.txt");
    209 
    210    cout << "Loaded map" << endl;
    211207
    212208   debugConsole.addLine("Debug console:");
     
    452448
    453449      if (msgProcessor.receiveMessage(&msgFrom, &from) >= 0)
    454          processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId);
     450         processMessage(msgFrom, state, chatConsole, mapPlayers, mapProjectiles, curPlayerId);
    455451
    456452      if (redraw)
     
    595591   delete wndGameSummary;
    596592
    597    delete gameMap;
    598 
     593   // game should be deleted when the player leaves a gamw
    599594   if (game != NULL)
    600595      delete game;
     
    644639}
    645640
    646 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player*>& mapPlayers,
     641void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player*>& mapPlayers,
    647642                    map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId)
    648643{
     
    780775            {
    781776               chatConsole.addLine(response);
    782 
    783                break;
    784             }
    785             case MSG_TYPE_OBJECT:
    786             {
    787                cout << "Received OBJECT message" << endl;
    788 
    789                WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
    790                o.deserialize(msg.buffer);
    791                cout << "object id: " << o.id << endl;
    792                gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
    793 
    794                break;
    795             }
    796             case MSG_TYPE_REMOVE_OBJECT:
    797             {
    798                cout << "Received REMOVE_OBJECT message!" << endl;
    799 
    800                int id;
    801                memcpy(&id, msg.buffer, 4);
    802 
    803                cout << "Removing object with id " << id << endl;
    804 
    805                if (!gameMap->removeObject(id))
    806                   cout << "Did not remove the object" << endl;
    807777
    808778               break;
Note: See TracChangeset for help on using the changeset viewer.