Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 314 for code


Ignore:
Timestamp:
Nov 28, 2007, 2:41:41 PM (17 years ago)
Author:
scheusso
Message:

implementing GameStateManager

Location:
code/branches/network
Files:
5 edited

Legend:

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

    r92 r314  
    3737#This sets where to look for "Find*.cmake" files
    3838SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
     39SET(BOOST_LIBDIR /usr/pack/boost-1.33.1-mo/i686-debian-linux3.1/lib/)
     40SET(BOOST_INCDIR /usr/pack/boost-1.33.1-mo/i686-debian-linux3.1/include/)
     41
    3942#Performs the search and sets the variables
    4043FIND_PACKAGE(OGRE)
     
    4245
    4346#Sets the search paths for the linking
    44 LINK_DIRECTORIES(${OGRE_LIB_DIR} ${OIS_LIB_DIR})
     47LINK_DIRECTORIES(${OGRE_LIB_DIR} ${OIS_LIB_DIR} ${BOOST_LIBDIR})
    4548#Sets the search path for include files
    46 INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR})
     49INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${BOOST_INCDIR})
    4750
    4851#add main source dir
  • code/branches/network/Ogre.log

    r96 r314  
    1 14:39:58: Creating resource group General
    2 14:39:58: Creating resource group Internal
    3 14:39:58: Creating resource group Autodetect
    4 14:39:58: SceneManagerFactory for type 'DefaultSceneManager' registered.
    5 14:39:58: Registering ResourceManager for type Material
    6 14:39:58: Registering ResourceManager for type Mesh
    7 14:39:58: Registering ResourceManager for type Skeleton
    8 14:39:58: MovableObjectFactory for type 'ParticleSystem' registered.
    9 14:39:58: OverlayElementFactory for type Panel registered.
    10 14:39:58: OverlayElementFactory for type BorderPanel registered.
    11 14:39:58: OverlayElementFactory for type TextArea registered.
    12 14:39:58: Registering ResourceManager for type Font
    13 14:39:58: ArchiveFactory for archive type FileSystem registered.
    14 14:39:58: ArchiveFactory for archive type Zip registered.
    15 14:39:58: FreeImage version: 3.9.3
    16 14:39:58: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
    17 14:39:58: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi
    18 14:39:58: DDS codec registering
    19 14:39:58: Registering ResourceManager for type HighLevelGpuProgram
    20 14:39:58: Registering ResourceManager for type Compositor
    21 14:39:58: MovableObjectFactory for type 'Entity' registered.
    22 14:39:58: MovableObjectFactory for type 'Light' registered.
    23 14:39:58: MovableObjectFactory for type 'BillboardSet' registered.
    24 14:39:58: MovableObjectFactory for type 'ManualObject' registered.
    25 14:39:58: MovableObjectFactory for type 'BillboardChain' registered.
    26 14:39:58: MovableObjectFactory for type 'RibbonTrail' registered.
    27 14:39:58: OGRE EXCEPTION(6:FileNotFoundException): 'plugins.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
    28 14:39:58: plugins.cfg not found, automatic plugin loading disabled.
    29 14:39:58: *-*-* OGRE Initialising
    30 14:39:58: *-*-* Version 1.4.5 (Eihort)
    31 14:39:58: OGRE EXCEPTION(6:FileNotFoundException): 'resources.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
    32 14:39:58: *-*-* OGRE Shutdown
    33 14:39:58: Unregistering ResourceManager for type Compositor
    34 14:39:58: Unregistering ResourceManager for type Font
    35 14:39:58: Unregistering ResourceManager for type Skeleton
    36 14:39:58: Unregistering ResourceManager for type Mesh
    37 14:39:58: Unregistering ResourceManager for type HighLevelGpuProgram
    38 14:39:58: Unregistering ResourceManager for type Material
     115:20:52: Creating resource group General
     215:20:52: Creating resource group Internal
     315:20:52: Creating resource group Autodetect
     415:20:52: SceneManagerFactory for type 'DefaultSceneManager' registered.
     515:20:52: Registering ResourceManager for type Material
     615:20:52: Registering ResourceManager for type Mesh
     715:20:52: Registering ResourceManager for type Skeleton
     815:20:52: MovableObjectFactory for type 'ParticleSystem' registered.
     915:20:52: OverlayElementFactory for type Panel registered.
     1015:20:52: OverlayElementFactory for type BorderPanel registered.
     1115:20:52: OverlayElementFactory for type TextArea registered.
     1215:20:52: Registering ResourceManager for type Font
     1315:20:52: ArchiveFactory for archive type FileSystem registered.
     1415:20:52: ArchiveFactory for archive type Zip registered.
     1515:20:52: FreeImage version: 3.9.3
     1615:20:52: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
     1715:20:52: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi
     1815:20:52: DDS codec registering
     1915:20:52: Registering ResourceManager for type HighLevelGpuProgram
     2015:20:52: Registering ResourceManager for type Compositor
     2115:20:52: MovableObjectFactory for type 'Entity' registered.
     2215:20:52: MovableObjectFactory for type 'Light' registered.
     2315:20:52: MovableObjectFactory for type 'BillboardSet' registered.
     2415:20:52: MovableObjectFactory for type 'ManualObject' registered.
     2515:20:52: MovableObjectFactory for type 'BillboardChain' registered.
     2615:20:52: MovableObjectFactory for type 'RibbonTrail' registered.
     2715:20:52: OGRE EXCEPTION(6:FileNotFoundException): 'plugins.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
     2815:20:52: plugins.cfg not found, automatic plugin loading disabled.
     2915:20:52: *-*-* OGRE Initialising
     3015:20:52: *-*-* Version 1.4.5 (Eihort)
     3115:20:52: OGRE EXCEPTION(6:FileNotFoundException): 'resources.cfg' file not found! in ConfigFile::load at OgreConfigFile.cpp (line 84)
     3215:20:52: *-*-* OGRE Shutdown
     3315:20:52: Unregistering ResourceManager for type Compositor
     3415:20:52: Unregistering ResourceManager for type Font
     3515:20:52: Unregistering ResourceManager for type Skeleton
     3615:20:52: Unregistering ResourceManager for type Mesh
     3715:20:52: Unregistering ResourceManager for type HighLevelGpuProgram
     3815:20:52: Unregistering ResourceManager for type Material
  • code/branches/network/src/network/GameStateManager.cc

    r290 r314  
    2222}
    2323
    24 GameState GameStateManager::getSnapshot()
     24/**
     25 * This function goes through the whole list of synchronisables and
     26 * saves all the synchronisables to a flat "list".
     27 * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
     28 */
     29GameState GameStateManager::getSnapshot(int id)
    2530{
     31  //the size of the gamestate
     32  int totalsize=0;
     33  //the size of one specific synchronisable
     34  int tempsize=0;
     35  // get the start of the Synchronisable list
     36  Iterator<Synchronisable> it;
     37  // struct for return value of Synchronisable::getData()
     38  syncData sync;
     39 
     40  GameState retval; //return value
     41  retval.id=id;
     42  // reserve a little memory and increase it later on
     43  retval.data = malloc(1);
     44 
     45  // offset of memory functions
     46  int offset=0;
     47  // go through all Synchronisables
     48  for(it = ObjectList<Synchronisable>::start(); it != 0; it++){
     49    //get size of the synchronisable
     50    tempsize=it->getSize();
     51    // add place for data and 3 ints (length,classid,objectid)
     52    totalsize+=tempsize+3*sizeof(int);
     53    // allocate additional space
     54    retval.data = (unsigned char *)realloc((void *)retval.data, totalsize);
     55   
     56    // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
     57    sync=it->getData(retval.data+offset+3*sizeof(int));
     58    *(retval.data+offset)=sync.length;
     59    *(retval.data+offset+sizeof(int))=sync.objectID;
     60    *(retval.data+offset+*sizeof(int))=sync.classID;
     61    // increase data pointer
     62    offset+=tempsize+3*sizeof(int);
     63  }
     64  retval.size=totalsize;
     65  return retval;
     66}
     67
     68/**
     69 * This function loads a Snapshort of the gamestate into the universe
     70 * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
     71 */
     72bool GameStateManager::loadSnapshot(GameState state)
     73{
     74  unsigned char *data=state->data;
     75  // get the start of the Synchronisable list
     76  Iterator<Synchronisable> it=ObjectList<Synchronisable>::start();
     77  syncData sync;
     78  // loop as long as we have some data ;)
     79  while(data < state->data+state->size){
     80    // prepare the syncData struct
     81    sync.length = *(int *)data;
     82    data+=sizeof(int);
     83    sync.objectID = *(int *)data;
     84    data+=sizeof(int);
     85    sync.classID = *(int *)data;
     86    data+=sizeof(int);
     87    sync.data = data;
     88    data+=sync.length;
     89   
     90    if(it->objectID!=sync.objectID){
     91      // bad luck ;)
     92    } else {
     93      // we have our object
     94      if(! it->updateData(sync))
     95        std::cout << "We couldn't update objectID: " << sync.objectID << "; classID: " << sync.classID << std::endl;
     96    }
     97  }
    2698 
    2799}
    28100
    29 bool GameStateManager::loadSnapshot(GameState state)
    30 {
    31  
     101
     102
     103
    32104}
    33105
    34 }
     106
  • code/branches/network/src/network/GameStateManager.h

    r247 r314  
    1313#define NETWORK_GAMESTATEMANAGER_H
    1414
     15#include "network/Synchronisable.h"
     16
    1517namespace network {
    1618
     
    2022 * data: pointer to the data allocated in the memory
    2123 */
    22 struct GameState{
     24  struct GameState{
     25  int id;
    2326  int size;
    2427  unsigned char *data;
     
    3639  GameStateManager();
    3740  ~GameStateManager();
    38   GameState getSnapshot();
     41  GameState getSnapshot(int id);
    3942  bool loadSnapshot(GameState state);
    4043private:
  • code/branches/network/src/network/Synchronisable.h

    r247 r314  
    1414
    1515#include <list>
     16#include <iostream>
     17
     18#include "orxonox/core/IdentifierIncludes.h"
    1619
    1720namespace network {
     
    2023struct syncData{
    2124  int length;
     25  int objectID;
    2226  int classID;
    23   int objectID;
    2427  unsigned char *data;
    2528};
Note: See TracChangeset for help on using the changeset viewer.