Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10351


Ignore:
Timestamp:
Apr 7, 2015, 10:12:07 PM (10 years ago)
Author:
landauf
Message:

using the 'official' way to define a non-static console command

Location:
code/branches/towerdefenseFS15
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseFS15

  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc

    r10340 r10351  
    9090namespace orxonox
    9191{
     92    static const std::string __CC_addTower_name  = "addTower";
     93    static const std::string __CC_upgradeTower_name = "upgradeTower";
     94
     95    SetConsoleCommand("TowerDefense", __CC_addTower_name,  &TowerDefense::addTower ).addShortcut().defaultValues(1);
     96    SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0);
     97
    9298    RegisterUnloadableClass(TowerDefense);
    9399
     
    108114        //this->stats_ = new TowerDefensePlayerStats();
    109115
    110         /* Temporary hack to allow the player to add towers and upgrade them */
    111         this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
    112         this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
     116        ModifyConsoleCommand(__CC_addTower_name).setObject(this);
     117        ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this);
    113118    }
    114119
     
    118123        if (this->isInitialized())
    119124        {
    120             if( this->dedicatedAddTower_ )
    121                 delete this->dedicatedAddTower_;
     125            ModifyConsoleCommand(__CC_addTower_name).setObject(NULL);
     126            ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL);
    122127        }
    123128    }
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h

    r10340 r10351  
    8686
    8787        void upgradeTower(int x, int y);
    88         /* Part of a temporary hack to allow the player to add towers */
    89         ConsoleCommand* dedicatedAddTower_;
    90         ConsoleCommand* dedicatedUpgradeTower_;
    9188
    9289        //TODO: void spawnNewWave()
Note: See TracChangeset for help on using the changeset viewer.