diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-16 16:30:52 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-16 16:30:52 +0100 |
commit | 16d201d391f0e38c9709026959a4e303f5737518 (patch) | |
tree | 04dacaff888c95c4d321224b0ffa18f28f9ba073 /core/src/ch/asynk/rustanddust | |
parent | 7cb950072c952bb45c2cc1f82c8a9719ac17afb2 (diff) | |
download | RustAndDust-16d201d391f0e38c9709026959a4e303f5737518.zip RustAndDust-16d201d391f0e38c9709026959a4e303f5737518.tar.gz |
DB: storeState update games table _p1, _p2, ts
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r-- | core/src/ch/asynk/rustanddust/util/DB.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index 4bfa046..096776e 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -66,6 +66,7 @@ public class DB private static final String GET_GAME_ID = "select _id from games where _p1=%d and _p2=%d and _b=%d;"; private static final String INSERT_TURN = "insert into turns(_g,_p,hash,payload) values (%d,%d,'%s','%s'); update games set ts=current_timestamp where _id=%d;"; private static final String INSERT_STATE = "insert or replace into states(_g,hash,payload) values (%d,'%s','%s'); update games set ts=current_timestamp where _id=%d;"; + private static final String UPDATE_GAME = "update games set _p1=%d, _p2=%d, ts=current_timestamp where _id=%d;"; private static final String GET_STATE = "select payload from states where _g=%d;"; private static final String DB_CRT = TBL_CFG_CRT + TBL_PLAYERS_CRT + TBL_BATTLES_CRT + TBL_GAMES_CRT + TBL_TURNS_CRT + TBL_STATES_CRT; @@ -202,13 +203,14 @@ public class DB return true; } - public boolean storeState(int game, String payload) + public boolean storeState(int game, int p1, int p2, String payload) { RustAndDust.debug("storeState"); try { String hash = getDigest(payload); if (hash == null) return false; db.execSQL(String.format(INSERT_STATE, game, hash, payload, game)); + db.execSQL(String.format(UPDATE_GAME, p1, p2, game)); } catch (SQLiteGdxException e) { RustAndDust.error("storeState"); return false; |