Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 12:55:35 PM (16 years ago)
Author:
dumenim
Message:

changed some comments and catched some return values and maybe some stuff we have to unchange

File:
1 edited

Legend:

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

    r1007 r1008  
    9595  bool Server::sendMSG(const char *msg) {
    9696    ENetPacket *packet = packet_gen.chatMessage(msg);
    97     std::cout <<"adding Packets" << std::endl;
     97    COUT(4) <<"Server: adding Packets" << std::endl;
    9898    connection->addPacketAll(packet);
    9999    //std::cout <<"added packets" << std::endl;
    100100    if (connection->sendPackets()){
    101       std::cout << "Sucessfully" << std::endl;
     101      COUT(4) << "Server: Sucessfully" << std::endl;
    102102      return true;
    103103    }
     
    126126    while(!connection->queueEmpty()){
    127127      //std::cout << "Client " << clientID << " sent: " << std::endl;
     128      //clientID here is a reference to grab clientID from ClientInformation
    128129      packet = connection->getPacket(clientID);
    129       elaborate(packet, clientID);
     130      //if statement to catch case that packetbuffer is empty
     131      if( !elaborate(packet, clientID) )
     132        COUT(4) << "Server: PacketBuffer empty" << std::endl;
    130133    }
    131134  }
     
    136139  void Server::updateGamestate() {
    137140    gamestates->update();
     141    COUT(4) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
    138142    //std::cout << "updated gamestate, sending it" << std::endl;
    139143    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
    140       sendGameState();
     144    sendGameState();
     145    COUT(4) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
    141146    //std::cout << "sent gamestate" << std::endl;
    142147  }
     
    146151  */
    147152  bool Server::sendGameState() {
    148     COUT(5) << "starting sendGameState" << std::endl;
     153    COUT(5) << "Server: starting function sendGameState" << std::endl;
    149154    ClientInformation *temp = clients;
    150155    bool added=false;
    151     while(temp!=NULL){
     156    while(temp != NULL){
    152157      if(temp->head){
    153158        temp=temp->next();
     159        //think this works without continue
    154160        continue;
    155161      }
    156162      if( !(temp->getSynched()) ){
    157         COUT(5) << "not sending gamestate" << std::endl;
     163        COUT(5) << "Server: not sending gamestate" << std::endl;
    158164        temp=temp->next();
     165        //think this works without continue
    159166        continue;
    160167      }
    161       COUT(5) << "doing gamestate gamestate preparation" << std::endl;
    162       int gid = temp->getGamestateID();
    163       int cid = temp->getID();
    164       COUT(5) << "server, got acked (gamestate) ID: " << gid << std::endl;
     168      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
     169      int gid = temp->getGamestateID(); //get gamestate id
     170      int cid = temp->getID(); //get client id
     171      COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
    165172      GameStateCompressed *gs = gamestates->popGameState(cid);
    166173      if(gs==NULL){
    167         COUT(2) << "could not generate gamestate" << std::endl;
     174        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
    168175        return false;
    169176      }
    170177      //std::cout << "adding gamestate" << std::endl;
    171       connection->addPacket(packet_gen.gstate(gs), cid);
     178      if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) )
     179        COUT(4) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl;
    172180      //std::cout << "added gamestate" << std::endl;
    173181      added=true;
    174182      temp=temp->next();
    175183    }
    176     if(added)
     184    if(added) {
     185      //std::cout << "send gamestates from server.cc in sendGameState" << std::endl;
    177186      return connection->sendPackets();
    178     COUT(5) << "had no gamestates to send" << std::endl;
     187    }
     188    COUT(5) << "Server: had no gamestates to send" << std::endl;
    179189    return false;
    180190  }
    181191
    182192  void Server::processAck( ack *data, int clientID) {
    183     COUT(5) << "processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl;
     193    COUT(5) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl;
    184194    clients->findClient(clientID)->setGamestateID(data->a);
    185195  }
Note: See TracChangeset for help on using the changeset viewer.