Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2008, 12:20:14 AM (16 years ago)
Author:
landauf
Message:

removed WorldEntity, SpaceShip and several other objects
removed SpaceShip-related hacks in network and other places

Location:
code/branches/objecthierarchy/src/network
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/CMakeLists.txt

    r1907 r1916  
    2121
    2222IF(WIN32)
    23   ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
     23  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
    2424ELSE(WIN32)
    2525  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
  • code/branches/objecthierarchy/src/network/ClientConnection.h

    r1907 r1916  
    6060
    6161
    62   class ClientConnection{
     62  class _NetworkExport ClientConnection{
    6363  public:
    6464    ClientConnection(int port, std::string address);
     
    9696    ENetPeer *server;
    9797    boost::thread *receiverThread_;
    98    
     98
    9999    static boost::recursive_mutex enet_mutex_;
    100100  };
  • code/branches/objecthierarchy/src/network/ClientInformation.h

    r1735 r1916  
    5757  * @author Oliver Scheuss
    5858  */
    59   class ClientInformation{
     59  class _NetworkExport ClientInformation{
    6060  public:
    6161    ClientInformation();
     
    6666    ClientInformation *prev();
    6767    static ClientInformation *insertBack(ClientInformation *ins);
    68    
     68
    6969    // set functions
    7070    void setID(int clientID);
     
    7373    bool setPartialGamestateID(int id);
    7474    inline void setShipID(unsigned int id){ShipID_=id;}
    75    
     75
    7676    // get functions
    7777    inline unsigned int getShipID(){return ShipID_;}
     
    8080    int getPartialGamestateID();
    8181    ENetPeer *getPeer();
    82    
     82
    8383    int getFailures();
    8484    void addFailure();
     
    8686    enet_uint32 getRTT();
    8787    enet_uint32 getPacketLoss();
    88    
     88
    8989    static bool removeClient(int clientID);
    9090    static bool removeClient(ENetPeer *peer);
     
    9999  private:
    100100    static ClientInformation *head_;
    101    
     101
    102102    bool setNext(ClientInformation *next);
    103103    bool setPrev(ClientInformation *prev);
    104104    ClientInformation *insertAfter(ClientInformation *ins);
    105105    ClientInformation *insertBefore(ClientInformation *ins);
    106    
     106
    107107    ClientInformation *preve;
    108108    ClientInformation *nexte;
     
    115115    bool synched_;
    116116    unsigned short failures_;
    117    
     117
    118118  };
    119119
  • code/branches/objecthierarchy/src/network/ConnectionManager.cc

    r1907 r1916  
    4949#include "core/BaseObject.h"
    5050#include "core/Iterator.h"
    51 #include "objects/SpaceShip.h"
    5251#include "util/Math.h"
    5352#include "util/Sleep.h"
     
    331330
    332331
    333 
    334   bool ConnectionManager::removeShip(ClientInformation *client){
    335     unsigned int id=client->getShipID();
    336     orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
    337     for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    338       if(it->getObjectID()!=id)
    339         continue;
    340       delete *it;
    341     }
    342     return true;
    343   }
    344 
    345 
    346332  void ConnectionManager::disconnectClient(ClientInformation *client){
    347333    {
     
    350336      lock.unlock();
    351337    }
    352     removeShip(client);
    353338  }
    354339
  • code/branches/objecthierarchy/src/network/ConnectionManager.h

    r1785 r1916  
    6666    const int NETWORK_DEFAULT_CHANNEL = 0;
    6767
    68   struct ClientList{
     68  struct _NetworkExport ClientList{
    6969    ENetEvent *event;
    7070    int ID;
     
    7272  };
    7373
    74   class ConnectionManager{
     74  class _NetworkExport ConnectionManager{
    7575    public:
    7676    static boost::recursive_mutex enet_mutex;
     
    107107    int getClientID(ENetAddress address);
    108108    ENetPeer *getClientPeer(int clientID);
    109     //bool createShip(ClientInformation *client);
    110     bool removeShip(ClientInformation *client);
    111109    PacketBuffer buffer;
    112110
  • code/branches/objecthierarchy/src/network/GamestateClient.cc

    r1907 r1916  
    4040namespace network
    4141{
    42   struct GameStateItem{
     42  struct _NetworkExport GameStateItem{
    4343    packet::Gamestate *state;
    4444    int id;
     
    5050    last_gamestate_=GAMESTATEID_INITIAL-1;
    5151    tempGamestate_=NULL;
    52     myShip_=NULL;
    5352  }
    5453
     
    7574      return false;
    7675    int id = GAMESTATEID_INITIAL;
    77     bool b = saveShipCache();
    7876    packet::Gamestate *processed = processGamestate(tempGamestate_);
    79     if(!processed){
    80       if(b)
    81         loadShipCache();
    82       return false;
    83     }
    8477//    assert(processed);
    8578    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
     
    8780    gamestateMap_[processed->getID()]=processed;
    8881    last_diff_ = processed->getID();
    89     if(b)
    90       loadShipCache();
    9182    id = processed->getID();
    9283    sendAck(id);
     
    134125
    135126  }
    136  
     127
    137128  bool GamestateClient::sendAck(unsigned int gamestateID){
    138129    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
     
    145136      return true;
    146137    }
    147   }
    148 
    149   bool GamestateClient::saveShipCache(){
    150     if(myShip_==NULL){
    151       myShip_ = orxonox::SpaceShip::getLocalShip();
    152 //      COUT(2) << "myShip_: " << myShip_ << " getLocalShip(): " << orxonox::SpaceShip::getLocalShip() << std::endl;
    153       if(!myShip_)
    154         return false;
    155     }
    156     if(myShip_){
    157       //      unsigned char *data = new unsigned char[myShip_->getSize()];
    158       int size=myShip_->getSize(0, 0x1);
    159       if(size==0)
    160         return false;
    161       shipCache_ = new unsigned char [size];
    162       unsigned char *temp = shipCache_;
    163       if(!myShip_->getData(temp, 0, 0x1))
    164         COUT(3) << "could not save shipCache" << std::endl;
    165       return true;
    166     }else
    167       return false;
    168   }
    169 
    170   bool GamestateClient::loadShipCache(){
    171     myShip_=orxonox::SpaceShip::getLocalShip(); //TODO: remove this (only a hack)
    172     if(myShip_ && shipCache_){
    173       assert(myShip_->getIdentifier());
    174       unsigned char *temp = shipCache_;
    175       myShip_->updateData(temp, 0x2);
    176       delete shipCache_;
    177       return true;
    178     }else
    179       return false;
    180138  }
    181139
  • code/branches/objecthierarchy/src/network/GamestateClient.h

    r1769 r1916  
    4646#include "core/CorePrereqs.h"
    4747#include "packet/Gamestate.h"
    48 #include "objects/SpaceShip.h"
    4948#include "GamestateHandler.h"
    5049
     
    5352namespace network
    5453{
    55   class GamestateClient: public GamestateHandler
     54  class _NetworkExport GamestateClient: public GamestateHandler
    5655  {
    5756  public:
     
    7069    void printGamestateMap();
    7170    bool sendAck(unsigned int gamestateID);
    72     bool saveShipCache();
    73     bool loadShipCache();
    7471
    7572    int           last_diff_;
     
    7774    std::map<int, packet::Gamestate *> gamestateMap_;
    7875    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
    79     orxonox::SpaceShip *myShip_;
    8076    unsigned char *shipCache_;
    8177
  • code/branches/objecthierarchy/src/network/GamestateHandler.h

    r1763 r1916  
    3939        @author Oliver Scheuss
    4040*/
    41 class GamestateHandler{
     41class _NetworkExport GamestateHandler{
    4242  private:
    4343    virtual bool add(packet::Gamestate *gs, int clientID)=0;
  • code/branches/objecthierarchy/src/network/GamestateManager.h

    r1907 r1916  
    6666  * @author Oliver Scheuss
    6767  */
    68   class GamestateManager: public GamestateHandler{
     68  class _NetworkExport GamestateManager: public GamestateHandler{
    6969  public:
    7070    GamestateManager();
  • code/branches/objecthierarchy/src/network/Host.h

    r1907 r1916  
    4444*       @author Oliver Scheuss
    4545*/
    46 class Host{
     46class _NetworkExport Host{
    4747  private:
    4848    //TODO add theese functions or adequate
     
    7272    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
    7373    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
    74     static bool isServer(){ return instance_->isServer_(); }           
     74    static bool isServer(){ return instance_->isServer_(); }
    7575    static bool Chat(std::string message);
    7676    static bool incomingChat(std::string message, unsigned int playerID);
  • code/branches/objecthierarchy/src/network/NetworkCallback.h

    r1536 r1916  
    22#define _NETWORK_CALLBACK__
    33
     4#include "NetworkPrereqs.h"
     5
    46namespace network{
    5   class NetworkCallbackBase
     7  class _NetworkExport NetworkCallbackBase
    68  {
    79    public:
     
    911          virtual ~NetworkCallbackBase() {}
    1012  };
    11  
     13
    1214  template <class T>
    13   class NetworkCallback: public NetworkCallbackBase
     15  class _NetworkExport NetworkCallback: public NetworkCallbackBase
    1416  {
    1517    public:
     
    1820      virtual void call()
    1921        { (this->object_->*function_)(); }
    20  
     22
    2123    private:
    2224      T* object_;
    2325      void (T::*function_) (void);
    24   }; 
     26  };
    2527
    2628
  • code/branches/objecthierarchy/src/network/PacketBuffer.h

    r1505 r1916  
    4949namespace network
    5050{
    51   struct PacketEnvelope{
     51  struct _NetworkExport PacketEnvelope{
    5252    int length;
    5353    int data;
    5454  };
    5555
    56   struct QueueItem{
     56  struct _NetworkExport QueueItem{
    5757    ENetEvent *event;
    5858    //ENetAddress address;
     
    6060  };
    6161
    62   class PacketBuffer{
     62  class _NetworkExport PacketBuffer{
    6363  public:
    6464    PacketBuffer();
  • code/branches/objecthierarchy/src/network/Server.cc

    r1907 r1916  
    4949#include "ClientInformation.h"
    5050#include "util/Sleep.h"
    51 #include "objects/SpaceShip.h"
    5251#include "core/ConsoleCommand.h"
    5352#include "core/CoreIncludes.h"
     
    101100    gamestates_ = new GamestateManager();
    102101  }
    103  
     102
    104103  /**
    105104  * @brief Destructor
     
    304303    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
    305304    connection->syncClassid(temp->getID());
    306     COUT(5) << "creating spaceship for clientid: " << temp->getID() << std::endl;
    307     // TODO: this is only a hack, untill we have a possibility to define default player-join actions
    308     if(!createShip(temp))
    309       COUT(2) << "Con.Man. could not create ship for clientid: " << clientID << std::endl;
    310     else
    311       COUT(3) << "created spaceship" << std::endl;
    312305    temp->setSynched(true);
    313306    COUT(3) << "sending welcome" << std::endl;
     
    327320  }
    328321
    329   bool Server::createShip(ClientInformation *client){
    330     if(!client)
    331       return false;
    332     orxonox::Identifier* id = ClassByName("SpaceShip");
    333     if(!id){
    334       COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;
    335       return false;
    336     }
    337     orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());
    338     no->classID = id->getNetworkID();
    339     client->setShipID(no->getObjectID());
    340     no->setPosition(orxonox::Vector3(0,0,80));
    341     no->setScale(10);
    342     //no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0));
    343     no->setMesh("assff.mesh");
    344     no->setMaxSpeed(500);
    345     no->setMaxSideAndBackSpeed(50);
    346     no->setMaxRotation(1.0);
    347     no->setTransAcc(200);
    348     no->setRotAcc(3.0);
    349     no->setTransDamp(75);
    350     no->setRotDamp(1.0);
    351     no->setCamera(std::string("cam_") + convertToString(client->getID()));
    352     no->create();
    353 
    354     return true;
    355   }
    356 
    357322  bool Server::disconnectClient(ENetEvent *event){
    358323    COUT(4) << "removing client from list" << std::endl;
     
    360325
    361326    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    362     orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    363327    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    364328    if(!client)
    365329      return false;
    366330    gamestates_->removeClient(client);
    367     while(it){
    368       if(it->getObjectID()!=client->getShipID()){
    369         ++it;
    370         continue;
    371       }
    372       orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
    373       ++it;
    374       delete  *temp;
    375       return ClientInformation::removeClient(event->peer);
    376     }
    377     return false;
     331    return ClientInformation::removeClient(event->peer);
    378332  }
    379333
     
    387341    gamestates_->removeClient(client);
    388342  }
    389  
     343
    390344  bool Server::chat(std::string message){
    391345    ClientInformation *temp = ClientInformation::getBegin();
  • code/branches/objecthierarchy/src/network/Server.h

    r1907 r1916  
    5252{
    5353  const int CLIENTID_SERVER = 0;
    54  
     54
    5555  /**
    5656  * This class is the root class of the network module for a server.
     
    6464    Server(int port, const char *bindAddress);
    6565    ~Server();
    66    
     66
    6767    void open();
    6868    void close();
     
    7777    unsigned int shipID(){return 0;}
    7878    unsigned int playerID(){return 0;}
    79    
     79
    8080    bool addClient(ENetEvent *event);
    8181    bool createClient(int clientID);
    82     bool createShip(ClientInformation *client);
    8382    bool disconnectClient(ENetEvent *event);
    8483    void disconnectClient(int clientID);
     
    8887    bool sendObjectDeletes();
    8988    virtual bool chat(std::string message);
    90    
     89
    9190    //void processChat( chat *data, int clientId);
    9291    ConnectionManager *connection;
    9392    GamestateManager *gamestates_;
    9493
    95    
     94
    9695    float timeSinceLastUpdate_;
    9796  };
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r1910 r1916  
    4646#define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)
    4747
    48 //TODO: this is only a very ugly hack ...
    49 namespace orxonox{
    50 class SpaceShip;
    51 }
    52 
    5348namespace network
    5449{
     
    6055    };
    6156  }
    62  
     57
    6358  namespace syncmode{
    6459    enum mode{
     
    6762    };
    6863  }
    69  
     64
    7065  enum variableType{
    7166    DATA,
     
    7368  };
    7469
    75   struct synchronisableHeader{
     70  struct _NetworkExport synchronisableHeader{
    7671    uint32_t size:31;
    7772    bool dataAvailable:1;
     
    8075  };
    8176
    82   typedef struct synchronisableVariable{
     77  typedef struct _NetworkExport synchronisableVariable{
    8378    unsigned int size;
    8479    int mode; // this determines in which direction the variable gets synchronised
     
    9893    friend class GamestateClient;
    9994    friend class Server;
    100     friend class orxonox::SpaceShip;
    10195    virtual ~Synchronisable();
    10296
    103    
     97
    10498    virtual bool create();
    10599    static void setClient(bool b);
    106    
     100
    107101    static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);
    108102    static bool deleteObject(unsigned int objectID);
     
    110104    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
    111105    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    112    
     106
    113107    inline unsigned int getObjectID(){return objectID;}
    114108    inline unsigned int getClassID(){return classID;}
     
    119113    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
    120114    virtual void registerAllVariables()=0;
    121    
    122    
     115
     116
    123117  private:
    124118    bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
     
    128122    bool doSelection(unsigned int id);
    129123    bool isMyTick(unsigned int id);
    130    
     124
    131125    unsigned int objectID;
    132126    unsigned int classID;
    133    
     127
    134128    std::list<synchronisableVariable *> *syncList;
    135129    static int state_; // detemines wheter we are server (default) or client
  • code/branches/objecthierarchy/src/network/packet/Acknowledgement.h

    r1907 r1916  
    2929#define NETWORKACKNOLEDGEMENT_H
    3030
     31#include "../NetworkPrereqs.h"
    3132#include "Packet.h"
    3233
     
    3536namespace packet {
    3637/**
    37         @author 
     38        @author
    3839*/
    39 class Acknowledgement : public Packet
     40class _NetworkExport Acknowledgement : public Packet
    4041{
    4142public:
     
    4344  Acknowledgement( uint8_t* data, unsigned int clientID );
    4445  ~Acknowledgement();
    45  
     46
    4647  inline unsigned int getSize() const;
    4748  bool process();
    48  
     49
    4950  unsigned int getAckID();
    5051private:
  • code/branches/objecthierarchy/src/network/packet/Chat.h

    r1907 r1916  
    22#ifndef NETWORKCHAT_H
    33#define NETWORKCHAT_H
     4
     5#include "../NetworkPrereqs.h"
    46
    57#include <string>
     
    1113namespace packet {
    1214/**
    13         @author 
     15        @author
    1416*/
    15 class Chat : public Packet
     17class _NetworkExport Chat : public Packet
    1618{
    1719public:
     
    1921  Chat( uint8_t* data, unsigned int clientID );
    2022  ~Chat();
    21  
     23
    2224  inline unsigned int getSize() const;
    2325  bool process();
    24  
     26
    2527  unsigned int getMessageLength(){ return messageLength_; };
    2628  unsigned char *getMessage();
  • code/branches/objecthierarchy/src/network/packet/ClassID.h

    r1907 r1916  
    2929#define NETWORKCLASSID_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include <string>
    3234
     
    3739
    3840/**
    39         @author 
     41        @author
    4042*/
    41 class ClassID : public Packet
     43class _NetworkExport ClassID : public Packet
    4244{
    4345public:
     
    4547  ClassID( uint8_t* data, unsigned int clientID );
    4648  ~ClassID();
    47  
     49
    4850  inline unsigned int getSize() const;
    4951  bool process();
    50  
     52
    5153  unsigned int getClassID();
    5254  unsigned int getClassNameLength(){ return classNameLength_; }
  • code/branches/objecthierarchy/src/network/packet/DeleteObjects.h

    r1907 r1916  
    2929#define NETWORKPACKETDELETEOBJECTS_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include "Packet.h"
    3234
     
    3537namespace packet {
    3638/**
    37         @author 
     39        @author
    3840*/
    39 class DeleteObjects : public Packet
     41class _NetworkExport DeleteObjects : public Packet
    4042{
    4143public:
     
    4345  DeleteObjects( uint8_t* data, unsigned int clientID );
    4446  ~DeleteObjects();
    45  
     47
    4648  bool fetchIDs();
    47  
     49
    4850  inline unsigned int getSize() const;
    4951  bool process();
    50  
     52
    5153private:
    5254};
  • code/branches/objecthierarchy/src/network/packet/Gamestate.h

    r1907 r1916  
    2727 */
    2828
     29
     30#ifndef NETWORK_PACKETGAMESTATE_H
     31#define NETWORK_PACKETGAMESTATE_H
     32
     33#include "../NetworkPrereqs.h"
     34
    2935#include "Packet.h"
    3036#include "network/Synchronisable.h"
     
    3440#endif
    3541
    36 
    37 #ifndef NETWORK_PACKETGAMESTATE_H
    38 #define NETWORK_PACKETGAMESTATE_H
    39 
    4042namespace network {
    4143
    4244namespace packet {
    4345
    44 struct GamestateHeader{
     46struct _NetworkExport GamestateHeader{
    4547  ENUM::Type packetType;
    4648  int32_t id; // id of the gamestate
     
    5961        @author Oliver Scheuss
    6062*/
    61 class Gamestate: public Packet{
     63class _NetworkExport Gamestate: public Packet{
    6264  public:
    6365    Gamestate();
  • code/branches/objecthierarchy/src/network/packet/Packet.h

    r1907 r1916  
    2929#define NETWORKPACKET_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include <map>
    3234#include <enet/enet.h>
     
    3739
    3840namespace packet{
    39  
     41
    4042namespace ENUM{
    4143  enum Direction{
     
    5355  };
    5456}
    55  
     57
    5658/**
    5759        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
    5860*/
    59 class Packet{
     61class _NetworkExport Packet{
    6062  public:
    6163    Packet(const Packet &p);
     
    6365    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
    6466    static void deletePacket(ENetPacket *packet);
    65    
     67
    6668    virtual unsigned char *getData(){ return data_; };
    6769    virtual unsigned int getSize() const =0;
     
    7375    void setClientID( int id )
    7476      { clientID_ = id; }
    75    
     77
    7678    bool send();
    7779  protected:
  • code/branches/objecthierarchy/src/network/packet/Welcome.h

    r1907 r1916  
    2929#define NETWORKWELCOME_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include "Packet.h"
    3234
     
    3537
    3638/**
    37         @author 
     39        @author
    3840*/
    39 class Welcome : public Packet
     41class _NetworkExport Welcome : public Packet
    4042{
    4143public:
     
    4345  Welcome( uint8_t* data, unsigned int clientID );
    4446  virtual ~Welcome();
    45  
     47
    4648  uint8_t *getData();
    4749  inline unsigned int getSize() const;
    4850  bool process();
    49  
     51
    5052private:
    5153};
Note: See TracChangeset for help on using the changeset viewer.