Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6983/src Modified Files: dashboard.c local.c newwin.c sound.c winsndlib.c Log Message: Best guess solution to deal with observers and observees orbitting a repair planet. Reimplemented select() on login screen, but put it in combination with sleep(). This reduces CPU usage and keeps the desirable things about using select, such as constant updated player list. Minor fix to observer draw logic in local.c Fix to volume setting check so it doesn't get called every time a sound is played (using old sound). Removed some completed/fixed bugs from Stas's todo list. Index: dashboard.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/dashboard.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- dashboard.c 21 May 2006 09:56:38 -0000 1.8 +++ dashboard.c 29 May 2006 23:59:53 -0000 1.9 @@ -855,6 +855,7 @@ int repair_time (void) { + int obs = 0; int shieldtime = 0; int hulltime = 0; int shieldneeded, hullneeded; @@ -862,7 +863,10 @@ struct player *plr; if ((me->p_flags & (PFPLOCK | PFOBSERV)) == (PFPLOCK | PFOBSERV)) + { plr = players + me->p_playerl; + obs = 1; + } else plr = me; @@ -875,9 +879,12 @@ if (me->p_flags & PFORBIT) { /* Damn server doesn't send us p_planet info, have to calculate it ourselves! */ + /* And since observers don't get war flags, assume that if ship is orbiting a repair + planet in repair mode, the planet is friendly - best we can do until server + sends us more info */ me->p_planet = get_closest_planet(me->p_x, me->p_y); if ((planets[me->p_planet].pl_flags & PLREPAIR) - &&(!(planets[me->p_planet].pl_owner & (plr->p_swar | plr->p_hostile)))) + &&(obs || !(planets[me->p_planet].pl_owner & (plr->p_swar | plr->p_hostile)))) me->p_subshield += me->p_ship.s_repair * 4; if (me->p_flags & PFDOCK) me->p_subshield += me->p_ship.s_repair * 6; @@ -894,9 +901,12 @@ if (me->p_flags & PFORBIT) { /* Damn server doesn't send us p_planet info, have to calculate it ourselves! */ + /* And since observers don't get war flags, assume that if ship is orbiting a repair + planet in repair mode, the planet is friendly - best we can do until server + sends us more info */ me->p_planet = get_closest_planet(me->p_x, me->p_y); if ((planets[me->p_planet].pl_flags & PLREPAIR) - && (!(planets[me->p_planet].pl_owner & (plr->p_swar | plr->p_hostile)))) + && (obs || !(planets[me->p_planet].pl_owner & (plr->p_swar | plr->p_hostile)))) me->p_subdamage += me->p_ship.s_repair * 2; if (me->p_flags & PFDOCK) me->p_subdamage += me->p_ship.s_repair * 3; Index: sound.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- sound.c 29 May 2006 00:18:09 -0000 1.13 +++ sound.c 29 May 2006 23:59:53 -0000 1.14 @@ -202,6 +202,8 @@ { sound_init = 1; sound_toggle = 1; + /* See if volume is adjustable */ + CheckVolumeSettings (); } strcpy (sound_prefix, sounddir); Index: newwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- newwin.c 28 May 2006 23:05:12 -0000 1.32 +++ newwin.c 29 May 2006 23:59:53 -0000 1.33 @@ -1394,12 +1394,31 @@ while (!W_EventsPending ()) { time_t elapsed; + fd_set rfds; + struct timeval tv; me->p_ghostbuster = 0; + /* Since we don't have a socket to check on Win32 + for windowing system events, we set the timeout to zero and + effectively poll. Yes, I could do the correct thing + and call WaitForMultipleObjects() etc. but I don't feel like it */ + tv.tv_sec = 0; + tv.tv_usec = 0; + FD_ZERO (&rfds); + FD_SET (sock, &rfds); + if (udpSock >= 0) + FD_SET (udpSock, &rfds); /* Select() causes infinite CPU usage, can't use WaitForMultipleObjects due to UI working on same thread (no blocking), so a simple Sleep is the best solution. */ Sleep(10); + select (32, &rfds, 0, 0, &tv); /* hmm, 32 might be too + * small */ + if (FD_ISSET (sock, &rfds) || + (udpSock >= 0 && FD_ISSET (udpSock, &rfds))) + { + readFromServer (&rfds); + } elapsed = time (0) - startTime; if (elapsed > (time_t)(autoQuit)) { Index: local.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- local.c 29 May 2006 02:41:35 -0000 1.35 +++ local.c 29 May 2006 23:59:53 -0000 1.36 @@ -2538,7 +2538,7 @@ /* Keep redrawing for double buffered observers who get set out of normal gameplay bounds, whether due to locking onto an ineligible planet, or observing a player who dies - otherwise screen doesn't refresh*/ - if (me->p_x < 0 || me->p_x >= GWIDTH && !(doubleBuffering && (me->p_flags & PFOBSERV))) + if ((me->p_x < 0 || me->p_x >= GWIDTH) && !(doubleBuffering && (me->p_flags & PFOBSERV))) return; DrawPlanets (); Index: winsndlib.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/winsndlib.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- winsndlib.c 29 May 2006 00:18:09 -0000 1.4 +++ winsndlib.c 29 May 2006 23:59:53 -0000 1.5 @@ -359,8 +359,6 @@ #endif waveOutPrepareHeader (hw, &snd->hdr, sizeof (WAVEHDR)); waveOutWrite (hw, &snd->hdr, sizeof (WAVEHDR)); - - CheckVolumeSettings(); return 0; } return -1;