1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
Subject: Quell const char conversion warnings.
From: Loui Chang <louipc.ist@gmail.com>
Date: Fri Oct 16 09:37:57 EDT 2009
const char* to char* is deprecated behaviour in gcc 4.4.
diff -Naur a/include/comments.h b/include/comments.h
--- a/include/comments.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/comments.h 2009-10-16 09:09:30.000000000 -0400
@@ -56,12 +56,12 @@
void clear(); // Clear the comment
void move(); // Move the comment
void draw(float ypos); // Draw the comment
- void set(int color, char *str); // Set the comment
+ void set(int color, const char *str); // Set the comment
void copy(COMMENT &from); // Copy the comment
};
-void add_comment(int color, char *str, ...);
+void add_comment(int color, const char *str, ...);
void draw_comments();
void move_comments();
void clear_comments();
diff -Naur a/include/config.h b/include/config.h
--- a/include/config.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/config.h 2009-10-16 09:19:40.000000000 -0400
@@ -59,14 +59,14 @@
// config file. It first checks the user's home directory,
// and if that fails it uses the CONFIG_DIR defined in the
// makefile.
-char *get_config_location(bool write = false);
+const char *get_config_location(bool write = false);
// Load config from file
-void load_config(char *file, CONFIG *conf);
+void load_config(const char *file, CONFIG *conf);
// Save config to file
-void save_config(char *file, CONFIG *conf);
+void save_config(const char *file, CONFIG *conf);
#endif
diff -Naur a/include/font.h b/include/font.h
--- a/include/font.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/font.h 2009-10-16 09:11:28.000000000 -0400
@@ -68,19 +68,19 @@
// Print a string with specified font texture
-void glprintf(GLuint tex, int set, float x, float y, float z, char *string, ...);
+void glprintf(GLuint tex, int set, float x, float y, float z, const char *string, ...);
// Print a centered string with specified font texture
-void glprintf_center(GLuint tex, int set, float x, float y, float z, char *string, ...);
+void glprintf_center(GLuint tex, int set, float x, float y, float z, const char *string, ...);
// Return the length of a string
-float glfont_length(char *string, ...);
+float glfont_length(const char *string, ...);
// Print numbers using the big number font
-void glprint_num(float x, float y, float z, char *string);
+void glprint_num(float x, float y, float z, const char *string);
// Build a display list for bitmapped fonts (-> font_base)
diff -Naur a/include/hiscore.h b/include/hiscore.h
--- a/include/hiscore.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/hiscore.h 2009-10-16 09:26:50.000000000 -0400
@@ -55,10 +55,10 @@
void clear(); // Clear the list
void sort(); // Sort the list
- int add_name(char *name, int score); // Add a record
+ int add_name(const char *name, int score); // Add a record
void draw(int place, float fade); // Draw the list
- void save(char *file); // Save the list
- void load(char *file); // Load the list
+ void save(const char *file); // Save the list
+ void load(const char *file); // Load the list
void input_name(int place); // Input a name
};
@@ -66,7 +66,7 @@
extern HISCORE_LIST hiscore_1;
extern HISCORE_LIST hiscore_2;
-char *get_hiscore_location(int which, bool write = false);
+const char *get_hiscore_location(int which, bool write = false);
#endif
diff -Naur a/include/init.h b/include/init.h
--- a/include/init.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/init.h 2009-10-16 09:11:43.000000000 -0400
@@ -48,7 +48,7 @@
void init_sdl_and_gl();
// Display an error message and quit
-void error_msg(char *msg, ...);
+void error_msg(const char *msg, ...);
#endif
diff -Naur a/include/mpak.h b/include/mpak.h
--- a/include/mpak.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/mpak.h 2009-10-16 09:30:54.000000000 -0400
@@ -94,7 +94,7 @@
// Open a package for reading or writing. You don't need to supply
// the override directory, but it's recommended for reading mode.
// Returns zero on failure.
- int open_mpk(int mode, char *file, char *override = NULL);
+ int open_mpk(int mode, const char *file, const char *override = NULL);
// Close the package. This writes the file table to the end of the
// package and updates the header. After closing the file, you can
@@ -103,13 +103,13 @@
// Add a file to the package.
// Returns zero on failure.
- int add_file(char *file);
+ int add_file(const char *file);
// Get a pointer to a certain file in the package. It first looks
// from the override directory, and if the file isn't there it looks
// from the package. The user MUST fclose() the pointer himself!
// Returns NULL on failure.
- FILE *open_file(char *file);
+ FILE *open_file(const char *file);
// Extracts a file from the package (using open_file()) and saves it
// to a file by the same name. It first looks from the override directory,
@@ -117,11 +117,11 @@
// You can supply optional path prefix if you don't want to extract to the
// working directory.
// Returns zero on failure.
- int extract_file(char *file, char *path = NULL);
+ int extract_file(const char *file, const char *path = NULL);
// Find the index of a particular file in the package.
// Returns -1 on failure.
- int find_file(char *file);
+ int find_file(const char *file);
};
diff -Naur a/include/soundmusic.h b/include/soundmusic.h
--- a/include/soundmusic.h 2004-11-20 13:49:07.000000000 -0500
+++ b/include/soundmusic.h 2009-10-16 08:26:21.000000000 -0400
@@ -86,7 +86,7 @@
void init_mixer();
// Play music
-void play_music(char *file);
+void play_music(const char *file);
// Play a sound
void play_sound(int sound, bool random_freq);
diff -Naur a/include/texture.h b/include/texture.h
--- a/include/texture.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/texture.h 2009-10-16 09:17:49.000000000 -0400
@@ -35,10 +35,10 @@
// Load a PNG
-GLuint load_png(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
+GLuint load_png(const char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
// Load a JPG
-GLuint load_jpg(char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
+GLuint load_jpg(const char *file, bool alpha = false, bool repeat = false, bool mipmaps = true);
// Load a image file using SDL_Image and
@@ -47,10 +47,10 @@
// If repeat == true -> texture can be tiled
// If mipmaps == true -> Mipmaps will be generated
// Return texture ID
-GLuint load_texture(char *file, char *type, bool alpha = false, bool repeat = false, bool mipmaps = true);
+GLuint load_texture(const char *file, const char *type, bool alpha = false, bool repeat = false, bool mipmaps = true);
// Same as load_texture(), but loads into the specified texture index
-void load_texture_into(GLuint tex, char *file, char *img_type, bool alpha, bool repeat, bool mipmaps);
+void load_texture_into(GLuint tex, const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps);
// Grab texture contents from the frame buffer.
// Assuming that 'tex' is a valid texture ID
diff -Naur a/include/tilemap.h b/include/tilemap.h
--- a/include/tilemap.h 2004-09-27 05:28:10.000000000 -0400
+++ b/include/tilemap.h 2009-10-16 08:26:42.000000000 -0400
@@ -76,8 +76,8 @@
void build_map();
void kill_map();
-void save_map(char *file);
-void load_map(char *file);
+void save_map(const char *file);
+void load_map(const char *file);
#endif
diff -Naur a/src/comments.cpp b/src/comments.cpp
--- a/src/comments.cpp 2004-09-27 05:28:20.000000000 -0400
+++ b/src/comments.cpp 2009-10-16 09:09:01.000000000 -0400
@@ -50,7 +50,7 @@
// Add a comment
-void add_comment(int color, char *str, ...) {
+void add_comment(int color, const char *str, ...) {
// Format the string arguments
char buf[256];
va_list args;
@@ -97,7 +97,7 @@
// Set the text
-void COMMENT::set(int color_, char *str) {
+void COMMENT::set(int color_, const char *str) {
clear();
// Set the buf
diff -Naur a/src/config.cpp b/src/config.cpp
--- a/src/config.cpp 2004-09-27 05:35:48.000000000 -0400
+++ b/src/config.cpp 2009-10-16 09:19:02.000000000 -0400
@@ -76,7 +76,7 @@
// config file. It first checks the user's home directory,
// and if that fails it uses the CONFIG_DIR defined in the
// makefile.
-char *get_config_location(bool write) {
+const char *get_config_location(bool write) {
#ifdef LINUX
// Get the path to the config file
string tmp = get_tomatoes_dir() + "config.cfg";
@@ -91,7 +91,7 @@
fclose(ftest);
}
- return (char*)tmp.c_str();
+ return (const char*)tmp.c_str();
#endif
// Return the CONFIG_DIR
@@ -100,7 +100,7 @@
// Load config from file
-void load_config(char *file, CONFIG *conf) {
+void load_config(const char *file, CONFIG *conf) {
FILE *f = fopen(file, "rt");
if(!f)
@@ -127,7 +127,7 @@
// Save config to file
-void save_config(char *file, CONFIG *conf) {
+void save_config(const char *file, CONFIG *conf) {
FILE *f = fopen(file, "wt");
if(!f)
diff -Naur a/src/font.cpp b/src/font.cpp
--- a/src/font.cpp 2004-09-27 05:28:22.000000000 -0400
+++ b/src/font.cpp 2009-10-16 09:13:57.000000000 -0400
@@ -53,7 +53,7 @@
// Return the length of a string
-float glfont_length(char *string, ...) {
+float glfont_length(const char *string, ...) {
// Format the string arguments
char buf[1024];
@@ -71,7 +71,7 @@
// Print a string with specified font texture
-void glprintf(GLuint tex, int set, float x, float y, float z, char *string, ...) {
+void glprintf(GLuint tex, int set, float x, float y, float z, const char *string, ...) {
// Format the string arguments
char buf[1024];
@@ -97,7 +97,7 @@
// Print a centered string with specified font texture
-void glprintf_center(GLuint tex, int set, float x, float y, float z, char *string, ...) {
+void glprintf_center(GLuint tex, int set, float x, float y, float z, const char *string, ...) {
// Format the string arguments
char buf[1024];
@@ -179,7 +179,7 @@
// Print numbers using the big number font
-void glprint_num(float x, float y, float z, char *string) {
+void glprint_num(float x, float y, float z, const char *string) {
// Print
BIND_TEXTURE(font_num);
diff -Naur a/src/hiscore.cpp b/src/hiscore.cpp
--- a/src/hiscore.cpp 2004-11-20 13:49:07.000000000 -0500
+++ b/src/hiscore.cpp 2009-10-16 09:27:01.000000000 -0400
@@ -69,7 +69,7 @@
// hiscore file. It first checks the user's home directory,
// and if that fails it uses the HISCORE_DIR defined in the
// makefile.
-char *get_hiscore_location(int which, bool write) {
+const char *get_hiscore_location(int which, bool write) {
#ifdef LINUX
// Get the path to the hiscore file
string tmp;
@@ -401,7 +401,7 @@
// Save the list to a file
-void HISCORE_LIST::save(char *file) {
+void HISCORE_LIST::save(const char *file) {
FILE *fout;
fout = fopen(file, "wb");
if(!fout)
@@ -421,7 +421,7 @@
// Load the list from a file
-void HISCORE_LIST::load(char *file) {
+void HISCORE_LIST::load(const char *file) {
FILE *fin;
fin = fopen(file, "rb");
if(!fin) {
@@ -444,7 +444,7 @@
// Add a name to the list. Returns the place.
-int HISCORE_LIST::add_name(char *name, int score) {
+int HISCORE_LIST::add_name(const char *name, int score) {
// Check if we qualify
if(list[NUM_NAMES-1].score >= score)
return -1;
diff -Naur a/src/init.cpp b/src/init.cpp
--- a/src/init.cpp 2004-11-20 13:49:07.000000000 -0500
+++ b/src/init.cpp 2009-10-16 09:14:11.000000000 -0400
@@ -58,7 +58,7 @@
// Display an error message and quit
-void error_msg(char *msg, ...) {
+void error_msg(const char *msg, ...) {
char *buf = new char[4096];
diff -Naur a/src/menu.cpp b/src/menu.cpp
--- a/src/menu.cpp 2004-11-21 05:26:40.000000000 -0500
+++ b/src/menu.cpp 2009-10-16 09:29:02.000000000 -0400
@@ -92,7 +92,7 @@
// Helper function which returns a key name in upper case
-char *key_name(int key) {
+const char *key_name(int key) {
if(key != -1) {
// Get the key name from SDL
diff -Naur a/src/mpak.cpp b/src/mpak.cpp
--- a/src/mpak.cpp 2004-09-27 05:28:22.000000000 -0400
+++ b/src/mpak.cpp 2009-10-16 09:31:31.000000000 -0400
@@ -102,7 +102,7 @@
// Compute the CRC for a file
-UINT32 mpk_crc_file(char *file, UINT32 pos) {
+UINT32 mpk_crc_file(const char *file, UINT32 pos) {
// Initial CRC
UINT32 crc = 0xFFFFFFFFL;
@@ -172,7 +172,7 @@
// This helper function returns the filename without full path.
// Pass a full path.
-char *mpk_strip_path(char *path) {
+char *mpk_strip_path(const char *path) {
int pos = strlen(path);
while(pos > 0) {
@@ -218,7 +218,7 @@
// Open a package for reading or writing. You don't need to supply
// the override directory, but it's recommended for reading mode.
// Returns zero on failure.
-int MPAK_FILE::open_mpk(int open_mode, char *file, char *override) {
+int MPAK_FILE::open_mpk(int open_mode, const char *file, const char *override) {
// Check if it's already open
if(mode != MPAK_CLOSED)
@@ -402,7 +402,7 @@
// Add a file to the package.
// Returns zero on failure.
-int MPAK_FILE::add_file(char *file) {
+int MPAK_FILE::add_file(const char *file) {
// Check that we're in write mode
if(mode != MPAK_WRITE)
@@ -450,7 +450,7 @@
// from the override directory, and if the file isn't there it looks
// from the package. The user MUST fclose() the pointer himself!
// Returns NULL on failure.
-FILE *MPAK_FILE::open_file(char *file) {
+FILE *MPAK_FILE::open_file(const char *file) {
// Check that we're in read mode
if(mode != MPAK_READ)
@@ -501,7 +501,7 @@
// You can supply optional path prefix if you don't want to extract to the
// working directory.
// Returns zero on failure.
-int MPAK_FILE::extract_file(char *file, char *path) {
+int MPAK_FILE::extract_file(const char *file, const char *path) {
// Retrieve the pointer from open_file()
FILE *fin = open_file(file);
@@ -551,7 +551,7 @@
// Find the index of a particular file in the package.
// Returns -1 on failure.
-int MPAK_FILE::find_file(char *file) {
+int MPAK_FILE::find_file(const char *file) {
// Check that we're open
if(mode == MPAK_CLOSED)
return -1;
diff -Naur a/src/screenshot.cpp b/src/screenshot.cpp
--- a/src/screenshot.cpp 2004-09-27 05:38:16.000000000 -0400
+++ b/src/screenshot.cpp 2009-10-16 08:28:22.000000000 -0400
@@ -46,11 +46,11 @@
// Save an array of pixels to a TGA file
-void save_tga(char *filename, short int w, short int h, unsigned char *image_data);
+void save_tga(const char *filename, short int w, short int h, unsigned char *image_data);
// Check if a file exists
-bool file_exists(char *file) {
+bool file_exists(const char *file) {
FILE *f = fopen(file, "rb");
if(!f)
return false;
@@ -105,7 +105,7 @@
// Save an array of pixels to a TGA file
// Written using OpenGL Game Programming - book as a reference
-void save_tga(char *filename, short int w, short int h, unsigned char *image_data) {
+void save_tga(const char *filename, short int w, short int h, unsigned char *image_data) {
unsigned char byte_skip; // Used to fill in the data fields that we don't care about
short int short_skip;
diff -Naur a/src/soundmusic.cpp b/src/soundmusic.cpp
--- a/src/soundmusic.cpp 2004-11-21 05:18:29.000000000 -0500
+++ b/src/soundmusic.cpp 2009-10-16 08:28:34.000000000 -0400
@@ -168,7 +168,7 @@
// This helper function loads a sound and stores it to the sound array
static int cur_sound = 0;
-void load_sound(char *file) {
+void load_sound(const char *file) {
if(cur_sound > NUM_SOUNDS-1)
error_msg("load_sounds():\nTrying to load too many sounds!\nNUM_SOUNDS is defined as %d.\n", NUM_SOUNDS);
@@ -257,7 +257,7 @@
// Play music
-void play_music(char *file) {
+void play_music(const char *file) {
if(!config.sound || !config.music_vol)
return;
diff -Naur a/src/texture.cpp b/src/texture.cpp
--- a/src/texture.cpp 2004-11-20 13:49:22.000000000 -0500
+++ b/src/texture.cpp 2009-10-16 09:28:00.000000000 -0400
@@ -67,13 +67,13 @@
// Load a PNG
-GLuint load_png(char *file, bool alpha, bool repeat, bool mipmaps) {
+GLuint load_png(const char *file, bool alpha, bool repeat, bool mipmaps) {
return load_texture(file, "PNG", alpha, repeat, mipmaps);
}
// Load a JPG
-GLuint load_jpg(char *file, bool alpha, bool repeat, bool mipmaps) {
+GLuint load_jpg(const char *file, bool alpha, bool repeat, bool mipmaps) {
return load_texture(file, "JPG", alpha, repeat, mipmaps);
}
@@ -84,9 +84,10 @@
// If repeat == true -> texture can be tiled
// If mipmaps == true -> Mipmaps will be generated
// Return texture ID
-GLuint load_texture(char *file, char *img_type, bool alpha, bool repeat, bool mipmaps) {
+GLuint load_texture(const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps) {
GLuint tex;
+ char itype[5];
// Load the 'file' to SDL_Surface
SDL_Surface *img = NULL;
@@ -98,7 +99,8 @@
SDL_RWops *rw;
rw = SDL_RWFromFP(fin, 1);
- img = IMG_LoadTyped_RW(rw,0, img_type);
+ strcpy(itype, img_type);
+ img = IMG_LoadTyped_RW(rw,0, itype);
if(img == NULL)
error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
SDL_FreeRW(rw);
@@ -187,9 +189,10 @@
// Same as load_texture(), but loads into a specified texture index
-void load_texture_into(GLuint tex, char *file, char *img_type, bool alpha, bool repeat, bool mipmaps) {
+void load_texture_into(GLuint tex, const char *file, const char *img_type, bool alpha, bool repeat, bool mipmaps) {
// Load the 'file' to SDL_Surface
SDL_Surface *img = NULL;
+ char itype[5];
FILE *fin = pakfile.open_file(file);
if(!fin)
@@ -197,7 +200,8 @@
SDL_RWops *rw;
rw = SDL_RWFromFP(fin, 1);
- img = IMG_LoadTyped_RW(rw,0, img_type);
+ strcpy(itype, img_type);
+ img = IMG_LoadTyped_RW(rw,0, itype);
if(img == NULL)
error_msg("Unable to load texture from %s!\n%s", file, IMG_GetError());
SDL_FreeRW(rw);
diff -Naur a/src/tilemap.cpp b/src/tilemap.cpp
--- a/src/tilemap.cpp 2004-09-27 05:28:22.000000000 -0400
+++ b/src/tilemap.cpp 2009-10-16 08:29:06.000000000 -0400
@@ -416,7 +416,7 @@
// Save the map to a file
-void save_map(char *file) {
+void save_map(const char *file) {
#ifdef EDITOR
// Open the file
FILE *f = fopen(file, "wb");
@@ -466,7 +466,7 @@
// Load the map from a file
-void load_map(char *file) {
+void load_map(const char *file) {
#ifndef EDITOR
// Load the level from the pakfile
FILE *f = pakfile.open_file(file);
|