Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/world_entities/bsp_entity.cc @ 9396

Last change on this file since 9396 was 9396, checked in by patrick, 18 years ago

committing my weekends work: 2100 lines :D

  • proxy server now accepts and synchronizes clients like a master server
  • network manager got different network setup interface
  • network stream got different constructure scheme
  • permissions checking and algorithm extended and changed
  • starting ability to connect to multiple network nodes at the same time
  • some very much smaller changes here and there
File size: 2.8 KB
RevLine 
[4838]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
[9396]3
[1853]4   Copyright (C) 2004 orx
[9396]5
[1853]6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[9396]10
[1855]11   ### File Specific:
[8490]12   main-programmer: Claudio Botta
[1855]13   co-programmer: ...
[1853]14*/
15
[8081]16#include "bsp_entity.h"
17#include "util/loading/resource_manager.h"
[9003]18#include "util/loading/resource_manager.h"
[1853]19
[8490]20CREATE_FACTORY(BspEntity, CL_BSP_ENTITY);
[8087]21
22
[3564]23/**
[8490]24 * constructs and loads a BspEntity from a XML-element
[4838]25 * @param root the XML-element to load from
26 */
[8490]27BspEntity::BspEntity(const TiXmlElement* root)
[4483]28{
29  this->init();
[8490]30
[4838]31  if (root != NULL)
32    this->loadParams(root);
[4483]33}
34
35
36/**
[4838]37 * standard deconstructor
38 */
[8490]39BspEntity::~BspEntity ()
[3566]40{
[9003]41  if( this->bspManager != NULL)
[8490]42    delete this->bspManager;
[3566]43}
44
[8087]45
[9003]46
[3762]47/**
[8490]48 * initializes the BspEntity
[4838]49 * @todo change this to what you wish
50 */
[8490]51void BspEntity::init()
[4483]52{
[5509]53
[9003]54  this->bspManager = NULL;
[9396]55
[9059]56  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name" ) );
[9396]57
[9059]58  this->setSynchronized( true );
[8490]59}
[5509]60
[8490]61
62void BspEntity::setName(const std::string& name)
63{
64  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
[9396]65
[9059]66  this->name = name;
[8490]67
[9003]68  // Check wether file exists....
69  if ( File(ResourceManager::getFullName(name)).exists()  ) {
70
71    this->setClassID(CL_BSP_ENTITY, "BspEntity");
72    this->bspManager = new BspManager(this);
73
74    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
75      this->bspManager = NULL;
76
77    } else {
78      this->toList(OM_ENVIRON); // Success!!!
79    }
80  } else {
81    this->bspManager = NULL;
82    this->toList(OM_DEAD);
83  }
[4483]84}
85
[5509]86
[4483]87/**
[8490]88 * loads a BspEntity from a XML-element
[4838]89 * @param root the XML-element to load from
90 * @todo make the class Loadable
91 */
[8490]92void BspEntity::loadParams(const TiXmlElement* root)
[4483]93{
[4838]94  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
[9003]95  // WorldEntity::loadParam(root);
[8087]96
[8490]97  LoadParam(root, "Name", this, BspEntity, setName)
[9003]98  .describe("Sets the of the BSP file.");
[4483]99
[9003]100  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
101        .describe("Sets the scale factore of the bsp level.");
102  */
[5509]103
104  /**
105   * @todo: make the class Loadable
106   */
[4483]107}
108
109
110/**
[8490]111 * advances the BspEntity about time seconds
[4838]112 * @param time the Time to step
113 */
[8490]114void BspEntity::tick(float time)
[3762]115{
[8490]116  this->bspManager->tick(time);
[3762]117}
118
[8081]119
[3245]120/**
[4838]121 * draws this worldEntity
122 */
[8490]123void BspEntity::draw () const
[4838]124{
[8081]125  this->bspManager->draw();
[3559]126}
[5509]127
128
129/**
130 *
131 *
132 */
[8490]133void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
[9003]134{}
[9059]135
136void BspEntity::varChangeHandler( std::list< int > & id )
137{
138  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
139  {
140    this->setName( this->name_write );
141  }
142}
Note: See TracBrowser for help on using the repository browser.