ref: 82ff0b70095060015274ae80c8dd66bb55011c26
parent: f177dcbc082f60d3e5e89a30b36a17f3cd04eaca
parent: ef9843f52ce3d058fd30475f98564b34553ecee2
author: Simon Howard <fraggle+github@gmail.com>
date: Thu Aug 2 13:10:57 EDT 2018
Merge pull request #1072 from turol/const More const correctness
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -914,7 +914,7 @@
return "unknown.wad";
}
-char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
+const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
{
int i;
@@ -929,7 +929,7 @@
return "unknown.wad";
}
-char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
+const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
{
int i;
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -33,10 +33,10 @@
typedef struct
{
- char *name;
+ const char *name;
GameMission_t mission;
GameMode_t mode;
- char *description;
+ const char *description;
} iwad_t;
char *D_FindWADByName(const char *filename);
@@ -44,8 +44,8 @@
char *D_FindIWAD(int mask, GameMission_t *mission);
const iwad_t **D_FindAllIWADs(int mask);
const char *D_SaveGameIWADName(GameMission_t gamemission);
-char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
-char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
+const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
+const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
void D_CheckCorrectIWAD(GameMission_t mission);
#endif
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -709,12 +709,12 @@
return gamename;
}
-static void SetMissionForPackName(char *pack_name)
+static void SetMissionForPackName(const char *pack_name)
{
int i;
static const struct
{
- char *name;
+ const char *name;
int mission;
} packs[] = {
{ "doom2", doom2 },
@@ -948,8 +948,8 @@
static struct
{
- char *description;
- char *cmdline;
+ const char *description;
+ const char *cmdline;
GameVersion_t version;
} gameversions[] = {
{"Doom 1.666", "1.666", exe_doom_1_666},
--- a/src/doom/doomstat.c
+++ b/src/doom/doomstat.c
@@ -26,7 +26,7 @@
GameMission_t gamemission = doom;
GameVersion_t gameversion = exe_final2;
GameVariant_t gamevariant = vanilla;
-char *gamedescription;
+const char *gamedescription;
// Set if homebrew PWAD stuff has been added.
boolean modifiedgame;
--- a/src/doom/doomstat.h
+++ b/src/doom/doomstat.h
@@ -57,7 +57,7 @@
extern GameMission_t gamemission;
extern GameVersion_t gameversion;
extern GameVariant_t gamevariant;
-extern char *gamedescription;
+extern const char *gamedescription;
// Convenience macro.
// 'gamemission' can be equal to pack_chex or pack_hacx, but these are
@@ -244,7 +244,7 @@
//
// File handling stuff.
-extern char * savegamedir;
+extern char *savegamedir;
extern char basedefault[1024];
// if true, load all graphics at level load
--- a/src/doom/f_finale.c
+++ b/src/doom/f_finale.c
@@ -61,8 +61,8 @@
{
GameMission_t mission;
int episode, level;
- char *background;
- char *text;
+ const char *background;
+ const char *text;
} textscreen_t;
static textscreen_t textscreens[] =
@@ -299,7 +299,7 @@
//
typedef struct
{
- char *name;
+ const char *name;
mobjtype_t type;
} castinfo_t;
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -2123,7 +2123,7 @@
// Generate a string describing a demo version
-static char *DemoVersionDescription(int version)
+static const char *DemoVersionDescription(int version)
{
static char resultbuf[16];
@@ -2186,14 +2186,14 @@
}
else if (demoversion != G_VanillaVersionCode())
{
- char *message = "Demo is from a different game version!\n"
- "(read %i, should be %i)\n"
- "\n"
- "*** You may need to upgrade your version "
- "of Doom to v1.9. ***\n"
- " See: https://www.doomworld.com/classicdoom"
- "/info/patches.php\n"
- " This appears to be %s.";
+ const char *message = "Demo is from a different game version!\n"
+ "(read %i, should be %i)\n"
+ "\n"
+ "*** You may need to upgrade your version "
+ "of Doom to v1.9. ***\n"
+ " See: https://www.doomworld.com/classicdoom"
+ "/info/patches.php\n"
+ " This appears to be %s.";
I_Error(message, demoversion, G_VanillaVersionCode(),
DemoVersionDescription(demoversion));
--- a/src/doom/hu_stuff.c
+++ b/src/doom/hu_stuff.c
@@ -76,7 +76,7 @@
HUSTR_CHATMACRO9
};
-char* player_names[] =
+const char *player_names[] =
{
HUSTR_PLRGREEN,
HUSTR_PLRINDIGO,
@@ -110,7 +110,7 @@
// The actual names can be found in DStrings.h.
//
-char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
+const char *mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
{
HUSTR_E1M1,
@@ -164,7 +164,7 @@
"NEWLEVEL"
};
-char* mapnames_chex[] = // Chex Quest names.
+const char *mapnames_chex[] = // Chex Quest names.
{
HUSTR_E1M1,
@@ -224,7 +224,7 @@
// the layout in the Vanilla executable, where it is possible to
// overflow the end of one array into the next.
-char *mapnames_commercial[] =
+const char *mapnames_commercial[] =
{
// DOOM 2 map names.
@@ -591,7 +591,7 @@
{
static char lastmessage[HU_MAXLINELENGTH+1];
- char* macromessage;
+ const char *macromessage;
boolean eatkey = false;
static boolean altdown = false;
unsigned char c;
--- a/src/doom/info.c
+++ b/src/doom/info.c
@@ -29,7 +29,7 @@
#include "p_mobj.h"
-char *sprnames[] = {
+const char *sprnames[] = {
"TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG",
"MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2",
"PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS",
--- a/src/doom/info.h
+++ b/src/doom/info.h
@@ -1154,7 +1154,7 @@
} state_t;
extern state_t states[NUMSTATES];
-extern char *sprnames[];
+extern const char *sprnames[];
typedef enum {
MT_PLAYER,
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -167,7 +167,7 @@
// graphic name of skulls
// warning: initializer-string for array of chars is too long
-char *skullName[2] = {"M_SKULL1","M_SKULL2"};
+const char *skullName[2] = {"M_SKULL1","M_SKULL2"};
// current menudef
menu_t* currentMenu;
@@ -214,8 +214,8 @@
static void M_DrawSaveLoadBorder(int x,int y);
static void M_SetupNextMenu(menu_t *menudef);
static void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
-static void M_WriteText(int x, int y, char *string);
-static int M_StringWidth(char *string);
+static void M_WriteText(int x, int y, const char *string);
+static int M_StringWidth(const char *string);
static int M_StringHeight(const char *string);
static void M_StartMessage(const char *string, void *routine, boolean input);
static void M_ClearMenus (void);
@@ -938,8 +938,8 @@
//
// M_Options
//
-static char *detailNames[2] = {"M_GDHIGH","M_GDLOW"};
-static char *msgNames[2] = {"M_MSGOFF","M_MSGON"};
+static const char *detailNames[2] = {"M_GDHIGH","M_GDLOW"};
+static const char *msgNames[2] = {"M_MSGOFF","M_MSGON"};
void M_DrawOptions(void)
{
@@ -1229,7 +1229,7 @@
//
// Find string width from hu_font chars
//
-int M_StringWidth(char* string)
+int M_StringWidth(const char *string)
{
size_t i;
int w = 0;
@@ -1274,10 +1274,10 @@
M_WriteText
( int x,
int y,
- char* string)
+ const char *string)
{
int w;
- char* ch;
+ const char *ch;
int c;
int cx;
int cy;
--- a/src/doom/r_things.c
+++ b/src/doom/r_things.c
@@ -168,9 +168,9 @@
// letter/number appended.
// The rotation character can be 0 to signify no rotations.
//
-void R_InitSpriteDefs (char** namelist)
+void R_InitSpriteDefs(const char **namelist)
{
- char** check;
+ const char **check;
int i;
int l;
int frame;
@@ -288,7 +288,7 @@
// R_InitSprites
// Called at program start.
//
-void R_InitSprites (char** namelist)
+void R_InitSprites(const char **namelist)
{
int i;
--- a/src/doom/r_things.h
+++ b/src/doom/r_things.h
@@ -51,7 +51,7 @@
void R_AddSprites (sector_t* sec);
void R_AddPSprites (void);
void R_DrawSprites (void);
-void R_InitSprites (char** namelist);
+void R_InitSprites(const char **namelist);
void R_ClearSprites (void);
void R_DrawMasked (void);