diff --git a/engine/backend/dc/driver_ronin.h b/engine/backend/dc/driver_ronin.h index a578fcc0c07..993ce06555d 100644 --- a/engine/backend/dc/driver_ronin.h +++ b/engine/backend/dc/driver_ronin.h @@ -97,7 +97,7 @@ public: void prepareSmushFrame(int width, int height, byte *bitmap); void drawSmushFrame(int offsetX, int offsetY); - char *getVideoDeviceName(); + const char *getVideoDeviceName(); const ControlDescriptor *listControls(); int getNumControls(); diff --git a/engine/backend/dc/driver_ronin_gfx.cpp b/engine/backend/dc/driver_ronin_gfx.cpp index 0023bf10580..15a2b963f5a 100644 --- a/engine/backend/dc/driver_ronin_gfx.cpp +++ b/engine/backend/dc/driver_ronin_gfx.cpp @@ -604,7 +604,7 @@ void DriverRonin::drawSmushFrame(int offsetX, int offsetY) _polyCount++; } -char *DriverRonin::getVideoDeviceName() +const char *DriverRonin::getVideoDeviceName() { return "Dreamcast PowerVR Video Device"; } diff --git a/engine/backend/driver.h b/engine/backend/driver.h index 06af5b0df9e..77e4a998251 100644 --- a/engine/backend/driver.h +++ b/engine/backend/driver.h @@ -124,7 +124,7 @@ public: virtual void prepareSmushFrame(int width, int height, byte *bitmap) = 0; virtual void drawSmushFrame(int offsetX, int offsetY) = 0; - virtual char *getVideoDeviceName() = 0; + virtual const char *getVideoDeviceName() = 0; /** @name Events and Time */ //@{ @@ -192,7 +192,7 @@ public: * */ struct ControlDescriptor { - char *name; + const char *name; int key; }; diff --git a/engine/backend/sdl/driver_sdl.cpp b/engine/backend/sdl/driver_sdl.cpp index 694995c6448..33f90296d8d 100644 --- a/engine/backend/sdl/driver_sdl.cpp +++ b/engine/backend/sdl/driver_sdl.cpp @@ -317,7 +317,7 @@ void DriverSDL::init() { #endif } -char *DriverSDL::getVideoDeviceName() { +const char *DriverSDL::getVideoDeviceName() { return "SDL Video Device"; } diff --git a/engine/backend/sdl/driver_sdl.h b/engine/backend/sdl/driver_sdl.h index 20daad3757e..4930e1a8664 100644 --- a/engine/backend/sdl/driver_sdl.h +++ b/engine/backend/sdl/driver_sdl.h @@ -54,7 +54,7 @@ public: void setupIcon(); - char *getVideoDeviceName(); + const char *getVideoDeviceName(); const ControlDescriptor *listControls(); int getNumControls(); diff --git a/engine/costume.cpp b/engine/costume.cpp index 9c41d25db59..41e0aebd446 100644 --- a/engine/costume.cpp +++ b/engine/costume.cpp @@ -954,7 +954,7 @@ void Costume::stopChores() { _chores[i].stop(); } -int Costume::isChoring(char *name, bool excludeLooping) { +int Costume::isChoring(const char *name, bool excludeLooping) { for (int i = 0; i < _numChores; i++) { if (!strcmp(_chores[i]._name, name) && _chores[i]._playing && !(excludeLooping && _chores[i]._looping)) return i; diff --git a/engine/costume.h b/engine/costume.h index 5cef3e2c490..7571b866ded 100644 --- a/engine/costume.h +++ b/engine/costume.h @@ -54,7 +54,7 @@ public: Model::HierNode *getModelNodes(); void setColormap(char *map); void stopChores(); - int isChoring(char *name, bool excludeLooping); + int isChoring(const char *name, bool excludeLooping); int isChoring(int num, bool excludeLooping); int isChoring(bool excludeLooping); diff --git a/engine/engine.h b/engine/engine.h index 2129c3a880a..95fd6d0b22f 100644 --- a/engine/engine.h +++ b/engine/engine.h @@ -174,7 +174,7 @@ public: bool _savegameLoadRequest; bool _savegameSaveRequest; - char *_savegameFileName; + const char *_savegameFileName; SaveGame *_savedState; Engine(); diff --git a/engine/lua.cpp b/engine/lua.cpp index 3b2670210a5..0dbaf1e4568 100644 --- a/engine/lua.cpp +++ b/engine/lua.cpp @@ -81,8 +81,8 @@ extern DIR *g_searchFile; #define strmatch(src, dst) (strlen(src) == strlen(dst) && strcmp(src, dst) == 0) #define DEBUG_FUNCTION() debugFunction("Function", __FUNCTION__) -static void debugFunction(char *debugMessage, const char *funcName); -static void stubWarning(char *funcName); +static void debugFunction(const char *debugMessage, const char *funcName); +static void stubWarning(const char *funcName); static inline bool isObject(int num) { lua_Object param = lua_getparam(num); @@ -222,7 +222,7 @@ static inline void pushbool(bool val) { lua_pushnil(); } -static Costume *get_costume(Actor *a, int param, char *called_from) { +static Costume *get_costume(Actor *a, int param, const char *called_from) { Costume *result; if (lua_isnil(lua_getparam(param))) { result = a->currentCostume(); @@ -239,7 +239,7 @@ static Costume *get_costume(Actor *a, int param, char *called_from) { // Lua interface to bundle_dofile static void new_dofile() { - char *fname_str = luaL_check_string(1); + const char *fname_str = luaL_check_string(1); bundle_dofile(fname_str); } @@ -278,9 +278,9 @@ static void PrintWarning() { } static void FunctionName() { - char *name; + const char *name; char buf[256]; - char *filename; + const char *filename; int line; DEBUG_FUNCTION(); @@ -321,7 +321,7 @@ static void FunctionName() { // File functions static void CheckForFile() { - char *filename = luaL_check_string(1); + const char *filename = luaL_check_string(1); DEBUG_FUNCTION(); pushbool(g_resourceloader->fileExists(filename)); @@ -359,7 +359,7 @@ static void GetColorComponents() { // Registry functions static void ReadRegistryValue() { - char *key; + const char *key; const char *val; DEBUG_FUNCTION(); @@ -369,8 +369,8 @@ static void ReadRegistryValue() { } static void WriteRegistryValue() { - char *key; - char *val; + const char *key; + const char *val; DEBUG_FUNCTION(); key = luaL_check_string(1); @@ -420,7 +420,7 @@ static void GetCameraActor() { } static void SetSayLineDefaults() { - char *key_text = NULL; + const char *key_text = NULL; lua_Object table_obj; lua_Object key = LUA_NOOBJECT; @@ -892,7 +892,7 @@ static void SetActorWalkDominate() { } static void SetActorColormap() { - char *mapname; + const char *mapname; CMap *_cmap; Actor *act; @@ -1467,7 +1467,7 @@ static void SetActorShadowPlane() { DEBUG_FUNCTION(); Actor *act = check_actor(1); - char *name = lua_getstring(lua_getparam(2)); + const char *name = lua_getstring(lua_getparam(2)); act->setShadowPlane(name); } @@ -1476,7 +1476,7 @@ static void AddShadowPlane() { DEBUG_FUNCTION(); Actor *act = check_actor(1); - char *name = lua_getstring(lua_getparam(2)); + const char *name = lua_getstring(lua_getparam(2)); act->addShadowPlane(name); } @@ -1534,7 +1534,7 @@ std::string parseMsgText(const char *msg, char *msgId) { static void TextFileGetLine() { char textBuf[512]; textBuf[0] = 0; - char *filename; + const char *filename; FILE *file; DEBUG_FUNCTION(); @@ -1555,7 +1555,7 @@ static void TextFileGetLine() { static void TextFileGetLineCount() { char textBuf[512]; - char *filename; + const char *filename; FILE *file; DEBUG_FUNCTION(); @@ -1592,8 +1592,8 @@ static void TextFileGetLineCount() { // Localization function static void LocalizeString() { - char msgId[32], buf[640], *str; - char *result; + char msgId[32], buf[640]; + const char *str, *result; DEBUG_FUNCTION(); str = luaL_check_string(1); @@ -1607,7 +1607,7 @@ static void LocalizeString() { } else { result = str; } - lua_pushstring(const_cast(result)); + lua_pushstring(result); } static void SayLine() { @@ -1623,7 +1623,7 @@ static void SayLine() { if (!lua_isnil(param2)) { do { if (lua_isstring(param2)) { - char *tmpstr = lua_getstring(param2); + const char *tmpstr = lua_getstring(param2); msg = parseMsgText(tmpstr, msgId); } else if (lua_isnumber(param2)) { pan = 64; @@ -1774,7 +1774,7 @@ static void MakeSectorActive(void) { numSectors = g_engine->currScene()->getSectorCount(); if (lua_isstring(sectorName)) { - char *name = luaL_check_string(1); + const char *name = luaL_check_string(1); for (i = 0; i < numSectors; i++) { Sector *sector = g_engine->currScene()->getSectorBase(i); @@ -1906,7 +1906,7 @@ enum ImuseParam { static void ImStartSound() { int priority, group; - char *soundName; + const char *soundName; DEBUG_FUNCTION(); soundName = luaL_check_string(1); @@ -1930,7 +1930,7 @@ static void ImStartSound() { } static void ImStopSound() { - char *soundName; + const char *soundName; DEBUG_FUNCTION(); soundName = luaL_check_string(1); @@ -1953,7 +1953,7 @@ static void ImResume() { } static void ImSetVoiceEffect() { - char *effectName; + const char *effectName; DEBUG_FUNCTION(); effectName = luaL_check_string(1); @@ -1993,7 +1993,7 @@ static void ImGetSfxVol() { static void ImSetParam() { int param, value; - char *soundName; + const char *soundName; DEBUG_FUNCTION(); soundName = luaL_check_string(1); @@ -2014,7 +2014,7 @@ static void ImSetParam() { } void ImGetParam() { - char *soundName; + const char *soundName; int param; DEBUG_FUNCTION(); @@ -2036,7 +2036,7 @@ void ImGetParam() { static void ImFadeParam() { int opcode, value, duration; - char *soundName; + const char *soundName; DEBUG_FUNCTION(); soundName = luaL_check_string(1); @@ -2093,7 +2093,7 @@ static void SetSoundPosition() { g_engine->currScene()->getSoundParameters(&minVolume, &maxVolume); } - char *soundName = lua_getstring(lua_getresult(1)); + const char *soundName = lua_getstring(lua_getresult(1)); if (isActor(lua_getparam(2))) { Actor *act = check_actor(2); @@ -2197,7 +2197,7 @@ static void luaFileFindNext() { } static void luaFileFindFirst() { - char *path, *extension; + const char *path, *extension; lua_Object pathObj; DEBUG_FUNCTION(); @@ -2291,7 +2291,7 @@ static void killBitmapPrimitives(Bitmap *bitmap) } static void GetImage() { - char *bitmapName; + const char *bitmapName; DEBUG_FUNCTION(); bitmapName = luaL_check_string(1); @@ -2326,7 +2326,7 @@ static void BlastImage() { } void getTextObjectParams(TextObject *textObject, lua_Object table_obj) { - char *key_text = NULL; + const char *key_text = NULL; lua_Object key = LUA_NOOBJECT; DEBUG_FUNCTION(); @@ -2481,7 +2481,7 @@ static void SetTextSpeed() { static void MakeTextObject() { TextObject *textObject = new TextObject(); lua_Object tableObj; - char *line; + const char *line; DEBUG_FUNCTION(); line = lua_getstring(lua_getparam(1)); @@ -2538,7 +2538,7 @@ static void BlastText() { DEBUG_FUNCTION(); TextObject *textObject = new TextObject(); lua_Object tableObj; - char *line; + const char *line; DEBUG_FUNCTION(); line = lua_getstring(lua_getparam(1)); @@ -2894,7 +2894,7 @@ static void GetDiskFreeSpace() { static void NewObjectState() { ObjectState *state = NULL; ObjectState::Position pos; - char *bitmap, *zbitmap; + const char *bitmap, *zbitmap; bool visible; int setupID; @@ -2986,7 +2986,8 @@ static void ScreenShot() { */ static void GetSaveGameImage() { int width = 250, height = 188; - char *filename, *data; + const char *filename; + char *data; Bitmap *screenshot; int dataSize; @@ -3013,7 +3014,7 @@ static void SubmitSaveGameData() { lua_Object table, table2; SaveGame *savedState; int count = 0; - char *str; + const char *str; printf("SubmitSaveGameData() started.\n"); DEBUG_FUNCTION(); @@ -3042,7 +3043,7 @@ static void SubmitSaveGameData() { static void GetSaveGameData() { lua_Object result; - char *filename; + const char *filename; int dataSize; printf("GetSaveGameData() started.\n"); @@ -3127,7 +3128,7 @@ static void LockFont() { DEBUG_FUNCTION(); param1 = lua_getparam(1); if (lua_isstring(param1)) { - char *fontName = lua_getstring(param1); + const char *fontName = lua_getstring(param1); Font *result = g_resourceloader->loadFont(fontName); if (result) { result->luaRef(); @@ -3243,7 +3244,7 @@ static void LoadBundle() { * generate warnings about missing functions when the debug flag * is set to "Stub", warnings, or everything. */ -static void debugFunction(char *debugMessage, const char *funcName) { +static void debugFunction(const char *debugMessage, const char *funcName) { bool stubFn = strcmp(debugMessage, "WARNING: Stub function") == 0; FILE *output; @@ -3289,7 +3290,7 @@ static void debugFunction(char *debugMessage, const char *funcName) { } // Stub function for builtin functions not yet implemented -static void stubWarning(char *funcName) { +static void stubWarning(const char *funcName) { // If the user doesn't want these debug messages then don't print them if (debugLevel != DEBUG_WARN && debugLevel != DEBUG_STUB && debugLevel != DEBUG_FUNC && debugLevel != DEBUG_ALL) return; @@ -3454,7 +3455,7 @@ static void dummyHandler() { // Entries in the system table static struct { - char *name; + const char *name; int key; } system_defaults[] = { { "frameTime", 0 }, @@ -3891,7 +3892,7 @@ int bundle_dofile(const char *filename) { return result; } -lua_Object getTableFunction(lua_Object table, char *name) { +lua_Object getTableFunction(lua_Object table, const char *name) { lua_pushobject(table); lua_pushstring(const_cast(name)); lua_Object handler = lua_gettable(); @@ -3917,8 +3918,8 @@ lua_Object getTableFunction(lua_Object table, char *name) { return handler; } -lua_Object getTableValue(lua_Object table, char *name) { - char *key_text = NULL; +lua_Object getTableValue(lua_Object table, const char *name) { + const char *key_text = NULL; lua_Object key = LUA_NOOBJECT; if (!lua_istable(table)) { @@ -3978,14 +3979,14 @@ lua_Object getIndexedTableValue(lua_Object table, int index) { return lua_getresult(2); } -void setTableValue(lua_Object table, char *name, int newvalue) { +void setTableValue(lua_Object table, const char *name, int newvalue) { lua_pushobject(table); lua_pushstring(name); lua_pushnumber(newvalue); lua_settable(); } -void setTableValue(lua_Object table, char *name, lua_Object newvalue) { +void setTableValue(lua_Object table, const char *name, lua_Object newvalue) { lua_pushobject(table); lua_pushstring(name); if (newvalue == 0) @@ -4019,5 +4020,5 @@ Vector3d tableToVector(lua_Object table) { lua_Object getEventHandler(const char *name) { lua_Object system_table = lua_getglobal("system"); - return getTableFunction(system_table, (char *)name); + return getTableFunction(system_table, name); } diff --git a/engine/lua.h b/engine/lua.h index 6f01622b2e8..f68c4562c09 100644 --- a/engine/lua.h +++ b/engine/lua.h @@ -50,17 +50,17 @@ void setMovieTime(float movieTime); lua_Object getEventHandler(const char *name); // set the value for a table item -void setTableValue(lua_Object table, char *name, int newvalue); -void setTableValue(lua_Object table, char *name, lua_Object newvalue); +void setTableValue(lua_Object table, const char *name, int newvalue); +void setTableValue(lua_Object table, const char *name, lua_Object newvalue); // get the value of a table item -lua_Object getTableValue(lua_Object table, char *name); +lua_Object getTableValue(lua_Object table, const char *name); lua_Object getIndexedTableValue(lua_Object table, int index); // make a Vector3d object from coordinate table values Vector3d tableToVector(lua_Object table); // get a function stored in a table -lua_Object getTableFunction(lua_Object table, char *name); +lua_Object getTableFunction(lua_Object table, const char *name); #endif diff --git a/engine/lua/lapi.cpp b/engine/lua/lapi.cpp index 286d31326c5..261bbc8a4b6 100644 --- a/engine/lua/lapi.cpp +++ b/engine/lua/lapi.cpp @@ -136,13 +136,13 @@ int lua_callfunction (lua_Object function) } -lua_Object lua_gettagmethod (int tag, char *event) +lua_Object lua_gettagmethod (int tag, const char *event) { return put_luaObject(luaT_gettagmethod(tag, event)); } -lua_Object lua_settagmethod (int tag, char *event) +lua_Object lua_settagmethod (int tag, const char *event) { checkCparams(1); luaT_settagmethod(tag, event, L->stack.top-1); @@ -208,7 +208,7 @@ lua_Object lua_createtable (void) } -lua_Object lua_getglobal (char *name) +lua_Object lua_getglobal (const char *name) { luaD_checkstack(2); /* may need that to call T.M. */ luaV_getglobal(luaS_new(name)); @@ -216,14 +216,14 @@ lua_Object lua_getglobal (char *name) } -lua_Object lua_rawgetglobal (char *name) +lua_Object lua_rawgetglobal (const char *name) { TaggedString *ts = luaS_new(name); return put_luaObject(&ts->u.s.globalval); } -void lua_setglobal (char *name) +void lua_setglobal (const char *name) { checkCparams(1); luaD_checkstack(2); /* may need that to call T.M. */ @@ -231,7 +231,7 @@ void lua_setglobal (char *name) } -void lua_rawsetglobal (char *name) +void lua_rawsetglobal (const char *name) { TaggedString *ts = luaS_new(name); checkCparams(1); @@ -285,7 +285,7 @@ double lua_getnumber (lua_Object object) else return (nvalue(Address(object))); } -char *lua_getstring (lua_Object object) +const char *lua_getstring (lua_Object object) { luaC_checkGC(); /* "tostring" may create a new string */ if (object == LUA_NOOBJECT || tostring(Address(object))) @@ -329,7 +329,7 @@ void lua_pushnumber (double n) incr_top; } -void lua_pushlstring (char *s, long len) +void lua_pushlstring (const char *s, long len) { tsvalue(L->stack.top) = luaS_newlstr(s, len); ttype(L->stack.top) = LUA_T_STRING; @@ -337,7 +337,7 @@ void lua_pushlstring (char *s, long len) luaC_checkGC(); } -void lua_pushstring (char *s) +void lua_pushstring (const char *s) { if (s == NULL) lua_pushnil(); @@ -508,7 +508,7 @@ int lua_setlocal (lua_Function func, int local_number) } -void lua_funcinfo (lua_Object func, char **filename, int *linedefined) +void lua_funcinfo (lua_Object func, const char **filename, int *linedefined) { if (!lua_isfunction(func)) lua_error("API - `funcinfo' called with a non-function value"); @@ -532,7 +532,7 @@ static int checkfunc (TObject *o) } -char *lua_getobjname (lua_Object o, char **name) +const char *lua_getobjname (lua_Object o, const char **name) { /* try to find a name for given function */ set_normalized(L->stack.top, Address(o)); /* to be accessed by "checkfunc */ if ((*name = luaT_travtagmethods(checkfunc)) != NULL) diff --git a/engine/lua/lauxlib.cpp b/engine/lua/lauxlib.cpp index 08be69eb279..42066eec7d6 100644 --- a/engine/lua/lauxlib.cpp +++ b/engine/lua/lauxlib.cpp @@ -20,7 +20,7 @@ #include "lmem.h" -int luaL_findstring (char *name, char *list[]) { +int luaL_findstring (const char *name, const char *list[]) { int i; for (i=0; list[i]; i++) if (strcmp(list[i], name) == 0) @@ -28,9 +28,9 @@ int luaL_findstring (char *name, char *list[]) { return -1; /* name not found */ } -void luaL_argerror (int numarg, char *extramsg) +void luaL_argerror (int numarg, const char *extramsg) { - char *funcname; + const char *funcname; lua_getobjname(lua_stackedfunction(0), &funcname); if (funcname == NULL) funcname = "???"; @@ -41,7 +41,7 @@ void luaL_argerror (int numarg, char *extramsg) numarg, funcname, extramsg); } -char *luaL_check_lstr (int numArg, long *len) +const char *luaL_check_lstr (int numArg, long *len) { lua_Object o = lua_getparam(numArg); luaL_arg_check(lua_isstring(o), numArg, "string expected"); @@ -49,7 +49,7 @@ char *luaL_check_lstr (int numArg, long *len) return lua_getstring(o); } -char *luaL_opt_lstr (int numArg, char *def, long *len) +const char *luaL_opt_lstr (int numArg, const char *def, long *len) { return (lua_getparam(numArg) == LUA_NOOBJECT) ? def : luaL_check_lstr(numArg, len); @@ -120,7 +120,7 @@ void luaL_openlib (struct luaL_reg *l, int n) } -void luaL_verror (char *fmt, ...) +void luaL_verror (const char *fmt, ...) { char buff[500]; va_list argp; diff --git a/engine/lua/lauxlib.h b/engine/lua/lauxlib.h index 15a8c99ae06..859183e8139 100644 --- a/engine/lua/lauxlib.h +++ b/engine/lua/lauxlib.h @@ -13,7 +13,7 @@ struct luaL_reg { - char *name; + const char *name; lua_CFunction func; }; @@ -30,17 +30,17 @@ extern luaL_libList *list_of_libs; void luaL_openlib (struct luaL_reg *l, int n); void luaL_addlibtolist(luaL_reg *l, int n); -void luaL_argerror (int numarg, char *extramsg); +void luaL_argerror (int numarg, const char *extramsg); #define luaL_check_string(n) (luaL_check_lstr((n), NULL)) -char *luaL_check_lstr (int numArg, long *len); +const char *luaL_check_lstr (int numArg, long *len); #define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL)) -char *luaL_opt_lstr (int numArg, char *def, long *len); +const char *luaL_opt_lstr (int numArg, const char *def, long *len); double luaL_check_number (int numArg); double luaL_opt_number (int numArg, double def); lua_Object luaL_functionarg (int arg); lua_Object luaL_tablearg (int arg); lua_Object luaL_nonnullarg (int numArg); -void luaL_verror (char *fmt, ...); +void luaL_verror (const char *fmt, ...); char *luaL_openspace (int size); void luaL_resetbuffer (void); void luaL_addchar (int c); @@ -49,7 +49,7 @@ void luaL_addsize (int n); int luaL_newbuffer (int size); void luaL_oldbuffer (int old); char *luaL_buffer (void); -int luaL_findstring (char *name, char *list[]); +int luaL_findstring (const char *name, const char *list[]); #endif diff --git a/engine/lua/lbuiltin.cpp b/engine/lua/lbuiltin.cpp index 4ab61429928..b0a97707692 100644 --- a/engine/lua/lbuiltin.cpp +++ b/engine/lua/lbuiltin.cpp @@ -119,7 +119,7 @@ static void foreach (void) static void internaldostring (void) { long l; - char *s = luaL_check_lstr(1, &l); + const char *s = luaL_check_lstr(1, &l); if (*s == ID_CHUNK) lua_error("`dostring' cannot run pre-compiled code"); if (lua_dobuffer(s, l, luaL_opt_string(2, NULL)) == 0) @@ -130,7 +130,7 @@ static void internaldostring (void) static void internaldofile (void) { - char *fname = luaL_opt_string(1, NULL); + const char *fname = luaL_opt_string(1, NULL); if (lua_dofile(fname) == 0) if (luaA_passresults() == 0) lua_pushuserdata(NULL); /* at least one result to signal no errors */ @@ -216,12 +216,13 @@ static void tonumber (void) lua_pushnumber(lua_getnumber(o)); } else { - char *s = luaL_check_string(1); + const char *s = luaL_check_string(1); + char *e; unsigned long n; luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); - n = strtol(s, &s, base); - while (isspace(*s)) s++; /* skip trailing spaces */ - if (*s) lua_pushnil(); /* invalid format: return nil */ + n = strtol(s, &e, base); + while (isspace(*e)) e++; /* skip trailing spaces */ + if (*e) lua_pushnil(); /* invalid format: return nil */ else lua_pushnumber(n); } } @@ -243,7 +244,7 @@ static void luaI_assert (void) static void setglobal (void) { - char *n = luaL_check_string(1); + const char *n = luaL_check_string(1); lua_Object value = luaL_nonnullarg(2); lua_pushobject(value); lua_setglobal(n); @@ -252,7 +253,7 @@ static void setglobal (void) static void rawsetglobal (void) { - char *n = luaL_check_string(1); + const char *n = luaL_check_string(1); lua_Object value = luaL_nonnullarg(2); lua_pushobject(value); lua_rawsetglobal(n); @@ -287,7 +288,7 @@ static void luaI_call (void) { lua_Object f = luaL_nonnullarg(1); lua_Object arg = luaL_tablearg(2); - char *options = luaL_opt_string(3, ""); + const char *options = luaL_opt_string(3, ""); lua_Object err = lua_getparam(4); int narg = getnarg(arg); int i, status; diff --git a/engine/lua/ldo.cpp b/engine/lua/ldo.cpp index a34eabfd827..1a41cc5830c 100644 --- a/engine/lua/ldo.cpp +++ b/engine/lua/ldo.cpp @@ -342,7 +342,7 @@ void luaD_travstack (int (*fn)(TObject *)) -static void message (char *s) +static void message (const char *s) { TObject im = L->errorim; if (ttype(&im) != LUA_T_NIL) { @@ -354,7 +354,7 @@ static void message (char *s) /* ** Reports an error, and jumps up to the available recover label */ -void lua_error (char *s) +void lua_error (const char *s) { if (s) message(s); if (L->errorJmp) @@ -465,7 +465,7 @@ void luaD_gcIM (TObject *o) } -int lua_dofile (char *filename) +int lua_dofile (const char *filename) { ZIO z; int status; @@ -493,7 +493,7 @@ int lua_dofile (char *filename) #define SSIZE_PREF "20" -static void build_name (char *str, char *name) { +static void build_name (const char *str, char *name) { if (str == NULL || *str == ID_CHUNK) strcpy(name, "(buffer)"); else { @@ -508,12 +508,12 @@ static void build_name (char *str, char *name) { } -int lua_dostring (char *str) { +int lua_dostring (const char *str) { return lua_dobuffer(str, strlen(str), NULL); } -int lua_dobuffer (char *buff, int size, char *name) { +int lua_dobuffer (const char *buff, int size, const char *name) { char newname[SIZE_PREF+25]; ZIO z; int status; diff --git a/engine/lua/liolib.cpp b/engine/lua/liolib.cpp index d113ade9f6f..1e32f323bf9 100644 --- a/engine/lua/liolib.cpp +++ b/engine/lua/liolib.cpp @@ -78,7 +78,7 @@ static int ishandler (lua_Object f) else return 0; } -static FILE *getfile (char *name) +static FILE *getfile (const char *name) { lua_Object f = lua_getglobal(name); if (!ishandler(f)) @@ -87,7 +87,7 @@ static FILE *getfile (char *name) } -static FILE *getfileparam (char *name, int *arg) +static FILE *getfileparam (const char *name, int *arg) { lua_Object f = lua_getparam(*arg); if (ishandler(f)) { @@ -99,7 +99,7 @@ static FILE *getfileparam (char *name, int *arg) } -static void closefile (char *name) +static void closefile (const char *name) { FILE *f = getfile(name); if (f == stdin || f == stdout) return; @@ -110,14 +110,14 @@ static void closefile (char *name) } -static void setfile (FILE *f, char *name, int tag) +static void setfile (FILE *f, const char *name, int tag) { lua_pushusertag(f, tag); lua_setglobal(name); } -static void setreturn (FILE *f, char *name) +static void setreturn (FILE *f, const char *name) { int tag = gettag(IOTAG); setfile(f, name, tag); @@ -136,7 +136,7 @@ static void io_readfrom (void) else if (lua_tag(f) == gettag(IOTAG)) current = (FILE *)lua_getuserdata(f); else { - char *s = luaL_check_string(FIRSTARG); + const char *s = luaL_check_string(FIRSTARG); if (*s == '|') current = popen(s+1, "r"); else { @@ -166,7 +166,7 @@ static void io_writeto (void) else if (lua_tag(f) == gettag(IOTAG)) current = (FILE *)lua_getuserdata(f); else { - char *s = luaL_check_string(FIRSTARG); + const char *s = luaL_check_string(FIRSTARG); current = (*s == '|') ? popen(s+1,"w") : fopen(s,"w"); if (current == NULL) { pushresult(0); @@ -179,7 +179,7 @@ static void io_writeto (void) static void io_appendto (void) { - char *s = luaL_check_string(FIRSTARG); + const char *s = luaL_check_string(FIRSTARG); FILE *fp = fopen (s, "a"); if (fp != NULL) setreturn(fp, FOUTPUT); @@ -205,7 +205,7 @@ static void read_until (FILE *f, int lim) { static void io_read (void) { int arg = FIRSTARG; FILE *f = getfileparam(FINPUT, &arg); - char *p = luaL_opt_string(arg, NULL); + const char *p = luaL_opt_string(arg, NULL); luaL_resetbuffer(); if (p == NULL) /* default: read a line */ read_until(f, '\n'); @@ -228,7 +228,7 @@ static void io_read (void) { p++; continue; default: { - char *ep; /* get what is next */ + const char *ep; /* get what is next */ int m; /* match result */ if (c == NEED_OTHER) c = getc(f); if (c == EOF) { @@ -273,7 +273,7 @@ static void io_write (void) int arg = FIRSTARG; FILE *f = getfileparam(FOUTPUT, &arg); int status = 1; - char *s; + const char *s; long l; while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) status = status && (fwrite(s, 1, l, f) == (unsigned long)l); @@ -322,7 +322,7 @@ static void io_date (void) { time_t t; struct tm *tm; - char *s = luaL_opt_string(1, "%c"); + const char *s = luaL_opt_string(1, "%c"); char b[BUFSIZ]; time(&t); tm = localtime(&t); if (strftime(b,sizeof(b),s,tm)) @@ -336,7 +336,7 @@ static void setloc (void) { static int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; - static char *catnames[] = {"all", "collate", "ctype", "monetary", + static const char *catnames[] = {"all", "collate", "ctype", "monetary", "numeric", "time", NULL}; int op = luaL_findstring(luaL_opt_string(2, "all"), catnames); luaL_arg_check(op != -1, 2, "invalid option"); @@ -368,9 +368,9 @@ static void lua_printstack (FILE *f) int level = 1; /* skip level 0 (it's this function) */ lua_Object func; while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) { - char *name; + const char *name; int currentline; - char *filename; + const char *filename; int linedefined; lua_funcinfo(func, &filename, &linedefined); fprintf(f, (level==2) ? "Active Stack:\n\t" : "\t"); diff --git a/engine/lua/llex.cpp b/engine/lua/llex.cpp index 80b7562fd6d..564f236027b 100644 --- a/engine/lua/llex.cpp +++ b/engine/lua/llex.cpp @@ -30,7 +30,7 @@ int lua_debug=0; #define save_and_next(LS) (save(LS->current), next(LS)) -char *reserved [] = {"and", "do", "else", "elseif", "end", "function", +const char *reserved [] = {"and", "do", "else", "elseif", "end", "function", "if", "local", "nil", "not", "or", "repeat", "return", "then", "until", "while"}; @@ -45,7 +45,7 @@ void luaX_init (void) } -void luaX_syntaxerror (LexState *ls, char *s, char *token) { +void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { if (token[0] == 0) token = ""; luaL_verror("%.100s;\n last token read: `%.50s' at line %d in chunk `%.50s'", @@ -53,7 +53,7 @@ void luaX_syntaxerror (LexState *ls, char *s, char *token) { } -void luaX_error (LexState *ls, char *s) { +void luaX_error (LexState *ls, const char *s) { save(0); luaX_syntaxerror(ls, s, luaL_buffer()); } @@ -117,7 +117,7 @@ static void skipspace (LexState *LS) static int checkcond (LexState *LS, char *buff) { - static char *opts[] = {"nil", "1", NULL}; + static const char *opts[] = {"nil", "1", NULL}; int i = luaL_findstring(buff, opts); if (i >= 0) return i; else if (isalpha((unsigned char)buff[0]) || buff[0] == '_') @@ -162,7 +162,7 @@ static void ifskip (LexState *LS) static void inclinenumber (LexState *LS) { - static char *pragmas [] = + static const char *pragmas [] = {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; next(LS); /* skip '\n' */ ++LS->linenumber; diff --git a/engine/lua/llex.h b/engine/lua/llex.h index db57bd9d628..0e2accf73ef 100644 --- a/engine/lua/llex.h +++ b/engine/lua/llex.h @@ -54,8 +54,8 @@ typedef struct LexState { void luaX_init (void); void luaX_setinput (LexState *LS, ZIO *z); int luaX_lex (LexState *LS); -void luaX_syntaxerror (LexState *ls, char *s, char *token); -void luaX_error (LexState *ls, char *s); +void luaX_syntaxerror (LexState *ls, const char *s, const char *token); +void luaX_error (LexState *ls, const char *s); void luaX_token2str (LexState *ls, int token, char *s); diff --git a/engine/lua/lmem.cpp b/engine/lua/lmem.cpp index 5e8b0c40900..88e48c86619 100644 --- a/engine/lua/lmem.cpp +++ b/engine/lua/lmem.cpp @@ -14,7 +14,7 @@ int luaM_growaux (void **block, unsigned long nelems, int size, - char *errormsg, unsigned long limit) + const char *errormsg, unsigned long limit) { if (nelems >= limit) lua_error(errormsg); diff --git a/engine/lua/lmem.h b/engine/lua/lmem.h index fa027193af2..c957bfcbf18 100644 --- a/engine/lua/lmem.h +++ b/engine/lua/lmem.h @@ -22,7 +22,7 @@ void *luaM_realloc (void *oldblock, unsigned long size); int luaM_growaux (void **block, unsigned long nelems, int size, - char *errormsg, unsigned long limit); + const char *errormsg, unsigned long limit); #define luaM_free(b) free((b)) #define luaM_malloc(t) malloc((t)) diff --git a/engine/lua/lobject.cpp b/engine/lua/lobject.cpp index c914b795021..92ed92f56a5 100644 --- a/engine/lua/lobject.cpp +++ b/engine/lua/lobject.cpp @@ -10,7 +10,7 @@ #include "lua.h" -char *luaO_typenames[] = { /* ORDER LUA_T */ +const char *luaO_typenames[] = { /* ORDER LUA_T */ "userdata", "number", "string", "table", "function", "function", "task", "nil", "function", "mark", "mark", "mark", "line", NULL }; diff --git a/engine/lua/lobject.h b/engine/lua/lobject.h index 1536d16b1be..b030891e102 100644 --- a/engine/lua/lobject.h +++ b/engine/lua/lobject.h @@ -191,7 +191,7 @@ typedef struct Hash { } Hash; -extern char *luaO_typenames[]; +extern const char *luaO_typenames[]; extern TObject luaO_nilobject; diff --git a/engine/lua/lstring.cpp b/engine/lua/lstring.cpp index 8a9bc3a0acb..f1d1c3f89a0 100644 --- a/engine/lua/lstring.cpp +++ b/engine/lua/lstring.cpp @@ -37,7 +37,7 @@ void luaS_init (void) } -static unsigned long hash_s (char *s, long l) +static unsigned long hash_s (const char *s, long l) { unsigned long h = 0; while (l--) @@ -86,7 +86,7 @@ static void grow (stringtable *tb) } -static TaggedString *newone_s (char *str, long l, unsigned long h) +static TaggedString *newone_s (const char *str, long l, unsigned long h) { TaggedString *ts = (TaggedString *)luaM_malloc(sizeof(TaggedString)+l); memcpy(ts->str, str, l); @@ -114,7 +114,7 @@ static TaggedString *newone_u (char *buff, int tag, unsigned long h) return ts; } -static TaggedString *insert_s (char *str, long l, stringtable *tb) +static TaggedString *insert_s (const char *str, long l, stringtable *tb) { TaggedString *ts; unsigned long h = hash_s(str, l); @@ -130,8 +130,7 @@ static TaggedString *insert_s (char *str, long l, stringtable *tb) j = i; else if (ts->constindex >= 0 && ts->u.s.len == l && - (memcmp(str, ts->str, l) == 0)) - return ts; + (memcmp(str, ts->str, l) == 0)) return ts; if (++i == size) i=0; } /* not found */ @@ -177,18 +176,18 @@ TaggedString *luaS_createudata (void *udata, int tag) return insert_u(udata, tag, &L->string_root[(unsigned long)udata%NUM_HASHS]); } -TaggedString *luaS_newlstr (char *str, long l) +TaggedString *luaS_newlstr (const char *str, long l) { int i = (l==0)?0:(unsigned char)str[0]; return insert_s(str, l, &L->string_root[i%NUM_HASHS]); } -TaggedString *luaS_new (char *str) +TaggedString *luaS_new (const char *str) { return luaS_newlstr(str, strlen(str)); } -TaggedString *luaS_newfixedstring (char *str) +TaggedString *luaS_newfixedstring (const char *str) { TaggedString *ts = luaS_new(str); if (ts->head.marked == 0) @@ -305,7 +304,7 @@ char *luaS_travsymbol (int (*fn)(TObject *)) } -int luaS_globaldefined (char *name) +int luaS_globaldefined (const char *name) { TaggedString *ts = luaS_new(name); return ts->u.s.globalval.ttype != LUA_T_NIL; diff --git a/engine/lua/lstring.h b/engine/lua/lstring.h index 0397a29ec9a..7ac2be6d618 100644 --- a/engine/lua/lstring.h +++ b/engine/lua/lstring.h @@ -15,12 +15,12 @@ void luaS_init (void); TaggedString *luaS_createudata (void *udata, int tag); TaggedString *luaS_collector (void); void luaS_free (TaggedString *l); -TaggedString *luaS_newlstr (char *str, long l); -TaggedString *luaS_new (char *str); -TaggedString *luaS_newfixedstring (char *str); +TaggedString *luaS_newlstr (const char *str, long l); +TaggedString *luaS_new (const char *str); +TaggedString *luaS_newfixedstring (const char *str); void luaS_rawsetglobal (TaggedString *ts, TObject *newval); char *luaS_travsymbol (int (*fn)(TObject *)); -int luaS_globaldefined (char *name); +int luaS_globaldefined (const char *name); TaggedString *luaS_collectudata (void); void luaS_freeall (void); diff --git a/engine/lua/lstrlib.cpp b/engine/lua/lstrlib.cpp index d2caba0663c..990a835e652 100644 --- a/engine/lua/lstrlib.cpp +++ b/engine/lua/lstrlib.cpp @@ -16,7 +16,7 @@ -static void addnchar (char *s, int n) +static void addnchar (const char *s, int n) { char *b = luaL_openspace(n); memcpy(b, s, n); @@ -48,7 +48,7 @@ static long posrelat (long pos, long len) static void str_sub (void) { long l; - char *s = luaL_check_lstr(1, &l); + const char *s = luaL_check_lstr(1, &l); long start = posrelat((int)luaL_check_number(2), l); long end = posrelat((int)luaL_opt_number(3, -1), l); if (1 <= start && start <= end && end <= l) @@ -61,7 +61,7 @@ static void str_lower (void) { long l; int i; - char *s = luaL_check_lstr(1, &l); + const char *s = luaL_check_lstr(1, &l); luaL_resetbuffer(); for (i=0; i 0) @@ -95,7 +95,7 @@ static void str_rep (void) static void str_byte (void) { long l; - char *s = luaL_check_lstr(1, &l); + const char *s = luaL_check_lstr(1, &l); long pos = posrelat((int)luaL_opt_number(2, 1), l); luaL_arg_check(0level >= MAX_CAPT) lua_error("too many captures"); cap->capture[cap->level].init = s; cap->capture[cap->level].len = -1; @@ -286,7 +286,7 @@ static char *match (char *s, char *p, struct Capture *cap) } case ')': { /* end capture */ int l = capture_to_close(cap); - char *res; + const char *res; cap->capture[l].len = s - cap->capture[l].init; /* close capture */ if ((res = match(s, p+1, cap)) == NULL) /* match failed? */ cap->capture[l].len = -1; /* undo capture */ @@ -297,23 +297,23 @@ static char *match (char *s, char *p, struct Capture *cap) return s; /* else go through */ default: { /* it is a pattern item */ - char *ep; /* get what is next */ - char *s1 = matchitem(s, p, cap, &ep); + const char *ep; /* get what is next */ + const char *s1 = matchitem(s, p, cap, &ep); switch (*ep) { case '*': { /* repetition */ - char *res; + const char *res; if (s1 && s1>s && ((res=match(s1, p, cap)) != NULL)) return res; p=ep+1; goto init; /* else return match(s, ep+1, cap); */ } case '?': { /* optional */ - char *res; + const char *res; if (s1 && ((res=match(s1, ep+1, cap)) != NULL)) return res; p=ep+1; goto init; /* else return match(s, ep+1, cap); */ } case '-': { /* repetition */ - char *res; + const char *res; if ((res = match(s, ep+1, cap)) != NULL) return res; else if (s1 && s1>s) { @@ -335,8 +335,8 @@ static char *match (char *s, char *p, struct Capture *cap) static void str_find (void) { long l; - char *s = luaL_check_lstr(1, &l); - char *p = luaL_check_string(2); + const char *s = luaL_check_lstr(1, &l); + const char *p = luaL_check_string(2); long init = posrelat((int)luaL_opt_number(3, 1), l) - 1; struct Capture cap; luaL_arg_check(0 <= init && init <= l, 3, "out of range"); @@ -351,10 +351,10 @@ static void str_find (void) } else { int anchor = (*p == '^') ? (p++, 1) : 0; - char *s1=s+init; + const char *s1=s+init; cap.src_end = s+l; do { - char *res; + const char *res; cap.level = 0; if ((res=match(s1, p, &cap)) != NULL) { lua_pushnumber(s1-s+1); /* start */ @@ -371,7 +371,7 @@ static void str_find (void) static void add_s (lua_Object newp, struct Capture *cap) { if (lua_isstring(newp)) { - char *news = lua_getstring(newp); + const char *news = lua_getstring(newp); int l = lua_strlen(newp); int i; for (i=0; ierrorim)) diff --git a/engine/lua/ltm.h b/engine/lua/ltm.h index 1cd51f4d26c..dbfc1204207 100644 --- a/engine/lua/ltm.h +++ b/engine/lua/ltm.h @@ -48,15 +48,15 @@ struct IM { #define luaT_getim(tag,event) (&L->IMtable[-(tag)].int_method[event]) #define luaT_getimbyObj(o,e) (luaT_getim(luaT_efectivetag(o),(e))) -extern char *luaT_eventname[]; +extern const char *luaT_eventname[]; void luaT_init (void); void luaT_realtag (int tag); int luaT_efectivetag (TObject *o); -void luaT_settagmethod (int t, char *event, TObject *func); -TObject *luaT_gettagmethod (int t, char *event); -char *luaT_travtagmethods (int (*fn)(TObject *)); +void luaT_settagmethod (int t, const char *event, TObject *func); +TObject *luaT_gettagmethod (int t, const char *event); +const char *luaT_travtagmethods (int (*fn)(TObject *)); void luaT_setfallback (void); /* only if LUA_COMPAT2_5 */ diff --git a/engine/lua/lua.h b/engine/lua/lua.h index aeed7fcc13f..dae5d17304f 100644 --- a/engine/lua/lua.h +++ b/engine/lua/lua.h @@ -40,18 +40,18 @@ void lua_open (void); void lua_close (void); lua_State *lua_setstate (lua_State *st); -lua_Object lua_settagmethod (int tag, char *event); /* In: new method */ -lua_Object lua_gettagmethod (int tag, char *event); +lua_Object lua_settagmethod (int tag, const char *event); /* In: new method */ +lua_Object lua_gettagmethod (int tag, const char *event); lua_Object lua_seterrormethod (void); /* In: new method */ int lua_newtag (void); int lua_copytagmethods (int tagto, int tagfrom); void lua_settag (int tag); /* In: object */ -void lua_error (char *s); -int lua_dofile (char *filename); /* Out: returns */ -int lua_dostring (char *string); /* Out: returns */ -int lua_dobuffer (char *buff, int size, char *name); +void lua_error (const char *s); +int lua_dofile (const char *filename); /* Out: returns */ +int lua_dostring (const char *string); /* Out: returns */ +int lua_dobuffer (const char *buff, int size, const char *name); /* Out: returns */ int lua_callfunction (lua_Object f); /* In: parameters; Out: returns */ @@ -72,7 +72,7 @@ int lua_isstring (lua_Object object); int lua_isfunction (lua_Object object); double lua_getnumber (lua_Object object); -char *lua_getstring (lua_Object object); +const char *lua_getstring (lua_Object object); long lua_strlen (lua_Object object); lua_CFunction lua_getcfunction (lua_Object object); void *lua_getuserdata (lua_Object object); @@ -80,18 +80,18 @@ void *lua_getuserdata (lua_Object object); void lua_pushnil (void); void lua_pushnumber (double n); -void lua_pushlstring (char *s, long len); -void lua_pushstring (char *s); +void lua_pushlstring (const char *s, long len); +void lua_pushstring (const char *s); void lua_pushcclosure (lua_CFunction fn, int n); void lua_pushusertag (void *u, int tag); void lua_pushobject (lua_Object object); lua_Object lua_pop (void); -lua_Object lua_getglobal (char *name); -lua_Object lua_rawgetglobal (char *name); -void lua_setglobal (char *name); /* In: value */ -void lua_rawsetglobal (char *name); /* In: value */ +lua_Object lua_getglobal (const char *name); +lua_Object lua_rawgetglobal (const char *name); +void lua_setglobal (const char *name); /* In: value */ +void lua_rawsetglobal (const char *name); /* In: value */ void lua_settable (void); /* In: table, index, value */ void lua_rawsettable (void); /* In: table, index, value */ diff --git a/engine/lua/luadebug.h b/engine/lua/luadebug.h index 0bba58e8eb3..937d8d4cb6e 100644 --- a/engine/lua/luadebug.h +++ b/engine/lua/luadebug.h @@ -14,12 +14,12 @@ typedef lua_Object lua_Function; typedef void (*lua_LHFunction) (int line); -typedef void (*lua_CHFunction) (lua_Function func, char *file, int line); +typedef void (*lua_CHFunction) (lua_Function func, const char *file, int line); lua_Function lua_stackedfunction (int level); -void lua_funcinfo (lua_Object func, char **filename, int *linedefined); +void lua_funcinfo (lua_Object func, const char **filename, int *linedefined); int lua_currentline (lua_Function func); -char *lua_getobjname (lua_Object o, char **name); +const char *lua_getobjname (lua_Object o, const char **name); lua_Object lua_getlocal (lua_Function func, int local_number, char **name); int lua_setlocal (lua_Function func, int local_number); diff --git a/engine/lua/lualib.h b/engine/lua/lualib.h index 04e14c7b791..7da23c7a2e5 100644 --- a/engine/lua/lualib.h +++ b/engine/lua/lualib.h @@ -28,7 +28,7 @@ void lua_mathlibopen (void); /* Auxiliary functions (private) */ -int luaI_singlematch (int c, char *p, char **ep); +int luaI_singlematch (int c, const char *p, const char **ep); #endif diff --git a/engine/lua/lundump.cpp b/engine/lua/lundump.cpp index 325634c4d3b..bff14fd1db8 100644 --- a/engine/lua/lundump.cpp +++ b/engine/lua/lundump.cpp @@ -181,7 +181,7 @@ static TProtoFunc* LoadFunction(ZIO* Z) static void LoadSignature(ZIO* Z) { - char* s=SIGNATURE; + const char* s=SIGNATURE; while (*s!=0 && ezgetc(Z)==*s) ++s; if (*s!=0) luaL_verror("bad signature in %s",zname(Z)); diff --git a/engine/lua/lvm.cpp b/engine/lua/lvm.cpp index f75f5263a27..9f9236965a3 100644 --- a/engine/lua/lvm.cpp +++ b/engine/lua/lvm.cpp @@ -206,7 +206,7 @@ void luaV_setglobal (TaggedString *ts) } -static void call_binTM (IMS event, char *msg) +static void call_binTM (IMS event, const char *msg) { TObject *im = luaT_getimbyObj(L->stack.top-2, event);/* try first operand */ if (ttype(im) == LUA_T_NIL) { diff --git a/engine/lua/lzio.cpp b/engine/lua/lzio.cpp index 682ac731d24..0adcf349028 100644 --- a/engine/lua/lzio.cpp +++ b/engine/lua/lzio.cpp @@ -20,11 +20,11 @@ static int zmfilbuf (ZIO* /*z*/) return EOZ; } -ZIO* zmopen (ZIO* z, char* b, int size, char *name) +ZIO* zmopen (ZIO* z, const char* b, int size, const char *name) { if (b==NULL) return NULL; z->n=size; - z->p= (unsigned char *)b; + z->p= (const unsigned char *)b; z->filbuf=zmfilbuf; z->u=NULL; z->name=name; @@ -33,7 +33,7 @@ ZIO* zmopen (ZIO* z, char* b, int size, char *name) /* ------------------------------------------------------------ strings --- */ -ZIO* zsopen (ZIO* z, char* s, char *name) +ZIO* zsopen (ZIO* z, const char* s, const char *name) { if (s==NULL) return NULL; return zmopen(z,s,strlen(s),name); @@ -51,7 +51,7 @@ static int zffilbuf (ZIO* z) } -ZIO* zFopen (ZIO* z, FILE* f, char *name) +ZIO* zFopen (ZIO* z, FILE* f, const char *name) { if (f==NULL) return NULL; z->n=0; diff --git a/engine/lua/lzio.h b/engine/lua/lzio.h index 5d440283bc4..6b0f5255410 100644 --- a/engine/lua/lzio.h +++ b/engine/lua/lzio.h @@ -22,9 +22,9 @@ typedef struct zio ZIO; -ZIO* zFopen (ZIO* z, FILE* f, char *name); /* open FILEs */ -ZIO* zsopen (ZIO* z, char* s, char *name); /* string */ -ZIO* zmopen (ZIO* z, char* b, int size, char *name); /* memory */ +ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */ +ZIO* zsopen (ZIO* z, const char* s, const char *name); /* string */ +ZIO* zmopen (ZIO* z, const char* b, int size, const char *name); /* memory */ int zread (ZIO* z, void* b, int n); /* read next n bytes */ @@ -39,10 +39,10 @@ int zread (ZIO* z, void* b, int n); /* read next n bytes */ struct zio { int n; /* bytes still unread */ - unsigned char* p; /* current position in buffer */ + const unsigned char* p; /* current position in buffer */ int (*filbuf)(ZIO* z); void* u; /* additional data */ - char *name; + const char *name; unsigned char buffer[ZBSIZE]; /* buffer */ }; diff --git a/engine/savegame.cpp b/engine/savegame.cpp index 20567331509..68fadaee68b 100644 --- a/engine/savegame.cpp +++ b/engine/savegame.cpp @@ -31,7 +31,7 @@ #define SAVEGAME_VERSION 2 // Constructor. Should create/open a saved game -SaveGame::SaveGame(char *filename, bool saving) : +SaveGame::SaveGame(const char *filename, bool saving) : _saving(saving), _currentSection(0) { if (_saving) { uint32 tag = SAVEGAME_HEADERTAG; @@ -99,6 +99,7 @@ void SaveGame::endSection() { } delete[] _sectionBuffer; _sectionBuffer = NULL; + _currentSection = 0; } void SaveGame::read(void *data, int size) { @@ -110,7 +111,7 @@ void SaveGame::read(void *data, int size) { _sectionPtr += size; } -void SaveGame::write(void *data, int size) { +void SaveGame::write(const void *data, int size) { if (!_saving) error("SaveGame::writeBlock called when restoring a savegame!"); if (_currentSection == 0) diff --git a/engine/savegame.h b/engine/savegame.h index 1f6e4faffff..cc5c123f3fe 100644 --- a/engine/savegame.h +++ b/engine/savegame.h @@ -38,13 +38,13 @@ class SaveGame { public: - SaveGame(char *filename, bool saving); + SaveGame(const char *filename, bool saving); ~SaveGame(); uint32 beginSection(uint32 sectionTag); void endSection(); void read(void *data, int size); - void write(void *data, int size); + void write(const void *data, int size); protected: bool _saving; diff --git a/engine/tinygl/error.cpp b/engine/tinygl/error.cpp index 400b42de495..f5e99777405 100644 --- a/engine/tinygl/error.cpp +++ b/engine/tinygl/error.cpp @@ -3,7 +3,7 @@ #include "engine/tinygl/zgl.h" -void gl_fatal_error(char *format, ...) { +void gl_fatal_error(const char *format, ...) { va_list ap; va_start(ap, format); diff --git a/engine/tinygl/list.cpp b/engine/tinygl/list.cpp index ce2c1c2d276..0dd5125366b 100644 --- a/engine/tinygl/list.cpp +++ b/engine/tinygl/list.cpp @@ -1,7 +1,7 @@ #include "engine/tinygl/zgl.h" -static char *op_table_str[] = { +static const char *op_table_str[] = { #define ADD_OP(a, b, c) "gl" #a " " #c, #include "engine/tinygl/opinfo.h" @@ -64,7 +64,7 @@ static GLList *alloc_list(GLContext *c, int list) { void gl_print_op(FILE *f, TGLParam *p) { int op; - char *s; + const char *s; op = p[0].op; p++; diff --git a/engine/tinygl/zgl.h b/engine/tinygl/zgl.h index 9e8c5f2cdd0..1c1c6a0e9f4 100644 --- a/engine/tinygl/zgl.h +++ b/engine/tinygl/zgl.h @@ -321,7 +321,7 @@ void gl_resizeImageNoInterpolate(unsigned char *dest, int xsize_dest, int ysize_ GLContext *gl_get_context(void); -void gl_fatal_error(char *format, ...); +void gl_fatal_error(const char *format, ...); // specular buffer "api" GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float shininess); diff --git a/engine/walkplane.h b/engine/walkplane.h index 9f01ef68d8d..4c90dd61fea 100644 --- a/engine/walkplane.h +++ b/engine/walkplane.h @@ -43,8 +43,8 @@ public: void setVisible(bool visible); const char *name() const { return _name.c_str(); } - const int id() const { return _id; } - const int type() const { return _type; } // FIXME: Implement type de-masking + int id() const { return _id; } + int type() const { return _type; } // FIXME: Implement type de-masking bool visible() const { return _visible; } bool isPointInSector(Vector3d point) const; diff --git a/icons/residual.xpm b/icons/residual.xpm index 3d1f2496dcc..aa988d67259 100644 --- a/icons/residual.xpm +++ b/icons/residual.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * residual_icon[] = { +static const char * residual_icon[] = { "32 32 84 1", " c None", ". c #000100",