aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/intmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/intmap.h')
-rw-r--r--engines/sci/engine/intmap.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/engines/sci/engine/intmap.h b/engines/sci/engine/intmap.h
index bb1f610100..68823789ec 100644
--- a/engines/sci/engine/intmap.h
+++ b/engines/sci/engine/intmap.h
@@ -27,6 +27,7 @@
#define SCI_ENGINE_INTMAP_H
#include "common/scummsys.h"
+#include "common/serializer.h"
namespace Sci {
@@ -50,8 +51,13 @@ enum {
* All in all, this implementation is not very elegant, and wastes memory.
* But it does the job. Any rewrite of this class would have to provide a
* way to load the old savegames made using the current implementation.
+ *
+ * One approach to implement a replacement: Combine a Common::HashMap<int,int>
+ * with a bitfield which track which low-value integers are in use.
+ * That way, lookup just invokes the hashmap, and insertion (which requires
+ * finding an unmapped low-value integer) can still be implemented efficiently.
*/
-struct IntMapper {
+struct IntMapper : public Common::Serializable {
struct Node {
int key;
@@ -66,11 +72,17 @@ struct IntMapper {
** to base_value */
void free_node_recursive(Node *node);
+protected:
+ void insert(int key, int idx); // For loading only
public:
IntMapper();
~IntMapper();
+ virtual void saveLoadWithSerializer(Common::Serializer &ser);
+
+ void clear();
+
/**
* Checks whether a key is in the map, adds it if neccessary.
* @param value The key to check for/add