aboutsummaryrefslogtreecommitdiffstats
path: root/inc/savegame.inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc/savegame.inc')
-rw-r--r--inc/savegame.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/inc/savegame.inc b/inc/savegame.inc
index 8772585..6d92af2 100644
--- a/inc/savegame.inc
+++ b/inc/savegame.inc
@@ -1,6 +1,8 @@
<?php
require_once("inc/messages.inc");
+require_once("inc/Inventory.inc");
+require_once("inc/Item.inc");
define("SAVEDIR", "data/save");
@@ -63,7 +65,10 @@ function parseSave($xml, &$table) { // Passing $table by reference
if(is_numeric($v)) $v = +$v; // If it is in fact a number, treat it that way using PHP unary '+' coercion
$table[$k] = $v;
} elseif($k == "inventory") { // Special case for inventory: objects need to be created
- foreach($v as $item) Inventory::addItem(Item::fromXML($item));
+ foreach($v as $item) {
+ for($i=0; $i<+$item->count; $i++) // Add the right count of items to Inventory
+ Inventory::addItem(Item::fromXML($item));
+ }
} else { // If nested array
$table[$k] = array();
parseSave($v, $table[$k]);