Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3214 for code/trunk


Ignore:
Timestamp:
Jun 23, 2009, 6:02:25 PM (15 years ago)
Author:
scheusso
Message:

merged netp5 back to trunk

Location:
code/trunk/src
Files:
4 added
2 deleted
62 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/Core.cc

    r3196 r3214  
    4747#  endif
    4848#  include <windows.h>
     49#  undef min
     50#  undef max
    4951#elif defined(ORXONOX_PLATFORM_APPLE)
    5052#  include <sys/param.h>
  • code/trunk/src/core/CorePrecompiledHeaders.h

    r3196 r3214  
    3535#include "CorePrereqs.h"
    3636
     37#include <cassert>
    3738#include <fstream>
    3839#include <iostream>
    3940#include <list>
     41#include <locale>
    4042#include <map>
     43#include <queue>
    4144#include <set>
    4245#include <sstream>
     46#include <stack>
    4347#include <string>
    4448#include <vector>
     
    4751#ifdef ORXONOX_COMPILER_MSVC
    4852
    49 #define WIN32_LEAN_AND_MEAN
    50 #include <windows.h>
     53#include <OgreMath.h>
     54#include <OgreVector2.h>
     55#include <OgreVector3.h>
     56#include <OgreVector4.h>
     57#include <OgreQuaternion.h>
     58#include <OgreColourValue.h>
     59
     60#include <boost/shared_ptr.hpp> // 12
     61#include <boost/preprocessor/cat.hpp> // 12
     62// Included by both filesystem and thread but still relatively small
     63#include <boost/iterator/iterator_facade.hpp> // 10
     64
     65// Just in case some header included windows.h
     66#undef min
    5167#undef max
    52 #undef min
    53 
    54 #include <ois/OISKeyboard.h>
    55 #include <ois/OISMouse.h>
    56 #include <ois/OISJoyStick.h>
    57 #include <tinyxml/ticpp.h>
    58 // Included by both filesystem and thread but still relatively small
    59 #include <boost/iterator/iterator_facade.hpp>
    6068
    6169#endif /* ORXONOX_COMPILER_MSVC */
    6270
    6371
    64 #include "util/Convert.h"
    6572#include "util/Debug.h"
    66 #include "util/Exception.h"
    6773#include "util/Math.h"
    68 #include "util/mbool.h"
    6974#include "util/MultiType.h"
    70 #include "util/OrxAssert.h"
    71 #include "util/OrxEnum.h"
    72 #include "util/String.h"
    7375#include "util/SubString.h"
    7476
  • code/trunk/src/network/CMakeLists.txt

    r3196 r3214  
    2424  ClientInformation.cc
    2525  ClientConnectionListener.cc
    26   ConnectionManager.cc
     26  Connection.cc
    2727  FunctionCallManager.cc
    2828  GamestateManager.cc
     
    3333  PacketBuffer.cc
    3434  Server.cc
     35  ServerConnection.cc
    3536  TrafficControl.cc
    3637)
  • code/trunk/src/network/ChatListener.cc

    r2896 r3214  
    2828
    2929#include "ChatListener.h"
    30 
    3130#include "core/CoreIncludes.h"
    3231
  • code/trunk/src/network/ChatListener.h

    r2171 r3214  
    3131
    3232#include "NetworkPrereqs.h"
    33 
    34 #include "ClientInformation.h"
    3533#include "core/OrxonoxClass.h"
    3634
  • code/trunk/src/network/Client.cc

    r3198 r3214  
    3939//
    4040
     41#include "Client.h"
     42
    4143#include <cassert>
    42 #include <enet/enet.h>
    4344
    44 #include "Client.h"
    45 #include "Host.h"
     45#include "util/Debug.h"
     46#include "core/Clock.h"
    4647#include "synchronisable/Synchronisable.h"
    47 #include "core/Clock.h"
    48 #include "core/CoreIncludes.h"
    49 #include "packet/Packet.h"
     48#include "packet/Chat.h"
     49#include "packet/Gamestate.h"
    5050#include "FunctionCallManager.h"
    51 
    52 // #include "packet/Acknowledgement.h"
    5351
    5452namespace orxonox
    5553{
    56 //   SetConsoleCommandShortcut(Client, chat);
    5754
    5855
     
    6158  * initializes the address and the port to default localhost:NETWORK_PORT
    6259  */
    63   Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
    64     // set server address to localhost
    65     isConnected=false;
    66     isSynched_=false;
    67     gameStateFailure_=false;
     60  Client::Client():
     61      isSynched_(false),
     62      gameStateFailure_(false)
     63  {
    6864  }
    6965
     
    7369  * @param port port of the application on the server
    7470  */
    75   Client::Client(const std::string& address, int port) : client_connection(port, address){
    76     isConnected=false;
    77     isSynched_=false;
    78     gameStateFailure_=false;
    79   }
    80 
    81   /**
    82   * Constructor for the Client class
    83   * @param address the server address
    84   * @param port port of the application on the server
    85   */
    86   Client::Client(const char *address, int port) : client_connection(port, address){
    87     isConnected=false;
    88     isSynched_=false;
    89     gameStateFailure_=false;
     71  Client::Client(const std::string& address, int port):
     72      isSynched_(false),
     73      gameStateFailure_(false)
     74  {
     75      setPort( port );
     76      setServerAddress( address );
    9077  }
    9178
    9279  Client::~Client(){
    93     if(isConnected)
     80    if ( ClientConnection::isConnected() )
    9481      closeConnection();
    9582  }
     
    10188  bool Client::establishConnection(){
    10289    Synchronisable::setClient(true);
    103     isConnected=client_connection.createConnection();
    104     if(!isConnected)
    105       COUT(1) << "could not create connection laber" << std::endl;
    106     return isConnected;
     90    return ClientConnection::establishConnection();
    10791  }
    10892
     
    11296  */
    11397  bool Client::closeConnection(){
    114     isConnected=false;
    115     return client_connection.closeConnection();
     98    return ClientConnection::closeConnection();
    11699  }
    117100
    118101  bool Client::queuePacket(ENetPacket *packet, int clientID){
    119     return client_connection.addPacket(packet);
     102    bool b = ClientConnection::addPacket(packet);
     103    assert(b);
     104    return b;
    120105  }
    121106
     
    143128    //this steers our network frequency
    144129    timeSinceLastUpdate_+=time.getDeltaTime();
    145     if(timeSinceLastUpdate_>=NETWORK_PERIOD){
     130    if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     131    {
    146132      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    147133      //     COUT(3) << ".";
    148       if(client_connection.isConnected() && isSynched_){
     134      if ( isConnected() && isSynched_ )
     135      {
    149136        COUT(4) << "popping partial gamestate: " << std::endl;
    150137        packet::Gamestate *gs = gamestate.getGamestate();
     
    159146      }
    160147    }
     148    sendPackets(); // flush the enet queue
    161149   
    162     ENetEvent *event;
    163     // stop if the packet queue is empty
    164     while(!(client_connection.queueEmpty())){
    165       event = client_connection.getEvent();
    166       COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
    167       packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
    168       // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
    169       bool b = packet->process();
    170       assert(b);
    171       delete event;
    172     }
     150    Connection::processQueue();
    173151    if(gamestate.processGamestates())
    174152    {
  • code/trunk/src/network/Client.h

    r3084 r3214  
    4545
    4646#include <string>
    47 
    48 #include "Host.h"
    49 #include "packet/Chat.h"
    5047#include "ClientConnection.h"
    5148#include "GamestateClient.h"
    52 
     49#include "Host.h"
    5350
    5451namespace orxonox
     
    6158  *
    6259  */
    63   class _NetworkExport Client : public Host{
     60  class _NetworkExport Client : public Host, public ClientConnection{
    6461  public:
    6562    Client();
    6663    Client(const std::string& address, int port);
    67     Client(const char *address, int port);
    6864    ~Client();
    6965
     
    7470    virtual bool chat(const std::string& message);
    7571    virtual bool broadcast(const std::string& message) { return false; }
    76     //bool sendChat(packet::Chat *chat);
    7772
    7873    void update(const Clock& time);
     
    8277    virtual bool isServer_(){return false;}
    8378
    84     ClientConnection client_connection;
    8579    GamestateClient gamestate;
    86     bool isConnected;
    8780    bool isSynched_;
    8881
  • code/trunk/src/network/ClientConnection.cc

    r3198 r3214  
    2727 */
    2828
    29 //
    30 // C++ Interface: ClientConnection
    31 //
    32 // Description: The Class ClientConnection manages the servers conenctions to the clients.
    33 // each connection is provided by a new process. communication between master process and
    34 // connection processes is provided by ...
    35 //
    36 //
    37 // Author:  Oliver Scheuss
    38 //
    39 
    4029#include "ClientConnection.h"
    4130
     31#include <cassert>
    4232#include <enet/enet.h>
    43 #include <iostream>
    44 #include <cassert>
    45 // boost.thread library for multithreading support
    46 #include <boost/thread/thread.hpp>
    47 #include <boost/bind.hpp>
    48 #include <boost/thread/recursive_mutex.hpp>
    49 
    50 #include "util/Sleep.h"
    5133#include "util/Debug.h"
    5234
    5335namespace orxonox
    5436{
    55   //static boost::thread_group network_threads;
     37  const unsigned int NETWORK_CLIENT_WAIT_TIME = 1;
     38  const unsigned int NETWORK_CLIENT_CONNECTION_TIMEOUT = 3000; //millisecs
     39  const unsigned int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
     40  const unsigned int NETWORK_CLIENT_CHANNELS = 2;
    5641
    57   static boost::recursive_mutex enet_mutex_g;
    5842
    59   ClientConnection::ClientConnection(int port, const std::string& address) {
    60     quit_=false;
    61     server=NULL;
    62     serverAddress = new ENetAddress();
    63     enet_address_set_host(serverAddress, address.c_str());
    64     serverAddress->port = port;
    65     established=false;
    66   }
    67 
    68   ClientConnection::ClientConnection(int port, const char *address) {
    69     quit_=false;
    70     server=NULL;
    71     serverAddress = new ENetAddress();
    72     enet_address_set_host(serverAddress, address);
    73     serverAddress->port = port;
    74     established=false;
    75   }
    76 
    77   bool ClientConnection::waitEstablished(int milisec) {
    78     for(int i=0; i<=milisec && !established; i++)
    79       msleep(1);
    80 
    81     return established;
     43  ClientConnection::ClientConnection():
     44    established_(false),
     45    server_(NULL)
     46  {
     47    this->serverAddress_ = new ENetAddress();
     48    //set standard address and port
     49    enet_address_set_host(this->serverAddress_, "127.0.0.1");
     50    serverAddress_->port = NETWORK_PORT;
    8251  }
    8352
    8453  ClientConnection::~ClientConnection(){
    85     if(established)
     54    if(this->established_)
    8655      closeConnection();
    87     delete serverAddress; // surely was created
     56    delete this->serverAddress_; // surely was created
    8857  }
    8958
    90   ENetEvent *ClientConnection::getEvent(){
    91     if(!buffer.isEmpty())
    92       return buffer.pop();
    93     else
    94       return NULL;
     59  void ClientConnection::setServerAddress( const std::string& serverAddress ) {
     60    enet_address_set_host (this->serverAddress_, serverAddress.c_str());
    9561  }
    9662
    97   bool ClientConnection::queueEmpty() {
    98     return buffer.isEmpty();
     63  void ClientConnection::setPort( unsigned int port ) {
     64    this->serverAddress_->port = port;
    9965  }
    10066
    101   bool ClientConnection::createConnection() {
    102     receiverThread_ = new boost::thread(boost::bind(&ClientConnection::receiverThread, this));
    103     //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
    104     // wait 10 seconds for the connection to be established
    105     return waitEstablished(NETWORK_CLIENT_CONNECT_TIMEOUT);
    106   }
    107 
    108   bool ClientConnection::closeConnection() {
    109     quit_=true;
    110     //network_threads.join_all();
    111     receiverThread_->join();
    112     established=false;
    113     return true;
    114   }
    115 
    116 
    117   bool ClientConnection::addPacket(ENetPacket *packet) {
    118     if(server==NULL)
    119       return false;
    120     if(packet==NULL){
    121       COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl;
     67  bool ClientConnection::establishConnection()
     68  {
     69    ENetEvent event;
     70   
     71    this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
     72    if ( this->host_ == NULL )
     73    {
     74      COUT(2) << "ClientConnection: host_ == NULL" << std::endl;
     75      // error handling
    12276      return false;
    12377    }
    124     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    125     if(enet_peer_send(server, 0, packet)<0)
    126       return false;
    127     else
    128       return true;
    129   }
    130 
    131   bool ClientConnection::sendPackets() {
    132     if(server==NULL)
    133       return false;
    134     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    135     enet_host_flush(client);
    136     lock.unlock();
    137     return true;
    138   }
    139 
    140   void ClientConnection::receiverThread() {
    141     // what about some error-handling here ?
    142     atexit(enet_deinitialize);
    143     ENetEvent *event;
     78    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS);
     79    if ( this->server_==NULL )
    14480    {
    145       boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    146       enet_initialize();
    147       client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
    148       lock.unlock();
    149     }
    150     if(client==NULL) {
    151       COUT(2) << "ClientConnection: could not create client host" << std::endl;
    152       // add some error handling here ==========================
    153       quit_=true;
    154     }
    155     //connect to the server
    156     if(!establishConnection()){
    157       COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
    158       quit_=true;
    159       return;
    160     }
    161     event = new ENetEvent;
    162     //main loop
    163     while(!quit_){
    164       //std::cout << "connection loop" << std::endl;
    165       {
    166         boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    167         if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
    168           // we should never reach this point
    169 //              assert(0);
    170           printf("ClientConnection: ENet returned with an error!\n");
    171 //           quit_=true;
    172           continue;
    173           // add some error handling here ========================
    174         }
    175         lock.unlock();
    176       }
    177       switch(event->type){
    178         // log handling ================
    179       case ENET_EVENT_TYPE_CONNECT:
    180         break;
    181       case ENET_EVENT_TYPE_RECEIVE:
    182         //COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
    183         if ( !processData(event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl;
    184         //COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
    185         event = new ENetEvent;
    186         break;
    187       case ENET_EVENT_TYPE_DISCONNECT:
    188         quit_=true;
    189         printf("Received disconnect Packet from Server!\n");
    190         // server closed the connection
    191         return;
    192         break;
    193       case ENET_EVENT_TYPE_NONE:
    194         //receiverThread_->yield();
    195         msleep(1);
    196         break;
    197       }
    198     }
    199     delete event;
    200     // now disconnect
    201 
    202     if(!disconnectConnection())
    203     {
    204       printf("could not disconnect properly\n");
    205       // if disconnecting failed destroy conn.
    206       boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    207       enet_peer_reset(server);
    208     }
    209     else
    210       printf("properly disconnected\n");
    211     return;
    212   }
    213 
    214   bool ClientConnection::disconnectConnection() {
    215     ENetEvent event;
    216     if(this->quit_)
    217       return true;
    218     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    219     enet_peer_disconnect(server, 0);
    220     while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) >= 0){
    221       switch (event.type)
    222       {
    223       case ENET_EVENT_TYPE_NONE:
    224       case ENET_EVENT_TYPE_CONNECT:
    225       case ENET_EVENT_TYPE_RECEIVE:
    226         enet_packet_destroy(event.packet);
    227         break;
    228       case ENET_EVENT_TYPE_DISCONNECT:
    229         printf("received disconnect confirmation from server");
    230         return true;
    231       }
    232     }
    233     enet_peer_reset(server);
    234     return false;
    235   }
    236 
    237   bool ClientConnection::establishConnection() {
    238     ENetEvent event;
    239     // connect to peer (server is type ENetPeer*)
    240     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    241     server = enet_host_connect(client, serverAddress, NETWORK_CLIENT_CHANNELS);
    242     if(server==NULL) {
    24381      COUT(2) << "ClientConnection: server == NULL" << std::endl;
    24482      // error handling
     
    24684    }
    24785    // handshake
    248     while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit_){
    249       if( event.type == ENET_EVENT_TYPE_CONNECT ){
    250         established=true;
     86    for( unsigned int i=0; i<NETWORK_CLIENT_CONNECTION_TIMEOUT/NETWORK_CLIENT_WAIT_TIME; i++ )
     87    {
     88      if( enet_host_service(this->host_, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && event.type == ENET_EVENT_TYPE_CONNECT )
     89      {
     90        this->established_=true;
    25191        return true;
    25292      }
    25393    }
    254     COUT(2) << "ClientConnection: enet_host_service < 0 or event.type != ENET_EVENT_TYPE_CONNECT # EVENT:" << event.type << std::endl;
     94    COUT(1) << "Could not connect to server" << endl;
    25595    return false;
    25696  }
    25797
    258   bool ClientConnection::processData(ENetEvent *event) {
    259     COUT(5) << "Cl.Con: got packet, pushing to queue" << std::endl;
    260     // just add packet to the buffer
    261     // this can be extended with some preprocessing
    262     return buffer.push(event);
     98  bool ClientConnection::closeConnection() {
     99    ENetEvent event;
     100   
     101    if ( !this->established_ )
     102      return true;
     103    this->established_ = false;
     104    enet_peer_disconnect(this->server_, 0);
     105    for( unsigned int i=0; i<NETWORK_CLIENT_CONNECTION_TIMEOUT/NETWORK_CLIENT_WAIT_TIME; i++)
     106    {
     107      if ( enet_host_service(this->host_, &event, NETWORK_CLIENT_WAIT_TIME) >= 0 )
     108      {
     109        switch (event.type)
     110        {
     111          case ENET_EVENT_TYPE_NONE:
     112          case ENET_EVENT_TYPE_CONNECT:
     113            break;
     114          case ENET_EVENT_TYPE_RECEIVE:
     115            enet_packet_destroy(event.packet);
     116            break;
     117          case ENET_EVENT_TYPE_DISCONNECT:
     118            COUT(4) << "received disconnect confirmation from server" << endl;
     119            return true;
     120        }
     121      }
     122    }
     123    enet_peer_reset( this->server_ );
     124    return false;
     125  }
     126
     127
     128  bool ClientConnection::addPacket(ENetPacket *packet) {
     129    assert( this->server_ );
     130    assert( packet );
     131    return Connection::addPacket( packet, this->server_ );
     132  }
     133
     134  void ClientConnection::addClient(ENetEvent* event)
     135  {
     136    assert(0);
     137  }
     138  void ClientConnection::disconnectPeer(ENetEvent* event)
     139  {
     140    this->established_=false;
     141    COUT(1) << "Received disconnect Packet from Server!" << endl;
     142        // server closed the connection
    263143  }
    264144
  • code/trunk/src/network/ClientConnection.h

    r3084 r3214  
    2626 *
    2727 */
    28 
    29 //
    30 // C++ Interface: ClientConnection
    31 //
    32 // Description:
    33 //
    34 //
    35 // Author:  Oliver Scheuss, (C) 2007
    36 //
    37 // Copyright: See COPYING file that comes with this distribution
    38 //
    39 //
     28 
    4029#ifndef _ClientConnection_H__
    4130#define _ClientConnection_H__
    4231
    4332#include "NetworkPrereqs.h"
    44 
    45 #include <string>
    46 #include "PacketBuffer.h"
    47 
    48 namespace boost { class thread; }
     33#include "Connection.h"
    4934
    5035namespace orxonox
    5136{
    5237
    53     const int NETWORK_PORT = 55556;
    54     const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
    55     const int NETWORK_CLIENT_WAIT_TIME = 10;
    56     const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
    57     const int NETWORK_CLIENT_CHANNELS = 2;
    58 
    59 
    60   class _NetworkExport ClientConnection{
     38  class _NetworkExport ClientConnection: public Connection{
    6139  public:
    62     ClientConnection(int port, const std::string& address);
    63     ClientConnection(int port, const char* address);
    64     ~ClientConnection();
     40    ClientConnection();
     41    virtual ~ClientConnection();
     42   
     43    void setServerAddress( const std::string& serverAddress );
     44    void setPort( unsigned int port );
     45   
    6546    ENetEvent *getEvent();
    6647    // check wheter the packet queue is empty
    6748    bool queueEmpty();
    6849    // create a new listener thread
    69     bool createConnection();
    70     bool closeConnection();
     50    virtual bool establishConnection();
     51    virtual bool closeConnection();
    7152    // add a packet to queue for the server
    7253    bool addPacket(ENetPacket *packet);
    73     // send out all queued packets
    74     bool sendPackets();
    75     // send out all queued packets and save result in event
    76     //bool sendPackets(ENetEvent *event);
    77     bool waitEstablished(int milisec);
    78     inline bool isConnected(){return established;}
    79     inline bool checkConnection(){ return !quit_ && isConnected(); }
     54    inline bool isConnected(){ return this->established_; }
    8055  private:
    81     ClientConnection(const ClientConnection& copy); // not used
    82     bool processData(ENetEvent *event);
    83     // implementation of the listener
    84     void receiverThread(); //thread2
    85     //packetbuffer
    86     bool establishConnection();
     56    virtual void addClient(ENetEvent* event);
     57    virtual void disconnectPeer(ENetEvent* event);
     58   
    8759    bool disconnectConnection();
    88     PacketBuffer buffer;
    8960    // enet stuff
    90     ENetHost *client;
    91     ENetAddress *serverAddress;
    92     // quit-variable (communication with threads)
    93     bool quit_;
    94     bool established;
     61    ENetAddress *serverAddress_;
     62    bool established_;
    9563    // clientlist
    96     ENetPeer *server;
    97     boost::thread *receiverThread_;
     64    ENetPeer *server_;
    9865};
    99 
    100 
    101 
    102 
    103 
    104 
    10566
    10667
  • code/trunk/src/network/ClientConnectionListener.cc

    r2896 r3214  
    2828
    2929#include "ClientConnectionListener.h"
     30
    3031#include "core/CoreIncludes.h"
    3132#include "core/GameMode.h"
     33#include "ClientInformation.h"
    3234
    3335namespace orxonox{
  • code/trunk/src/network/ClientConnectionListener.h

    r2171 r3214  
    1 #ifndef _NETWORK_CLIENTCONNECTIONLISTENER__
    2 #define _NETWORK_CLIENTCONNECTIONLISTENER__
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29#ifndef _ClientConnectionListener_H__
     30#define _ClientConnectionListener_H__
    331
    432#include "NetworkPrereqs.h"
    5 #include "ClientInformation.h"
    633#include "core/OrxonoxClass.h"
    734
     
    2653
    2754
    28 #endif
     55#endif /* _ClientConnectionListener_H__ */
  • code/trunk/src/network/ClientInformation.cc

    r2773 r3214  
    4040
    4141#include "ClientInformation.h"
    42 
    4342#include <enet/enet.h>
    44 #include <iostream> //debug
    4543
    4644namespace orxonox
  • code/trunk/src/network/FunctionCallManager.h

    r3084 r3214  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128
    2 #ifndef NETWORKFUNCTIONCALLMANAGER_H
    3 #define NETWORKFUNCTIONCALLMANAGER_H
     29#ifndef _FunctionCallManager_H__
     30#define _FunctionCallManager_H__
    431
    532#include "NetworkPrereqs.h"
    6 #include "packet/FunctionCalls.h"
     33
    734#include <map>
    8 
     35#include "util/UtilPrereqs.h"
    936
    1037namespace orxonox {
     
    1239        @author
    1340*/
    14 
    15 class MultiType;
    1641
    1742class _NetworkExport FunctionCallManager
     
    4267} //namespace orxonox
    4368
    44 #endif
     69#endif /* _FunctionCallManager_H__ */
  • code/trunk/src/network/GamestateClient.cc

    r3196 r3214  
    2929#include "GamestateClient.h"
    3030
    31 #include <cassert>
    32 #include <zlib.h>
    33 
    34 #include "core/CoreIncludes.h"
    35 #include "core/BaseObject.h"
     31#include "util/Debug.h"
     32#include "core/ObjectList.h"
    3633#include "synchronisable/Synchronisable.h"
    3734#include "synchronisable/NetworkCallbackManager.h"
    3835#include "packet/Acknowledgement.h"
     36#include "packet/Gamestate.h"
    3937
    4038
  • code/trunk/src/network/GamestateClient.h

    r2171 r3214  
    4141#define _GamestateClient_H__
    4242
     43#include "NetworkPrereqs.h"
     44
    4345#include <map>
    44 //
    45 #include "NetworkPrereqs.h"
    4646#include "core/CorePrereqs.h"
    47 #include "packet/Gamestate.h"
    4847#include "GamestateHandler.h"
    4948
  • code/trunk/src/network/GamestateHandler.cc

    r2773 r3214  
    1 #include <cassert>
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    228
    329#include "GamestateHandler.h"
    4 #include "packet/Packet.h"
     30#include <cassert>
    531
    632namespace orxonox {
  • code/trunk/src/network/GamestateHandler.h

    r2171 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKGAMESTATEHANDLER_H
    29 #define NETWORKGAMESTATEHANDLER_H
    3028
    31 #include <string>
     29#ifndef _GamestateHandler_H__
     30#define _GamestateHandler_H__
    3231
    3332#include "NetworkPrereqs.h"
    34 #include "packet/Chat.h"
    3533
    3634namespace orxonox {
     
    5856}
    5957
    60 #endif
     58#endif /* _GamestateHandler_H__ */
  • code/trunk/src/network/GamestateManager.cc

    r3198 r3214  
    4141#include "GamestateManager.h"
    4242
    43 #include <utility>
    44 #include <iostream>
    45 #include <zlib.h>
    4643#include <cassert>
    4744
    48 #include "core/CoreIncludes.h"
    49 #include "core/BaseObject.h"
     45#include "util/Debug.h"
    5046#include "ClientInformation.h"
    51 #include "synchronisable/Synchronisable.h"
     47#include "packet/Acknowledgement.h"
     48#include "packet/Gamestate.h"
    5249#include "synchronisable/NetworkCallbackManager.h"
    53 #include "packet/Acknowledgement.h"
     50#include "TrafficControl.h"
    5451
    5552namespace orxonox
  • code/trunk/src/network/GamestateManager.h

    r3084 r3214  
    4242
    4343#include "NetworkPrereqs.h"
     44
     45#include <map>
    4446#include "GamestateHandler.h"
    45 #include "TrafficControl.h"
    46 #include <map>
    47 
    48 #include "packet/Gamestate.h"
    4947
    5048namespace orxonox
    5149{
    5250
    53     const int KEEP_GAMESTATES = 10;
     51  const int KEEP_GAMESTATES = 10;
    5452
    5553  /**
  • code/trunk/src/network/Host.cc

    r3095 r3214  
    2727 */
    2828
     29#include "Host.h"
     30
    2931#include <cassert>
     32#include <string>
    3033
    31 #include "Host.h"
    3234#include "core/ConsoleCommand.h"
    33 #include "packet/Packet.h"
     35#include "core/ObjectList.h"
    3436#include "ChatListener.h"
    3537
  • code/trunk/src/network/Host.h

    r3196 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKHOST_H
    29 #define NETWORKHOST_H
    3028
    31 #include <string>
     29#ifndef _NETWORK_Host_H__
     30#define _NETWORK_Host_H__
    3231
    3332#include "NetworkPrereqs.h"
    34 #include "packet/Chat.h"
    3533
    3634namespace orxonox {
     
    8684}
    8785
    88 #endif
     86#endif /* _NETWORK_Host_H__ */
  • code/trunk/src/network/NetworkFunction.cc

    r3084 r3214  
    2828
    2929#include "NetworkFunction.h"
    30 #include <string>
    31 #include "synchronisable/Synchronisable.h"
     30#include "core/CoreIncludes.h"
    3231
    3332namespace orxonox
     
    4241  std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
    4342
    44   NetworkFunctionBase::NetworkFunctionBase(std::string name)
     43  NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
    4544  {
    4645    RegisterRootObject(NetworkFunctionBase);
     
    5857 
    5958 
    60   NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p):
     59  NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
    6160    NetworkFunctionBase(name)
    6261  {
     
    7574 
    7675 
    77   NetworkMemberFunctionBase::NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p):
     76  NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
    7877    NetworkFunctionBase(name)
    7978  {
  • code/trunk/src/network/NetworkFunction.h

    r3196 r3214  
    2727 */
    2828
    29 #ifndef NETWORKFUNCTION_H
    30 #define NETWORKFUNCTION_H
     29#ifndef _NetworkFunction_H__
     30#define _NetworkFunction_H__
    3131
    3232#include "NetworkPrereqs.h"
     33
     34#include <cassert>
     35#include <cstring>
     36#include <map>
     37#include <string>
     38#include <boost/preprocessor/cat.hpp>
     39
    3340#include "core/OrxonoxClass.h"
    34 
    35 #include <string>
    36 #include <map>
    37 #include <cassert>
    38 #include <boost/preprocessor/cat.hpp>
    39 #include "util/MultiType.h"
    4041#include "core/Functor.h"
     42#include "FunctionCallManager.h"
    4143#include "synchronisable/Synchronisable.h"
    42 #include "OrxonoxConfig.h"
    43 #include "FunctionCallManager.h"
    44 
    4544
    4645namespace orxonox
     
    7271class _NetworkExport NetworkFunctionBase: virtual public OrxonoxClass {
    7372  public:
    74     NetworkFunctionBase(std::string name);
     73    NetworkFunctionBase(const std::string& name);
    7574    ~NetworkFunctionBase();
    7675   
    77     inline void         setNetworkID(uint32_t id)       { this->networkID_ = id; }
     76    virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
    7877    inline uint32_t     getNetworkID() const            { return this->networkID_; }
    79     inline std::string  getName() const                 { return name_; }
     78    inline const std::string& getName() const           { return name_; }
    8079    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
    8180   
    82     static inline void setNetworkID(std::string name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
     81    static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
    8382   
    8483  protected:
     
    9594class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    9695  public:
    97     NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p);
     96    NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
    9897    ~NetworkFunctionStatic();
    9998   
     
    105104    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
    106105   
     106    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
    107107    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
    108108    static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
     
    120120class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
    121121  public:
    122     NetworkMemberFunctionBase(std::string name, const NetworkFunctionPointer& p);
     122    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
    123123    ~NetworkMemberFunctionBase();
    124124   
     125    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
    125126    static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
    126127    static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
     
    143144template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
    144145  public:
    145     NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p);
     146    NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
    146147    ~NetworkMemberFunction();
    147148   
     
    181182};
    182183
    183 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p):
     184template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p):
    184185    NetworkMemberFunctionBase(name, p), functor_(functor)
    185186{
     
    199200}
    200201
    201 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, std::string name )
     202template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    202203{
    203204  NetworkFunctionPointer destptr;
     
    207208}
    208209
    209 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, std::string name )
     210template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    210211{
    211212  NetworkFunctionPointer destptr;
     
    237238}
    238239
    239 #endif
     240#endif /* _NetworkFunction_H__ */
  • code/trunk/src/network/NetworkPrecompiledHeaders.h

    r3196 r3214  
    3535#include "NetworkPrereqs.h"
    3636
     37#include <cassert>
    3738#include <fstream>
    3839#include <iostream>
    3940#include <list>
    4041#include <map>
     42#include <queue>
    4143#include <set>
    4244#include <sstream>
     
    4749#ifdef ORXONOX_COMPILER_MSVC
    4850
     51#include <OgreMath.h>
     52#include <OgreVector2.h>
     53#include <OgreVector3.h>
     54#include <OgreVector4.h>
     55#include <OgreQuaternion.h>
     56#include <OgreColourValue.h>
     57
    4958#define WIN32_LEAN_AND_MEAN
    5059#include <enet/enet.h>
     
    5261#undef min
    5362
    54 // Too larg PCH file if you include this and only 10% faster
    55 //#include <boost/thread/recursive_mutex.hpp>
    56 
    57 #include "util/CRC32.h"
    5863#include "util/Debug.h"
    59 #include "util/Math.h"
    60 #include "util/mbool.h"
    61 #include "util/MultiType.h"
    62 #include "util/String.h"
    63 
    64 #include "core/Core.h"
    65 #include "core/CoreIncludes.h"
    66 #include "core/Functor.h"
    67 #include "core/GameMode.h"
     64#include "core/Identifier.h"
    6865
    6966#endif /* ORXONOX_COMPILER_MSVC */
  • code/trunk/src/network/NetworkPrereqs.h

    r3084 r3214  
    8989  class ClientFrameListener;
    9090  class ClientInformation;
    91   class ConnectionManager;
     91  class Connection;
    9292  class FunctionCallManager;
    9393  class GamestateClient;
     
    104104  class PacketBuffer;
    105105  class Server;
     106  class ServerConnection;
    106107  class ServerFrameListener;
    107108  class Synchronisable;
     
    113114  struct QueueItem;
    114115  struct syncData;
     116  class TrafficControl;
    115117  class obj;
    116118  class objInfo;
     
    127129    class Packet;
    128130    class Welcome;
     131
     132    namespace PacketFlag
     133    {
     134      enum Enum
     135      {
     136        Reliable   = 1,
     137        Unsequence = 2,
     138        NoAllocate = 4
     139      };
     140    }
    129141  }
    130142}
  • code/trunk/src/network/PacketBuffer.cc

    r2773 r3214  
    3333#include "PacketBuffer.h"
    3434
    35 #include <enet/enet.h>
    36 #include <iostream>
    37 #include <queue>
    38 #include <string>
    39 #include <boost/bind.hpp>
    40 #include <boost/thread/mutex.hpp>
     35//#include <iostream>
    4136#include <boost/thread/recursive_mutex.hpp>
    4237
  • code/trunk/src/network/Server.cc

    r3198 r3214  
    4242
    4343#include <enet/enet.h>
    44 #include <iostream>
    4544#include <cassert>
    46 
    47 
    48 #include "ConnectionManager.h"
    49 #include "ClientConnectionListener.h"
     45#include <string>
     46
     47#include "util/Debug.h"
     48#include "core/Clock.h"
     49#include "core/ObjectList.h"
     50#include "packet/Chat.h"
     51#include "packet/ClassID.h"
     52#include "packet/DeleteObjects.h"
     53#include "packet/FunctionIDs.h"
     54#include "packet/Gamestate.h"
     55#include "packet/Welcome.h"
     56#include "ChatListener.h"
     57#include "ClientInformation.h"
     58#include "FunctionCallManager.h"
    5059#include "GamestateManager.h"
    51 #include "ClientInformation.h"
    52 #include "util/Sleep.h"
    53 #include "core/Clock.h"
    54 #include "core/ConsoleCommand.h"
    55 #include "core/CoreIncludes.h"
    56 #include "packet/Chat.h"
    57 #include "packet/Packet.h"
    58 #include "packet/Welcome.h"
    59 #include "packet/DeleteObjects.h"
    60 #include "util/Convert.h"
    61 #include "ChatListener.h"
    62 #include "FunctionCallManager.h"
    63 #include "packet/FunctionIDs.h"
    64 
    6560
    6661namespace orxonox
     
    7469  Server::Server() {
    7570    timeSinceLastUpdate_=0;
    76     connection = new ConnectionManager();
    7771    gamestates_ = new GamestateManager();
    7872  }
    7973
    8074  Server::Server(int port){
     75    this->setPort( port );
    8176    timeSinceLastUpdate_=0;
    82     connection = new ConnectionManager(port);
    8377    gamestates_ = new GamestateManager();
    8478  }
     
    9084  */
    9185  Server::Server(int port, const std::string& bindAddress) {
     86    this->setPort( port );
     87    this->setBindAddress( bindAddress );
    9288    timeSinceLastUpdate_=0;
    93     connection = new ConnectionManager(port, bindAddress);
    9489    gamestates_ = new GamestateManager();
    9590  }
    9691
    9792  /**
    98   * Constructor
    99   * @param port Port to listen on
    100   * @param bindAddress Address to listen on
    101   */
    102   Server::Server(int port, const char *bindAddress) {
    103     timeSinceLastUpdate_=0;
    104     connection = new ConnectionManager(port, bindAddress);
    105     gamestates_ = new GamestateManager();
    106   }
    107 
    108   /**
    10993  * @brief Destructor
    11094  */
    11195  Server::~Server(){
    112     if(connection)
    113       delete connection;
    11496    if(gamestates_)
    11597      delete gamestates_;
     
    120102  */
    121103  void Server::open() {
    122     connection->createListener();
     104    COUT(4) << "opening server" << endl;
     105    this->openListener();
    123106    return;
    124107  }
     
    128111  */
    129112  void Server::close() {
    130     ClientInformation *temp = ClientInformation::getBegin();
    131     ClientInformation *temp2;
    132     // disconnect all connected clients
    133     while( temp )
    134     {
    135       temp2 = temp;
    136       temp = temp->next();
    137       disconnectClient( temp2 );
    138     }
    139     connection->quitListener();
     113    COUT(4) << "closing server" << endl;
     114    this->disconnectClients();
     115    this->closeListener();
    140116    return;
    141117  }
     
    162138  */
    163139  void Server::update(const Clock& time) {
    164     processQueue();
     140    Connection::processQueue();
    165141    gamestates_->processGamestates();
    166142    //this steers our network frequency
    167143    timeSinceLastUpdate_+=time.getDeltaTime();
    168     if(timeSinceLastUpdate_>=NETWORK_PERIOD){
     144    if(timeSinceLastUpdate_>=NETWORK_PERIOD)
     145    {
    169146      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    170147      updateGamestate();
    171148      FunctionCallManager::sendCalls();
    172149    }
     150    sendPackets(); // flush the enet queue
    173151  }
    174152
    175153  bool Server::queuePacket(ENetPacket *packet, int clientID){
    176     return connection->addPacket(packet, clientID);
     154    return ServerConnection::addPacket(packet, clientID);
    177155  }
    178156 
     
    191169    assert(ClientInformation::findClient(clientID));
    192170    return ClientInformation::findClient(clientID)->getPacketLoss();
    193   }
    194  
    195   /**
    196   * processes all the packets waiting in the queue
    197   */
    198   void Server::processQueue() {
    199     ENetEvent *event;
    200     while(!connection->queueEmpty()){
    201       //std::cout << "Client " << clientID << " sent: " << std::endl;
    202       //clientID here is a reference to grab clientID from ClientInformation
    203       event = connection->getEvent();
    204       if(!event)
    205         continue;
    206       assert(event->type != ENET_EVENT_TYPE_NONE);
    207       switch( event->type ) {
    208       case ENET_EVENT_TYPE_CONNECT:
    209         COUT(4) << "processing event_Type_connect" << std::endl;
    210         addClient(event);
    211         break;
    212       case ENET_EVENT_TYPE_DISCONNECT:
    213         if(ClientInformation::findClient(&event->peer->address))
    214           disconnectClient(event);
    215         break;
    216       case ENET_EVENT_TYPE_RECEIVE:
    217         if(!processPacket(event->packet, event->peer))
    218           COUT(3) << "processing incoming packet failed" << std::endl;
    219         break;
    220       default:
    221         break;
    222       }
    223       delete event;
    224       //if statement to catch case that packetbuffer is empty
    225     }
    226171  }
    227172
     
    318263
    319264
    320   bool Server::addClient(ENetEvent *event){
     265  void Server::addClient(ENetEvent *event){
    321266    static unsigned int newid=1;
    322267
     
    325270    if(!temp){
    326271      COUT(2) << "Server: could not add client" << std::endl;
    327       return false;
    328     }
    329     /*if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
    330       newid=1;
    331     }
    332     else
    333       newid=temp->prev()->getID()+1;*/
     272    }
    334273    temp->setID(newid);
    335274    temp->setPeer(event->peer);
     
    342281    }
    343282
    344     newid++;
     283    ++newid;
    345284
    346285    COUT(3) << "Server: added client id: " << temp->getID() << std::endl;
    347     return createClient(temp->getID());
     286    createClient(temp->getID());
    348287}
    349288
     
    357296   
    358297    // synchronise class ids
    359     connection->syncClassid(temp->getID());
     298    syncClassid(temp->getID());
    360299   
    361300    // now synchronise functionIDs
     
    382321    return true;
    383322  }
    384 
    385   bool Server::disconnectClient(ENetEvent *event){
    386     COUT(4) << "removing client from list" << std::endl;
    387     //return removeClient(head_->findClient(&(peer->address))->getID());
    388 
    389     //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    390     ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    391     if(!client)
    392       return false;
    393     else
    394       disconnectClient( client );
    395     return true;
    396   }
    397 
    398   void Server::disconnectClient(int clientID){
    399     ClientInformation *client = ClientInformation::findClient(clientID);
    400     if(client)
    401       disconnectClient(client);
    402   }
    403323 
    404   void Server::disconnectClient( ClientInformation *client){
    405     connection->disconnectClient(client);
     324  void Server::disconnectClient( ClientInformation *client ){
     325    ServerConnection::disconnectClient( client );
    406326    gamestates_->removeClient(client);
    407327// inform all the listeners
     
    439359  }
    440360
     361  void Server::syncClassid(unsigned int clientID) {
     362    int failures=0;
     363    packet::ClassID *classid = new packet::ClassID();
     364    classid->setClientID(clientID);
     365    while(!classid->send() && failures < 10){
     366      failures++;
     367    }
     368    assert(failures<10);
     369    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
     370  }
     371
    441372}
  • code/trunk/src/network/Server.h

    r3084 r3214  
    3232#include "NetworkPrereqs.h"
    3333
    34 #include <string>
    35 
     34#include "core/CorePrereqs.h"
    3635#include "Host.h"
    37 #include "GamestateManager.h"
     36#include "ServerConnection.h"
    3837
    3938namespace orxonox
     
    4443  * It implements all functions necessary for a Server
    4544  */
    46   class _NetworkExport Server : public Host{
     45  class _NetworkExport Server : public Host, public ServerConnection{
    4746  public:
    4847    Server();
    4948    Server(int port);
    5049    Server(int port, const std::string& bindAddress);
    51     Server(int port, const char *bindAddress);
    5250    ~Server();
    5351
     
    6058    double getPacketLoss(unsigned int clientID);
    6159  protected:
    62     void processQueue();
    6360    void updateGamestate();
    6461  private:
     
    6764    unsigned int playerID(){return 0;}
    6865
    69     bool addClient(ENetEvent *event);
     66    void addClient(ENetEvent *event);
    7067    bool createClient(int clientID);
    71     bool disconnectClient(ENetEvent *event);
    72     void disconnectClient(int clientID);
    7368    void disconnectClient( ClientInformation *client);
    7469    bool processPacket( ENetPacket *packet, ENetPeer *peer );
     
    7873    virtual bool broadcast(const std::string& message);
    7974    bool sendChat(const std::string& message, unsigned int clientID);
     75    void syncClassid(unsigned int clientID);
    8076
    81     //void processChat( chat *data, int clientId);
    82     ConnectionManager *connection;
    8377    GamestateManager *gamestates_;
    8478
  • code/trunk/src/network/TrafficControl.cc

    r3198 r3214  
    2929#include "TrafficControl.h"
    3030
    31 #include "synchronisable/Synchronisable.h"
     31#include <cassert>
     32#include <boost/bind.hpp>
     33
    3234#include "core/CoreIncludes.h"
    3335#include "core/ConfigValueIncludes.h"
    34 
    35 #include <cassert>
    36 #include <boost/bind.hpp>
     36#include "synchronisable/Synchronisable.h"
    3737
    3838namespace orxonox {
  • code/trunk/src/network/TrafficControl.h

    r3084 r3214  
    2525 *      ...
    2626 *
     27
    2728 */
    28 #ifndef NETWORK_TRAFFICCONTROL_H
    29 #define NETWORK_TRAFFICCONTROL_H
     29#ifndef _TrafficControl_H__
     30#define _TrafficControl_H__
    3031
    3132#include "NetworkPrereqs.h"
    3233
    33 #include <string>
    3434#include <list>
    3535#include <map>
    36 #include <utility>
    37 #include <algorithm>
    38 #include "core/OrxonoxClass.h"
    3936#include "network/ClientConnectionListener.h"
    4037
     
    143140}
    144141
    145 #endif
    146 
     142#endif /* _TrafficControl_H__ */
  • code/trunk/src/network/packet/Acknowledgement.cc

    r3198 r3214  
    2727 */
    2828
     29#include "Acknowledgement.h"
    2930
    30 #include "Acknowledgement.h"
    31 #include "network/Host.h"
     31#include "util/Debug.h"
    3232#include "network/GamestateHandler.h"
    33 #include "core/CoreIncludes.h"
    3433
    3534namespace orxonox {
  • code/trunk/src/network/packet/Acknowledgement.h

    r2662 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKACKNOLEDGEMENT_H
    29 #define NETWORKACKNOLEDGEMENT_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _Acknowledgement_H__
     30#define _Acknowledgement_H__
     31
     32#include "network/NetworkPrereqs.h"
    3233#include "Packet.h"
    3334
     35namespace orxonox {
    3436const unsigned int ACKID_NACK = 0;
    35 
    36 namespace orxonox {
    3737namespace packet {
    3838/**
     
    5656} //namespace orxonox
    5757
    58 #endif
     58#endif /* _Acknowledgement_H__ */
  • code/trunk/src/network/packet/Chat.cc

    r2773 r3214  
    2929#include "Chat.h"
    3030
    31 #include <enet/enet.h>
    32 #include <cassert>
     31#include <cstring>
     32#include <string>
    3333#include "network/Host.h"
    3434
     
    3636namespace packet {
    3737 
    38 #define   PACKET_FLAGS_CHAT ENET_PACKET_FLAG_RELIABLE
     38#define   PACKET_FLAGS_CHAT PacketFlag::Reliable
    3939#define   _PACKETID         0
    4040const int _PLAYERID     =   _PACKETID + sizeof(ENUM::Type);
     
    4242#define   _MESSAGE          _MESSAGELENGTH + sizeof(uint32_t)
    4343
    44 Chat::Chat( std::string message, unsigned int playerID )
     44Chat::Chat( const std::string& message, unsigned int playerID )
    4545 : Packet()
    4646{
  • code/trunk/src/network/packet/Chat.h

    r2171 r3214  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128
    2 #ifndef NETWORKCHAT_H
    3 #define NETWORKCHAT_H
     29#ifndef _NETWORK_Chat_H__
     30#define _NETWORK_Chat_H__
    431
    5 #include "../NetworkPrereqs.h"
    6 
    7 #include <string>
    8 #include <cstring>
    9 
     32#include "network/NetworkPrereqs.h"
    1033#include "Packet.h"
    1134
     
    1841{
    1942public:
    20   Chat( std::string message, unsigned int playerID );
     43  Chat( const std::string& message, unsigned int playerID );
    2144  Chat( uint8_t* data, unsigned int clientID );
    2245  ~Chat();
     
    3558} //namespace orxonox
    3659
    37 #endif
     60#endif /* _NETWORK_Chat_H__ */
  • code/trunk/src/network/packet/ClassID.cc

    r3084 r3214  
    2727 */
    2828
     29#include "ClassID.h"
    2930
    30 
    31 #include "ClassID.h"
    32 #include <enet/enet.h>
    33 #include "core/CoreIncludes.h"
    34 #include "core/Factory.h"
     31#include <cassert>
     32#include <cstdlib>
    3533#include <cstring>
    36 #include <string>
    37 #include <cassert>
    3834#include <map>
    3935#include <queue>
     36#include <string>
     37
     38#include "core/CoreIncludes.h"
    4039
    4140namespace orxonox {
     
    4342
    4443
    45 #define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
     44#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4645#define _PACKETID             0
    4746
  • code/trunk/src/network/packet/ClassID.h

    r2759 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKCLASSID_H
    29 #define NETWORKCLASSID_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _NETWORK_ClassID_H__
     30#define _NETWORK_ClassID_H__
    3231
    33 #include <string>
    34 
     32#include "network/NetworkPrereqs.h"
    3533#include "Packet.h"
    3634
     
    5856} //namespace orxonox
    5957
    60 #endif
     58#endif /* _NETWORK_ClassID_H__ */
  • code/trunk/src/network/packet/DeleteObjects.cc

    r2773 r3214  
    2929
    3030#include "DeleteObjects.h"
    31 #include <enet/enet.h>
     31
     32#include <cassert>
     33#include "util/Debug.h"
    3234#include "network/synchronisable/Synchronisable.h"
    33 #include "core/CoreIncludes.h"
    34 #include <cassert>
    3535
    3636namespace orxonox {
    3737namespace packet {
    3838
    39 #define PACKET_FLAG_DELETE  ENET_PACKET_FLAG_RELIABLE
     39#define PACKET_FLAG_DELETE  PacketFlag::Reliable
    4040#define _PACKETID           0
    4141#define _QUANTITY           _PACKETID + sizeof(ENUM::Type)
     
    9090    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
    9191  }
     92  delete this;
    9293  return true;
    9394}
  • code/trunk/src/network/packet/DeleteObjects.h

    r2171 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKPACKETDELETEOBJECTS_H
    29 #define NETWORKPACKETDELETEOBJECTS_H
     28#ifndef _DeleteObjects_H__
     29#define _DeleteObjects_H__
    3030
    31 #include "../NetworkPrereqs.h"
    32 
     31#include "network/NetworkPrereqs.h"
    3332#include "Packet.h"
    34 
    3533
    3634namespace orxonox {
     
    5755} //namespace orxonox
    5856
    59 #endif
     57#endif /* _DeleteObjects_H__ */
  • code/trunk/src/network/packet/FunctionCalls.cc

    r3084 r3214  
    2929#include "FunctionCalls.h"
    3030
    31 #include <enet/enet.h>
    3231#include <cassert>
    3332#include <cstring>
    34 #include "network/Host.h"
     33#include "util/MultiType.h"
    3534#include "network/NetworkFunction.h"
    36 #include "util/MultiType.h"
    3735
    3836namespace orxonox {
    3937namespace packet {
    4038 
    41 #define   PACKET_FLAGS_FUNCTIONCALLS ENET_PACKET_FLAG_RELIABLE
     39#define   PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable
    4240#define   _PACKETID         0
    4341const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
  • code/trunk/src/network/packet/FunctionCalls.h

    r3084 r3214  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128
    2 #ifndef NETWORKFUNCTIONCALLS_H
    3 #define NETWORKFUNCTIONCALLS_H
     29#ifndef _FunctionCalls_H__
     30#define _FunctionCalls_H__
    431
    5 #include "../NetworkPrereqs.h"
     32#include "network/NetworkPrereqs.h"
    633
    7 #include <string>
    8 #include <cstring>
    9 
     34#include <cassert>
     35#include "util/UtilPrereqs.h"
    1036#include "Packet.h"
    11 #include <cassert>
    1237
    1338namespace orxonox {
    14 
    15 class MultiType;
    1639
    1740namespace packet {
     
    4467} //namespace orxonox
    4568
    46 #endif
     69#endif /* _FunctionCalls_H__ */
  • code/trunk/src/network/packet/FunctionIDs.cc

    r3084 r3214  
    2727 */
    2828
     29#include "FunctionIDs.h"
    2930
     31#include <cassert>
     32#include <cstring>
     33#include <queue>
     34#include <string>
    3035
    31 #include "FunctionIDs.h"
     36#include "util/Debug.h"
     37#include "core/ObjectList.h"
    3238#include "network/NetworkFunction.h"
    33 #include <enet/enet.h>
    34 #include "core/CoreIncludes.h"
    35 #include <string>
    36 #include <cassert>
    37 #include <queue>
    3839
    3940namespace orxonox {
     
    4142
    4243
    43 #define PACKET_FLAGS_FUNCTIONIDS  ENET_PACKET_FLAG_RELIABLE
     44#define PACKET_FLAGS_FUNCTIONIDS  PacketFlag::Reliable
    4445#define _PACKETID                 0
    4546
  • code/trunk/src/network/packet/FunctionIDs.h

    r3084 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKFUNCTIONIDS_H
    29 #define NETWORKFUNCTIONIDS_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _FunctionIDs_H__
     30#define _FunctionIDs_H__
    3231
    33 #include <string>
    34 
     32#include "network/NetworkPrereqs.h"
    3533#include "Packet.h"
    3634
     
    5856} //namespace orxonox
    5957
    60 #endif
     58#endif /* _FunctionIDs_H__ */
  • code/trunk/src/network/packet/Gamestate.cc

    r3198 r3214  
    2828
    2929#include "Gamestate.h"
    30 #include <enet/enet.h>
     30
    3131#include <zlib.h>
    32 #include <cassert>
    33 #include "../GamestateHandler.h"
    34 #include "../synchronisable/Synchronisable.h"
    35 #include "../TrafficControl.h"
     32
     33#include "util/Debug.h"
    3634#include "core/GameMode.h"
    37 #include "core/CoreIncludes.h"
    38 
    39 
    40 
     35#include "core/ObjectList.h"
     36#include "network/synchronisable/Synchronisable.h"
     37#include "network/GamestateHandler.h"
    4138
    4239namespace orxonox {
     
    4643#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
    4744
    48 #define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
     45#define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
    4946
    5047
  • code/trunk/src/network/packet/Gamestate.h

    r3198 r3214  
    2828
    2929
    30 #ifndef NETWORK_PACKETGAMESTATE_H
    31 #define NETWORK_PACKETGAMESTATE_H
     30#ifndef _Gamestate_H__
     31#define _Gamestate_H__
    3232
    3333#include "network/NetworkPrereqs.h"
    3434
     35#include <cassert>
     36#include <cstring>
     37#include <list>
     38
     39#include "util/CRC32.h"
     40#include "network/TrafficControl.h"
    3541#include "Packet.h"
    36 #include "network/TrafficControl.h"
    37 #include <string.h>
    38 #include <map>
    39 #include <vector>
    40 #include <cassert>
    41 #ifndef NDEBUG
    42 #include "util/CRC32.h"
    43 #endif
    4442
    4543namespace orxonox {
     
    138136}
    139137
    140 #endif
     138#endif /* _Gamestate_H__ */
  • code/trunk/src/network/packet/Packet.cc

    r3097 r3214  
    3131
    3232#include <cassert>
     33#include <cstring>
    3334#include <enet/enet.h>
    34 #include <boost/bind.hpp>
    35 #include <boost/thread/recursive_mutex.hpp>
    36 
    37 #include "network/ConnectionManager.h"
    38 #include "network/ClientInformation.h"
    39 
     35#include <boost/static_assert.hpp>
     36
     37#include "util/Debug.h"
    4038#include "Acknowledgement.h"
    41 #include "DeleteObjects.h"
    4239#include "Chat.h"
    4340#include "ClassID.h"
     41#include "DeleteObjects.h"
    4442#include "FunctionCalls.h"
    4543#include "FunctionIDs.h"
     
    4745#include "Welcome.h"
    4846#include "network/Host.h"
    49 #include "core/CoreIncludes.h"
     47#include "network/ClientInformation.h"
    5048
    5149namespace orxonox{
     
    5351namespace packet{
    5452
    55 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
     53// Make sure we assume the right values
     54BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)   == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
     55BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
     56BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
     57
     58#define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
    5659#define _PACKETID           0
    5760
    5861std::map<size_t, Packet *> Packet::packetMap_;
    59 //! Static mutex for any packetMap_ access
    60 static boost::recursive_mutex packetMap_mutex_g;
    6162
    6263Packet::Packet(){
     
    108109  }
    109110  else if (this->data_) {
    110     // This destructor was probably called as a consequence to ENet executing our callback.
     111    // This destructor was probably called as a consequence of ENet executing our callback.
    111112    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
    112113    // we have created it in the first place.
     
    142143      // Assures we don't create a packet and destroy it right after in another thread
    143144      // without having a reference in the packetMap_
    144       boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    145145      packetMap_[(size_t)(void*)enetPacket_] = this;
    146146    }
     
    218218  // Data was created by ENet
    219219  p->bDataENetAllocated_ = true;
     220  p->enetPacket_ = packet;
    220221
    221222  return p;
     
    228229*/
    229230void Packet::deletePacket(ENetPacket *enetPacket){
    230   boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    231231  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
    232232  std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
     
    236236  delete it->second;
    237237  packetMap_.erase(it);
    238   COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl;
     238  COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
    239239}
    240240
  • code/trunk/src/network/packet/Packet.h

    r3084 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKPACKET_H
    29 #define NETWORKPACKET_H
     28#ifndef _NETWORK_Packet_H__
     29#define _NETWORK_Packet_H__
    3030
    3131#include "network/NetworkPrereqs.h"
    32 
    3332#include <map>
    3433
     
    102101} //namespace orxonox
    103102
    104 #endif
     103#endif /* _NETWORK_Packet_H__ */
  • code/trunk/src/network/packet/Welcome.cc

    r2773 r3214  
    2929 */
    3030
     31#include "Welcome.h"
    3132
    32 #include "Welcome.h"
    33 #include <enet/enet.h>
    3433#include <cassert>
     34#include "util/Debug.h"
    3535#include "network/Host.h"
    3636#include "network/synchronisable/Synchronisable.h"
    37 #include "core/CoreIncludes.h"
    3837
    3938namespace orxonox {
    4039namespace packet {
    4140
    42 #define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
     41#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4342#define _PACKETID             0
    4443#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
  • code/trunk/src/network/packet/Welcome.h

    r2662 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKWELCOME_H
    29 #define NETWORKWELCOME_H
     28#ifndef _NETWORK_Welcome_H__
     29#define _NETWORK_Welcome_H__
    3030
    31 #include "../NetworkPrereqs.h"
    32 
     31#include "network/NetworkPrereqs.h"
    3332#include "Packet.h"
    3433
     
    5655} //namespace orxonox
    5756
    58 #endif
     57#endif /* _NETWORK_Welcome_H__ */
  • code/trunk/src/network/synchronisable/NetworkCallback.h

    r3068 r3214  
    2828
    2929
    30 #ifndef _NETWORK_CALLBACK__
    31 #define _NETWORK_CALLBACK__
     30#ifndef _NetworkCallback_H__
     31#define _NetworkCallback_H__
    3232
    3333#include "network/NetworkPrereqs.h"
     
    6161
    6262
    63 #endif
     63#endif /* _NetworkCallback_H__ */
  • code/trunk/src/network/synchronisable/NetworkCallbackManager.cc

    r3084 r3214  
    2727 */
    2828 
    29 
    3029#include "NetworkCallbackManager.h"
    3130#include "NetworkCallback.h"
  • code/trunk/src/network/synchronisable/NetworkCallbackManager.h

    r2662 r3214  
    2828
    2929
    30 #ifndef _NETWORK_CALLBACKMANAGER__
    31 #define _NETWORK_CALLBACKMANAGER__
     30#ifndef _NetworkCallbackManager_H__
     31#define _NetworkCallbackManager_H__
    3232
    3333#include "network/NetworkPrereqs.h"
     34
    3435#include <set>
    3536#include <queue>
     
    5253
    5354
    54 #endif
     55#endif /* _NetworkCallbackManager_H__ */
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r3198 r3214  
    3131#include "Synchronisable.h"
    3232
    33 #include <cstring>
    34 #include <string>
    35 #include <iostream>
    36 #include <cassert>
    37 
     33#include <cstdlib>
    3834#include "core/CoreIncludes.h"
    3935#include "core/BaseObject.h"
    40 // #include "core/Identifier.h"
    41 
    4236#include "network/Host.h"
     37
    4338namespace orxonox
    4439{
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r3084 r3214  
    3232#include "network/NetworkPrereqs.h"
    3333
    34 #include <list>
     34#include <cassert>
     35#include <cstring>
    3536#include <vector>
    3637#include <map>
    3738#include <queue>
    38 #include <cassert>
    39 #include <string>
    40 #include "util/Math.h"
     39
    4140#include "util/mbool.h"
    4241#include "core/OrxonoxClass.h"
     42#include "SynchronisableVariable.h"
    4343#include "NetworkCallback.h"
    44 #include "SynchronisableVariable.h"
    4544
    4645/*#define REGISTERDATA(varname, ...) \
  • code/trunk/src/network/synchronisable/SynchronisableSpecialisations.cc

    r3084 r3214  
    2828 */
    2929
    30 #include "network/synchronisable/Synchronisable.h"
    3130#include <string>
     31#include "util/Math.h"
     32#include "Synchronisable.h"
     33#include "SynchronisableVariable.h"
    3234
    3335// ================ template spezialisation
  • code/trunk/src/network/synchronisable/SynchronisableVariable.cc

    r3084 r3214  
    2929#include "SynchronisableVariable.h"
    3030
    31 
    3231namespace orxonox{
    3332
  • code/trunk/src/network/synchronisable/SynchronisableVariable.h

    r3102 r3214  
    2828
    2929
    30 #ifndef _NETWORK_SYNCHRONISABLEVARIABLE__
    31 #define _NETWORK_SYNCHRONISABLEVARIABLE__
     30#ifndef _SynchronisableVariable_H__
     31#define _SynchronisableVariable_H__
    3232
    3333#include "network/NetworkPrereqs.h"
    3434
    35 #include <string>
    3635#include <cassert>
     36#include <cstring>
    3737#include "util/Serialise.h"
    38 #include "core/Core.h"
    39 #include "core/CoreIncludes.h"
    4038#include "core/GameMode.h"
    41 #include "network/synchronisable/NetworkCallback.h"
    4239#include "network/synchronisable/NetworkCallbackManager.h"
    4340
     
    253250
    254251
    255 #endif
     252#endif /* _SynchronisableVariable_H__ */
  • code/trunk/src/orxonox/OrxonoxPrecompiledHeaders.h

    r3196 r3214  
    3535#include "OrxonoxPrereqs.h"
    3636
     37#include <cassert>
    3738#include <deque>
    3839#include <fstream>
     
    8485#include "util/Math.h"
    8586#include "util/OgreForwardRefs.h"
    86 #include "util/OrxAssert.h"
    87 #include "util/String.h"
    8887#include "util/SubString.h"
    8988
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r3196 r3214  
    5959        PawnManager::touch();
    6060        this->bAlive_ = true;
    61         this->fire_ = 0x0;
    62         this->firehack_ = 0x0;
    6361        this->bReload_ = false;
    6462
     
    122120        registerVariable(this->health_,        variableDirection::toclient);
    123121        registerVariable(this->initialHealth_, variableDirection::toclient);
    124         registerVariable(this->fire_,          variableDirection::toserver);
    125122        registerVariable(this->bReload_,       variableDirection::toserver);
    126123    }
     
    130127        SUPER(Pawn, tick, dt);
    131128
    132 //        if (this->weaponSystem_ && GameMode::isMaster())
    133 //        {
    134 //            for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
    135 //                if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
    136 //                    this->weaponSystem_->fire(firemode);
    137 //
    138 //            if (this->bReload_)
    139 //                this->weaponSystem_->reload();
    140 //        }
    141 //
    142 //        this->fire_ = this->firehack_;
    143 //        this->firehack_ = 0x0;
    144129        this->bReload_ = false;
    145130
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r3196 r3214  
    137137
    138138            WeaponSystem* weaponSystem_;
    139             unsigned int fire_;
    140             unsigned int firehack_;
    141139            bool bReload_;
    142140
  • code/trunk/src/util/Clipboard.cc

    r3196 r3214  
    4242/////////////
    4343
     44#ifndef WIN32_LEAN_AND_MEAN
     45#  define WIN32_LEAN_AND_MEAN
     46#endif
    4447#include <windows.h>
     48#undef min
     49#undef max
    4550#include "Debug.h"
    4651
  • code/trunk/src/util/Math.h

    r3196 r3214  
    4747#include <OgreColourValue.h>
    4848
    49 // Certain headers might define min and max macros
    50 #if defined(max) || defined(min) || defined(sgn) || defined(clamp) || defined(square) || defined(mod)
    51 #  error An inline math function was overridden by a macro
    52 #endif
     49// Certain headers might define unwanted macros...
     50#undef max
     51#undef min
     52#undef sgn
     53#undef clamp
     54#undef sqrt
     55#undef square
     56#undef mod
     57#undef rnd
    5358
    5459namespace orxonox
  • code/trunk/src/util/Sleep.cc

    r3196 r3214  
    3737
    3838#ifdef ORXONOX_PLATFORM_WINDOWS
     39#ifndef WIN32_LEAN_AND_MEAN
     40#  define WIN32_LEAN_AND_MEAN
     41#endif
    3942#include <windows.h>
     43#undef min
     44#undef max
    4045
    4146namespace orxonox
Note: See TracChangeset for help on using the changeset viewer.