Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2005, 5:02:50 PM (19 years ago)
Author:
manuel
Message:

needs fix in weapon_powert_up.cc (fabricate from string)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/powerups/src/world_entities/power_ups/weapon_power_up.cc

    r5965 r5973  
    2222
    2323#include "primitive_model.h"
     24
     25#include "factory.h"
     26#include "load_param.h"
    2427
    2528using namespace std;
     
    5255{
    5356  static_cast<PowerUp*>(this)->loadParams(root);
    54 
     57  const TiXmlElement* elem = root->FirstChildElement("weapon");
     58  if(elem != NULL && (elem = weapon->getFirstChildElement()) != NULL)
     59  {
     60    this->weaponXML = elem;
     61    createWeapon();
     62  }
     63  else
     64  {
     65    LoadParam(root, "weaponID", this, const char*, setWeaponClass);
     66  }
    5567}
    5668
    5769Weapon* WeaponPowerUp::getWeapon()
    5870{
    59   return dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(this->getWeaponID()));
     71  return this->weapon;
    6072}
    6173
    62 ClassID WeaponPowerUp::getWeaponID()
     74void WeaponPowerUp::createWeapon()
    6375{
    64   return this->weaponID;
     76  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
     77      ? Factory::getFirst()->fabricate(static_cast<ClassID>(this->weapon->getClassID()))
     78      : Factory::getFirst()->fabricate(weaponXML));
    6579}
    6680
    67 long WeaponPowerUp::getCapsNeeded()
     81void WeaponPowerUp::setWeaponClass(const char* name)
    6882{
    69   return this->capsNeeded;
     83  this->weapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(name, name));
    7084}
Note: See TracChangeset for help on using the changeset viewer.