Changeset 5f868c0 in network-game for server


Ignore:
Timestamp:
May 22, 2013, 10:34:42 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
45b2750
Parents:
6e66ffd
Message:

Added partial server support for new messages for sending item info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    r6e66ffd r5f868c0  
    9898   // add some items to the map. They will be sent out
    9999   // to players when they login
    100    // m->addObject(x*25+12, y*25+12, OBJECT_BLUE_FLAG);
    101    // m->addObject(x*25+12, y*25+12, OBJECT_RED_FLAG);
     100   for (int y=0; y<gameMap->height; y++) {
     101      for (int x=0; x<gameMap->width; x++) {
     102         switch (gameMap->getStructure(x, y)) {
     103            case WorldMap::STRUCTURE_BLUE_FLAG:
     104               gameMap->addObject(WorldMap::OBJECT_BLUE_FLAG, x*25+12, y*25+12);
     105               break;
     106            case WorldMap::STRUCTURE_RED_FLAG:
     107               gameMap->addObject(WorldMap::OBJECT_RED_FLAG, x*25+12, y*25+12);
     108               break;
     109         }
     110      }
     111   }
    102112
    103113   sock = socket(AF_INET, SOCK_DGRAM, 0);
     
    259269
    260270               cout << "sending info about " << it->second.name  << endl;
    261                cout << "sending ind " << it->second.id  << endl;
     271               cout << "sending id " << it->second.id  << endl;
     272               if ( sendMessage(&serverMsg, sock, &from) < 0 )
     273                  error("sendMessage");
     274            }
     275
     276            // tell the new player about all map objects
     277            // (currently just the flags)
     278            serverMsg.type = MSG_TYPE_OBJECT;
     279            vector<WorldMap::Object> vctObjects = gameMap->getObjects();
     280            vector<WorldMap::Object>::iterator itObjects;
     281            cout << "sending items" << endl;
     282            for (itObjects = vctObjects.begin(); itObjects != vctObjects.end(); itObjects++) {
     283               itObjects->serialize(serverMsg.buffer);
     284               cout << "sending item id " << itObjects->id  << endl;
    262285               if ( sendMessage(&serverMsg, sock, &from) < 0 )
    263286                  error("sendMessage");
Note: See TracChangeset for help on using the changeset viewer.