Commit graph

25 commits

Author SHA1 Message Date
Eric House
ed90c9c16d implement util->dutil split for Android
So now all jni code uses a single dutil context, but also a single
mempool and jniutil instance instead of new instances of the latter two
per game and dict-iteration.
2018-07-05 08:32:19 -07:00
Eric House
9cdd5a7b72 share mpool and vtable in jni calls
A number of jni calls were "stateless", which meant they allocated their
own vtmgr and mpool instances each time invoked. Instead invoke them
with the global jni closure and add to it vtmgr (already has mpool) and
use these instead of allocating/freeing each time. To make sure no race
conditions are introduced (mpool, though debug-only, is probably not
thread-safe), guard these new uses with an in-use flag. If that fires
I'll need a mutex or something.
2018-06-27 21:17:44 -07:00
Eric House
875d956836 don't need the local threadinfo at all
I think the crash was just due to removing env from the global state
rather than just leaving it be.
2018-01-23 21:26:11 -08:00
Eric House
d809ff4f7c give dict iter its own threadmap
I like this better than the previous fix: rather than share a
thread->env map with the game world allocate a new one for each
iterator. This could cause problem if the iterator is used on threads
that don't currently call map_thread(), or if there are callbacks that
need to look up the env that I'm not aware of. Needs testing...
2018-01-22 22:02:57 -08:00
Eric House
cbb683fc74 fix env-mapping crash in jni due to race condition
As reported to google, dict iterator destruction was crashing due to a
race condition if it happened after a game using the same dict had been
closed since it needed a mapped env that the game closure would
remove. Fixed in two ways, one by adding the mapping prior to the code
that uses it (a common pattern: add happens many times, whenver it might
be needed, but remove only once), and second by passing env into the
code that was crashing.

The mapping stuff remains inherently racy and I'm not sure now how to
fix that. It depends on there being a place to unmap after which it's
guaranteed the mapped value won't be needed again. When two
objects (game and dict_iter in this case) map the same env/thread combo
there's a race.
2018-01-22 07:45:43 -08:00
Eric House
17f27a1b65 remove relayStatus() from jni
Making it a no-op as the only thing it did, tweaking the net status
indicator, isn't useful.
2017-12-27 14:42:15 -08:00
Eric House
ed57a744b6 use the new built-in game_receiveMessage
I'd forgotten it...
2017-12-19 07:28:19 -08:00
Eric House
af81342021 create new fdroid variant 2017-11-27 20:40:06 -08:00
Eric House
64014944f3 finish: using java's base64 en/decoder from java
Added a wrapper function since for compatibility with the jni's encoding
the flags matter and need to be the same everywhere. Or at least there
should be no chance of their getting changed.
2017-07-13 07:40:28 -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
9644f40659 add ui for disabling comms send and receive
Add DEBUG-builds-only UI at the bottom of GameConfig for turning on the
comms feature dropping outgoing or incoming messages. The idea's to use
this to reproduce and fix stalls. There's a noticable slowdown opening
the GameConfig fragment, but it should all be no-op in a release build.
2017-05-26 07:49:38 -07:00
Eric House
b6665a15c4 double-check to avoid crash (by observation)
Chasing a rare play-store-reported JNI crash: test for a null ptr in C
and assert/test in Java.
2017-05-25 07:10:49 -07:00
Eric House
ef2da21bbe xw4dbg -> xw4d: tired of typing the extra letters
Rename the debug variant and make it work. appID stays the same and so
no longer matches. Gradle allows that.
2017-05-23 06:37:31 -07:00
Eric House
55339b6aaf fix release compile warnings 2017-04-06 07:43:20 -07:00
Eric House
a804983b8e fix makeIntArray to work for non-32-bit array sources 2017-03-13 19:32:20 -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
70b3aaa263 modify function to be more useful 2017-03-09 19:35:07 -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
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
b96d44393a add and use boolToStr
Just to make log messages a bit more helpful. Should be no behavior
change, and no change in code generated in release builds.
2017-01-22 14:15:29 -08:00
Eric House
3ac0039b4d fix jni build. Full .apk now produced.
But it gets confused about downloading wordlists.
2017-01-18 08:33:49 -08:00
Eric House
fcdb66eb87 forgot a file 2017-01-18 07:28:19 -08:00
Eric House
49242f78cf more script fixes; move jni code 2017-01-18 07:27:23 -08:00