Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/base/savegame.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/game/base/savegame.cc b/src/game/base/savegame.cc
index e70e143..90f3a57 100644
--- a/src/game/base/savegame.cc
+++ b/src/game/base/savegame.cc
@@ -7,6 +7,7 @@
#include "base/game.h"
#include "base/savegame.h"
#include "base/ship.h"
+#include "base/weapon.h"
namespace game {
@@ -177,14 +178,6 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile)
item->unset_flag(core::Item::Tradeable);
}
}
- } else if (inifile.got_key_bool("unique", b)) {
- if (item) {
- if (b) {
- item->set_flag(core::Item::Unique);
- } else {
- item->unset_flag(core::Item::Unique);
- }
- }
} else {
inifile.unknown_key();
}
@@ -194,6 +187,20 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile)
}
if (ship) {
+ for (core::Inventory::Items::iterator it = ship->inventory()->items().begin(); it != ship->inventory()->items().end(); ++it) {
+ core::Item *item = (*it);
+
+ if (item->info()->type() == Weapon::infotype()) {
+ const Weapon *weapon = static_cast<const Weapon *>(item->info());
+
+ item->set_flag(core::Item::Unrestricted);
+ if (weapon->stackable()) {
+ item->unset_flag(core::Item::Unique);
+ } else {
+ item->set_flag(core::Item::Unique);
+ }
+ }
+ }
ship->inventory()->recalculate();
ship->inventory()->set_dirty();
@@ -286,7 +293,7 @@ void SaveGame::inventory_to_stream(core::Inventory *inventory, std::ostream & os
if(!inventory)
return;
- for (core::Inventory::Items::iterator it = inventory->items().begin();
+ for (core::Inventory::Items::const_iterator it = inventory->items().begin();
it != inventory->items().end(); ++it)
{
const core::Item *item = (*it);
@@ -302,9 +309,6 @@ void SaveGame::inventory_to_stream(core::Inventory *inventory, std::ostream & os
if (item->has_flag(core::Item::Tradeable)) {
os << "tradeable=" << (item->has_flag(core::Item::Tradeable) ? "yes" : "no") << std::endl;
}
- if (item->has_flag(core::Item::Unique)) {
- os << "unique=" << (item->has_flag(core::Item::Unique) ? "yes" : "no") << std::endl;
- }
}
}