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;
}
}
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);
#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
#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 */
struct HiScore
{
- char Name[MAX_NAMELEN];
+ char Name[MAX_PLAYER_NAME_LEN + 1];
int Score;
};
#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;
};