Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9974/src Modified Files: cowmain.c local.c playback.c short.c socket.c warning.c winmain.c Log Message: Change from Multithreaded to Multithreaded DLL runtime library, involved adding a few headers, and commenting out the perror() and getpid() function definitions as they seem to be built in now. Also removed libcmt.lib from import libs. Removed unused UPDATE define. Changed WARNTIME and MESSTIME to use tenths of seconds rather than updates/sec, so warning messages don't disappear too fast at higher FPS rates. Moved j->p_explode out of draw if check, so that explosion counter updates even at low update rates. Reworked logic for phaser, torp and plasma fuses. Sets a minimum fuse and updatefuse length so even at low update rates, these weapons draw on screen. Also changed sound logic so that sound events play proper at all update rates. Also fixes a bug where frame could fall outside range of bitmaps, causing errors. Frame is now reset within the bounds of the bitmap definition number of frames. Showed up as a problem at low updates/sec rates. Index: local.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- local.c 25 Feb 2007 08:01:33 -0000 1.59 +++ local.c 26 Feb 2007 06:54:49 -0000 1.60 @@ -56,8 +56,6 @@ static int warpchange = 0; static unsigned int twarpflag = 0; static int cloak_phases = 0; -static int bmp_torpdet_frames = 0; -static int bmp_torp_frames = 0; #endif /* Background Stars Definitions */ @@ -1415,8 +1413,8 @@ clearzone[3][clearcount] = BMP_SHIPEXPL_HEIGHT; } clearcount++; - j->p_explode++; } + j->p_explode++; } /* Now draw his phaser (if it exists) */ @@ -1909,8 +1907,8 @@ if (k->t_status == TEXPLODE) { k->t_fuse--; - bmp_torpdet_frames = BMP_TORPDET_FRAMES * server_ups / 10; frame = k->t_fuse * 10 / server_ups; + if (k->t_fuse <= 0) { k->t_status = TFREE; @@ -1918,13 +1916,11 @@ continue; } - if (k->t_fuse >= bmp_torpdet_frames) - { - k->t_fuse = bmp_torpdet_frames - 1; - } + if (frame >= BMP_TORPDET_FRAMES) + frame = BMP_TORPDET_FRAMES - 1; #ifdef SOUND - if (k->t_fuse == bmp_torpdet_frames - 1) + if (k->t_fuse == (MAX(2, BMP_TORPDET_FRAMES * server_ups / 10) - 1)) { if (newSound) { @@ -1956,7 +1952,6 @@ Play_Sound(TORP_HIT_SOUND); } #endif - if (colorWeapons) { if (myPlayer(j)) @@ -2008,12 +2003,13 @@ { k->t_fuse++; - bmp_torp_frames = BMP_TORP_FRAMES * server_ups / 10; frame = k->t_fuse * 10 / server_ups; - if ((k->t_fuse >= bmp_torp_frames - 1) || (k->t_fuse < 0)) - k->t_fuse = 0; - + if ((frame > BMP_TORP_FRAMES - 1) || (frame < 0)) + { + k->t_fuse = 0; + frame = 0; + } if (myPlayer(j)) torpTeam = 0; else @@ -2178,22 +2174,20 @@ if (pt->pt_status == PTEXPLODE) { pt->pt_fuse--; - bmp_torpdet_frames = BMP_TORPDET_FRAMES * server_ups / 10; + frame = pt->pt_fuse * 10 / server_ups; + if (pt->pt_fuse <= 0) { pt->pt_status = PTFREE; players[pt->pt_owner].p_nplasmatorp--; continue; } - - if (pt->pt_fuse >= bmp_torpdet_frames) - { - pt->pt_fuse = bmp_torpdet_frames - 1; - } + if (frame >= BMP_TORPDET_FRAMES) + frame = BMP_TORPDET_FRAMES - 1; #ifdef SOUND - if (pt->pt_fuse == bmp_torpdet_frames - 1) + if (pt->pt_fuse == (MAX(2, BMP_TORPDET_FRAMES * server_ups / 10) - 1)) { if (newSound) { @@ -2278,12 +2272,13 @@ { pt->pt_fuse++; - bmp_torp_frames = BMP_TORP_FRAMES * server_ups / 10; frame = pt->pt_fuse * 10 / server_ups; - if ((pt->pt_fuse >= bmp_torp_frames - 1) || (pt->pt_fuse < 0)) + if ((frame > BMP_TORP_FRAMES - 1) || (frame < 0)) + { + frame = 0; pt->pt_fuse = 0; - + } if (pt->pt_owner == me->p_no) ptorpTeam = 0; else @@ -2728,7 +2723,7 @@ weaponUpdate = 0; DrawMisc (); - + #ifdef RECORDGAME if (doubleBuffering && !inplayback) W_Mem2Win (localSDB); Index: short.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/short.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- short.c 25 Feb 2007 08:01:34 -0000 1.15 +++ short.c 26 Feb 2007 06:54:49 -0000 1.16 @@ -273,7 +273,9 @@ thetorp = &torps[((unsigned char) *which * 8)]; for (shift = 0, i = 0; i < 8; i++, thetorp++, bitset >>= 1) { - thetorp->t_updateFuse = TORP_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10); if (bitset & 01) { @@ -998,7 +1000,9 @@ for (shift = 0, i = 0; i < 8; thetorp++, *bitset >>= 1, *infobitset >>= 1, i++) { - thetorp->t_updateFuse = TORP_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10); if (*bitset & 01) { @@ -1094,7 +1098,9 @@ thetorp->t_status = status; if (thetorp->t_status == TEXPLODE) { - thetorp->t_fuse = BMP_TORPDET_FRAMES * server_ups / 10; + /* Fuse requires minimum value of 2 to ensure a redraw, fuse decremented + before drawing torp in local.c */ + thetorp->t_fuse = MAX(2, BMP_TORPDET_FRAMES * server_ups / 10); } } } /* if */ @@ -2007,8 +2013,10 @@ phas->sound_phaser = 1; #endif /* normalized fuses */ - phas->ph_updateFuse = PHASER_UPDATE_FUSE * server_ups / 10; - phas->ph_maxfuse = (players[pnum].p_ship.s_phaserfuse * server_ups) / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing phaser in local.c */ + phas->ph_updateFuse = MAX(2, PHASER_UPDATE_FUSE * server_ups / 10); + phas->ph_maxfuse = MAX(1, (players[pnum].p_ship.s_phaserfuse * server_ups) / 10); #ifdef ROTATERACE if (rotate) Index: winmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/winmain.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- winmain.c 23 Feb 2007 13:43:57 -0000 1.4 +++ winmain.c 26 Feb 2007 06:54:50 -0000 1.5 @@ -207,12 +207,13 @@ //***************************************************************************// //Get process ID +/* int getpid () { return (int) GetCurrentProcessId (); } - +*/ //getpwuid() function - does it for real under NT. Just copies the given string... struct passwd * @@ -261,12 +262,13 @@ //A more useful perror(), reports last winsock error as well +/* void perror (const char *str) { LineToConsole ("%s: errno = %d, WSALast = %d\n", str, errno, WSAGetLastError ()); } - +*/ #ifdef NEW_SELECT // ********************************* select ******************************** Index: playback.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/playback.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- playback.c 12 Dec 2006 04:47:08 -0000 1.15 +++ playback.c 26 Feb 2007 06:54:49 -0000 1.16 @@ -19,6 +19,7 @@ #include <ctype.h> #include <setjmp.h> #include <winsock.h> +#include <process.h> #include "Wlib.h" #include "defs.h" Index: warning.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/warning.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- warning.c 11 Jun 2006 09:36:25 -0000 1.10 +++ warning.c 26 Feb 2007 06:54:50 -0000 1.11 @@ -116,7 +116,7 @@ else #endif W_WriteText (warnw, 5, 5, textColor, text, warncount, W_RegularFont); - warntimer = udcounter + WARNTIME; /* set the line to be + warntimer = udcounter + WARNTIME * server_ups / 10; /* set the line to be * cleared */ Index: cowmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- cowmain.c 25 Feb 2007 00:19:00 -0000 1.22 +++ cowmain.c 26 Feb 2007 06:54:49 -0000 1.23 @@ -16,6 +16,7 @@ #include <pwd.h> #include <time.h> #include <winsock.h> +#include <process.h> #include "copyright.h" #include "config.h" Index: socket.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- socket.c 25 Feb 2007 00:19:00 -0000 1.18 +++ socket.c 26 Feb 2007 06:54:49 -0000 1.19 @@ -18,6 +18,7 @@ #include <math.h> #include <errno.h> #include <time.h> +#include <process.h> #include "Wlib.h" #include "defs.h" @@ -1098,7 +1099,9 @@ thetorp->t_x = ntohl (packet->x); thetorp->t_y = ntohl (packet->y); thetorp->t_dir = packet->dir; - thetorp->t_updateFuse = TORP_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10); #ifdef ROTATERACE @@ -1126,7 +1129,9 @@ weaponUpdate = 1; thetorp = &torps[ntohs (packet->tnum)]; - thetorp->t_updateFuse = TORP_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->t_updateFuse = MAX(2, TORP_UPDATE_FUSE * server_ups / 10); if (packet->status == TEXPLODE && thetorp->t_status == TFREE) { @@ -1158,7 +1163,9 @@ thetorp->t_status = packet->status; if (thetorp->t_status == TEXPLODE) { - thetorp->t_fuse = BMP_TORPDET_FRAMES * server_ups / 10; + /* Fuse requires minimum value of 2 to ensure a redraw, fuse decremented + before drawing torp in local.c */ + thetorp->t_fuse = MAX(2, BMP_TORPDET_FRAMES * server_ups / 10); } } } @@ -1612,8 +1619,10 @@ phas->sound_phaser = 1; #endif /* normalized fuses */ - phas->ph_updateFuse = PHASER_UPDATE_FUSE * server_ups / 10; - phas->ph_maxfuse = (players[packet->pnum].p_ship.s_phaserfuse * server_ups) / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing phaser in local.c */ + phas->ph_updateFuse = MAX(2, PHASER_UPDATE_FUSE * server_ups / 10); + phas->ph_maxfuse = MAX(1, (players[packet->pnum].p_ship.s_phaserfuse * server_ups) / 10); #ifdef ROTATERACE if (rotate) @@ -1760,7 +1769,9 @@ weaponUpdate = 1; thetorp = &plasmatorps[ntohs (packet->pnum)]; - thetorp->pt_updateFuse = PLASMA_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->pt_updateFuse = MAX(2, PLASMA_UPDATE_FUSE * server_ups / 10); if (packet->status == PTEXPLODE && thetorp->pt_status == PTFREE) { /* FAT: redundant explosion; don't update p_nplasmatorp */ @@ -1781,7 +1792,9 @@ thetorp->pt_status = packet->status; if (thetorp->pt_status == PTEXPLODE) { - thetorp->pt_fuse = BMP_TORPDET_FRAMES * server_ups / 10; + /* Fuse requires minimum value of 2 to ensure a redraw, fuse decremented + before drawing torp in local.c */ + thetorp->pt_fuse = MAX(2, BMP_TORPDET_FRAMES * server_ups / 10); } } } @@ -1803,7 +1816,9 @@ thetorp = &plasmatorps[ntohs (packet->pnum)]; thetorp->pt_x = ntohl (packet->x); thetorp->pt_y = ntohl (packet->y); - thetorp->pt_updateFuse = PLASMA_UPDATE_FUSE * server_ups / 10; + /* Updatefuse requires minimum value of 2 to ensure a redraw, updateFuse decremented + before drawing torp in local.c */ + thetorp->pt_updateFuse = MAX(2, PLASMA_UPDATE_FUSE * server_ups / 10); #ifdef ROTATERACE if (rotate)