Changeset 45b2750 in network-game for client


Ignore:
Timestamp:
May 22, 2013, 10:55:36 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
23559e7
Parents:
5f868c0
Message:

Clients can now process MSG_TYPE_OBJECT messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r5f868c0 r45b2750  
    4747void initWinSock();
    4848void shutdownWinSock();
    49 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId);
     49void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId);
    5050void drawMap(WorldMap* gameMap);
    5151void drawPlayers(map<unsigned int, Player>& mapPlayers, unsigned int curPlayerId);
     
    265265
    266266      if (receiveMessage(&msgFrom, sock, &from) >= 0)
    267          processMessage(msgFrom, state, chatConsole, mapPlayers, curPlayerId);
     267         processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, curPlayerId);
    268268
    269269      if (redraw)
     
    381381}
    382382
    383 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId)
     383void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId)
    384384{
    385385   string response = string(msg.buffer);
     
    443443               break;
    444444            }
     445            case MSG_TYPE_OBJECT:
     446            {
     447               cout << "Received object message. Baller Biller!" << endl;
     448
     449               WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
     450               o.deserialize(msg.buffer);
     451               gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
     452
     453               break;
     454            }
    445455         }
    446456
     
    509519
    510520               break;
     521            }
     522            case MSG_TYPE_OBJECT:
     523            {
     524               cout << "Received object message. Baller Biller!" << endl;
     525
     526               WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
     527               o.deserialize(msg.buffer);
     528               gameMap->updateObject(o.id, o.type, o.pos.x, o.pos.y);
     529
     530               break;
     531            }
     532            default:
     533            {
     534               cout << "Received an unexpected message type: " << msg.type << endl;
    511535            }
    512536         }
Note: See TracChangeset for help on using the changeset viewer.