summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/util/DB.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-04-13 23:44:53 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-04-13 23:48:54 +0200
commit95d0131cb9733d273b81bf63a8778dc2b8e0a414 (patch)
treebe0bca04dc39f66ce1ffbeb5f22e191123e5facf /core/src/ch/asynk/rustanddust/util/DB.java
parent513938e9b1731308535ef45336239f9209e2e396 (diff)
downloadRustAndDust-keep.zip
RustAndDust-keep.tar.gz
WIPkeep
Diffstat (limited to 'core/src/ch/asynk/rustanddust/util/DB.java')
-rw-r--r--core/src/ch/asynk/rustanddust/util/DB.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java
index 994e5d3..70767cf 100644
--- a/core/src/ch/asynk/rustanddust/util/DB.java
+++ b/core/src/ch/asynk/rustanddust/util/DB.java
@@ -67,6 +67,7 @@ public class DB
this.db = DatabaseFactory.getNewDatabase(dbPath, DB_SCHEMA_VERSION, null, null);
this.db.setupDatabase();
this.debug = debug;
+ this.debug = true;
}
public void setup()
@@ -126,6 +127,7 @@ public class DB
private boolean checkDigest(String what, int id, String payload, String digest)
{
+ if (payload == null) return true;
if (digest.equals(getDigest(payload)))
return true;
RustAndDust.error(String.format("corrupted %s(%d)", what, id));
@@ -295,6 +297,7 @@ public class DB
public boolean storeLastTurn(int game)
{
+ RustAndDust.debug("storeLastTurn");
try {
exec(String.format(COPY_TURN, game));
} catch (SQLiteGdxException e) {
@@ -304,6 +307,18 @@ public class DB
return true;
}
+ public boolean clearOrders(int game)
+ {
+ RustAndDust.debug("clearOrders");
+ try {
+ exec(String.format("update games set orders=null, ordersH=null where _id=%d;", game));
+ } catch (SQLiteGdxException e) {
+ RustAndDust.error("clearOrders");
+ return false;
+ }
+ return true;
+ }
+
private static final String LOAD_BASE = "select g._id, g.mode, g.battle, g.opponent, g.turn, g.currentPlayer, g.ts, g.synched";
private static final String LOAD_GAMES = LOAD_BASE + ", null, null, null, null, p.name, b.name"
@@ -347,7 +362,7 @@ public class DB
return r;
}
- private static final String LOAD_LAST_TURN = "select g._id, g.mode, g.battle, g.opponent, t.turn, t.currentPlayer, g.ts, g.synched"
+ private static final String LOAD_LAST_TURN = "select g._id, g.mode, g.battle, g.opponent, t.turn, t.currentPlayer, g.ts, 0"
+ ", t.state, t.stateH, g.orders, g.ordersH, null, null from games g inner join turns t on (g._id = t.game) where g._id=%d order by t.turn desc limit 1;";
public GameRecord loadLastTurn(int game)