Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-21 10:31:05 +0000
committerStijn Buys <ingar@osirion.org>2012-10-21 10:31:05 +0000
commita3259b0d7dd9e4444b7dbe1489e1470f29c8dc7c (patch)
tree7faab0c53c41f5a313cc413ada4adea7a0b21983 /src/game/base
parent37116aad3b2c128bae5b7f1ef4d1bc3cb8608f57 (diff)
Corrected loadgame to have the Unique and Unrestricted item properties set from actual in-game properties rather than read from the savegame file.
Diffstat (limited to 'src/game/base')
-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;
- }
}
}