Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 12, 2008, 5:36:57 PM (16 years ago)
Author:
scheusso
Message:

we have a new gamestate concept now: dont transmit synchronisable header of objects, that dont get updated that tick. transmit objectids of deleted objects to delete them on the client too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Server.cc

    r1755 r1775  
    5656#include "packet/Packet.h"
    5757#include "packet/Welcome.h"
     58#include "packet/DeleteObjects.h"
    5859#include <util/Convert.h>
    5960
     
    229230    //std::cout << "updated gamestate, sending it" << std::endl;
    230231    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
     232    sendObjectDeletes();
    231233    sendGameState();
    232234    COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
     
    276278      // gs gets automatically deleted by enet callback
    277279    }
    278     /*if(added) {
    279       //std::cout << "send gamestates from server.cc in sendGameState" << std::endl;
    280       return connection->sendPackets();
    281     }*/
    282     //COUT(5) << "Server: had no gamestates to send" << std::endl;
    283280    return true;
    284281  }
    285282
     283  bool Server::sendObjectDeletes(){
     284    ClientInformation *temp = ClientInformation::getBegin();
     285    packet::DeleteObjects *del = new packet::DeleteObjects();
     286    if(!del->fetchIDs())
     287      return true;  //everything ok (no deletes this tick)
     288    while(temp != NULL){
     289      if( !(temp->getSynched()) ){
     290        COUT(5) << "Server: not sending gamestate" << std::endl;
     291        temp=temp->next();
     292        continue;
     293      }
     294      int cid = temp->getID(); //get client id
     295      packet::DeleteObjects *cd = new packet::DeleteObjects(*del);
     296      assert(cd);
     297      cd->setClientID(cid);
     298      if ( !cd->send() )
     299        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
     300      temp=temp->next();
     301      // gs gets automatically deleted by enet callback
     302    }
     303    return true;
     304  }
     305 
    286306//   void Server::processChat( chat *data, int clientId){
    287307//     char *message = new char [strlen(data->message)+10+1];
Note: See TracChangeset for help on using the changeset viewer.