From cafb6d40174459819b33ffc5e3d5e96762375619 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 6 Jan 2013 15:26:56 +0000 Subject: Set the item::Mountable flag where required, removed the Weapon::stackable() attribute. --- src/game/base/game.cc | 30 ++++++++++++++++++++++-------- src/game/base/savegame.cc | 18 +++++++++++++----- src/game/base/weapon.cc | 9 --------- src/game/base/weapon.h | 10 +--------- 4 files changed, 36 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index efb89fe..b115d70 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -498,10 +498,14 @@ void Game::func_give(core::Player *player, const std::string &args) } } if (amount < 0) { - if (weapon->stackable()) { - amount = max; - } else { - amount = 1; + switch (weapon->subtype()) { + case Weapon::Mine: + case Weapon::Ammo: + amount = max; + break; + default: + amount = 1; + break; } } @@ -512,7 +516,7 @@ void Game::func_give(core::Player *player, const std::string &args) core::Item *item = 0; - if (weapon->stackable()) { + if ( (weapon->subtype() == Weapon::Ammo) || (weapon->subtype() == Weapon::Mine)) { item = player->control()->inventory()->find(weapon); if (!item) { item = new core::Item(weapon); @@ -2141,10 +2145,20 @@ bool Game::load_zone(core::Zone *zone) item = new core::Item(weapon); item->set_amount(-1); item->set_price(weapon->price()); - if (!weapon->stackable()) { - item->set_flag(core::Item::Unique); - } item->set_flag(core::Item::Unrestricted); + + switch (weapon->subtype()) { + case Weapon::Cannon: + item->set_flag(core::Item::Unique); + item->set_flag(core::Item::Mountable); + break; + case Weapon::Turret: + item->set_flag(core::Item::Unique); + item->set_flag(core::Item::Mountable); + break; + default: + break; + } inventory->add(item); } } else { diff --git a/src/game/base/savegame.cc b/src/game/base/savegame.cc index 6d492d0..616b85f 100644 --- a/src/game/base/savegame.cc +++ b/src/game/base/savegame.cc @@ -212,12 +212,20 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) if (item->info()->type() == Weapon::infotype()) { const Weapon *weapon = static_cast(item->info()); - + item->set_price(weapon->price()); item->set_flag(core::Item::Unrestricted); - if (weapon->stackable()) { - item->unset_flag(core::Item::Unique); - } else { - item->set_flag(core::Item::Unique); + + switch (weapon->subtype()) { + case Weapon::Cannon: + item->set_flag(core::Item::Unique); + item->set_flag(core::Item::Mountable); + break; + case Weapon::Turret: + item->set_flag(core::Item::Unique); + item->set_flag(core::Item::Mountable); + break; + default: + break; } } } diff --git a/src/game/base/weapon.cc b/src/game/base/weapon.cc index 1838733..a27d51b 100644 --- a/src/game/base/weapon.cc +++ b/src/game/base/weapon.cc @@ -205,21 +205,18 @@ bool Weapon::init() if (weaponsini.got_section("mine")) { previous = weapon; weapon = new Weapon(); - weapon->set_stackable(true); weapon->set_subtype(Mine); count++; } else if (weaponsini.got_section("cannon")) { previous = weapon; weapon = new Weapon(); - weapon->set_stackable(false); weapon->set_subtype(Cannon); count++; } else if (weaponsini.got_section("turret")) { previous = weapon; weapon = new Weapon(); - weapon->set_stackable(false); weapon->set_subtype(Turret); count++; @@ -279,7 +276,6 @@ Weapon::Weapon() : core::Info(weapon_infotype) { set_volume(1); set_level(1); - set_stackable(false); set_subtype(Ammo); set_damage(0); set_projectile_interval(0); @@ -291,11 +287,6 @@ Weapon::~Weapon() { } -void Weapon::set_stackable(bool stackable) -{ - weapon_stackable = stackable; -} - void Weapon::set_level(const int level) { weapon_level = level; diff --git a/src/game/base/weapon.h b/src/game/base/weapon.h index ec071ad..ee67cfc 100644 --- a/src/game/base/weapon.h +++ b/src/game/base/weapon.h @@ -24,11 +24,7 @@ public: inline SubType subtype() const { return weapon_subtype; } - - inline bool stackable() const { - return weapon_stackable; - } - + /** * @brief player level required to buy this weapon * */ @@ -101,8 +97,6 @@ public: /* --- mutators -------------------------------------------- */ - void set_stackable(bool stackable); - void set_level(const int level); void set_subtype(const SubType subtype); @@ -181,8 +175,6 @@ private: int weapon_level; - bool weapon_stackable; - unsigned long weapon_projectile_interval; unsigned long weapon_projectile_lifespan; -- cgit v1.2.3