|
From: Stefan F. <ste...@us...> - 2011-07-23 08:39:13
|
rails/game/GameManager.java | 1 -
rails/game/special/SpecialProperty.java | 11 ++++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
New commits:
commit 8b9df8fe03b3dbfbda264eaa0db322c600b325bb
Author: Stefan Frey <ste...@we...>
Date: Sat Jul 23 10:41:11 2011 +0200
Fixed problem of unique ids related to Special Properties (they start at
one instead of zero)
diff --git a/rails/game/GameManager.java b/rails/game/GameManager.java
index 77b2118..7c5a11a 100644
--- a/rails/game/GameManager.java
+++ b/rails/game/GameManager.java
@@ -1882,7 +1882,6 @@ public class GameManager implements ConfigurableComponentI, GameManagerI {
if (id == null) id = 0;
objectStorage.put(typeName + id, object);
storageIds.put(typeName, id + 1); // store next id
- log.debug("Stores " + typeName + " + on id " + id);
return id;
}
diff --git a/rails/game/special/SpecialProperty.java b/rails/game/special/SpecialProperty.java
index 8994da7..917b510 100644
--- a/rails/game/special/SpecialProperty.java
+++ b/rails/game/special/SpecialProperty.java
@@ -61,7 +61,9 @@ public abstract class SpecialProperty implements SpecialPropertyI {
public SpecialProperty() {
gameManager = GameManager.getInstance();
- uniqueId = gameManager.storeObject(STORAGE_NAME, this);
+ uniqueId = gameManager.storeObject(STORAGE_NAME, this) + 1;
+ // increase unique id to allow loading old save files (which increase by 1)
+ // TODO: remove that legacy issue
}
public void configureFromXML(Tag tag) throws ConfigurationException {
@@ -109,8 +111,11 @@ public abstract class SpecialProperty implements SpecialPropertyI {
return uniqueId;
}
- public static SpecialPropertyI getByUniqueId(int i) {
- return (SpecialPropertyI)GameManager.getInstance().retrieveObject(STORAGE_NAME, i);
+ public static SpecialPropertyI getByUniqueId(int id) {
+ id -= 1;
+ // decrease retrieval id to allow loading old save files (which increase by 1)
+ // TODO: remove that legacy issue
+ return (SpecialPropertyI)GameManager.getInstance().retrieveObject(STORAGE_NAME, id);
}
public void setCompany(CompanyI company) {
|