Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 18, 2008, 10:58:46 PM (16 years ago)
Author:
landauf
Message:

did some first (and very unfinished) steps to deal with different players on server and client

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

Legend:

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

    r1938 r1940  
    2222
    2323IF(WIN32)
    24   ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
     24  ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
    2525ELSE(WIN32)
    2626  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
  • code/branches/objecthierarchy/src/network/ClientConnectionListener.h

    r1939 r1940  
    88namespace network{
    99
    10   class _NetworkExport ClientConnectionListener : public orxonox::OrxonoxClass
     10  class _NetworkExport ClientConnectionListener : virtual public orxonox::OrxonoxClass
    1111  {
     12    friend class Server;
     13
    1214  public:
    1315    ClientConnectionListener();
     16    virtual ~ClientConnectionListener() {}
    1417
    1518    void getConnectedClients();
    1619
     20  protected:
    1721    virtual void clientConnected(unsigned int clientID) = 0;
    1822    virtual void clientDisconnected(unsigned int clientID) = 0;
  • code/branches/objecthierarchy/src/network/GamestateClient.cc

    r1917 r1940  
    7777    packet::Gamestate *processed = processGamestate(tempGamestate_);
    7878//    assert(processed);
     79    if (!processed)
     80        return false;
    7981    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
    8082    tempGamestate_=NULL;
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r1907 r1940  
    5151namespace network
    5252{
    53  
     53
    5454
    5555  std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
     
    6868    objectMode_=0x1; // by default do not send data to server
    6969    objectID=idCounter++;
     70    classID = (unsigned int)-1;
    7071    syncList = new std::list<synchronisableVariable *>;
    7172  }
    7273
    7374  /**
    74    * Destructor: 
     75   * Destructor:
    7576   * Delete all callback objects and remove objectID from the objectMap_
    7677   */
     
    9697    this->classID = this->getIdentifier()->getNetworkID();
    9798//     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
    98    
     99
    99100//     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
    100101//     objectMap_[objectID]=this;
     
    145146  }
    146147
    147  
     148
    148149  /**
    149150   * Finds and deletes the Synchronisable with the appropriate objectID
     
    164165    return true;
    165166  }
    166  
     167
    167168  /**
    168169   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
     
    185186  }
    186187
    187  
     188
    188189  /**
    189190  * This function is used to register a variable to be synchronized
     
    240241    if(classID==0)
    241242      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
     243
     244    if (this->classID == (unsigned int)-1)
     245        this->classID = this->getIdentifier()->getNetworkID();
     246
    242247    assert(this->classID==this->getIdentifier()->getNetworkID());
    243248//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
     
    314319    assert(this->objectID==syncHeader->objectID);
    315320//    assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
    316    
     321
    317322    COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
    318323    for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r1916 r1940  
    4141#include "util/Integers.h"
    4242
    43 #define REGISTERDATA(varname) registerVar(&varname, sizeof(varname), network::DATA)
    44 #define REGISTERDATA_WITHDIR(varname, mode) registerVar(&varname, sizeof(varname), network::DATA, mode)
    45 #define REGISTERSTRING(stringname) registerVar(&stringname, stringname.length()+1, network::STRING)
    46 #define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)
     43#define REGISTERDATA(varname, ...) \
     44    registerVar((void*)&varname, sizeof(varname), network::DATA, __VA_ARGS__)
     45#define REGISTERSTRING(stringname, ...) \
     46    registerVar(&stringname, stringname.length()+1, network::STRING, __VA_ARGS__)
    4747
    4848namespace network
     
    112112    void setObjectMode(int mode);
    113113    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
    114     virtual void registerAllVariables()=0;
    115114
    116115
  • code/branches/objecthierarchy/src/network/packet/Packet.cc

    r1907 r1940  
    4949
    5050namespace packet{
    51  
     51
    5252#define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
    5353#define _PACKETID           0
    54  
     54
    5555std::map<ENetPacket *, Packet *> Packet::packetMap_;
    56  
     56
    5757Packet::Packet(){
    5858  flags_ = PACKET_FLAG_DEFAULT;
     
    112112    packetMap_[enetPacket_] = this;
    113113  }
    114 #ifndef NDEBUG 
     114#ifndef NDEBUG
    115115  switch( *(ENUM::Type *)(data_ + _PACKETID) )
    116116  {
Note: See TracChangeset for help on using the changeset viewer.