diff options
author | tron <tron@openttd.org> | 2005-02-05 18:05:42 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-02-05 18:05:42 +0000 |
commit | 17ca2c49a538eb4896e0b6e6ff24d12e6915ede2 (patch) | |
tree | f89ba1ea60d31b2d81001fc7f60d31bc9bac8360 | |
parent | 7278f72157d834da45a3b7986128ea865c1b8ddc (diff) | |
download | openttd-17ca2c49a538eb4896e0b6e6ff24d12e6915ede2.tar.xz |
(svn r1805) Teach the driver layer a few things about const correctness
-rw-r--r-- | dedicated.c | 6 | ||||
-rw-r--r-- | extmidi.c | 2 | ||||
-rw-r--r-- | hal.h | 14 | ||||
-rw-r--r-- | os/beos/bemidi.cpp | 2 | ||||
-rw-r--r-- | os2.c | 2 | ||||
-rw-r--r-- | sdl.c | 12 | ||||
-rw-r--r-- | ttd.c | 21 | ||||
-rw-r--r-- | w32dm.c | 4 | ||||
-rw-r--r-- | win32.c | 6 |
9 files changed, 36 insertions, 33 deletions
diff --git a/dedicated.c b/dedicated.c index 9ee6f4da1..608b0f429 100644 --- a/dedicated.c +++ b/dedicated.c @@ -128,7 +128,8 @@ void CloseWindowsConsoleThread(void) #endif -static const char *DedicatedVideoStart(char **parm) { +static const char *DedicatedVideoStart(const char * const *parm) +{ _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); @@ -306,7 +307,8 @@ const HalVideoDriver _dedicated_video_driver = { static void *_dedicated_video_mem; -static const char *DedicatedVideoStart(char **parm) { +static const char *DedicatedVideoStart(const char **parm) +{ DEBUG(misc,0)("OpenTTD compiled without network-support, quiting..."); return NULL; @@ -26,7 +26,7 @@ static void extmidi_kill(void) _pid = 0; } -static char *extmidi_start(char **parm) +static const char *extmidi_start(const char * const *parm) { _pid = 0; return NULL; @@ -2,12 +2,12 @@ #define HAL_H typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); } HalCommonDriver; typedef struct { - const char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); void (*make_dirty)(int left, int top, int width, int height); int (*main_loop)(void); @@ -20,12 +20,12 @@ enum { }; typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); } HalSoundDriver; typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); void (*play_song)(const char *filename); @@ -88,9 +88,9 @@ extern bool _dbg_screen_rect; void LoadDriver(int driver, const char *name); -char *GetDriverParam(char **parm, const char *name); -bool GetDriverParamBool(char **parm, const char *name); -int GetDriverParamInt(char **parm, const char *name, int def); +const char *GetDriverParam(const char * const *parm, const char *name); +bool GetDriverParamBool(const char * const *parm, const char *name); +int GetDriverParamInt(const char * const *parm, const char *name, int def); diff --git a/os/beos/bemidi.cpp b/os/beos/bemidi.cpp index d0f41d865..969231a6d 100644 --- a/os/beos/bemidi.cpp +++ b/os/beos/bemidi.cpp @@ -9,7 +9,7 @@ BMidiSynthFile midiSynthFile; -static char *bemidi_start(char **parm) +static const char *bemidi_start(const char * const *parm) { return NULL; } @@ -656,7 +656,7 @@ static bool OS2MidiIsSongPlaying() return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; } -static char *OS2MidiStart(char **parm) +static const char *OS2MidiStart(const char * const *parm) { return 0; } @@ -103,7 +103,7 @@ static const char sdl_files[] = static SDLProcs _proc; -static char *LoadSdlDLL(void) +static const char *LoadSdlDLL(void) { if (_proc.SDL_Init != NULL) return NULL; @@ -138,11 +138,11 @@ static void SdlAbort(int sig) #endif -static char *SdlOpen(uint32 x) +static const char *SdlOpen(uint32 x) { #if defined(DYNAMICALLY_LOADED_SDL) && defined(WIN32) { - char *s = LoadSdlDLL(); + const char *s = LoadSdlDLL(); if (s != NULL) return s; } #endif @@ -540,7 +540,7 @@ static int PollEvent(void) return -1; } -static const char *SdlVideoStart(char **parm) +static const char *SdlVideoStart(const char * const *parm) { char buf[30]; @@ -654,11 +654,11 @@ static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) MxMixSamples(_mixer, stream, len / 4); } -static char *SdlSoundStart(char **parm) +static const char *SdlSoundStart(const char * const *parm) { SDL_AudioSpec spec; - char *s = SdlOpen(SDL_INIT_AUDIO); + const char *s = SdlOpen(SDL_INIT_AUDIO); if (s != NULL) return s; spec.freq = GetDriverParamInt(parm, "hz", 11025); @@ -100,7 +100,7 @@ char * CDECL str_fmt(const char *str, ...) // NULL midi driver -static char *NullMidiStart(char **parm) { return NULL; } +static const char *NullMidiStart(const char * const *parm) { return NULL; } static void NullMidiStop(void) {} static void NullMidiPlaySong(const char *filename) {} static void NullMidiStopSong(void) {} @@ -118,7 +118,8 @@ const HalMusicDriver _null_music_driver = { // NULL video driver static void *_null_video_mem; -static const char *NullVideoStart(char **parm) { +static const char *NullVideoStart(const char * const *parm) +{ _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; _null_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); @@ -149,7 +150,7 @@ const HalVideoDriver _null_video_driver = { }; // NULL sound driver -static char *NullSoundStart(char **parm) { return NULL; } +static const char *NullSoundStart(const char * const *parm) { return NULL; } static void NullSoundStop(void) {} const HalSoundDriver _null_sound_driver = { NullSoundStart, @@ -254,7 +255,7 @@ void LoadDriver(int driver, const char *name) const char *err; char *parm; char buffer[256]; - char *parms[32]; + const char *parms[32]; parms[0] = NULL; @@ -330,9 +331,9 @@ static void showhelp(void) } -char *GetDriverParam(char **parm, const char *name) +const char *GetDriverParam(const char * const *parm, const char *name) { - char *p; + const char *p; int len = strlen(name); while ((p = *parm++) != NULL) { if (!strncmp(p,name,len)) { @@ -343,15 +344,15 @@ char *GetDriverParam(char **parm, const char *name) return NULL; } -bool GetDriverParamBool(char **parm, const char *name) +bool GetDriverParamBool(const char * const *parm, const char *name) { - char *p = GetDriverParam(parm, name); + const char *p = GetDriverParam(parm, name); return p != NULL; } -int GetDriverParamInt(char **parm, const char *name, int def) +int GetDriverParamInt(const char * const *parm, const char *name, int def) { - char *p = GetDriverParam(parm, name); + const char *p = GetDriverParam(parm, name); return p != NULL ? atoi(p) : def; } @@ -32,7 +32,7 @@ #include "sound.h" #include "hal.h" -static char * DMusicMidiStart(char **parm); +static const char * DMusicMidiStart(const char * const *parm); static void DMusicMidiStop(void); static void DMusicMidiPlaySong(const char *filename); static void DMusicMidiStopSong(void); @@ -60,7 +60,7 @@ extern void SetVolume (long); bool seeking = false; -static char * DMusicMidiStart(char **parm) +static const char * DMusicMidiStart(const char * const *parm) { if (InitDirectMusic() == true) return(0); @@ -606,7 +606,7 @@ static void FindResolutions(void) } -static const char *Win32GdiStart(char **parm) +static const char *Win32GdiStart(const char * const *parm) { memset(&_wnd, 0, sizeof(_wnd)); _wnd.cursor_visible = true; @@ -879,7 +879,7 @@ static DWORD WINAPI MidiThread(LPVOID arg) return 0; } -static char *Win32MidiStart(char **parm) +static const char *Win32MidiStart(const char * const *parm) { DWORD threadId; memset(&_midi, 0, sizeof(_midi)); @@ -939,7 +939,7 @@ static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWOR } } -static char *Win32SoundStart(char **parm) +static const char *Win32SoundStart(const char * const *parm) { WAVEFORMATEX wfex; int hz; |