mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Merge branch 'relay_proxy' of /home/andy2/dev/git/LOCAL_ORIGIN into relay_proxy
This commit is contained in:
commit
048eff92b8
17 changed files with 78 additions and 113 deletions
|
@ -734,7 +734,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
m_fillPaint.setTextAlign( Paint.Align.CENTER );
|
||||
m_canvas.drawText( text, center, bottom, m_fillPaint );
|
||||
}
|
||||
}
|
||||
} // drawCentered
|
||||
|
||||
private void drawScaled( String text, final Rect rect, int descent )
|
||||
{
|
||||
|
@ -750,7 +750,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
int bottom = local.bottom - descent;
|
||||
canvas.drawText( text, 0, bottom, m_fillPaint );
|
||||
|
||||
m_canvas.drawBitmap( bitmap, local, rect, m_drawPaint );
|
||||
m_canvas.drawBitmap( bitmap, null, rect, m_drawPaint );
|
||||
}
|
||||
|
||||
private void positionDrawTile( final Rect rect, String text, int val )
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
franklin
|
||||
palm
|
||||
ARMV4Rel
|
||||
emulatorDbg
|
||||
PALM_PNO
|
||||
obj_linux_memdbg
|
||||
obj_linux_rel
|
||||
obj_win32_dbg
|
||||
obj_win32_rel
|
||||
obj_wince_dbg
|
||||
obj_wince_rel
|
|
@ -1,5 +0,0 @@
|
|||
*.bin
|
||||
*.xwd
|
||||
*.pdb
|
||||
*.inf
|
||||
*.dict.gz
|
|
@ -1,3 +0,0 @@
|
|||
*.bin
|
||||
*.xwd
|
||||
*.pdb
|
|
@ -1,10 +0,0 @@
|
|||
*.bin
|
||||
*.pdb
|
||||
*.xwd
|
||||
*.saved
|
||||
*.pdr
|
||||
*.ehouse
|
||||
*.seb
|
||||
decompose
|
||||
temp
|
||||
*.stamp
|
|
@ -1,3 +0,0 @@
|
|||
*.bin
|
||||
*.pdb
|
||||
*.xwd
|
|
@ -1,3 +0,0 @@
|
|||
*.bin
|
||||
*.xwd
|
||||
*.pdb
|
|
@ -1,4 +0,0 @@
|
|||
*.bin
|
||||
*.pdb
|
||||
*.xwd
|
||||
*.seb
|
|
@ -1,3 +0,0 @@
|
|||
*.bin
|
||||
*.xwd
|
||||
*.pdb
|
|
@ -1,8 +0,0 @@
|
|||
*.bin
|
||||
*.pdb
|
||||
*.saved
|
||||
*.pdr
|
||||
*.ehouse
|
||||
*.seb
|
||||
decompose
|
||||
temp
|
|
@ -1,7 +0,0 @@
|
|||
*.bin
|
||||
*.xwd
|
||||
*.pdb
|
||||
*.saved
|
||||
*.pdr
|
||||
*.ehouse
|
||||
*.seb
|
|
@ -1,4 +0,0 @@
|
|||
*.bin
|
||||
*.pdb
|
||||
*.xwd
|
||||
*.seb
|
|
@ -1 +0,0 @@
|
|||
obj_linux_memdbg
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -u -e
|
||||
|
||||
NGAMES=${NGAMES:-1}
|
||||
NROOMS=${NROOMS:-1}
|
||||
|
@ -51,7 +52,7 @@ connName() {
|
|||
sort -u
|
||||
}
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case $1 in
|
||||
*) usage
|
||||
;;
|
||||
|
@ -62,7 +63,7 @@ done
|
|||
declare -A CHECKED_ROOMS
|
||||
check_room() {
|
||||
ROOM=$1
|
||||
if [ -z "${CHECKED_ROOMS[$ROOM]}" ]; then
|
||||
if [ -z ${CHECKED_ROOMS[$ROOM]:-""} ]; then
|
||||
NUM=$(echo "SELECT COUNT(*) FROM games WHERE ntotal!=sum_array(nperdevice) AND room='$ROOM'" |
|
||||
psql -q -t xwgames)
|
||||
NUM=$((NUM+0))
|
||||
|
@ -82,8 +83,10 @@ build_cmds() {
|
|||
check_room $ROOM
|
||||
NDEVS=$(($RANDOM%3+2))
|
||||
DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]}
|
||||
# make one in three games public
|
||||
[ $((RANDOM%3)) -eq 0 ] && PUBLIC="-A -R" || PUBLIC=""
|
||||
|
||||
unset OTHERS
|
||||
OTHERS=""
|
||||
for II in $(seq 2 $NDEVS); do
|
||||
OTHERS="-N $OTHERS"
|
||||
done
|
||||
|
@ -94,6 +97,7 @@ build_cmds() {
|
|||
touch $LOG # so greps won't show errors
|
||||
CMD="./obj_linux_memdbg/xwords -C $ROOM -r ${NAMES[$DEV]} $OTHERS"
|
||||
CMD="$CMD -d $DICT -p $PORT -a $HOST -f $FILE -z 1:3 $PLAT_PARMS"
|
||||
CMD="$CMD $PUBLIC"
|
||||
CMDS[$COUNTER]=$CMD
|
||||
FILES[$COUNTER]=$FILE
|
||||
LOGS[$COUNTER]=$LOG
|
||||
|
@ -133,7 +137,7 @@ check_game() {
|
|||
KEY=$1
|
||||
LOG=${LOGS[$KEY]}
|
||||
CONNNAME="$(connName $LOG)"
|
||||
unset OTHERS
|
||||
OTHERS=""
|
||||
if [ -n "$CONNNAME" ]; then
|
||||
if grep -q '\[unused tiles\]' $LOG; then
|
||||
ALL_DONE=TRUE
|
||||
|
@ -143,7 +147,7 @@ check_game() {
|
|||
CONNNAME2="$(connName $ALOG)"
|
||||
if [ "$CONNNAME2" = "$CONNNAME" ]; then
|
||||
if ! grep -q '\[unused tiles\]' $ALOG; then
|
||||
unset OTHERS
|
||||
OTHERS=""
|
||||
break
|
||||
fi
|
||||
OTHERS="$OTHERS $INDX"
|
||||
|
@ -197,10 +201,10 @@ print_stats() {
|
|||
}
|
||||
|
||||
echo "*********$0 starting: $(date)**************"
|
||||
|
||||
STARTTIME=$(date +%s)
|
||||
build_cmds
|
||||
run_cmds
|
||||
print_stats
|
||||
|
||||
wait
|
||||
echo "*********$0 finished: $(date)**************"
|
||||
echo "*********$0 finished: $(date) (took $(($(date +%s)-$STARTTIME)) seconds)**************"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
xwrelay
|
|
@ -21,6 +21,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "dbmgr.h"
|
||||
#include "mlock.h"
|
||||
|
@ -35,6 +36,10 @@
|
|||
static DBMgr* s_instance = NULL;
|
||||
|
||||
static int sumArray( const char* const str );
|
||||
#define DELIM "\1"
|
||||
|
||||
static void formatParams( char* paramValues[], int nParams, const char* fmt,
|
||||
char* buf, int bufLen, ... );
|
||||
|
||||
/* static */ DBMgr*
|
||||
DBMgr::Get()
|
||||
|
@ -77,15 +82,27 @@ DBMgr::AddNew( const char* cookie, const char* connName, CookieID cid,
|
|||
{
|
||||
if ( !cookie ) cookie = "";
|
||||
if ( !connName ) connName = "";
|
||||
|
||||
const char* fmt = "INSERT INTO " GAMES_TABLE
|
||||
|
||||
const char* command = "INSERT INTO " GAMES_TABLE
|
||||
" (cid, room, connName, nTotal, nPerDevice, lang, pub)"
|
||||
" VALUES( %d, '%s', '%s', %d, ARRAY[0,0,0,0], %d, %s )";
|
||||
char buf[256];
|
||||
snprintf( buf, sizeof(buf), fmt, cid/*m_nextCID++*/, cookie, connName,
|
||||
nPlayersT, langCode, isPublic?"TRUE":"FALSE" );
|
||||
logf( XW_LOGINFO, "passing %s", buf );
|
||||
execSql( buf );
|
||||
" VALUES( $1, $2, $3, $4, ARRAY[0,0,0,0], $5, $6 )";
|
||||
int nParams = 6;
|
||||
char* paramValues[nParams];
|
||||
char buf[512];
|
||||
formatParams( paramValues, nParams,
|
||||
"%d"DELIM"%s"DELIM"%s"DELIM"%d"DELIM"%d"DELIM"%s",
|
||||
buf, sizeof(buf), cid, cookie, connName, nPlayersT,
|
||||
langCode, isPublic?"TRUE":"FALSE" );
|
||||
|
||||
PGresult* result = PQexecParams( getThreadConn(), command,
|
||||
nParams, NULL,
|
||||
paramValues,
|
||||
NULL, NULL, 0 );
|
||||
if ( PGRES_COMMAND_OK != PQresultStatus(result) ) {
|
||||
logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)),
|
||||
PQresultErrorMessage(result) );
|
||||
}
|
||||
PQclear( result );
|
||||
}
|
||||
|
||||
CookieID
|
||||
|
@ -122,21 +139,27 @@ DBMgr::FindOpen( const char* cookie, int lang, int nPlayersT, int nPlayersH,
|
|||
{
|
||||
CookieID cid = 0;
|
||||
|
||||
int nParams = 5;
|
||||
char* paramValues[nParams];
|
||||
char buf[512];
|
||||
formatParams( paramValues, nParams,
|
||||
"%s"DELIM"%d"DELIM"%d"DELIM"%d"DELIM"%s", buf, sizeof(buf),
|
||||
cookie, lang, nPlayersT, nPlayersH, wantsPublic?"TRUE":"FALSE" );
|
||||
|
||||
/* NOTE: ILIKE, for case-insensitive comparison, is a postgres extension
|
||||
to SQL. */
|
||||
const char* fmt = "SELECT cid, connName, nPerDevice FROM " GAMES_TABLE
|
||||
" WHERE room ILIKE '%s'"
|
||||
" AND lang = %d"
|
||||
" AND nTotal = %d"
|
||||
" AND %d <= nTotal-sum_array(nPerDevice)"
|
||||
" AND %s = pub"
|
||||
const char* cmd = "SELECT cid, connName, nPerDevice FROM " GAMES_TABLE
|
||||
" WHERE room ILIKE $1"
|
||||
" AND lang = $2"
|
||||
" AND nTotal = $3"
|
||||
" AND $4 <= nTotal-sum_array(nPerDevice)"
|
||||
" AND $5 = pub"
|
||||
" LIMIT 1";
|
||||
char query[256];
|
||||
snprintf( query, sizeof(query), fmt,
|
||||
cookie, lang, nPlayersT, nPlayersH, wantsPublic?"TRUE":"FALSE" );
|
||||
logf( XW_LOGINFO, "query: %s", query );
|
||||
|
||||
PGresult* result = PQexec( getThreadConn(), query );
|
||||
PGresult* result = PQexecParams( getThreadConn(), cmd,
|
||||
nParams, NULL,
|
||||
paramValues,
|
||||
NULL, NULL, 0 );
|
||||
if ( 1 == PQntuples( result ) ) {
|
||||
cid = atoi( PQgetvalue( result, 0, 0 ) );
|
||||
snprintf( connNameBuf, bufLen, "%s", PQgetvalue( result, 0, 1 ) );
|
||||
|
@ -441,6 +464,29 @@ DBMgr::RemoveStoredMessage( int msgID )
|
|||
execSql( query );
|
||||
}
|
||||
|
||||
static void
|
||||
formatParams( char* paramValues[], int nParams, const char* fmt, char* buf,
|
||||
int bufLen, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, bufLen );
|
||||
|
||||
int len = vsnprintf( buf, bufLen, fmt, ap );
|
||||
|
||||
int ii, pnum;
|
||||
for ( pnum = 0, ii = 0; ii < len && pnum < nParams; ++pnum ) {
|
||||
paramValues[pnum] = &buf[ii];
|
||||
for ( ; ii < len; ++ii ) {
|
||||
if ( buf[ii] == DELIM[0] ) {
|
||||
buf[ii] = '\0';
|
||||
++ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void
|
||||
destr_function( void* conn )
|
||||
{
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
ARMV4Rel
|
||||
ARMV4Dbg
|
||||
obj_win32_dbg
|
||||
obj_win32_rel
|
||||
obj_wince_dbg
|
||||
obj_wince_rel
|
||||
emulatorDbg
|
||||
ARMDbg
|
||||
ARMRel
|
||||
X86Dbg
|
||||
X86Rel
|
||||
xwords.vcb
|
||||
xwords.vcl
|
||||
xwords.vco
|
||||
xwords.vcw
|
||||
vc60.pdb
|
||||
obj_win32
|
||||
obj_wince
|
||||
*.xwg
|
||||
*.xwd
|
||||
_newgame
|
||||
xwDbgLog.txt
|
Loading…
Reference in a new issue