Fix to compile with relay enabled and not STANDALONE_ONLY. Verified

that win32 build can open games saved by previous version, but nothing
else (e.g. use of network or even dialogs to set up relay connection
parameters.)
This commit is contained in:
ehouse 2009-01-04 00:00:45 +00:00
parent 342674276a
commit 4698b835e8
8 changed files with 46 additions and 33 deletions

View file

@ -1,4 +1,6 @@
# -*- compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- # -*- compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*-
# Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights
# reserved.
# This Makefile is meant to allow building Crosswords for PocketPC and # This Makefile is meant to allow building Crosswords for PocketPC and
# Windows using Linux. As of March 2006, it compiles and runs on # Windows using Linux. As of March 2006, it compiles and runs on
@ -48,7 +50,7 @@ HAVE_COMMCTRL = 1
ifeq ($(TARGET_OS),wince) ifeq ($(TARGET_OS),wince)
# BLUETOOTH = -DXWFEATURE_BLUETOOTH # BLUETOOTH = -DXWFEATURE_BLUETOOTH
# RELAY = -DXWFEATURE_RELAY -DCOMMS_HEARTBEAT RELAY = -DXWFEATURE_RELAY
CC = ${CE_ARCH}-gcc CC = ${CE_ARCH}-gcc
WINDRES = ${CE_ARCH}-windres WINDRES = ${CE_ARCH}-windres
STRIP = ${CE_ARCH}-strip STRIP = ${CE_ARCH}-strip
@ -57,7 +59,8 @@ CELIBS = -L/usr/arm-wince-pe/lib
else else
CELIBS = -L${CEOPT_ROOT}/${CE_ARCH}/lib/ -lws2 CELIBS = -L${CEOPT_ROOT}/${CE_ARCH}/lib/ -lws2
endif endif
STANDALONE = -DXWFEATURE_STANDALONE_ONLY #STANDALONE = -DXWFEATURE_STANDALONE_ONLY
STANDALONE = -DPREV_WAS_STANDALONE_ONLY
COLOR_SEL = -DMY_COLOR_SEL COLOR_SEL = -DMY_COLOR_SEL
CFLAGS += -D_WIN32_WCE=0x0400 -D_WIN32_IE=0x0400 -DUNDER_CE \ CFLAGS += -D_WIN32_WCE=0x0400 -D_WIN32_IE=0x0400 -DUNDER_CE \
$(STANDALONE) $(USE_RAW_MINGW) -DDRAW_LINK_DIRECT \ $(STANDALONE) $(USE_RAW_MINGW) -DDRAW_LINK_DIRECT \
@ -74,9 +77,10 @@ CFLAGS += -DCANT_DO_CMDBAR
endif endif
else # ifeq ($(TARGET_OS),wince) else # ifeq ($(TARGET_OS),wince)
ifeq ($(TARGET_OS),win32) ifeq ($(TARGET_OS),win32)
STANDALONE = -DXWFEATURE_STANDALONE_ONLY #STANDALONE = -DXWFEATURE_STANDALONE_ONLY
STANDALONE = -DPREV_WAS_STANDALONE_ONLY
#BLUETOOTH = -DXWFEATURE_BLUETOOTH #BLUETOOTH = -DXWFEATURE_BLUETOOTH
#RELAY = -DXWFEATURE_RELAY RELAY = -DXWFEATURE_RELAY
CC = i586-mingw32msvc-gcc CC = i586-mingw32msvc-gcc
WINDRES = i586-mingw32msvc-windres WINDRES = i586-mingw32msvc-windres
STRIP = i586-mingw32msvc-strip STRIP = i586-mingw32msvc-strip

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* /*
* Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -176,13 +177,12 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
ceControlsFromAddrRec( hDlg, state ); ceControlsFromAddrRec( hDlg, state );
ceDlgSetup( &state->dlgState, hDlg, DLG_STATE_NONE ); ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_NONE );
result = TRUE; result = TRUE;
} else { } else {
state = (CeConnDlgState*)GetWindowLongPtr( hDlg, GWL_USERDATA ); state = (CeConnDlgState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
if ( !!state ) { if ( !!state ) {
CEAppGlobals* globals = state->dlgHdr.globals;
if ( message == WM_COMMAND ) { if ( message == WM_COMMAND ) {
XP_U16 id = LOWORD(wParam); XP_U16 id = LOWORD(wParam);
@ -207,10 +207,10 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
state->userCancelled = id == IDCANCEL; state->userCancelled = id == IDCANCEL;
result = TRUE; result = TRUE;
} }
} else if ( message == WM_VSCROLL ) { /* } else if ( message == WM_VSCROLL ) { */
if ( !IS_SMARTPHONE(globals) ) { /* if ( !IS_SMARTPHONE(globals) ) { */
ceDoDlgScroll( hDlg, wParam ); /* ceDoDlgScroll( hDlg, wParam ); */
} /* } */
} }
} }
} }
@ -225,7 +225,7 @@ WrapConnsDlg( HWND hDlg, CEAppGlobals* globals, const CommsAddrRec* addrRec,
XP_Bool result; XP_Bool result;
XP_MEMSET( state, 0, sizeof( *state ) ); XP_MEMSET( state, 0, sizeof( *state ) );
state->globals = globals; state->dlgHdr.globals = globals;
state->role = role; state->role = role;
XP_MEMCPY( &state->addrRec, addrRec, sizeof(state->addrRec) ); XP_MEMCPY( &state->addrRec, addrRec, sizeof(state->addrRec) );

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* /*
* Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -22,6 +23,7 @@
#include "comms.h" #include "comms.h"
#include "cemain.h" #include "cemain.h"
#include "ceutil.h"
typedef struct CeConnDlgState { typedef struct CeConnDlgState {
CeDlgHdr dlgHdr; CeDlgHdr dlgHdr;

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- */ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- */
/* /*
* Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights * Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -165,6 +165,9 @@ loadFromGameInfo( GameInfoState* state )
XP_U16 i; XP_U16 i;
CEAppGlobals* globals = state->dlgHdr.globals; CEAppGlobals* globals = state->dlgHdr.globals;
CurGameInfo* gi = &globals->gameInfo; CurGameInfo* gi = &globals->gameInfo;
#ifndef XWFEATURE_STANDALONE_ONLY
HWND hDlg = state->dlgHdr.hDlg;
#endif
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH #if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
wchar_t* roles[] = { L"Standalone", L"Host", L"Guest" }; wchar_t* roles[] = { L"Standalone", L"Host", L"Guest" };
@ -334,11 +337,11 @@ static void
handleConnOptionsButton( HWND hDlg, CEAppGlobals* globals, handleConnOptionsButton( HWND hDlg, CEAppGlobals* globals,
DeviceRole role, GameInfoState* state ) DeviceRole role, GameInfoState* state )
{ {
CeConnDlgState state; CeConnDlgState dlgState;
if ( WrapConnsDlg( hDlg, globals, &state->prefsPrefs.addrRec, if ( WrapConnsDlg( hDlg, globals, &state->prefsPrefs.addrRec,
role, &state ) ) { role, &dlgState ) ) {
XP_MEMCPY( &state->prefsPrefs.addrRec, &state.addrRec, XP_MEMCPY( &state->prefsPrefs.addrRec, &dlgState.addrRec,
sizeof(state->prefsPrefs.addrRec) ); sizeof(state->prefsPrefs.addrRec) );
state->addrChanged = XP_TRUE; state->addrChanged = XP_TRUE;
} }

View file

@ -1,6 +1,7 @@
/* -*- fill-column: 77; compile-command: "make -j TARGET_OS=wince DEBUG=TRUE" -*- */ /* -*- fill-column: 77; compile-command: "make -j TARGET_OS=wince DEBUG=TRUE" -*- */
/* /*
* Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -2855,7 +2856,6 @@ ce_send_proc( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
if ( !globals->socketWrap ) { if ( !globals->socketWrap ) {
globals->socketWrap = ce_sockwrap_new( MPPARM(globals->mpool) globals->socketWrap = ce_sockwrap_new( MPPARM(globals->mpool)
addr->conType,
got_data_proc, globals ); got_data_proc, globals );
} }
@ -3158,7 +3158,7 @@ ce_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
case TIMER_TIMERTICK: case TIMER_TIMERTICK:
howLong = 1000; /* 1 second */ howLong = 1000; /* 1 second */
break; break;
#if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT #if defined XWFEATURE_RELAY || defined COMMS_HEARTBEAT
case TIMER_HEARTBEAT: case TIMER_HEARTBEAT:
howLong = when * 1000; howLong = when * 1000;
break; break;

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* /*
* Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -20,6 +21,7 @@
#include "cesockwr.h" #include "cesockwr.h"
#include "cemain.h" #include "cemain.h"
#include "cedebug.h"
#include "debhacks.h" #include "debhacks.h"
#include <winsock.h> #include <winsock.h>
@ -90,10 +92,11 @@ queue_packet( CeSocketWrapper* self, XP_U8* packet, XP_U16 len )
self->packets[self->nPackets] = packet; self->packets[self->nPackets] = packet;
self->lens[self->nPackets] = len; self->lens[self->nPackets] = len;
++self->nPackets; ++self->nPackets;
XP_LOGF( "there are now %d packets on send queue", self->nPackets ); XP_LOGF( "there are now %d packets on send queue",
self->nPackets );
/* signal the writer thread */ /* signal the writer thread */
DH(SetEvent)( self->queueAddEvent ); SetEvent( self->queueAddEvent );
success = XP_TRUE; success = XP_TRUE;
} }
@ -152,7 +155,7 @@ static XP_Bool
sendAll( CeSocketWrapper* self, XP_U8* buf, XP_U16 len ) sendAll( CeSocketWrapper* self, XP_U8* buf, XP_U16 len )
{ {
for ( ; ; ) { for ( ; ; ) {
int nSent = MS(send)( self->socket, buf, len, 0 ); /* flags? */ int nSent = send( self->socket, (char*)buf, len, 0 ); /* flags? */
if ( nSent == SOCKET_ERROR ) { if ( nSent == SOCKET_ERROR ) {
return XP_FALSE; return XP_FALSE;
} else if ( nSent == len ) { } else if ( nSent == len ) {
@ -216,8 +219,9 @@ connectSocket( CeSocketWrapper* self )
self->connState = CE_IP_CONNECTED; self->connState = CE_IP_CONNECTED;
self->socket = sock; self->socket = sock;
/* Let the reader thread know there's now a socket to listen on */ /* Let the reader thread know there's now a socket to listen
DH(SetEvent)( self->socketConnEvent ); on */
SetEvent( self->socketConnEvent );
} else { } else {
logLastError( "connect" ); logLastError( "connect" );
@ -280,7 +284,7 @@ WriterThreadProc( LPVOID lpParameter )
/* Should this happen sooner? What if other thread signals in the /* Should this happen sooner? What if other thread signals in the
meantime? */ meantime? */
DH(ResetEvent)( self->queueAddEvent ); ResetEvent( self->queueAddEvent );
} }
ExitThread(0); /* docs say to exit this way */ ExitThread(0); /* docs say to exit this way */
@ -307,7 +311,7 @@ read_bytes_blocking( CeSocketWrapper* self, XP_U8* buf, XP_U16 len )
if ( sres == 0 ) { if ( sres == 0 ) {
break; break;
} else if ( sres == 1 && FD_ISSET( self->socket, &readSet ) ) { } else if ( sres == 1 && FD_ISSET( self->socket, &readSet ) ) {
int nRead = MS(recv)( self->socket, buf, len, 0 ); int nRead = MS(recv)( self->socket, (char*)buf, len, 0 );
if ( nRead > 0 ) { if ( nRead > 0 ) {
XP_LOGF( "read %d bytes", nRead ); XP_LOGF( "read %d bytes", nRead );
XP_ASSERT( nRead <= len ); XP_ASSERT( nRead <= len );
@ -361,8 +365,7 @@ ReaderThreadProc( LPVOID lpParameter )
CeSocketWrapper* CeSocketWrapper*
ce_sockwrap_new( MPFORMAL CommsConnType conType, DataRecvProc proc, ce_sockwrap_new( MPFORMAL DataRecvProc proc, void* closure )
void* closure )
{ {
CeSocketWrapper* self = XP_MALLOC( mpool, sizeof(*self) ); CeSocketWrapper* self = XP_MALLOC( mpool, sizeof(*self) );
XP_MEMSET( self, 0, sizeof(*self) ); XP_MEMSET( self, 0, sizeof(*self) );

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* /*
* Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -27,7 +28,7 @@ typedef struct CeSocketWrapper CeSocketWrapper; /* forward */
typedef void (*DataRecvProc)( XP_U8* data, XP_U16 len, void* closure ); typedef void (*DataRecvProc)( XP_U8* data, XP_U16 len, void* closure );
CeSocketWrapper* ce_sockwrap_new( MPFORMAL CommsConnType conType, DataRecvProc proc, void* closure ); CeSocketWrapper* ce_sockwrap_new( MPFORMAL DataRecvProc proc, void* closure );
void ce_sockwrap_delete( CeSocketWrapper* self ); void ce_sockwrap_delete( CeSocketWrapper* self );
XP_U16 ce_sockwrap_send( CeSocketWrapper* self, const XP_U8* buf, XP_U16 len, XP_U16 ce_sockwrap_send( CeSocketWrapper* self, const XP_U8* buf, XP_U16 len,

View file

@ -922,7 +922,7 @@ BEGIN
IDS_CANCEL "Cancel" IDS_CANCEL "Cancel"
IDS_OK "Ok" IDS_OK "Ok"
IDS_DONE "Done" IDS_DONE "Done"
IDS_ABOUT "Crosswords 4.2rc1 (rev " SVN_REV ") "\ IDS_ABOUT "Crosswords 4.4a1 (rev " SVN_REV ") "\
"for Windows Mobile. Copyright 1998-2008 by "\ "for Windows Mobile. Copyright 1998-2008 by "\
"Eric House. This software is released under the GNU "\ "Eric House. This software is released under the GNU "\
"Public License.\r\r"\ "Public License.\r\r"\