Add const to all char * function parameters.

This commit is contained in:
Guus Sliepen 2011-08-24 14:42:59 +02:00
parent 87730b0687
commit 0910cd3db6
28 changed files with 66 additions and 66 deletions

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern object enemy[MAX_ALIENS]; extern object enemy[MAX_ALIENS];
extern object player; extern object player;

View File

@ -38,13 +38,13 @@ extern void addEngine(object *craft);
extern void fireRay(object *attacker); extern void fireRay(object *attacker);
extern void addDebris(int x, int y, int amount); extern void addDebris(int x, int y, int amount);
extern void playSound(int sid); extern void playSound(int sid);
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern object *addCargo(object *owner, int cargoType); extern object *addCargo(object *owner, int cargoType);
extern void addCollectable(float x, float y, int type, int value, int life); extern void addCollectable(float x, float y, int type, int value, int life);
extern void updateMissionRequirements(int type, int id, int value); extern void updateMissionRequirements(int type, int id, int value);
extern void setInfoLine(char *in, int color); extern void setInfoLine(const char *in, int color);
extern void addBullet(object *theWeapon, object *attacker, int y, int dy); extern void addBullet(object *theWeapon, object *attacker, int y, int dy);
extern void showErrorAndExit(int errorId, char *name); extern void showErrorAndExit(int errorId, const char *name);
extern globalEngineVariables engine; extern globalEngineVariables engine;
extern devVariables dev; extern devVariables dev;

View File

@ -56,7 +56,7 @@ void playSound(int sid)
} }
} }
Mix_Chunk *loadSound(char *filename) Mix_Chunk *loadSound(const char *filename)
{ {
Mix_Chunk *chunk; Mix_Chunk *chunk;
@ -70,7 +70,7 @@ Mix_Chunk *loadSound(char *filename)
return chunk; return chunk;
} }
void loadMusic(char *filename) void loadMusic(const char *filename)
{ {
if (Mix_PlayingMusic()) if (Mix_PlayingMusic())
Mix_HaltMusic(); Mix_HaltMusic();

View File

@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "defs.h" #include "defs.h"
#include "structs.h" #include "structs.h"
extern void unpack(char *file, signed char fileType); extern void unpack(const char *file, signed char fileType);
extern void freePackBuffer(); extern void freePackBuffer();
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -35,13 +35,13 @@ extern void updateMissionRequirements(int type, int id, int value);
extern void addCollectable(float x, float y, int type, int value, int life); extern void addCollectable(float x, float y, int type, int value, int life);
extern void addExplosion(float x, float y, int type); extern void addExplosion(float x, float y, int type);
extern void generateShockWave(object *bullet); extern void generateShockWave(object *bullet);
extern void setInfoLine(char *in, int color); extern void setInfoLine(const char *in, int color);
extern void getKillMessage(object *ally); extern void getKillMessage(object *ally);
extern void getMissFireMessage(object *ally); extern void getMissFireMessage(object *ally);
extern void getPlayerHitMessage(object *ally); extern void getPlayerHitMessage(object *ally);
extern void checkMineBulletCollisions(object *bullet); extern void checkMineBulletCollisions(object *bullet);
extern void setKlineAttackMethod(object *theEnemy); extern void setKlineAttackMethod(object *theEnemy);
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern globalEngineVariables engine; extern globalEngineVariables engine;
extern devVariables dev; extern devVariables dev;

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "classes.h" #include "classes.h"
extern void addCollectable(float x, float y, int type, int value, int life); extern void addCollectable(float x, float y, int type, int value, int life);
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern globalEngineVariables engine; extern globalEngineVariables engine;
extern Game currentGame; extern Game currentGame;

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
extern void showErrorAndExit(int errorId, char *name); extern void showErrorAndExit(int errorId, const char *name);
class Collision { class Collision {
@ -333,7 +333,7 @@ class Graphics {
In 16 bit mode this is slow. VERY slow. Don't write directly to a surface In 16 bit mode this is slow. VERY slow. Don't write directly to a surface
that constantly needs updating (eg - the main game screen) that constantly needs updating (eg - the main game screen)
*/ */
int renderString(char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest) int renderString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{ {
SDL_Rect area; SDL_Rect area;
area.x = x; area.x = x;
@ -379,7 +379,7 @@ class Graphics {
return area.y; return area.y;
} }
int drawString(char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest) int drawString(const char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest)
{ {
renderString(in, x, y - 1, FONT_OUTLINE, wrap, dest); renderString(in, x, y - 1, FONT_OUTLINE, wrap, dest);
renderString(in, x, y + 1, FONT_OUTLINE, wrap, dest); renderString(in, x, y + 1, FONT_OUTLINE, wrap, dest);
@ -390,14 +390,14 @@ class Graphics {
return renderString(in, x, y, fontColor, wrap, dest); return renderString(in, x, y, fontColor, wrap, dest);
} }
int drawString(char *in, int x, int y, int fontColor, SDL_Surface *dest) int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest)
{ {
if (x == -1) if (x == -1)
x = (dest->w - (strlen(in) * 9)) / 2; x = (dest->w - (strlen(in) * 9)) / 2;
return drawString(in, x, y, fontColor, 0, dest); return drawString(in, x, y, fontColor, 0, dest);
} }
int drawString(char *in, int x, int y, int fontColor) int drawString(const char *in, int x, int y, int fontColor)
{ {
if (x == -1) if (x == -1)
x = (800 - (strlen(in) * 9)) / 2; x = (800 - (strlen(in) * 9)) / 2;
@ -619,7 +619,7 @@ class Graphics {
return newImage; return newImage;
} }
SDL_Surface *textSurface(char *inString, int color) SDL_Surface *textSurface(const char *inString, int color)
{ {
SDL_Surface *surface = createSurface(strlen(inString) * 9, 16); SDL_Surface *surface = createSurface(strlen(inString) * 9, 16);
@ -628,7 +628,7 @@ class Graphics {
return setTransparent(surface); return setTransparent(surface);
} }
void textSurface(int index, char *inString, int x, int y, int fontColor) void textSurface(int index, const char *inString, int x, int y, int fontColor)
{ {
strcpy(textShape[index].text, inString); strcpy(textShape[index].text, inString);
textShape[index].x = x; textShape[index].x = x;
@ -654,7 +654,7 @@ class Graphics {
return surface; return surface;
} }
void createMessageBox(SDL_Surface *face, char *message, signed char transparent) void createMessageBox(SDL_Surface *face, const char *message, signed char transparent)
{ {
if (messageBox != NULL) if (messageBox != NULL)
{ {

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "classes.h" #include "classes.h"
extern void updateMissionRequirements(int type, int id, int value); extern void updateMissionRequirements(int type, int id, int value);
extern void setInfoLine(char *in, int color); extern void setInfoLine(const char *in, int color);
extern object *addCargo(object *owner, int cargoType); extern object *addCargo(object *owner, int cargoType);
extern void addExplosion(float x, float y, int type); extern void addExplosion(float x, float y, int type);
extern void playSound(int sid); extern void playSound(int sid);

View File

@ -29,8 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern int getFace(char *face); extern int getFace(const char *face);
extern globalEngineVariables engine; extern globalEngineVariables engine;
extern Game currentGame; extern Game currentGame;

View File

@ -55,7 +55,7 @@ void compareLastKeyInputs()
{engine.cheatCredits = 1; memset(lastKeyEvents, ' ', 25);} {engine.cheatCredits = 1; memset(lastKeyEvents, ' ', 25);}
} }
void addKeyEvent(char *keyName) void addKeyEvent(const char *keyName)
{ {
if (strlen(keyName) > 1) if (strlen(keyName) > 1)
return; return;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics.h" #include "graphics.h"
SDL_Surface *loadImage(char *filename) SDL_Surface *loadImage(const char *filename)
{ {
SDL_Surface *image, *newImage; SDL_Surface *image, *newImage;

View File

@ -29,8 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern void unpack(char *file, signed char fileType); extern void unpack(const char *file, signed char fileType);
extern void showErrorAndExit(int errorId, char *name); extern void showErrorAndExit(int errorId, const char *name);
extern Star star[200]; extern Star star[200];
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -48,7 +48,7 @@ Something went wrong. This stops the game, present the error message and
prompts the user to press space or ctrl to exit the game. This is unlikely to prompts the user to press space or ctrl to exit the game. This is unlikely to
be seen by people unless something really stoopid happens! be seen by people unless something really stoopid happens!
*/ */
void showErrorAndExit(int errorId, char *name) void showErrorAndExit(int errorId, const char *name)
{ {
graphics.clearScreen(graphics.black); graphics.clearScreen(graphics.black);

View File

@ -40,8 +40,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void freeSound(); extern void freeSound();
extern void resetLists(); extern void resetLists();
extern void getPlayerInput(); extern void getPlayerInput();
extern void drawString(char *in, int x, int y, int fontColor); extern void drawString(const char *in, int x, int y, int fontColor);
extern SDL_Surface *loadImage(char *filename); extern SDL_Surface *loadImage(const char *filename);
extern globalEngineVariables engine; extern globalEngineVariables engine;
extern Game currentGame; extern Game currentGame;

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern SDL_Surface *loadImage(char *filename); extern SDL_Surface *loadImage(const char *filename);
extern void doStarfield(); extern void doStarfield();
extern void getPlayerInput(); extern void getPlayerInput();
extern void showShop(); extern void showShop();
@ -38,15 +38,15 @@ extern void initShop();
extern int initSaveSlots(); extern int initSaveSlots();
extern int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot); extern int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot);
extern void saveGame(int slot); extern void saveGame(int slot);
extern void loadMusic(char *filename); extern void loadMusic(const char *filename);
extern void loadBackground(char *filename); extern void loadBackground(const char *filename);
extern void createCommsSurface(SDL_Surface *comms); extern void createCommsSurface(SDL_Surface *comms);
extern void updateCommsSurface(SDL_Surface *comms); extern void updateCommsSurface(SDL_Surface *comms);
extern void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot); extern void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot);
extern void checkForBossMission(); extern void checkForBossMission();
extern void doComms(SDL_Surface *comms); extern void doComms(SDL_Surface *comms);
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern int getFace(char *face); extern int getFace(const char *face);
extern void flushInput(); extern void flushInput();
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -146,9 +146,9 @@ void getKillMessage(object *ally)
setRadioMessage(faceToUse, in, 0); setRadioMessage(faceToUse, in, 0);
} }
char *getKlineInsult() const char *getKlineInsult()
{ {
static char insult[][40] = { static const char insult[][40] = {
"Pathetic", "How very disappointing...", "Heroic. And stupid", "Fool", "And now you're nothing but a DEAD hero" "Pathetic", "How very disappointing...", "Heroic. And stupid", "Fool", "And now you're nothing but a DEAD hero"
}; };

View File

@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "defs.h" #include "defs.h"
#include "structs.h" #include "structs.h"
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
char killMessage[10][50]; char killMessage[10][50];
char deathMessage[6][50]; char deathMessage[6][50];

View File

@ -41,7 +41,7 @@ string and colors. It will set the information to the first free infoline
it finds (top to bottom). If it doesn't find any free ones, it will push it finds (top to bottom). If it doesn't find any free ones, it will push
all the other info lines down one and add itself to the top. all the other info lines down one and add itself to the top.
*/ */
void setInfoLine(char *in, int color) void setInfoLine(const char *in, int color)
{ {
int index = -1; int index = -1;
@ -70,7 +70,7 @@ Sets a radio message that appears at the top of the screen. Used for
script events, etc. We send a message priority too, since we don't want script events, etc. We send a message priority too, since we don't want
Phoebe or Ursula's banter to interrupt an important message Phoebe or Ursula's banter to interrupt an important message
*/ */
void setRadioMessage(signed char face, char *in, int priority) void setRadioMessage(signed char face, const char *in, int priority)
{ {
if ((graphics.textShape[3].life > 0) && (priority == 0)) if ((graphics.textShape[3].life > 0) && (priority == 0))
return; return;
@ -400,7 +400,7 @@ void doInfo()
} }
} }
int getFace(char *face) int getFace(const char *face)
{ {
for (int i = 0 ; i < 7 ; i++) for (int i = 0 ; i < 7 ; i++)
{ {

View File

@ -29,16 +29,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern SDL_Surface *loadImage(char *file_name); extern SDL_Surface *loadImage(const char *file_name);
extern void playRandomTrack(); extern void playRandomTrack();
extern void getPlayerInput(); extern void getPlayerInput();
extern void setInfoLine(char *in, int color); extern void setInfoLine(const char *in, int color);
extern void loadGameGraphics(); extern void loadGameGraphics();
extern void killAllAliens(); extern void killAllAliens();
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern void syncScriptEvents(); extern void syncScriptEvents();
extern void loadMusic(char *filename); extern void loadMusic(const char *filename);
extern void setTarget(int index); extern void setTarget(int index);
extern void flushInput(); extern void flushInput();

View File

@ -33,10 +33,10 @@ extern void fireBullet(object *attacker, int weaponType);
extern void addExplosion(float x, float y, int type); extern void addExplosion(float x, float y, int type);
extern void playSound(int sid); extern void playSound(int sid);
extern void addEngine(object *craft); extern void addEngine(object *craft);
extern void addKeyEvent(char *keyName); extern void addKeyEvent(const char *keyName);
extern void addDebris(int x, int y, int amount); extern void addDebris(int x, int y, int amount);
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern void setInfoLine(char *in, int color); extern void setInfoLine(const char *in, int color);
extern void getPlayerDeathMessage(); extern void getPlayerDeathMessage();
extern void playSound(int sid); extern void playSound(int sid);
extern void setTarget(int index); extern void setTarget(int index);

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "resources.h" #include "resources.h"
void loadBackground(char *filename) void loadBackground(const char *filename)
{ {
if (graphics.background != NULL) if (graphics.background != NULL)
{ {

View File

@ -29,10 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern void unpack(char *file, signed char fileType); extern void unpack(const char *file, signed char fileType);
extern SDL_Surface *loadImage(char *filename); extern SDL_Surface *loadImage(const char *filename);
extern Mix_Chunk *loadSound(char *filename); extern Mix_Chunk *loadSound(const char *filename);
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern void setAlienShapes(); extern void setAlienShapes();
extern void setWeaponShapes(); extern void setWeaponShapes();
extern void loadGameGraphics(); extern void loadGameGraphics();

View File

@ -32,14 +32,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void doStarfield(); extern void doStarfield();
extern void getPlayerInput(); extern void getPlayerInput();
extern void loadGameGraphics(); extern void loadGameGraphics();
extern void loadBackground(char *filename); extern void loadBackground(const char *filename);
extern void setRadioMessage(signed char face, char *in, int priority); extern void setRadioMessage(signed char face, const char *in, int priority);
extern void doExplosions(); extern void doExplosions();
extern void addEngine(object *craft); extern void addEngine(object *craft);
extern void doExplosions(); extern void doExplosions();
extern void resetLists(); extern void resetLists();
extern int getFace(char *face); extern int getFace(const char *face);
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern void flushInput(); extern void flushInput();
extern Game currentGame; extern Game currentGame;

View File

@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern object player; extern object player;
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -29,9 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern SDL_Surface *loadImage(char *filename); extern SDL_Surface *loadImage(const char *filename);
extern void unpack(char *file); extern void unpack(const char *file);
extern void loadMusic(char *filename); extern void loadMusic(const char *filename);
extern void doStarfield(); extern void doStarfield();
extern void doExplosions(); extern void doExplosions();
extern void addEngine(object *craft); extern void addEngine(object *craft);
@ -41,9 +41,9 @@ extern signed char loadGame(int slot);
extern int initSaveSlots(); extern int initSaveSlots();
extern void newGame(); extern void newGame();
extern void loadGameGraphics(); extern void loadGameGraphics();
extern void loadBackground(char *filename); extern void loadBackground(const char *filename);
extern void doCredits(); extern void doCredits();
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern void flushInput(); extern void flushInput();
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Searches the pak file for the required data. When Searches the pak file for the required data. When
it is found, the data is read into a character buffer. it is found, the data is read into a character buffer.
*/ */
void unpack(char *file, signed char fileType) void unpack(const char *file, signed char fileType)
{ {
unsigned char *packBuffer; unsigned char *packBuffer;
char packFilename[60]; char packFilename[60];
@ -105,7 +105,7 @@ void unpack(char *file, signed char fileType)
Search the data package for the required file. Search the data package for the required file.
When it is found, return the location. When it is found, return the location.
*/ */
int locateDataInPak(char *file, signed char required) int locateDataInPak(const char *file, signed char required)
{ {
//printf("Looking for %s...", file); //printf("Looking for %s...", file);

View File

@ -30,6 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "defs.h" #include "defs.h"
#include "structs.h" #include "structs.h"
extern void showErrorAndExit(int errorId, char *name); extern void showErrorAndExit(int errorId, const char *name);
extern globalEngineVariables engine; extern globalEngineVariables engine;

View File

@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h" #include "structs.h"
#include "classes.h" #include "classes.h"
extern int locateDataInPak(char *file, signed char required); extern int locateDataInPak(const char *file, signed char required);
extern Graphics graphics; extern Graphics graphics;
extern object weapon[MAX_WEAPONS]; extern object weapon[MAX_WEAPONS];