mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
Lots more changes, and some reversions. Win32, gtk and ncurses all
work now including saving/opening games. Network play probably doesn't as writing/reading a dict from stream has to change. It's doubtful patches from this branch will be merged. Rather, I'll take the concepts and crib some code when re-implementing. Concepts: XP_UCHAR becomes UTF-8 on both platforms, and on wince we translate to wchar_t just as now but from the utf-8 codepage. That keeps the work and risk to a minimum.
This commit is contained in:
parent
1ac648f3e6
commit
8f08667f5d
37 changed files with 492 additions and 476 deletions
|
@ -600,7 +600,7 @@ board_commitTurn( BoardCtxt* board )
|
|||
const XP_UCHAR* str = util_getUserString(board->util,
|
||||
STR_COMMIT_CONFIRM);
|
||||
|
||||
stream_putString( stream, str );
|
||||
stream_catString( stream, str );
|
||||
|
||||
warn = board->util->gameInfo->phoniesAction == PHONIES_WARN;
|
||||
|
||||
|
|
|
@ -358,7 +358,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
XP_Bool invert = XP_FALSE;
|
||||
XP_Bitmaps bitmaps;
|
||||
XP_Bitmaps* bptr = NULL;
|
||||
XP_UCHAR* textP = NULL;
|
||||
const XP_UCHAR* textP = NULL;
|
||||
HintAtts hintAtts;
|
||||
CellFlags flags = CELL_NONE;
|
||||
XP_Bool isOrigin;
|
||||
|
@ -392,15 +392,14 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
if ( board->showCellValues ) {
|
||||
Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
|
||||
XP_U16 val = dict_getTileValue( dict, valTile );
|
||||
XP_SNPRINTF( ch, sizeof(ch), XP_L("%d"), val );
|
||||
XP_SNPRINTF( ch, VSIZE(ch), XP_L("%d"), val );
|
||||
textP = ch;
|
||||
} else {
|
||||
if ( dict_faceIsBitmap( dict, tile ) ) {
|
||||
dict_getFaceBitmaps( dict, tile, &bitmaps );
|
||||
bptr = &bitmaps;
|
||||
}
|
||||
(void)dict_tilesToString( dict, &tile, 1, ch, sizeof(ch) );
|
||||
textP = ch;
|
||||
textP = dict_getTileString( dict, tile );
|
||||
}
|
||||
}
|
||||
bonus = util_getSquareBonus( board->util, model, col, row );
|
||||
|
@ -482,8 +481,7 @@ drawDragTileIf( BoardCtxt* board )
|
|||
XP_Rect rect;
|
||||
Tile tile;
|
||||
XP_Bool isBlank;
|
||||
XP_UCHAR buf[4];
|
||||
XP_UCHAR* face;
|
||||
const XP_UCHAR* face;
|
||||
XP_Bitmaps bitmaps;
|
||||
XP_S16 value;
|
||||
CellFlags flags;
|
||||
|
@ -493,7 +491,7 @@ drawDragTileIf( BoardCtxt* board )
|
|||
dragDropTileInfo( board, &tile, &isBlank );
|
||||
|
||||
face = getTileDrawInfo( board, tile, isBlank, &bitmaps,
|
||||
&value, buf, sizeof(buf) );
|
||||
&value );
|
||||
|
||||
flags = CELL_DRAGCUR;
|
||||
if ( isBlank ) {
|
||||
|
|
|
@ -269,9 +269,9 @@ void hideMiniWindow( BoardCtxt* board, XP_Bool destroy,
|
|||
void moveTileInTray( BoardCtxt* board, XP_U16 moveTo, XP_U16 moveFrom );
|
||||
XP_Bool handleTrayDuringTrade( BoardCtxt* board, XP_S16 index );
|
||||
|
||||
XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank,
|
||||
XP_Bitmaps* bitmaps, XP_S16* value,
|
||||
XP_UCHAR* buf, XP_U16 len );
|
||||
const XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile,
|
||||
XP_Bool isBlank, XP_Bitmaps* bitmaps,
|
||||
XP_S16* value );
|
||||
XP_Bool dividerMoved( BoardCtxt* board, XP_U8 newLoc );
|
||||
|
||||
XP_Bool checkScrollCell( BoardCtxt* board, XP_U16 col, XP_U16 row );
|
||||
|
|
|
@ -561,7 +561,7 @@ addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP )
|
|||
/* nothing to write */
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
stream_putString( stream, addr.u.bt.hostName );
|
||||
stringToStream( stream, addr.u.bt.hostName );
|
||||
/* sizeof(.bits) below defeats ARM's padding. */
|
||||
stream_putBytes( stream, &addr.u.bt.btAddr.bits,
|
||||
sizeof(addr.u.bt.btAddr.bits) );
|
||||
|
@ -570,18 +570,18 @@ addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP )
|
|||
/* nothing to save */
|
||||
break;
|
||||
case COMMS_CONN_IP_DIRECT:
|
||||
stream_putString( stream, addr.u.ip.hostName_ip );
|
||||
stringToStream( stream, addr.u.ip.hostName_ip );
|
||||
stream_putU32( stream, addr.u.ip.ipAddr_ip );
|
||||
stream_putU16( stream, addr.u.ip.port_ip );
|
||||
break;
|
||||
case COMMS_CONN_RELAY:
|
||||
stream_putString( stream, addr.u.ip_relay.cookie );
|
||||
stream_putString( stream, addr.u.ip_relay.hostName );
|
||||
stringToStream( stream, addr.u.ip_relay.cookie );
|
||||
stringToStream( stream, addr.u.ip_relay.hostName );
|
||||
stream_putU32( stream, addr.u.ip_relay.ipAddr );
|
||||
stream_putU16( stream, addr.u.ip_relay.port );
|
||||
break;
|
||||
case COMMS_CONN_SMS:
|
||||
stream_putString( stream, addr.u.sms.phone );
|
||||
stringToStream( stream, addr.u.sms.phone );
|
||||
stream_putU16( stream, addr.u.sms.port );
|
||||
break;
|
||||
default:
|
||||
|
@ -608,7 +608,7 @@ comms_writeToStream( const CommsCtxt* comms, XWStreamCtxt* stream )
|
|||
stream_putU16( stream, comms->nextChannelNo );
|
||||
if ( comms->addr.conType == COMMS_CONN_RELAY ) {
|
||||
stream_putU8( stream, comms->r.myHostID );
|
||||
stream_putString( stream, comms->r.connName );
|
||||
stringToStream( stream, comms->r.connName );
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -680,9 +680,8 @@ comms_getInitialAddr( CommsAddrRec* addr )
|
|||
addr->u.ip_relay.ipAddr = 0L; /* force 'em to set it */
|
||||
addr->u.ip_relay.port = 10999;
|
||||
{
|
||||
const XP_UCHAR* name = XP_L(RELAY_NAME_DEFAULT);
|
||||
XP_SNPRINTF( addr->u.ip_relay.hostName, VSIZE(addr->u.ip_relay.hostName),
|
||||
XP_L("%s"), name );
|
||||
char* name = RELAY_NAME_DEFAULT;
|
||||
XP_MEMCPY( addr->u.ip_relay.hostName, name, XP_STRLEN(name)+1 );
|
||||
}
|
||||
addr->u.ip_relay.cookie[0] = '\0';
|
||||
#elif defined PLATFORM_PALM
|
||||
|
@ -1059,7 +1058,7 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID )
|
|||
if ( hasName ) {
|
||||
stringFromStreamHere( stream, comms->r.connName,
|
||||
sizeof(comms->r.connName) );
|
||||
XP_LOGF( "read connName: " XP_LS, comms->r.connName );
|
||||
XP_LOGF( "read connName: %s", comms->r.connName );
|
||||
} else {
|
||||
XP_ASSERT( comms->r.connName[0] != '\0' );
|
||||
}
|
||||
|
@ -1526,42 +1525,41 @@ comms_getStats( CommsCtxt* comms, XWStreamCtxt* stream )
|
|||
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)"msg queue len: %d\n", comms->queueLen );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
for ( elem = comms->msgQueueHead; !!elem; elem = elem->next ) {
|
||||
XP_SNPRINTF( buf, sizeof(buf),
|
||||
XP_L(" - channelNo=%d; msgID=") XP_LD "; len=%d\n",
|
||||
elem->channelNo, elem->msgID, elem->len );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)"channel-less bytes sent: %d\n",
|
||||
comms->nUniqueBytes );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
now = util_getCurSeconds( comms->util );
|
||||
for ( rec = comms->recs; !!rec; rec = rec->next ) {
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)" Stats for channel: %d\n",
|
||||
rec->channelNo );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)"Last msg sent: " XP_LD "\n",
|
||||
rec->nextMsgID );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)"Unique bytes sent: %d\n",
|
||||
rec->nUniqueBytes );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
|
||||
(XP_UCHAR*)"Last message acknowledged: %d\n",
|
||||
rec->lastACK);
|
||||
stream_putString( stream, buf );
|
||||
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
} /* comms_getStats */
|
||||
#endif
|
||||
|
@ -1676,7 +1674,7 @@ send_via_relay( CommsCtxt* comms, XWRELAY_Cmd cmd, XWHostID destID,
|
|||
break;
|
||||
case XWRELAY_GAME_CONNECT:
|
||||
stream_putU8( tmpStream, XWRELAY_PROTO_VERSION );
|
||||
stream_putString( tmpStream, addr.u.ip_relay.cookie );
|
||||
stringToStream( tmpStream, addr.u.ip_relay.cookie );
|
||||
stream_putU8( tmpStream, comms->r.myHostID );
|
||||
stream_putU8( tmpStream, comms->r.nPlayersHere );
|
||||
stream_putU8( tmpStream, comms->r.nPlayersTotal );
|
||||
|
@ -1689,7 +1687,7 @@ send_via_relay( CommsCtxt* comms, XWRELAY_Cmd cmd, XWHostID destID,
|
|||
stream_putU8( tmpStream, comms->r.myHostID );
|
||||
stream_putU8( tmpStream, comms->r.nPlayersHere );
|
||||
stream_putU8( tmpStream, comms->r.nPlayersTotal );
|
||||
stream_putString( tmpStream, comms->r.connName );
|
||||
stringToStream( tmpStream, comms->r.connName );
|
||||
|
||||
comms->r.relayState = COMMS_RELAYSTATE_CONNECT_PENDING;
|
||||
break;
|
||||
|
|
|
@ -112,7 +112,6 @@ dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
|||
|
||||
while ( nTiles-- ) {
|
||||
Tile tile = *tiles++;
|
||||
/* XP_U16 index = ctxt->faceIndices[tile]; */
|
||||
const XP_UCHAR* facep = dict_getTileChar( ctxt, tile );
|
||||
|
||||
if ( IS_SPECIAL(*facep) ) {
|
||||
|
@ -132,8 +131,7 @@ dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
|||
bufp = NULL;
|
||||
break;
|
||||
}
|
||||
bufp += XP_SNPRINTF( bufp, end - bufp, XP_LS, facep );
|
||||
/* *bufp++ = face; */
|
||||
bufp += XP_SNPRINTF( bufp, end - bufp, XP_S, facep );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,6 +142,12 @@ dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
|||
return result;
|
||||
} /* dict_tilesToString */
|
||||
|
||||
const XP_UCHAR*
|
||||
dict_getTileString( const DictionaryCtxt* ctxt, Tile tile )
|
||||
{
|
||||
return dict_getTileChar( ctxt, tile );
|
||||
}
|
||||
|
||||
Tile
|
||||
dict_tileForString( const DictionaryCtxt* dict, const XP_UCHAR* key )
|
||||
{
|
||||
|
@ -215,6 +219,20 @@ dict_tilesAreSame( const DictionaryCtxt* dict1, const DictionaryCtxt* dict2 )
|
|||
return result;
|
||||
} /* dict_tilesAreSame */
|
||||
|
||||
static void
|
||||
ucharsToNarrow( const DictionaryCtxt* dict, XP_UCHAR* buf, XP_U16* bufsizep )
|
||||
{
|
||||
XP_U16 ii;
|
||||
XP_U16 nUsed = 0;
|
||||
XP_U16 bufsize = *bufsizep;
|
||||
for ( ii = 0; ii < dict->nFaces; ++ii ) {
|
||||
const XP_UCHAR* face = dict_getTileChar( dict, ii );
|
||||
nUsed += XP_SNPRINTF( &buf[nUsed], bufsize - nUsed, "%s", face );
|
||||
XP_ASSERT( nUsed < bufsize );
|
||||
}
|
||||
*bufsizep = nUsed;
|
||||
}
|
||||
|
||||
void
|
||||
dict_writeToStream( const DictionaryCtxt* dict, XWStreamCtxt* stream )
|
||||
{
|
||||
|
@ -250,15 +268,16 @@ dict_writeToStream( const DictionaryCtxt* dict, XWStreamCtxt* stream )
|
|||
stream_putBits( stream, maxValueBits, dict->countsAndValues[i+1] );
|
||||
}
|
||||
|
||||
for ( i = 0; i < dict->nFaces; ++i ) {
|
||||
XP_U16 index = dict->faceIndices[i];
|
||||
stream_putString( stream, &dict->faces[index] );
|
||||
}
|
||||
XP_UCHAR buf[64];
|
||||
XP_U16 nBytes = sizeof(buf);
|
||||
ucharsToNarrow( dict, buf, &nBytes );
|
||||
stream_putU8( stream, nBytes );
|
||||
stream_putBytes( stream, buf, nBytes );
|
||||
|
||||
for ( nSpecials = i = 0; i < dict->nFaces; ++i ) {
|
||||
const XP_UCHAR* facep = dict_getTileChar( dict, (Tile)i );
|
||||
if ( IS_SPECIAL( *facep ) ) {
|
||||
stream_putString( stream, dict->chars[nSpecials++] );
|
||||
stringToStream( stream, dict->chars[nSpecials++] );
|
||||
}
|
||||
}
|
||||
} /* dict_writeToStream */
|
||||
|
@ -270,7 +289,7 @@ freeSpecials( DictionaryCtxt* dict )
|
|||
XP_U16 nSpecials;
|
||||
|
||||
for ( nSpecials = t = 0; t < dict->nFaces; ++t ) {
|
||||
XP_UCHAR* facep = dict_getTileChar( dict, t );
|
||||
const XP_UCHAR* facep = dict_getTileChar( dict, t );
|
||||
if ( IS_SPECIAL( *facep ) ) {
|
||||
|
||||
XP_ASSERT( !!dict->chars[nSpecials] );
|
||||
|
@ -303,15 +322,13 @@ common_destructor( DictionaryCtxt* dict )
|
|||
|
||||
XP_FREE( dict->mpool, dict );
|
||||
} /* dict */
|
||||
#endif
|
||||
|
||||
void
|
||||
dict_loadFromStream( DictionaryCtxt* XP_UNUSED(dict),
|
||||
XWStreamCtxt* XP_UNUSED(stream) )
|
||||
dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_ASSERT(0);
|
||||
|
||||
XP_U8 nFaces;
|
||||
XP_U8 nFaces, nFaceBytes;
|
||||
XP_U16 maxCountBits, maxValueBits;
|
||||
XP_U16 i, nSpecials;
|
||||
XP_UCHAR* localTexts[32];
|
||||
|
@ -336,15 +353,15 @@ dict_loadFromStream( DictionaryCtxt* XP_UNUSED(dict),
|
|||
dict->countsAndValues[i+1] = (XP_U8)stream_getBits( stream,
|
||||
maxValueBits );
|
||||
}
|
||||
dict->faces = (XP_CHAR16*)XP_MALLOC( dict->mpool,
|
||||
sizeof(dict->faces[0]) * nFaces );
|
||||
for ( i = 0; i < dict->nFaces; ++i ) {
|
||||
dict->faces16[i] = (XP_CHAR16)stream_getU8( stream );
|
||||
}
|
||||
|
||||
nFaceBytes = (XP_U8)stream_getU8( stream );
|
||||
XP_U8 utf8[nFaceBytes];
|
||||
stream_getBytes( stream, utf8, nFaceBytes );
|
||||
dict_splitFaces( dict, utf8, nFaceBytes, nFaces );
|
||||
|
||||
for ( nSpecials = i = 0; i < nFaces; ++i ) {
|
||||
XP_UCHAR face = dict_getTileChar( dict, (Tile)i );
|
||||
if ( IS_SPECIAL( face ) ) {
|
||||
const XP_UCHAR* facep = dict_getTileChar( dict, (Tile)i );
|
||||
if ( IS_SPECIAL( *facep ) ) {
|
||||
XP_UCHAR* txt = stringFromStream( dict->mpool, stream );
|
||||
XP_ASSERT( !!txt );
|
||||
localTexts[nSpecials] = txt;
|
||||
|
|
|
@ -142,6 +142,7 @@ XP_U16 dict_numTileFaces( const DictionaryCtxt* ctxt );
|
|||
|
||||
XP_U16 dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
||||
XP_U16 nTiles, XP_UCHAR* buf, XP_U16 bufSize );
|
||||
const XP_UCHAR* dict_getTileString( const DictionaryCtxt* ctxt, Tile tile );
|
||||
const XP_UCHAR* dict_getName( const DictionaryCtxt* ctxt );
|
||||
|
||||
Tile dict_tileForString( const DictionaryCtxt* dict, const XP_UCHAR* key );
|
||||
|
@ -167,7 +168,9 @@ DictionaryCtxt* make_stubbed_dict( MPFORMAL_NOCOMMA );
|
|||
|
||||
/* To be called only by subclasses!!! */
|
||||
void dict_super_init( DictionaryCtxt* ctxt );
|
||||
|
||||
/* Must be implemented by subclass */
|
||||
void dict_splitFaces( DictionaryCtxt* dict, const XP_U8* bytes,
|
||||
XP_U16 nBytes, XP_U16 nFaces );
|
||||
|
||||
#ifdef CPLUS
|
||||
}
|
||||
|
|
|
@ -459,7 +459,7 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
|
|||
const LocalPlayer* pl;
|
||||
XP_U16 i;
|
||||
|
||||
stream_putString( stream, gi->dictName );
|
||||
stringToStream( stream, gi->dictName );
|
||||
|
||||
stream_putBits( stream, NPLAYERS_NBITS, gi->nPlayers );
|
||||
stream_putBits( stream, 4, gi->boardSize );
|
||||
|
@ -478,8 +478,8 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
|
|||
}
|
||||
|
||||
for ( pl = gi->players, i = 0; i < gi->nPlayers; ++pl, ++i ) {
|
||||
stream_putString( stream, pl->name );
|
||||
stream_putString( stream, pl->password );
|
||||
stringToStream( stream, pl->name );
|
||||
stringToStream( stream, pl->password );
|
||||
stream_putU16( stream, pl->secondsUsed );
|
||||
stream_putBits( stream, 1, pl->isRobot );
|
||||
stream_putBits( stream, 1, pl->isLocal );
|
||||
|
|
|
@ -245,9 +245,9 @@ mpool_free( MemPoolCtx* mpool, void* ptr, const char* file,
|
|||
|
||||
#define STREAM_OR_LOG(stream,buf) \
|
||||
if ( !!stream ) { \
|
||||
stream_putString( stream, buf ); \
|
||||
stream_catString( stream, buf ); \
|
||||
} else { \
|
||||
XP_LOGF( "%s", buf ); \
|
||||
XP_LOGF( XP_S, buf ); \
|
||||
} \
|
||||
|
||||
void
|
||||
|
|
|
@ -117,17 +117,6 @@ mem_stream_getU8( XWStreamCtxt* p_sctx )
|
|||
return result;
|
||||
} /* mem_stream_getU8 */
|
||||
|
||||
static XP_U16
|
||||
mem_stream_getString( XWStreamCtxt* p_sctx, XP_UCHAR* where, XP_U16 whereLen )
|
||||
{
|
||||
XP_U16 len = mem_stream_getU8( p_sctx );
|
||||
XP_U8 bytes[len * sizeof(XP_U8)];
|
||||
mem_stream_getBytes( p_sctx, bytes, len );
|
||||
|
||||
XP_NARROW_TO_UCHAR( bytes, where, len, &whereLen );
|
||||
return whereLen;
|
||||
}
|
||||
|
||||
static XP_U16
|
||||
mem_stream_getU16( XWStreamCtxt* p_sctx )
|
||||
{
|
||||
|
@ -226,17 +215,9 @@ mem_stream_putBytes( XWStreamCtxt* p_sctx, const void* whence,
|
|||
} /* mem_stream_putBytes */
|
||||
|
||||
static void
|
||||
mem_stream_putString( XWStreamCtxt* p_sctx, const XP_UCHAR* whence )
|
||||
mem_stream_catString( XWStreamCtxt* p_sctx, const char* whence )
|
||||
{
|
||||
XP_U16 wlen = 0;
|
||||
XP_U16 len = 0x00FF;
|
||||
XP_U8 bytes[0xFF];
|
||||
if ( !!whence ) {
|
||||
wlen = XP_STRLEN( whence );
|
||||
}
|
||||
|
||||
XP_UCHAR_TO_NARROW( whence, bytes, wlen, &len );
|
||||
|
||||
XP_U16 len = XP_STRLEN( whence );
|
||||
mem_stream_putBytes( p_sctx, (void*)whence, len );
|
||||
}
|
||||
|
||||
|
@ -451,14 +432,13 @@ make_vtable( MemStreamCtxt* stream )
|
|||
|
||||
SET_VTABLE_ENTRY( vtable, stream_getU8, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_getBytes, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_getString, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_getU16, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_getU32, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_getBits, mem );
|
||||
|
||||
SET_VTABLE_ENTRY( vtable, stream_putU8, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_putBytes, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_putString, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_catString, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_putU16, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_putU32, mem );
|
||||
SET_VTABLE_ENTRY( vtable, stream_putBits, mem );
|
||||
|
|
|
@ -1446,7 +1446,7 @@ notifyDictListeners( ModelCtxt* model, DictionaryCtxt* oldDict,
|
|||
static void
|
||||
printString( XWStreamCtxt* stream, const XP_UCHAR* str )
|
||||
{
|
||||
stream_putString( stream, str );
|
||||
stream_catString( stream, str );
|
||||
} /* printString */
|
||||
|
||||
static XP_UCHAR*
|
||||
|
@ -1676,7 +1676,7 @@ scoreLastMove( ModelCtxt* model, MoveInfo* moveInfo, XP_U16 howMany,
|
|||
const XP_UCHAR* str = util_getUserString( model->vol.util, STR_PASSED );
|
||||
XP_U16 len = XP_STRLEN( str );
|
||||
*bufLen = len;
|
||||
XP_MEMCPY( buf, str, len+1 ); /* no XP_STRCPY yet */
|
||||
XP_STRCPY( buf, str );
|
||||
} else {
|
||||
XP_U16 score;
|
||||
XP_UCHAR wordBuf[MAX_ROWS+1];
|
||||
|
|
|
@ -514,7 +514,7 @@ figureMoveScore( const ModelCtxt* model, MoveInfo* moveInfo,
|
|||
if ( !!stream ) {
|
||||
const XP_UCHAR* bstr = util_getUserString( model->vol.util,
|
||||
STR_BONUS_ALL );
|
||||
stream_putString( stream, bstr );
|
||||
stream_catString( stream, bstr );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,16 +760,17 @@ static void
|
|||
wordScoreFormatterAddTile( WordScoreFormatter* fmtr, Tile tile,
|
||||
XP_U16 tileMultiplier, XP_Bool isBlank )
|
||||
{
|
||||
XP_UCHAR buf[4];
|
||||
const XP_UCHAR* face;
|
||||
XP_UCHAR* fullBufPtr;
|
||||
XP_UCHAR* prefix;
|
||||
XP_U16 tileScore;
|
||||
|
||||
++fmtr->nTiles;
|
||||
|
||||
dict_tilesToString( fmtr->dict, &tile, 1, buf, sizeof(buf) );
|
||||
XP_ASSERT( XP_STRLEN(fmtr->wordBuf) + XP_STRLEN(buf) < sizeof(fmtr->wordBuf) );
|
||||
XP_STRCAT( fmtr->wordBuf, buf );
|
||||
face = dict_getTileString( fmtr->dict, tile );
|
||||
XP_ASSERT( XP_STRLEN(fmtr->wordBuf) + XP_STRLEN(face)
|
||||
< sizeof(fmtr->wordBuf) );
|
||||
XP_STRCAT( fmtr->wordBuf, face );
|
||||
if ( isBlank ) {
|
||||
tile = dict_getBlankTile( fmtr->dict );
|
||||
}
|
||||
|
@ -810,7 +811,7 @@ wordScoreFormatterFinish( WordScoreFormatter* fmtr, Tile* word, XWStreamCtxt* st
|
|||
}
|
||||
|
||||
if ( !!mainWord ) {
|
||||
XP_MEMCPY( mainWord, fmtr->wordBuf, XP_STRLEN(fmtr->wordBuf) + 1 );
|
||||
XP_STRCPY( mainWord, fmtr->wordBuf );
|
||||
}
|
||||
|
||||
} /* wordScoreFormatterFinish */
|
||||
|
@ -832,7 +833,7 @@ formatWordScore( XWStreamCtxt* stream, XP_U16 wordScore,
|
|||
}
|
||||
XP_ASSERT( XP_STRLEN(tmpBuf) < sizeof(tmpBuf) );
|
||||
|
||||
stream_putString( stream, tmpBuf );
|
||||
stream_catString( stream, tmpBuf );
|
||||
}
|
||||
} /* formatWordScore */
|
||||
|
||||
|
@ -844,7 +845,7 @@ formatSummary( XWStreamCtxt* stream, const ModelCtxt* model, XP_U16 score )
|
|||
util_getUserString(model->vol.util, STRD_TURN_SCORE),
|
||||
score);
|
||||
XP_ASSERT( XP_STRLEN(buf) < sizeof(buf) );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
} /* formatSummary */
|
||||
|
||||
#ifdef CPLUS
|
||||
|
|
|
@ -669,7 +669,7 @@ makeRobotMove( ServerCtxt* server )
|
|||
str = util_getUserString(util, STRD_ROBOT_TRADED);
|
||||
XP_SNPRINTF( buf, sizeof(buf), str, MAX_TRAY_TILES );
|
||||
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
XP_ASSERT( !server->vol.prevMoveStream );
|
||||
server->vol.prevMoveStream = stream;
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ showPrevScore( ServerCtxt* server )
|
|||
stream = mkServerStream( server );
|
||||
|
||||
str = util_getUserString( util, strCode );
|
||||
stream_putString( stream, str );
|
||||
stream_catString( stream, str );
|
||||
|
||||
if ( !!server->vol.prevMoveStream ) {
|
||||
XWStreamCtxt* prevStream = server->vol.prevMoveStream;
|
||||
|
@ -1160,7 +1160,7 @@ bwiToStream( XWStreamCtxt* stream, BadWordInfo* bwi )
|
|||
stream_putBits( stream, 4, nWords );
|
||||
|
||||
for ( sp = bwi->words; nWords > 0; --nWords, ++sp ) {
|
||||
stream_putString( stream, *sp );
|
||||
stringToStream( stream, *sp );
|
||||
}
|
||||
|
||||
} /* bwiToStream */
|
||||
|
@ -1618,7 +1618,7 @@ storeBadWords( XP_UCHAR* word, void* closure )
|
|||
{
|
||||
ServerCtxt* server = (ServerCtxt*)closure;
|
||||
|
||||
XP_STATUSF( "storeBadWords called with \"" XP_LS "\"", word );
|
||||
XP_STATUSF( "storeBadWords called with \"" XP_S "\"", word );
|
||||
|
||||
server->illegalWordInfo.words[server->illegalWordInfo.nWords++]
|
||||
= copyString( server->mpool, word );
|
||||
|
@ -1744,7 +1744,7 @@ makeTradeReportIf( ServerCtxt* server, const TrayTileSet* tradedTiles )
|
|||
XP_SNPRINTF( tradeBuf, sizeof(tradeBuf), tradeStr,
|
||||
tradedTiles->nTiles );
|
||||
stream = mkServerStream( server );
|
||||
stream_putString( stream, tradeBuf );
|
||||
stream_catString( stream, tradeBuf );
|
||||
}
|
||||
return stream;
|
||||
} /* makeTradeReportIf */
|
||||
|
@ -2398,33 +2398,32 @@ server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
|
|||
dict = model_getDictionary( server->vol.model );
|
||||
dname = dict_getShortName( dict );
|
||||
XP_SNPRINTF( buf, sizeof(buf), fmt, dname );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
|
||||
nChars = dict_numTileFaces( dict );
|
||||
|
||||
for ( tile = 0, nPrinted = 0; ; ) {
|
||||
XP_UCHAR buf[24];
|
||||
XP_UCHAR face[4];
|
||||
XP_U16 count, value;
|
||||
|
||||
count = dict_numTiles( dict, tile );
|
||||
|
||||
if ( count > 0 ) {
|
||||
dict_tilesToString( dict, &tile, 1, face, sizeof(face) );
|
||||
const XP_UCHAR* face = dict_getTileString( dict, tile );
|
||||
value = dict_getTileValue( dict, tile );
|
||||
|
||||
XP_SNPRINTF( buf, sizeof(buf), (XP_UCHAR*)"%s: %d/%d",
|
||||
XP_SNPRINTF( buf, sizeof(buf), "%s: %d/%d",
|
||||
face, count, value );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
|
||||
if ( ++tile >= nChars ) {
|
||||
break;
|
||||
} else if ( count > 0 ) {
|
||||
if ( ++nPrinted % nCols == 0 ) {
|
||||
stream_putString( stream, XP_L(XP_CR) );
|
||||
stream_catString( stream, XP_L(XP_CR) );
|
||||
} else {
|
||||
stream_putString( stream, (void*)" " );
|
||||
stream_catString( stream, (void*)" " );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2461,22 +2460,22 @@ server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream,
|
|||
XP_Bool hasCount = count > 0;
|
||||
|
||||
if ( hasCount ) {
|
||||
XP_UCHAR face[4];
|
||||
dict_tilesToString( dict, &tile, 1, face, sizeof(face) );
|
||||
const XP_UCHAR* face;
|
||||
face = dict_getTileString( dict, tile );
|
||||
|
||||
for ( ; ; ) {
|
||||
stream_putString( stream, face );
|
||||
stream_catString( stream, face );
|
||||
if ( --count == 0 ) {
|
||||
break;
|
||||
}
|
||||
stream_putString( stream, XP_L(".") );
|
||||
stream_catString( stream, XP_L(".") );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ++tile >= nChars ) {
|
||||
break;
|
||||
} else if ( hasCount ) {
|
||||
stream_putString( stream, (void*)" " );
|
||||
stream_catString( stream, XP_L(" ") );
|
||||
}
|
||||
}
|
||||
} /* server_formatRemainingTiles */
|
||||
|
@ -2524,7 +2523,7 @@ server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
if ( highestIndex == -1 ) {
|
||||
break; /* we're done */
|
||||
} else if ( place > 1 ) {
|
||||
stream_putString( stream, XP_L(XP_CR) );
|
||||
stream_catString( stream, XP_L(XP_CR) );
|
||||
}
|
||||
scores.arr[highestIndex] = IMPOSSIBLY_LOW_SCORE;
|
||||
|
||||
|
@ -2555,7 +2554,7 @@ server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
place,
|
||||
emptyStringIfNull(gi->players[highestIndex].name),
|
||||
highestScore, curScore, tmpbuf, timeStr );
|
||||
stream_putString( stream, buf );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
} /* server_writeFinalScores */
|
||||
|
||||
|
|
|
@ -123,20 +123,27 @@ p_stringFromStream( MPFORMAL XWStreamCtxt* stream
|
|||
XP_U16
|
||||
stringFromStreamHere( XWStreamCtxt* stream, XP_UCHAR* buf, XP_U16 buflen )
|
||||
{
|
||||
XP_U16 len = stream_getString( stream, buf, buflen );
|
||||
XP_ASSERT( len < buflen );
|
||||
XP_U16 len = stream_getU8( stream );
|
||||
if ( len > 0 ) {
|
||||
XP_ASSERT( len < buflen );
|
||||
if ( len >= buflen ) {
|
||||
/* better to leave stream in bad state than overwrite stack */
|
||||
len = buflen - 1;
|
||||
}
|
||||
stream_getBytes( stream, buf, len );
|
||||
}
|
||||
buf[len] = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
/* void */
|
||||
/* stringToStream( XWStreamCtxt* stream, const XP_UCHAR* str ) */
|
||||
/* { */
|
||||
/* XP_U16 len = str==NULL? 0: XP_STRLEN( str ); */
|
||||
/* XP_ASSERT( len < 0xFF ); */
|
||||
/* stream_putU8( stream, (XP_U8)len ); */
|
||||
/* stream_putBytes( stream, str, len ); */
|
||||
/* } /\* putStringToStream *\/ */
|
||||
void
|
||||
stringToStream( XWStreamCtxt* stream, const XP_UCHAR* str )
|
||||
{
|
||||
XP_U16 len = str==NULL? 0: XP_STRLEN( str );
|
||||
XP_ASSERT( len < 0xFF );
|
||||
stream_putU8( stream, (XP_U8)len );
|
||||
stream_putBytes( stream, str, len );
|
||||
} /* putStringToStream */
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
@ -150,7 +157,7 @@ p_copyString( MPFORMAL const XP_UCHAR* instr
|
|||
{
|
||||
XP_UCHAR* result = (XP_UCHAR*)NULL;
|
||||
if ( !!instr ) {
|
||||
XP_U16 len = 1 + XP_STRLEN( instr );
|
||||
XP_U16 len = 1 + XP_STRLEN( (const char*)instr );
|
||||
#ifdef MEM_DEBUG
|
||||
result = mpool_alloc( mpool, len, file, func, lineNo );
|
||||
#else
|
||||
|
@ -367,11 +374,11 @@ log_hex( const XP_U8* memp, XP_U16 len, const char* tag )
|
|||
XP_U16 offset = 0;
|
||||
|
||||
while ( offset < len ) {
|
||||
char buf[128];
|
||||
char vals[NUM_PER_LINE*3];
|
||||
char* valsp = vals;
|
||||
char chars[NUM_PER_LINE+1];
|
||||
char* charsp = chars;
|
||||
XP_UCHAR buf[128];
|
||||
XP_UCHAR vals[NUM_PER_LINE*3];
|
||||
XP_UCHAR* valsp = vals;
|
||||
XP_UCHAR chars[NUM_PER_LINE+1];
|
||||
XP_UCHAR* charsp = chars;
|
||||
XP_U16 oldOffset = offset;
|
||||
|
||||
for ( i = 0; i < NUM_PER_LINE && offset < len; ++i ) {
|
||||
|
@ -399,7 +406,7 @@ log_hex( const XP_U8* memp, XP_U16 len, const char* tag )
|
|||
if ( (NULL == tag) || (XP_STRLEN(tag) + sizeof(vals) >= sizeof(buf)) ) {
|
||||
tag = "<tag>";
|
||||
}
|
||||
XP_SNPRINTF( buf, VSIZE(buf), "%s[%d]: %s %s", tag, oldOffset,
|
||||
XP_SNPRINTF( buf, sizeof(buf), "%s[%d]: %s %s", tag, oldOffset,
|
||||
vals, chars );
|
||||
XP_LOGF( "%s", buf );
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ XP_UCHAR* p_stringFromStream( MPFORMAL XWStreamCtxt* stream
|
|||
#endif
|
||||
|
||||
XP_U16 stringFromStreamHere( XWStreamCtxt* stream, XP_UCHAR* buf, XP_U16 len );
|
||||
/* void stringToStream( XWStreamCtxt* stream, const XP_UCHAR* str ); */
|
||||
void stringToStream( XWStreamCtxt* stream, const XP_UCHAR* str );
|
||||
|
||||
XP_UCHAR* p_copyString( MPFORMAL const XP_UCHAR* instr
|
||||
#ifdef MEM_DEBUG
|
||||
|
|
|
@ -186,9 +186,8 @@ drawTray( BoardCtxt* board )
|
|||
draw_drawTile( board->draw, &tileRect, NULL,
|
||||
NULL, -1, flags | CELL_ISEMPTY );
|
||||
} else if ( showFaces ) {
|
||||
XP_UCHAR buf[4];
|
||||
XP_Bitmaps bitmaps;
|
||||
XP_UCHAR* textP = (XP_UCHAR*)NULL;
|
||||
const XP_UCHAR* textP = (XP_UCHAR*)NULL;
|
||||
XP_U8 traySelBits = pti->traySelBits;
|
||||
XP_S16 value;
|
||||
Tile tile;
|
||||
|
@ -211,8 +210,7 @@ drawTray( BoardCtxt* board )
|
|||
}
|
||||
|
||||
textP = getTileDrawInfo( board, tile, isBlank,
|
||||
&bitmaps, &value,
|
||||
buf, sizeof(buf) );
|
||||
&bitmaps, &value );
|
||||
if ( isADrag ) {
|
||||
if ( ddAddedIndx == ii ) {
|
||||
flags |= CELL_HIGHLIGHT;
|
||||
|
@ -258,18 +256,16 @@ drawTray( BoardCtxt* board )
|
|||
|
||||
} /* drawTray */
|
||||
|
||||
XP_UCHAR*
|
||||
const XP_UCHAR*
|
||||
getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank,
|
||||
XP_Bitmaps* bitmaps, XP_S16* value, XP_UCHAR* buf,
|
||||
XP_U16 len )
|
||||
XP_Bitmaps* bitmaps, XP_S16* value )
|
||||
{
|
||||
XP_UCHAR* face = NULL;
|
||||
const XP_UCHAR* face = NULL;
|
||||
DictionaryCtxt* dict = model_getDictionary( board->model );
|
||||
if ( isBlank ) {
|
||||
tile = dict_getBlankTile( dict );
|
||||
} else {
|
||||
dict_tilesToString( dict, &tile, 1, buf, len );
|
||||
face = buf;
|
||||
face = dict_getTileString( dict, tile );
|
||||
}
|
||||
|
||||
*value = dict_getTileValue( dict, tile );
|
||||
|
|
|
@ -45,8 +45,6 @@ typedef struct StreamCtxVTable {
|
|||
XP_U8 (*m_stream_getU8)( XWStreamCtxt* dctx );
|
||||
void (*m_stream_getBytes)( XWStreamCtxt* dctx, void* where,
|
||||
XP_U16 count );
|
||||
XP_U16 (*m_stream_getString)( XWStreamCtxt* dctx, XP_UCHAR* where,
|
||||
XP_U16 nChars );
|
||||
XP_U16 (*m_stream_getU16)( XWStreamCtxt* dctx );
|
||||
XP_U32 (*m_stream_getU32)( XWStreamCtxt* dctx );
|
||||
XP_U32 (*m_stream_getBits)( XWStreamCtxt* dctx, XP_U16 nBits );
|
||||
|
@ -54,7 +52,7 @@ typedef struct StreamCtxVTable {
|
|||
void (*m_stream_putU8)( XWStreamCtxt* dctx, XP_U8 byt );
|
||||
void (*m_stream_putBytes)( XWStreamCtxt* dctx, const void* whence,
|
||||
XP_U16 count );
|
||||
void (*m_stream_putString)( XWStreamCtxt* dctx, const XP_UCHAR* whence );
|
||||
void (*m_stream_catString)( XWStreamCtxt* dctx, const char* whence );
|
||||
void (*m_stream_putU16)( XWStreamCtxt* dctx, XP_U16 data );
|
||||
void (*m_stream_putU32)( XWStreamCtxt* dctx, XP_U32 data );
|
||||
void (*m_stream_putBits)( XWStreamCtxt* dctx, XP_U16 nBits, XP_U32 bits
|
||||
|
@ -100,9 +98,6 @@ struct XWStreamCtxt {
|
|||
#define stream_getBytes(sc, wh, c ) \
|
||||
(sc)->vtable->m_stream_getBytes((sc), (wh), (c))
|
||||
|
||||
#define stream_getString(sc, wh, c) \
|
||||
(sc)->vtable->m_stream_getString((sc), (wh), (c))
|
||||
|
||||
#define stream_getU16(sc) \
|
||||
(sc)->vtable->m_stream_getU16(sc)
|
||||
|
||||
|
@ -118,8 +113,8 @@ struct XWStreamCtxt {
|
|||
#define stream_putBytes( sc, w, c ) \
|
||||
(sc)->vtable->m_stream_putBytes((sc), (w), (c))
|
||||
|
||||
#define stream_putString( sc, w ) \
|
||||
(sc)->vtable->m_stream_putString((sc), (w))
|
||||
#define stream_catString( sc, w ) \
|
||||
(sc)->vtable->m_stream_catString((sc), (w))
|
||||
|
||||
#define stream_putU16(sc, d) \
|
||||
(sc)->vtable->m_stream_putU16((sc), (d))
|
||||
|
|
|
@ -232,7 +232,8 @@ curses_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* XP_UNUSED(pi),
|
|||
XP_UCHAR* playerName = globals->cGlobals.params->gi.players[playerNum].name;
|
||||
|
||||
XP_SNPRINTF( query, VSIZE(query),
|
||||
XP_L(Pick tile for %s! (Tab or type letter to select then hit <cr>.)), playerName );
|
||||
XP_L("Pick tile for %s! (Tab or type letter to select then ")
|
||||
XP_L("hit <cr>."), playerName );
|
||||
|
||||
index = curses_askLetter( globals, query, texts, nTiles );
|
||||
return index;
|
||||
|
|
|
@ -29,7 +29,7 @@ gtkask( const XP_UCHAR *message, GtkButtonsType buttons )
|
|||
GtkWidget* dlg = gtk_message_dialog_new( NULL, /* parent */
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_DIALOG_MODAL,
|
||||
buttons, XP_LS, message );
|
||||
buttons, XP_S, message );
|
||||
gint response = gtk_dialog_run( GTK_DIALOG(dlg) );
|
||||
gtk_widget_destroy( dlg );
|
||||
return response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES;
|
||||
|
|
|
@ -202,7 +202,7 @@ draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
|
|||
layout = layout_for_ht( dctx, fontHt );
|
||||
}
|
||||
|
||||
pango_layout_set_text( layout, (char*)str, XP_STRLEN(str) );
|
||||
pango_layout_set_text( layout, str, XP_STRLEN(str) );
|
||||
|
||||
if ( just != XP_GTK_JUST_NONE ) {
|
||||
int width, height;
|
||||
|
@ -466,7 +466,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
|||
}
|
||||
}
|
||||
if ( (flags & CELL_ISSTAR) != 0 ) {
|
||||
draw_string_at( dctx, NULL, XP_L(*), rect->height, rect,
|
||||
draw_string_at( dctx, NULL, XP_L("*"), rect->height, rect,
|
||||
XP_GTK_JUST_CENTER, &dctx->black, NULL );
|
||||
}
|
||||
} else if ( !!bitmaps ) {
|
||||
|
@ -577,7 +577,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
|||
}
|
||||
|
||||
if ( !valHidden ) {
|
||||
XP_SNPRINTF( numbuf, VSIZE(numbuf), XP_L(%d), val );
|
||||
XP_SNPRINTF( numbuf, VSIZE(numbuf), XP_L("%d"), val );
|
||||
len = XP_STRLEN( numbuf );
|
||||
|
||||
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
|
||||
|
@ -638,7 +638,7 @@ gtk_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
gtkInsetRect( &r, 1 );
|
||||
gtkFillRect( dctx, &r, hasCursor? &dctx->cursor : &dctx->tileBack );
|
||||
|
||||
draw_string_at( dctx, NULL, XP_L(?), r.height,
|
||||
draw_string_at( dctx, NULL, XP_L("?"), r.height,
|
||||
&r, XP_GTK_JUST_CENTER,
|
||||
&dctx->playerColors[dctx->trayOwner], NULL );
|
||||
|
||||
|
@ -690,7 +690,7 @@ gtk_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP,
|
|||
HintAtts hintAtts, CellFlags XP_UNUSED(flags) )
|
||||
{
|
||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||
const XP_UCHAR* curs = vertical? XP_L(|):XP_L(-);
|
||||
const XP_UCHAR* curs = vertical? XP_L("|"):XP_L("-");
|
||||
|
||||
/* font needs to be small enough that "|" doesn't overwrite cell below */
|
||||
draw_string_at( dctx, NULL, curs, (rectP->height*2)/3,
|
||||
|
@ -746,7 +746,7 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
|||
XP_UCHAR buf[10];
|
||||
PangoLayout* layout;
|
||||
|
||||
XP_SNPRINTF( buf, sizeof(buf), XP_L(rem:%d), nTilesLeft );
|
||||
XP_SNPRINTF( buf, sizeof(buf), XP_L("rem:%d"), nTilesLeft );
|
||||
layout = getLayoutToFitRect( dctx, buf, rect );
|
||||
|
||||
if ( !!widthP ) {
|
||||
|
@ -804,13 +804,13 @@ formatScoreText( XP_UCHAR* buf, XP_U16 bufLen, const DrawScoreInfo* dsi )
|
|||
borders = "*";
|
||||
}
|
||||
|
||||
used = XP_SNPRINTF( buf, bufLen, XP_L(%s%.3d), borders, score );
|
||||
used = XP_SNPRINTF( buf, bufLen, XP_L("%s%.3d"), borders, score );
|
||||
if ( (nTilesLeft < MAX_TRAY_TILES) && (nTilesLeft > 0) ) {
|
||||
XP_UCHAR nbuf[10];
|
||||
XP_SNPRINTF( nbuf, VSIZE(nbuf), XP_L(:%d), nTilesLeft );
|
||||
XP_SNPRINTF( nbuf, VSIZE(nbuf), XP_L(":%d"), nTilesLeft );
|
||||
(void)XP_STRCAT( buf, nbuf );
|
||||
}
|
||||
XP_SNPRINTF( buf+used, bufLen-used, XP_L(%s), borders );
|
||||
XP_SNPRINTF( buf+used, bufLen-used, XP_L("%s"), borders );
|
||||
} /* formatScoreText */
|
||||
|
||||
static void
|
||||
|
@ -881,9 +881,9 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
? &dctx->cursor : NULL;
|
||||
|
||||
if ( score >= 0 ) {
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L(%.3d), score );
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L("%.3d"), score );
|
||||
} else {
|
||||
XP_STRNCPY( buf, XP_L(\?\?\?), VSIZE(buf) );
|
||||
XP_STRNCPY( buf, XP_L("???"), VSIZE(buf) );
|
||||
}
|
||||
|
||||
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */
|
||||
|
@ -898,7 +898,7 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
}
|
||||
|
||||
ht = localR.height >> 2;
|
||||
draw_string_at( dctx, NULL, XP_L(Pts:), ht,
|
||||
draw_string_at( dctx, NULL, XP_L("Pts:"), ht,
|
||||
&localR, XP_GTK_JUST_TOPLEFT,
|
||||
&dctx->black, cursor );
|
||||
draw_string_at( dctx, NULL, buf, ht,
|
||||
|
@ -919,7 +919,7 @@ gtkFormatTimerText( XP_UCHAR* buf, XP_S16 secondsLeft )
|
|||
|
||||
minutes = secondsLeft / 60;
|
||||
seconds = secondsLeft % 60;
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L(% 1d:%02d), minutes, seconds );
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L("% 1d:%02d"), minutes, seconds );
|
||||
} /* gtkFormatTimerText */
|
||||
|
||||
static void
|
||||
|
@ -951,15 +951,15 @@ gtk_draw_getMiniWText( DrawCtx* XP_UNUSED(p_dctx), XWMiniTextType textHint )
|
|||
|
||||
switch( textHint ) {
|
||||
case BONUS_DOUBLE_LETTER:
|
||||
str = XP_L(Double letter); break;
|
||||
str = XP_L("Double letter"); break;
|
||||
case BONUS_DOUBLE_WORD:
|
||||
str = XP_L(Double word); break;
|
||||
str = XP_L("Double word"); break;
|
||||
case BONUS_TRIPLE_LETTER:
|
||||
str = XP_L(Triple letter); break;
|
||||
str = XP_L("Triple letter"); break;
|
||||
case BONUS_TRIPLE_WORD:
|
||||
str = XP_L(Triple word); break;
|
||||
str = XP_L("Triple word"); break;
|
||||
case INTRADE_MW_TEXT:
|
||||
str = XP_L(Trading tiles;\nclick D when done); break;
|
||||
str = XP_L("Trading tiles;\nclick D when done"); break;
|
||||
default:
|
||||
XP_ASSERT( XP_FALSE );
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ final_scores( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
|||
if ( gameOver ) {
|
||||
printFinalScores( globals );
|
||||
} else {
|
||||
if ( gtkask( XP_L(Are you sure everybody wants to end the game now?),
|
||||
if ( gtkask( XP_L("Are you sure everybody wants to end the game now?"),
|
||||
GTK_BUTTONS_YES_NO ) ) {
|
||||
server_endGame( globals->cGlobals.game.server );
|
||||
gameOver = TRUE;
|
||||
|
@ -1165,9 +1165,8 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
|||
quit( NULL, globals );
|
||||
} else if ( globals->cGlobals.params->undoWhenDone ) {
|
||||
server_handleUndo( globals->cGlobals.game.server );
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
}
|
||||
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
} /* gtk_util_notifyGameOver */
|
||||
|
||||
/* define this to prevent user events during debugging from stopping the engine */
|
||||
|
@ -1315,8 +1314,8 @@ idle_func( gpointer data )
|
|||
gtk_idle_remove( globals->idleID );
|
||||
|
||||
if ( server_do( globals->cGlobals.game.server ) ) {
|
||||
XP_ASSERT( globals->cGlobals.game.board != NULL );
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
if ( NULL != globals->cGlobals.game.board )
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
}
|
||||
return 0; /* 0 will stop it from being called again */
|
||||
} /* idle_func */
|
||||
|
@ -1344,7 +1343,7 @@ gtk_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
|||
|
||||
for ( i = 0, wordsBuf[0] = '\0'; ; ) {
|
||||
char wordBuf[18];
|
||||
sprintf( wordBuf, "\"" XP_LS "\"", bwi->words[i] );
|
||||
sprintf( wordBuf, "\"" XP_S "\"", bwi->words[i] );
|
||||
strcat( wordsBuf, wordBuf );
|
||||
if ( ++i == bwi->nWords ) {
|
||||
break;
|
||||
|
@ -1357,7 +1356,7 @@ gtk_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
|||
player+1, name, wordsBuf );
|
||||
|
||||
if ( globals->cGlobals.params->skipWarnings ) {
|
||||
XP_LOGF( XP_LS, buf );
|
||||
XP_LOGF( XP_S, buf );
|
||||
} else {
|
||||
gtkUserError( globals, buf );
|
||||
}
|
||||
|
@ -1365,8 +1364,9 @@ gtk_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
|||
} else {
|
||||
XP_ASSERT( bwi->nWords == 1 );
|
||||
XP_SNPRINTF( buf, VSIZE(buf),
|
||||
XP_L(Word ) "\"%s\""
|
||||
XP_L(not in the current dictionary. Use it anyway?), bwi->words[0] );
|
||||
XP_L("Word" ) "\"%s\""
|
||||
XP_L("not in the current dictionary. Use it anyway?"),
|
||||
bwi->words[0] );
|
||||
result = gtkask( buf, GTK_BUTTONS_YES_NO );
|
||||
}
|
||||
|
||||
|
@ -1426,7 +1426,7 @@ gtk_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
XP_LOGF( "%s(%d)", __func__, id );
|
||||
|
||||
if ( silent ) {
|
||||
XP_LOGF( XP_LS, message );
|
||||
XP_LOGF( XP_S, message );
|
||||
} else {
|
||||
gtkUserError( globals, message );
|
||||
}
|
||||
|
@ -1448,7 +1448,7 @@ gtk_util_userQuery( XW_UtilCtxt* XP_UNUSED(uc), UtilQueryID id,
|
|||
freeMe = XP_TRUE;
|
||||
break;
|
||||
case QUERY_COMMIT_TRADE:
|
||||
question = XP_L(Are you sure you want to trade the selected tiles?);
|
||||
question = XP_L("Are you sure you want to trade the selected tiles?");
|
||||
break;
|
||||
case QUERY_ROBOT_MOVE:
|
||||
case QUERY_ROBOT_TRADE:
|
||||
|
|
|
@ -446,7 +446,7 @@ gtk_newgame_col_set( void* closure, XP_U16 player, NewGameColumn col,
|
|||
switch ( col ) {
|
||||
case NG_COL_NAME:
|
||||
case NG_COL_PASSWD: {
|
||||
cp = value.ng_cp? value.ng_cp : XP_L( );
|
||||
cp = value.ng_cp? value.ng_cp : XP_L(" ");
|
||||
/* gchar tmp[(sizeof(XP_UCHAR) * wcslen(cp))+6]; */
|
||||
/* const XP_UCHAR* src = cp; */
|
||||
/* mbstate_t ps = {0}; */
|
||||
|
|
|
@ -49,7 +49,7 @@ gtkpasswdask( const XP_UCHAR* name, XP_UCHAR* outbuf, XP_U16* buflen )
|
|||
dialog = gtk_dialog_new();
|
||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||
|
||||
snprintf( buf, sizeof(buf), "Password for player \"" XP_LS "\"", name );
|
||||
snprintf( buf, sizeof(buf), "Password for player \"" XP_S "\"", name );
|
||||
label = gtk_label_new( buf );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
|
||||
|
@ -83,7 +83,7 @@ gtkpasswdask( const XP_UCHAR* name, XP_UCHAR* outbuf, XP_U16* buflen )
|
|||
|
||||
if ( ok ) {
|
||||
const char* text = gtk_entry_get_text( GTK_ENTRY(entry) );
|
||||
*buflen = XP_SNPRINTF( outbuf, *buflen, XP_L(%s), text );
|
||||
*buflen = XP_SNPRINTF( outbuf, *buflen, XP_L("%s"), text );
|
||||
}
|
||||
|
||||
gtk_widget_destroy( dialog );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */
|
||||
/*
|
||||
* Copyright 1997-2002 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 1997-2009 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -150,7 +151,7 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, FILE* dictF )
|
|||
text[txtlen] = '\0';
|
||||
texts[(XP_U16)*facep] = text;
|
||||
|
||||
XP_DEBUGF( "skipping bitmaps for " XP_LS, texts[asIndex] );
|
||||
XP_DEBUGF( "skipping bitmaps for " XP_S, texts[asIndex] );
|
||||
|
||||
bitmaps[asIndex].largeBM = skipBitmap( ctxt, dictF );
|
||||
bitmaps[asIndex].smallBM = skipBitmap( ctxt, dictF );
|
||||
|
@ -163,16 +164,16 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, FILE* dictF )
|
|||
ctxt->super.bitmaps = bitmaps;
|
||||
} /* skipBitmaps */
|
||||
|
||||
static void
|
||||
splitFaces( LinuxDictionaryCtxt* dctx, XP_UCHAR* bytes,
|
||||
XP_U16 nFaces, XP_U16 nFaceBytes )
|
||||
void
|
||||
dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
||||
XP_U16 nBytes, XP_U16 nFaces )
|
||||
{
|
||||
XP_UCHAR* faces = XP_MALLOC( dctx->super.mpool,
|
||||
nFaces + nFaceBytes );
|
||||
XP_U16* indices = XP_MALLOC( dctx->super.mpool, nFaces * sizeof(indices[0]));
|
||||
XP_UCHAR* faces = XP_MALLOC( dict->mpool, nBytes + nFaces );
|
||||
XP_U16* indices = XP_MALLOC( dict->mpool, nFaces * sizeof(indices[0]));
|
||||
XP_U16 ii;
|
||||
XP_Bool isUTF8 = dctx->super.isUTF8;
|
||||
XP_Bool isUTF8 = dict->isUTF8;
|
||||
XP_UCHAR* next = faces;
|
||||
const gchar* bytes = (const gchar*)utf8;
|
||||
|
||||
for ( ii = 0; ii < nFaces; ++ii ) {
|
||||
indices[ii] = next - faces;
|
||||
|
@ -189,12 +190,12 @@ splitFaces( LinuxDictionaryCtxt* dctx, XP_UCHAR* bytes,
|
|||
}
|
||||
*next++ = '\0';
|
||||
}
|
||||
XP_ASSERT( next == faces + nFaces + nFaceBytes );
|
||||
XP_ASSERT( !dctx->super.faces );
|
||||
dctx->super.faces = faces;
|
||||
XP_ASSERT( !dctx->super.faceIndices );
|
||||
dctx->super.faceIndices = indices;
|
||||
} /* splitFaces */
|
||||
XP_ASSERT( next == faces + nFaces + nBytes );
|
||||
XP_ASSERT( !dict->faces );
|
||||
dict->faces = faces;
|
||||
XP_ASSERT( !dict->faceIndices );
|
||||
dict->faceIndices = indices;
|
||||
} /* dict_splitFaces */
|
||||
|
||||
static XP_Bool
|
||||
initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName )
|
||||
|
@ -274,44 +275,13 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName )
|
|||
if ( !isUTF8 ) {
|
||||
facesSize /= 2;
|
||||
}
|
||||
/* dctx->super.faces = XP_MALLOC( dctx->super.mpool, facesSize ); */
|
||||
/* XP_MEMSET( dctx->super.faces, 0, facesSize ); */
|
||||
|
||||
gchar tmp[numFaceBytes];
|
||||
XP_U8 tmp[numFaceBytes];
|
||||
if ( 1 != fread( tmp, numFaceBytes, 1, dictF ) ) {
|
||||
goto closeAndExit;
|
||||
}
|
||||
|
||||
/* if ( isUTF8 ) { */
|
||||
/* XP_MEMCPY( dctx->super.faces, tmp, numFaceBytes ); */
|
||||
/* } else { */
|
||||
/* XP_U16 ii; */
|
||||
/* XP_ASSERT( 1 == sizeof(dctx->super.faces[0]) ); */
|
||||
/* for ( ii = 0; ii < numFaces; ++ii ) { */
|
||||
/* dctx->super.faces[ii] = tmp[ii*2]; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* XP_ASSERT( !dctx->super.faceIndices ); */
|
||||
/* dctx->super.faceIndices = */
|
||||
/* XP_MALLOC( dctx->super.mpool, */
|
||||
/* numFaces * sizeof(dctx->super.faceIndices[0]) ); */
|
||||
splitFaces( dctx, tmp, numFaces, numFaceBytes );
|
||||
|
||||
/* if ( charSize == sizeof(dctx->super.faces[0]) ) { */
|
||||
/* /\* fix endianness *\/ */
|
||||
/* XP_U16 i; */
|
||||
/* for ( i = 0; i < numFaces; ++i ) { */
|
||||
/* XP_UCHAR tmp = dctx->super.faces[i]; */
|
||||
/* dctx->super.faces[i] = ntohs(tmp); */
|
||||
/* } */
|
||||
/* } else { */
|
||||
/* XP_UCHAR* src = ((XP_UCHAR*)(dctx->super.faces)) + numFaces; */
|
||||
/* XP_UCHAR* dest = dctx->super.faces + numFaces; */
|
||||
/* while ( src-- <= (XP_UCHAR*)(dest--) ) { */
|
||||
/* *dest = (XP_UCHAR)*src; */
|
||||
/* } */
|
||||
/* } */
|
||||
dict_splitFaces( &dctx->super, tmp, numFaceBytes, numFaces );
|
||||
|
||||
if ( (1 != fread( &xloc, 2, 1, dictF ) )/* read in (dump) the xloc
|
||||
header for now */
|
||||
|
|
|
@ -108,7 +108,7 @@ linux_sms_init( CommonGlobals* globals, const CommsAddrRec* addr )
|
|||
XP_STRNCPY( data->myPhone, addr->u.sms.phone,
|
||||
sizeof(data->myPhone) );
|
||||
} else {
|
||||
XP_SNPRINTF( data->myPhone, sizeof(data->myPhone), XP_L(%.6d),
|
||||
XP_SNPRINTF( data->myPhone, sizeof(data->myPhone), XP_L("%.6d"),
|
||||
getpid() );
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,9 @@ typedef gchar XP_UCHAR;
|
|||
/* typedef gunichar XP_UCHAR; */
|
||||
/* # define XP_L(s) L##s */
|
||||
/* # define XP_LS "%ls" */
|
||||
# define XP_L(s) ""#s
|
||||
# define XP_LS "%s"
|
||||
# define XP_L(s) s
|
||||
/* # define XP_LS XP_L("%s") */
|
||||
# define XP_S XP_L("%s")
|
||||
#else
|
||||
typedef char XP_UCHAR;
|
||||
# define XP_L(s) ##s
|
||||
|
@ -72,7 +73,7 @@ typedef guint32 XP_Time;
|
|||
typedef unsigned long XP_Time;
|
||||
#endif
|
||||
|
||||
#define XP_CR XP_L(\\n)
|
||||
#define XP_CR XP_L("\n")
|
||||
|
||||
#define XP_STATUSF XP_DEBUGF
|
||||
#define XP_LOGF XP_DEBUGF
|
||||
|
@ -127,21 +128,23 @@ extern void linux_debugf(const char*, ...)
|
|||
#define XP_STRNCMP(s1,s2,len) strncmp((s1),(s2),(len))
|
||||
#define XP_CSTRLEN XP_STRLEN
|
||||
#define XP_STRNCPY(s1,s2,len) strncpy((s1),(s2),(len))
|
||||
#define XP_STRCPY(s1,s2) strcpy((s1),(s2))
|
||||
#endif
|
||||
#define XP_STRCPY(s1,s2) strcpy((s1),(s2))
|
||||
|
||||
|
||||
#define XP_MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#define XP_MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define XP_ABS(a) ((a)>=0?(a):-(a))
|
||||
|
||||
#define XP_NARROW_TO_UCHAR( in, out, inlen, outlenp ) \
|
||||
#define XP_NARROW_TO_UCHAR( in, inlen, out, outlenp ) \
|
||||
{ \
|
||||
memcpy( out, in, inlen ); \
|
||||
*(outlenp) = inlen; \
|
||||
}
|
||||
|
||||
#define XP_UCHAR_TO_NARROW( in, out, inlen, outlenp ) \
|
||||
XP_NARROW_TO_UCHAR( in, out, inlen, outlenp )
|
||||
#define XP_UCHAR_TO_NARROW( in, inlen, out, outlenp ) \
|
||||
XP_NARROW_TO_UCHAR( in, inlen, out, outlenp )
|
||||
|
||||
#ifdef DEBUG
|
||||
# define XP_ASSERT(b) assert(b)
|
||||
|
|
|
@ -26,23 +26,23 @@
|
|||
static void
|
||||
loadLettersList( BlankDialogState* bState )
|
||||
{
|
||||
XP_U16 i;
|
||||
XP_U16 ii;
|
||||
XP_U16 nTiles = bState->nTiles;
|
||||
HWND hDlg = bState->dlgHdr.hDlg;
|
||||
CEAppGlobals* globals = bState->dlgHdr.globals;
|
||||
const XP_UCHAR4* texts = bState->texts;
|
||||
|
||||
for ( i = 0; i < nTiles; ++i ) {
|
||||
/* XP_U16 len; */
|
||||
/* wchar_t widebuf[4]; */
|
||||
for ( ii = 0; ii < nTiles; ++ii ) {
|
||||
XP_U16 len;
|
||||
wchar_t widebuf[4];
|
||||
|
||||
/* len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, */
|
||||
/* texts[i], strlen(texts[i]), */
|
||||
/* widebuf, VSIZE(widebuf) ); */
|
||||
/* widebuf[len] = 0; */
|
||||
len = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED,
|
||||
texts[ii], strlen(texts[ii]),
|
||||
widebuf, VSIZE(widebuf) );
|
||||
widebuf[len] = 0;
|
||||
|
||||
SendDlgItemMessage( hDlg, LB_IF_PPC(globals,BLANKFACE_LIST),
|
||||
ADDSTRING(globals), 0, (long)texts[i] );
|
||||
ADDSTRING(globals), 0, (long)widebuf );
|
||||
}
|
||||
|
||||
SendDlgItemMessage( hDlg, LB_IF_PPC(globals,BLANKFACE_LIST),
|
||||
|
@ -61,28 +61,28 @@ showCurTray( HWND hDlg, BlankDialogState* bState )
|
|||
XP_U16 lenSoFar = 0;
|
||||
XP_U16 i;
|
||||
XP_UCHAR labelBuf[48];
|
||||
/* wchar_t widebuf[48]; */
|
||||
wchar_t widebuf[48];
|
||||
XP_UCHAR* name;
|
||||
|
||||
name = bState->dlgHdr.globals->gameInfo.players[bState->playerNum].name;
|
||||
|
||||
lenSoFar += XP_SNPRINTF( labelBuf + lenSoFar,
|
||||
VSIZE(labelBuf) - lenSoFar,
|
||||
XP_L("%d of %d for %s") XP_CR "Cur",
|
||||
sizeof(labelBuf) - lenSoFar,
|
||||
"%d of %d for %s" XP_CR "Cur",
|
||||
pi->thisPick + 1, pi->nTotal, name );
|
||||
|
||||
for ( i = 0; i < pi->nCurTiles; ++i ) {
|
||||
lenSoFar += XP_SNPRINTF( labelBuf+lenSoFar,
|
||||
VSIZE(labelBuf)-lenSoFar, XP_L("%s%s"),
|
||||
sizeof(labelBuf)-lenSoFar, "%s%s",
|
||||
i==0?": ":", ", pi->curTiles[i] );
|
||||
}
|
||||
|
||||
/* (void)MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, */
|
||||
/* labelBuf, lenSoFar + 1, */
|
||||
/* widebuf, */
|
||||
/* VSIZE(widebuf) + VSIZE(widebuf[0]) ); */
|
||||
(void)MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED,
|
||||
labelBuf, lenSoFar + 1,
|
||||
widebuf,
|
||||
VSIZE(widebuf) + sizeof(widebuf[0]) );
|
||||
|
||||
SetDlgItemText( hDlg,IDC_PICKMSG, labelBuf );
|
||||
SetDlgItemText( hDlg,IDC_PICKMSG, widebuf );
|
||||
}
|
||||
} /* showCurTray */
|
||||
#endif
|
||||
|
|
|
@ -100,7 +100,7 @@ void
|
|||
XP_LOGW( const char* prefix, const wchar_t* arg )
|
||||
{
|
||||
char buf[512];
|
||||
(void)WideCharToMultiByte( CP_ACP, 0, arg, -1,
|
||||
(void)WideCharToMultiByte( CP_UTF8, 0, arg, -1,
|
||||
buf, sizeof(buf), NULL, NULL );
|
||||
XP_LOGF( "%s: %ls", prefix, arg );
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ logLastError( const char* comment )
|
|||
/* WideCharToMultiByte( CP_ACP, 0, lpMsgBuf, len + 1, */
|
||||
/* msg + lenSoFar, len + 1, NULL, NULL ); */
|
||||
|
||||
XP_LOGF( "system error: %ls", (XP_UCHAR*)lpMsgBuf );
|
||||
XP_LOGF( "system error: %ls", (wchar_t*)lpMsgBuf );
|
||||
LocalFree( lpMsgBuf );
|
||||
} /* logLastError */
|
||||
|
||||
|
|
146
wince/cedict.c
146
wince/cedict.c
|
@ -57,9 +57,9 @@ static XP_Bool findAlternateDict( CEAppGlobals* globals, wchar_t* dictName );
|
|||
#define ALIGN_COUNT 2
|
||||
|
||||
DictionaryCtxt*
|
||||
ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
||||
ce_dictionary_make( CEAppGlobals* globals, const char* dictName )
|
||||
{
|
||||
XP_LOGF( "%s(%ls)", __func__, dictName );
|
||||
XP_LOGF( "%s(%s)", __func__, dictName );
|
||||
CEDictionaryCtxt* ctxt = (CEDictionaryCtxt*)NULL;
|
||||
HANDLE mappedFile = NULL;
|
||||
|
||||
|
@ -74,10 +74,10 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
#ifdef UCHAR_IS_WIDE
|
||||
XP_SNPRINTF( nameBuf, VSIZE(nameBuf), XP_L("%ls"), dictName );
|
||||
#else
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, dictName, -1,
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, dictName, -1,
|
||||
nameBuf, VSIZE(nameBuf) );
|
||||
#endif
|
||||
|
||||
XP_LOGF( "calling openMappedFile 1" );
|
||||
ptr = openMappedFile( MPPARM(globals->mpool) nameBuf, &mappedFile,
|
||||
&hFile, &dictLength );
|
||||
if ( !ptr ) {
|
||||
|
@ -85,9 +85,10 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
#ifdef UCHAR_IS_WIDE
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L("%ls"), nameBuf );
|
||||
#else
|
||||
(void)WideCharToMultiByte( CP_ACP, 0, nameBuf, -1,
|
||||
(void)WideCharToMultiByte( CP_UTF8, 0, nameBuf, -1,
|
||||
buf, sizeof(buf), NULL, NULL );
|
||||
#endif
|
||||
XP_LOGF( "calling openMappedFile 2" );
|
||||
ptr = openMappedFile( MPPARM(globals->mpool) nameBuf, &mappedFile,
|
||||
&hFile, &dictLength );
|
||||
if ( !!ptr ) {
|
||||
|
@ -96,6 +97,8 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
}
|
||||
}
|
||||
|
||||
XP_LOGF( "opened file %ls: %p", nameBuf, ptr );
|
||||
|
||||
while( !!ptr ) { /* lets us break.... */
|
||||
XP_U32 offset;
|
||||
XP_U16 numFaces, numFaceBytes;
|
||||
|
@ -126,6 +129,14 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
if ( isUTF8 ) {
|
||||
numFaceBytes = (XP_U16)(*ptr++);
|
||||
}
|
||||
numFaces = (XP_U16)(*ptr++);
|
||||
if ( numFaces > 64 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
ctxt = (CEDictionaryCtxt*)ce_dictionary_make_empty( globals );
|
||||
|
||||
ctxt->mappedFile = mappedFile;
|
||||
|
@ -134,31 +145,39 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
ctxt->super.destructor = ce_dict_destroy;
|
||||
ctxt->super.func_dict_getShortName = ce_dict_getShortName;
|
||||
|
||||
if ( isUTF8 ) {
|
||||
numFaceBytes = (XP_U16)(*ptr++);
|
||||
}
|
||||
numFaces = (XP_U16)(*ptr++);
|
||||
if ( !isUTF8 ) {
|
||||
numFaceBytes = numFaces * 2;
|
||||
}
|
||||
ctxt->super.nFaces = (XP_U8)numFaces;
|
||||
ctxt->super.faces =
|
||||
XP_MALLOC( globals->mpool,
|
||||
numFaces * sizeof(ctxt->super.faces[0]) );
|
||||
|
||||
#ifdef NODE_CAN_4
|
||||
ctxt->super.is_4_byte = (ctxt->super.nodeSize == 4);
|
||||
ctxt->super.nFaces = (XP_U8)numFaces;
|
||||
ctxt->super.isUTF8 = isUTF8;
|
||||
|
||||
if ( isUTF8 ) {
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, (LPCSTR)ptr, numFaces,
|
||||
ctxt->super.faces, numFaces );
|
||||
dict_splitFaces( &ctxt->super, ptr, numFaceBytes, numFaces );
|
||||
ptr += numFaceBytes;
|
||||
} else {
|
||||
for ( i = 0; i < numFaces; ++i ) {
|
||||
ctxt->super.faces[i] = n_ptr_tohs(&ptr);
|
||||
XP_U8 tmp[numFaces*4]; /* should be enough... */
|
||||
XP_U16 nBytes = 0;
|
||||
XP_U16 ii;
|
||||
/* Need to translate from iso-8859-n to utf8 */
|
||||
for ( ii = 0; ii < numFaces; ++ii ) {
|
||||
XP_UCHAR ch = ptr[1];
|
||||
wchar_t wch;
|
||||
|
||||
ptr += 2;
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, &ch, 1, &wch, 1 );
|
||||
XP_UCHAR utfs[8];
|
||||
int len = WideCharToMultiByte( CP_UTF8, 0, &wch, 1,
|
||||
utfs, VSIZE(utfs), NULL, NULL );
|
||||
XP_MEMCPY( &tmp[nBytes], utfs, len );
|
||||
nBytes += len;
|
||||
}
|
||||
dict_splitFaces( &ctxt->super, tmp, nBytes, numFaces );
|
||||
}
|
||||
#endif
|
||||
|
||||
XP_LOGF( "%s: dict_splitFaces done", __func__ );
|
||||
|
||||
ctxt->super.is_4_byte = (ctxt->super.nodeSize == 4);
|
||||
|
||||
ctxt->super.countsAndValues =
|
||||
(XP_U8*)XP_MALLOC(globals->mpool, numFaces*2);
|
||||
|
@ -170,6 +189,7 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
}
|
||||
|
||||
ceLoadSpecialData( ctxt, &ptr );
|
||||
XP_LOGF( "ceLoadSpecialData done" );
|
||||
|
||||
dictLength -= ptr - (XP_U8*)ctxt->mappedBase;
|
||||
if ( dictLength > sizeof(XP_U32) ) {
|
||||
|
@ -203,11 +223,14 @@ ce_dictionary_make( CEAppGlobals* globals, const XP_UCHAR* dictName )
|
|||
ctxt->super.base = (array_edge*)NULL;
|
||||
}
|
||||
|
||||
setBlankTile( (DictionaryCtxt*)ctxt );
|
||||
setBlankTile( &ctxt->super );
|
||||
|
||||
XP_LOGF( "copying %s", dictName );
|
||||
ctxt->super.name = copyString(globals->mpool, dictName);
|
||||
XP_LOGF( "got %s", ctxt->super.name );
|
||||
break; /* exit phony while loop */
|
||||
}
|
||||
LOG_RETURNF( "%p", ctxt );
|
||||
return (DictionaryCtxt*)ctxt;
|
||||
} /* ce_dictionary_make */
|
||||
|
||||
|
@ -223,12 +246,54 @@ ce_dictionary_make_empty( CEAppGlobals* XP_UNUSED_DBG(globals) )
|
|||
return (DictionaryCtxt*)ctxt;
|
||||
} /* ce_dictionary_make_empty */
|
||||
|
||||
void
|
||||
dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
||||
XP_U16 nBytes, XP_U16 nFaces )
|
||||
{
|
||||
XP_UCHAR* faces = XP_MALLOC( dict->mpool, nBytes + nFaces );
|
||||
XP_U16* indices = XP_MALLOC( dict->mpool, nFaces * sizeof(indices[0]));
|
||||
XP_U16 ii;
|
||||
/* XP_Bool isUTF8 = dict->isUTF8; */
|
||||
XP_UCHAR* next = faces;
|
||||
/* const XP_U8* bytes = (const XP_U8*)utf8; */
|
||||
|
||||
/* if ( isUTF8 ) { */
|
||||
wchar_t widebuf[nFaces];
|
||||
int nRead = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, (char*)utf8, nBytes,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
XP_ASSERT( nRead == nFaces );
|
||||
|
||||
/* now split */
|
||||
for ( ii = 0; ii < nFaces; ++ii ) {
|
||||
indices[ii] = next - faces;
|
||||
int nWritten = WideCharToMultiByte( CP_UTF8, 0, &widebuf[ii], 1,
|
||||
next, 100, NULL, NULL );
|
||||
next += nWritten;
|
||||
*next++ = 0;
|
||||
XP_LOGF( "%s: read char %d: %s", __func__, ii, &faces[indices[ii]] );
|
||||
}
|
||||
/* } else { */
|
||||
/* for ( ii = 0; ii < nFaces; ++ii ) { */
|
||||
/* indices[ii] = next - faces; */
|
||||
/* XP_ASSERT( 0 == *bytes ); */
|
||||
/* ++bytes; /\* skip empty *\/ */
|
||||
/* *next++ = *bytes++; */
|
||||
/* *next++ = '\0'; */
|
||||
/* } */
|
||||
/* } */
|
||||
XP_ASSERT( next == faces + nFaces + nBytes );
|
||||
XP_ASSERT( !dict->faces );
|
||||
dict->faces = faces;
|
||||
XP_ASSERT( !dict->faceIndices );
|
||||
dict->faceIndices = indices;
|
||||
} /* dict_splitFaces */
|
||||
|
||||
static void
|
||||
ceLoadSpecialData( CEDictionaryCtxt* ctxt, XP_U8** ptrp )
|
||||
{
|
||||
XP_U16 nSpecials = ceCountSpecials( ctxt );
|
||||
XP_U8* ptr = *ptrp;
|
||||
Tile i;
|
||||
Tile ii;
|
||||
XP_UCHAR** texts;
|
||||
SpecialBitmaps* bitmaps;
|
||||
|
||||
|
@ -237,22 +302,22 @@ ceLoadSpecialData( CEDictionaryCtxt* ctxt, XP_U8** ptrp )
|
|||
bitmaps = (SpecialBitmaps*)
|
||||
XP_MALLOC( ctxt->super.mpool, nSpecials * sizeof(*bitmaps) );
|
||||
|
||||
for ( i = 0; i < ctxt->super.nFaces; ++i ) {
|
||||
for ( ii = 0; ii < ctxt->super.nFaces; ++ii ) {
|
||||
|
||||
XP_UCHAR face = ctxt->super.faces[(short)i];
|
||||
if ( IS_SPECIAL(face) ) {
|
||||
|
||||
XP_UCHAR* facep = &ctxt->super.faces[ctxt->super.faceIndices[(short)ii]];
|
||||
if ( IS_SPECIAL(*facep) ) {
|
||||
XP_LOGF( "face %d is special", ii );
|
||||
/* get the string */
|
||||
XP_U8 txtlen = *ptr++;
|
||||
XP_UCHAR* text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
|
||||
XP_MEMCPY( text, ptr, txtlen );
|
||||
ptr += txtlen;
|
||||
text[txtlen] = '\0';
|
||||
XP_ASSERT( face < nSpecials );
|
||||
texts[face] = text;
|
||||
XP_ASSERT( *facep < nSpecials );
|
||||
texts[(int)*facep] = text;
|
||||
|
||||
bitmaps[face].largeBM = ceMakeBitmap( ctxt, &ptr );
|
||||
bitmaps[face].smallBM = ceMakeBitmap( ctxt, &ptr );
|
||||
bitmaps[(int)*facep].largeBM = ceMakeBitmap( ctxt, &ptr );
|
||||
bitmaps[(int)*facep].smallBM = ceMakeBitmap( ctxt, &ptr );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,10 +331,11 @@ static XP_U16
|
|||
ceCountSpecials( CEDictionaryCtxt* ctxt )
|
||||
{
|
||||
XP_U16 result = 0;
|
||||
XP_U16 i;
|
||||
XP_U16 ii;
|
||||
|
||||
for ( i = 0; i < ctxt->super.nFaces; ++i ) {
|
||||
if ( IS_SPECIAL(ctxt->super.faces[i] ) ) {
|
||||
for ( ii = 0; ii < ctxt->super.nFaces; ++ii ) {
|
||||
XP_U16 index = ctxt->super.faceIndices[ii];
|
||||
if ( IS_SPECIAL( ctxt->super.faces[index] ) ) {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
|
@ -435,6 +501,7 @@ ce_dict_destroy( DictionaryCtxt* dict )
|
|||
}
|
||||
|
||||
XP_FREE( ctxt->super.mpool, ctxt->super.faces );
|
||||
XP_FREE( ctxt->super.mpool, ctxt->super.faceIndices );
|
||||
XP_FREE( ctxt->super.mpool, ctxt->super.countsAndValues );
|
||||
XP_FREE( ctxt->super.mpool, ctxt->super.name );
|
||||
|
||||
|
@ -562,7 +629,7 @@ checkIfDictAndLegal( MPFORMAL wchar_t* path, XP_U16 pathLen,
|
|||
{
|
||||
char narrowName[CE_MAX_PATH_LEN+1];
|
||||
int len = wcslen( pathBuf );
|
||||
len = WideCharToMultiByte( CP_ACP, 0, pathBuf, len + 1,
|
||||
len = WideCharToMultiByte( CP_UTF8, 0, pathBuf, len + 1,
|
||||
narrowName, len + 1, NULL, NULL );
|
||||
}
|
||||
#endif
|
||||
|
@ -735,7 +802,7 @@ matchShortName( const wchar_t* wPath, XP_U16 XP_UNUSED(index), void* ctxt )
|
|||
|
||||
XP_ASSERT( !datap->found );
|
||||
|
||||
name = wbname( buf, sizeof(buf), wPath );
|
||||
name = wbname( buf, VSIZE(buf), wPath );
|
||||
if ( 0 == wcscmp( name, datap->sought ) ) {
|
||||
wcscpy( datap->result, wPath );
|
||||
datap->found = XP_TRUE;
|
||||
|
@ -754,7 +821,7 @@ findAlternateDict( CEAppGlobals* globals, wchar_t* path )
|
|||
FindOneData data;
|
||||
|
||||
XP_MEMSET( &data, 0, sizeof(data) );
|
||||
data.sought = wbname( shortPath, sizeof(shortPath), path );
|
||||
data.sought = wbname( shortPath, VSIZE(shortPath), path );
|
||||
data.result = path;
|
||||
|
||||
(void)ceLocateNDicts( globals, CE_MAXDICTS, matchShortName,
|
||||
|
@ -800,20 +867,19 @@ bname( const XP_UCHAR* in )
|
|||
wchar_t*
|
||||
wbname( wchar_t* buf, XP_U16 buflen, const wchar_t* in )
|
||||
{
|
||||
XP_LOGF( "%s(%ls)", __func__, in );
|
||||
wchar_t* result;
|
||||
|
||||
_snwprintf( buf, buflen, L"%s", in );
|
||||
result = buf + wcslen( buf ) - 1;
|
||||
|
||||
/* wipe out extension */
|
||||
while ( *result != '.' ) {
|
||||
while ( *result != L'.' ) {
|
||||
--result;
|
||||
XP_ASSERT( result > buf );
|
||||
XP_ASSERT( result > buf ); /* firing */
|
||||
}
|
||||
*result = 0;
|
||||
|
||||
while ( result >= buf && *result != '\\' ) {
|
||||
while ( result >= buf && *result != L'\\' ) {
|
||||
--result;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,15 +224,15 @@ ceDrawLinesClipped( HDC hdc, const FontCacheEntry* fce, XP_UCHAR* buf,
|
|||
XP_U16 width = bounds->right - bounds->left;
|
||||
|
||||
for ( ; ; ) {
|
||||
XP_UCHAR* newline = XP_STRSTR( buf, XP_CR_L );
|
||||
XP_U16 len = newline==NULL? XP_STRLEN(buf): newline - buf;
|
||||
/* wchar_t widebuf[len]; */
|
||||
XP_UCHAR* newline = strstr( buf, XP_CR );
|
||||
XP_U16 len = newline==NULL? strlen(buf): newline - buf;
|
||||
wchar_t widebuf[len];
|
||||
XP_U16 mblen;
|
||||
|
||||
#ifndef UCHAR_IS_WIDE
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, buf, len,
|
||||
widebuf, len );
|
||||
#endif
|
||||
ceDrawTextClipped( hdc, buf, len, clip, fce, bounds->left, top,
|
||||
mblen = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, buf, len,
|
||||
widebuf, len );
|
||||
|
||||
ceDrawTextClipped( hdc, widebuf, mblen, clip, fce, bounds->left, top,
|
||||
width, DT_CENTER );
|
||||
if ( !newline ) {
|
||||
break;
|
||||
|
@ -343,7 +343,7 @@ makeTestBuf( CEDrawCtx* dctx, XP_UCHAR* buf, XP_U16 bufLen, RFIndex index )
|
|||
XP_SNPRINTF( buf, bufLen, XP_L("%s"), txt );
|
||||
}
|
||||
|
||||
XP_LOGF( "%s=>\"%ls\"", __func__, buf );
|
||||
XP_LOGF( "%s=>\"%s\"", __func__, buf );
|
||||
} /* makeTestBuf */
|
||||
|
||||
static void
|
||||
|
@ -499,7 +499,7 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
|||
const XP_U16 soughtWidth, /* pass 0 to ignore width */
|
||||
RFIndex index, FontCacheEntry* fce )
|
||||
{
|
||||
/* wchar_t widebuf[65]; */
|
||||
wchar_t widebuf[65];
|
||||
XP_U16 len;
|
||||
XP_U16 hasMinTop, hasMaxBottom;
|
||||
XP_Bool firstPass;
|
||||
|
@ -517,7 +517,7 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
|||
makeTestBuf( dctx, sample, VSIZE(sample), index );
|
||||
len = 1 + XP_STRLEN(sample);
|
||||
#ifndef UCHAR_IS_WIDE
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, sample, len, widebuf, len ); */
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, sample, len, widebuf, len );
|
||||
#endif
|
||||
memBM = CreateCompatibleBitmap( memDC, testHeight, testHeight );
|
||||
SelectObject( memDC, memBM );
|
||||
|
@ -542,15 +542,15 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
|||
are calculated. */
|
||||
if ( nextFromHeight > 0 || nextFromWidth > 0 ) {
|
||||
if ( firstPass ) {
|
||||
ceMeasureGlyphs( dctx, memDC, sample, &hasMinTop,
|
||||
ceMeasureGlyphs( dctx, memDC, widebuf, &hasMinTop,
|
||||
&hasMaxBottom );
|
||||
firstPass = XP_FALSE;
|
||||
}
|
||||
/* Thereafter, just measure the two we know about */
|
||||
ceMeasureGlyph( memDC, white, sample[hasMinTop], 1000, 0,
|
||||
ceMeasureGlyph( memDC, white, widebuf[hasMinTop], 1000, 0,
|
||||
&top, &bottom );
|
||||
if ( hasMaxBottom != hasMinTop ) {
|
||||
ceMeasureGlyph( memDC, white, sample[hasMaxBottom],
|
||||
ceMeasureGlyph( memDC, white, widebuf[hasMaxBottom],
|
||||
top, bottom, &top, &bottom );
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
|||
|
||||
if ( (soughtWidth > 0) && (nextFromWidth > 0) ) {
|
||||
SIZE size;
|
||||
GetTextExtentPoint32( memDC, sample, len-1, &size );
|
||||
GetTextExtentPoint32( memDC, widebuf, len-1, &size );
|
||||
|
||||
if ( size.cx > soughtWidth ) { /* width too big... */
|
||||
nextFromWidth = 1 + ((testHeight * soughtWidth) / size.cx);
|
||||
|
@ -658,7 +658,7 @@ checkBMCache( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* letters,
|
|||
|
||||
#ifdef DEBUG
|
||||
if ( !canCache ) {
|
||||
XP_WARNF( "%s: unable to cache bitmap for %ls", __func__, letters );
|
||||
XP_WARNF( "%s: unable to cache bitmap for %s", __func__, letters );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -760,13 +760,14 @@ ceMeasureText( CEDrawCtx* dctx, HDC hdc, const FontCacheEntry* fce,
|
|||
wchar_t widebuf[32];
|
||||
XP_UCHAR* nextStr = XP_STRSTR( str, XP_CR_L );
|
||||
XP_U16 len = nextStr==NULL? XP_STRLEN(str): nextStr - str;
|
||||
XP_U16 mblen;
|
||||
SIZE size;
|
||||
|
||||
XP_ASSERT( nextStr != str );
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, len,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
GetTextExtentPoint32( hdc, widebuf, len, &size );
|
||||
mblen = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, str, len,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
GetTextExtentPoint32( hdc, widebuf, mblen, &size );
|
||||
|
||||
maxWidth = (XP_U16)XP_MAX( maxWidth, size.cx );
|
||||
if ( !!fce ) {
|
||||
|
@ -796,7 +797,7 @@ drawTextLines( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* text, XP_S16 padding,
|
|||
|
||||
for ( ; ; ) { /* draw up to the '\n' each time */
|
||||
XP_UCHAR* nextStr = strstr( text, XP_CR );
|
||||
XP_U16 len;
|
||||
XP_U16 len, mblen;
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
len = XP_STRLEN(text);
|
||||
|
@ -804,12 +805,13 @@ drawTextLines( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* text, XP_S16 padding,
|
|||
len = nextStr - text;
|
||||
}
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, text, len,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
XP_LOGF( "line at start: %s; len: %d", text, len );
|
||||
mblen = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, text, len,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
|
||||
textRt.bottom = textRt.top + dctx->miniLineHt;
|
||||
|
||||
DrawText( hdc, widebuf, len, &textRt, flags );
|
||||
DrawText( hdc, widebuf, mblen, &textRt, flags );
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
break;
|
||||
|
@ -1051,8 +1053,8 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
} else if ( !isDragSrc && !!letters && (letters[0] != '\0') ) {
|
||||
wchar_t widebuf[4];
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, letters, -1,
|
||||
widebuf, sizeof(widebuf) );
|
||||
ceDrawTextClipped( hdc, widebuf, -1, XP_FALSE, fce, xprect->left+1,
|
||||
xprect->top+2, xprect->width, DT_CENTER );
|
||||
} else if ( (flags&CELL_ISSTAR) != 0 ) {
|
||||
|
@ -1178,7 +1180,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
|
||||
if ( !!bitmaps || !!letters ) {
|
||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||
XP_U16 len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED,
|
||||
XP_U16 len = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED,
|
||||
letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
|
||||
|
@ -1477,7 +1479,7 @@ static void
|
|||
ceFormatScoreText( CEDrawCtx* dctx, const DrawScoreInfo* dsi,
|
||||
XP_UCHAR* buf, XP_U16 buflen )
|
||||
{
|
||||
XP_UCHAR bullet[] = {'•', '\0'};
|
||||
XP_UCHAR bullet[] = {'*', '\0'};
|
||||
XP_UCHAR optPart[16];
|
||||
|
||||
/* For a horizontal scoreboard, we want *300:6*
|
||||
|
|
|
@ -127,10 +127,10 @@ addDictsToMenu( GameInfoState* state )
|
|||
ADDSTRING(globals), 0, (long)shortname );
|
||||
|
||||
if ( state->newDictName[0] != 0 && sel == 0 ) {
|
||||
/* XP_UCHAR buf[CE_MAX_PATH_LEN+1]; */
|
||||
/* WideCharToMultiByte( CP_ACP, 0, wPath, -1, buf, sizeof(buf), */
|
||||
/* NULL, NULL ); */
|
||||
if ( 0 == XP_STRCMP( wPath, state->newDictName ) ) {
|
||||
XP_UCHAR buf[CE_MAX_PATH_LEN+1];
|
||||
WideCharToMultiByte( CP_UTF8, 0, wPath, -1, buf, sizeof(buf),
|
||||
NULL, NULL );
|
||||
if ( 0 == XP_STRCMP( buf, state->newDictName ) ) {
|
||||
sel = i;
|
||||
}
|
||||
}
|
||||
|
@ -192,11 +192,11 @@ loadFromGameInfo( GameInfoState* state )
|
|||
if ( state->isNewGame ) {
|
||||
(void)ceLocateNDicts( globals, CE_MAXDICTS, addDictToState, state );
|
||||
} else {
|
||||
/* wchar_t wPath[CE_MAX_PATH_LEN+1]; */
|
||||
wchar_t wPath[CE_MAX_PATH_LEN+1];
|
||||
XP_ASSERT( gi->dictName[0] != '\0' );
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, gi->dictName, -1, */
|
||||
/* wPath, VSIZE(wPath) ); */
|
||||
(void)addDictToState( gi->dictName, 0, state );
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, gi->dictName, -1,
|
||||
wPath, VSIZE(wPath) );
|
||||
(void)addDictToState( wPath, 0, state );
|
||||
}
|
||||
addDictsToMenu( state );
|
||||
#endif
|
||||
|
@ -222,11 +222,9 @@ stateToGameInfo( GameInfoState* state )
|
|||
sel = SendDlgItemMessage( hDlg, state->dictListId,
|
||||
GETCURSEL(globals), 0, 0L );
|
||||
if ( sel >= 0 ) {
|
||||
/* WideCharToMultiByte( CP_ACP, 0, state->menuDicts[sel], -1, */
|
||||
/* state->newDictName, */
|
||||
/* sizeof(state->newDictName), NULL, NULL ); */
|
||||
XP_SNPRINTF( state->newDictName, VSIZE(state->newDictName),
|
||||
L"%s", state->menuDicts[sel] );
|
||||
WideCharToMultiByte( CP_UTF8, 0, state->menuDicts[sel], -1,
|
||||
state->newDictName,
|
||||
sizeof(state->newDictName), NULL, NULL );
|
||||
}
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
state->newDictName );
|
||||
|
@ -491,7 +489,7 @@ ceSetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
|||
XP_SNPRINTF( buf, VSIZE(buf), XP_L("Player %d"), player + 1 );
|
||||
cp = buf;
|
||||
} else {
|
||||
cp = XP_L();
|
||||
cp = XP_L("");
|
||||
}
|
||||
ceSetDlgItemText( state->dlgHdr.hDlg, resID, cp );
|
||||
break;
|
||||
|
|
143
wince/cemain.c
143
wince/cemain.c
|
@ -32,7 +32,6 @@
|
|||
#endif
|
||||
/* #include <imm.h> */
|
||||
#include "strutils.h"
|
||||
/* #include "xwstream.h" */
|
||||
|
||||
#include "memstream.h"
|
||||
|
||||
|
@ -784,12 +783,11 @@ ceSetTitleFromName( CEAppGlobals* globals )
|
|||
LoadString( globals->hInst, IDS_APP_TITLE, widebuf, VSIZE(widebuf) );
|
||||
} else {
|
||||
wchar_t* dotPos;
|
||||
XP_UCHAR* baseStart = 1 + XP_STRRCHR( gameName, '\\' );
|
||||
/* XP_U16 len = (XP_U16)XP_STRLEN( baseStart ); */
|
||||
XP_SNPRINTF( widebuf, VSIZE(widebuf), L"%ls", baseStart );
|
||||
XP_UCHAR* baseStart = 1 + strrchr( gameName, '\\' );
|
||||
XP_U16 len = (XP_U16)XP_STRLEN( baseStart );
|
||||
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, baseStart, len + 1, */
|
||||
/* widebuf, len + 1 ); */
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, baseStart, len + 1,
|
||||
widebuf, len + 1 );
|
||||
|
||||
/* now get rid of the ".xwg" */
|
||||
dotPos = wcsrchr( widebuf, '.' );
|
||||
|
@ -838,7 +836,7 @@ ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame,
|
|||
#else
|
||||
XP_ASSERT( !!newDictName );
|
||||
XP_LOGF( "calling ce_dictionary_make" );
|
||||
dict = ce_dictionary_make( globals, newDictName );
|
||||
dict = ce_dictionary_make( globals, newDictName);
|
||||
#endif
|
||||
XP_ASSERT( !!dict );
|
||||
model_setDictionary( globals->game.model, dict );
|
||||
|
@ -1048,14 +1046,14 @@ fileToStream( const CEAppGlobals* globals, const XP_UCHAR* path )
|
|||
{
|
||||
XWStreamCtxt* stream = NULL;
|
||||
HANDLE fileH;
|
||||
/* wchar_t widebuf[257]; */
|
||||
wchar_t widebuf[257];
|
||||
XP_U16 len;
|
||||
|
||||
len = (XP_U16)XP_STRLEN( path );
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, path, len + 1, */
|
||||
/* widebuf, len + 1 ); */
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, path, len + 1,
|
||||
widebuf, len + 1 );
|
||||
|
||||
fileH = CreateFile( path, GENERIC_READ, 0, NULL,
|
||||
fileH = CreateFile( widebuf, GENERIC_READ, 0, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
|
||||
if ( fileH != INVALID_HANDLE_VALUE ) {
|
||||
|
@ -1105,8 +1103,8 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
success = dict != NULL;
|
||||
if ( !success ) {
|
||||
XP_UCHAR buf[128];
|
||||
XP_SNPRINTF( buf, VSIZE(buf), XP_L("Unable to open dictionary: %s"),
|
||||
dictName );
|
||||
snprintf( buf, VSIZE(buf), "Unable to open dictionary: %s",
|
||||
dictName );
|
||||
buf[VSIZE(buf)-1] = '\0';
|
||||
ceOops( globals, buf );
|
||||
|
||||
|
@ -1135,7 +1133,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
if ( !!dict ) {
|
||||
dict_destroy( dict );
|
||||
}
|
||||
ceOops( globals, XP_L("Saved game cannot be opened.") );
|
||||
ceOops( globals, "Saved game cannot be opened." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1308,7 +1306,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow
|
|||
getOSInfo( globals );
|
||||
|
||||
globals->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) );
|
||||
|
||||
|
||||
globals->hInst = hInstance;
|
||||
// Initialize global strings
|
||||
|
@ -1643,10 +1640,8 @@ ceChooseAndOpen( CEAppGlobals* globals )
|
|||
len = wcslen(newName);
|
||||
name = XP_MALLOC( globals->mpool, len + 1 );
|
||||
|
||||
XP_SNPRINTF( name, len + 1, XP_L("%ls"), newName );
|
||||
|
||||
/* WideCharToMultiByte( CP_ACP, 0, newName, len + 1, */
|
||||
/* name, len + 1, NULL, NULL ); */
|
||||
WideCharToMultiByte( CP_ACP, 0, newName, len + 1,
|
||||
name, len + 1, NULL, NULL );
|
||||
|
||||
if ( globals->curGameName != NULL
|
||||
&& 0 == XP_STRCMP( name, globals->curGameName ) ){
|
||||
|
@ -1667,11 +1662,11 @@ ceChooseAndOpen( CEAppGlobals* globals )
|
|||
closeGame( globals );
|
||||
|
||||
if ( CE_SVGAME_RENAME == choice ) {
|
||||
/* XP_U16 len = 1 + XP_STRLEN( oldName ); */
|
||||
/* wchar_t widebuf[len]; */
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, oldName, len, */
|
||||
/* widebuf, len ); */
|
||||
(void)MoveFile( oldName, newName );
|
||||
XP_U16 len = 1 + XP_STRLEN( oldName );
|
||||
wchar_t widebuf[len];
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, oldName, len,
|
||||
widebuf, len );
|
||||
(void)MoveFile( widebuf, newName );
|
||||
}
|
||||
|
||||
globals->curGameName = name;
|
||||
|
@ -1743,12 +1738,12 @@ ceWriteToFile( XWStreamCtxt* stream, void* closure )
|
|||
#endif
|
||||
XP_UCHAR* path = fwState->path;
|
||||
XP_U16 len = (XP_U16)XP_STRLEN( path ) + 1; /* 1: null byte */
|
||||
/* wchar_t widebuf[len]; */
|
||||
wchar_t widebuf[len];
|
||||
HANDLE fileH;
|
||||
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, path, len, widebuf, len ); */
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, path, len, widebuf, len );
|
||||
|
||||
fileH = CreateFile( path, GENERIC_WRITE, 0, NULL,
|
||||
fileH = CreateFile( widebuf, GENERIC_WRITE, 0, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
|
||||
if ( fileH != INVALID_HANDLE_VALUE ) {
|
||||
|
@ -1772,7 +1767,10 @@ isDefaultName( CEAppGlobals* globals, const XP_UCHAR* name )
|
|||
{
|
||||
wchar_t path[CE_MAX_PATH_LEN];
|
||||
(void)ceGetPath( globals, DEFAULT_GAME_PATH, path, VSIZE(path) );
|
||||
return 0 == XP_STRCMP( path, name );
|
||||
XP_UCHAR nbuf[CE_MAX_PATH_LEN];
|
||||
WideCharToMultiByte( CP_ACP, 0, path, -1,
|
||||
nbuf, VSIZE(nbuf), NULL, NULL );
|
||||
return 0 == XP_STRCMP( nbuf, name );
|
||||
} /* isDefaultName */
|
||||
|
||||
static XP_Bool
|
||||
|
@ -1804,10 +1802,9 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
|||
nameBuf, VSIZE(nameBuf) );
|
||||
if ( confirmed ) {
|
||||
XP_U16 len = wcslen(nameBuf);
|
||||
newName = XP_MALLOC( globals->mpool, (len + 1) * sizeof(newName[0]) );
|
||||
XP_SNPRINTF( newName, len*sizeof(newName[0]), L"%ls", nameBuf );
|
||||
/* WideCharToMultiByte( CP_ACP, 0, nameBuf, len + 1, */
|
||||
/* newName, len + 1, NULL, NULL ); */
|
||||
newName = XP_MALLOC( globals->mpool, len + 1 );
|
||||
WideCharToMultiByte( CP_ACP, 0, nameBuf, len + 1,
|
||||
newName, len + 1, NULL, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1827,7 +1824,7 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
|||
XWStreamCtxt* memStream;
|
||||
DictionaryCtxt* dict;
|
||||
FileWriteState fwState;
|
||||
const XP_UCHAR* dictName;
|
||||
const char* dictName;
|
||||
XP_U8 flags;
|
||||
|
||||
fwState.path = globals->curGameName;
|
||||
|
@ -1850,7 +1847,7 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave )
|
|||
stream_putU8( memStream, flags );
|
||||
|
||||
if ( !!dictName ) {
|
||||
stream_putString( memStream, dictName );
|
||||
stringToStream( memStream, dictName );
|
||||
}
|
||||
|
||||
ce_draw_toStream( globals->draw, memStream );
|
||||
|
@ -2289,8 +2286,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ID_FILE_NEWGAME:
|
||||
XP_LOGF( "ID_FILE_NEWGAME" );
|
||||
if ( ceSaveCurGame( globals, XP_FALSE )
|
||||
|| queryBoxChar( hWnd, XP_L("Do you really want to ")
|
||||
XP_L("overwrite the current game?") ) ) {
|
||||
|| queryBoxChar( hWnd, "Do you really want to "
|
||||
"overwrite the current game?" ) ) {
|
||||
draw = ceDoNewGame( globals );
|
||||
}
|
||||
break;
|
||||
|
@ -2308,8 +2305,8 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ID_GAME_FINALSCORES:
|
||||
if ( server_getGameIsOver( globals->game.server ) ) {
|
||||
ceDisplayFinalScores( globals );
|
||||
} else if ( queryBoxChar( hWnd, XP_L("Are you sure you want to end ")
|
||||
XP_L("the game now?") ) ) {
|
||||
} else if ( queryBoxChar( hWnd, "Are you sure you want to end "
|
||||
"the game now?" ) ) {
|
||||
server_endGame( globals->game.server );
|
||||
draw = TRUE;
|
||||
}
|
||||
|
@ -2669,14 +2666,14 @@ messageBoxStream( CEAppGlobals* globals, XWStreamCtxt* stream, wchar_t* title,
|
|||
XP_Bool
|
||||
queryBoxChar( HWND hWnd, const XP_UCHAR* msg )
|
||||
{
|
||||
/* wchar_t widebuf[128]; */
|
||||
wchar_t widebuf[128];
|
||||
XP_U16 answer;
|
||||
|
||||
/* XP_U16 len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, msg, -1, */
|
||||
/* widebuf, VSIZE(widebuf) ); */
|
||||
/* widebuf[len] = 0; */
|
||||
XP_U16 len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, msg, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
widebuf[len] = 0;
|
||||
|
||||
answer = MessageBox( hWnd, msg, L"Question",
|
||||
answer = MessageBox( hWnd, widebuf, L"Question",
|
||||
MB_YESNO | MB_ICONQUESTION );
|
||||
return answer == IDOK || answer == IDYES;
|
||||
} /* queryBoxChar */
|
||||
|
@ -2808,7 +2805,7 @@ wince_snprintf( XP_UCHAR* buf, XP_U16 len, const XP_UCHAR* format, ... )
|
|||
|
||||
va_start( ap, format );
|
||||
|
||||
_vsnwprintf( buf, len, format, ap );
|
||||
_vsnprintf( buf, len, format, ap );
|
||||
|
||||
/* FormatMessage( */
|
||||
/* FORMAT_MESSAGE_FROM_STRING, */
|
||||
|
@ -2920,75 +2917,75 @@ ce_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
|
||||
switch( id ) {
|
||||
case ERR_TILES_NOT_IN_LINE:
|
||||
message = XP_L("All tiles played must be in a line.");
|
||||
message = "All tiles played must be in a line.";
|
||||
break;
|
||||
case ERR_NO_EMPTIES_IN_TURN:
|
||||
message = XP_L("Empty squares cannot separate tiles played.");
|
||||
message = "Empty squares cannot separate tiles played.";
|
||||
break;
|
||||
|
||||
case ERR_TWO_TILES_FIRST_MOVE:
|
||||
message = XP_L("Must play two or more pieces on the first move.");
|
||||
message = "Must play two or more pieces on the first move.";
|
||||
break;
|
||||
case ERR_TILES_MUST_CONTACT:
|
||||
message = XP_L("New pieces must contact others already in place (or ")
|
||||
XP_L("the middle square on the first move.");
|
||||
message = "New pieces must contact others already in place (or "
|
||||
"the middle square on the first move).";
|
||||
break;
|
||||
case ERR_NOT_YOUR_TURN:
|
||||
message = XP_L("You can\'t do that; it\'s not your turn!");
|
||||
message = "You can't do that; it's not your turn!";
|
||||
break;
|
||||
case ERR_NO_PEEK_ROBOT_TILES:
|
||||
message = XP_L("No peeking at the robot's tiles!");
|
||||
message = "No peeking at the robot's tiles!";
|
||||
break;
|
||||
case ERR_CANT_TRADE_MID_MOVE:
|
||||
message = XP_L("Remove played tiles before trading.");
|
||||
message = "Remove played tiles before trading.";
|
||||
break;
|
||||
case ERR_TOO_FEW_TILES_LEFT_TO_TRADE:
|
||||
message = XP_L("Too few tiles left to trade.");
|
||||
message = "Too few tiles left to trade.";
|
||||
break;
|
||||
case ERR_CANT_UNDO_TILEASSIGN:
|
||||
message = XP_L("Tile assignment can\'t be undone.");
|
||||
message = "Tile assignment can't be undone.";
|
||||
break;
|
||||
|
||||
case ERR_CANT_HINT_WHILE_DISABLED:
|
||||
message = XP_L("The hint feature is disabled for this game. Enable ")
|
||||
XP_L("it for a new game using the Preferences dialog.");
|
||||
message = "The hint feature is disabled for this game. Enable "
|
||||
"it for a new game using the Preferences dialog.";
|
||||
break;
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case ERR_NO_PEEK_REMOTE_TILES:
|
||||
message = XP_L("No peeking at remote players\' tiles!");
|
||||
message = "No peeking at remote players' tiles!";
|
||||
break;
|
||||
case ERR_REG_UNEXPECTED_USER:
|
||||
message = XP_L("Refused attempt to register unexpected user[s].");
|
||||
message = "Refused attempt to register unexpected user[s].";
|
||||
break;
|
||||
case ERR_SERVER_DICT_WINS:
|
||||
message = XP_L("Conflict between Host and Guest dictionaries; Host wins.");
|
||||
message = "Conflict between Host and Guest dictionaries; Host wins.";
|
||||
XP_WARNF( "GTK may have problems here." );
|
||||
break;
|
||||
case ERR_REG_SERVER_SANS_REMOTE:
|
||||
message = XP_L("At least one player must be marked remote for a game ")
|
||||
XP_L("started as Host.");
|
||||
message = "At least one player must be marked remote for a game "
|
||||
"started as Host.";
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
case ERR_RELAY_BASE + XWRELAY_ERROR_TIMEOUT:
|
||||
message = XP_L("The relay timed you out; usually that means ")
|
||||
XP_L("the other players didn\'t show.");
|
||||
message = "The relay timed you out; usually that means "
|
||||
"the other players didn't show.";
|
||||
break;
|
||||
case ERR_RELAY_BASE + XWRELAY_ERROR_HEART_YOU:
|
||||
message = XP_L("You were disconnected from relay because it didn\'t ")
|
||||
XP_L("hear from you in too long.");
|
||||
message = "You were disconnected from relay because it didn't "
|
||||
"hear from you in too long.";
|
||||
break;
|
||||
case ERR_RELAY_BASE + XWRELAY_ERROR_HEART_OTHER:
|
||||
case ERR_RELAY_BASE + XWRELAY_ERROR_LOST_OTHER:
|
||||
message = XP_L("The relay has lost contact with a device in this game.");
|
||||
message = "The relay has lost contact with a device in this game.";
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
XP_LOGF( "%s(%d)", __func__, id );
|
||||
message = XP_L("unknown errorcode ID!!!");
|
||||
message = "unknown errorcode ID!!!";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3006,7 +3003,7 @@ ce_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream )
|
|||
return ceQueryFromStream( globals, stream );
|
||||
|
||||
case QUERY_COMMIT_TRADE:
|
||||
query = XP_L("Are you sure you want to trade the selected tiles?");
|
||||
query = "Are you sure you want to trade the selected tiles?";
|
||||
assertOnTop( globals->hWnd );
|
||||
return queryBoxChar( globals->hWnd, query );
|
||||
|
||||
|
@ -3338,14 +3335,14 @@ ce_formatBadWords( BadWordInfo* bwi, XP_UCHAR buf[], XP_U16 bufsiz )
|
|||
|
||||
for ( i = 0, buf[0] = '\0'; ; ) {
|
||||
XP_UCHAR wordBuf[18];
|
||||
XP_SNPRINTF( wordBuf, VSIZE(wordBuf), XP_L("\"%s\""), bwi->words[i] );
|
||||
XP_ASSERT( XP_STRLEN(wordBuf) < sizeof(wordBuf)-1 );
|
||||
XP_SNPRINTF( buf, bufsiz - 1, XP_L("%ls"), wordBuf );
|
||||
sprintf( wordBuf, "\"%s\"", bwi->words[i] );
|
||||
XP_ASSERT( strlen(wordBuf) < sizeof(wordBuf)-1 );
|
||||
strncat( buf, wordBuf, bufsiz - 1 );
|
||||
if ( ++i == bwi->nWords ) {
|
||||
break;
|
||||
}
|
||||
bufsiz -= XP_STRLEN( wordBuf );
|
||||
XP_SNPRINTF( buf, bufsiz - 1, XP_L("%s"), ", " );
|
||||
bufsiz -= strlen( wordBuf );
|
||||
strncat( buf, ", ", bufsiz - 1 );
|
||||
bufsiz -= 2;
|
||||
}
|
||||
} /* ce_formatBadWords */
|
||||
|
|
|
@ -335,7 +335,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
if ( IS_SMARTPHONE(globals) ) {
|
||||
ceMessageBoxChar( globals, XP_L("This feature ")
|
||||
"requires a touch screen.",
|
||||
XP_L("Sorry"), MB_OK | MB_ICONHAND );
|
||||
L"Sorry", MB_OK | MB_ICONHAND );
|
||||
ceSetChecked( hDlg, IDC_CHECKHINTSLIMITS, XP_FALSE );
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -251,17 +251,10 @@ static void
|
|||
getHostAddr( CeSocketWrapper* self )
|
||||
{
|
||||
if ( self->addrRec.u.ip_relay.hostName[0] ) {
|
||||
XP_UCHAR* hostName = self->addrRec.u.ip_relay.hostName;
|
||||
XP_U16 len = 1 + XP_STRLEN(hostName);
|
||||
char tmp[1+VSIZE(self->addrRec.u.ip_relay.hostName)];
|
||||
|
||||
WideCharToMultiByte( CP_ACP, 0, hostName, len,
|
||||
tmp, len + 1, NULL, NULL );
|
||||
|
||||
XP_LOGF( "%s: calling WSAAsyncGetHostByName(%s)", __func__, tmp );
|
||||
self->getHostTask
|
||||
= WSAAsyncGetHostByName( self->globals->hWnd,
|
||||
XWWM_HOSTNAME_ARRIVED, tmp,
|
||||
XWWM_HOSTNAME_ARRIVED,
|
||||
self->addrRec.u.ip_relay.hostName,
|
||||
(char*)&self->hostNameUnion,
|
||||
sizeof(self->hostNameUnion) );
|
||||
if ( NULL == self->getHostTask ) {
|
||||
|
|
|
@ -41,10 +41,10 @@ stuffTextInField( HWND hDlg, StrBoxState* state )
|
|||
}
|
||||
sbuf[nBytes] = '\0';
|
||||
|
||||
len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, sbuf, nBytes,
|
||||
len = MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, sbuf, nBytes,
|
||||
NULL, 0 );
|
||||
wbuf = XP_MALLOC( globals->mpool, (len+1) * sizeof(*wbuf) );
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, sbuf, nBytes,
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, sbuf, nBytes,
|
||||
wbuf, len );
|
||||
XP_FREE( globals->mpool, sbuf );
|
||||
wbuf[len] = 0;
|
||||
|
|
|
@ -487,12 +487,12 @@ ceSavedGamesDlg( CEAppGlobals* globals, const XP_UCHAR* curPath,
|
|||
state.sel = -1;
|
||||
|
||||
if ( !!curPath ) {
|
||||
/* wchar_t widebuf[MAX_PATH]; */
|
||||
/* XP_U16 len; */
|
||||
/* len = (XP_U16)XP_STRLEN( curPath ); */
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, curPath, len + 1, */
|
||||
/* widebuf, len + 1 ); */
|
||||
ceBasename( state.openNameW, curPath );
|
||||
wchar_t widebuf[MAX_PATH];
|
||||
XP_U16 len;
|
||||
len = (XP_U16)XP_STRLEN( curPath );
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, curPath, len + 1,
|
||||
widebuf, len + 1 );
|
||||
ceBasename( state.openNameW, widebuf );
|
||||
}
|
||||
|
||||
for ( ; ; ) {
|
||||
|
|
|
@ -37,7 +37,7 @@ static void ceDoDlgFocusScroll( CeDlgHdr* dlgHdr, HWND nextCtrl );
|
|||
void
|
||||
ceSetDlgItemText( HWND hDlg, XP_U16 id, const XP_UCHAR* buf )
|
||||
{
|
||||
/* wchar_t widebuf[BUF_SIZE]; */
|
||||
wchar_t widebuf[BUF_SIZE];
|
||||
XP_U16 len;
|
||||
|
||||
XP_ASSERT( buf != NULL );
|
||||
|
@ -48,9 +48,9 @@ ceSetDlgItemText( HWND hDlg, XP_U16 id, const XP_UCHAR* buf )
|
|||
len = BUF_SIZE - 1;
|
||||
}
|
||||
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, buf, len, widebuf, len ); */
|
||||
/* widebuf[len] = 0; */
|
||||
SendDlgItemMessage( hDlg, id, WM_SETTEXT, 0, (long)buf );
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, buf, len, widebuf, len );
|
||||
widebuf[len] = 0;
|
||||
SendDlgItemMessage( hDlg, id, WM_SETTEXT, 0, (long)widebuf );
|
||||
} /* ceSetDlgItemText */
|
||||
|
||||
void
|
||||
|
@ -80,21 +80,19 @@ ceGetDlgItemText( HWND hDlg, XP_U16 id, XP_UCHAR* buf, XP_U16* bLen )
|
|||
{
|
||||
XP_U16 len = *bLen;
|
||||
XP_U16 gotLen;
|
||||
/* wchar_t wbuf[BUF_SIZE]; */
|
||||
wchar_t wbuf[BUF_SIZE];
|
||||
|
||||
XP_ASSERT( len <= BUF_SIZE );
|
||||
|
||||
gotLen = (XP_U16)SendDlgItemMessage( hDlg, id, WM_GETTEXT, len,
|
||||
(long)buf );
|
||||
XP_LOGF( "%s: gotLen: %d; len: %d; got: %ls", __func__,
|
||||
gotLen, len, buf );
|
||||
(long)wbuf );
|
||||
if ( gotLen > 0 ) {
|
||||
XP_ASSERT( gotLen < len );
|
||||
if ( gotLen >= len ) {
|
||||
gotLen = len - 1;
|
||||
}
|
||||
/* gotLen = WideCharToMultiByte( CP_ACP, 0, wbuf, gotLen, */
|
||||
/* buf, len, NULL, NULL ); */
|
||||
gotLen = WideCharToMultiByte( CP_UTF8, 0, wbuf, gotLen,
|
||||
buf, len, NULL, NULL );
|
||||
*bLen = gotLen;
|
||||
buf[gotLen] = '\0';
|
||||
} else {
|
||||
|
@ -119,7 +117,7 @@ ceGetDlgItemNum( HWND hDlg, XP_U16 id )
|
|||
XP_U16 len = VSIZE(buf);
|
||||
ceGetDlgItemText( hDlg, id, buf, &len );
|
||||
|
||||
result = _wtoi( buf );
|
||||
result = XP_ATOI( buf );
|
||||
return result;
|
||||
} /* ceGetDlgItemNum */
|
||||
|
||||
|
@ -873,7 +871,7 @@ ceGetPath( CEAppGlobals* globals, CePathType typ,
|
|||
|
||||
len = wcslen( bufW );
|
||||
if ( asAscii ) {
|
||||
(void)WideCharToMultiByte( CP_ACP, 0, bufW, len + 1,
|
||||
(void)WideCharToMultiByte( CP_UTF8, 0, bufW, len + 1,
|
||||
(char*)bufOut, bufLen, NULL, NULL );
|
||||
} else {
|
||||
wcscpy( (wchar_t*)bufOut, bufW );
|
||||
|
@ -888,15 +886,15 @@ ceMessageBoxChar( CEAppGlobals* XP_UNUSED(globals), const XP_UCHAR* str,
|
|||
HWND parent;
|
||||
/* Get the length required, then alloc and go. This is technically
|
||||
correct, but everywhere else I assume a 2:1 ratio for wchar_t:char. */
|
||||
/* XP_U16 clen = 1 + XP_STRLEN(str); */
|
||||
/* XP_U32 wlen = 1 + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, */
|
||||
/* clen, NULL, 0 ); */
|
||||
/* wchar_t widebuf[wlen]; */
|
||||
XP_U16 clen = 1 + XP_STRLEN(str);
|
||||
XP_U32 wlen = 1 + MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, str,
|
||||
clen, NULL, 0 );
|
||||
wchar_t widebuf[wlen];
|
||||
|
||||
/* MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, clen, widebuf, wlen ); */
|
||||
MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, str, clen, widebuf, wlen );
|
||||
|
||||
parent = GetForegroundWindow();
|
||||
return MessageBox( parent, str, title, buttons );
|
||||
return MessageBox( parent, widebuf, title, buttons );
|
||||
} /* ceMessageBoxChar */
|
||||
|
||||
int
|
||||
|
@ -905,24 +903,3 @@ ceOops( CEAppGlobals* globals, const XP_UCHAR* str )
|
|||
return ceMessageBoxChar( globals, str, L"Oops!",
|
||||
MB_OK | MB_ICONHAND );
|
||||
}
|
||||
|
||||
XP_U16
|
||||
wince_narrow_to_wide( const XP_U8* in, XP_UCHAR* out, XP_U16 inLen, XP_U16 outLen )
|
||||
{
|
||||
XP_U16 nWritten;
|
||||
nWritten = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, (const char*)in, inLen,
|
||||
out, outLen );
|
||||
out[nWritten++] = 0;
|
||||
XP_ASSERT( nWritten < outLen );
|
||||
return nWritten;
|
||||
}
|
||||
|
||||
XP_U16
|
||||
wince_wide_to_narrow( const XP_UCHAR* in, XP_U8* out, XP_U16 inLen, XP_U16 outLen )
|
||||
{
|
||||
XP_U16 nWritten = WideCharToMultiByte( CP_ACP, 0, in, inLen,
|
||||
(char*)out, outLen, NULL, NULL );
|
||||
out[nWritten++] = 0;
|
||||
XP_ASSERT( nWritten <= outLen );
|
||||
return nWritten;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <winuser.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#define UCHAR_IS_WIDE
|
||||
//#define UCHAR_IS_WIDE
|
||||
|
||||
typedef unsigned char XP_U8;
|
||||
typedef signed char XP_S8;
|
||||
|
@ -39,7 +39,7 @@ typedef unsigned long XP_U32;
|
|||
typedef signed long XP_S32;
|
||||
|
||||
/* typedef char XP_UCHAR; */
|
||||
typedef wchar_t XP_UCHAR;
|
||||
typedef char XP_UCHAR;
|
||||
|
||||
typedef signed short XP_FontCode; /* not sure how I'm using this yet */
|
||||
typedef BOOL XP_Bool;
|
||||
|
@ -51,8 +51,6 @@ typedef XP_U32 XP_Time;
|
|||
/* 'Doze expects a carraige return followed by a linefeed */
|
||||
#define XP_CR "\015\012"
|
||||
#define XP_CR_L XP_L(XP_CR)
|
||||
#define XP_L(s) L"" s
|
||||
#define XP_LS XP_L("%ls")
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
@ -75,15 +73,32 @@ typedef XP_U32 XP_Time;
|
|||
#define XP_MEMCPY(d,s,l) memcpy((d),(s),(l))
|
||||
#define XP_MEMMOVE(d,s,l) memmove((d),(s),(l))
|
||||
#define XP_MEMCMP( a1, a2, l ) memcmp((a1),(a2),(l))
|
||||
#define XP_STRLEN(s) strlen((char*)(s))
|
||||
/* #define XP_STRCAT(d,s) strcat((d),(s)) */
|
||||
#define XP_STRCMP(s1,s2) strcmp((char*)(s1),(char*)(s2))
|
||||
#define XP_STRNCMP(s1,s2,l) strncmp((char*)(s1),(char*)(s2),(l))
|
||||
#define XP_SNPRINTF wince_snprintf
|
||||
#define XP_STRRCHR(s1,c1) wcsrchr(s1,c1)
|
||||
#define XP_ATOI _wtoi
|
||||
#define XP_STRCAT wcscat
|
||||
#define XP_STRSTR wcsstr
|
||||
|
||||
#ifdef UCHAR_IS_WIDE
|
||||
# define XP_ATOI _wtoi
|
||||
# define XP_STRCAT wcscat
|
||||
# define XP_STRSTR wcsstr
|
||||
# define XP_STRRCHR(s1,c1) wcsrchr(s1,c1)
|
||||
/* #define XP_STRCMP(s1,s2) strcmp((char*)(s1),(char*)(s2)) */
|
||||
/* #define XP_STRNCMP(s1,s2,l) strncmp((char*)(s1),(char*)(s2),(l)) */
|
||||
/* #define XP_STRLEN(s) strlen((char*)(s)) */
|
||||
#else
|
||||
# define XP_L(s) s
|
||||
# define XP_S XP_L("%s")
|
||||
//# define XP_LS "%s"
|
||||
# define XP_LS_L XP_LS
|
||||
# define XP_ATOI atoi
|
||||
# define XP_STRCAT strcat
|
||||
# define XP_STRSTR strstr
|
||||
# define XP_STRRCHR(s1,c1) strrchr(s1,c1)
|
||||
# define XP_STRCMP(s1,s2) strcmp((s1),(s2))
|
||||
# define XP_STRNCMP(s1,s2,l) strncmp((s1),(s2),(l))
|
||||
# define XP_STRLEN(s) strlen((char*)(s))
|
||||
# define XP_STRCPY(s,d) strcpy((s),(d))
|
||||
#endif
|
||||
|
||||
|
||||
XP_U16 wince_narrow_to_wide( const XP_U8* in, XP_UCHAR* out, XP_U16 inLen,
|
||||
XP_U16 outLen );
|
||||
|
|
Loading…
Reference in a new issue