Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 590 for code/branches/FICN/src


Ignore:
Timestamp:
Dec 17, 2007, 8:23:26 PM (17 years ago)
Author:
scheusso
Message:

enhanced memory handling

Location:
code/branches/FICN/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/GameStateManager.cc

    r573 r590  
    8282  //the size of the gamestate
    8383  int totalsize=0;
     84  int memsize=1000;
    8485  //the size of one specific synchronisable
    8586  int tempsize=0;
     
    9394  // reserve a little memory and increase it later on
    9495  COUT(2) << "mallocing" << std::endl;
    95   retval->data = (unsigned char*)malloc(1);
     96  retval->data = (unsigned char*)malloc(memsize);
    9697  COUT(2) << "malloced" << std::endl;
    9798
     
    106107    totalsize+=tempsize+3*sizeof(int);
    107108    // allocate additional space
    108     retval->data = (unsigned char *)realloc((void *)retval->data, totalsize);
     109    if(totalsize+tempsize>memsize){
     110      retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
     111      memsize+=1000;
     112    }
    109113
    110114    // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
  • code/branches/FICN/src/orxonox/objects/BaseEntity.cc

    r580 r590  
    3030        name_ = xmlElem->Attribute("name");
    3131        mesh_ = xmlElem->Attribute("src");
    32         std::string node = xmlElem->Attribute("node");
     32        node_ = xmlElem->Attribute("node");
    3333
    34         // get the node
    35         this->setNode(Orxonox::getSingleton()->getSceneManager()->getSceneNode(node));
    36 
    37        
    3834        // register variables to be synchronised
    3935        registerAllVariables();
     
    4137        create();
    4238
    43                 std::cout << "Loader: Created entity "<< name_ <<" with source " << mesh_  << " at node " << node  << std::endl << std::endl;
     39                std::cout << "Loader: Created entity "<< name_ <<" with source " << mesh_  << " at node " << node_  << std::endl << std::endl;
    4440        }
    4541   }
     
    4945     registerVar(&name_, name_.length()+1, network::STRING);
    5046     registerVar(&mesh_, mesh_.length()+1, network::STRING);
     47     registerVar(&node_, node_.length()+1, network::STRING);
    5148   }
    5249   
     
    5451     if(!valid)
    5552       return false;
     53     // get the node
     54     this->setNode(Orxonox::getSingleton()->getSceneManager()->getSceneNode(node_));
    5655     Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
    5756     
  • code/branches/FICN/src/orxonox/objects/BaseEntity.h

    r568 r590  
    2222      std::string name_;
    2323      std::string mesh_;
     24      std::string node_;
    2425    // other membervariables
    25       Ogre::SceneNode *sceneNode_;
     26      //Ogre::SceneNode *sceneNode_;
    2627      bool valid;
    2728  };
  • code/branches/FICN/src/orxonox/objects/SceneNode.cc

    r580 r590  
    7777        }
    7878   }
     79   
     80   void SceneNode::registerAllVariables(){
     81     
     82   }
     83   
     84   bool SceneNode::create(){
     85     return true;
     86   }
     87   
    7988}
  • code/branches/FICN/src/orxonox/objects/SceneNode.h

    r515 r590  
    44#include "BaseObject.h"
    55#include "../../tinyxml/tinyxml.h"
     6#include "network/Synchronisable.h"
    67
    78namespace orxonox
    89{
    9     class SceneNode : public BaseObject
     10    class SceneNode : public BaseObject, public network::Synchronisable
    1011    {
    1112        public:
    12             SceneNode();
    13             virtual ~SceneNode();
     13          SceneNode();
     14          virtual ~SceneNode();
    1415
    1516           
    16             void loadParams(TiXmlElement* xmlElem);
    17 
     17          void loadParams(TiXmlElement* xmlElem);
     18          bool create();
     19        protected:
     20          void registerAllVariables();
    1821        private:
    19            
     22          float x_, y_, z_;
     23          float sx_, sy_, sz_;
     24          float yaw_, pitch_, roll_;
     25          std::string node_;
    2026
    2127    };
Note: See TracChangeset for help on using the changeset viewer.