1 Subject: Quell const char conversion warnings.
2 From: Loui Chang <louipc.ist@gmail.com>
3 Date: Fri Oct 16 09:37:57 EDT 2009
5 const char* to char* is deprecated behaviour in gcc 4.4.
7 diff -Naur a/include/comments.h b/include/comments.h
8 --- a/include/comments.h 2004-09-27 05:28:10.000000000 -0400
9 +++ b/include/comments.h 2009-10-16 09:09:30.000000000 -0400
11 void clear(); // Clear the comment
12 void move(); // Move the comment
13 void draw(float ypos); // Draw the comment
14 - void set(int color, char *str); // Set the comment
15 + void set(int color, const char *str); // Set the comment
16 void copy(COMMENT &from); // Copy the comment
20 -void add_comment(int color, char *str, ...);
21 +void add_comment(int color, const char *str, ...);
24 void clear_comments();
25 diff -Naur a/include/config.h b/include/config.h
26 --- a/include/config.h 2004-09-27 05:28:10.000000000 -0400
27 +++ b/include/config.h 2009-10-16 09:19:40.000000000 -0400
29 // config file. It first checks the user's home directory,
30 // and if that fails it uses the CONFIG_DIR defined in the
32 -char *get_config_location(bool write = false);
33 +const char *get_config_location(bool write = false);
36 // Load config from file
37 -void load_config(char *file, CONFIG *conf);
38 +void load_config(const char *file, CONFIG *conf);
40 // Save config to file
41 -void save_config(char *file, CONFIG *conf);
42 +void save_config(const char *file, CONFIG *conf);
46 diff -Naur a/include/font.h b/include/font.h
47 --- a/include/font.h 2004-09-27 05:28:10.000000000 -0400
48 +++ b/include/font.h 2009-10-16 09:11:28.000000000 -0400
52 // Print a string with specified font texture
53 -void glprintf(GLuint tex, int set, float x, float y, float z, char *string, ...);
54 +void glprintf(GLuint tex, int set, float x, float y, float z, const char *string, ...);
57 // Print a centered string with specified font texture
58 -void glprintf_center(GLuint tex, int set, float x, float y, float z, char *string, ...);
59 +void glprintf_center(GLuint tex, int set, float x, float y, float z, const char *string, ...);
62 // Return the length of a string
63 -float glfont_length(char *string, ...);
64 +float glfont_length(const char *string, ...);
67 // Print numbers using the big number font
68 -void glprint_num(float x, float y, float z, char *string);
69 +void glprint_num(float x, float y, float z, const char *string);
72 // Build a display list for bitmapped fonts (-> font_base)
73 diff -Naur a/include/hiscore.h b/include/hiscore.h
74 --- a/include/hiscore.h 2004-09-27 05:28:10.000000000 -0400
75 +++ b/include/hiscore.h 2009-10-16 09:26:50.000000000 -0400
78 void clear(); // Clear the list
79 void sort(); // Sort the list
80 - int add_name(char *name, int score); // Add a record
81 + int add_name(const char *name, int score); // Add a record
82 void draw(int place, float fade); // Draw the list
83 - void save(char *file); // Save the list
84 - void load(char *file); // Load the list
85 + void save(const char *file); // Save the list
86 + void load(const char *file); // Load the list
87 void input_name(int place); // Input a name
91 extern HISCORE_LIST hiscore_1;
92 extern HISCORE_LIST hiscore_2;
94 -char *get_hiscore_location(int which, bool write = false);
95 +const char *get_hiscore_location(int which, bool write = false);
99 diff -Naur a/include/init.h b/include/init.h
100 --- a/include/init.h 2004-09-27 05:28:10.000000000 -0400
101 +++ b/include/init.h 2009-10-16 09:11:43.000000000 -0400
103 void init_sdl_and_gl();
105 // Display an error message and quit
106 -void error_msg(char *msg, ...);
107 +void error_msg(const char *msg, ...);
111 diff -Naur a/include/mpak.h b/include/mpak.h
112 --- a/include/mpak.h 2004-09-27 05:28:10.000000000 -0400
113 +++ b/include/mpak.h 2009-10-16 09:30:54.000000000 -0400
115 // Open a package for reading or writing. You don't need to supply
116 // the override directory, but it's recommended for reading mode.
117 // Returns zero on failure.
118 - int open_mpk(int mode, char *file, char *override = NULL);
119 + int open_mpk(int mode, const char *file, const char *override = NULL);
121 // Close the package. This writes the file table to the end of the
122 // package and updates the header. After closing the file, you can
123 @@ -103,13 +103,13 @@
125 // Add a file to the package.
126 // Returns zero on failure.
127 - int add_file(char *file);
128 + int add_file(const char *file);
130 // Get a pointer to a certain file in the package. It first looks
131 // from the override directory, and if the file isn't there it looks
132 // from the package. The user MUST fclose() the pointer himself!
133 // Returns NULL on failure.
134 - FILE *open_file(char *file);
135 + FILE *open_file(const char *file);
137 // Extracts a file from the package (using open_file()) and saves it
138 // to a file by the same name. It first looks from the override directory,
139 @@ -117,11 +117,11 @@
140 // You can supply optional path prefix if you don't want to extract to the
141 // working directory.
142 // Returns zero on failure.
143 - int extract_file(char *file, char *path = NULL);
144 + int extract_file(const char *file, const char *path = NULL);
146 // Find the index of a particular file in the package.
147 // Returns -1 on failure.
148 - int find_file(char *file);
149 + int find_file(const char *file);
153 diff -Naur a/include/soundmusic.h b/include/soundmusic.h
154 --- a/include/soundmusic.h 2004-11-20 13:49:07.000000000 -0500
155 +++ b/include/soundmusic.h 2009-10-16 08:26:21.000000000 -0400
160 -void play_music(char *file);
161 +void play_music(const char *file);
164 void play_sound(int sound, bool random_freq);
165 diff -Naur a/include/texture.h b/include/texture.h
166 --- a/include/texture.h 2004-09-27 05:28:10.000000000 -0400
167 +++ b/include/texture.h 2009-10-16 09:17:49.000000000 -0400
172 -GLuint load_png(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
173 +GLuint load_png(const char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
176 -GLuint load_jpg(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
177 +GLuint load_jpg(const char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
180 // Load a image file using SDL_Image and
182 // If repeat == true -> texture can be tiled
183 // If mipmaps == true -> Mipmaps will be generated
185 -GLuint load_texture(char *file, char *type, bool alpha = false, bool repeat = false, bool mipmaps = true);
186 +GLuint load_texture(const char *file, const char *type, bool alpha = false, bool repeat = false, bool mipmaps = true);
188 // Same as load_texture(), but loads into the specified texture index
189 -void load_texture_into(GLuint tex, char *file, char *img_type, bool alpha, bool repeat, bool mipmaps);
190 +void load_texture_into(GLuint tex, const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps);
192 // Grab texture contents from the frame buffer.
193 // Assuming that 'tex' is a valid texture ID
194 diff -Naur a/include/tilemap.h b/include/tilemap.h
195 --- a/include/tilemap.h 2004-09-27 05:28:10.000000000 -0400
196 +++ b/include/tilemap.h 2009-10-16 08:26:42.000000000 -0400
201 -void save_map(char *file);
202 -void load_map(char *file);
203 +void save_map(const char *file);
204 +void load_map(const char *file);
208 diff -Naur a/src/comments.cpp b/src/comments.cpp
209 --- a/src/comments.cpp 2004-09-27 05:28:20.000000000 -0400
210 +++ b/src/comments.cpp 2009-10-16 09:09:01.000000000 -0400
215 -void add_comment(int color, char *str, ...) {
216 +void add_comment(int color, const char *str, ...) {
217 // Format the string arguments
224 -void COMMENT::set(int color_, char *str) {
225 +void COMMENT::set(int color_, const char *str) {
229 diff -Naur a/src/config.cpp b/src/config.cpp
230 --- a/src/config.cpp 2004-09-27 05:35:48.000000000 -0400
231 +++ b/src/config.cpp 2009-10-16 09:19:02.000000000 -0400
233 // config file. It first checks the user's home directory,
234 // and if that fails it uses the CONFIG_DIR defined in the
236 -char *get_config_location(bool write) {
237 +const char *get_config_location(bool write) {
239 // Get the path to the config file
240 string tmp = get_tomatoes_dir() + "config.cfg";
245 - return (char*)tmp.c_str();
246 + return (const char*)tmp.c_str();
249 // Return the CONFIG_DIR
253 // Load config from file
254 -void load_config(char *file, CONFIG *conf) {
255 +void load_config(const char *file, CONFIG *conf) {
257 FILE *f = fopen(file, "rt");
262 // Save config to file
263 -void save_config(char *file, CONFIG *conf) {
264 +void save_config(const char *file, CONFIG *conf) {
266 FILE *f = fopen(file, "wt");
268 diff -Naur a/src/font.cpp b/src/font.cpp
269 --- a/src/font.cpp 2004-09-27 05:28:22.000000000 -0400
270 +++ b/src/font.cpp 2009-10-16 09:13:57.000000000 -0400
274 // Return the length of a string
275 -float glfont_length(char *string, ...) {
276 +float glfont_length(const char *string, ...) {
278 // Format the string arguments
283 // Print a string with specified font texture
284 -void glprintf(GLuint tex, int set, float x, float y, float z, char *string, ...) {
285 +void glprintf(GLuint tex, int set, float x, float y, float z, const char *string, ...) {
287 // Format the string arguments
292 // Print a centered string with specified font texture
293 -void glprintf_center(GLuint tex, int set, float x, float y, float z, char *string, ...) {
294 +void glprintf_center(GLuint tex, int set, float x, float y, float z, const char *string, ...) {
296 // Format the string arguments
301 // Print numbers using the big number font
302 -void glprint_num(float x, float y, float z, char *string) {
303 +void glprint_num(float x, float y, float z, const char *string) {
306 BIND_TEXTURE(font_num);
307 diff -Naur a/src/hiscore.cpp b/src/hiscore.cpp
308 --- a/src/hiscore.cpp 2004-11-20 13:49:07.000000000 -0500
309 +++ b/src/hiscore.cpp 2009-10-16 09:27:01.000000000 -0400
311 // hiscore file. It first checks the user's home directory,
312 // and if that fails it uses the HISCORE_DIR defined in the
314 -char *get_hiscore_location(int which, bool write) {
315 +const char *get_hiscore_location(int which, bool write) {
317 // Get the path to the hiscore file
322 // Save the list to a file
323 -void HISCORE_LIST::save(char *file) {
324 +void HISCORE_LIST::save(const char *file) {
326 fout = fopen(file, "wb");
331 // Load the list from a file
332 -void HISCORE_LIST::load(char *file) {
333 +void HISCORE_LIST::load(const char *file) {
335 fin = fopen(file, "rb");
340 // Add a name to the list. Returns the place.
341 -int HISCORE_LIST::add_name(char *name, int score) {
342 +int HISCORE_LIST::add_name(const char *name, int score) {
343 // Check if we qualify
344 if(list[NUM_NAMES-1].score >= score)
346 diff -Naur a/src/init.cpp b/src/init.cpp
347 --- a/src/init.cpp 2004-11-20 13:49:07.000000000 -0500
348 +++ b/src/init.cpp 2009-10-16 09:14:11.000000000 -0400
352 // Display an error message and quit
353 -void error_msg(char *msg, ...) {
354 +void error_msg(const char *msg, ...) {
356 char *buf = new char[4096];
358 diff -Naur a/src/menu.cpp b/src/menu.cpp
359 --- a/src/menu.cpp 2004-11-21 05:26:40.000000000 -0500
360 +++ b/src/menu.cpp 2009-10-16 09:29:02.000000000 -0400
364 // Helper function which returns a key name in upper case
365 -char *key_name(int key) {
366 +const char *key_name(int key) {
369 // Get the key name from SDL
370 diff -Naur a/src/mpak.cpp b/src/mpak.cpp
371 --- a/src/mpak.cpp 2004-09-27 05:28:22.000000000 -0400
372 +++ b/src/mpak.cpp 2009-10-16 09:31:31.000000000 -0400
376 // Compute the CRC for a file
377 -UINT32 mpk_crc_file(char *file, UINT32 pos) {
378 +UINT32 mpk_crc_file(const char *file, UINT32 pos) {
380 UINT32 crc = 0xFFFFFFFFL;
384 // This helper function returns the filename without full path.
386 -char *mpk_strip_path(char *path) {
387 +char *mpk_strip_path(const char *path) {
389 int pos = strlen(path);
392 // Open a package for reading or writing. You don't need to supply
393 // the override directory, but it's recommended for reading mode.
394 // Returns zero on failure.
395 -int MPAK_FILE::open_mpk(int open_mode, char *file, char *override) {
396 +int MPAK_FILE::open_mpk(int open_mode, const char *file, const char *override) {
398 // Check if it's already open
399 if(mode != MPAK_CLOSED)
402 // Add a file to the package.
403 // Returns zero on failure.
404 -int MPAK_FILE::add_file(char *file) {
405 +int MPAK_FILE::add_file(const char *file) {
407 // Check that we're in write mode
408 if(mode != MPAK_WRITE)
410 // from the override directory, and if the file isn't there it looks
411 // from the package. The user MUST fclose() the pointer himself!
412 // Returns NULL on failure.
413 -FILE *MPAK_FILE::open_file(char *file) {
414 +FILE *MPAK_FILE::open_file(const char *file) {
416 // Check that we're in read mode
417 if(mode != MPAK_READ)
419 // You can supply optional path prefix if you don't want to extract to the
420 // working directory.
421 // Returns zero on failure.
422 -int MPAK_FILE::extract_file(char *file, char *path) {
423 +int MPAK_FILE::extract_file(const char *file, const char *path) {
425 // Retrieve the pointer from open_file()
426 FILE *fin = open_file(file);
429 // Find the index of a particular file in the package.
430 // Returns -1 on failure.
431 -int MPAK_FILE::find_file(char *file) {
432 +int MPAK_FILE::find_file(const char *file) {
433 // Check that we're open
434 if(mode == MPAK_CLOSED)
436 diff -Naur a/src/screenshot.cpp b/src/screenshot.cpp
437 --- a/src/screenshot.cpp 2004-09-27 05:38:16.000000000 -0400
438 +++ b/src/screenshot.cpp 2009-10-16 08:28:22.000000000 -0400
442 // Save an array of pixels to a TGA file
443 -void save_tga(char *filename, short int w, short int h, unsigned char *image_data);
444 +void save_tga(const char *filename, short int w, short int h, unsigned char *image_data);
447 // Check if a file exists
448 -bool file_exists(char *file) {
449 +bool file_exists(const char *file) {
450 FILE *f = fopen(file, "rb");
455 // Save an array of pixels to a TGA file
456 // Written using OpenGL Game Programming - book as a reference
457 -void save_tga(char *filename, short int w, short int h, unsigned char *image_data) {
458 +void save_tga(const char *filename, short int w, short int h, unsigned char *image_data) {
460 unsigned char byte_skip; // Used to fill in the data fields that we don't care about
461 short int short_skip;
462 diff -Naur a/src/soundmusic.cpp b/src/soundmusic.cpp
463 --- a/src/soundmusic.cpp 2004-11-21 05:18:29.000000000 -0500
464 +++ b/src/soundmusic.cpp 2009-10-16 08:28:34.000000000 -0400
467 // This helper function loads a sound and stores it to the sound array
468 static int cur_sound = 0;
469 -void load_sound(char *file) {
470 +void load_sound(const char *file) {
471 if(cur_sound > NUM_SOUNDS-1)
472 error_msg("load_sounds():\nTrying to load too many sounds!\nNUM_SOUNDS is defined as %d.\n", NUM_SOUNDS);
478 -void play_music(char *file) {
479 +void play_music(const char *file) {
480 if(!config.sound || !config.music_vol)
483 diff -Naur a/src/texture.cpp b/src/texture.cpp
484 --- a/src/texture.cpp 2004-11-20 13:49:22.000000000 -0500
485 +++ b/src/texture.cpp 2009-10-16 09:28:00.000000000 -0400
490 -GLuint load_png(char *file, bool alpha, bool repeat, bool mipmaps) {
491 +GLuint load_png(const char *file, bool alpha, bool repeat, bool mipmaps) {
492 return load_texture(file, "PNG", alpha, repeat, mipmaps);
497 -GLuint load_jpg(char *file, bool alpha, bool repeat, bool mipmaps) {
498 +GLuint load_jpg(const char *file, bool alpha, bool repeat, bool mipmaps) {
499 return load_texture(file, "JPG", alpha, repeat, mipmaps);
503 // If repeat == true -> texture can be tiled
504 // If mipmaps == true -> Mipmaps will be generated
506 -GLuint load_texture(char *file, char *img_type, bool alpha, bool repeat, bool mipmaps) {
507 +GLuint load_texture(const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps) {
512 // Load the 'file' to SDL_Surface
513 SDL_Surface *img = NULL;
517 rw = SDL_RWFromFP(fin, 1);
518 - img = IMG_LoadTyped_RW(rw,0, img_type);
519 + strcpy(itype, img_type);
520 + img = IMG_LoadTyped_RW(rw,0, itype);
522 error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
527 // Same as load_texture(), but loads into a specified texture index
528 -void load_texture_into(GLuint tex, char *file, char *img_type, bool alpha, bool repeat, bool mipmaps) {
529 +void load_texture_into(GLuint tex, const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps) {
530 // Load the 'file' to SDL_Surface
531 SDL_Surface *img = NULL;
534 FILE *fin = pakfile.open_file(file);
539 rw = SDL_RWFromFP(fin, 1);
540 - img = IMG_LoadTyped_RW(rw,0, img_type);
541 + strcpy(itype, img_type);
542 + img = IMG_LoadTyped_RW(rw,0, itype);
544 error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
546 diff -Naur a/src/tilemap.cpp b/src/tilemap.cpp
547 --- a/src/tilemap.cpp 2004-09-27 05:28:22.000000000 -0400
548 +++ b/src/tilemap.cpp 2009-10-16 08:29:06.000000000 -0400
552 // Save the map to a file
553 -void save_map(char *file) {
554 +void save_map(const char *file) {
557 FILE *f = fopen(file, "wb");
561 // Load the map from a file
562 -void load_map(char *file) {
563 +void load_map(const char *file) {
565 // Load the level from the pakfile
566 FILE *f = pakfile.open_file(file);