Skip to content

Commit

Permalink
Merge pull request #1072 from turol/const
Browse files Browse the repository at this point in the history
More const correctness
  • Loading branch information
fragglet committed Aug 2, 2018
2 parents f177dcb + ef9843f commit 82ff0b7
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/d_iwad.c
Expand Up @@ -914,7 +914,7 @@ const char *D_SaveGameIWADName(GameMission_t gamemission)
return "unknown.wad"; return "unknown.wad";
} }


char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode) const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
{ {
int i; int i;


Expand All @@ -929,7 +929,7 @@ char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
return "unknown.wad"; return "unknown.wad";
} }


char *D_SuggestGameName(GameMission_t mission, GameMode_t mode) const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
{ {
int i; int i;


Expand Down
8 changes: 4 additions & 4 deletions src/d_iwad.h
Expand Up @@ -33,19 +33,19 @@


typedef struct typedef struct
{ {
char *name; const char *name;
GameMission_t mission; GameMission_t mission;
GameMode_t mode; GameMode_t mode;
char *description; const char *description;
} iwad_t; } iwad_t;


char *D_FindWADByName(const char *filename); char *D_FindWADByName(const char *filename);
char *D_TryFindWADByName(const char *filename); char *D_TryFindWADByName(const char *filename);
char *D_FindIWAD(int mask, GameMission_t *mission); char *D_FindIWAD(int mask, GameMission_t *mission);
const iwad_t **D_FindAllIWADs(int mask); const iwad_t **D_FindAllIWADs(int mask);
const char *D_SaveGameIWADName(GameMission_t gamemission); const char *D_SaveGameIWADName(GameMission_t gamemission);
char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode); const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
char *D_SuggestGameName(GameMission_t mission, GameMode_t mode); const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
void D_CheckCorrectIWAD(GameMission_t mission); void D_CheckCorrectIWAD(GameMission_t mission);


#endif #endif
Expand Down
8 changes: 4 additions & 4 deletions src/doom/d_main.c
Expand Up @@ -709,12 +709,12 @@ static char *GetGameName(char *gamename)
return gamename; return gamename;
} }


static void SetMissionForPackName(char *pack_name) static void SetMissionForPackName(const char *pack_name)
{ {
int i; int i;
static const struct static const struct
{ {
char *name; const char *name;
int mission; int mission;
} packs[] = { } packs[] = {
{ "doom2", doom2 }, { "doom2", doom2 },
Expand Down Expand Up @@ -948,8 +948,8 @@ void PrintDehackedBanners(void)


static struct static struct
{ {
char *description; const char *description;
char *cmdline; const char *cmdline;
GameVersion_t version; GameVersion_t version;
} gameversions[] = { } gameversions[] = {
{"Doom 1.666", "1.666", exe_doom_1_666}, {"Doom 1.666", "1.666", exe_doom_1_666},
Expand Down
2 changes: 1 addition & 1 deletion src/doom/doomstat.c
Expand Up @@ -26,7 +26,7 @@ GameMode_t gamemode = indetermined;
GameMission_t gamemission = doom; GameMission_t gamemission = doom;
GameVersion_t gameversion = exe_final2; GameVersion_t gameversion = exe_final2;
GameVariant_t gamevariant = vanilla; GameVariant_t gamevariant = vanilla;
char *gamedescription; const char *gamedescription;


// Set if homebrew PWAD stuff has been added. // Set if homebrew PWAD stuff has been added.
boolean modifiedgame; boolean modifiedgame;
Expand Down
4 changes: 2 additions & 2 deletions src/doom/doomstat.h
Expand Up @@ -57,7 +57,7 @@ extern GameMode_t gamemode;
extern GameMission_t gamemission; extern GameMission_t gamemission;
extern GameVersion_t gameversion; extern GameVersion_t gameversion;
extern GameVariant_t gamevariant; extern GameVariant_t gamevariant;
extern char *gamedescription; extern const char *gamedescription;


// Convenience macro. // Convenience macro.
// 'gamemission' can be equal to pack_chex or pack_hacx, but these are // 'gamemission' can be equal to pack_chex or pack_hacx, but these are
Expand Down Expand Up @@ -244,7 +244,7 @@ extern wbstartstruct_t wminfo;
// //


// File handling stuff. // File handling stuff.
extern char * savegamedir; extern char *savegamedir;
extern char basedefault[1024]; extern char basedefault[1024];


// if true, load all graphics at level load // if true, load all graphics at level load
Expand Down
6 changes: 3 additions & 3 deletions src/doom/f_finale.c
Expand Up @@ -61,8 +61,8 @@ typedef struct
{ {
GameMission_t mission; GameMission_t mission;
int episode, level; int episode, level;
char *background; const char *background;
char *text; const char *text;
} textscreen_t; } textscreen_t;


static textscreen_t textscreens[] = static textscreen_t textscreens[] =
Expand Down Expand Up @@ -299,7 +299,7 @@ void F_TextWrite (void)
// //
typedef struct typedef struct
{ {
char *name; const char *name;
mobjtype_t type; mobjtype_t type;
} castinfo_t; } castinfo_t;


Expand Down
18 changes: 9 additions & 9 deletions src/doom/g_game.c
Expand Up @@ -2123,7 +2123,7 @@ void G_DeferedPlayDemo(const char *name)


// Generate a string describing a demo version // Generate a string describing a demo version


static char *DemoVersionDescription(int version) static const char *DemoVersionDescription(int version)
{ {
static char resultbuf[16]; static char resultbuf[16];


Expand Down Expand Up @@ -2186,14 +2186,14 @@ void G_DoPlayDemo (void)
} }
else if (demoversion != G_VanillaVersionCode()) else if (demoversion != G_VanillaVersionCode())
{ {
char *message = "Demo is from a different game version!\n" const char *message = "Demo is from a different game version!\n"
"(read %i, should be %i)\n" "(read %i, should be %i)\n"
"\n" "\n"
"*** You may need to upgrade your version " "*** You may need to upgrade your version "
"of Doom to v1.9. ***\n" "of Doom to v1.9. ***\n"
" See: https://www.doomworld.com/classicdoom" " See: https://www.doomworld.com/classicdoom"
"/info/patches.php\n" "/info/patches.php\n"
" This appears to be %s."; " This appears to be %s.";


I_Error(message, demoversion, G_VanillaVersionCode(), I_Error(message, demoversion, G_VanillaVersionCode(),
DemoVersionDescription(demoversion)); DemoVersionDescription(demoversion));
Expand Down
10 changes: 5 additions & 5 deletions src/doom/hu_stuff.c
Expand Up @@ -76,7 +76,7 @@ char *chat_macros[10] =
HUSTR_CHATMACRO9 HUSTR_CHATMACRO9
}; };


char* player_names[] = const char *player_names[] =
{ {
HUSTR_PLRGREEN, HUSTR_PLRGREEN,
HUSTR_PLRINDIGO, HUSTR_PLRINDIGO,
Expand Down Expand Up @@ -110,7 +110,7 @@ static boolean headsupactive = false;
// The actual names can be found in DStrings.h. // 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, HUSTR_E1M1,
Expand Down Expand Up @@ -164,7 +164,7 @@ char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
"NEWLEVEL" "NEWLEVEL"
}; };


char* mapnames_chex[] = // Chex Quest names. const char *mapnames_chex[] = // Chex Quest names.
{ {


HUSTR_E1M1, HUSTR_E1M1,
Expand Down Expand Up @@ -224,7 +224,7 @@ char* mapnames_chex[] = // Chex Quest names.
// the layout in the Vanilla executable, where it is possible to // the layout in the Vanilla executable, where it is possible to
// overflow the end of one array into the next. // overflow the end of one array into the next.


char *mapnames_commercial[] = const char *mapnames_commercial[] =
{ {
// DOOM 2 map names. // DOOM 2 map names.


Expand Down Expand Up @@ -591,7 +591,7 @@ boolean HU_Responder(event_t *ev)
{ {


static char lastmessage[HU_MAXLINELENGTH+1]; static char lastmessage[HU_MAXLINELENGTH+1];
char* macromessage; const char *macromessage;
boolean eatkey = false; boolean eatkey = false;
static boolean altdown = false; static boolean altdown = false;
unsigned char c; unsigned char c;
Expand Down
2 changes: 1 addition & 1 deletion src/doom/info.c
Expand Up @@ -29,7 +29,7 @@


#include "p_mobj.h" #include "p_mobj.h"


char *sprnames[] = { const char *sprnames[] = {
"TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG", "TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG",
"MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2", "MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2",
"PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS", "PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS",
Expand Down
2 changes: 1 addition & 1 deletion src/doom/info.h
Expand Up @@ -1154,7 +1154,7 @@ typedef struct
} state_t; } state_t;


extern state_t states[NUMSTATES]; extern state_t states[NUMSTATES];
extern char *sprnames[]; extern const char *sprnames[];


typedef enum { typedef enum {
MT_PLAYER, MT_PLAYER,
Expand Down
16 changes: 8 additions & 8 deletions src/doom/m_menu.c
Expand Up @@ -167,7 +167,7 @@ short whichSkull; // which skull to draw


// graphic name of skulls // graphic name of skulls
// warning: initializer-string for array of chars is too long // 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 // current menudef
menu_t* currentMenu; menu_t* currentMenu;
Expand Down Expand Up @@ -214,8 +214,8 @@ static void M_DrawSave(void);
static void M_DrawSaveLoadBorder(int x,int y); static void M_DrawSaveLoadBorder(int x,int y);
static void M_SetupNextMenu(menu_t *menudef); static void M_SetupNextMenu(menu_t *menudef);
static void M_DrawThermo(int x,int y,int thermWidth,int thermDot); static void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
static void M_WriteText(int x, int y, char *string); static void M_WriteText(int x, int y, const char *string);
static int M_StringWidth(char *string); static int M_StringWidth(const char *string);
static int M_StringHeight(const char *string); static int M_StringHeight(const char *string);
static void M_StartMessage(const char *string, void *routine, boolean input); static void M_StartMessage(const char *string, void *routine, boolean input);
static void M_ClearMenus (void); static void M_ClearMenus (void);
Expand Down Expand Up @@ -938,8 +938,8 @@ void M_Episode(int choice)
// //
// M_Options // M_Options
// //
static char *detailNames[2] = {"M_GDHIGH","M_GDLOW"}; static const char *detailNames[2] = {"M_GDHIGH","M_GDLOW"};
static char *msgNames[2] = {"M_MSGOFF","M_MSGON"}; static const char *msgNames[2] = {"M_MSGOFF","M_MSGON"};


void M_DrawOptions(void) void M_DrawOptions(void)
{ {
Expand Down Expand Up @@ -1229,7 +1229,7 @@ M_StartMessage
// //
// Find string width from hu_font chars // Find string width from hu_font chars
// //
int M_StringWidth(char* string) int M_StringWidth(const char *string)
{ {
size_t i; size_t i;
int w = 0; int w = 0;
Expand Down Expand Up @@ -1274,10 +1274,10 @@ void
M_WriteText M_WriteText
( int x, ( int x,
int y, int y,
char* string) const char *string)
{ {
int w; int w;
char* ch; const char *ch;
int c; int c;
int cx; int cx;
int cy; int cy;
Expand Down
6 changes: 3 additions & 3 deletions src/doom/r_things.c
Expand Up @@ -168,9 +168,9 @@ R_InstallSpriteLump
// letter/number appended. // letter/number appended.
// The rotation character can be 0 to signify no rotations. // 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 i;
int l; int l;
int frame; int frame;
Expand Down Expand Up @@ -288,7 +288,7 @@ int newvissprite;
// R_InitSprites // R_InitSprites
// Called at program start. // Called at program start.
// //
void R_InitSprites (char** namelist) void R_InitSprites(const char **namelist)
{ {
int i; int i;


Expand Down
2 changes: 1 addition & 1 deletion src/doom/r_things.h
Expand Up @@ -51,7 +51,7 @@ void R_SortVisSprites (void);
void R_AddSprites (sector_t* sec); void R_AddSprites (sector_t* sec);
void R_AddPSprites (void); void R_AddPSprites (void);
void R_DrawSprites (void); void R_DrawSprites (void);
void R_InitSprites (char** namelist); void R_InitSprites(const char **namelist);
void R_ClearSprites (void); void R_ClearSprites (void);
void R_DrawMasked (void); void R_DrawMasked (void);


Expand Down

0 comments on commit 82ff0b7

Please sign in to comment.