Commit graph

260 commits

Author SHA1 Message Date
Eric House
f49c81462c wip: received messages dispatched to games 2017-10-22 09:29:15 -07:00
Eric House
37162e0471 fix curses commit; refactor & cleanup 2017-10-21 12:11:26 -07:00
Eric House
3045697d31 wip: process moves received 2017-10-19 21:20:14 -07:00
Eric House
36aef059c1 remove assertion: deviceID can change
Hit this nuking the devices table mid-game. Games recover with the
assertion removed (and storing the new/non-matching deviceID)
2017-10-07 10:47:44 -07:00
Eric House
0b0a50bd5c add timestamp to chat messages, db and display
On send, add current seconds to message. Store and display in android
code. Display layout needs work.
2017-06-10 11:36:45 -07:00
Eric House
6e5973c55b toward making tile picking work through rotations
Make face-up tile picker util method return void and add mechanism for
passing in selected tiles asynchronously, as has been done recently with
the rest of the once-blocking util callbacks. Works perfectly in the gtk
case. Likely crashes in curses (if picking face-up option is on.) In
java all the callbacks are there but rather than put up a UI we pretend
the user says "pick 'em for me" each time. Putting up a UI is next.
2017-03-09 20:36:14 -08:00
Eric House
c271202faa make bad phonies alert non-blocking
Continue conversion of alerts that required blocking the JNI thread. Now
board_commitTurn() takes a second boolean indicating whether phonies
found have been approved by user. Common code informs user, and if he
approves client code calls board_commitTurn() again. In case where
turn's lost there's no call to make back, but there's the undesirable
change that if a robot moves next its move will be reported on top of
the turn-lost alert. Ideally new alerts would appear under, not on top
of, those that have not yet been dismissed.
2017-02-20 07:20:19 -08:00
Eric House
5f12d1a03b assign faces to blanks asynchronously
Next step in converting util_ methods that required blocking: blank tile
assignment. Now post a query and add a method that the client code can
call when the user's decided. Include enough state (col, row, and
playerNum) so that it's probably pretty safe.
2017-02-18 19:16:32 -08:00
Eric House
ca6edcfc9a make trade and move confirm non-blocking
Probably breaks curses build, but for gtk and Android
turn move and trade confirmation into a two-step process, making
board_commitTurn() non-interactive when called with a second
parameter. The old blocking util methods now return void and it's up to
the client code to interact (on the main thread) then re-call
board_commitTurn() if appropriate.
2017-02-17 08:58:20 -08:00
Eric House
1f2f4506c4 remove unused query option. Less to convert. 2017-02-17 06:30:54 -08:00
Eric House
2a0b21e5e8 make password fetching non-blocking
First attempt to stop blocking the jni thread: instead of returning a
password from a util_ method, have it include enough state that the UI
can return, put up a dialog, and then pass that state and the password
back and have them matched up again. I think this will work for the
remaining blocking Alerts too.
2017-02-17 06:23:44 -08:00
Eric House
5742c5cb12 gtk: save game on every turn change
Idea is to have the games list stay in sync, but in fact it stays one
move behind, at least in a typical standalone human-vs-robot game. So
this is incomplete.
2016-09-19 09:12:23 -07:00
Eric House
7994c42691 allow board cells to be wider than tall
There are some screen dimensions, especially with dual-pane mode, where
the board is just bit narrower than the screen. Rather than have narrow
white borders, allow the cells to take up the slack. The API takes an
upper bound on the ratio of width to height so things shouldn't get too
odd looking.
2016-09-15 20:37:29 -07:00
Eric House
406eb77f54 post notification (rather than just play sound) when turn comes into
boarddelegate but it's not visible
2016-04-14 22:16:18 -07:00
Eric House
19713a40ad add param to comms_resendAll to limit type of message sent
(e.g. BT). Meant to be used when a single type has become available.
2016-02-02 07:01:48 -08:00
Eric House
87517edd6f fix counting of messages sent by "Resend messages" menuitem: actually
count them, and do so based on new msgNo passed from comms that's
concatenation of channelNo and msgID so that duplicates (over multiple
transports) aren't counted twice.
2015-09-30 06:50:04 -07:00
Eric House
6d7123c27a fix curses app for standalone games (at least to not crash) 2015-08-19 06:05:18 -07:00
Eric House
8f7267b3ec add index of sending player to chat transmission, and on receiving
side translate that into showing the sender's name in
notification. Not yet done: replacing silly "not me" in chat listing
with same, but now it should be easy.
2015-08-12 07:36:36 -07:00
Eric House
ad6be1bb7e add debug-only "tag" to open games so logging can more easily track
what's going on when multiple participants in a single game are on the
same device. But for a couple of strings passed into the jni the
changes are only in DEBUG code.
2015-02-09 19:15:43 -08:00
Eric House
28bfa3c904 make forceChannel part of CurGameInfo rather than comms, since Android
needs to save it there on receipt of an invitation (doesn't create
full game with comms until later.)  Passes discon2 tests and seems to
work on a single Android device. (Haven't tested inviting on Android
yet.)
2014-12-29 07:39:28 -08:00
Eric House
897c4d5786 add param to force a client to connect to host requesting a particular
channel. Works well enough that relay test script works. Not yet
integrated for let alone tested on Android.
2014-12-21 17:40:00 -08:00
Eric House
d81f022c78 Merge branch 'android_branch' into android_multi2
Conflicts:
	xwords4/linux/scripts/discon_ok2.sh
2014-12-15 16:48:10 -08:00
Eric House
30d2c84dcc so tests can continue, comment out an assertion that indicates a relay
bug that neverless doesn't prevent games from running to completion.
2014-12-15 16:43:24 -08:00
Eric House
9ff7cd1ff9 comment out dead code so I stop trying to debug it 2014-12-10 07:47:36 -08:00
Eric House
c704b7ff4f remove dead code 2014-11-10 07:31:33 -08:00
Eric House
17bc0ab47c snapshot of work toward communicating when two addresses are in use.
An invitation works with relay and (fake) SMS on, and the invited
client connects successfully using both (the second to arrive being
correctly identified as a dupe.)  While the game can be played after,
only SMS messages are being received. And opening a saved game
crashes.
2014-11-05 07:41:20 -08:00
Eric House
fe4c7b52f2 snapshot: relay test script works with a second address type set
(though with its actual transport stubbed out).  Android doesn't even
compile.
2014-10-15 07:26:18 -07:00
Eric House
43bd3c018a make an addr's conType a bitfield rather than holding a single value.
Works for large numbers of relay games in test, but will not yet
actually hold more than one value.  Should be safe to merge to main
branch once stream upgrade is verified.
2014-09-25 20:05:37 -07:00
Eric House
6f07098cf3 return succes from server_initClientConnection() 2014-09-14 13:42:11 -07:00
Eric House
4231ed1108 fix refcount leak 2014-03-11 21:59:53 -07:00
Eric House
19c70ccdcb fix mistaken scoreboard size calc 2014-01-06 06:54:56 -08:00
Eric House
3702a9f326 don't constrain screen size 2014-01-06 06:40:59 -08:00
Eric House
b43855a313 fix curses build for 64bit compile and to use common layout (meaning
tray is now under the board unstead of to the right).  Works on 64-bit
system at least for non-networked games.
2014-01-05 13:04:59 -08:00
Eric House
6bdd939531 rename field 2013-12-17 20:02:31 -08:00
Eric House
8d20c33b76 snapshot: still not correctly recording return address 2013-12-16 08:06:29 -08:00
Eric House
2a56a0ba98 snapshot: more linux-sms stuff 2013-12-12 21:08:25 -08:00
Eric House
7cffa27a88 snapshot toward implementing fake-sms as per-device rather than per-game 2013-12-11 07:54:26 -08:00
Eric House
184ac28ebc fix to compile, and in gtk case to work, when COMMON_LAYOUT defined 2013-11-03 12:15:53 -08:00
Eric House
2629c07256 Address problem with devids (e.g. GCM): until now when you got a new
devid you tossed your relayID and reregistered.  Which meant any
existing messages meant for your relayID were orphaned, and any open
games didn't know who they belonged to until you reconnected to them
with your new relayID.  So: modify the UDP protocol (though not on
Android yet) to include both relayID and devid with registration, with
one or the other an empty string if not present or not changed from
earlier.  I can't fix existing clients that are dropping their
relayIDs, but when one does a re-connect without a relayID I can look
it up from the existing game record, then reuse it rather than issue a
new one.  Better than nothing -- and that protocol will be obsolete
soon anyway.
2013-09-14 21:06:14 -07:00
Eric House
71ea59e7fb separate whether app is using udp from whether it stores games in a
sqlite3 db so that it can switch mid-game -- that being something that
needs testing.
2013-08-07 21:09:48 -07:00
Eric House
da54b1e5fb add keepalive timers 2013-08-02 08:01:16 -07:00
Eric House
63ad3a196b debug build asserts that packet is meant for this device, but
non-debug should drop those that aren't.
2013-07-29 07:30:46 -07:00
Eric House
27d9f3de45 Don't enable chat when more than 128 messages are in queue to prevent
an extremely unlikely cause of stalls -- and make tests trip over full
queues less often.
2013-07-18 07:37:45 -07:00
Eric House
1e6ff9b33c include seed in chat messages to make sure they're unique 2013-07-18 07:06:20 -07:00
Eric House
d6fd79be44 log, and be more aggressive about closing, sockets on which errors occur 2013-07-16 06:43:30 -07:00
Eric House
491b288631 assert that the seed's preserved for curses version too (where
clientToken is otherwise ignored since there's only one game per app
instance)
2013-07-11 20:39:10 -07:00
Eric House
5a20cc282c fix so curses app works well enough that discon_ok2.sh script runs
successfully.  GTK mode is untested and certainly broken.
2013-07-09 18:10:41 -07:00
Eric House
f5696334a9 changes to get the merged code to compile but not included by git in the commit 2013-07-09 07:25:23 -07:00
Eric House
d50c808f96 Merge branch 'android_branch' into gtk_multigame
Conflicts:
	xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
	xwords4/common/comms.c
	xwords4/linux/cursesmain.c
	xwords4/linux/cursesmain.h
	xwords4/linux/gtkmain.c
	xwords4/linux/gtkmain.h
	xwords4/linux/linuxmain.c
	xwords4/linux/main.h
	xwords4/linux/scripts/discon_ok2.sh
	xwords4/relay/xwrelay.cpp

(Note: The curses app crashes on exit with mempool assertions, but that's a problem before the merge.)
2013-07-09 07:18:00 -07:00
Eric House
923d41e0ee fix to compile when DEBUG not set 2013-07-07 13:17:26 -07:00
Eric House
0ac5d6d9e2 don't send more than three unanswered chats per boot -- to avoid
filling up the queues in a way that doesn't reflect real use.
2013-07-02 18:30:23 -07:00
Eric House
dd48cea912 don't log string before it's initialized 2013-07-02 07:26:32 -07:00
Eric House
9fca3792cf don't pile on chat messages when relay isn't even connected: it's an
unfair test that doesn't duplicate what users will likely do.
2013-07-02 05:53:58 -07:00
Eric House
195f873ab0 tweak logging 2013-06-30 07:37:35 -07:00
Eric House
1a73ab26ac tweak logging 2013-06-28 20:33:27 -07:00
Eric House
5612bb000b quick hack to allow testing intermix of chat with normal moves 2013-06-24 18:37:49 -07:00
Eric House
c8f584dad2 don't listen on stdin if it's been closed 2013-06-10 06:15:36 -07:00
Eric House
72a78100b1 fix compile error in non-debug version 2013-05-27 16:18:11 -07:00
Eric House
ffa983db94 use pipe to quit from signal handler since calling g_main_loop_quit()
doesn't work with more recent glib versions (and has always been a bad idea)
2013-05-24 21:19:20 -07:00
Eric House
c75ecef240 test deletion of games and generation of anonymous relayIDs 2013-01-29 07:42:10 -08:00
Eric House
2aba3c0ce1 load dict early enough to have lang available to comms when it first connects. 2013-01-26 11:56:20 -08:00
Eric House
498498a2bf remove gameToken param from XWPDEV_HAVEMSGS message since it's for the
whole device rather than one game on it.
2013-01-24 19:20:35 -08:00
Eric House
481f344ff4 fix failure to clean up on exit 2013-01-24 08:08:53 -08:00
Eric House
9f3250cb3f make curses version use udp socket when --db param passed. There's no
UI for the DB and the assumption is only one game will be stored but
this should let the test script be modified to test the new protocol.
2013-01-24 07:49:49 -08:00
Eric House
ae9ec31863 don't call g_main_loop_quit() from inside signal handler: it doesn't
work on Ubuntu LTS at least.  Instead write to a "quit pipe" and exit
the loop from the pipe's reader back outside exception context.
2013-01-21 18:57:48 -08:00
Eric House
3dfb2e04e6 call comms_close in curses too to avoid new assert 2013-01-19 22:53:25 -08:00
Eric House
1519a00004 toward being able to handle messages received for closed game.
Receipt seems to work but send in that state doesn't.
2013-01-18 07:49:00 -08:00
Eric House
fac3e6b678 fix gtk version to correctly implement util_setIsServer (which only
Android did so far) by calling server_initClientConnection().  Now
relay games work with both started as hosts.  (GTK UI prevents
starting one as a guest; cmdline is required for that, if it still
works.)
2013-01-08 07:28:30 -08:00
Eric House
76f3bb3413 fix curses version so discon_ok2 tests work again. 2013-01-07 20:40:46 -08:00
Eric House
f88387da80 lots of changes to separate game data from app data so several games
can be open at once.  (curses version is almost certainly broken)
2013-01-07 06:10:44 -08:00
Eric House
c4df31892e Fix occasional infinite loop of devices sending and receiving the same
message over and over when getting updated by GCM.  The problem
occurred when one device had an un-ACKable initial message still in
its queue.  I call resendAll a lot, which caused that message to get
resent to the other game which then replied without being able to ACK
it so it remained to be sent again.  This would continue until users
moved forward in the game.  The fix is to add a backoff timer to
resendAll() so that it can't loop.  The timer is reset when an ackable
and new message is received, meaning there's been a change in what's
available to resend.  And since users calling resendAll manually
expect it to do something, add a force param that ignores the backoff.
seems to fix the problem (but needs a lot of testing.)
2012-11-13 21:25:03 -08:00
Eric House
093fc4d1fa cleanup 2012-11-13 07:23:07 -08:00
Eric House
2908802017 try to make linux client mimic Android a bit better in saving after
any network activity so messages get acked more quickly.
2012-11-13 06:15:36 -08:00
Eric House
aec03fc572 When a game's consumated and guest discovers it isn't using the same
dict, give chance to switch, and to download if required.  Because of
the way the JNI thread works, and JNI's requirement in general that
env instances match up (e.g. dicts must be destroyed in the same
thread that creates them), substituting into a live game is too hard.
So the game's saved with its new dict and then reloaded.
2012-10-24 07:17:21 -07:00
Eric House
e90c5ee94f pass index of resigning player into util_notifyGameOver. Not yet
passed into java.
2012-10-09 05:31:12 -07:00
Eric House
968340f665 Fix release-build warnings that new compiler flags. 2012-10-07 11:43:50 -07:00
Eric House
fd9b9f85e2 make util_hiliteCell conditional, and remove from android where it
wasn't used anyway.
2012-10-05 18:51:32 -07:00
Eric House
6ddd4a61c1 fix compile errors (mostly unused variables) found by gcc on latest
Ubuntu (12.04).
2012-09-25 07:28:02 -07:00
Eric House
140c982d41 merge from android_branch 2012-09-24 07:39:44 -07:00
Eric House
0ccc2331b5 address bug where message was getting ACK'd by a device that failed to
save what it had ACK'd leaving the game permanently broken.  Do that
by adding a new method game_saveSucceeded() called after the client
claims to have committed bytes returned by game_writeToStream() to
disk.  In that method comms updates the value it'll use in subseqent
ACKs.
2012-09-10 07:31:45 -07:00
Eric House
95a7b14a3a transmit dict's md5sum along with name in initial message from host to
guest.  On guest, pass that sum into client code along with names so
the appropriate tests can be done and corrections taken.
2012-09-08 20:23:48 -07:00
Eric House
270a19f3aa Revert "first of a set of changes to communicate to clients dictionary being"
This reverts commit b7a0f1489b, which I didn't mean to check in on this branch.
2012-09-03 21:34:51 -07:00
Eric House
ea4d805d5f first of a set of changes to communicate to clients dictionary being
used by server.  Clients need to care if e.g. the server's disallowing
phonies based on its dict.  Can only be sent if client is of latest
version.  In that case, common code calls into new util function.  In
future changes, BoardActivity's implemention of the callback will need
to check if the server's choice of dict is available, and if not offer
to download it.  Once it's available, will want to install it.
2012-09-03 21:33:46 -07:00
Eric House
b7a0f1489b first of a set of changes to communicate to clients dictionary being
used by server.  Clients need to care if e.g. the server's disallowing
phonies based on its dict.  Can only be sent if client is of latest
version.  In that case, common code calls into new util function.  In
future changes, BoardActivity's implemention of the callback will need
to check if the server's choice of dict is available, and if not offer
to download it.  Once it's available, will want to install it.
2012-09-03 21:29:21 -07:00
Eric House
d25916ae5f protect sqlite code with compile-time flag so easier to disable. 2012-07-29 08:37:08 -07:00
Eric House
08e5fbdcc2 add ability to open game in sqlite3 DB from an Android phone. It's
read-only now: changes are not saved.  But it works!
2012-07-26 20:44:33 -07:00
Eric House
0b1a9a67fe add param to server_handleUndo to prevent it from undoing all moves in
robot-vs-robot game, which is the wrong thing to do during a test
simulating play.
2012-05-24 22:25:30 -07:00
Eric House
cd89885cd2 add new periodic (one-second) timer, and commandline option that sets
what percent of the times that timer fires will result in a move being
undone.  Will be used to interject random out-of-order undos into
games played for testing.  (Currently the tests fail when this is
enabled; I need to fix that.)
2012-05-23 19:58:03 -07:00
Eric House
3a54aa0ebc add util_informUndo() that gets called, and puts up a dialog, after
remote device has performed an undo on a committed turn.
2012-05-14 07:01:02 -07:00
Eric House
64199c4e64 Merge branch 'android_branch' into android_bt 2012-05-05 11:08:03 -07:00
Eric House
44a6653166 add passthrough of params present in gtk but not curses 2012-05-05 09:24:41 -07:00
Eric House
d59b19514b Merge branch 'android_branch' into android_bt 2012-05-03 21:44:35 -07:00
Eric House
09f9038cff add option to have robot choose to trade tiles a configurable percent
of the time.  Meant to increase automated test coverage of trades.
2012-05-02 20:14:42 -07:00
Eric House
79a897b428 fix assert (but still leaking) 2012-02-09 05:16:32 -08:00
Andy2
2a34cd1e05 remove second param from server_do() -- it doesn't work anyway. 2011-12-21 18:45:05 -08:00
Andy2
d37424ad7f Merge branch 'android_branch' into send_in_background
Conflicts:
	xwords4/linux/linuxutl.h
2011-11-21 22:18:52 -08:00
Eric House
8a51d5f3e4 fix race condition that was breaking tests: when one device sends two
messages they must be handled by the relay in order.  So modify linux
client to build a single packet of all messages sent instead of
letting rq sent each on a separate socket.  The relay would give the
sockets to different threads and sometimes the wrong one won.  Will
need to make sure the android code's doing the same thing (it appears
to be), or perhaps make the coalescing code common so I only debug it
once.
2011-11-17 19:56:36 -08:00
Andy2
210c59ef9b move bonus square values into model: add API to set an array, and API
to query model for values.  Now everybody else queries new model API
rather than client via util_getSquareBonus(), model uses its internal
values if present otherwise falls back to util_getSquareBonus(), and
internalizes the array as part of the game.  Now it should be easier
to have different bonus patterns and to have them exchanged as part of
network game init.
2011-11-16 19:01:11 -08:00
Andy2
379e5f1d96 use actual rather than max possible board dimensions to apportion
space, fixing crashes when max upped to 32.  Will still fail as actual
size approaches that number.
2011-11-14 20:18:09 -08:00
Andy2
2492e7cfc5 Merge branch 'android_branch' into send_in_background
Conflicts:
	xwords4/linux/cursesmain.c
2011-11-13 17:10:46 -08:00