Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/src Modified Files: bccnetrek.rc check.c cowmain.c data.c death.c defaults.c defwin.c distress.c dmessage.c docwin.c feature.c findslot.c getname.c helpwin.c hintwin.c input.c local.c main.c makefile map.c mswindow.c newwin.c option.c parsemeta.c ping.c playback.c playerlist.c redraw.c reserved.c senddist.c short.c smessage.c socket.c sound.c stampver.inf udpopt.c winmain.c winsndlib.c Log Message: This large patch brings the client up to Stas's version 4.4.0.4. The visible changes to the user are: - added "allowWheelActions: (on)/off" to be able to disable wheel in non-scrolling windows - added new window "player2" that behaves exactly as player list window, but allows to select alternate custom layout and could be toggled with 'A' key - added "playerList2: (string)" option that allows to select different player list layout for alternate player list window, by default it will be "n T R N l M K W L r O D d " - fixed bug that caused main thread to continue in case player died while scrolling message window using scrollbar (which forced him close client window and reconnect) - fixed incorrect behavior of 'windowMove: off' feature. Previously window would snap back to wrong place if the main window top-left corner was not (0,0) coordinates - long lines are now wrapped by words instead of by chars. Maximum message length was reduced to 4 full message lines (4 * 69 characters) - message input window will now show Sender->Recipient even when the input line is longer than 69 characters - changed 'Forum' URL on metaserver window to open Google's r.g.n location There are also several internal changes, such as a new format for error messages. Index: findslot.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/findslot.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- findslot.c 21 Jan 2003 21:28:41 -0000 1.1.1.1 +++ findslot.c 21 Apr 2006 12:00:06 -0000 1.2 @@ -99,9 +99,6 @@ findslot (void) { int oldcount = -1; - W_Window waitWin, qwin, countWin, motdButtonWin; - - W_Window motdWin; extern int MaxMotdLine; int WaitMotdLine = 0; int showMotd = booleanDefault ("showMotd", 1); @@ -119,7 +116,7 @@ Exit_Sound (); #endif - printf ("Shit! Ghostbusted!\n"); + LineToConsole ("Shit! Ghostbusted!\n"); terminate (0); } readFromServer (NULL); @@ -165,7 +162,7 @@ Exit_Sound (); #endif - printf ("Damn, We've been ghostbusted!\n"); + LineToConsole ("Damn, We've been ghostbusted!\n"); terminate (0); } while (W_EventsPending ()) @@ -224,7 +221,7 @@ Exit_Sound (); #endif - printf ("OK, bye!\n"); + LineToConsole ("OK, bye!\n"); terminate (0); } break; Index: smessage.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/smessage.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- smessage.c 12 Apr 2006 04:20:04 -0000 1.2 +++ smessage.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -22,16 +22,17 @@ static int lcount; static int HUDoffset; -static char buf[1024]; +static char buf[MAX_MLENGTH]; static char cursor = '_'; static char mbuf[80]; + /* Routines to handle multi-window messaging */ void DisplayMessage () { int length; - int offset = 0; + char tmp[1024]; length = strlen (outmessage); @@ -42,21 +43,22 @@ if (length > 80) { - offset = length - 80; + strncpy (tmp, outmessage, 10); + tmp[10] = '\0'; // have to null terminate, because strncpy doesn't + strncat (tmp, outmessage + length - 70, 80); length = 80; } + else + strcpy (tmp, outmessage); #ifdef XTRA_MESSAGE_UI if (HUDoffset) - W_WriteText (w, 5, HUDoffset, textColor, - outmessage + offset, length, W_RegularFont); + W_WriteText (w, 5, HUDoffset, textColor, tmp, length, W_RegularFont); #endif - W_WriteText (messagew, 5, 5, textColor, - outmessage + offset, length, W_RegularFont); - - printf ("length: %d, offset %d\n", length, offset); + W_WriteText (messagew, 5, 5, textColor, tmp, length, W_RegularFont); } + void AddChar (char *twochar) { @@ -74,6 +76,7 @@ twochar, 2, W_RegularFont); } + void BlankChar (int HUDoffsetcol, int len) @@ -90,6 +93,7 @@ W_Textwidth * (len), W_Textheight); } + void DrawCursor (int col) { @@ -202,7 +206,7 @@ mdisplayed = 0; messpend = 0; message_off (); - for (i = 0; i < 1024; i++) + for (i = 0; i < MAX_MLENGTH; i++) { outmessage[i] = '\0'; } @@ -224,7 +228,7 @@ if (strlen (clipString) == 0) break; - if (lcount + strlen (clipString) >= 1024) + if (lcount + strlen (clipString) >= MAX_MLENGTH) { W_Beep (); warning ("Clipboard text is too long to fit"); @@ -254,7 +258,7 @@ case '\r': /* send message */ buf[lcount - ADDRLEN] = '\0'; messpend = 0; - for (i = 0; i < 1024; i++) + for (i = 0; i < MAX_MLENGTH; i++) { outmessage[i] = '\0'; } @@ -347,7 +351,7 @@ break; default: /* add character */ - if (lcount >= 1024) + if (lcount >= MAX_MLENGTH) { W_Beep (); break; @@ -364,55 +368,112 @@ } } -// SRS - should look at using proper variable types here + +void +send_pmessage (char *str, + short recip, + short group) +{ + char newbuf[100]; + char * cstr; + + /* message length failsafe and last message saving - jn 6/17/93 */ + lastMessage[0] = '\0'; + strncat (lastMessage, str, 69); + cstr = lastMessage; + + switch (group) + { + +#ifdef TOOLS + case MTOOLS: + sendTools (cstr); + break; +#endif + + case MMOO: + strcpy (defaultsFile, cstr); + sprintf (mbuf, "changing defaultsFile to %s", cstr); + warning (mbuf); + break; + default: + sendMessage (cstr, group, recip); + } + + if ((group == MTEAM && recip != me->p_team) || + (group == MINDIV && recip != me->p_no)) + { + sprintf (newbuf, "%s %s", getaddr2 (group, recip), cstr); + newbuf[79] = 0; + dmessage (newbuf, (unsigned char) group, (unsigned char) me->p_no, + (unsigned char) recip); + } +} + + +void pmessage (char *str, short recip, short group) { - char newbuf[100]; - char * cstr; - int length; + char * str1; /* temporary string 1 */ + char * str2; /* temporary string 2 */ + char buf[100]; /* temporary buffer */ int i = 0; - length = strlen (str); + str1 = str; /* save original string pointer */ - do + while (strlen (str1) > 0) { - /* message length failsafe and last message saving - jn 6/17/93 */ - lastMessage[0] = '\0'; - strncat (lastMessage, str + i, 69); - cstr = lastMessage; - - switch (group) + if (strlen (str1) > 69) { + if (str1[69] == ' ') + { + /* We're lucky to fall on space as next character */ + strncpy (buf, str1, 69); + buf[69] = 0; + send_pmessage (buf, recip, group); + str1 += 69 + 1; /* skip the space */ + } + else + { + /* Have to search for first occurence of ' ' from the end + of the string */ -#ifdef TOOLS - case MTOOLS: - sendTools (cstr); - break; -#endif + str2 = str1 + 69; - case MMOO: - strcpy (defaultsFile, cstr); - sprintf (mbuf, "changing defaultsFile to %s", cstr); - warning (mbuf); - break; - default: - sendMessage (cstr, group, recip); - } + while (str2[0] != ' ' && str2 != str1) + str2--; - if ((group == MTEAM && recip != me->p_team) || - (group == MINDIV && recip != me->p_no)) + if (str2 == str1) + { + /* Well, we should send the whole string because + we have no spaces here */ + strncpy (buf, str1, 69); + buf[69] = 0; + send_pmessage (buf, recip, group); + str1 += 69; + } + else + { + /* Let's send just the part until space */ + strncpy (buf, str1, str2 - str1); + buf[str2 - str1] = 0; + send_pmessage (buf, recip, group); + str1 += (str2 - str1) + 1; /* skip space */ + } + } + } + else { - sprintf (newbuf, "%s %s", getaddr2 (group, recip), cstr); - newbuf[79] = 0; - dmessage (newbuf, (unsigned char) group, (unsigned char) me->p_no, - (unsigned char) recip); + /* Just output everything as is */ + strcpy (buf, str1); + buf[strlen (str1)] = 0; + send_pmessage (buf, recip, group); + str1 += strlen (str1); } - i += 69; - - } while (i < length); + } message_off (); } @@ -530,7 +591,7 @@ } else { - /* printf("smessage:getaddr2 recip=%d\n",recip); */ + /* LineToConsole ("smessage:getaddr2 recip=%d\n",recip); */ (void) sprintf (&addrmesg[5], "%c%c ", teamlet[players[recip].p_team], shipnos[recip]); } @@ -553,6 +614,8 @@ return (addrmesg); } + +void message_on (void) { messageon = 1; @@ -565,6 +628,8 @@ #endif } + +void message_off (void) { messageon = 0; @@ -572,7 +637,9 @@ W_DefineMapcursor (mapw); } + #ifdef XTRA_MESSAGE_UI +void message_hold (void) { //char twochar[2] = { '#', ' ' }; @@ -581,6 +648,7 @@ } #endif + /* Used in NEWMACRO, useful elsewhere also */ int getgroup (char addr, @@ -685,6 +753,7 @@ } +void pnbtmacro (int c) { switch (macro[c].who) Index: bccnetrek.rc =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/bccnetrek.rc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bccnetrek.rc 20 Apr 2006 06:13:50 -0000 1.3 +++ bccnetrek.rc 21 Apr 2006 12:00:06 -0000 1.4 @@ -1,8 +1,8 @@ #include "resource.h" 1 VERSIONINFO -FILEVERSION 4, 4, 0, 1 -PRODUCTVERSION 4, 4, 0, 1 +FILEVERSION 4, 4, 0, 4 +PRODUCTVERSION 4, 4, 0, 4 FILEOS VOS_DOS_WINDOWS32 FILETYPE VFT_APP { BLOCK "StringFileInfo" Index: hintwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/hintwin.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- hintwin.c 14 Apr 2006 12:24:00 -0000 1.2 +++ hintwin.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -1,15 +1,10 @@ /******************************************************************************/ /*** File: hintwin.c ***/ /*** ***/ -/*** Function: ***/ -/*** hintwin.c copyright 2003 Stas Pirogov Free to use, hack, etc. Just keep -/*** these credits here. Use of this code may be dangerous to your health -/*** and/or system. Its use is at your own risk. I assume no responsibility for -/*** damages, real, potential, or imagined, resulting from the use of it. -/*** +/*** Function: set of hint window manipulation functions ***/ +/*** ***/ /******************************************************************************/ - #include <stdio.h> #include <signal.h> #include <sys/types.h> Index: winmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/winmain.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- winmain.c 12 Apr 2006 04:20:04 -0000 1.2 +++ winmain.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -152,13 +152,12 @@ //Kick winsock into gear if (WSAStartup (MAKEWORD (1, 1), &data) != 0) { - fprintf (stderr, - "Could not find WINSOCK.DLL / WINSOCK initializtion failed\n"); + LineToConsole ("Could not find WINSOCK.DLL / WINSOCK initializtion failed\n"); return -1; } if (data.wVersion < MAKEWORD (1, 1)) { - fprintf (stderr, "Bad WINSOCK.DLL version (need at least v1.1).\n"); + LineToConsole ("Bad WINSOCK.DLL version (need at least v1.1).\n"); WSACleanup (); return -1; } @@ -264,7 +263,7 @@ void perror (const char *str) { - printf ("%s: errno = %d, WSALast = %d\n", str, errno, WSAGetLastError ()); + LineToConsole ("%s: errno = %d, WSALast = %d\n", str, errno, WSAGetLastError ()); } @@ -289,27 +288,27 @@ if (timeout) { ms = (timeout->tv_sec << 10) + (timeout->tv_usec >> 10); - printf ("sec = %d, usec = %d\n", timeout->tv_sec, timeout->tv_usec); + LineToConsole ("sec = %d, usec = %d\n", timeout->tv_sec, timeout->tv_usec); } else ms = INFINITE; - printf ("ms=%d, ", ms); + LineToConsole ("ms=%d, ", ms); /* Scan through the array, copying and looking for W_Socket */ for (i = j = 0; i < readfds->fd_count; i++) { if (readfds->fd_array[i] != W_SOCKET) { - printf ("handle %d, sock=%d\n", readfds->fd_array[i], sock); + LineToConsole ("handle %d, sock=%d\n", readfds->fd_array[i], sock); handles[j++] = readfds->fd_array[i]; } else wsocket_present = 1; } - printf ("handles=%d, handle[0]=%d, wsocket=%d\n", j, handles[0], - wsocket_present); + LineToConsole ("handles=%d, handle[0]=%d, wsocket=%d\n", j, handles[0], + wsocket_present); readfds->fd_count = 1; @@ -335,7 +334,7 @@ if (got == WAIT_TIMEOUT) { - printf ("Timeout\n"); + LineToConsole ("Timeout\n"); readfds->fd_count = 0; // clear return 0; } @@ -343,7 +342,7 @@ readfds->fd_array[0] = handles[got - WAIT_OBJECT_0]; return 1; - printf ("Success! Returned %d\n", got); + LineToConsole ("Success! Returned %d\n", got); } #endif Index: defaults.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- defaults.c 19 Apr 2006 15:18:27 -0000 1.6 +++ defaults.c 21 Apr 2006 12:00:06 -0000 1.7 @@ -54,6 +54,12 @@ NULL } }, + {"allowWheelActions", &allowWheelActions, RC_BOOL, + { + "allow mouse wheel to produce action in non-scrollable windows", + NULL + } + }, {"autoQuit", &autoQuit, RC_INT, { "Autoquit timer (default 60)", @@ -74,7 +80,7 @@ }, {"colorClient", &colorClient, RC_INT, { - "What type of ship bitmaps to load", + "What type of ship bitmaps to use", "0 - mono", "1 - new color bitmaps (default)", "2 - old color bitmaps", @@ -723,7 +729,7 @@ DefaultsLoaded = 1; #ifdef DEBUG - printf ("Initdefaults\n"); + LineToConsole ("Initdefaults\n"); #endif /* Clear defaults if they exist */ @@ -750,7 +756,8 @@ fp = fopen (deffile, "r"); if (!fp) return; - printf ("Reading defaults file %s\n", deffile); + + LineToConsole ("Reading defaults file %s\n", deffile); #ifdef NBT macrocnt = 0; /* reset macros */ @@ -784,15 +791,16 @@ { if (macrocnt == MAX_MACRO) { - fprintf (stderr, "Maximum number of macros is %d\n", - MAX_MACRO); + LineToConsole ("Maximum number of macros is %d\n", MAX_MACRO); } else { str = file + 6; c = getctrlkey ((unsigned char **) &str); if (c == '?') - fprintf (stderr, "Cannot use '?' for a macro\n"); + { + LineToConsole ("Cannot use '?' for a macro\n"); + } else { macro[macrocnt].type = NBTM; @@ -824,15 +832,16 @@ { if (macrocnt == MAX_MACRO) { - fprintf (stderr, "Maximum number of macros is %d\n", - MAX_MACRO); + LineToConsole ("Maximum number of macros is %d\n", MAX_MACRO); } else { str = file + 4; c = getctrlkey ((unsigned char **) &str); if (c == '?') - fprintf (stderr, "Cannot use '?' for a macro\n"); + { + LineToConsole ("Cannot use '?' for a macro\n"); + } else { macro[macrocnt].key = c; @@ -879,12 +888,9 @@ #ifdef MULTILINE_MACROS if (keysused[macro[macrocnt].key]) { - printf - ("Multiline macros of nonstandard types are not recommended.\n"); - printf - ("You might experience strange behaviour of macros.\n"); - printf ("Type: unspecified macro, key: %c.\n", - macro[macrocnt].key); + LineToConsole ("Multiline macros of nonstandard types are not recommended.\n"); + LineToConsole ("You might experience strange behaviour of macros.\n"); + LineToConsole ("Type: unspecified macro, key: %c.\n", macro[macrocnt].key); } #endif /* MULTILINE_MACROS */ } @@ -989,8 +995,7 @@ if ((keycnt = strlen (keys)) == MAX_KEY - 1) { - fprintf (stderr, "Maximum number of keys is %d\n", - MAX_KEY - 1); + LineToConsole ("Maximum number of keys is %d\n", MAX_KEY - 1); } else { @@ -1342,6 +1347,8 @@ if (timerType < T_NONE || timerType >= T_TOTAL) timerType = T_SHIP; + allowWheelActions = booleanDefault ("allowWheelActions", allowWheelActions); + tpDotDist = intDefault ("tpDotDist", tpDotDist); omitTeamLetter = booleanDefault ("omitTeamLetter", omitTeamLetter); beepOnPrivateMessage = booleanDefault ("beepOnPrivateMessage", beepOnPrivateMessage); @@ -1598,7 +1605,6 @@ updateWindowsGeometry (qwin); updateWindowsGeometry (statwin); - updateWindowsGeometry (scanwin); updateWindowsGeometry (war); */ } @@ -1628,7 +1634,7 @@ #ifdef DEBUG #define CHECK_FILE \ - printf("Checking for file %s...\n", found); \ + LineToConsole ("Checking for file %s...\n", found); \ accessible = access(found, R_OK); \ if (accessible == 0)\ return 1; @@ -1650,7 +1656,7 @@ /* check current directory first */ #ifdef DEBUG - printf ("Checking for file %s\n", fname); + LineToConsole ("Checking for file %s\n", fname); #endif accessible = access (fname, R_OK); if (accessible == 0) Index: data.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- data.c 19 Apr 2006 15:18:27 -0000 1.6 +++ data.c 21 Apr 2006 12:00:06 -0000 1.7 @@ -46,7 +46,7 @@ int shrinkPhaserOnMiss = 0; int colorClient = 1; /* Use new colorized bitmaps SRS 11/12/99 */ -int dynamicBitmaps = 1; /* in game switching of ship bitmaps, default to on */ +int dynamicBitmaps = 1; /* in game switching of ship bitmaps, default to on */ int newDashboard = 2; /* use new graphic * dashboard, 6/2/93 LAB */ int old_db = 0; /* should be same as @@ -90,7 +90,7 @@ int infomapped = 0; int mustexit = 0; int messtime = 5; -int keepPeace = 0; +int keepPeace = 1; #ifdef GATEWAY unsigned LONG netaddr = 0; /* for blessing */ @@ -98,7 +98,6 @@ #endif int msgBeep = 1; /* ATM - msg beep */ -int scanmapped = 0; /* ATM - scanners */ int planetBitmap = 0; @@ -216,12 +215,10 @@ int updatesPerSec = 10; #ifdef META -char *metaServer = "metaserver.netrek.org"; /* Default Metaserver */ -char *metaServer1 = "metaserver.us.netrek.org"; /* First Metaserver */ -char *metaServer2 = "metaserver2.us.netrek.org"; /* Second Metaserver */ -char *metaServer3 = "metaserver.eu.netrek.org"; /* Third Metaserver */ -int metaPort = 3521; /* HAVE to use nicely - * formated version */ +/* Metaservers list */ +char *metaServer[] = {"metaserver.us.netrek.org", + "metaserever2.us.netrek.org"}; +int metaPort = 3521; #ifdef METAPING int metaPing = 1; /* ICMP ping the metaserverlist */ #endif @@ -335,8 +332,9 @@ W_Window messagew, w, mapw, statwin, baseWin = 0, infow, tstatw, war, warnw, helpWin, teamWin[4], qwin, messwa, messwt, messwi, messwk, - playerw, planetw, rankw, optionWin = 0, reviewWin; -W_Window scanw, scanwin, udpWin, phaserwin, hintWin; + playerw, playerw2, planetw, rankw, optionWin = 0, reviewWin; +W_Window udpWin, phaserwin, hintWin; +W_Window waitWin, qwin, countWin, motdButtonWin, motdWin; #ifdef SHORT_PACKETS W_Window spWin = NULL; @@ -360,7 +358,7 @@ W_Window pStats = NULL; char deathmessage[80]; -char outmessage[1024]; /* maximum message length */ +char outmessage[MAX_MLENGTH]; /* maximum message length */ char *xdisplay_name = NULL; @@ -505,7 +503,7 @@ struct dmacro_list rcm_msg[] = { {'0', "none", "Unknown RCM message"}, {'1', "kill", "GOD->ALL %i (%S) (%T%c%?%a>0%{+%a armies%!%}) was kill %?%d>0%{%k%!(NO CREDIT)%} for %u (%r%p) %?%w>0%{%W%!%}"}, - {'2', "planet", "GOD->ALL %i (%S) (%T%c%?%a>0%{+%a armies%!%} killed by %l (%z) %?%w>0%{%W%!%}"}, + {'2', "planet", "GOD->ALL %i (%S) (%T%c%?%a>0%{+%a armies%!%}) killed by %l (%z) %?%w>0%{%W%!%}"}, {'3', "bomb", "%N->%Z We are being attacked by %i (%T%c) who is %d%% damaged."}, {'4', "destroy", "%N->%Z %N destroyed by %i (%T%c)"}, {'5', "take", "%N->%O %N taken by %i (%T%c)"}, @@ -654,7 +652,8 @@ char *ind_ship_bmp_M; // Added to fix thread creation issue -HANDLE ThreadCreated = NULL; +HANDLE MainThread = NULL; +HANDLE InputThread = NULL; // missing variables int forceDisplay = 0; @@ -711,3 +710,14 @@ SDBUFFER * mapSDB = NULL; int disableWinkey = 1; /* disable WinKey + ContextKey by default */ + +int exitFlag = 0; /* no exit by default */ + +struct cons_buffer * consHead = NULL; // head of the linked list for console buffer +struct cons_buffer * consTail = NULL; // tail of the linked list for console buffer + +int allowWheelActions = 1; /* allow wheel actions */ + +WNDPROC lpfnDefRichEditWndProc; /* default window proc */ + +int richText = 0; /* temporary variable to select rich text message windows */ \ No newline at end of file Index: defwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/defwin.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- defwin.c 12 Apr 2006 04:20:03 -0000 1.2 +++ defwin.c 21 Apr 2006 12:00:06 -0000 1.3 @@ -18,6 +18,25 @@ * the use of it.) * * $Log$ + * Revision 1.3 2006/04/21 12:00:06 modemhero + * This large patch brings the client up to Stas's version 4.4.0.4. The visible changes to the user are: + * - added "allowWheelActions: (on)/off" to be able to disable wheel in non-scrolling windows + * - added new window "player2" that behaves exactly as player list window, but allows to + * select alternate custom layout and could be toggled with 'A' key + * - added "playerList2: (string)" option that allows to select different player list layout + * for alternate player list window, by default it will be "n T R N l M K W L r O D d " + * - fixed bug that caused main thread to continue in case player died while scrolling + * message window using scrollbar (which forced him close client window and reconnect) + * - fixed incorrect behavior of 'windowMove: off' feature. Previously window would snap + * back to wrong place if the main window top-left corner was not (0,0) coordinates + * - long lines are now wrapped by words instead of by chars. Maximum message length was + * reduced to 4 full message lines (4 * 69 characters) + * - message input window will now show Sender->Recipient even when the input line is longer + * than 69 characters + * - changed 'Forum' URL on metaserver window to open Google's r.g.n location + * + * There are also several internal changes, such as a new format for error messages. + * * Revision 1.2 2006/04/12 04:20:03 modemhero * Update to version 4.4.0.3 * @@ -504,7 +523,7 @@ x = xo + INDENT; break; default: - fprintf (stderr, "Unknown type.\n"); + LineToConsole ("Unknown type.\n"); break; } } Index: feature.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/feature.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- feature.c 18 Apr 2006 13:41:48 -0000 1.2 +++ feature.c 21 Apr 2006 12:00:06 -0000 1.3 @@ -112,7 +112,7 @@ (char) (f->arg2 ? *f->arg2 : 0)); #ifdef DEBUG - printf ("(C->S) %s (%c): %d\n", f->name, f->feature_type, f->value); + LineToConsole ("(C->S) %s (%c): %d\n", f->name, f->feature_type, f->value); #endif } } @@ -131,7 +131,7 @@ #ifdef DEBUG if (packet->type != SP_FEATURE) { - printf ("Packet type %d sent to checkFeature!\n", packet->type); + LineToConsole ("Packet type %d sent to checkFeature!\n", packet->type); return; } #endif @@ -142,7 +142,7 @@ #ifdef TOOLS W_WriteText (toolsWin, 0, 0, textColor, buf, strlen (buf), W_RegularFont); #else - printf ("%s\n", buf); + LineToConsole ("%s\n", buf); #endif for (i = 0; features[i].name != 0; i++) @@ -163,7 +163,7 @@ } if (features[i].name == 0) { - printf ("Feature %s from server unknown to client!\n", packet->name); + LineToConsole ("Feature %s from server unknown to client!\n", packet->name); } /* special cases: */ if (strcmpi (packet->name, "FEATURE_PACKETS") == 0) Index: parsemeta.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/parsemeta.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parsemeta.c 15 Apr 2006 09:58:25 -0000 1.3 +++ parsemeta.c 21 Apr 2006 12:00:07 -0000 1.4 @@ -140,7 +140,9 @@ if ((hp = gethostbyname (host)) == NULL) { if (verbose) - fprintf (stderr, "unknown host '%s'\n", host); + { + LineToConsole ("unknown host '%s'\n", host); + } return (-1); } else @@ -182,7 +184,7 @@ #endif #ifdef DEBUG - printf ("In parseInput\n"); + LineToConsole ("In parseInput\n"); #endif /* Create some space to hold the entries that will be read. More space can @@ -302,13 +304,13 @@ { #ifdef DEBUG - printf ("HOST:%-30s PORT:%-6d %12s %-5d %d %c\n", - serverlist[num_servers].address, - serverlist[num_servers].port, - statusStrings[serverlist[num_servers].status], - serverlist[num_servers].players, - serverlist[num_servers].RSA_client, - serverlist[num_servers].typeflag); + LineToConsole ("HOST:%-30s PORT:%-6d %12s %-5d %d %c\n", + serverlist[num_servers].address, + serverlist[num_servers].port, + statusStrings[serverlist[num_servers].status], + serverlist[num_servers].players, + serverlist[num_servers].RSA_client, + serverlist[num_servers].typeflag); #endif ++num_servers; @@ -328,37 +330,34 @@ char *sockbuf, *buf; int bufleft = BUF - 1; int len; - int sock; + int sock = 0; + int i = 0; - if ((stringDefault ("metaServer")) != NULL) - metaServer = stringDefault ("metaServer"); + if (stringDefault ("metaServer") != NULL) + metaServer[0] = stringDefault ("metaServer"); metaPort = intDefault ("metaPort", metaPort); - if ((sock = open_port (metaServer, metaPort, 1)) <= 0) + /* Attempt connecting to all servers one by one */ + do { - fprintf (stderr, "Cannot connect to MetaServer (%s , %d)\n", - metaServer, metaPort); + LineToConsole ("Calling %s on port %d\n", metaServer[i], metaPort); - /* Okie, let's just try default servers */ - if ((sock = open_port (metaServer1, metaPort, 1)) <= 0) + sock = open_port (metaServer[i], metaPort, 0); + + if (sock <= 0) { - fprintf (stderr, "Cannot connect to MetaServer (%s , %d)\n", - metaServer1, metaPort); - if ((sock = open_port (metaServer2, metaPort, 1)) <= 0) - { - fprintf (stderr, "Cannot connect to MetaServer (%s , %d)\n", - metaServer2, metaPort); - if ((sock = open_port (metaServer3, metaPort, 1)) <= 0) - { - fprintf (stderr, "Cannot connect to MetaServer (%s , %d)\n", - metaServer3, metaPort); - return 0; - } - } + LineToConsole ("Cannot connect to MetaServer (%s port %d)\n", + metaServer[i], metaPort); } - } + i++; + + } while (sock <= 0 && i <= 1); /* i shouldn't be bigger than number of servers */ + + /* Still no connection -> return */ + if (sock <= 0) + return 0; /* Allocate a buffer and read until full */ buf = sockbuf = (char *) malloc (BUF); @@ -367,7 +366,7 @@ bufleft -= len; buf += len; #ifdef DEBUG - printf ("Read %d bytes from Metaserver\n", len); + LineToConsole ("Read %d bytes from Metaserver\n", len); #endif } closesocket (sock); @@ -401,10 +400,10 @@ if (out == NULL) { - fprintf (stderr, + LineToConsole ( "Can not write to the metaCache temporary file `%s'.\n", tmpFileName); - fprintf (stderr, "Meta-server read will not be cached.\n"); + LineToConsole ("Meta-server read will not be cached.\n"); } } else @@ -451,15 +450,14 @@ if (!cacheName) { - fprintf (stderr, - "You must define the .xtrekrc variable `metaCache' in\n"); - fprintf (stderr, "order to use the `show known servers' option.\n"); + LineToConsole ("You must define the .xtrekrc variable `metaCache' in\n"); + LineToConsole ("order to use the `show known servers' option.\n"); return 0; } else if (!findfile (cacheName, cacheFileName) || !(in = fopen (cacheFileName, "r"))) { - fprintf (stderr, + LineToConsole ( "The metaCache file `%s' is empty or not accessable.\n", cacheName); return 0; @@ -476,7 +474,7 @@ bufleft -= len; buf += len; #ifdef DEBUG - printf ("Read %d bytes from Metaserver cache file\n", len); + LineToConsole ("Read %d bytes from Metaserver cache file\n", len); #endif } *buf = 0; /* End of buffer marker */ @@ -701,7 +699,7 @@ /* Additional Help Options */ W_WriteText (metaWin, 0, num_servers + 1, W_Yellow, - " Netrek Homepage | Newbie Manual | FAQ | Dogfight Manual", 63, 0); + " Netrek Homepage | Newbie Manual | Forum | FAQ | Dogfight Manual", 67, 0); /* Map window */ W_MapWindow (metaWin); @@ -742,7 +740,7 @@ int x; #ifdef DEBUG - printf ("Got meta window action, y=%d\n", data->y); + LineToConsole ("Got meta window action, y=%d\n", data->y); #endif if ((data->y >= 0) && (data->y < num_servers)) { @@ -751,7 +749,7 @@ if (data->key == W_RBUTTON) /* Guess at an observer port */ { xtrekPort++; - printf ("Attempting to observe on port %d...\n", xtrekPort); + LineToConsole ("Attempting to observe on port %d...\n", xtrekPort); } serverName = strdup (slist->address); serverType = metaGetServerType (slist->typeflag); @@ -762,6 +760,8 @@ slist->status = statusConnecting; metarefresh (data->y); + LineToConsole ("Checking %s on port %d\n", serverName, xtrekPort); + if ((sock = open_port (serverName, xtrekPort, 0)) <= 0) { slist->status = statusCantConnect; @@ -784,13 +784,15 @@ else if (data->y == num_servers + 1) /* Help Line */ { x = data->x / W_Textwidth; - if (x >= 0 && x <= 23) /* Netrek Home Page */ + if (x >= 0 && x <= 19) /* Netrek Home Page */ ShellExecute (NULL, "open", "http://www.netrek.org", NULL, NULL, SW_SHOWNORMAL); - else if (x >= 25 && x <= 39) /* Newbie Manual */ + else if (x >= 21 && x <= 35) /* Newbie Manual */ ShellExecute (NULL, "open", "http://www.netrek.org/cow/current/newbie.html", NULL, NULL, SW_SHOWNORMAL); - else if (x >= 41 && x <= 45) /* FAQ */ + else if (x >= 37 && x <= 43) /* Forums */ + ShellExecute (NULL, "open", "http://groups-beta.google.com/group/rec.games.netrek", NULL, NULL, SW_SHOWNORMAL); + else if (x >= 45 && x <= 49) /* FAQ */ ShellExecute (NULL, "open", "http://www.inl.org/netrek/netrekFAQ.html", NULL, NULL, SW_SHOWNORMAL); - else if (x >= 47 && x <= 63) /* Dogfight Manual */ + else if (x >= 51 && x <= 67) /* Dogfight Manual */ ShellExecute (NULL, "open", "http://cha.rlie.nl/dfmanual/", NULL, NULL, SW_SHOWNORMAL); } } @@ -825,7 +827,8 @@ &IDThread); // returns thread identifier // Check the return value for success. - if (hThread == NULL) printf("CreateThread error\n"); + if (hThread == NULL) + LineToConsole ("CreateThread error\n"); } #endif @@ -912,8 +915,7 @@ // What happened? void metaPing_ReportError(char *pWhere) { - fprintf(stderr,"\n%s error: %d\n", pWhere, - WSAGetLastError()); + LineToConsole ("\n%s error: %d\n", pWhere, WSAGetLastError()); } Index: helpwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/helpwin.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- helpwin.c 12 Apr 2006 04:20:03 -0000 1.2 +++ helpwin.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -127,6 +127,7 @@ "U Show rankings window", "m Message Window Zoom", "/ Toggle sorted player list", + "A Toggle alternate player list", ": Toggle message logging", "+ Show UDP options window", "= Update all", Index: dmessage.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/dmessage.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dmessage.c 18 Apr 2006 13:41:48 -0000 1.3 +++ dmessage.c 21 Apr 2006 12:00:06 -0000 1.4 @@ -102,12 +102,10 @@ buf[79] = '\0'; - /* printf("%s\n", buf); */ - #ifdef TOOLS W_WriteText (toolsWin, 0, 0, textColor, buf, strlen (buf), W_RegularFont); #else - W_MessageAllowedWindows (WAM_INDIV, 0, 0, W_White, buf, stlen (buf), 0); + W_MessageAllowedWindows (WAM_INDIV, 0, 0, W_White, buf, strlen (buf), 0); #endif } @@ -178,19 +176,17 @@ } else { - printf ("%s: %s\n", timebuf, message); + LineToConsole ("%s: %s\n", timebuf, message); } } if (!(logging && logFile == NULL) && flags == conq) { /* output conquer stuff to stdout in addition to message window */ - fprintf (stdout, "%s\n", message); + LineToConsole ("%s\n", message); if (instr (message, "kill")) { - fprintf (stdout, - "NOTE: The server here does not properly set message flags\n"); - fprintf (stdout, - "You should probably pester the server god to update....\n"); + LineToConsole ("NOTE: The server here does not properly set message flags\n"); + LineToConsole ("You should probably pester the server god to update....\n"); } } if (flags == (MCONFIG + MINDIV + MVALID)) @@ -205,7 +201,7 @@ if ((flags == team) && !strncmp (message + 10, " ", 5) && (message[15] == 0)) { - printf ("dmessage:flags==team PIG call from=%d\n", from); + LineToConsole ("dmessage:flags==team PIG call from=%d\n", from); pmessage (pigcall, from, MINDIV); } } @@ -226,13 +222,13 @@ W_MessageAllowedWindows (WAM_INDIV, 0, 0, color, message, len, 0); if (!strncmp (message + 10, " ", 5) && (message[15] == 0)) { - printf ("dmessage:MINDIV PIG call from=%d\n", from); + LineToConsole ("dmessage:MINDIV PIG call from=%d\n", from); pmessage (pigcall, from, MINDIV); } #ifdef CLUECHECKBORG if (from == 255) { - printf ("dmessage: Message from God %s\n", message); + LineToConsole ("dmessage: Message from God %s\n", message); ClueRespond (message); } #endif @@ -275,8 +271,8 @@ } else { - printf ("%s ", message); - printf ("%s\n", timebuf); + LineToConsole ("%s ", message); + LineToConsole ("%s\n", timebuf); } } return; @@ -299,8 +295,8 @@ } else { - printf ("%s ", message); - printf ("%s\n", timebuf); + LineToConsole ("%s ", message); + LineToConsole ("%s\n", timebuf); } } break; @@ -326,8 +322,8 @@ } else { - printf ("%s ", message); - printf ("%s\n", timebuf); + LineToConsole ("%s ", message); + LineToConsole ("%s\n", timebuf); } } break; @@ -347,8 +343,8 @@ } else { - printf ("%s", message); - printf ("%s\n", timebuf); + LineToConsole ("%s", message); + LineToConsole ("%s\n", timebuf); } } break; Index: udpopt.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/udpopt.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- udpopt.c 21 Jan 2003 21:28:43 -0000 1.1.1.1 +++ udpopt.c 21 Apr 2006 12:00:07 -0000 1.2 @@ -61,8 +61,8 @@ strcat (buf, "Verifying UDP connection"); break; default: - fprintf (stderr, "netrek: UDP error: bad commStatus (%d)\n", - commStatus); + LineToConsole ("netrek: UDP error: bad commStatus (%d)\n", + commStatus); } break; case UDP_DROPPED: @@ -145,7 +145,7 @@ strcpy (buf, "Done"); break; default: - fprintf (stderr, "netrek: UDP error: bad udprefresh(%d) call\n", i); + LineToConsole ("netrek: UDP error: bad udprefresh(%d) call\n", i); } W_WriteText (udpWin, 0, i, textColor, buf, strlen (buf), 0); Index: input.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- input.c 15 Apr 2006 09:58:25 -0000 1.3 +++ input.c 21 Apr 2006 12:00:07 -0000 1.4 @@ -632,7 +632,7 @@ #endif /* SHIFTED_MOUSE */ default: - fprintf (stderr, "%c ignored in buttonmap\n", *(str - 1)); + LineToConsole ("%c ignored in buttonmap\n", *(str - 1)); break; } } @@ -673,9 +673,12 @@ event detection and handling into the select() mechanism. It probably also increases performance */ // Close HANDLE from previously created thread. - if (ThreadCreated != NULL) - CloseHandle (ThreadCreated); - THREAD (input2); + if (InputThread != NULL) + { + WaitForSingleObject (InputThread, INFINITE); + CloseHandle (InputThread); + } + InputThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) input2, 0, 0, &InputThreadID); while (1) { @@ -684,6 +687,9 @@ process_event (); } + /* clear exitFlag */ + exitFlag = 0; + while (W_EventsPending ()) W_NextEvent (&event); @@ -745,8 +751,8 @@ if (isServerDead ()) { - printf ("Whoops! We've been ghostbusted!\n"); - printf ("Pray for a miracle!\n"); + LineToConsole ("Whoops! We've been ghostbusted!\n"); + LineToConsole ("Pray for a miracle!\n"); /* UDP fail-safe */ commMode = commModeReq = COMM_TCP; commSwitchTimeout = 0; @@ -758,7 +764,7 @@ udprefresh (UDP_STATUS); } connectToServer (nextSocket); - printf ("Yea! We've been resurrected!\n"); + LineToConsole ("Yea! We've been resurrected!\n"); } } @@ -968,8 +974,8 @@ intrupt (); if (isServerDead ()) { - printf ("Shit, We've been ghostbusted\n"); - printf ("hope you're not in a base\n"); + LineToConsole ("Shit, We've been ghostbusted\n"); + LineToConsole ("hope you're not in a base\n"); /* UDP fail-safe */ commMode = commModeReq = COMM_TCP; commSwitchTimeout = 0; @@ -981,7 +987,7 @@ udprefresh (UDP_STATUS); } connectToServer (nextSocket); - printf ("We've been resurrected!\n"); + LineToConsole ("We've been resurrected!\n"); map (); } } @@ -1010,7 +1016,7 @@ case W_EV_KEY: #ifdef DEBUG - printf ("W_EV_KEY\n"); + LineToConsole ("W_EV_KEY\n"); #endif if ((handler = W_GetWindowKeyDownHandler (data.Window)) != NULL) @@ -1109,7 +1115,7 @@ case W_EV_KEY_OFF: #ifdef DEBUG - printf ("W_EV_KEY_OFF\n"); + LineToConsole ("W_EV_KEY_OFF\n"); #endif if ((handler = W_GetWindowKeyUpHandler (data.Window)) != NULL) @@ -1122,7 +1128,7 @@ case W_EV_BUTTON: #ifdef DEBUG - printf ("W_EV_BUTTON\n"); + LineToConsole ("W_EV_BUTTON\n"); #endif if ((handler = W_GetWindowButtonHandler (data.Window)) != NULL) @@ -1134,7 +1140,7 @@ case W_EV_EXPOSE: #ifdef DEBUG - printf ("W_EV_EXPOSE\n"); + LineToConsole ("W_EV_EXPOSE\n"); #endif if ((handler = W_GetWindowExposeHandler (data.Window)) != NULL) @@ -1178,7 +1184,7 @@ * fastquit! */ if (data->Window != mapw && data->Window != w && data->Window != infow - && data->Window != scanw && data->Window != playerw) + && data->Window != playerw) return; key = data->key; @@ -1481,7 +1487,7 @@ if (data->Window != w && data->Window != mapw - && data->Window != infow && data->Window != scanwin + && data->Window != infow && data->Window != playerw) return; @@ -1489,9 +1495,9 @@ { int x, y; - if (findMouseInWin (&x, &y, playerw)) - { - data->Window = playerw; + if (findMouseInWin (&x, &y, playerw)) + { + data->Window = playerw; data->x = x; data->y = y; } @@ -1819,15 +1825,6 @@ / 3.14159 * 128.) + 0.5)); } -/******************************************************************************/ -/*** scan.c - Why do you have a func that does nothing? ***/ -/******************************************************************************/ -void -scan (W_Window w, - int x, - int y) -{ -} /******************************************************************************/ /*** detmine() ***/ @@ -1915,8 +1912,9 @@ if (MacroNum > -1) { /* macro identified, who to? */ if (MacroNum >= MAX_MACRO) - fprintf (stderr, - "Unknown Macro Num! There is a macro bug!!\n"); + { + LineToConsole ("Unknown Macro Num! There is a macro bug!!\n"); + } if (!pmacro (MacroNum, data->key, data)) W_Beep (); @@ -2050,7 +2048,7 @@ default: - fprintf (stderr, "Unknown Macro Type! Jeff's a twink!!\n"); + LineToConsole ("Unknown Macro Type! Jeff's a twink!!\n"); warning ("Unknown macro type (eg There is a macro bug)"); return; break; @@ -2095,6 +2093,7 @@ if (infomapped) destroyInfo (); W_UnmapWindow (helpWin); + W_UnmapWindow (playerw2); #ifdef NBT W_UnmapWindow (macroWin); @@ -2108,11 +2107,7 @@ W_UnmapWindow (war); if (optionWin) optiondone (); - if (scanmapped) - { - W_UnmapWindow (scanwin); - scanmapped = 0; - } + if (udpWin) udpdone (); @@ -2488,8 +2483,10 @@ void Key65 (W_Event * data) { - /* W_ShowBitmaps(); */ - emptyKey (); + if (W_IsMapped (playerw2)) + W_UnmapWindow (playerw2); + else + W_MapWindow (playerw2); } /******************************************************************************/ @@ -2919,16 +2916,7 @@ void Key97 (W_Event * data) { - if (!W_IsMapped (scanwin)) - { - scan (data->Window, data->x, data->y); - } - else - { - if (scanmapped) - W_UnmapWindow (scanwin); - scanmapped = 0; - } + emptyKey (); } /******************************************************************************/ Index: makefile =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- makefile 18 Apr 2006 13:41:48 -0000 1.4 +++ makefile 21 Apr 2006 12:00:07 -0000 1.5 @@ -88,7 +88,7 @@ DEBUGDEFS = -DDEBUG !endif -ROBJ = beeplite.obj check.obj colors.obj data.obj death.obj defaults.obj dmessage.obj\ +ROBJ = beeplite.obj check.obj colors.obj console.obj data.obj death.obj defaults.obj dmessage.obj\ enter.obj findslot.obj getname.obj getship.obj helpwin.obj hintwin.obj inform.obj\ interface.obj newwin.obj option.obj planetlist.obj macrowin.obj\ map.obj playerlist.obj ranklist.obj reserved.obj sintab.obj\ @@ -99,7 +99,7 @@ docwin.obj feature.obj\ string_util.obj local.obj cowmain.obj playback.obj -RSRC = beeplite.c check.c colors.c data.c death.c defaults.c dmessage.c\ +RSRC = beeplite.c check.c colors.c console.c data.c death.c defaults.c dmessage.c\ enter.c findslot.c getname.c getship.c helpwin.c hintwin.c inform.c\ input.c interface.c newwin.c option.c planetlist.c\ macrowin.c map.c playerlist.c ranklist.c redraw.c\ Index: distress.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/distress.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- distress.c 21 Jan 2003 21:28:40 -0000 1.1.1.1 +++ distress.c 21 Apr 2006 12:00:06 -0000 1.2 @@ -137,14 +137,12 @@ if (bufa[*inda]) (*inda)--; - if (!operation) /* incomplete is truth, just - * ask Godel */ + if (!operation) /* incomplete is truth, just ask Godel */ return (1); switch (operation) { - case '=': /* character by character - * equality */ + case '=': /* character by character equality */ if (indc != indh) return (0); for (i = 0; i < indc; i++) @@ -171,11 +169,9 @@ default: warning ("Bad operation in Macro!"); - printf - ("Unrecognizable operation in macro pass3: %c Trying to continue.\n", - operation); - return (1); /* don't know what happened, - * pretend we do */ + LineToConsole ("Unrecognizable operation in macro pass3: %c Trying to continue.\n", + operation); + return (1); /* don't know what happened, pretend we do */ break; } } @@ -219,14 +215,12 @@ bufb[(*indb)++] = bufa[(*inda)++]; } else - return; /* we are full, so we are - * done */ + return; /* we are full, so we are done */ state = 0; continue; break; - case '?': /* the dreaded conditional, - * evaluate it */ + case '?': /* the dreaded conditional, evaluate it */ bufb[*indb] = '0' + solvetest (bufa, inda); (*indb)++; state = 0; @@ -235,10 +229,10 @@ default: warning ("Bad character in Macro!"); - printf - ("Unrecognizable special character in macro pass2: %c Trying to continue.\n", + LineToConsole ( + "Unrecognizable special character in macro pass2: %c Trying to continue.\n", bufa[(*inda) - 1]); - fprintf (stderr, "macro: %s\n", bufa); + LineToConsole ("macro: %s\n", bufa); state = 0; continue; break; @@ -302,8 +296,8 @@ break; default: warning ("Bad character in Macro!"); - printf - ("Unrecognizable special character in macro pass5: %c Trying to continue.\n", + LineToConsole ( + "Unrecognizable special character in macro pass5: %c Trying to continue.\n", buf[index - 1]); } } @@ -347,31 +341,28 @@ { switch (bufa[(*inda)++]) { - case '}': /* done with this - * conditional, return */ + case '}': /* done with this conditional, return */ return (0); break; case '{': /* handle new conditional */ - if (*indb > 0) + if ((bufa[*inda - 3] == '0') && ((*inda - 3) >= 0)) { - (*indb)--; - if (bufb[*indb] == '0') - newflag = 0; - else - newflag = 1; + if (*indb > 0 && include) + (*indb)--; + newflag = 0; } - else /* moron starting with cond, - * assume true */ + else + { + if (*indb > 0 && include) + (*indb)--; newflag = 1; + } if (include) condmacro (bufa, bufb, inda, indb, newflag); else - { - (*indb)++; *inda = skipmacro (bufa, *inda); - } state = 0; continue; @@ -427,8 +418,8 @@ default: warning ("Bad character in Macro!"); - printf - ("Unrecognizable special character in macro pass4: %c Trying to continue.\n", + LineToConsole ( + "Unrecognizable special character in macro pass4: %c Trying to continue.\n", bufa[(*inda) - 1]); } } @@ -480,7 +471,7 @@ *t = 0; if (buf[255]) { - fprintf (stderr, "ERROR: String constant overwritten\n"); + LineToConsole ("ERROR: String constant overwritten\n"); return NULL; } return buf; @@ -629,10 +620,8 @@ char *strcap (char *s); #ifndef SERVER - extern int ping_tloss_sc; /* total % loss 0--100, - * server to client */ - extern int ping_tloss_cs; /* total % loss 0--100, - * client to server */ + extern int ping_tloss_sc; /* total % loss 0--100, server to client */ + extern int ping_tloss_cs; /* total % loss 0--100, client to server */ extern int ping_av; /* average rt */ extern int ping_sd; /* standard deviation */ @@ -666,11 +655,9 @@ case ' ': *pbuf1++ = ' '; break; - case 'O': /* push a 3 character team - * name into buf */ + case 'O': /* push a 3 character team name into buf */ cap = 1; - case 'o': /* push a 3 character team - * name into buf */ + case 'o': /* push a 3 character team name into buf */ APPEND_CAP (pbuf1, cap, teamshort[sender->p_team]); cap = 0; break; @@ -694,16 +681,12 @@ break; case 'P': /* push player id into buf */ - case 'G': /* push friendly player id - * into buf */ - case 'H': /* push enemy target player - * id into buf */ + case 'G': /* push friendly player id into buf */ + case 'H': /* push enemy target player id into buf */ case 'p': /* push player id into buf */ - case 'g': /* push friendly player id - * into buf */ - case 'h': /* push enemy target player - * id into buf */ + case 'g': /* push friendly player id into buf */ + case 'h': /* push enemy target player id into buf */ switch (c) { @@ -729,8 +712,7 @@ *pbuf1++ = j->p_mapchars[1]; break; - case 'n': /* push planet armies into - * buf */ + case 'n': /* push planet armies into buf */ l = &planets[dist->tclose_pl]; APPEND_INT (pbuf1, ((l->pl_info & sender->p_team) ? l-> @@ -762,17 +744,14 @@ l = &planets[dist->tclose_pl]; APPEND (pbuf1, l->pl_name); break; - case 'Z': /* push a 3 character team - * name into buf */ + case 'Z': /* push a 3 character team name into buf */ cap = 1; - case 'z': /* push a 3 character team - * name into buf */ + case 'z': /* push a 3 character team name into buf */ l = &planets[dist->tclose_pl]; APPEND_CAP (pbuf1, cap, teamshort[l->pl_owner]); cap = 0; break; - case 't': /* push a team character - * into buf */ + case 't': /* push a team character into buf */ l = &planets[dist->tclose_pl]; *pbuf1++ = teamlet[l->pl_owner]; break; @@ -861,26 +840,22 @@ break; #ifdef SERVER - case 'v': /* push average ping round - * trip time into buf */ + case 'v': /* push average ping round trip time into buf */ case 'V': /* push ping stdev into buf */ case 'y': /* push packet loss into buf */ *pbuf1++ = '0'; - case 'M': /* push capitalized - * lastMessage into buf */ + case 'M': /* push capitalized lastMessage into buf */ case 'm': /* push lastMessage into buf */ break; #else - case 'M': /* push capitalized - * lastMessage into buf */ + case 'M': /* push capitalized lastMessage into buf */ cap = 1; case 'm': /* push lastMessage into buf */ APPEND_CAP (pbuf1, cap, lastMessage); cap = 0; break; - case 'v': /* push average ping round - * trip time into buf */ + case 'v': /* push average ping round trip time into buf */ APPEND_INT (pbuf1, ping_av); break; @@ -921,7 +896,7 @@ * message will be parsed without whatever %. has occurred. - * jn */ warning ("Bad Macro character in distress!"); - fprintf (stderr, + LineToConsole ( "Unrecognizable special character in distress pass 1: %c\n", *(pm - 1)); break; Index: short.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/short.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- short.c 15 Apr 2006 11:55:14 -0000 1.3 +++ short.c 21 Apr 2006 12:00:07 -0000 1.4 @@ -861,8 +861,10 @@ char addrbuf[9]; if (debug) - printf ("Length of Message is: %d total Size %d \n", - strlen (&packet->mesg), (int) packet->length); + { + LineToConsole ("Length of Message is: %d total Size %d \n", + strlen (&packet->mesg), (int) packet->length); + } if (packet->m_from >= MAXPLAYER) packet->m_from = 255; @@ -905,7 +907,7 @@ /* S_P2 */ if (shortversion == SHORTVERSION && recv_short == 0) { /* retry for S_P 1 */ - printf ("Using Short Packet Version 1.\n"); + LineToConsole ("Using Short Packet Version 1.\n"); shortversion = OLDSHORTVERSION; sendShortReq (SPK_VON); } @@ -927,7 +929,7 @@ sprefresh (SPK_VFIELD); spwinside = ntohs (packet->winside); spgwidth = ntohl (packet->gwidth); - printf ("Receiving Short Packet Version %d\n", shortversion); + LineToConsole ("Receiving Short Packet Version %d\n", shortversion); /* * Get a `-' style update to fix the kills shown on the playerlist * when you first enter and to fix other loss if short packets @@ -965,8 +967,8 @@ case SPK_THRESHOLD: break; default: - fprintf (stderr, "%s: unknown response packet value short-req: %d\n", - "netrek", packet->repl); + LineToConsole ("%s: unknown response packet value short-req: %d\n", + "netrek", packet->repl); } } @@ -1253,12 +1255,29 @@ } char *whydeadmess[] = - { "", "[quit]", "[photon]", "[phaser]", "[planet]", "[explosion]", - "[daemon]", "[winner]", "[ghostbust]", "[genocide]", "[hacker]", - "[plasma]", - "[tournend]", "[gameover]", "[gamestart]", "[bad binary]", - "[detted photon]", "[chain explosion]", - "[zapped plasma]", "", "[team det]", "[team explosion]" +{ + "", + "[quit]", /* KQUIT */ + "[photon]", /* KTORP */ + "[phaser]", /* KPHASER */ + "[planet]", /* KPLANET */ + "[explosion]", /* KSHIP */ + "[daemon]", /* KDAEMON */ + "[winner]", /* KWINNER */ + "[ghostbust]", /* KGHOST */ + "[genocide]", /* KGENOCIDE */ + "[hacker]", /* KPROVIDENCE */ + "[plasma]", /* KPLASMA */ + "[tournend]", /* TOURNEND */ + "[gameover]", /* KOVER */ + "[gamestart]", /* TOURNSTART */ + "[bad binary]", /* KBADBIN */ + "[detted photon]", /* KTORP2 */ + "[chain explosion]", /* KSHIP2 */ + "[zapped plasma]", /* KPLASMA2 */ + "", + "[team det]", + "[team explosion]" }; void @@ -1913,7 +1932,7 @@ #ifdef CORRUPTED_PACKETS if (pnum < 0 || pnum >= MAXPLAYER) { - fprintf (stderr, "handleKills: bad index %d\n", pnum); + LineToConsole ("handleKills: bad index %d\n", pnum); return; } #endif @@ -2002,7 +2021,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum < 0 || packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleStats: bad index %d\n", packet->pnum); + LineToConsole ("handleStats: bad index %d\n", packet->pnum); return; } #endif Index: getname.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/getname.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- getname.c 12 Apr 2006 04:20:03 -0000 1.2 +++ getname.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -120,13 +120,13 @@ readFromServer (NULL); if (isServerDead ()) { - printf ("Server is dead!\n"); + LineToConsole ("Server is dead!\n"); exit (0); } } if (loginAccept == 0) { - printf ("Hmmm... The SOB server won't let me log in as guest!\n"); + LineToConsole ("Hmmm... The SOB server won't let me log in as guest!\n"); exit (0); } return; @@ -140,7 +140,7 @@ readFromServer (NULL); if (isServerDead ()) { - printf ("Server is dead!\n"); + LineToConsole ("Server is dead!\n"); exit (0); } } @@ -174,7 +174,7 @@ readFromServer (NULL); if (isServerDead ()) { - printf ("Server is dead!\n"); + LineToConsole ("Server is dead!\n"); exit (0); } } @@ -474,7 +474,7 @@ if (secondsLeft == 0) { me->p_status = PFREE; - printf ("Auto-Quit\n"); + LineToConsole ("Auto-Quit\n"); exit (0); } } @@ -485,7 +485,7 @@ if (isServerDead ()) { - printf ("Ack! We've been ghostbusted!\n"); + LineToConsole ("Ack! We've been ghostbusted!\n"); exit (0); } } @@ -593,8 +593,7 @@ void noserver (void) { - printf ("No server name was given. Please put a default server in\n"); - printf - ("your .xtrekrc file or specify the server in the command line.\n"); + LineToConsole ("No server name was given. Please put a default server in\n"); + LineToConsole ("your netrekrc.txt file or specify the server in the command line.\n"); terminate (1); } Index: playback.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/playback.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- playback.c 17 Apr 2006 09:49:45 -0000 1.7 +++ playback.c 21 Apr 2006 12:00:07 -0000 1.8 @@ -512,7 +512,9 @@ if (size > count) count += fread (buf + count, 1, size - count, recordFile); if (debug) - printf ("Reading packet %d\n", buf[0]); + { + LineToConsole ("Reading packet %d\n", buf[0]); + } if (count < size) { return 1; @@ -977,7 +979,7 @@ break; #ifdef nodef default: - printf ("packet type %d", *(unsigned char *) packet); + LineToConsole ("packet type %d", *(unsigned char *) packet); #endif } } Index: option.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- option.c 18 Apr 2006 13:41:48 -0000 1.5 +++ option.c 21 Apr 2006 12:00:07 -0000 1.6 @@ -288,6 +288,7 @@ {1, "use continuous mouse", &continuousMouse, 0, 0, 0, NULL, NULL}, {1, "fix continuous mouse", &continuousMouseFix, 0, 0, 0, NULL, NULL}, #endif + {1, "allow wheel actions", &allowWheelActions, 0, 0, 0, NULL, NULL}, {1, "new keymap entries: %s", 0, 0, newkeys, 13, NULL, NULL}, {1, "ignore the capslock key", &ignoreCaps, 0, 0, 0, NULL, NULL}, {1, "%d updates per second", &updatesPerSec, 0, 0, 0, 0, &updates_range}, @@ -312,6 +313,7 @@ {1, "show \"total\" message window", 0, &reviewWin, 0, 0, NULL, NULL}, {1, "show phaser log window", 0, &phaserwin, 0, 0, NULL}, {1, "show statistic window", 0, &statwin, 0, 0, NULL, NULL}, + {1, "show alternate player list", 0, &playerw2, 0, 0, NULL, NULL}, {1, "show help window", 0, &helpWin, 0, 0, NULL, NULL}, {1, "show hints window", &showHints, &hintWin, 0, 0, NULL, NULL}, #ifdef XTREKRC_HELP @@ -330,7 +332,7 @@ {1, "show UDP control window", 0, &udpWin, 0, 0, NULL, NULL}, {1, "show ping stats window", 0, &pStats, 0, 0, NULL}, #ifdef SHORT_PACKETS - {1, "show Short Packets window", 0, &spWin, 0, 0, NULL, NULL}, + {1, "show short packets window", 0, &spWin, 0, 0, NULL, NULL}, #endif {1, "done", ¬done, 0, 0, 0, NULL, NULL}, {-1, NULL, 0, 0, 0, 0, NULL, NULL} @@ -407,7 +409,7 @@ MaxOptions = InitOptionMenus (); if (MaxOptions < 0) { - fprintf (stderr, "InitOptionMenus() error %s!\n", MaxOptions); + LineToConsole ("InitOptionMenus() error %s!\n", MaxOptions); notdone = 0; return; } @@ -677,12 +679,12 @@ if (plistCustomLayout == 0 && playerListStyle == 0) playerListStyle = (data->key == W_LBUTTON) ? PLISTLASTSTYLE : 1; - if (W_IsMapped (playerw)) + if (W_IsMapped (playerw) || W_IsMapped (playerw2)) RedrawPlayerList (); } else if (op->op_option == &playerListObserver) { - if (W_IsMapped (playerw)) + if (W_IsMapped (playerw) || W_IsMapped (playerw2)) RedrawPlayerList (); } /* Let's see if this is our option changed */ @@ -838,6 +840,12 @@ if (showHockeyLinesLocal && !hockey_mode ()) showHockeyLinesLocal = 0; } + else if (op->op_option == &showHockeyScore) + { + // same as above + if (showHockeyScore && !hockey_mode ()) + showHockeyScore = 0; + } #endif else if (op->op_option == &partitionPlist) RedrawPlayerList (); Index: mswindow.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mswindow.c 19 Apr 2006 13:02:33 -0000 1.6 +++ mswindow.c 21 Apr 2006 12:00:07 -0000 1.7 @@ -26,7 +26,7 @@ #include <stdio.h> #include <limits.h> #include <string.h> - +#include <richedit.h> #include "copyright2.h" #include "config.h" @@ -79,12 +79,13 @@ #define WIN_TEXT 2 #define WIN_MENU 3 #define WIN_SCROLL 4 +#define WIN_RICHTEXT 5 #define MoveTo(dc, x, y) MoveToEx(dc, x, y, NULL); // Custom window messages, used for communicating between threads -#define WM_TERMINATE_WAIT WM_USER -#define WM_CROSS_THREAD_DESTROY (WM_USER+1) +#define WM_TERMINATE_WAIT 0x8000 +#define WM_CROSS_THREAD_DESTROY 0x8001 #ifdef DEBUG #define MAX_SCROLLWINDOW_LINES 300 @@ -159,7 +160,6 @@ char FontFileName[] = "\\ntfonts2.fon"; extern int DefaultsLoaded; HWND AnyWindow; -DWORD MainThreadID; int W_FastClear = 0; W_Font W_BigFont, W_RegularFont; @@ -525,6 +525,16 @@ pfnFastCallKill(0); FreeLibrary(hWinkeyLibrary); } + + /* empty console buffer */ + while (consHead) + { + struct cons_buffer * tmp; + tmp = consHead->next; + free (consHead->string); + free (consHead); + consHead = tmp; + } } #define MakeTeamCursor(upper, team) \ @@ -553,7 +563,8 @@ char FileName[100]; WNDCLASSEX wc; static int InitDone = 0; - HINSTANCE hCursorLibrary; + HMODULE hCursorLibrary; + HMODULE hRichTextLibrary; GetColors (); @@ -562,7 +573,7 @@ InitDone = -1; #ifdef DEBUG - printf ("Initializing windowing system\n"); + LineToConsole ("Initializing windowing system\n"); #endif //Register our class @@ -582,7 +593,13 @@ RegisterClassEx (&wc); if ((hCursorLibrary = LoadLibrary ("bitmaps/CURSLIB.DLL")) == NULL) { - fprintf (stderr, "Could not open curslib.dll\n"); + LineToConsole ("Could not load curslib.dll\n"); + exit (1); + } + + if ((hRichTextLibrary = LoadLibrary ("riched20.dll")) == NULL) + { + LineToConsole ("Could not load riched20.dll\n"); exit (1); } @@ -613,7 +630,7 @@ 32, 32, LR_MONOCHROME); if (RomCursor == NULL) - printf ("Whhops, there it is!\n"); + LineToConsole ("Whoops, there it is!\n"); FreeLibrary (hCursorLibrary); @@ -708,6 +725,7 @@ VKShiftMap[VK_ESCAPE] = 27; // Map shift+escape-> escape MainThreadID = GetCurrentThreadId (); // Save main thread ID so we can tell + MainThread = GetCurrentThread; // Also save main thread handle // which thread we're in later // Get the current system colors @@ -724,7 +742,7 @@ if (hWinkeyLibrary < (HINSTANCE) 32) { //Just continue if there is a problem - fprintf (stderr, "Unable to load __fastcall DLL"); + LineToConsole ("Unable to load __fastcall DLL"); } else { @@ -733,7 +751,7 @@ if (!pfnFastCallKill) { //Just continue if there is a problem - fprintf (stderr, "Unable to initialize __fastcall"); + LineToConsole ("Unable to initialize __fastcall"); } else { @@ -784,7 +802,7 @@ i = GetDeviceCaps (hdc, BITSPIXEL) * GetDeviceCaps (hdc, PLANES); #ifdef DEBUG - printf ("Bits per pixel detected: %d\n", i); + LineToConsole ("Bits per pixel detected: %d\n", i); #endif if ((i <= 4) @@ -833,7 +851,9 @@ colortable[i].rgb = RGB (xclrs[j].r, xclrs[j].g, xclrs[j].b); else - fprintf (stderr, "Color '%s' unknown\n", def); + { + LineToConsole ("Color '%s' unknown\n", def); + } } } @@ -841,7 +861,7 @@ { case 1: #ifdef DEBUG - printf ("16 color display detected.\n"); + LineToConsole ("16 color display detected.\n"); #endif break; @@ -868,7 +888,7 @@ NetrekPalette = CreatePalette (pal); #ifdef DEBUG - printf ("Paletted color display detected.\n"); + LineToConsole ("Paletted color display detected.\n"); #endif } break; @@ -934,7 +954,7 @@ /* find the window with the name specified */ if (found = FindWindow (ClassName, adefault)) - *parent = (W_Window) GetWindowLong (found, 0); //Return struct ptr + *parent = (W_Window) GetWindowLongPtr (found, GWLP_USERDATA); //Return struct ptr return; } @@ -963,7 +983,7 @@ if (!(window = (Window *) malloc (sizeof (Window)))) { - printf ("Not enough memory to create a new window."); + LineToConsole ("Not enough memory to create a new window."); return 0; } memset (window, 0, sizeof (Window)); @@ -1053,17 +1073,28 @@ //Actually create the window //Hacked to allow negative create locations -SAC - window->hwnd = CreateWindow (ClassName, s, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SpecialStyle, - x + parentwin->border, y + parentwin->border, width + border * 2, - height + border * 2 + - ((SpecialStyle & WS_CAPTION) ? GetSystemMetrics (SM_CYCAPTION) : 0), - parentwin->hwnd, NULL, MyInstance, (void *) window); - //Pass Window struct * as user param - + if (window->type == WIN_RICHTEXT) + { + window->hwnd = CreateWindowEx (0, RICHEDIT_CLASS, "", + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | + WS_VSCROLL | WS_BORDER | ES_READONLY | ES_MULTILINE, + x + parentwin->border, y + parentwin->border, + width + border * 2, height + border * 2, + parentwin->hwnd, NULL, MyInstance, (void *) window); + } + else + { + window->hwnd = CreateWindow (ClassName, s, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SpecialStyle, + x + parentwin->border, y + parentwin->border, + width + border * 2, height + border * 2 + + ((SpecialStyle & WS_CAPTION) ? GetSystemMetrics (SM_CYCAPTION) : 0), + parentwin->hwnd, NULL, MyInstance, (void *) window); + //Pass Window struct * as user param + } if (!window->hwnd) { - printf ("CreateWindow() for %s failed...", name); + LineToConsole ("CreateWindow() for %s failed...", name); return (0); } @@ -1221,8 +1252,8 @@ newwin->orig_height = orig_height; //Give it a scroll bar, and set the range (to zero, initially) - SetWindowLong (newwin->hwnd, GWL_STYLE, - GetWindowLong (newwin->hwnd, GWL_STYLE) | WS_VSCROLL); + SetWindowLongPtr (newwin->hwnd, GWL_STYLE, + GetWindowLongPtr (newwin->hwnd, GWL_STYLE) | WS_VSCROLL); SetScrollRange (newwin->hwnd, SB_VERT, 0, 0, FALSE); //Map (show) the window if the user spec'd it @@ -1272,7 +1303,7 @@ if (! (items = (struct menuItem *) malloc (height * sizeof (struct menuItem)))) - fprintf (stderr, "Could not allocate storage for menu window"); + LineToConsole ("Could not allocate storage for menu window"); else for (i = 0; i < height; i++) { @@ -1581,7 +1612,7 @@ } // Wait for an event to become available; it returns zero if it recieves a -// WM_TERMAINTE_WAIT (defined as WM_USER) message, +// WM_TERMINATE_WAIT (defined as 0x8000) message, // which we use to reset the game (it's issued by another thread) int W_WaitForEvent () @@ -1590,9 +1621,8 @@ while (EventHead == EventTail) // Get an event { - GetMessage (&msg, NULL, 0, 0); - if (msg.message == WM_TERMINATE_WAIT) // Quit message recieved + if (msg.message == WM_TERMINATE_WAIT || exitFlag) // Quit message recieved return 0; //TranslateMessage(&msg); //translate keyboard messages, @@ -1606,7 +1636,8 @@ void W_TerminateWait () { - PostMessage (AnyWindow, WM_TERMINATE_WAIT, 0, 0); + while (PostMessage (AnyWindow, WM_TERMINATE_WAIT, 0, 0) == 0) + ; } //Get the next event (message). Simply copies the event *, and advances the pointer @@ -1643,7 +1674,7 @@ //processing of the zillion other messages that go through the loop. #define GET_STRUCT_PTR\ - win=(Window *)GetWindowLong(hwnd, 0) + win = (Window *) GetWindowLongPtr (hwnd, GWLP_USERDATA) #define STORE_EVENT\ i = (EventTail + 1) % EVENT_Q_SIZE;\ @@ -1718,9 +1749,8 @@ { case WM_CREATE: //Store our structure pointer - passed from newWindow() as final CreateWindow() param - SetWindowLong (hwnd, 0, - (LONG) (Window *) ((CREATESTRUCT *) lParam)-> - lpCreateParams); + SetWindowLongPtr (hwnd, GWLP_USERDATA, + (LONG) (Window *) ((CREATESTRUCT *) lParam)->lpCreateParams); return (0); case WM_SIZE: @@ -1735,20 +1765,63 @@ case WM_ENTERSIZEMOVE: //Disable possibility to move internal windows + { // have to add bracket to be able to declare variables + RECT baseRect; // baseWin rectangle + RECT winRect; // current window rectangle + GET_STRUCT_PTR; - if (windowMove || (win->hwnd == ((Window *) baseWin)->hwnd)) + /* this has to be the same as for WM_EXITSIZEMOVE */ + if (windowMove || + (win->hwnd == ((Window *) baseWin)->hwnd) || + (((Window *) metaWin != NULL && win->hwnd == ((Window *) metaWin)->hwnd)) || + (((Window *) waitWin != NULL && win->hwnd == ((Window *) waitWin)->hwnd)) || + (((Window *) countWin != NULL && win->hwnd == ((Window *) countWin)->hwnd)) || + (((Window *) motdButtonWin != NULL && win->hwnd == ((Window *) motdButtonWin)->hwnd)) || + (((Window *) motdWin != NULL && win->hwnd == ((Window *) motdWin)->hwnd))) break; - //Save window position to RECT - GetWindowRect (win->hwnd, &movingr); + GetWindowRect (win->hwnd, &winRect); + GetWindowRect (((Window *) baseWin)->hwnd, &baseRect); + + movingr.left = winRect.left - baseRect.left; + movingr.top = winRect.top - baseRect.top; + movingr.right = winRect.right - baseRect.left; + movingr.bottom = winRect.bottom - baseRect.top; + + /* In case of WS_CAPTION (titlebar on) we have to subtract caption size and + additional borders to get screen coordinates */ + if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION) + { + movingr.left -= GetSystemMetrics (SM_CXFIXEDFRAME); + movingr.top -= (GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION)); + movingr.right -= GetSystemMetrics (SM_CXFIXEDFRAME); + movingr.bottom -= (GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION)); + } + + /* If our window has parent we have to subtract parent's border as well */ + if (win->parent != (Window *) baseWin) + { + movingr.left -= win->parent->border / 2; + movingr.top -= win->parent->border / 2; + movingr.right -= win->parent->border / 2; + movingr.bottom -= win->parent->border / 2; + } + } break; case WM_EXITSIZEMOVE: //Disable possibility to move internal windows GET_STRUCT_PTR; - if (windowMove || (win->hwnd == ((Window *) baseWin)->hwnd)) + /* this has to be the same as for WM_ENTERSIZEMOVE */ + if (windowMove || + (win->hwnd == ((Window *) baseWin)->hwnd) || + (((Window *) metaWin != NULL && win->hwnd == ((Window *) metaWin)->hwnd)) || + (((Window *) waitWin != NULL && win->hwnd == ((Window *) waitWin)->hwnd)) || + (((Window *) countWin != NULL && win->hwnd == ((Window *) countWin)->hwnd)) || + (((Window *) motdButtonWin != NULL && win->hwnd == ((Window *) motdButtonWin)->hwnd)) || + (((Window *) motdWin != NULL && win->hwnd == ((Window *) motdWin)->hwnd))) break; //Get window position from RECT to restore original location @@ -1791,7 +1864,7 @@ if (i != EventHead) EventTail = i; EventQueue[EventTail].type = W_EV_EXPOSE; - EventQueue[EventTail].Window = (W_Window) GetWindowLong (hwnd, 0); + EventQueue[EventTail].Window = (W_Window) GetWindowLongPtr (hwnd, GWLP_USERDATA); EventQueue[EventTail].x = ps.rcPaint.left; //- win->border; EventQueue[EventTail].y = ps.rcPaint.top; //- win->border; /* EventQueue[EventTail].width = ps.rcPaint.right - ps.rcPaint.left; @@ -1959,14 +2032,6 @@ { LONG wl; RECT r; - int cx, cy; - - cx = GetSystemMetrics (SM_CXEDGE); - if (!cx) - cx = GetSystemMetrics (SM_CXBORDER); - cy = GetSystemMetrics (SM_CYEDGE); - if (!cy) - GetSystemMetrics (SM_CYBORDER); wl = GetWindowLong (((Window *) baseWin)->hwnd, GWL_STYLE); GetWindowRect (((Window *) baseWin)->hwnd, &r); @@ -1982,7 +2047,7 @@ r.left -= GetSystemMetrics (SM_CXBORDER); r.top -= GetSystemMetrics (SM_CYBORDER); } - SetWindowLong (((Window *) baseWin)->hwnd, GWL_STYLE, wl); + SetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE, wl); // Update the window since the height has changed MoveWindow (((Window *) baseWin)->hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE); @@ -2039,7 +2104,7 @@ //the mouse is in. hwnd = WindowFromPoint (pos); - if (GetWindowLong (hwnd, GWL_WNDPROC) != (LONG) NetrekWndProc) + if (GetWindowLongPtr (hwnd, GWLP_WNDPROC) != (LONG) NetrekWndProc) return 0; //Mouse is not in one of our windows if (!hwnd || hwnd == ((Window *) baseWin)->hwnd) @@ -2078,6 +2143,8 @@ case WM_MOUSEMOVE: GET_STRUCT_PTR; + /*if (win->hwnd != GetFocus ()) + SetFocus (win->hwnd);*/ SetCursor (win->cursor); #if defined(MOTION_MOUSE) || defined(XTRA_MESSAGE_UI) @@ -2516,10 +2583,14 @@ // If we're not in message windows then we'll map wheel up and // wheel down events as regular mouse events - if (win->type != WIN_SCROLL) + if (win->type == WIN_GRAPH || win->type == WIN_TEXT || win->type == WIN_MENU) { //BringWindowToTop (hwnd); - GET_STRUCT_PTR; + //GET_STRUCT_PTR; + + /* Let's see whether we should process wheel messages */ + if (!allowWheelActions) + return (1); STORE_EVENT_MOUSE; LastPressHwnd = hwnd; @@ -2536,25 +2607,62 @@ } return (0); } - - i = GetScrollPos (hwnd, SB_VERT); - - switch (wheel) + else if (win->type == WIN_SCROLL) { - case -1: - i += 1; - break; - case 1: - i -= 1; - break; - default: + i = GetScrollPos (hwnd, SB_VERT); + + switch (wheel) + { + case -1: + i += 1; + break; + case 1: + i -= 1; + break; + default: + return (0); + } + + SetScrollPos (hwnd, SB_VERT, i, TRUE); //Move scroll + InvalidateRect (hwnd, &win->ClipRect, TRUE); //Redraw text in window + UpdateWindow (hwnd); return (0); } + else if (win->type == WIN_RICHTEXT) + { + POINT p; + RECT r; + int lines, visline, maxscroll; - SetScrollPos (hwnd, SB_VERT, i, TRUE); //Move scroll - InvalidateRect (hwnd, &win->ClipRect, TRUE); //Redraw text in window - UpdateWindow (hwnd); - return (0); + SendMessage (win->hwnd, EM_GETSCROLLPOS, 0, (LPARAM) &p); + SendMessage (win->hwnd, EM_GETRECT, 0, (LPARAM) &r); + visline = SendMessage (win->hwnd, EM_GETFIRSTVISIBLELINE, 0, 0); + lines = SendMessage (win->hwnd, EM_GETLINECOUNT, 0, 0); + + maxscroll = ((lines - visline) - (r.bottom / W_Textheight)) * W_Textheight; + + switch (wheel) + { + case -1: + p.y += W_Textheight; + break; + case 1: + p.y -= W_Textheight; + break; + default: + return (0); + } + + if (p.y > maxscroll) + return (0); + + SendMessage (win->hwnd, EM_SETSCROLLPOS, 0, (LPARAM) &p); + //InvalidateRect (hwnd, &win->ClipRect, TRUE); //Redraw text in window + //UpdateWindow (hwnd); + return (0); + } + else + return (1); //Trap WM_ERASEBKGRND, to handle windows with tiled backgrounds case WM_ERASEBKGND: @@ -2610,6 +2718,14 @@ else return i; + // When PostMessage sends us WM_TERMINATE_WAIT it isn't always reaching the right + // thread (somehow ;), so to fix the die while scrolling bug I had to add this stupid + // flag + case WM_TERMINATE_WAIT: + exitFlag = 1; + WaitForSingleObject (InputThread, INFINITE); + return 0; + //This message sent from another thread to indicate a window should be destroyed, // which only the main thread can do case WM_CROSS_THREAD_DESTROY: @@ -2667,6 +2783,25 @@ } break; + case WM_NOTIFY: + if (((NMHDR *) lParam)->code == EN_LINK) + { + ENLINK *link = (ENLINK *) lParam; + CHARRANGE cr; + char str[250]; + HWND hwndFrom = link->nmhdr.hwndFrom; + + if (link->msg == WM_LBUTTONDOWN || link->msg == WM_LBUTTONDBLCLK) + { + SendMessage (hwndFrom, EM_EXGETSEL, 0, (LPARAM) &cr); + SendMessage (hwndFrom, EM_EXSETSEL, (WPARAM) 0, (LPARAM) &(link->chrg)); + SendMessage (hwndFrom, EM_GETSELTEXT, 0, (LPARAM) str); + SendMessage (hwndFrom, EM_EXSETSEL, 0, (LPARAM) &cr); + ShellExecute (NULL, "open", str, NULL, NULL, SW_SHOWNORMAL); + } + } + break; + } return DefWindowProc (hwnd, msg, wParam, lParam); @@ -3097,13 +3232,18 @@ AddToScrolling (win, color, str, len); break; + case WIN_RICHTEXT: +// str[len]=0; + AddToRichText (win, color, str, len); + break; + case WIN_MENU: // str[len]=0; ChangeMenuItem (win, y, str, len, color); break; default: - printf ("Unknown window type in W_WriteText"); + LineToConsole ("Unknown window type in W_WriteText"); } } @@ -3149,13 +3289,18 @@ AddToScrolling (win, color, str, len); break; + case WIN_RICHTEXT: + str[len]=0; + AddToRichText (win, color, str, len); + break; + case WIN_MENU: str[len] = 0; ChangeMenuItem (win, y, str, len, color); break; default: - printf ("Unknown window type in W_WriteText"); + LineToConsole ("Unknown window type in W_WriteText"); } } @@ -3170,7 +3315,7 @@ HDC hdc; int t; - printf ("pBM: %p\nbmlCount: %d", pBM, bmlCount); + LineToConsole ("pBM: %p\nbmlCount: %d", pBM, bmlCount); if (!pBM) { @@ -3189,7 +3334,8 @@ if (pBM && tmp) { - printf ("tmp: %p\n", tmp); + LineToConsole ("tmp: %p\n", tmp); + if (!SelectObject (GlobalMemDC, pBM->bm)) goto fail; if (!(hdc = GetDC (((Window *) tmp)->hwnd))) @@ -3270,7 +3416,7 @@ if (!(temp2 = CreateBitmap (width, height, 1, 1, NULL))) goto memfail; - printf ("."); + LineToConsole ("."); bmlCount++; //Mirror bitmap @@ -3291,7 +3437,7 @@ } else { - printf + LineToConsole ("Got impossible internal error in W_StoreBitmap(). Please report to author.\n"); exit (-1); } @@ -3350,9 +3496,9 @@ //Copy the bits to their new location, mirroring as we go if (!SelectObject (GlobalMemDC, temp)) - printf ("SelectObject(DC, temp) bombed"); + LineToConsole ("SelectObject(DC, temp) bombed"); if (!SelectObject (GlobalMemDC2, CurrentBitmap->bm)) - printf ("SelectObject(DC2,CurrentBitmap->tm) bombed"); + LineToConsole ("SelectObject(DC2,CurrentBitmap->tm) bombed"); StretchBlt (GlobalMemDC2, CurX, CurY, width, height, GlobalMemDC, newwidth - 1, 0, -width, height, SRCCOPY); @@ -3373,7 +3519,7 @@ return (W_Icon) bitmap; memfail: - printf ("Memory allocation or CreateBitmap() failure in StoreBitmap\n"); + LineToConsole ("Memory allocation or CreateBitmap() failure in StoreBitmap\n"); if (bits2) free (bits2); if (bitmap) @@ -3439,9 +3585,9 @@ return (W_Icon) bitmap; memfail: - printf - ("Memory allocation or CreateBitmap() failure in StoreBitmap2()\n"); - printf ("Id: %d %d %d\n", height, width, bits); + LineToConsole ("Memory allocation or CreateBitmap() failure in StoreBitmap2()\n"); + LineToConsole ("Id: %d %d %d\n", height, width, bits); + if (bitmap) free (bitmap); if (temp) @@ -3497,9 +3643,9 @@ return (W_Icon) bitmap; memfail: - printf - ("Memory allocation or CreateBitmap() failure in StoreBitmap3()\n"); - printf ("Id: %d %d %s\n", height, width, BMPfile); + LineToConsole ("Memory allocation or CreateBitmap() failure in StoreBitmap3()\n"); + LineToConsole ("Id: %d %d %s\n", height, width, BMPfile); + if (bitmap) free (bitmap); if (temp) @@ -3534,8 +3680,9 @@ return (W_Icon) bitmap; memfail: - printf ("Memory allocation or malloc() failure in PointBitmap2()\n"); - printf ("Id: %d %d %d %d \n", col, row, height, width); + LineToConsole ("Memory allocation or malloc() failure in PointBitmap2()\n"); + LineToConsole ("Id: %d %d %d %d \n", col, row, height, width); + if (bitmap) free (bitmap); return NULL; @@ -3866,8 +4013,7 @@ p2 = (struct stringList *) malloc (sizeof (struct stringList)); if (!p2) { - fprintf (stderr, - "Not enough memory to allocate a new listbox string.\n"); + LineToConsole ("Not enough memory to allocate a new listbox string.\n"); return; } @@ -3891,7 +4037,7 @@ p->string = (char *) malloc (win->TextWidth + 1); if (!p->string) { - printf ("Not enough memory to allocate a new listbox string."); + LineToConsole ("Not enough memory to allocate a new listbox string."); return; } @@ -3912,6 +4058,7 @@ win->AddedStrings++; } + //Redraw a scrolling window void RedrawScrolling (Window * win, @@ -4283,7 +4430,7 @@ GetCursorPos (&p); hwnd = ChildWindowFromPoint (((Window *) baseWin)->hwnd, p); - if (!hwnd || (W_Window) GetWindowLong (hwnd, 0) != window) + if (!hwnd || (W_Window) GetWindowLongPtr (hwnd, GWLP_USERDATA) != window) { *x = 0; *y = 0; @@ -4330,8 +4477,7 @@ { if (width > 32 || height > 32) { - fprintf (stderr, - "Attempt to define cursor > 32x32. Cursor will be garbled!"); + LineToConsole ("Attempt to define cursor > 32x32. Cursor will be garbled!"); width = min (32, width); height = min (32, height); } @@ -5422,7 +5568,7 @@ break; default: - printf ("Unknown window type in W_WriteText"); + LineToConsole ("Unknown window type in W_WriteText"); } } @@ -5454,7 +5600,7 @@ break; default: - printf ("Unknown window type in W_WriteText"); + LineToConsole ("Unknown window type in W_WriteText"); } } @@ -5612,3 +5758,205 @@ BitBlt (sdb->mem_dc, x, y, //Copy the bitmap width, height, GlobalMemDC, srcx, srcy, SRCPAINT); // <-- using OR mode } + + +// Make a WIN_SCROLL type window. +// We use a scrollbar so we can look through the text, something the X version +// didn't have. Nyah, nyah. +W_Window +W_MakeScrollingRichTextWindow (char *name, + int x, + int y, + int width, + int height, + W_Window parent, + int border) +{ + Window *newwin; + int orig_x, orig_y, orig_width, orig_height; + + orig_x = x; + orig_y = y; + orig_width = width; + orig_height = height; + + //Get the default position, etc. + checkGeometry (name, &x, &y, &width, &height); + + //Get the default parent.. + checkParent (name, &parent); + + if (!(newwin = newWindow (name, x, y, + width * W_Textwidth + WIN_EDGE * 2 + + GetSystemMetrics (SM_CXVSCROLL), + height * W_Textheight + MENU_PAD * 2, parent, + border, W_White, WIN_RICHTEXT))) + return (0); + + SetWindowLongPtr (newwin->hwnd, GWLP_USERDATA, (LONG_PTR) newwin); + lpfnDefRichEditWndProc = (WNDPROC) SetWindowLongPtr (newwin->hwnd, GWLP_WNDPROC, + (DWORD) RichTextWndProc); + SendMessage (newwin->hwnd, EM_AUTOURLDETECT, TRUE, 0); + SendMessage (newwin->hwnd, EM_SETEVENTMASK, 0, ENM_LINK); + SendMessage (newwin->hwnd, EM_SETBKGNDCOLOR, 0, W_Black); + SendMessage (newwin->hwnd, WM_SETFONT, (WPARAM) W_RegularFont, TRUE); + + //Store the original textheight, width + newwin->TextHeight = height; + newwin->TextWidth = width; + + /* Set original coordinates, so we will be able to restore to them */ + newwin->orig_x = orig_x; + newwin->orig_y = orig_y; + newwin->orig_width = orig_width; + newwin->orig_height = orig_height; + + //Map (show) the window if the user spec'd it + if (checkMapped (name)) + W_MapWindow ((W_Window) newwin); + + return (W_Window) newwin; +} + + +void +AddToRichText (Window * win, + W_Color color, + char *str, + int len) +{ + struct stringList *p = win->strings; + struct stringList *end, *p2; + int NumStrings = win->NumItems; + char str1[256]; + CHARFORMAT2 cf; + POINT point; + RECT rect; + HWND hwnd; + CHARRANGE cr; + int numLines, visibleLines; + + //Find the end of the linked-list of strings... + if (p) // ...if the list has been created + { + end = p; + while (end->next) + end = end->next; + } + else + { + end = 0; + NumStrings = 0; + } + + if (NumStrings < MAX_SCROLLWINDOW_LINES) //Create a new stringList item + { + p2 = (struct stringList *) malloc (sizeof (struct stringList)); + if (!p2) + { + LineToConsole ("Not enough memory to allocate a new listbox string.\n"); + return; + } + + if (!p) + win->strings = p2; //Store the new start of list + + p = p2; //Point p to the new string + + win->NumItems = ++NumStrings; //Inc the string number + } + else //Re-use the first string, place it at the end of the list + { + if (p->string) + free (p->string); + win->strings = p->next; //Store the new start of list + } + + if (str[len - 1] == '\n') //Remove trailing newlines + str[--len] = 0; + + p->string = (char *) malloc (win->TextWidth + 1); + if (!p->string) + { + LineToConsole ("Not enough memory to allocate a new listbox string."); + return; + } + + p->color = color; + strncpy (p->string, str, win->TextWidth); + + /* we pad out the string with spaces so we don't have to clear + the window */ + if (len < win->TextWidth - 1) + memset (p->string + len, ' ', win->TextWidth - len - 1); + p->string[win->TextWidth - 1] = 0; + + if (end) + end->next = p; + p->next = 0; + + //Mark as out of date... + win->AddedStrings++; + + hwnd = GetFocus (); + SendMessage (win->hwnd, EM_EXGETSEL, 0, (LPARAM) &cr); + //SendMessage (win->hwnd, EM_HIDESELECTION, TRUE, 0); + + cf.cbSize = sizeof (CHARFORMAT2); + cf.dwEffects = 0; + cf.dwMask = CFM_COLOR; + cf.crTextColor = colortable[color].rgb; + + strcpy (str1, str); + strcat (str1, "\n"); + + SendMessage (win->hwnd, EM_GETSCROLLPOS, 0, (LPARAM) &point); + numLines = SendMessage (win->hwnd, EM_GETLINECOUNT, 0, 0); + SendMessage (win->hwnd, EM_GETRECT, 0, (LPARAM) &rect); + visibleLines = rect.bottom / W_Textheight; + SendMessage (win->hwnd, EM_SETSEL, -1, -1); + SendMessage (win->hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf); + SendMessage (win->hwnd, EM_REPLACESEL, FALSE, (LPARAM) str1); + if (numLines - point.y / W_Textheight > visibleLines + 1) + { + SendMessage (win->hwnd, EM_SETSCROLLPOS, 0, (LPARAM) &point); + } + else if (numLines - point.y / W_Textheight == visibleLines + 1) + { + point.y += W_Textheight; + SendMessage (win->hwnd, EM_SETSCROLLPOS, 0, (LPARAM) &point); + } + //SendMessage (win->hwnd, EM_HIDESELECTION, FALSE, 0); + SendMessage (win->hwnd, EM_SCROLLCARET, 0, 0); + + if (cr.cpMin != cr.cpMax) + SendMessage (win->hwnd, EM_SETSEL, 0, (LPARAM) &cr); + + if (hwnd) + SetFocus (hwnd); +} + + +LRESULT CALLBACK RichTextWndProc (HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ +// Window * win; + + switch (msg) + { +/* case WM_PAINT: + GET_STRUCT_PTR; + W_ChangeBorder ((W_Window) win, W_White); + break;*/ + +/* case WM_KEYDOWN: + LineToConsole ("key down\n"); + return (0);*/ + case WM_LBUTTONDOWN: + BringWindowToTop (hwnd); + break; + } + return CallWindowProc (lpfnDefRichEditWndProc, hwnd, msg, wParam, lParam); +} Index: newwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- newwin.c 20 Apr 2006 06:48:20 -0000 1.8 +++ newwin.c 21 Apr 2006 12:00:07 -0000 1.9 @@ -13,7 +13,7 @@ #include <math.h> #include <signal.h> #include <sys/types.h> -#include <sys/stat.h> + #include <time.h> #include <winsock.h> @@ -478,10 +478,12 @@ rankw = W_MakeTextWindow ("rank", 50, 300, 65, NUMRANKS + 9, w, 2); W_SetWindowExposeHandler (rankw, ranklist); - playerw = W_MakeTextWindow ("player", 0, WINSIDE + 50, - PlistMaxWidth (), 21, baseWin, 2); + playerw = W_MakeTextWindow ("player", 0, WINSIDE + 50, PlistMaxWidth (), 21, baseWin, 2); W_SetWindowExposeHandler (playerw, RedrawPlayerList); + playerw2 = W_MakeTextWindow ("player2", 140, 100, PlistMaxWidth2 (), 32, baseWin, 2); + W_SetWindowExposeHandler (playerw2, RedrawPlayerList); + #ifdef RECORDGAME if (playback) helpWin = W_MakeTextWindow ("help", 286, @@ -509,29 +511,58 @@ #endif /* Message windows */ - messwa = W_MakeScrollingWindow ("review_all", 506, 668, 81, 5, baseWin, BORDER); - wam_windows[0] = messwa; - W_SetWindowKeyDownHandler (messwa, handleMessageWindowKeyDown); + if (richText) + { + messwa = W_MakeScrollingRichTextWindow ("review_all", 506, 668, 81, 5, baseWin, BORDER); + wam_windows[0] = messwa; + W_SetWindowKeyDownHandler (messwa, handleMessageWindowKeyDown); - messwt = W_MakeScrollingWindow ("review_team", 506, 579, 81, 8, baseWin, BORDER); - wam_windows[1] = messwt; - W_SetWindowKeyDownHandler (messwt, handleMessageWindowKeyDown); + messwt = W_MakeScrollingRichTextWindow ("review_team", 506, 579, 81, 8, baseWin, BORDER); + wam_windows[1] = messwt; + W_SetWindowKeyDownHandler (messwt, handleMessageWindowKeyDown); - messwi = W_MakeScrollingWindow ("review_your", 506, 540, 81, 3, baseWin, BORDER); - wam_windows[2] = messwi; - W_SetWindowKeyDownHandler (messwi, handleMessageWindowKeyDown); + messwi = W_MakeScrollingRichTextWindow ("review_your", 506, 540, 81, 3, baseWin, BORDER); + wam_windows[2] = messwi; + W_SetWindowKeyDownHandler (messwi, handleMessageWindowKeyDown); - messwk = W_MakeScrollingWindow ("review_kill", 506, 727, 81, 3, baseWin, BORDER); - wam_windows[3] = messwk; + messwk = W_MakeScrollingRichTextWindow ("review_kill", 506, 727, 81, 3, baseWin, BORDER); + wam_windows[3] = messwk; - phaserwin = W_MakeScrollingWindow ("review_phaser", WINSIDE + BORDER + 6, YOFF + - WINSIDE + 3 * BORDER + 2 * MESSAGESIZE + - 15 * W_Textheight + 16, 80, 4, baseWin, BORDER); - wam_windows[4] = phaserwin; + phaserwin = W_MakeScrollingRichTextWindow ("review_phaser", WINSIDE + BORDER + 6, YOFF + + WINSIDE + 3 * BORDER + 2 * MESSAGESIZE + + 15 * W_Textheight + 16, 80, 4, baseWin, BORDER); + wam_windows[4] = phaserwin; - reviewWin = W_MakeScrollingWindow ("review", 506, 540, 81, 22, baseWin, BORDER); - wam_windows[5] = reviewWin; - W_SetWindowKeyDownHandler (reviewWin, handleMessageWindowKeyDown); + reviewWin = W_MakeScrollingRichTextWindow ("review", 506, 540, 81, 22, baseWin, BORDER); + wam_windows[5] = reviewWin; + W_SetWindowKeyDownHandler (reviewWin, handleMessageWindowKeyDown); + } + else + { + messwa = W_MakeScrollingWindow ("review_all", 506, 668, 81, 5, baseWin, BORDER); + wam_windows[0] = messwa; + W_SetWindowKeyDownHandler (messwa, handleMessageWindowKeyDown); + + messwt = W_MakeScrollingWindow ("review_team", 506, 579, 81, 8, baseWin, BORDER); + wam_windows[1] = messwt; + W_SetWindowKeyDownHandler (messwt, handleMessageWindowKeyDown); + + messwi = W_MakeScrollingWindow ("review_your", 506, 540, 81, 3, baseWin, BORDER); + wam_windows[2] = messwi; + W_SetWindowKeyDownHandler (messwi, handleMessageWindowKeyDown); + + messwk = W_MakeScrollingWindow ("review_kill", 506, 727, 81, 3, baseWin, BORDER); + wam_windows[3] = messwk; + + phaserwin = W_MakeScrollingWindow ("review_phaser", WINSIDE + BORDER + 6, YOFF + + WINSIDE + 3 * BORDER + 2 * MESSAGESIZE + + 15 * W_Textheight + 16, 80, 4, baseWin, BORDER); + wam_windows[4] = phaserwin; + + reviewWin = W_MakeScrollingWindow ("review", 506, 540, 81, 22, baseWin, BORDER); + wam_windows[5] = reviewWin; + W_SetWindowKeyDownHandler (reviewWin, handleMessageWindowKeyDown); + } /* End of Message windows */ pStats = W_MakeWindow ("pingStats", 500, 4, pStatsWidth (), pStatsHeight (), @@ -580,31 +611,30 @@ statwin = W_MakeWindow ("stats", 405, 506, 100, 80, baseWin, BORDER, foreColor); W_SetWindowExposeHandler (statwin, redrawStats); - scanwin = W_MakeWindow ("scanner", 422, 13, 160, 120, baseWin, 5, foreColor); - W_DefineTrekCursor (baseWin); W_DefineLocalcursor (w); W_DefineMapcursor (mapw); W_DefineTrekCursor (pStats); W_DefineTextCursor (warnw); + W_DefineTextCursor (messagew); + W_DefineTrekCursor (messwa); W_DefineTrekCursor (messwt); W_DefineTrekCursor (messwi); + W_DefineTrekCursor (messwk); + W_DefineTrekCursor (reviewWin); + W_DefineTrekCursor (phaserwin); W_DefineTrekCursor (helpWin); #ifdef META W_DefineArrowCursor (metaWin); #endif - W_DefineTrekCursor (reviewWin); - W_DefineTrekCursor (messwk); - W_DefineTrekCursor (phaserwin); W_DefineTrekCursor (playerw); + W_DefineTrekCursor (playerw2); W_DefineTrekCursor (rankw); W_DefineTrekCursor (statwin); - W_DefineTextCursor (messagew); W_DefineTrekCursor (tstatw); W_DefineWarningCursor (qwin); - W_DefineTrekCursor (scanwin); W_DefineArrowCursor (udpWin); #ifdef SHORT_PACKETS @@ -677,6 +707,8 @@ W_MapWindow (phaserwin); phaserWindow = 1; } + if (checkMapped ("player2")) + W_MapWindow (playerw2); if (checkMappedPref ("player", 1)) W_MapWindow (playerw); if (checkMappedPref ("review", 1)) @@ -1049,7 +1081,7 @@ elapsed = time (0) - startTime; if (elapsed > autoQuit) { - printf ("Auto-Quit.\n"); + LineToConsole ("Auto-Quit.\n"); *team = 4; break; } @@ -1249,7 +1281,9 @@ redrawQuit (); } else if (event.Window == tstatw) + { redrawTstats (); + } else if (event.Window == w) { showMotdWin (w, line); @@ -1319,8 +1353,8 @@ readFromServer (NULL); if (isServerDead ()) { - printf ("Oh SHIT, We've been ghostbusted!\n"); - printf ("hope you weren't in a base\n"); + LineToConsole ("Oh SHIT, We've been ghostbusted!\n"); + LineToConsole ("hope you weren't in a base\n"); /* UDP fail-safe */ commMode = commModeReq = COMM_TCP; commSwitchTimeout = 0; @@ -1332,7 +1366,7 @@ udprefresh (UDP_STATUS); } connectToServer (nextSocket); - printf (" We've been resurrected!\n"); + LineToConsole (" We've been resurrected!\n"); pickOk = 0; break; } @@ -1594,7 +1628,7 @@ if ((*temp) == NULL) { /* malloc error checking -- * 10/30/92 EM */ - printf ("Warning: Couldn't malloc space for a new motd line!"); + LineToConsole ("Warning: Couldn't malloc space for a new motd line!"); return; } /* Motd clearing code */ Index: ping.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/ping.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ping.c 21 Jan 2003 21:28:42 -0000 1.1.1.1 +++ ping.c 21 Apr 2006 12:00:07 -0000 1.2 @@ -45,7 +45,7 @@ { ping = 1; /* we got a ping */ - /* printf("ping received at %d (lag: %d)\n", msetime(), (int)packet->lag); */ + /* LineToConsole ("ping received at %d (lag: %d)\n", msetime(), (int)packet->lag); */ sendServerPingResponse ((int) packet->number); ping_lag = ntohs (packet->lag); ping_iloss_sc = (int) packet->iloss_sc; @@ -70,7 +70,7 @@ if (gwrite (sock, (char *) &packet, sizeof (struct ping_cpacket)) != sizeof (struct ping_cpacket)) { - printf ("gwrite failed.\n"); + LineToConsole ("gwrite failed.\n"); serverDead = 1; } } @@ -86,7 +86,7 @@ if (gwrite (sock, (char *) &packet, sizeof (struct ping_cpacket)) != sizeof (struct ping_cpacket)) { - printf ("gwrite failed.\n"); + LineToConsole ("gwrite failed.\n"); serverDead = 1; } } @@ -113,12 +113,12 @@ packet.cp_sent = htonl (packets_sent); packet.cp_recv = htonl (packets_received); - /* printf("ping response sent at %d\n", msetime()); */ + /* LineToConsole ("ping response sent at %d\n", msetime()); */ if (gwrite (s, (char *) &packet, sizeof (struct ping_cpacket)) != sizeof (struct ping_cpacket)) { - printf ("gwrite failed.\n"); + LineToConsole ("gwrite failed.\n"); serverDead = 1; } } Index: stampver.inf =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/stampver.inf,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- stampver.inf 12 Apr 2006 04:20:04 -0000 1.2 +++ stampver.inf 21 Apr 2006 12:00:07 -0000 1.3 @@ -1,5 +1,5 @@ ;StampVer information file -FileVersion=4.4.0.3 -ProductVersion=4.4.0.3 +FileVersion=4.4.0.4 +ProductVersion=4.4.0.4 ;FileFormat=%a.%b.%c Build %04d (%td %tb %tY) ;ProductFormat=%a.%b.%c Build %04d Index: check.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/check.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- check.c 12 Apr 2006 04:20:03 -0000 1.2 +++ check.c 21 Apr 2006 12:00:06 -0000 1.3 @@ -58,7 +58,7 @@ { if ((hp = gethostbyname (serverName)) == NULL) { - fprintf (stderr, "unknown host '%s'\n", serverName); + LineToConsole ("unknown host '%s'\n", serverName); terminate (0); } else @@ -73,7 +73,7 @@ perror ("socket"); terminate (0); } - printf ("checking %s on port %d\n", serverName, xtrekPort); + LineToConsole ("checking %s on port %d\n", serverName, xtrekPort); if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0) { perror ("connect"); @@ -81,7 +81,7 @@ terminate (0); } - while ((cc = read (sock, buf, BUF_SIZE)) > 0) + while ((cc = recv (sock, buf, BUF_SIZE, 0)) > 0) { fwrite (buf, cc, 1, stdout); } Index: main.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- main.c 12 Apr 2006 04:20:03 -0000 1.2 +++ main.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -20,6 +20,7 @@ #include "Wlib.h" #include "struct.h" #include "proto.h" +#include "data.h" char *servertmp = NULL; @@ -30,48 +31,48 @@ static void printUsage (char *prog) { - printf ("%s %s\n", version, mvers); - printf ("Usage: %s [options] [display-name]\n", prog); - printf ("Options:\n"); - printf (" [-h servername] Specify a server\n"); - printf (" [-p port number] Specify a port to connect to\n"); - printf (" [-r defaultsfile] Specify defaults file\n"); - printf - (" [-s socketnum] Specify listen socket port for manual start\n"); - printf (" [-u] show usage\n"); - printf (" [-A] character password\n"); - printf (" [-C] character name\n"); + LineToConsole ("%s %s\n", version, mvers); + LineToConsole ("Usage: %s [options] [display-name]\n", prog); -#ifdef GATEWAY - printf (" [-H] specify host (via gateway)\n"); + LineToConsole ("Options:\n"); + LineToConsole (" [-h servername] specify a server\n"); + LineToConsole (" [-p port number] specify a port to connect to\n"); + LineToConsole (" [-r defaultsfile] specify defaults file\n"); + LineToConsole (" [-s socketnum] specify listen socket port for manual start\n"); + LineToConsole (" [-U udp_port] specify client UDP port (useful for some firewalls)\n"); +#ifdef RECORDGAME + LineToConsole (" [-F filename] view recorded game from 'filename'\n"); + LineToConsole (" [-f filename] record game into 'filename'\n"); #endif + LineToConsole (" [-l filename] record messages into 'filename'\n"); - printf - (" [-U udp_port] Specify client UDP port (useful for some firewalls)\n"); + LineToConsole (" [-A] character password\n"); + LineToConsole (" [-C] character name\n"); + +#ifdef GATEWAY + LineToConsole (" [-H] specify host (via gateway)\n"); +#endif #ifdef RSA - printf (" [-o] use old-style binary verification)\n"); - printf (" [-R] use RSA binary verification\n"); + LineToConsole (" [-o] use old style binary verification\n"); + LineToConsole (" [-R] use RSA binary verification\n"); #endif #ifdef PACKET_LOG - printf (" [-P] Log server packets, repeat for increased information\n"); + LineToConsole (" [-P] log server packets, repeat for increased information\n"); #endif - printf (" [-c] to just do ck_players on the server\n"); -#ifdef RECORDGAME - printf (" [-F filename] View recorded game from 'filename'\n"); - printf (" [-f filename] Record game into 'filename'\n"); -#endif - printf (" [-l filename] Record messages into 'filename'\n"); + LineToConsole (" [-c] run players check on the server\n"); #ifdef META - printf (" [-m] check metaserver for active servers\n"); - printf (" [-k] display known servers\n"); + LineToConsole (" [-m] check metaserver for active servers\n"); + LineToConsole (" [-k] display known servers\n"); #endif - printf (" [-n] show console window\n"); - printf (" [-v] display client version info\n"); + LineToConsole (" [-D] output debug info\n"); + LineToConsole (" [-n] show console window\n"); + LineToConsole (" [-u] show usage\n"); + LineToConsole (" [-v] display client version info\n"); } @@ -97,8 +98,6 @@ int xtrekPort = -1; name = argv[0]; -// if ((ptr = RINDEX(name, "/")) != NULL) -// name = ptr + 1; #ifdef GATEWAY netaddr = 0; @@ -143,13 +142,15 @@ case 'u': /* program usage */ usage++; + hideConsole = 0; break; case 'c': /* run ck_players */ checking = 1; + hideConsole = 0; break; - case 's': + case 's': /* listen socket number */ if (i < argc) { xtrekPort = atoi (argv[i + 1]); @@ -160,11 +161,11 @@ usage++; break; #ifdef RECORDGAME - case 'F': + case 'F': /* playback recorded cambot */ inplayback = 1; /* No break */ - case 'f': + case 'f': /* record to cambot file */ if (i < argc) { recordFileName = argv[i + 1]; @@ -174,7 +175,7 @@ usage++; break; #endif - case 'l': + case 'l': /* log to file */ if (i < argc) { logFileName = argv[i + 1]; @@ -184,7 +185,7 @@ usage++; break; - case 'p': + case 'p': /* port to connect to */ if (i < argc) { xtrekPort = atoi (argv[i + 1]); @@ -193,6 +194,7 @@ else usage++; break; + case 'd': if (i < argc) { @@ -204,17 +206,17 @@ break; #ifdef META - case 'm': + case 'm': /* show metaserver window */ if (usemeta && usemeta != 1) { - fputs ("The options -k and -m are mutuall exclusive\n", + fputs ("The options -k and -m are mutually exclusive\n", stderr); err++; } usemeta = 1; break; - case 'k': + case 'k': /* show metacache window */ if (usemeta && usemeta != 2) { fputs ("The options -k and -m are mutually exclusive\n", @@ -226,31 +228,31 @@ #endif #ifdef RSA - case 'o': + case 'o': /* try old binary verification */ useRsa = -1; /* will be reset leter, set - * negative here * to flag - * that it should override - * xtrekrc */ - printf ("Using standard binary verification\n"); + * negative here * to flag + * that it should override + * xtrekrc */ + LineToConsole ("Using standard binary verification\n"); break; - case 'R': + case 'R': /* try RSA verification */ useRsa = -2; /* will be reset leter, set - * negative here * to flag - * that it should override - * xtrekrc */ - printf ("Using RSA verification\n"); + * negative here * to flag + * that it should override + * xtrekrc */ + LineToConsole ("Using RSA verification\n"); break; #else case 'R': - printf ("This client does not support RSA verification\n"); + LineToConsole ("This client does not support RSA verification\n"); case 'o': - printf ("Using standard binary verification\n"); + LineToConsole ("Using standard binary verification\n"); break; #endif - case 'h': + case 'h': /* server to connect to */ if (i < argc) { servertmp = argv[i + 1]; @@ -267,7 +269,7 @@ break; #ifdef GATEWAY - case 'H': + case 'H': /* gateway to connect through */ hset++; if (i < argc) { @@ -278,12 +280,12 @@ usage++; break; #endif - case 'U': + case 'U': /* local UDP port */ if (i < argc) { if ((baseUdpLocalPort = atoi (argv[i + 1])) == 0) { - fprintf (stderr, "Error: -U requires a port number\n"); + LineToConsole ("Error: -U requires a port number\n"); exit (1); } i++; @@ -293,23 +295,23 @@ break; #ifdef PACKET_LOG - case 'P': + case 'P': /* log packets */ log_packets++; break; #endif - case 'G': + case 'G': /* try restarting previous session */ if (i < argc) { ghoststart++; ghost_pno = atoi (argv[i + 1]); - printf ("Emergency restart being attempted...\n"); + LineToConsole ("Emergency restart being attempted...\n"); i++; } else usage++; break; - case 't': + case 't': /* window title */ if (i < argc) { title = argv[i + 1]; @@ -319,7 +321,7 @@ usage++; break; - case 'r': + case 'r': /* defaults file */ if (i < argc) { deffile = argv[i + 1]; @@ -329,29 +331,31 @@ usage++; break; - case 'D': + case 'D': /* add debug info */ debug++; + hideConsole = 0; break; - case 'n': - hideConsole = 0; - break; + case 'n': /* don't hide console window */ + hideConsole = 0; + break; - case 'v': - printf ("%s %s\n", version, mvers); - printf ("%s\n", CBUGS); + case 'v': /* output version info */ + hideConsole = 0; + LineToConsole ("%s %s\n", version, mvers); + LineToConsole ("%s\n", CBUGS); #ifdef RSA - printf ("RSA key installed: %s --- Created by: %s\n", key_name, client_creator); - printf ("Client type: %s\n", client_type); - printf ("Client arch: %s\n", client_arch); - printf ("Key permutation date: %s\n", client_key_date); - printf ("Comments: %s\n", client_comments); + LineToConsole ("RSA key installed: %s --- Created by: %s\n", key_name, client_creator); + LineToConsole ("Client type: %s\n", client_type); + LineToConsole ("Client arch: %s\n", client_arch); + LineToConsole ("Key permutation date: %s\n", client_key_date); + LineToConsole ("Comments: %s\n", client_comments); #endif exit (0); break; default: - fprintf (stderr, "%s: unknown option '%c'\n", name, *ptr); + LineToConsole ("%s: unknown option '%c'\n", name, *ptr); err++; break; } /* end switch */ @@ -360,21 +364,25 @@ } /* end while */ } /* end for */ + if (!usemeta && !servertmp) /* no meta type was selected, pick metaserver */ + usemeta = 1; + + if (hideConsole) + FreeConsole (); + if (usage || err) { printUsage (name); exit (err); } - if (hideConsole) - FreeConsole (); - #ifdef GATEWAY - if (!hset) use_trekhopd = 0; /* allow use via normal - * connections */ + if (!hset) use_trekhopd = 0; /* allow use via normal connections */ if (netaddr == 0) - fprintf (stderr, "netrek: no remote address set (-H). + { + LineToConsole ("netrek: no remote address set (-H). Restricted server will not work.\n"); + } #endif #ifdef RECORDGAME Index: map.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- map.c 18 Apr 2006 13:41:48 -0000 1.3 +++ map.c 21 Apr 2006 12:00:07 -0000 1.4 @@ -364,7 +364,7 @@ } #endif - if (l->pl_flags & PLAGRI) + if ((l->pl_flags & PLAGRI) && (l->pl_info & me->p_team)) { if (agriCAPS) { @@ -466,6 +466,8 @@ int ori_light = FED; char kli_score_line[5]; char ori_score_line[5]; + int ori_offset, kli_offset; + int i; /* Let's check KLI scores */ @@ -493,21 +495,33 @@ break; /* Now we have scores, so let's draw them */ - sprintf (kli_score_line, "%-2d", kli_score); sprintf (ori_score_line, "%2d", ori_score); + sprintf (kli_score_line, "%-2d", kli_score); - W_WriteText (mapw, 3 * W_Textwidth, 1 * W_Textheight, W_Kli, - kli_score_line, strlen (kli_score_line), W_RegularFont); - /*W_WriteTextDB (mapSDB, 3 * W_Textwidth, 1 * W_Textheight, W_Kli, - kli_score_line, strlen (kli_score_line), W_RegularFont);*/ + /* If we rotate galaxy 180 degrees the scoreboard flips */ + if (rotate == 2) + { + ori_offset = 8; + kli_offset = 3; + } + else + { + ori_offset = 3; + kli_offset = 8; + } + + W_WriteText (mapw, ori_offset * W_Textwidth, 1 * W_Textheight, W_Ori, + ori_score_line, strlen (ori_score_line), W_RegularFont); + /*W_WriteTextDB (mapSDB, ori_offset * W_Textwidth, 1 * W_Textheight, W_Ori, + ori_score_line, strlen (ori_score_line), W_RegularFont);*/ W_WriteText (mapw, 6 * W_Textwidth, 1 * W_Textheight, W_White, ":", 1, W_RegularFont); /*W_WriteTextDB (mapSDB, 6 * W_Textwidth, 1 * W_Textheight, W_White, ":", 1, W_RegularFont);*/ - W_WriteText (mapw, 8 * W_Textwidth, 1 * W_Textheight, W_Ori, - ori_score_line, strlen (ori_score_line), W_RegularFont); - /*W_WriteTextDB (mapSDB, 8 * W_Textwidth, 1 * W_Textheight, W_Ori, - ori_score_line, strlen (ori_score_line), W_RegularFont);*/ + W_WriteText (mapw, kli_offset * W_Textwidth, 1 * W_Textheight, W_Kli, + kli_score_line, strlen (kli_score_line), W_RegularFont); + /*W_WriteTextDB (mapSDB, kli_offset * W_Textwidth, 1 * W_Textheight, W_Kli, + kli_score_line, strlen (kli_score_line), W_RegularFont);*/ } #endif /* HOCKEY_LINES */ @@ -744,20 +758,28 @@ if (j->p_flags & PFCLOAK) { - W_WriteText (mapw, dx - W_Textwidth, - dy - W_Textheight / 2, unColor, cloakChars, - (cloakChars[1] == '\0' ? 1 : 2), W_RegularFont); - /*W_WriteTextDB (mapSDB, dx - W_Textwidth, - dy - W_Textheight / 2, unColor, cloakChars, - (cloakChars[1] == '\0' ? 1 : 2), W_RegularFont);*/ + if (omitTeamLetter) + W_WriteText (mapw, dx - (W_Textwidth / 2), + dy - W_Textheight / 2, unColor, cloakChars, + 1, W_RegularFont); + /*W_WriteTextDB (mapSDB, dx - (W_Textwidth / 2), + dy - W_Textheight / 2, unColor, cloakChars, + (cloakChars[1] == '\0' ? 1 : 2), W_RegularFont);*/ + else + W_WriteText (mapw, dx - W_Textwidth, + dy - W_Textheight / 2, unColor, cloakChars, + (cloakChars[1] == '\0' ? 1 : 2), W_RegularFont); + /*W_WriteTextDB (mapSDB, dx - W_Textwidth, + dy - W_Textheight / 2, unColor, cloakChars, + (cloakChars[1] == '\0' ? 1 : 2), W_RegularFont);*/ } else { if (omitTeamLetter) - W_WriteText (mapw, dx - W_Textwidth, + W_WriteText (mapw, dx - (W_Textwidth / 2), dy - W_Textheight / 2, playerColor (j), (j->p_mapchars)+1, 1, shipFont (j)); - /*W_WriteTextDB (mapSDB, dx - W_Textwidth, + /*W_WriteTextDB (mapSDB, dx - (W_Textwidth / 2), dy - W_Textheight / 2, playerColor (j), (j->p_mapchars)+1, 1, shipFont (j));*/ else @@ -816,10 +838,7 @@ if (j->p_status == PALIVE && !(j->p_flags & PFCLOAK)) { - if (omitTeamLetter) /* we want to draw triangle in the middle */ - dx = j->p_x * WINSIDE / GWIDTH - (W_Textwidth / 2); - else - dx = j->p_x * WINSIDE / GWIDTH; + dx = j->p_x * WINSIDE / GWIDTH; dy = j->p_y * WINSIDE / GWIDTH; W_WriteTriangle (mapw, dx, dy + 6, 4, 1, foreColor); //W_WriteTriangleDB (mapSDB, dx, dy + 6, 4, 1, foreColor); Index: redraw.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/redraw.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- redraw.c 19 Apr 2006 13:02:33 -0000 1.4 +++ redraw.c 21 Apr 2006 12:00:07 -0000 1.5 @@ -67,12 +67,15 @@ updateMaxStats (0); /* Update the max stats * <isae> */ - W_FlushScrollingWindow (messwa); - W_FlushScrollingWindow (messwt); - W_FlushScrollingWindow (messwi); - W_FlushScrollingWindow (messwk); - W_FlushScrollingWindow (reviewWin); - W_FlushScrollingWindow (phaserwin); + if (!richText) + { + W_FlushScrollingWindow (messwa); + W_FlushScrollingWindow (messwt); + W_FlushScrollingWindow (messwi); + W_FlushScrollingWindow (messwk); + W_FlushScrollingWindow (reviewWin); + W_FlushScrollingWindow (phaserwin); + } UpdatePlayerList (); } Index: sound.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- sound.c 21 Jan 2003 21:28:42 -0000 1.1.1.1 +++ sound.c 21 Apr 2006 12:00:07 -0000 1.2 @@ -88,7 +88,7 @@ char buf[PATH_MAX]; #ifdef DEBUG - printf ("Init_Sound\n"); + LineToConsole ("Init_Sound\n"); #endif if (sound_init) { @@ -260,7 +260,7 @@ } else { - fprintf (stderr, "Uh oh, bogus refresh number in soundrefresh\n"); + LineToConsole ("Uh oh, bogus refresh number in soundrefresh\n"); } W_WriteText (soundWin, 0, i, textColor, buf, strlen (buf), 0); Index: cowmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- cowmain.c 17 Apr 2006 09:44:08 -0000 1.6 +++ cowmain.c 21 Apr 2006 12:00:06 -0000 1.7 @@ -74,10 +74,8 @@ unsigned LONG mkaddr (); -unsigned LONG netaddr; /* used for blessedness - * checking */ -int serv_port; /* used for blessedness - * checking */ +unsigned LONG netaddr; /* used for blessedness checking */ +int serv_port; /* used for blessedness checking */ static char *gateway = DEFAULT_GATEWAY; @@ -123,7 +121,7 @@ if (!server_count) { - fprintf (stderr, "No server list, cannot resolve id\n"); + LineToConsole ("No server list, cannot resolve id\n"); return (-1); } @@ -132,8 +130,8 @@ { if (!strcmp (str, slp->id)) { - printf ("%s is %s(%d) (%s)\n", slp->id, slp->full_name, - slp->remote_port, slp->comment); + LineToConsole ("%s is %s(%d) (%s)\n", slp->id, slp->full_name, + slp->remote_port, slp->comment); xtrekPort = slp->gw_port; str = slp->inet_addr; break; @@ -141,7 +139,7 @@ } if (i == server_count) { - fprintf (stderr, "Specified server not found.\n"); + LineToConsole ("Specified server not found.\n"); return (-1); } @@ -162,18 +160,18 @@ /* do things slightly different */ if (slp->id == NULL) { - fprintf (stderr, "ERROR: host ID '%s' unknown\n", str); + LineToConsole ("ERROR: host ID '%s' unknown\n", str); return (-1); } xtrekPort = trekhopd_port; /* ought to have an arg to * specify this */ port_req = slp->remote_port; host_req = slp->full_name; - printf ("Connecting to %s (%d) via trekhopd (%s %d)\n", host_req, - port_req, serverName, xtrekPort); + LineToConsole ("Connecting to %s (%d) via trekhopd (%s %d)\n", host_req, + port_req, serverName, xtrekPort); #else - printf ("Connecting to %s through %s port %d\n", str, serverName, - xtrekPort); + LineToConsole ("Connecting to %s through %s port %d\n", str, serverName, + xtrekPort); #endif return (answer); @@ -226,7 +224,7 @@ return; } } - printf ("unable to get ports for your uid\n"); /* debug */ + LineToConsole ("unable to get ports for your uid\n"); /* debug */ gw_p = getenv ("GW_PORT"); gw_sp = getenv ("GW_SPORT"); @@ -237,8 +235,7 @@ gw_port = strtol (gw_p, &err, 10); if (err == gw_p) { - fprintf (stderr, "netrek: malformed integer for GW_PORT: %s\n", - gw_p); + LineToConsole ("netrek: malformed integer for GW_PORT: %s\n", gw_p); /* let something else complain about port 0 */ } } @@ -249,8 +246,7 @@ gw_serv_port = strtol (gw_sp, &err, 10); if (err == gw_sp) { - fprintf (stderr, "netrek: malformed integer for GW_SPORT: %s\n", - gw_sp); + LineToConsole ("netrek: malformed integer for GW_SPORT: %s\n", gw_sp); /* let something else complain about port 0 */ } } @@ -262,8 +258,7 @@ gw_local_port = strtol (gw_lp, &err, 10); if (err == gw_lp) { - fprintf (stderr, "netrek: malformed integer for GW_LPORT: %s\n", - gw_lp); + LineToConsole ("netrek: malformed integer for GW_LPORT: %s\n", gw_lp); /* let something else complain about port 0 */ } } @@ -293,7 +288,7 @@ ad.s_addr = inet_addr (m); if (ad.s_addr == -1) { - fprintf (stderr, "netrek: unknown host \'%s\'\n", m); + LineToConsole ("netrek: unknown host \'%s\'\n", m); terminate (1); } } @@ -343,8 +338,8 @@ { /* failed, give up */ perror ("warning: Unable to open server list"); - fprintf (stderr, "Tried to open '%s', '%s', and './%s'\n", - homedot, buf, SERVER_FILE); + LineToConsole ("Tried to open '%s', '%s', and './%s'\n", + homedot, buf, SERVER_FILE); return; } @@ -393,8 +388,7 @@ } if (map_count >= MAX_UDPMAP) { - fprintf (stderr, "UDP map too large; max is %d entries\n", - MAX_UDPMAP); + LineToConsole ("UDP map too large; max is %d entries\n", MAX_UDPMAP); break; } ump = &udpmap[map_count]; @@ -409,8 +403,8 @@ ump->local_port = atoi (cp); #ifdef DEBUG - printf ("%2d: %-8d %-8d %-8d %-8d\n", map_count, - ump->uid, ump->serv_port, ump->port, ump->local_port); + LineToConsole ("%2d: %-8d %-8d %-8d %-8d\n", map_count, + ump->uid, ump->serv_port, ump->port, ump->local_port); #endif map_count++; @@ -424,8 +418,7 @@ } if (server_count >= MAX_SERVER) { - fprintf (stderr, "server list too large; max is %d entries\n", - MAX_SERVER); + LineToConsole ("server list too large; max is %d entries\n", MAX_SERVER); break; } slp = &servers[server_count]; @@ -443,9 +436,9 @@ STRNCPY (slp->comment, cp, sizeof (slp->comment)); #ifdef DEBUG - printf ("%2d: %-9s %-15s %-5d %-5d %-25s \"%s\"\n", server_count, - slp->id, slp->inet_addr, slp->remote_port, slp->gw_port, - slp->full_name, slp->comment); + LineToConsole ("%2d: %-9s %-15s %-5d %-5d %-25s \"%s\"\n", server_count, + slp->id, slp->inet_addr, slp->remote_port, slp->gw_port, + slp->full_name, slp->comment); #endif server_count++; @@ -453,7 +446,7 @@ case 5: /* all done! */ break; default: - fprintf (stderr, "Whoops!\n"); + LineToConsole ("Whoops!\n"); terminate (2); } } @@ -472,8 +465,7 @@ static RETSIGTYPE handle_exception (int _dummy) { - printf - ("floating point exception error detected; attempting to continue\n"); + LineToConsole ("floating point exception error detected; attempting to continue\n"); /* Under Watcom C++, after a signal handler is called the signal reverts to SIG_DFL so has to be reset... is this standard? */ (void) SIGNAL (SIGFPE, handle_exception); @@ -501,7 +493,7 @@ int checking = 0; #ifdef META -int usemeta = 1; +int usemeta = 0; #endif /******************************************************************************/ @@ -541,17 +533,16 @@ { if ((hp = gethostbyname (myname)) == NULL) { - fprintf (stderr, "unable to get addr for local host\n"); + LineToConsole ("unable to get addr for local host\n"); return (1); } myaddr = *(LONG *) hp->h_addr; } - /* printf("myname = '%s', myaddr = 0x%.8lx\n", myname, myaddr); */ + /* LineToConsole ("myname = '%s', myaddr = 0x%.8lx\n", myname, myaddr); */ if ((myaddr & MYADDR_MASK) != MYADDR) { - fprintf (stderr, - "Sorry, you may not run this client on this host\n"); + LineToConsole ("Sorry, you may not run this client on this host\n"); return (1); } } @@ -966,7 +957,7 @@ sleep (1); if (logFile != NULL) fclose (logFile); - printf ("OK, bye!\n"); + LineToConsole ("OK, bye!\n"); #ifdef PACKET_LOG if (log_packets) Index: local.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- local.c 18 Apr 2006 13:41:48 -0000 1.5 +++ local.c 21 Apr 2006 12:00:07 -0000 1.6 @@ -1037,7 +1037,7 @@ if (highlightFriendlyPhasers) W_CacheLine (w, px, py, tx, ty, foreColor); else - { + { if ((php->ph_fuse % 2) == 1) W_CacheLine (w, px, py, tx, ty, foreColor); else @@ -1895,7 +1895,6 @@ tri_y = dy + 20; /* below ship */ facing = 1; } - /* printf("Drawing local triangle at %d %d\n", tri_x, tri_y); */ } } else if (me->p_flags & PFPLLOCK) @@ -1913,7 +1912,6 @@ tri_y = dy - 20; /* below planet */ facing = 0; } - /* printf("Drawing local triangle at %d %d\n", tri_x, tri_y); */ } if (tri_x != -1) { Index: death.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/death.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- death.c 12 Apr 2006 04:20:03 -0000 1.2 +++ death.c 21 Apr 2006 12:00:06 -0000 1.3 @@ -94,6 +94,10 @@ deathFont = W_RegularFont; +#ifdef DEBUG + LineToConsole ("Death cause: %d\n", me->p_whydead); +#endif + switch (me->p_whydead) { case KQUIT: @@ -106,13 +110,6 @@ teamlet[players[me->p_whodead].p_team], shipnos[me->p_whodead]); break; - case KPLASMA: - sprintf (deathmessage, - "You were SMACKed by a plasma torpedo from %s (%c%c) ", - players[me->p_whodead].p_name, - teamlet[players[me->p_whodead].p_team], - shipnos[me->p_whodead]); - break; case KPHASER: sprintf (deathmessage, "You were phasered to death by %s (%c%c)", @@ -159,22 +156,36 @@ case KPROVIDENCE: strcpy (deathmessage, "You were nuked by GOD."); break; + case KPLASMA: + sprintf (deathmessage, + "You were SMACKed by a plasma torpedo from %s (%c%c) ", + players[me->p_whodead].p_name, + teamlet[players[me->p_whodead].p_team], + shipnos[me->p_whodead]); + break; + case TOURNEND: + strcpy (deathmessage, "The tournament game has ended."); + break; case KOVER: - strcpy (deathmessage, "The game is over!"); + strcpy (deathmessage, "The game is over!"); break; case TOURNSTART: strcpy (deathmessage, "The tournament game has begun!"); break; - case TOURNEND: - strcpy (deathmessage, "The tournament game has ended."); - break; case KBADBIN: - strcpy (deathmessage, - "Your netrek executable didn't verify correctly."); + strcpy (deathmessage, "Your netrek executable didn't verify correctly."); + break; + case KTORP2: + strcpy (deathmessage, "You were killed by detonated torpedo"); + break; + case KSHIP2: + strcpy (deathmessage, "You were killed by chain reaction explosion"); + break; + case KPLASMA2: + strcpy (deathmessage, "You were killed by zapped plasma"); break; default: - strcpy (deathmessage, - "You were killed by something unknown to this game?"); + strcpy (deathmessage, "You were killed by something unknown to this game?"); break; } @@ -201,7 +212,7 @@ if (!playback) { /* If we are not playing back a recorded game, do this */ W_TerminateWait (); - ENDTHREAD; + ExitThread(0); } else { /* Otherwise we aren't within a thread, so... */ Index: playerlist.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/playerlist.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- playerlist.c 12 Apr 2006 04:20:04 -0000 1.2 +++ playerlist.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -77,6 +77,7 @@ int partitionPlist = FALSE; char *plistCustomLayout; +char *plist2CustomLayout; int plistReorder = FALSE; int playerListStyle = 0; int playerListObserver = 0; @@ -101,16 +102,20 @@ */ char *plistLayout = ""; +char *plist2Layout = ""; static int plistPos[MAXPLAYER]; static int plistWidth = 0; +static int plist2Width = 0; static char *my_classes[NUM_TYPES] = { "SC", "DD", "CA", "BB", "AS", "SB", "GA", "??" }; /* Local Functions */ -static int PlistHeader (char *layout, +static int PlistHeader (W_Window win, + char *layout, int doWrite); -static void PlistLine (struct player *j, +static void PlistLine (W_Window win, + struct player *j, int pos); static void WriteSortedPlist (void); static void WriteUnsortedPlist (void); @@ -125,9 +130,8 @@ { /* Find the default style number for the player list. */ - plistCustomLayout = stringDefault ("playerlist"); - - + plistCustomLayout = stringDefault ("playerList"); + plist2CustomLayout = stringDefault ("playerList2"); /* Select a style number base on the information in the defaults * (.xtrekrc) file. */ @@ -208,7 +212,7 @@ plistCustomLayout = stringDefault ("playerlist"); if (IsNotEmpty (plistCustomLayout)) - plistWidth = PlistHeader (plistCustomLayout, FALSE); + plistWidth = PlistHeader (playerw, plistCustomLayout, FALSE); else plistWidth = 0; @@ -219,6 +223,22 @@ } +int +PlistMaxWidth2 () +/* Calculate the maximum width of all the defined player lists so that the + * width of the player list window can be defined. */ +{ + plist2CustomLayout = stringDefault ("playerList2"); + + if (IsNotEmpty (plist2CustomLayout)) + plist2Width = PlistHeader (playerw2, plist2CustomLayout, FALSE); + else + plist2Width = PlistHeader (playerw2, "n T R N l M K W L r O D d ", FALSE); + + return plist2Width; +} + + void RedrawPlayerList () /* Completly redraw the player list, rather than incrementally updating the @@ -231,7 +251,7 @@ { int i; - if (IsEmpty (me) || !W_IsMapped (playerw)) + if (IsEmpty (me)) return; @@ -263,7 +283,7 @@ break; default: - fprintf (stderr, "Unknown playerListStyle in ChangedPlistStyle().\n"); + LineToConsole ("Unknown playerListStyle\n"); break; } @@ -272,10 +292,18 @@ if (playerListObserver == 2) plistLayout = "n N l M"; + if (IsEmpty (plist2CustomLayout)) + plist2Layout = "n T R N l M K W L r O D d "; + else + plist2Layout = plist2CustomLayout; + /* Redraw the player list. */ W_ClearWindow (playerw); - (void) PlistHeader (plistLayout, TRUE); + PlistHeader (playerw, plistLayout, TRUE); + + W_ClearWindow (playerw2); + PlistHeader (playerw2, plist2Layout, TRUE); plistReorder = TRUE; plistUpdated = TRUE; @@ -303,7 +331,7 @@ plistUpdated = FALSE; - if (!W_IsMapped (playerw)) + if (!W_IsMapped (playerw) && !W_IsMapped (playerw2)) return; if (!plistReorder) @@ -339,13 +367,22 @@ if (players[count].p_status != PFREE) { if (playerListObserver == 0) - PlistLine (players + count, plistPos[count]); + { + PlistLine (playerw, players + count, plistPos[count]); + PlistLine (playerw2, players + count, plistPos[count]); + } else if (playerListObserver == 1 && players[count].p_mapchars[1] <= 'f') - PlistLine (players + count, plistPos[count]); + { + PlistLine (playerw, players + count, plistPos[count]); + PlistLine (playerw2, players + count, plistPos[count]); + } else if (playerListObserver == 2 && !(players[count].p_mapchars[1] <= 'f')) - PlistLine (players + count, plistPos[count]); + { + PlistLine (playerw, players + count, plistPos[count]); + PlistLine (playerw2, players + count, plistPos[count]); + } } } else @@ -356,7 +393,10 @@ !(players[count].p_flags & PFOBSERV)) || ((playerListObserver == 2) && (players[count].p_flags & PFOBSERV)))) - PlistLine (players + count, plistPos[count]); + { + PlistLine (playerw, players + count, plistPos[count]); + PlistLine (playerw2, players + count, plistPos[count]); + } } } } @@ -458,6 +498,7 @@ { blankLine = last; W_ClearArea (playerw, 0, last, plistWidth, 1); + W_ClearArea (playerw2, 0, last, plist2Width, 1); } ++last; @@ -481,6 +522,7 @@ { blankLine = last; W_ClearArea (playerw, 0, last, plistWidth, 1); + W_ClearArea (playerw2, 0, last, plist2Width, 1); } ++last; @@ -500,6 +542,7 @@ { blankLine2 = last; W_ClearArea (playerw, 0, last, plistWidth, 1); + W_ClearArea (playerw2, 0, last, plist2Width, 1); } ++last; @@ -513,7 +556,10 @@ /* Clear some lines if people have left. */ for (row = last; row < plistLastRow; ++row) + { W_ClearArea (playerw, 0, row, plistWidth, 1); + W_ClearArea (playerw2, 0, row, plist2Width, 1); + } plistLastRow = last; @@ -541,7 +587,8 @@ plistPos[i] = row; updatePlayer[i] = FALSE; - PlistLine (current, row); + PlistLine (playerw, current, row); + PlistLine (playerw2, current, row); } else if (playerListObserver == 1 && current->p_mapchars[1] <= 'f') @@ -553,7 +600,8 @@ plistPos[i] = row; updatePlayer[i] = FALSE; - PlistLine (current, row); + PlistLine (playerw, current, row); + PlistLine (playerw2, current, row); } else if (playerListObserver == 2 && !(current->p_mapchars[1] <= 'f')) @@ -565,7 +613,8 @@ plistPos[i] = row; updatePlayer[i] = FALSE; - PlistLine (current, row); + PlistLine (playerw, current, row); + PlistLine (playerw2, current, row); } } else @@ -581,7 +630,8 @@ plistPos[i] = row; updatePlayer[i] = FALSE; - PlistLine (current, row); + PlistLine (playerw, current, row); + PlistLine (playerw2, current, row); } } } @@ -645,16 +695,23 @@ plistPos[count] = pos; if (players[count].p_status != PFREE) - PlistLine (players + count, pos); + { + PlistLine (playerw, players + count, pos); + PlistLine (playerw2, players + count, pos); + } else + { W_ClearArea (playerw, 0, pos, plistWidth, 1); + W_ClearArea (playerw2, 0, pos, plistWidth, 1); + } } } static int -PlistHeader (char *layout, +PlistHeader (W_Window win, + char *layout, int doWrite) /* Analyse the heading (field names) for a player list, and set the * plistHasSpeed and plistHasHostile flags. @@ -682,7 +739,7 @@ * code will dump core here because of an attempt to write over a * constant string. */ - fprintf (stderr, "Playerlist truncated to fit buffer.\n"); + LineToConsole ("Playerlist truncated to fit buffer.\n"); layout = '\0'; break; } @@ -911,8 +968,7 @@ #endif default: - fprintf (stderr, - "%c is not an option for the playerlist\n", *layout); + LineToConsole ("%c is not an option for the playerlist\n", *layout); break; } } @@ -920,25 +976,31 @@ header[num] = '\0'; if (doWrite) - W_WriteText (playerw, 0, 0, textColor, header, num, W_RegularFont); + if (W_IsMapped (win)) + W_WriteText (win, 0, 0, textColor, header, num, W_RegularFont); return num; } static void -PlistLine (struct player *j, +PlistLine (W_Window win, + struct player *j, int pos) /* Write the player list entry for player `j' on line `pos'. */ { char buf[BUFSIZ]; char *ptr; char *buffPoint; + char *tmpLayout; int kills, losses, my_ticks; float pRating, oRating, dRating, bRating, Ratings; float KillsPerHour, LossesPerHour; /* Added 12/27/93 ATH */ double ratio, max_kills; + if (!W_IsMapped (win)) + return; + /* Fill pl_row to get right player placement in the list */ pl_row[j->p_no] = pos; @@ -999,7 +1061,12 @@ buffPoint = buf; - for (ptr = plistLayout; IsNotZero (*ptr); ++ptr) + if (win == playerw) + tmpLayout = plistLayout; + else + tmpLayout = plist2Layout; + + for (ptr = tmpLayout; IsNotZero (*ptr); ++ptr) { *(buffPoint++) = ' '; @@ -1289,7 +1356,7 @@ *buffPoint = '\0'; // Don't draw the line if pos has been set to -1 if (pos > -1) - W_WriteText (playerw, 0, pos, playerColor (j), + W_WriteText (win, 0, pos, playerColor (j), buf, buffPoint - buf, shipFont (j)); } Index: winsndlib.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/winsndlib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- winsndlib.c 12 Apr 2006 04:20:04 -0000 1.2 +++ winsndlib.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -82,17 +82,17 @@ in = fopen (fname, "rb"); if (!in) { - fprintf (stderr, "Could not open wave file %s\n", fname); + LineToConsole ("Could not open wave file %s\n", fname); return 0; } fread (chunk, 8, 1, in); /* read signature, and file length (which we discard) */ #ifdef DEBUG - printf ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], chunk[3]); + LineToConsole ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], chunk[3]); #endif if (strncmp (chunk, "RIFF", 4)) { - fprintf (stderr, "%s is not a valid wave file\n", fname); + LineToConsole ("%s is not a valid wave file\n", fname); return 0; } @@ -103,7 +103,7 @@ if (feof (in)) goto NoGood; #ifdef DEBUG - printf ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], chunk[3]); + LineToConsole ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], chunk[3]); #endif if (!strncmp (chunk, "WAVE", 4)) do @@ -113,8 +113,8 @@ if (feof (in)) goto NoGood; #ifdef DEBUG - printf ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], - chunk[3]); + LineToConsole ("Chunk: %c%c%c%c\n", chunk[0], chunk[1], chunk[2], + chunk[3]); #endif if (!strncmp (chunk, "fmt ", 4)) /* found fmt chunk, read header */ { @@ -124,7 +124,7 @@ != 1) goto NoGood; #ifdef DEBUG - printf ("Yup gosh read the header\n"); + LineToConsole ("Yup gosh read the header\n"); #endif chunksread++; } @@ -135,7 +135,7 @@ if (fread (*data, len, 1, in) != 1) goto NoGood; #ifdef DEBUG - printf ("Read %d bytes of data\n", *datalen); + LineToConsole ("Read %d bytes of data\n", *datalen); #endif chunksread++; } @@ -150,7 +150,7 @@ return 1; NoGood: - fprintf (stderr, "%s is not a valid wave file\n", fname); + LineToConsole ("%s is not a valid wave file\n", fname); fclose (in); return 0; } @@ -166,7 +166,7 @@ struct sound *itr = newest, *newsnd; #ifdef DEBUG - printf ("Searching for sound %s in cache\n", name); + LineToConsole ("Searching for sound %s in cache\n", name); #endif while (itr) @@ -174,17 +174,17 @@ #ifdef DEBUG if (loopcount > 0 && itr == newest) { - printf ("Sound list is circular with %d items!\n", loopcount); + LineToConsole ("Sound list is circular with %d items!\n", loopcount); return 0; } if (loopcount++ > 100) { - printf ("Stuck in GetSound loop!\n"); + LineToConsole ("Stuck in GetSound loop!\n"); return 0; } - printf ("Found %s in cache\n", itr->name); + LineToConsole ("Found %s in cache\n", itr->name); #endif if (!strcmp (name, itr->name)) @@ -212,7 +212,7 @@ /* Sound not in cache, must load */ #ifdef DEBUG - printf ("Sound %s not in cache, loading\n", name); + LineToConsole ("Sound %s not in cache, loading\n", name); #endif newsnd = (struct sound *) malloc (sizeof (struct sound)); @@ -231,8 +231,8 @@ struct sound *next = itr->newer; bytesused -= itr->hdr.dwBufferLength; #ifdef DEBUG - printf ("Trimming sound cache, file %s, %d bytes\n", itr->name, - itr->hdr.dwBufferLength); + LineToConsole ("Trimming sound cache, file %s, %d bytes\n", itr->name, + itr->hdr.dwBufferLength); #endif if (next) /* Remove from list, simple as always at end */ { @@ -301,7 +301,7 @@ if (SoundPlaying ()) { #ifdef DEBUG - printf ("Interuppting sound\n"); + LineToConsole ("Interuppting sound\n"); #endif waveOutReset (hw); waveOutUnprepareHeader (hw, ¤t->hdr, sizeof (WAVEHDR)); @@ -318,7 +318,7 @@ WAVEOUTCAPS caps; #ifdef DEBUG - printf ("Request to play sound %s\n", name); + LineToConsole ("Request to play sound %s\n", name); #endif StopSound (); @@ -329,33 +329,34 @@ if (!hw) { #ifdef DEBUG - printf ("Initial open of wave device\n"); + LineToConsole ("Initial open of wave device\n"); #endif if (err = waveOutOpen (&hw, WAVE_MAPPER, (LPWAVEFORMATEX) & snd->fmt, 0, 0, 0)) - fprintf (stderr, "Could not open wave device, error %d\n", - err); + { + LineToConsole ("Could not open wave device, error %d\n", err); + } memcpy (&lastfmt, &snd->fmt, sizeof (PCMWAVEFORMAT)); } else if (memcmp (&snd->fmt, &lastfmt, sizeof (PCMWAVEFORMAT))) /* Re-use the currently open sound handle of the formats are the same */ { #ifdef DEBUG - printf ("Re-open of wave device\n"); + LineToConsole ("Re-open of wave device\n"); #endif waveOutClose (hw); memcpy (&lastfmt, &snd->fmt, sizeof (PCMWAVEFORMAT)); if (err = waveOutOpen (&hw, WAVE_MAPPER, (LPWAVEFORMATEX) & snd->fmt, 0, 0, 0)) - fprintf (stderr, "Could not open wave device, error %d\n", - err); - + { + LineToConsole ("Could not open wave device, error %d\n", err); + } } #ifdef DEBUG else - printf ("Re-using open sound handle\n"); + LineToConsole ("Re-using open sound handle\n"); #endif waveOutPrepareHeader (hw, &snd->hdr, sizeof (WAVEHDR)); waveOutWrite (hw, &snd->hdr, sizeof (WAVEHDR)); @@ -389,7 +390,7 @@ int playing; #ifdef DEBUG - printf ("playing = ..."); + LineToConsole ("playing = ..."); #endif if (!hw || !current) return 0; @@ -401,7 +402,7 @@ current = NULL; } #ifdef DEBUG - printf ("%d\n", playing); + LineToConsole ("%d\n", playing); #endif return playing; } Index: reserved.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/reserved.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- reserved.c 21 Jan 2003 21:28:42 -0000 1.1.1.1 +++ reserved.c 21 Apr 2006 12:00:07 -0000 1.2 @@ -80,7 +80,7 @@ netaddr = saddr.sin_addr.s_addr; } - /* printf("Verifying with netaddr %x\n", netaddr); */ + /* LineToConsole ("Verifying with netaddr %x\n", netaddr); */ mixin1 = (unsigned char) ((netaddr >> 24) & 0xff); mixin2 = pno; mixin3 = (unsigned char) ((netaddr >> 16) & 0xff); Index: docwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/docwin.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- docwin.c 21 Jan 2003 21:28:34 -0000 1.1.1.1 +++ docwin.c 21 Apr 2006 12:00:06 -0000 1.2 @@ -153,7 +153,7 @@ if (temp == NULL) { /* malloc error checking -- * 10/30/92 EM */ - printf ("Warning: Couldn't malloc space for a new doc line!"); + LineToConsole ("Warning: Couldn't malloc space for a new doc line!"); return; } @@ -202,7 +202,7 @@ if (temp->next == NULL) { /* malloc error checking -- * 10/30/92 EM */ - printf ("Warning: Couldn't malloc space for a new doc line!"); + LineToConsole ("Warning: Couldn't malloc space for a new doc line!"); return; } @@ -329,7 +329,7 @@ if (temp == NULL) { /* malloc error checking -- * 10/30/92 EM */ - printf ("Warning: Couldn't malloc space for a new doc line!"); + LineToConsole ("Warning: Couldn't malloc space for a new doc line!"); return; } @@ -361,7 +361,7 @@ if (temp->next == NULL) { /* malloc error checking -- * 10/30/92 EM */ - printf ("Warning: Couldn't malloc space for a new doc line!"); + LineToConsole ("Warning: Couldn't malloc space for a new doc line!"); return; } Index: senddist.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/senddist.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- senddist.c 12 Apr 2006 04:20:04 -0000 1.2 +++ senddist.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -184,7 +184,7 @@ if (!group) { - printf ("Bad group! %c %d %d\n", addr, recip, group); + LineToConsole ("Bad group! %c %d %d\n", addr, recip, group); return (0); } Index: socket.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- socket.c 12 Apr 2006 04:20:04 -0000 1.2 +++ socket.c 21 Apr 2006 12:00:07 -0000 1.3 @@ -423,7 +423,7 @@ (char *) &option_value, sizeof (option_value)); if (status < 0) { - fprintf (stderr, ("setsockopt() failed, %s\n", strerror (errno))); + LineToConsole ("setsockopt() failed, %s\n", strerror (errno)); /* can still play without this, proceed */ } } @@ -447,11 +447,11 @@ sock = -1; } - printf ("Waiting for connection (port %d). \n", port); + LineToConsole ("Waiting for connection (port %d). \n", port); if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) { - printf ("I can't create a socket\n"); + LineToConsole ("I can't create a socket\n"); terminate (2); } @@ -489,7 +489,7 @@ if (select (max_fd, &readfds, NULL, NULL, &timeout) == 0) { - printf ("Well, I think the server died!\n"); + LineToConsole ("Well, I think the server died!\n"); terminate (0); } @@ -503,7 +503,7 @@ if (sock >= max_fd) max_fd = sock + 1; - printf ("Got connection.\n"); + LineToConsole ("Got connection.\n"); closesocket (s); setNoDelay (sock); @@ -536,7 +536,7 @@ strcpy (serverName, inet_ntoa (addr.sin_addr)); } } - printf ("Connection from server %s (0x%x)\n", serverName, serveraddr); + LineToConsole ("Connection from server %s (0x%x)\n", serverName, serveraddr); } @@ -550,11 +550,11 @@ serverDead = 0; - printf ("Calling %s on port %d.\n", server, port); + LineToConsole ("Calling %s on port %d\n", server, port); if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) { - printf ("I can't create a socket\n"); + LineToConsole ("I can't create a socket\n"); terminate (0); } addr.sin_family = AF_INET; @@ -564,7 +564,7 @@ { if ((hp = gethostbyname (server)) == NULL) { - printf ("Who is %s?\n", server); + LineToConsole ("Who is %s?\n", server); terminate (0); } else @@ -576,10 +576,10 @@ if (connect (s, (struct sockaddr *) &addr, sizeof (addr)) < 0) { - printf ("Server not listening!\n"); + LineToConsole ("Server not listening!\n"); terminate (0); } - printf ("Got connection.\n"); + LineToConsole ("Got connection.\n"); sock = s; @@ -611,10 +611,10 @@ strcpy (msg.mesg + 16, host_req); if (gwrite (s, &msg, sizeof (struct mesg_cpacket)) < 0) { - fprintf (stderr, "trekhopd init failure\n"); + LineToConsole ("trekhopd init failure\n"); terminate (1); } - printf ("--- trekhopd request sent, awaiting reply\n"); + LineToConsole ("--- trekhopd request sent, awaiting reply\n"); /* now block waiting for reply */ count = sizeof (struct mesg_spacket); @@ -629,7 +629,7 @@ if (reply.type != SP_MESSAGE) { - fprintf (stderr, "Got bogus reply from trekhopd (%d)\n", + LineToConsole ("Got bogus reply from trekhopd (%d)\n", reply.type); terminate (1); } @@ -637,9 +637,9 @@ gw_serv_port = ntohl (*ip++); gw_port = ntohl (*ip++); serv_port = ntohl (*ip++); - printf ("--- trekhopd reply received\n"); + LineToConsole ("--- trekhopd reply received\n"); - /* printf("ports = %d/%d, %d\n", gw_serv_port, gw_port, serv_port); */ + /* LineToConsole ("ports = %d/%d, %d\n", gw_serv_port, gw_port, serv_port); */ } } #endif /* TREKHOPD */ @@ -836,7 +836,7 @@ size = ((unsigned char) bufptr[1] * 2) + 2; break; default: - fprintf (stderr, "Unknown variable packet\n"); + LineToConsole ("Unknown variable packet\n"); /* terminate(1); */ return -1; break; @@ -871,8 +871,10 @@ 0); if (debug) - printf ("read %d bytes from %s socket\n", + { + LineToConsole ("read %d bytes from %s socket\n", count, asock == udpSock ? "UDP" : "TCP"); + } if (count <= 0) { @@ -916,7 +918,7 @@ } return (0); } - printf ("1) Got read() of %d. Server dead\n", count); + LineToConsole ("1) Got read() of %d. Server dead\n", count); perror ("1) read()"); serverDead = 1; return (0); @@ -933,14 +935,14 @@ int i; #endif - fprintf (stderr, "Unknown packet type: %d\n", *bufptr); + LineToConsole ("Unknown packet type: %d\n", *bufptr); #ifndef CORRUPTED_PACKETS - printf ("count: %d, bufptr at %d, Content:\n", count, - bufptr - buf); + LineToConsole ("count: %d, bufptr at %d, Content:\n", count, + bufptr - buf); for (i = 0; i < count; i++) { - printf ("0x%x, ", (unsigned int) buf[i]); + LineToConsole ("0x%x, ", (unsigned int) buf[i]); } #endif @@ -954,20 +956,23 @@ size = getvpsize (bufptr); if (size <= 0) { - fprintf (stderr, "Bad short-packet size value (%d)\n", size); + LineToConsole ("Bad short-packet size value (%d)\n", size); return 0; } if (debug) - printf ("read variable packet size %d, type %d\n", - size, *bufptr); + { + LineToConsole ("read variable packet size %d, type %d\n", + size, *bufptr); + } } #endif /* SHORT_PACKETS */ if (size == 0) - fprintf (stderr, - "Variable packet has 0 length! type=%d Trying to read more!\n", - *bufptr); + { + LineToConsole ("Variable packet has 0 length! type=%d Trying to read more!\n", + *bufptr); + } /* read broke in the middle of a packet, wait until we get the rest */ while (size > count + (buf - bufptr) || size == 0) { @@ -981,7 +986,7 @@ /* readfds=1<<asock; */ if ((temp = select (max_fd, &readfds, 0, 0, &timeout)) == 0) { - printf ("Packet fragment. Server must be dead\n"); + LineToConsole ("Packet fragment. Server must be dead\n"); serverDead = 1; return (0); } @@ -998,7 +1003,7 @@ count += temp; if (temp <= 0) { - printf ("2) Got read() of %d. Server is dead\n", temp); + LineToConsole ("2) Got read() of %d. Server is dead\n", temp); serverDead = 1; return (0); } @@ -1014,7 +1019,9 @@ || *bufptr == SP_SC_SEQUENCE)) { if (debug) - printf ("read packet %d\n", *bufptr); + { + LineToConsole ("read packet %d\n", *bufptr); + } #ifdef RECORDGAME if (recordFile != NULL && ckRecordPacket (*bufptr)) @@ -1047,14 +1054,16 @@ if (debug) { if (drop_flag) - printf ("%d bytes dropped.\n", size); + { + LineToConsole ("%d bytes dropped.\n", size); + } } UDPDIAG (("Ignored type %d\n", *bufptr)); } } else { - printf ("Handler for packet %d not installed...\n", *bufptr); + LineToConsole ("Handler for packet %d not installed...\n", *bufptr); } bufptr += size; @@ -1071,7 +1080,7 @@ #ifdef CORRUPTED_PACKETS if (ntohs (packet->tnum) >= MAXPLAYER * MAXTORP) { - fprintf (stderr, "handleTorp: bad index %d\n", ntohs (packet->tnum)); + LineToConsole ("handleTorp: bad index %d\n", ntohs (packet->tnum)); return; } #endif @@ -1103,8 +1112,7 @@ #ifdef CORRUPTED_PACKETS if (ntohs (packet->tnum) >= MAXPLAYER * MAXTORP) { - fprintf (stderr, "handleTorpInfo: bad index %d\n", - ntohs (packet->tnum)); + LineToConsole ("handleTorpInfo: bad index %d\n", ntohs (packet->tnum)); return; } #endif @@ -1116,7 +1124,7 @@ if (packet->status == TEXPLODE && thetorp->t_status == TFREE) { /* FAT: redundant explosion; don't update p_ntorp */ - /* printf("texplode ignored\n"); */ + /* LineToConsole ("texplode ignored\n"); */ return; } @@ -1161,12 +1169,12 @@ if (debug) { - printf ("SERVER STATS:\n"); - printf ("time: %d\n", status->time / (60 * 60 * 10)); - printf ("kills: %d\n", status->kills); - printf ("losses: %d\n", status->losses); - printf ("planets: %d\n", status->planets); - printf ("armsbomb: %d\n", status->armsbomb); + LineToConsole ("SERVER STATS:\n"); + LineToConsole ("time: %d\n", status->time / (60 * 60 * 10)); + LineToConsole ("kills: %d\n", status->kills); + LineToConsole ("losses: %d\n", status->losses); + LineToConsole ("planets: %d\n", status->planets); + LineToConsole ("armsbomb: %d\n", status->armsbomb); } } @@ -1177,7 +1185,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleSelf: bad index %d\n", packet->pnum); + LineToConsole ("handleSelf: bad index %d\n", packet->pnum); return; } #endif @@ -1233,7 +1241,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handlePlayer: bad index %d\n", packet->pnum); + LineToConsole ("handlePlayer: bad index %d\n", packet->pnum); return; } #endif @@ -1382,7 +1390,7 @@ if (packet->type < 1 || packet->type > NUM_SIZES || sizes[packet->type] == 0) { - printf ("Attempt to send strange packet %d!\n", packet->type); + LineToConsole ("Attempt to send strange packet %d!\n", packet->type); return; } size = sizes[packet->type]; @@ -1407,7 +1415,7 @@ /* business as usual (or player has turned off UDP transmission) */ if (gwrite (sock, (char *) packet, size) != size) { - printf ("gwrite failed. Server must be dead\n"); + LineToConsole ("gwrite failed. Server must be dead\n"); serverDead = 1; } } @@ -1471,7 +1479,7 @@ /* critical stuff, use TCP */ if (gwrite (sock, (char *) packet, size) != size) { - printf ("gwrite failed. Server must be dead\n"); + LineToConsole ("gwrite failed. Server must be dead\n"); serverDead = 1; } } @@ -1489,7 +1497,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLANETS) { - fprintf (stderr, "handlePlanet: bad index %d\n", packet->pnum); + LineToConsole ("handlePlanet: bad index %d\n", packet->pnum); return; } #endif @@ -1543,14 +1551,13 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handlePhaser: bad index %d\n", packet->pnum); + LineToConsole ("handlePhaser: bad index %d\n", packet->pnum); return; } if (packet->status == PHHIT && (ntohl (packet->target) < 0 || ntohl (packet->target) >= MAXPLAYER)) { - fprintf (stderr, "handlePhaser: bad target %d\n", - ntohl (packet->target)); + LineToConsole ("handlePhaser: bad target %d\n", ntohl (packet->target)); return; } #endif @@ -1587,9 +1594,10 @@ packet->mesg[sizeof (packet->mesg) - 1] = '\0'; #endif - /* printf("flags: 0x%x\n", packet->m_flags); printf("from: %d\n", - * packet->m_from); printf("recpt: %d\n", packet->m_recpt); printf("mesg: - * %s\n", packet->mesg); */ + /* LineToConsole ("flags: 0x%x\n", packet->m_flags); + * LineToConsole ("from: %d\n", * packet->m_from); + * LineToConsole ("recpt: %d\n", packet->m_recpt); + * LineToConsole ("mesg: * %s\n", packet->mesg); */ dmessage (packet->mesg, packet->m_flags, packet->m_from, packet->m_recpt); @@ -1697,7 +1705,7 @@ #ifdef CORRUPTED_PACKETS if (ntohs (packet->pnum) >= MAXPLAYER * MAXPLASMA) { - fprintf (stderr, "handlePlasmaInfo: bad index %d\n", packet->pnum); + LineToConsole ("handlePlasmaInfo: bad index %d\n", packet->pnum); return; } #endif @@ -1738,7 +1746,7 @@ #ifdef CORRUPTED_PACKETS if (ntohs (packet->pnum) >= MAXPLAYER * MAXPLASMA) { - fprintf (stderr, "handlePlasma: bad index %d\n", packet->pnum); + LineToConsole ("handlePlasma: bad index %d\n", packet->pnum); return; } #endif @@ -1765,7 +1773,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleFlags: bad index %d\n", packet->pnum); + LineToConsole ("handleFlags: bad index %d\n", packet->pnum); return; } #endif @@ -1802,7 +1810,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleKills: bad index %d\n", packet->pnum); + LineToConsole ("handleKills: bad index %d\n", packet->pnum); return; } #endif @@ -1831,7 +1839,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handlePStatus: bad index %d\n", packet->pnum); + LineToConsole ("handlePStatus: bad index %d\n", packet->pnum); return; } #endif @@ -1954,8 +1962,8 @@ switch (packet->why) { case 0: - printf ("Sorry, this is an invalid client version.\n"); - printf ("You need a new version of the client code.\n"); + LineToConsole ("Sorry, this is an invalid client version.\n"); + LineToConsole ("You need a new version of the client code.\n"); break; case 1: case 2: @@ -1963,11 +1971,11 @@ case 4: case 5: case 6: - printf ("Sorry, but you cannot play xtrek now.\n"); - printf ("Try again later.\n"); + LineToConsole ("Sorry, but you cannot play xtrek now.\n"); + LineToConsole ("Try again later.\n"); break; default: - printf ("Unknown message from handleBadVersion.\n"); + LineToConsole ("Unknown message from handleBadVersion.\n"); return; } terminate (1); @@ -1985,8 +1993,7 @@ { if (fd == udpSock) { - fprintf (stderr, "Tried to write %d, 0x%x, %d\n", - fd, buf, bytes); + LineToConsole ("Tried to write %d, 0x%x, %d\n", fd, buf, bytes); perror ("write"); printUdpInfo (); } @@ -2006,7 +2013,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleHostile: bad index %d\n", packet->pnum); + LineToConsole ("handleHostile: bad index %d\n", packet->pnum); return; } #endif @@ -2031,7 +2038,7 @@ #ifdef CORRUPTED_PACKETS if (sock == udpSock) { - fprintf (stderr, "garbage packet discarded.\n"); + LineToConsole ("garbage packet discarded.\n"); return; } #endif @@ -2039,12 +2046,12 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handlePlyrLogin: bad index %d\n", packet->pnum); + LineToConsole ("handlePlyrLogin: bad index %d\n", packet->pnum); return; } if (packet->rank >= NUMRANKS) { - fprintf (stderr, "handlePlyrLogin: bad rank %d\n", packet->rank); + LineToConsole ("handlePlyrLogin: bad rank %d\n", packet->rank); return; } packet->name[sizeof (packet->name) - 1] = '\0'; @@ -2059,7 +2066,7 @@ strcpy (pl->p_login, packet->login); pl->p_stats.st_rank = packet->rank; - /* printf("read player login %s, %s, %s\n", pl->p_name, pl->p_monitor, + /* LineToConsole ("read player login %s, %s, %s\n", pl->p_name, pl->p_monitor, * pl->p_login); */ if (packet->pnum == me->p_no) @@ -2094,7 +2101,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleStats: bad index %d\n", packet->pnum); + LineToConsole ("handleStats: bad index %d\n", packet->pnum); return; } #endif @@ -2139,12 +2146,12 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handlePlyrInfo: bad index %d\n", packet->pnum); + LineToConsole ("handlePlyrInfo: bad index %d\n", packet->pnum); return; } if (packet->team > ALLTEAM) { - fprintf (stderr, "handlePlyrInfo: bad team %d\n", packet->team); + LineToConsole ("handlePlyrInfo: bad team %d\n", packet->team); return; } #endif @@ -2195,7 +2202,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLANETS) { - fprintf (stderr, "handlePlanetLoc: bad index\n"); + LineToConsole ("handlePlanetLoc: bad index\n"); return; } #endif @@ -2207,7 +2214,7 @@ if (pl_update[packet->pnum].plu_update != -1) { pl_update[packet->pnum].plu_update = 1; - /* printf("update: %s, old (%d,%d) new (%d,%d)\n", pl->pl_name, + /* LineToConsole ("update: %s, old (%d,%d) new (%d,%d)\n", pl->pl_name, * pl->pl_x, pl->pl_y, ntohl(packet->x),ntohl(packet->y)); */ } else @@ -2239,7 +2246,7 @@ #ifdef CORRUPTED_PACKETS if (sock == udpSock) { - fprintf (stderr, "garbage Reserved packet discarded.\n"); + LineToConsole ("garbage Reserved packet discarded.\n"); return; } #endif @@ -2263,7 +2270,7 @@ response.type = CP_RESERVED; #ifdef DEBUG - printf ("Sending RSA reserved response\n"); + LineToConsole ("Sending RSA reserved response\n"); #endif } else @@ -2358,7 +2365,7 @@ sendServerPacket ((struct player_spacket *) &response); /* #ifdef DEBUG */ - printf ("RSA verification requested.\n"); + LineToConsole ("RSA verification requested.\n"); /* #endif */ } @@ -2374,7 +2381,7 @@ #ifdef CORRUPTED_PACKETS if (packet->pnum >= MAXPLAYER) { - fprintf (stderr, "handleScan: bad index\n"); + LineToConsole ("handleScan: bad index\n"); return; } #endif @@ -2622,8 +2629,8 @@ UDPDIAG (("Received UDP verification\n")); break; default: - fprintf (stderr, "netrek: Got funny reply (%d) in UDP_REPLY packet\n", - packet->reply); + LineToConsole ("netrek: Got funny reply (%d) in UDP_REPLY packet\n", + packet->reply); break; } } @@ -2637,7 +2644,7 @@ if (udpSock >= 0) { - fprintf (stderr, "netrek: tried to open udpSock twice\n"); + LineToConsole ("netrek: tried to open udpSock twice\n"); return (0); /* pretend we succeeded * (this could be bad) */ } @@ -2708,7 +2715,7 @@ { if ((hp = gethostbyname (serverName)) == NULL) { - printf ("Who is %s?\n", serverName); + LineToConsole ("Who is %s?\n", serverName); terminate (0); } else @@ -2735,7 +2742,7 @@ udpServerPort)); if (connect (udpSock, (const struct sockaddr *) &addr, sizeof (addr)) < 0) { - fprintf (stderr, "Error %d: "); + LineToConsole ("Error %d: ", WSAGetLastError ()); perror ("netrek: unable to connect UDP socket"); printUdpInfo (); /* debug */ return (-1); @@ -2828,7 +2835,7 @@ V_UDPDIAG (("Closing UDP socket\n")); if (udpSock < 0) { - fprintf (stderr, "netrek: tried to close a closed UDP socket\n"); + LineToConsole ("netrek: tried to close a closed UDP socket\n"); return (-1); } shutdown (udpSock, 2); @@ -2880,7 +2887,7 @@ udprefresh (UDP_DROPPED); newseq = (LONG) ntohs (packet->sequence); - /* printf("read %d - ", newseq); */ + /* LineToConsole ("read %d - ", newseq); */ if (((unsigned short) sequence) > 65000 && ((unsigned short) newseq) < 1000) @@ -2957,7 +2964,7 @@ drop_flag = 1; } } - /* printf("newseq %d, sequence %d\n", newseq, sequence); */ + /* LineToConsole ("newseq %d, sequence %d\n", newseq, sequence); */ if (recent_count > UDP_RECENT_INTR) { /* once a minute (at 5 upd/sec), report on how many were dropped */ @@ -2999,7 +3006,7 @@ if (type <= 0 && type > NUM_PACKETS) { - fprintf (stderr, "Attempted to log a bad packet? \n"); + LineToConsole ("Attempted to log a bad packet? \n"); return; } packet_log[type]++; @@ -3016,8 +3023,8 @@ lasttime = this_sec; if (log_packets > 1) { - fprintf (stdout, "%d %d %d\n", this_sec - Start_Time, - data_this_sec, outdata_this_sec); + LineToConsole ("%d %d %d\n", this_sec - Start_Time, + data_this_sec, outdata_this_sec); } if (Start_Time == 0) { @@ -3069,19 +3076,19 @@ Now = time (NULL); - printf ("Packet Logging Summary:\n"); - printf ("Start time: %s ", ctime (&Start_Time)); - printf (" End time: %s Elapsed play time: %3.2f min\n", - ctime (&Now), (float) ((Now - Start_Time) / 60)); - printf ("Maximum CPS in during normal play: %d bytes per sec\n", Max_CPS); - printf ("Standard deviation in: %d\n", - (int) sqrt ((numpl * s2 - sumpl * sumpl) / - (numpl * (numpl - 1)))); - printf ("Maximum CPS out during normal play: %d bytes per sec\n", - Max_CPSout); - printf ("Standard deviation out: %d\n", - (int) sqrt ((numpl * sout2 - sumout * sumout) / - (numpl * (numpl - 1)))); + LineToConsole ("Packet Logging Summary:\n"); + LineToConsole ("Start time: %s ", ctime (&Start_Time)); + LineToConsole (" End time: %s Elapsed play time: %3.2f min\n", + ctime (&Now), (float) ((Now - Start_Time) / 60)); + LineToConsole ("Maximum CPS in during normal play: %d bytes per sec\n", Max_CPS); + LineToConsole ("Standard deviation in: %d\n", + (int) sqrt ((numpl * s2 - sumpl * sumpl) / + (numpl * (numpl - 1)))); + LineToConsole ("Maximum CPS out during normal play: %d bytes per sec\n", + Max_CPSout); + LineToConsole ("Standard deviation out: %d\n", + (int) sqrt ((numpl * sout2 - sumout * sumout) / + (numpl * (numpl - 1)))); #ifdef SHORT_PACKETS /* total_bytes = ALL_BYTES; *//* Hope this works HW */ @@ -3113,10 +3120,10 @@ #endif } - printf ("Total bytes received %d, average CPS: %4.1f\n", - total_bytes, (float) (total_bytes / (Now - Start_Time))); - printf ("Server Packets Summary:\n"); - printf ("Num #Rcvd Size TotlBytes %%Total\n"); + LineToConsole ("Total bytes received %d, average CPS: %4.1f\n", + total_bytes, (float) (total_bytes / (Now - Start_Time))); + LineToConsole ("Server Packets Summary:\n"); + LineToConsole ("Num #Rcvd Size TotlBytes %%Total\n"); for (i = 0; i <= NUM_PACKETS; i++) { @@ -3126,20 +3133,20 @@ else calc_temp = vari_sizes[i]; - printf ("%3d %5d %4d %9d %3.2f\n", - i, packet_log[i], handlers[i].size, calc_temp, - (float) (calc_temp * 100 / total_bytes)); + LineToConsole ("%3d %5d %4d %9d %3.2f\n", + i, packet_log[i], handlers[i].size, calc_temp, + (float) (calc_temp * 100 / total_bytes)); #else calc_temp = handlers[i].size * packet_log[i]; - printf ("%3d %5d %4d %9d %3.2f\n", - i, packet_log[i], handlers[i].size, calc_temp, - (float) (calc_temp * 100 / total_bytes)); + LineToConsole ("%3d %5d %4d %9d %3.2f\n", + i, packet_log[i], handlers[i].size, calc_temp, + (float) (calc_temp * 100 / total_bytes)); #endif } - printf ("Total bytes sent %d, average CPS: %4.1f\n", - outtotal_bytes, (float) (outtotal_bytes / (Now - Start_Time))); - printf ("Client Packets Summary:\n"); - printf ("Num #Sent Size TotlBytes %%Total\n"); + LineToConsole ("Total bytes sent %d, average CPS: %4.1f\n", + outtotal_bytes, (float) (outtotal_bytes / (Now - Start_Time))); + LineToConsole ("Client Packets Summary:\n"); + LineToConsole ("Num #Sent Size TotlBytes %%Total\n"); for (i = 0; i <= NUM_SIZES; i++) { @@ -3148,15 +3155,15 @@ calc_temp = cp_msg_size; else calc_temp = sizes[i] * outpacket_log[i]; - printf ("%3d %5d %4d %9d %3.2f\n", - i, outpacket_log[i], sizes[i], calc_temp, - (float) (calc_temp * 100 / outtotal_bytes)); + LineToConsole ("%3d %5d %4d %9d %3.2f\n", + i, outpacket_log[i], sizes[i], calc_temp, + (float) (calc_temp * 100 / outtotal_bytes)); } #else calc_temp = sizes[i] * outpacket_log[i]; - printf ("%3d %5d %4d %9d %3.2f\n", - i, outpacket_log[i], sizes[i], calc_temp, - (float) (calc_temp * 100 / outtotal_bytes)); + LineToConsole ("%3d %5d %4d %9d %3.2f\n", + i, outpacket_log[i], sizes[i], calc_temp, + (float) (calc_temp * 100 / outtotal_bytes)); } #endif }