From 1afbfb7e5fb5c133924ed8d376c6064575fc1c36 Mon Sep 17 00:00:00 2001
From: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
Date: Mon, 12 Mar 2012 22:18:22 +0100
Subject: Fixed problems with map-bound world state variables

Due to a wrong primary key, which covered only the state name, it was
impossible to use the same state name on different maps. This has now
been fixed.

Another problem was that the map variables were being included in the
global variables, because the related database query did not filter on
the map_id column properly. While fixing that, the map_id column now
allows explicitly marking a state variable as global (with the value 0)
or system variables (with the value -1).

System variables are currently not accessible from scripts, but that
could be changed later.

Reviewed-by: Yohann Ferreira
Reviewed-by: Erik Schilling
---
 src/sql/sqlite/createTables.sql | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/sql/sqlite/createTables.sql')

diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index 9a9dfe2..a5822f3 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -250,10 +250,12 @@ CREATE TABLE mana_quests
 
 CREATE TABLE mana_world_states
 (
-   state_name   TEXT        PRIMARY KEY,
-   map_id       INTEGER     NULL,
-   value        TEXT        NULL,
-   moddate      INTEGER     NOT NULL
+   state_name   TEXT        NOT NULL,
+   map_id       INTEGER     NOT NULL,
+   value        TEXT        NOT NULL,
+   moddate      INTEGER     NOT NULL,
+   --
+   PRIMARY KEY (state_name, map_id)
 );
 
 -----------------------------------------------------------------------------
-- 
cgit 

