Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25543/src

Modified Files:
	cowmain.c data.c enter.c input.c local.c map.c mswindow.c 
	option.c sound.c 
Log Message:
Remove constant hockey_mode() calls with a single check on initial client connect, setting
new global bool playing_hockey.
Minor changes inspired by COW implementation of XP 2006 patches.
Map window, player redraw: cleared up some confusing references to lastUpdate, renamed
it a more fitting lastRedraw.  Still needs testing once server is fixed regarding orbit/stationary
ship position updates.
Inlined SDB_lookup as it gets called more than any other function.
Made music and sound arrays static.

Index: mswindow.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- mswindow.c	27 Feb 2007 08:37:07 -0000	1.43
+++ mswindow.c	28 Feb 2007 07:44:00 -0000	1.44
@@ -5639,7 +5639,7 @@
     return sdb;
 }
 
-SDBUFFER *
+inline SDBUFFER *
 SDB_lookup (W_Window window)
 {
     Window * win;

Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- sound.c	26 Feb 2007 13:20:37 -0000	1.28
+++ sound.c	28 Feb 2007 07:44:01 -0000	1.29
@@ -28,8 +28,8 @@
 #include "audio.h"
 #include "proto.h"
 
-Mix_Chunk *newsounds[NUM_WAVES];
-Mix_Music *newmusic[NUM_MUSIC];
+static Mix_Chunk *newsounds[NUM_WAVES];
+static Mix_Music *newmusic[NUM_MUSIC];
 /* Each sound has a priority which controls what can override what
    Currently these are set as follows:
 

Index: input.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- input.c	26 Feb 2007 07:53:03 -0000	1.23
+++ input.c	28 Feb 2007 07:44:00 -0000	1.24
@@ -2592,7 +2592,7 @@
 Key71 (W_Event * data)
 {
 #ifdef HOCKEY_LINES
-    if (!hockey_mode ())
+    if (!playing_hockey)
         return;
 
     showHockeyLinesMap = !showHockeyLinesMap;
@@ -2613,7 +2613,7 @@
 Key72 (W_Event * data)
 {
 #ifdef HOCKEY_LINES
-    if (!hockey_mode ())
+    if (!playing_hockey)
         return;
 
     showHockeyLinesLocal = !showHockeyLinesLocal;
@@ -3141,12 +3141,11 @@
 
     /* Observers can't move.  Also incorrectly removes the lock flag even though
        you are still locked */
-    if (!(me->p_flags & PFOBSERV))
-    {
-        course = (unsigned char) (getcourse (data->Window, data->x, data->y));
-        set_course (course);
-        me->p_flags &= ~(PFPLOCK | PFPLLOCK);
-    }
+    if (me->p_flags & PFOBSERV) return;
+
+    course = (unsigned char) (getcourse (data->Window, data->x, data->y));
+    set_course (course);
+    me->p_flags &= ~(PFPLOCK | PFPLLOCK);
 }
 
 /******************************************************************************/

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- local.c	27 Feb 2007 10:16:33 -0000	1.62
+++ local.c	28 Feb 2007 07:44:00 -0000	1.63
@@ -1215,7 +1215,7 @@
             }
 #ifdef HOCKEY_LINES
             /* Puck circle */
-            if (puckCircle && hockey_mode ())
+            if (puckCircle && playing_hockey)
             {
             	if (myPlayer(j) || isObsLockPlayer(j))
             	{
@@ -1260,7 +1260,7 @@
 
 #ifdef HOCKEY_LINES
                 /* Do we want to see puck's letter ? Nah. */
-                if (hockey_mode () && 
+                if (playing_hockey && 
                     strcmp(j->p_name, "Puck") == 0 &&
                     strcmp(j->p_login, "Robot") == 0 &&
                     j->p_team == NOBODY &&
@@ -2365,7 +2365,7 @@
 #endif
 
 #ifdef HOCKEY_LINES
-    if (showHockeyLinesLocal && hockey_mode ())
+    if (showHockeyLinesLocal && playing_hockey)
         for (sl = local_hockey_lines + NUM_HOCKEY_LINES - 1;
              sl >= local_hockey_lines; --sl)
         {

Index: enter.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/enter.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- enter.c	27 Feb 2007 08:37:07 -0000	1.6
+++ enter.c	28 Feb 2007 07:44:00 -0000	1.7
@@ -206,30 +206,22 @@
 
 #ifdef HOCKEY_LINES
 /******************************************************************************/
-/***  hockey_mode()                                                         ***/
+/***  check_hockey_mode() - checked on initial entry into game              ***/
 /******************************************************************************/
-int hockey_mode (void)
+void check_hockey_mode (void)
 {
     int i;
-    static int playing_hockey = 0;
-    static int first_run = 1;
 
-    if (first_run)
+    for (i = 0; i < MAXPLAYER; i++)
     {
-        for (i = 0; i < MAXPLAYER; i++)
+        if (strcmp(players[i].p_name, "Puck") == 0 &&
+            strcmp(players[i].p_login, "Robot") == 0 &&
+            players[i].p_team == NOBODY &&
+            players[i].p_ship.s_type == SCOUT)
         {
-            if (strcmp(players[i].p_name, "Puck") == 0 &&
-                strcmp(players[i].p_login, "Robot") == 0 &&
-                players[i].p_team == NOBODY &&
-                players[i].p_ship.s_type == SCOUT)
-            {
-                playing_hockey = 1;
-            }
+            playing_hockey = 1;
         }
-        first_run = 0;
     }
-
-    return playing_hockey;
 }
 
 /******************************************************************************/

Index: option.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- option.c	25 Feb 2007 14:12:10 -0000	1.29
+++ option.c	28 Feb 2007 07:44:01 -0000	1.30
@@ -831,25 +831,25 @@
         {
             // We definitely don't want to be able to
             // change this option on non hockey server
-            if (showHockeyLinesMap && !hockey_mode ())
+            if (showHockeyLinesMap && !playing_hockey)
                 showHockeyLinesMap = 0;
         }
         else if (op->op_option == &showHockeyLinesLocal)
         {
             // same as above
-            if (showHockeyLinesLocal && !hockey_mode ())
+            if (showHockeyLinesLocal && !playing_hockey)
                 showHockeyLinesLocal = 0;
         }
         else if (op->op_option == &showHockeyScore)
         {
             // same as above
-            if (showHockeyScore && !hockey_mode ())
+            if (showHockeyScore && !playing_hockey)
                 showHockeyScore = 0;
         }
         else if (op->op_option == &puckCircle)
         {
             // same as above
-            if (puckCircle && !hockey_mode ())
+            if (puckCircle && !playing_hockey)
                 puckCircle = 0;
         }
 #endif

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- data.c	25 Feb 2007 14:12:10 -0000	1.54
+++ data.c	28 Feb 2007 07:44:00 -0000	1.55
@@ -648,7 +648,7 @@
 struct s_line local_hockey_lines[NUM_HOCKEY_LINES + 1];
 int showHockeyLinesMap = 0;
 struct s_line map_hockey_lines[NUM_HOCKEY_LINES + 1];
-
+int playing_hockey = 0;
 #endif
 
 #ifdef MULTILINE_MACROS

Index: cowmain.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cowmain.c	26 Feb 2007 06:54:49 -0000	1.23
+++ cowmain.c	28 Feb 2007 07:44:00 -0000	1.24
@@ -1077,6 +1077,10 @@
         /* Send request for updatesPerSec.  New servers now support 50 u/s */
         sendUpdatePacket (1000000 / updatesPerSec);
 
+#ifdef HOCKEY_LINES
+        /* Playing hockey? */
+        check_hockey_mode();
+#endif
         isFirstEntry = 0;
     }
 

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- map.c	23 Feb 2007 13:43:56 -0000	1.24
+++ map.c	28 Feb 2007 07:44:00 -0000	1.25
@@ -695,7 +695,6 @@
  */
 {
     register int i;
-    register unsigned char *update;
     register struct player *j;
     register struct planet *l;
     register int dx, dy;
@@ -703,7 +702,7 @@
     static char clearlock = 0;
     static int mclearzone[6][MAXPLAYER];
     static int clearlmark[4];
-    static unsigned char lastUpdate[MAXPLAYER];
+    static unsigned int lastRedraw[MAXPLAYER];
 
     static int viewx = 0, viewy = 0;
     static char clearviewbox = 0;
@@ -744,7 +743,7 @@
 
         for (i = 0; i < MAXPLAYER; i++)
         {
-            lastUpdate[i] = 0;
+            lastRedraw[i] = 0;
             mclearzone[2][i] = 0;
             redrawPlayer[i] = 1;
         }
@@ -786,15 +785,14 @@
         }
 
         /* Erase the ships */
-        for (i = 0, update = lastUpdate; i < MAXPLAYER; i++, update++)
+        for (i = 0; i < MAXPLAYER; i++)
         {
+            /* Erase the player if redrawPlayer[i] is set and there
+               is an active clearzone */
             if (redrawPlayer[i])
             {
-                /* Erase the player if redrawPlayer[i] is set
-                   or lastUpdate allows it. */
                 if (mclearzone[2][i])
                 {
-                    /* XFIX */
                     W_ClearArea (mapw, mclearzone[0][i], mclearzone[1][i],
                                  mclearzone[2][i], mclearzone[3][i]);
                     /* Redraw the hole just left next update */
@@ -802,16 +800,22 @@
                     mclearzone[2][i] = 0;
                 }
                 /* Reset the last redrawn counter */
-                *update = 0;
+                lastRedraw[i] = 0;
             }
-            else if (*update == 10)
+
+            if (lastRedraw[i] == 10)
             {
                 /* Redraw stationary ships every update so that these
                    ships are not hidden by planet updates. */
                 redrawPlayer[i] = 1;
             }
             else
-                ++(*update);
+            {
+            	/* Just increment the counter instead */
+                lastRedraw[i]++;
+            }
+            if (&players[i] == me)
+            LineToConsole("Last redraw %d ", lastRedraw[i]);
         }
     }
 
@@ -842,7 +846,7 @@
     }
 
 #ifdef HOCKEY_LINES
-    if (hockey_mode ())
+    if (playing_hockey)
     {
         /* Draw Hockey Lines */
 	if (showHockeyLinesMap)
@@ -858,7 +862,7 @@
 
     for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++)
     {
-        /* lastUpdate[i] has been set to 0 if redrawall or the ship has
+        /* redrawPlayer[i] has been set to 1 if redrawall or the ship has
          * been erased or a redraw has not taken place for a while.  These
          * decisions are made at the top of the file.             */