Commit 14c715ef authored by Steven Fuller's avatar Steven Fuller

made code -Wwrite-strings clean.

parent 2577c478
Wolfenstein 3D for Linux - http://www.icculus.org/wolf3d/
------------------------
This is an in-progress port of the id Software MS-DOS game, Wolfenstein 3D,
to the GNU/Linux operating system.
Save game and configuration file formats are not yet "solid" (files created
with an older version may not work with a new binary), but they probably
......@@ -22,6 +27,6 @@ Thanks:
* Chuck Mason
* And everyone who has emailed me about this code! Thanks!
-----
--
Steven Fuller
relnev@icculus.org
......@@ -14,7 +14,8 @@ typedef struct
=============================================================================
*/
word RLEWtag;
static word RLEWtag;
int mapon;
word *mapsegs[MAPPLANES];
......@@ -49,7 +50,7 @@ static int audiohandle = -1; /* handle to AUDIOT */
=============================================================================
*/
static void CA_CannotOpen(char *string)
static void CA_CannotOpen(const char *string)
{
char str[30];
......@@ -69,7 +70,7 @@ static void CA_CannotOpen(char *string)
==========================
*/
boolean CA_WriteFile(char *filename, void *ptr, long length)
boolean CA_WriteFile(const char *filename, const void *ptr, long length)
{
ssize_t l;
int handle;
......@@ -79,7 +80,7 @@ boolean CA_WriteFile(char *filename, void *ptr, long length)
if (handle == -1)
return false;
l = WriteBytes(handle, (byte *)ptr, length);
l = WriteBytes(handle, (const byte *)ptr, length);
if (l == -1) {
perror("CA_FarWrite");
return false;
......@@ -106,7 +107,7 @@ boolean CA_WriteFile(char *filename, void *ptr, long length)
==========================
*/
boolean CA_LoadFile(char *filename, memptr *ptr)
boolean CA_LoadFile(const char *filename, memptr *ptr)
{
int handle;
ssize_t l;
......@@ -154,15 +155,16 @@ boolean CA_LoadFile(char *filename, memptr *ptr)
*/
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
void CAL_HuffExpand(const byte *source, byte *dest, long length,
const huffnode *htable)
{
huffnode *headptr;
huffnode *nodeon;
const huffnode *headptr;
const huffnode *nodeon;
byte mask = 0x01;
word path;
byte *endoff = dest + length;
nodeon = headptr = htable + 254;
nodeon = headptr = htable + 254;
do {
if (*source & mask)
......@@ -198,11 +200,12 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
#define NEARTAG 0xa7
#define FARTAG 0xa8
void CAL_CarmackExpand(byte *source, word *dest, word length)
void CAL_CarmackExpand(const byte *source, word *dest, word length)
{
unsigned int offset;
word *copyptr, *outptr;
byte chhigh, chlow, *inptr;
byte chhigh, chlow;
const byte *inptr;
length /= 2;
......@@ -262,7 +265,7 @@ void CAL_CarmackExpand(byte *source, word *dest, word length)
======================
*/
void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
void CA_RLEWexpand(const word *source, word *dest, long length, word rlewtag)
{
word value, count, i;
word *end = dest + length / 2;
......@@ -271,10 +274,10 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
do {
value = *source++;
if (value != rlewtag)
if (value != rlewtag) {
/* uncompressed */
*dest++ = value;
else {
} else {
/* compressed string */
count = *source++;
......@@ -580,7 +583,7 @@ void CA_LoadAllSounds()
======================
*/
static void CAL_ExpandGrChunk(int chunk, byte *source)
static void CAL_ExpandGrChunk(int chunk, const byte *source)
{
int tilecount = 0, i;
long expanded;
......
......@@ -27,10 +27,8 @@ extern char extension[5];
/* ======================================================================== */
boolean CA_LoadFile(char *filename, memptr *ptr);
boolean CA_WriteFile(char *filename, void *ptr, long length);
void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag);
boolean CA_LoadFile(const char *filename, memptr *ptr);
boolean CA_WriteFile(const char *filename, const void *ptr, long length);
void CA_Startup();
void CA_Shutdown();
......
......@@ -79,8 +79,8 @@ typedef struct {
extern const byte gamepal[];
int MS_CheckParm(char *string);
void Quit(char *error);
int MS_CheckParm(const char *string);
void Quit(const char *error);
#define TickBase 70 /* 70Hz per tick */
......
......@@ -61,7 +61,7 @@ void US_Shutdown()
// supported.
//
///////////////////////////////////////////////////////////////////////////
void US_Print(char *str)
void US_Print(const char *str)
{
char c, *se, *s, *sz = strdup(str);
word w, h;
......@@ -115,7 +115,7 @@ void US_PrintUnsigned(longword n)
// USL_PrintInCenter() - Prints a string in the center of the given rect
//
///////////////////////////////////////////////////////////////////////////
void USL_PrintInCenter(char *s, Rect r)
void USL_PrintInCenter(const char *s, Rect r)
{
word w, h, rw, rh;
......@@ -133,7 +133,7 @@ void USL_PrintInCenter(char *s, Rect r)
// US_PrintCentered() - Prints a string centered in the current window.
//
///////////////////////////////////////////////////////////////////////////
void US_PrintCentered(char *s)
void US_PrintCentered(const char *s)
{
Rect r;
......@@ -151,7 +151,7 @@ void US_PrintCentered(char *s)
// advances to the next line. Newlines are not supported.
//
///////////////////////////////////////////////////////////////////////////
void US_CPrintLine(char *s)
void US_CPrintLine(const char *s)
{
word w, h;
......@@ -171,7 +171,7 @@ void US_CPrintLine(char *s)
// supported.
//
///////////////////////////////////////////////////////////////////////////
void US_CPrint(char *str)
void US_CPrint(const char *str)
{
/* Functions like to pass a string constant */
......@@ -251,7 +251,7 @@ void US_DrawWindow(word x,word y,word w,word h)
// USL_XORICursor() - XORs the I-bar text cursor. Used by US_LineInput()
//
///////////////////////////////////////////////////////////////////////////
static void USL_XORICursor(int x, int y, char *s, word cursor)
static void USL_XORICursor(int x, int y, const char *s, word cursor)
{
static boolean status;
char buf[MaxString];
......@@ -285,7 +285,7 @@ static void USL_XORICursor(int x, int y, char *s, word cursor)
// returned
//
///////////////////////////////////////////////////////////////////////////
boolean US_LineInput(int x,int y,char *buf,char *def,boolean escok,
boolean US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
int maxchars,int maxwidth)
{
boolean redraw, cursorvis, cursormoved, done, result = true;
......
......@@ -30,15 +30,15 @@ void US_Startup(),
US_InitRndT(boolean randomize),
US_DrawWindow(word x,word y,word w,word h),
US_ClearWindow(void),
US_PrintCentered(char *s),
US_CPrint(char *s),
US_CPrintLine(char *s),
US_Print(char *s),
US_PrintCentered(const char *s),
US_CPrint(const char *s),
US_CPrintLine(const char *s),
US_Print(const char *s),
US_PrintUnsigned(longword n);
boolean US_LineInput(int x,int y,char *buf,char *def,boolean escok,
boolean US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
int maxchars,int maxwidth);
int US_RndT();
void USL_PrintInCenter(char *s,Rect r);
void USL_PrintInCenter(const char *s,Rect r);
#endif
......@@ -199,7 +199,7 @@ height is a word
256 byte widths
data
*/
void VW_DrawPropString(char *string)
void VW_DrawPropString(const char *string)
{
byte *font;
int width, step, height, x, xs, y;
......@@ -227,7 +227,7 @@ void VW_DrawPropString(char *string)
}
}
void VW_MeasurePropString(char *string, word *width, word *height)
void VW_MeasurePropString(const char *string, word *width, word *height)
{
int w, mw;
byte *font = grsegs[STARTFONT+fontnumber];
......
......@@ -29,9 +29,9 @@ extern boolean screenfaded;
#define VW_WaitVBL VL_WaitVBL
#define VW_FadeIn() VL_FadeIn(0,255,gamepal,30);
#define VW_FadeOut() VL_FadeOut(0,255,0,0,0,30);
void VW_MeasurePropString(char *string, word *width, word *height);
void VW_MeasurePropString(const char *string, word *width, word *height);
void VW_DrawPropString(char *string);
void VW_DrawPropString(const char *string);
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn(int start, int end, const byte *palette, int steps);
......
......@@ -160,7 +160,7 @@ static void put_dos2ansi(byte attrib)
printf ("%c[%d;25;%dm%c[%dm", 27, intens, fore, 27, back);
}
void DisplayTextSplash(byte *text, int l)
void DisplayTextSplash(const byte *text, int l)
{
int i, x;
......@@ -207,7 +207,7 @@ uint32_t SwapInt32L(uint32_t i)
/* ** */
int OpenWrite(char *fn)
int OpenWrite(const char *fn)
{
int fp;
......@@ -215,7 +215,7 @@ int OpenWrite(char *fn)
return fp;
}
int OpenWriteAppend(char *fn)
int OpenWriteAppend(const char *fn)
{
int fp;
......@@ -257,13 +257,13 @@ int WriteInt32(int fp, int32_t d)
return write(fp, &b, 4) / 4;
}
int WriteBytes(int fp, byte *d, int len)
int WriteBytes(int fp, const byte *d, int len)
{
return write(fp, d, len);
}
int OpenRead(char *fn)
int OpenRead(const char *fn)
{
int fp;
......
......@@ -4,8 +4,8 @@
extern int _argc;
extern char **_argv;
void SavePCX256ToFile(unsigned char *buf, int width, int height, unsigned char *pal, char *name);
void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
void SavePCX256ToFile(const unsigned char *buf, int width, int height, const unsigned char *pal, const char *name);
void SavePCXRGBToFile(const unsigned char *buf, int width, int height, const char *name);
void set_TimeCount(unsigned long t);
unsigned long get_TimeCount();
......@@ -23,8 +23,8 @@ char *ultoa(unsigned long value, char *string, int radix);
uint16_t SwapInt16L(uint16_t i);
uint32_t SwapInt32L(uint32_t i);
extern int OpenWrite(char *fn);
extern int OpenWriteAppend(char *fn);
extern int OpenWrite(const char *fn);
extern int OpenWriteAppend(const char *fn);
extern void CloseWrite(int fp);
extern int WriteSeek(int fp, int offset, int whence);
......@@ -33,9 +33,9 @@ extern int WritePos(int fp);
extern int WriteInt8(int fp, int8_t d);
extern int WriteInt16(int fp, int16_t d);
extern int WriteInt32(int fp, int32_t d);
extern int WriteBytes(int fp, byte *d, int len);
extern int WriteBytes(int fp, const byte *d, int len);
extern int OpenRead(char *fn);
extern int OpenRead(const char *fn);
extern void CloseRead(int fp);
extern int ReadSeek(int fp, int offset, int whence);
......
......@@ -161,7 +161,7 @@ extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
IN_Ack();
extern boolean IN_UserInput(longword delay);
extern char *IN_GetScanName(ScanCode);
extern const char *IN_GetScanName(ScanCode);
byte IN_MouseButtons();
byte IN_JoyButtons();
......
......@@ -14,7 +14,7 @@ byte *gfxbuf = NULL;
==========================
*/
void Quit(char *error)
void Quit(const char *error)
{
memptr screen = NULL;
......
......@@ -25,7 +25,7 @@ void DisplayTextSplash(byte *text);
==========================
*/
void Quit(char *error)
void Quit(const char *error)
{
memptr screen = NULL;
......
......@@ -19,7 +19,7 @@ void DisplayTextSplash(byte *text);
==========================
*/
void Quit(char *error)
void Quit(const char *error)
{
memptr screen = NULL;
......
......@@ -499,9 +499,9 @@ int main(int argc, char *argv[])
==========================
*/
void DisplayTextSplash(byte *text, int l);
void DisplayTextSplash(const byte *text, int l);
void Quit(char *error)
void Quit(const char *error)
{
memptr screen = NULL;
int l = 0;
......
......@@ -493,7 +493,6 @@ typedef enum {
nodir
} dirtype;
#define NUMENEMIES 22
typedef enum {
en_guard,
......@@ -520,15 +519,6 @@ typedef enum {
en_death
} enemy_t;
typedef struct statestruct
{
boolean rotate;
int shapenum; /* a shapenum of -1 means get from ob->temp1 */
int tictime;
void (*think)(), (*action)();
int next; /* stateenum */
} statetype;
//---------------------
//
// trivial actor structure
......@@ -595,6 +585,15 @@ typedef struct objstruct
struct objstruct *next,*prev;
} objtype;
typedef struct statestruct
{
boolean rotate;
int shapenum; /* a shapenum of -1 means get from ob->temp1 */
int tictime;
void (*think)(objtype *ob);
void (*action)(objtype *ob);
int next; /* stateenum */
} statetype;
#define NUMBUTTONS 8
enum {
......@@ -700,9 +699,9 @@ void NewGame(int difficulty,int episode);
void NewViewSize(int width);
void ShowViewSize(int width);
int LoadTheGame(char *fn, int x, int y);
int SaveTheGame(char *fn, char *tag, int x, int y);
int ReadSaveTag(char *fn, char *tag);
int LoadTheGame(const char *fn, int x, int y);
int SaveTheGame(const char *fn, const char *tag, int x, int y);
int ReadSaveTag(const char *fn, const char *tag);
void ShutdownId();
int WriteConfig();
......@@ -735,7 +734,7 @@ void DrawPlayScreen (void);
void GameLoop (void);
void ClearMemory (void);
void PlayDemo(int demonumber);
int PlayDemoFromFile(char *demoname);
int PlayDemoFromFile(const char *demoname);
void RecordDemo();
void DrawHighScores();
void DrawPlayBorder();
......
......@@ -17,7 +17,7 @@ boolean spearflag;
/* ELEVATOR BACK MAPS - REMEMBER (-1)!! */
#ifndef SPEAR
static int ElevatorBackTo[]={ 1, 1, 7, 3, 5, 3};
static const int ElevatorBackTo[]={ 1, 1, 7, 3, 5, 3};
#endif
//===========================================================================
......@@ -841,7 +841,7 @@ void PlayDemo(int demonumber)
ClearMemory();
}
int PlayDemoFromFile(char *demoname)
int PlayDemoFromFile(const char *demoname)
{
int length;
......
......@@ -269,9 +269,9 @@ void PG13()
//==========================================================================
void Write(int x,int y,char *string)
void Write(int x,int y,const char *string)
{
int alpha[]={L_NUM0PIC,L_NUM1PIC,L_NUM2PIC,L_NUM3PIC,L_NUM4PIC,L_NUM5PIC,
const int alpha[]={L_NUM0PIC,L_NUM1PIC,L_NUM2PIC,L_NUM3PIC,L_NUM4PIC,L_NUM5PIC,
L_NUM6PIC,L_NUM7PIC,L_NUM8PIC,L_NUM9PIC,L_COLONPIC,0,0,0,0,0,0,L_APIC,L_BPIC,
L_CPIC,L_DPIC,L_EPIC,L_FPIC,L_GPIC,L_HPIC,L_IPIC,L_JPIC,L_KPIC,
L_LPIC,L_MPIC,L_NPIC,L_OPIC,L_PPIC,L_QPIC,L_RPIC,L_SPIC,L_TPIC,
......@@ -320,7 +320,7 @@ void Write(int x,int y,char *string)
break;
default:
VWB_DrawPic(nx,ny,alpha[(int)ch]);
VWB_DrawPic(nx,ny,alpha[(unsigned char)ch]);
}
nx+=16;
}
......@@ -333,7 +333,7 @@ void Write(int x,int y,char *string)
void BJ_Breathe()
{
static int which=0,max=10;
int pics[2]={L_GUYPIC,L_GUY2PIC};
const int pics[2]={L_GUYPIC,L_GUY2PIC};
if (get_TimeCount() > max)
{
......@@ -380,7 +380,7 @@ void LevelCompleted()
char tempstr[10];
long bonus,timeleft=0;
times parTimes[]=
const times parTimes[]=
{
#ifndef SPEAR
//
......
......@@ -331,7 +331,7 @@ configend:
return 0;
}
int SaveTheGame(char *fn, char *tag, int dx, int dy)
int SaveTheGame(const char *fn, const char *tag, int dx, int dy)
{
objtype *ob;
int fd, i, x, y;
......@@ -508,7 +508,7 @@ int SaveTheGame(char *fn, char *tag, int dx, int dy)
return 0;
}
int ReadSaveTag(char *fn, char *tag)
int ReadSaveTag(const char *fn, const char *tag)
{
char buf[8];
int fd;
......@@ -556,7 +556,7 @@ rstfail:
return -1;
}
int LoadTheGame(char *fn, int dx, int dy)
int LoadTheGame(const char *fn, int dx, int dy)
{
char buf[8];
int fd, i, x, y, id;
......@@ -805,7 +805,7 @@ loadfail:
=================
*/
int MS_CheckParm(char *check)
int MS_CheckParm(const char *check)
{
int i;
char *parm;
......
......@@ -17,7 +17,7 @@ void CP_ReadThis();
#define STARTITEM newgame
#endif
static char endStrings[9][80]=
static const char endStrings[9][80]=
{
ENDSTR1,
ENDSTR2,
......@@ -146,8 +146,8 @@ CusMenu[]=
};
static int color_hlite[] = { DEACTIVE, HIGHLIGHT, READHCOLOR, 0x67 };
static int color_norml[] = { DEACTIVE, TEXTCOLOR, READCOLOR, 0x6b };
static const int color_hlite[] = { DEACTIVE, HIGHLIGHT, READHCOLOR, 0x67 };
static const int color_norml[] = { DEACTIVE, TEXTCOLOR, READCOLOR, 0x6b };
#ifndef SPEAR
static int EpisodeSelect[6] = { 1 };
......@@ -192,7 +192,7 @@ static struct {
{ sc_None, "?" }
};
char *IN_GetScanName(ScanCode scan)
const char *IN_GetScanName(ScanCode scan)
{
int i;
......@@ -204,7 +204,7 @@ char *IN_GetScanName(ScanCode scan)
#else
static char
static const char
*ScanNames[] = // Scan code names with single chars
{
"?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",
......@@ -231,7 +231,7 @@ static char
"Down","Left","Right",""
};
char *IN_GetScanName(ScanCode scan)
const char *IN_GetScanName(ScanCode scan)
{
char **p;
ScanCode *s;
......@@ -240,7 +240,7 @@ char *IN_GetScanName(ScanCode scan)
if (*s == scan)
return *p;
return ScanNames[(int)scan];
return ScanNames[(unsigned char)scan];
}
#endif
......@@ -3064,7 +3064,7 @@ void ReadAnyControl(ControlInfo *ci)
// DRAW DIALOG AND CONFIRM YES OR NO TO QUESTION
//
////////////////////////////////////////////////////////////////////
int Confirm(char *string)
int Confirm(const char *string)
{
int xit=0,x,y,tick=0,whichsnd[2]={ESCPRESSEDSND,SHOOTSND};
......@@ -3120,7 +3120,7 @@ int Confirm(char *string)
// PRINT A MESSAGE IN A WINDOW
//
////////////////////////////////////////////////////////////////////
void Message(char *string)
void Message(const char *string)
{
word h=0, mw=0;
......
......@@ -126,8 +126,8 @@ void TicDelay(int count);
void CacheLump(int lumpstart,int lumpend);
void UnCacheLump(int lumpstart,int lumpend);
void StartCPMusic(int song);
int Confirm(char *string);
void Message(char *string);
int Confirm(const char *string);
void Message(const char *string);
void CheckPause(void);
void ShootSnd(void);
void FreeMusic(void);
......@@ -220,7 +220,7 @@ typedef struct {
extern LRstruct LevelRatios[];
void Write(int x,int y,char *string);
void Write(int x,int y,const char *string);
int GetYorN(int x,int y,int pic);
#endif
......@@ -46,14 +46,14 @@ TEXT FORMATTING COMMANDS
=============================================================================
*/
int pagenum, numpages;
static int pagenum, numpages;
unsigned leftmargin[TEXTROWS], rightmargin[TEXTROWS];
char *text;
unsigned rowon;
static unsigned leftmargin[TEXTROWS], rightmargin[TEXTROWS];
static const char *text;
static unsigned rowon;
int picx, picy, picnum, picdelay;
boolean layoutdone;
static int picx, picy, picnum, picdelay;
static boolean layoutdone;
/* ======================================================================== */
......@@ -526,7 +526,7 @@ void BackPage()
*/
void CacheLayoutGraphics()
{
char *bombpoint, *textstart;
const char *bombpoint, *textstart;
char ch;
textstart = text;
......@@ -577,7 +577,7 @@ void CacheLayoutGraphics()
=====================
*/
void ShowArticle(char *article)
void ShowArticle(const char *article)
{
unsigned oldfontnumber;
boolean newpage, firstpage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment