updated on Sun Jan 15 16:02:00 UTC 2012
[aur-mirror.git] / tomatoes / 0002-tomatoes-1.55-Quell-const-char-conversion-warnings.patch
blobd096d21cc37d42ca8cf7ece58dc3667bd1781709
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
10 @@ -56,12 +56,12 @@
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, ...);
22 void draw_comments();
23 void move_comments();
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
28 @@ -59,14 +59,14 @@
29 // config file. It first checks the user's home directory,
30 // and if that fails it uses the CONFIG_DIR defined in the
31 // makefile.
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);
44 #endif
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
49 @@ -68,19 +68,19 @@
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
76 @@ -55,10 +55,10 @@
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
90 @@ -66,7 +66,7 @@
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);
98 #endif
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
102 @@ -48,7 +48,7 @@
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, ...);
109 #endif
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
114 @@ -94,7 +94,7 @@
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
156 @@ -86,7 +86,7 @@
157 void init_mixer();
159 // Play music
160 -void play_music(char *file);
161 +void play_music(const char *file);
163 // Play a sound
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
168 @@ -35,10 +35,10 @@
171 // Load a PNG
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);
175 // Load a JPG
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
181 @@ -47,10 +47,10 @@
182 // If repeat == true -> texture can be tiled
183 // If mipmaps == true -> Mipmaps will be generated
184 // Return texture ID
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
197 @@ -76,8 +76,8 @@
198 void build_map();
199 void kill_map();
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);
207 #endif
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
211 @@ -50,7 +50,7 @@
214 // Add a comment
215 -void add_comment(int color, char *str, ...) {
216 +void add_comment(int color, const char *str, ...) {
217 // Format the string arguments
218 char buf[256];
219 va_list args;
220 @@ -97,7 +97,7 @@
223 // Set the text
224 -void COMMENT::set(int color_, char *str) {
225 +void COMMENT::set(int color_, const char *str) {
226 clear();
228 // Set the buf
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
232 @@ -76,7 +76,7 @@
233 // config file. It first checks the user's home directory,
234 // and if that fails it uses the CONFIG_DIR defined in the
235 // makefile.
236 -char *get_config_location(bool write) {
237 +const char *get_config_location(bool write) {
238 #ifdef LINUX
239 // Get the path to the config file
240 string tmp = get_tomatoes_dir() + "config.cfg";
241 @@ -91,7 +91,7 @@
242 fclose(ftest);
245 - return (char*)tmp.c_str();
246 + return (const char*)tmp.c_str();
247 #endif
249 // Return the CONFIG_DIR
250 @@ -100,7 +100,7 @@
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");
258 if(!f)
259 @@ -127,7 +127,7 @@
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");
267 if(!f)
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
271 @@ -53,7 +53,7 @@
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
279 char buf[1024];
280 @@ -71,7 +71,7 @@
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
288 char buf[1024];
289 @@ -97,7 +97,7 @@
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
297 char buf[1024];
298 @@ -179,7 +179,7 @@
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) {
305 // Print
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
310 @@ -69,7 +69,7 @@
311 // hiscore file. It first checks the user's home directory,
312 // and if that fails it uses the HISCORE_DIR defined in the
313 // makefile.
314 -char *get_hiscore_location(int which, bool write) {
315 +const char *get_hiscore_location(int which, bool write) {
316 #ifdef LINUX
317 // Get the path to the hiscore file
318 string tmp;
319 @@ -401,7 +401,7 @@
322 // Save the list to a file
323 -void HISCORE_LIST::save(char *file) {
324 +void HISCORE_LIST::save(const char *file) {
325 FILE *fout;
326 fout = fopen(file, "wb");
327 if(!fout)
328 @@ -421,7 +421,7 @@
331 // Load the list from a file
332 -void HISCORE_LIST::load(char *file) {
333 +void HISCORE_LIST::load(const char *file) {
334 FILE *fin;
335 fin = fopen(file, "rb");
336 if(!fin) {
337 @@ -444,7 +444,7 @@
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)
345 return -1;
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
349 @@ -58,7 +58,7 @@
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
361 @@ -92,7 +92,7 @@
364 // Helper function which returns a key name in upper case
365 -char *key_name(int key) {
366 +const char *key_name(int key) {
368 if(key != -1) {
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
373 @@ -102,7 +102,7 @@
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) {
379 // Initial CRC
380 UINT32 crc = 0xFFFFFFFFL;
382 @@ -172,7 +172,7 @@
384 // This helper function returns the filename without full path.
385 // Pass a full path.
386 -char *mpk_strip_path(char *path) {
387 +char *mpk_strip_path(const char *path) {
389 int pos = strlen(path);
390 while(pos > 0) {
391 @@ -218,7 +218,7 @@
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)
400 @@ -402,7 +402,7 @@
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)
409 @@ -450,7 +450,7 @@
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)
418 @@ -501,7 +501,7 @@
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);
427 @@ -551,7 +551,7 @@
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)
435 return -1;
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
439 @@ -46,11 +46,11 @@
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");
451 if(!f)
452 return false;
453 @@ -105,7 +105,7 @@
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
465 @@ -168,7 +168,7 @@
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);
474 @@ -257,7 +257,7 @@
477 // Play music
478 -void play_music(char *file) {
479 +void play_music(const char *file) {
480 if(!config.sound || !config.music_vol)
481 return;
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
486 @@ -67,13 +67,13 @@
489 // Load a PNG
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);
496 // Load a JPG
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);
502 @@ -84,9 +84,10 @@
503 // If repeat == true -> texture can be tiled
504 // If mipmaps == true -> Mipmaps will be generated
505 // Return texture ID
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) {
509 GLuint tex;
510 + char itype[5];
512 // Load the 'file' to SDL_Surface
513 SDL_Surface *img = NULL;
514 @@ -98,7 +99,8 @@
516 SDL_RWops *rw;
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);
521 if(img == NULL)
522 error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
523 SDL_FreeRW(rw);
524 @@ -187,9 +189,10 @@
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;
532 + char itype[5];
534 FILE *fin = pakfile.open_file(file);
535 if(!fin)
536 @@ -197,7 +200,8 @@
538 SDL_RWops *rw;
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);
543 if(img == NULL)
544 error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
545 SDL_FreeRW(rw);
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
549 @@ -416,7 +416,7 @@
552 // Save the map to a file
553 -void save_map(char *file) {
554 +void save_map(const char *file) {
555 #ifdef EDITOR
556 // Open the file
557 FILE *f = fopen(file, "wb");
558 @@ -466,7 +466,7 @@
561 // Load the map from a file
562 -void load_map(char *file) {
563 +void load_map(const char *file) {
564 #ifndef EDITOR
565 // Load the level from the pakfile
566 FILE *f = pakfile.open_file(file);