rnd-19990315-1-src
authorHolger Schemel <info@artsoft.org>
Mon, 15 Mar 1999 00:38:13 +0000 (01:38 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:33:56 +0000 (10:33 +0200)
src/files.c
src/game.c
src/main.h
src/network.c
src/screens.c

index a7238908437ca22db1bd06af9266af1ce6b4e600..000992012cb38657d255a7f4e9bdd9f6d34644fb 100644 (file)
@@ -827,15 +827,15 @@ void LoadScore(int level_nr)
     fscanf(file, "%d", &highscore[i].Score);
     fgets(line, MAX_LINE_LEN, file);
 
-    if (line[strlen(line)-1] == '\n')
-      line[strlen(line)-1] = '\0';
+    if (line[strlen(line) - 1] == '\n')
+      line[strlen(line) - 1] = '\0';
 
     for (line_ptr = line; *line_ptr; line_ptr++)
     {
       if (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
       {
-       strncpy(highscore[i].Name, line_ptr, MAX_NAMELEN - 1);
-       highscore[i].Name[MAX_NAMELEN - 1] = '\0';
+       strncpy(highscore[i].Name, line_ptr, MAX_PLAYER_NAME_LEN);
+       highscore[i].Name[MAX_PLAYER_NAME_LEN] = '\0';
        break;
       }
     }
@@ -1572,11 +1572,11 @@ void LoadSetup()
     freeSetupFileList(setup_file_list);
 
     /* needed to work around problems with fixed length strings */
-    if (strlen(setup.player_name) >= MAX_NAMELEN)
-      setup.player_name[MAX_NAMELEN - 1] = '\0';
-    else if (strlen(setup.player_name) < MAX_NAMELEN - 1)
+    if (strlen(setup.player_name) > MAX_PLAYER_NAME_LEN)
+      setup.player_name[MAX_PLAYER_NAME_LEN] = '\0';
+    else if (strlen(setup.player_name) < MAX_PLAYER_NAME_LEN)
     {
-      char *new_name = checked_malloc(MAX_NAMELEN);
+      char *new_name = checked_malloc(MAX_PLAYER_NAME_LEN + 1);
 
       strcpy(new_name, setup.player_name);
       free(setup.player_name);
index 48482c90e6f63224a69ad8c888811f974a00aa82..89ed530fcf9ba4d2cc551348dbe359bda6d7f121 100644 (file)
@@ -897,15 +897,16 @@ int NewHiScore()
 #ifdef ONE_PER_NAME
       put_into_list:
 #endif
-      strncpy(highscore[k].Name, setup.player_name, MAX_NAMELEN - 1);
-      highscore[k].Name[MAX_NAMELEN - 1] = '\0';
+      strncpy(highscore[k].Name, setup.player_name, MAX_PLAYER_NAME_LEN);
+      highscore[k].Name[MAX_PLAYER_NAME_LEN] = '\0';
       highscore[k].Score = local_player->score; 
       position = k;
       break;
     }
 
 #ifdef ONE_PER_NAME
-    else if (!strncmp(setup.player_name, highscore[k].Name, MAX_NAMELEN - 1))
+    else if (!strncmp(setup.player_name, highscore[k].Name,
+                     MAX_PLAYER_NAME_LEN))
       break;   /* player already there with a higher score */
 #endif
 
index a625102cc706ac76f1b88198b4b14af8dd878bba..fad880a44de800221ef9bad3ca01a5ac155dd551 100644 (file)
@@ -201,7 +201,7 @@ typedef unsigned char byte;
 #define NUM_PIXMAPS            10
 
 /* boundaries of arrays etc. */
-#define MAX_NAMELEN            (10+1)
+#define MAX_PLAYER_NAME_LEN    10
 #define MAX_LEVEL_NAME_LEN     32
 #define MAX_LEVEL_AUTHOR_LEN   32
 #define MAX_TAPELEN            (1000 * 50)     /* max. time * framerate */
@@ -227,7 +227,7 @@ typedef unsigned char byte;
 
 struct HiScore
 {
-  char Name[MAX_NAMELEN];
+  char Name[MAX_PLAYER_NAME_LEN + 1];
   int Score;
 };
 
index 5d137f0598f3514e1c824c6e40664055cd6a6070..e16c0d9f74abd086023561bea21e0831a87c4fab 100644 (file)
 #include "screens.h"
 #include "misc.h"
 
-#define MAX_PLAYER_NAME_LEN 14
-
 struct NetworkClientPlayerInfo
 {
   byte nr;
-  char name[MAX_PLAYER_NAME_LEN + 2];
+  char name[MAX_PLAYER_NAME_LEN + 1];
   struct NetworkClientPlayerInfo *next;
 };
 
index d494e99a7c1f3ce3f92fc5c687ef7aeb0135523d..ed99fd4052445aab73157b8ad1abce93ea313670 100644 (file)
@@ -763,7 +763,7 @@ void HandleTypeName(int newxpos, KeySym key)
   }
 
   if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) && 
-      xpos < MAX_NAMELEN - 1)
+      xpos < MAX_PLAYER_NAME_LEN)
   {
     char ascii;