diff --git a/src/net/torvald/terrarum/gameactors/Actor.kt b/src/net/torvald/terrarum/gameactors/Actor.kt index a91f9df98..e2d46f56f 100644 --- a/src/net/torvald/terrarum/gameactors/Actor.kt +++ b/src/net/torvald/terrarum/gameactors/Actor.kt @@ -74,10 +74,10 @@ abstract class Actor : Comparable, Runnable { fun Int.sign(): Int = if (this > 0) 1 else if (this < 0) -1 else 0 + /* called when the actor is loaded from the save; one use of this function is to "re-sync" the + * Transient variables such as `mainUI` of FixtureBase + */ open fun reload() { - /* called when the actor is loaded from the save; one use of this function is to "re-sync" the - * Transient variables such as `mainUI` of FixtureBase - */ actorValue.actor = this if (this is Pocketed) diff --git a/src/net/torvald/terrarum/gameitems/GameItem.kt b/src/net/torvald/terrarum/gameitems/GameItem.kt index c881a815a..b4c9a54b3 100644 --- a/src/net/torvald/terrarum/gameitems/GameItem.kt +++ b/src/net/torvald/terrarum/gameitems/GameItem.kt @@ -192,6 +192,11 @@ abstract class GameItem(val originalID: ItemID) : Comparable, Cloneabl */ open val extra = Codex() + /* called when the instance of the dynamic is loaded from the save; one may use this function to "re-sync" some values, + * for the purpose of savegame format update, defence against rogue savegame manipulation, etc. + */ + open fun reload() { } + /** * Effects applied continuously while in pocket */ diff --git a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt index 966fdf107..2c09fae02 100644 --- a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt +++ b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt @@ -73,6 +73,9 @@ class ItemCodex { } } dynamicItemInventory[dynid] = item + + // try to call reload() of the dynamic items + item.reload() } }