mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
coalesce CMD_DO messages; fixes robot-vs-robot game.
This commit is contained in:
parent
3798084dab
commit
bb90dce2c4
1 changed files with 11 additions and 3 deletions
|
@ -140,6 +140,12 @@ public class JNIThread extends Thread {
|
||||||
XwJNI.board_invalAll( m_jniGamePtr );
|
XwJNI.board_invalAll( m_jniGamePtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean nextSame( JNICmd cmd )
|
||||||
|
{
|
||||||
|
QueueElem nextElem = m_queue.peek();
|
||||||
|
return null != nextElem && nextElem.m_cmd == cmd;
|
||||||
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
boolean[] barr = new boolean[1]; // scratch boolean
|
boolean[] barr = new boolean[1]; // scratch boolean
|
||||||
|
@ -176,6 +182,9 @@ public class JNIThread extends Thread {
|
||||||
draw = XwJNI.server_do( m_jniGamePtr );
|
draw = XwJNI.server_do( m_jniGamePtr );
|
||||||
break;
|
break;
|
||||||
case CMD_DO:
|
case CMD_DO:
|
||||||
|
if ( nextSame( JNICmd.CMD_DO ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
draw = XwJNI.server_do( m_jniGamePtr );
|
draw = XwJNI.server_do( m_jniGamePtr );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -186,9 +195,7 @@ public class JNIThread extends Thread {
|
||||||
barr );
|
barr );
|
||||||
break;
|
break;
|
||||||
case CMD_PEN_MOVE:
|
case CMD_PEN_MOVE:
|
||||||
QueueElem nextElem = m_queue.peek();
|
if ( nextSame( JNICmd.CMD_PEN_MOVE ) ) {
|
||||||
if ( null != nextElem && nextElem.m_cmd == JNICmd.CMD_PEN_MOVE ) {
|
|
||||||
Utils.logf( "dropping CMD_PEN_MOVE" );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
draw = XwJNI.board_handlePenMove( m_jniGamePtr,
|
draw = XwJNI.board_handlePenMove( m_jniGamePtr,
|
||||||
|
@ -283,6 +290,7 @@ public class JNIThread extends Thread {
|
||||||
public void handle( JNICmd cmd, Object... args )
|
public void handle( JNICmd cmd, Object... args )
|
||||||
{
|
{
|
||||||
QueueElem elem = new QueueElem( cmd, args );
|
QueueElem elem = new QueueElem( cmd, args );
|
||||||
|
// Utils.logf( "adding: " + cmd.toString() );
|
||||||
m_queue.add( elem );
|
m_queue.add( elem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue