Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2008, 7:40:47 PM (16 years ago)
Author:
scheusso
Message:

merged network branch back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/Client.cc

    r1769 r1907  
    4343#include "Synchronisable.h"
    4444#include "core/CoreIncludes.h"
    45 #include "core/ConsoleCommand.h"
    4645#include "packet/Packet.h"
    4746// #include "packet/Acknowledgement.h"
     
    6160    isSynched_=false;
    6261    gameStateFailure_=false;
    63     isServer_ = false;
    6462  }
    6563
     
    7371    isSynched_=false;
    7472    gameStateFailure_=false;
    75     isServer_ = false;
    7673  }
    7774
     
    8582    isSynched_=false;
    8683    gameStateFailure_=false;
    87     isServer_ = false;
    8884  }
    8985
     
    118114  }
    119115
    120   bool Client::processChat(packet::Chat *message, unsigned int clientID){
    121     return message->process();
     116  bool Client::processChat(std::string message, unsigned int playerID){
     117    COUT(1) << "Player " << playerID << ": " << message << std::endl;
     118    return true;
    122119  }
    123 
    124   /*bool Client::sendChat(packet::Chat *chat){
    125     chat->process();
    126     packet::Packet *p = new packet::Packet(chat);
    127     return p->send();
    128   }*/
     120 
     121  /**
     122   * This function implements the method of sending a chat message to the server
     123   * @param message message to be sent
     124   * @return result(true/false)
     125   */
     126  bool Client::chat(std::string message){
     127    packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
     128    return m->send();
     129  }
    129130
    130131
    131132  /**
    132   * submits a chat message to the server
    133   * @param message message to send
    134   * @return true/false
    135   */
    136   bool Client::sendChat( std::string message ){
    137     // generate packet and add it to queue
    138     if(!isConnected)
    139       return false;
    140     packet::Chat chat(message, 0);
    141     return chat.send();
    142     // send packets
    143   }
    144 
    145   /**
    146   * Performs a GameState update
    147   */
     133   * Processes incoming packets, sends a gamestate to the server and does the cleanup
     134   * @param time
     135   */
    148136  void Client::tick(float time){
    149137//     COUT(3) << ".";
     
    164152      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
    165153      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
    166       assert(packet->process());
     154      bool b = packet->process();
     155      assert(b);
    167156    }
    168157    if(gamestate.processGamestates())
     
    170159      if(!isSynched_)
    171160        isSynched_=true;
    172     }else
    173       COUT(3) << "gamestate has not been processed sucessfully" << std::endl;
     161    }
    174162    gamestate.cleanup();
    175163    return;
Note: See TracChangeset for help on using the changeset viewer.