From 025077c7cd81f077b83674a5e9b5f00575c8d933 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Mon, 8 Feb 2010 08:09:13 +0000 Subject: [PATCH] const-char warning fixes --- include/2d.h | 16 ++--- include/3d.h | 2 +- include/ai.h | 6 +- include/aigoals.h | 18 +++--- include/animplay.h | 6 +- include/asteroid.h | 2 +- include/audiostr.h | 2 +- include/bmpman.h | 6 +- include/cfile.h | 48 +++++++-------- include/cfilesystem.h | 8 +-- include/chatbox.h | 2 +- include/controlsconfig.h | 12 ++-- include/cutscenes.h | 4 +- include/demo.h | 8 +-- include/emp.h | 4 +- include/eventmusic.h | 4 +- include/font.h | 4 +- include/freespace.h | 12 ++-- include/gamesequence.h | 4 +- include/hud.h | 8 +-- include/hudconfig.h | 6 +- include/hudgauges.h | 2 +- include/hudmessage.h | 14 ++--- include/hudsquadmsg.h | 2 +- include/hudtarget.h | 4 +- include/managepilot.h | 6 +- include/missionbrief.h | 2 +- include/missionbriefcommon.h | 2 +- include/missioncampaign.h | 32 +++++----- include/missiongoals.h | 2 +- include/missionlog.h | 8 +-- include/missionmessage.h | 6 +- include/missionparse.h | 46 +++++++------- include/missionscreencommon.h | 8 +-- include/model.h | 2 +- include/movie.h | 4 +- include/multi_log.h | 4 +- include/multi_pmsg.h | 4 +- include/multi_rate.h | 2 +- include/multimsgs.h | 6 +- include/multiteamselect.h | 2 +- include/multiui.h | 6 +- include/multiutil.h | 14 ++--- include/mvelib.h | 4 +- include/nebula.h | 4 +- include/object.h | 2 +- include/optionsmenu.h | 8 +-- include/osapi.h | 4 +- include/osregistry.h | 28 ++++----- include/outwnd.h | 4 +- include/palman.h | 4 +- include/parselo.h | 52 ++++++++-------- include/player.h | 4 +- include/popup.h | 4 +- include/pstypes.h | 28 ++++----- include/sexp.h | 10 ++-- include/ship.h | 16 ++--- include/snazzyui.h | 4 +- include/stand_gui.h | 22 +++---- include/starfield.h | 6 +- include/ui.h | 51 ++++++++-------- include/uidefs.h | 2 +- include/version.h | 2 +- include/weapon.h | 4 +- src/anim/animplay.cpp | 6 +- src/bmpman/bmpman.cpp | 8 +-- src/cfile/cfile.cpp | 40 ++++++------- src/cfile/cfilesystem.cpp | 32 +++++----- src/cmdline/cmdline.cpp | 14 ++--- src/controlconfig/controlsconfig.cpp | 12 ++-- src/controlconfig/controlsconfigcommon.cpp | 28 ++++----- src/cutscene/cutscenes.cpp | 10 ++-- src/debris/debris.cpp | 2 +- src/debugconsole/console.cpp | 12 ++-- src/demo/demo.cpp | 10 ++-- src/freespace2/freespace.cpp | 24 ++++---- src/freespace2/unixmain.cpp | 3 + src/gamehelp/contexthelp.cpp | 4 +- src/gamehelp/gameplayhelp.cpp | 12 ++-- src/gamesequence/gamesequence.cpp | 4 +- src/gamesnd/eventmusic.cpp | 8 +-- src/gamesnd/gamesnd.cpp | 2 +- src/globalincs/systemvars.cpp | 4 +- src/globalincs/version.cpp | 2 +- src/graphics/2d.cpp | 4 +- src/graphics/font.cpp | 16 ++--- src/graphics/gropengl.cpp | 6 +- src/hud/hud.cpp | 22 +++---- src/hud/hudconfig.cpp | 30 +++++----- src/hud/hudescort.cpp | 2 +- src/hud/hudmessage.cpp | 26 ++++---- src/hud/hudsquadmsg.cpp | 16 ++--- src/hud/hudtarget.cpp | 10 ++-- src/hud/hudtargetbox.cpp | 8 +-- src/hud/hudwingmanstatus.cpp | 4 +- src/io/keycontrol.cpp | 20 +++---- src/localization/localize.cpp | 8 +-- src/menuui/barracks.cpp | 17 +++--- src/menuui/credits.cpp | 21 +++---- src/menuui/fishtank.cpp | 4 +- src/menuui/mainhallmenu.cpp | 6 +- src/menuui/mainhalltemp.cpp | 4 +- src/menuui/optionsmenu.cpp | 12 ++-- src/menuui/optionsmenumulti.cpp | 12 ++-- src/menuui/playermenu.cpp | 25 ++++---- src/menuui/readyroom.cpp | 34 +++++------ src/menuui/snazzyui.cpp | 4 +- src/menuui/techmenu.cpp | 16 ++--- src/mission/missionbriefcommon.cpp | 2 +- src/mission/missioncampaign.cpp | 66 ++++++++++---------- src/mission/missiongoals.cpp | 10 ++-- src/mission/missionhotkey.cpp | 18 +++--- src/mission/missionload.cpp | 2 +- src/mission/missionlog.cpp | 58 ++++++++++-------- src/mission/missionmessage.cpp | 18 +++--- src/mission/missionparse.cpp | 62 +++++++++---------- src/mission/missiontraining.cpp | 4 +- src/missionui/chatbox.cpp | 34 +++++------ src/missionui/missionbrief.cpp | 28 ++++----- src/missionui/missioncmdbrief.cpp | 6 +- src/missionui/missiondebrief.cpp | 22 +++---- src/missionui/missionloopbrief.cpp | 4 +- src/missionui/missionpause.cpp | 14 ++--- src/missionui/missionscreencommon.cpp | 4 +- src/missionui/missionshipchoice.cpp | 10 ++-- src/missionui/missionweaponchoice.cpp | 16 ++--- src/missionui/redalert.cpp | 6 +- src/model/modelread.cpp | 6 +- src/movie/movie.cpp | 4 +- src/movie/mvelib.cpp | 4 +- src/network/multi_dogfight.cpp | 4 +- src/network/multi_ingame.cpp | 6 +- src/network/multi_log.cpp | 4 +- src/network/multi_pinfo.cpp | 4 +- src/network/multi_pmsg.cpp | 8 +-- src/network/multi_rate.cpp | 2 +- src/network/multi_team.cpp | 4 +- src/network/multimsgs.cpp | 8 +-- src/network/multiteamselect.cpp | 12 ++-- src/network/multiui.cpp | 66 ++++++++++---------- src/network/multiutil.cpp | 16 ++--- src/network/psnet2.cpp | 2 +- src/network/stand_gui-unix.cpp | 16 ++--- src/object/collideweaponweapon.cpp | 2 +- src/object/object.cpp | 2 +- src/osapi/os_unix.cpp | 4 +- src/osapi/osregistry-unix.cpp | 62 +++++++++---------- src/osapi/outwnd_unix.cpp | 10 ++-- src/palman/palman.cpp | 8 +-- src/parse/parselo.cpp | 70 +++++++++++----------- src/parse/sexp.cpp | 10 ++-- src/platform/unix.cpp | 12 ++-- src/playerman/managepilot.cpp | 12 ++-- src/playerman/playercontrol.cpp | 2 +- src/popup/popup.cpp | 36 +++++------ src/popup/popupdead.cpp | 6 +- src/render/3dsetup.cpp | 2 +- src/ship/ai.cpp | 2 +- src/ship/aicode.cpp | 10 ++-- src/ship/aigoals.cpp | 24 ++++---- src/ship/shield.cpp | 2 +- src/ship/ship.cpp | 18 +++--- src/sound/audiostr-openal.cpp | 10 ++-- src/starfield/nebula.cpp | 6 +- src/starfield/starfield.cpp | 6 +- src/stats/medals.cpp | 4 +- src/ui/button.cpp | 2 +- src/ui/checkbox.cpp | 2 +- src/ui/gadget.cpp | 4 +- src/ui/icon.cpp | 2 +- src/ui/inputbox.cpp | 8 +-- src/ui/listbox.cpp | 2 +- src/ui/radio.cpp | 2 +- src/ui/scroll.cpp | 6 +- src/ui/slider.cpp | 8 +-- src/ui/slider2.cpp | 2 +- src/ui/uidraw.cpp | 2 +- src/ui/window.cpp | 12 ++-- src/weapon/emp.cpp | 6 +- src/weapon/shockwave.cpp | 2 +- src/weapon/weapons.cpp | 4 +- 181 files changed, 1060 insertions(+), 1061 deletions(-) diff --git a/include/2d.h b/include/2d.h index 8a5a797..3b94e2d 100644 --- a/include/2d.h +++ b/include/2d.h @@ -465,7 +465,7 @@ typedef struct screen { void (*gf_rect)(int x, int y, int w, int h); void (*gf_shade)(int x, int y, int w, int h); - void (*gf_string)(int x, int y, char * text); + void (*gf_string)(int x, int y, const char * text); // Draw a gradient line... x1,y1 is bright, x2,y2 is transparent. void (*gf_gradient)(int x1, int y1, int x2, int y2); @@ -494,7 +494,7 @@ typedef struct screen { void (*gf_tmapper)(int nv, vertex *verts[], uint flags ); // dumps the current screen to a file - void (*gf_print_screen)(char * filename); + void (*gf_print_screen)(const char * filename); // Call once before rendering anything. void (*gf_start_frame)(); @@ -604,25 +604,25 @@ extern screen gr_screen; // it will return the same font number both times. This font is // then set to be the current font, and default font if none is // yet specified. -int gr_init_font( char * typeface ); +int gr_init_font( const char * typeface ); // Does formatted printing. This calls gr_string after formatting, // so if you don't need to format the string, then call gr_string // directly. -extern void _cdecl gr_printf( int x, int y, char * format, ... ); +extern void _cdecl gr_printf( int x, int y, const char * format, ... ); // Returns the size of the string in pixels in w and h -extern void gr_get_string_size( int *w, int *h, char * text, int len = 9999 ); +extern void gr_get_string_size( int *w, int *h, const char * text, int len = 9999 ); // Returns the height of the current font extern int gr_get_font_height(); -extern void gr_set_palette(char *name, ubyte *palette, int restrict_to_128 = 0); +extern void gr_set_palette(const char *name, ubyte *palette, int restrict_to_128 = 0); // These two functions use a Windows mono font. Only for use // in the editor, please. -void gr_get_string_size_win(int *w, int *h, char *text); -void gr_string_win(int x, int y, char *s ); +void gr_get_string_size_win(int *w, int *h, const char *text); +void gr_string_win(int x, int y, const char *s ); // set the mouse pointer to a specific bitmap, used for animating cursors #define GR_CURSOR_LOCK 1 diff --git a/include/3d.h b/include/3d.h index bd8abc5..ed8208f 100644 --- a/include/3d.h +++ b/include/3d.h @@ -139,7 +139,7 @@ #define g3_start_frame(zbuffer_flag) g3_start_frame_func(zbuffer_flag, __FILE__, __LINE__ ) // use the g3_start_frame macro instead of calling this directly. -extern void g3_start_frame_func(int zbuffer_flag, char * filename, int lineno); +extern void g3_start_frame_func(int zbuffer_flag, const char * filename, int lineno); //set view from x,y,z & p,b,h, zoom. Must call one of g3_set_view_*() diff --git a/include/ai.h b/include/ai.h index da54004..c08f88e 100644 --- a/include/ai.h +++ b/include/ai.h @@ -249,7 +249,7 @@ typedef struct ai_goals { int flags; // one of the AIGF_* values above fix time; // time at which this goal was issued. int priority; // how important is this goal -- number 0 - 100 - char *ship_name; // name of the ship that this goal acts upon + const char *ship_name; // name of the ship that this goal acts upon int ship_name_index; // index of ship_name in Goal_ship_names[][] int wp_index; // index into waypoints list of waypoints that this ship might fly. int weapon_signature; // signature of weapon this ship might be chasing. Paired with above value to get target. @@ -602,7 +602,7 @@ extern char *Ai_class_names[]; extern int Num_ai_classes; extern int Ai_firing_enabled; -extern char *Skill_level_names(int skill_level, int translate = 1); +extern const char *Skill_level_names(int skill_level, int translate = 1); extern int Skill_level_max_attackers[NUM_SKILL_LEVELS]; extern int Ai_goal_signature; @@ -629,7 +629,7 @@ void ai_process( object * obj, int ai_index, float frametime ); int get_wingnum(int objnum); void set_wingnum(int objnum, int wingnum); -char *ai_get_goal_ship_name(char *name, int *index); +char *ai_get_goal_ship_name(const char *name, int *index); extern waypoint_list Waypoint_lists[MAX_WAYPOINT_LISTS]; extern int Num_waypoint_lists; diff --git a/include/aigoals.h b/include/aigoals.h index bb6b445..b6491ec 100644 --- a/include/aigoals.h +++ b/include/aigoals.h @@ -197,7 +197,7 @@ extern int Num_ai_dock_names; extern char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH]; -extern char *Ai_goal_text(int goal); +extern const char *Ai_goal_text(int goal); // extern function definitions extern void ai_post_process_mission(); @@ -210,8 +210,8 @@ extern void ai_add_wing_goal_sexp( int sexp, int type, int wingnum ); extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp ); // adds goals to ships/sings through player orders -extern void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip ); -extern void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum ); +extern void ai_add_ship_goal_player( int type, int mode, int submode, const char *shipname, ai_info *aip ); +extern void ai_add_wing_goal_player( int type, int mode, int submode, const char *shipname, int wingnum ); extern void ai_remove_ship_goal( ai_info *aip, int index ); extern void ai_clear_ship_goals( ai_info *aip ); @@ -222,16 +222,16 @@ extern void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip ); extern void ai_mission_goal_complete( ai_info *aip ); extern void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp ); -extern int ai_get_subsystem_type( char *subsystem ); +extern int ai_get_subsystem_type( const char *subsystem ); extern char *ai_get_subsystem_type_name(int type); -extern void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *new_name); -extern int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name); -extern char *ai_add_dock_name(char *str); +extern void ai_update_goal_references(ai_goal *goals, int type, const char *old_name, char *new_name); +extern int query_referenced_in_ai_goals(ai_goal *goals, int type, const char *name); +extern char *ai_add_dock_name(const char *str); extern int ai_query_goal_valid( int ship, int ai_goal ); -extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate = 1 ); -extern void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate = 1 ); +extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, const char *name, int docker_point, int dockee_point, int immediate = 1 ); +extern void ai_add_goal_wing_internal( wing *wingp, int goal_type, const char *name, int immediate = 1 ); #endif diff --git a/include/animplay.h b/include/animplay.h index a8e2383..15d602f 100644 --- a/include/animplay.h +++ b/include/animplay.h @@ -136,11 +136,11 @@ int anim_stop_playing(anim_instance* anim_instance); int anim_show_next_frame(anim_instance *instance, float frametime); void anim_release_all_instances(int screen_id = 0); void anim_release_render_instance(anim_instance* instance); -anim *anim_load(char *name, int file_mapped = 0); +anim *anim_load(const char *name, int file_mapped = 0); int anim_free(anim *ptr); int anim_playing(anim_instance *ai); -int anim_write_frames_out(char *filename); -void anim_display_info(char *filename); +int anim_write_frames_out(const char *filename); +void anim_display_info(const char *filename); void anim_read_header(anim *ptr, CFILE *fp); void anim_reverse_direction(anim_instance *ai); // called automatically for ping-ponging, and can also be called externally void anim_pause(anim_instance *ai); diff --git a/include/asteroid.h b/include/asteroid.h index 088b743..1dd0a2c 100644 --- a/include/asteroid.h +++ b/include/asteroid.h @@ -161,7 +161,7 @@ struct collision_info_struct; typedef struct debris_struct { int index; - char *name; + const char *name; } debris_struct; // Data structure to track the active asteroids diff --git a/include/audiostr.h b/include/audiostr.h index b0db041..324a0f7 100644 --- a/include/audiostr.h +++ b/include/audiostr.h @@ -102,7 +102,7 @@ void audiostream_init(); void audiostream_close(); // Opens a wave file but doesn't play it. -int audiostream_open( char * filename, int type ); +int audiostream_open( const char * filename, int type ); // Closes the opened wave file. This doesn't have to be // called between songs, because when you open the next diff --git a/include/bmpman.h b/include/bmpman.h index 7e7b502..edda9bd 100644 --- a/include/bmpman.h +++ b/include/bmpman.h @@ -184,12 +184,12 @@ extern int bm_texture_ram; // It returns a negative number if it couldn't load // the bitmap. On success, it returns the bitmap // number. -int bm_load(char * filename); +int bm_load(const char * filename); // special load function. basically allows you to load a bitmap which already exists (by filename). // this is useful because in some cases we need to have a bitmap which is locked in screen format // _and_ texture format, such as pilot pics and squad logos -int bm_load_duplicate(char *filename); +int bm_load_duplicate(const char *filename); // Creates a bitmap that exists in RAM somewhere, instead // of coming from a disk file. You pass in a pointer to a @@ -215,7 +215,7 @@ void bm_release(int n); // It returns a negative number if it couldn't load // the bitmap. On success, it returns the bitmap // number of the first frame and nframes is set. -extern int bm_load_animation( char * filename, int * nframes, int *fps = NULL, int can_drop_frames = 0 ); +extern int bm_load_animation( const char * filename, int * nframes, int *fps = NULL, int can_drop_frames = 0 ); // This locks down a bitmap and returns a pointer to a bitmap // that can be accessed until you call bm_unlock. Only lock diff --git a/include/cfile.h b/include/cfile.h index de134b8..100bf9f 100644 --- a/include/cfile.h +++ b/include/cfile.h @@ -428,7 +428,7 @@ typedef struct { // callback function used for get_file_list() to filter files to be added to list. Return 1 // to add file to list, or 0 to not add it. -extern int (*Get_file_list_filter)(char *filename); +extern int (*Get_file_list_filter)(const char *filename); // cfile directory. valid after cfile_init() returns successfully #define CFILE_ROOT_DIRECTORY_LEN 256 @@ -439,7 +439,7 @@ extern char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN]; //================= LOW-LEVEL FUNCTIONS ================== // Call this once at the beginning of the program -int cfile_init(char *exe_dir,char *cdrom_dir=NULL); +int cfile_init(const char *exe_dir, const char *cdrom_dir=NULL); // Call this if pack files got added or removed or the // cdrom changed. This will refresh the list of filenames @@ -447,14 +447,14 @@ int cfile_init(char *exe_dir,char *cdrom_dir=NULL); void cfile_refresh(); // add an extension to a filename if it doesn't already have it -char *cf_add_ext(char *filename, char *ext); +char *cf_add_ext(const char *filename, const char *ext); // return CF_TYPE (directory location type) of a CFILE you called cfopen() successfully on. int cf_get_dir_type(CFILE *cfile); // Opens the file. If no path is given, use the extension to look into the // default path. If mode is NULL, delete the file. -CFILE *cfopen(char *filename, char *mode, int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false); +CFILE *cfopen(const char *filename, const char *mode, int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false); // Flush the open file buffer int cflush(CFILE *cfile); @@ -464,13 +464,13 @@ int cflush(CFILE *cfile); void cf_set_version( CFILE * cfile, int version ); // Deletes a file. -void cf_delete( char *filename, int dir_type ); +void cf_delete( const char *filename, int dir_type ); // Same as _access function to read a file's access bits -int cf_access( char *filename, int dir_type, int mode ); +int cf_access( const char *filename, int dir_type, int mode ); // Returns 1 if file exists, 0 if not. -int cf_exist( char *filename, int dir_type ); +int cf_exist( const char *filename, int dir_type ); // ctmpfile() opens a temporary file stream. File is deleted automatically when closed CFILE *ctmpfile(); @@ -485,7 +485,7 @@ int cfilelength(CFILE *fp); int cfread(void *buf, int elsize, int nelem, CFILE *fp); // cfwrite() writes to the file -int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile); +int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile); // Reads/writes RLE compressed data. int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile); @@ -501,7 +501,7 @@ int cftell(CFILE *fp); int cfputc(int c, CFILE *cfile); // cfputs() writes a string to a file -int cfputs(char *str, CFILE *cfile); +int cfputs(const char *str, CFILE *cfile); // cfgetc() reads a character to a file int cfgetc(CFILE *cfile); @@ -516,14 +516,14 @@ int cfeof(CFILE *cfile); void *cf_returndata(CFILE *cfile); // get the 2 byte checksum of the passed filename - return 0 if operation failed, 1 if succeeded -int cf_chksum_short(char *filename, ushort *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY ); +int cf_chksum_short(const char *filename, ushort *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY ); // get the 2 byte checksum of the passed file - return 0 if operation failed, 1 if succeeded // NOTE : preserves current file position int cf_chksum_short(CFILE *file, ushort *chksum, int max_size = -1); // get the 32 bit CRC checksum of the passed filename - return 0 if operation failed, 1 if succeeded -int cf_chksum_long(char *filename, uint *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY ); +int cf_chksum_long(const char *filename, uint *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY ); // get the 32 bit CRC checksum of the passed file - return 0 if operation failed, 1 if succeeded // NOTE : preserves current file position @@ -532,24 +532,24 @@ int cf_chksum_long(CFILE *file, uint *chksum, int max_size = -1); // convenient for misc checksumming purposes ------------------------------------------ // update cur_chksum with the chksum of the new_data of size new_data_size -ushort cf_add_chksum_short(ushort seed, char *buffer, int size); +ushort cf_add_chksum_short(ushort seed, const char *buffer, int size); // update cur_chksum with the chksum of the new_data of size new_data_size -unsigned long cf_add_chksum_long(unsigned long seed, char *buffer, int size); +unsigned long cf_add_chksum_long(unsigned long seed, const char *buffer, int size); // convenient for misc checksumming purposes ------------------------------------------ //================= HIGH LEVEL FUNCTIONS ================== -int cfexist(char *filename); // Returns true if file exists on disk (1) or in hog (2). +int cfexist(const char *filename); // Returns true if file exists on disk (1) or in hog (2). // rename a file, utilizing the extension to determine where file is. #define CF_RENAME_SUCCESS 0 // successfully renamed the file #define CF_RENAME_FAIL_ACCESS 1 // new name could not be created #define CF_RENAME_FAIL_EXIST 2 // old name does not exist -int cf_rename(char *old_name, char *name, int type = CF_TYPE_ANY ); +int cf_rename(const char *old_name, const char *name, int type = CF_TYPE_ANY ); // changes the attributes of a file -void cf_attrib(char *name, int set, int clear, int type); +void cf_attrib(const char *name, int set, int clear, int type); // flush (delete all files in) the passed directory (by type), return the # of files deleted // NOTE : WILL NOT DELETE READ-ONLY FILES @@ -558,8 +558,6 @@ int cfile_flush_dir(int type); // functions for reading from cfile // These are all high level, built up from // cfread. -int cfgetc(CFILE *fp); -char *cfgets(char *buf, size_t n, CFILE *fp); char cfread_char(CFILE *file, int ver = 0, char deflt = 0); ubyte cfread_ubyte(CFILE *file, int ver = 0, ubyte deflt = 0); short cfread_short(CFILE *file, int ver = 0, short deflt = 0); @@ -572,10 +570,10 @@ void cfread_angles(angles *ang, CFILE *file, int ver = 0, angles *deflt = NULL); // Reads variable length, null-termined string. Will only read up // to n characters. -void cfread_string(char *buf,int n, CFILE *file); +void cfread_string(char *buf, int n, CFILE *file); // Read a fixed length that is null-terminatedm, and has the length // stored in file -void cfread_string_len(char *buf,int n, CFILE *file); +void cfread_string_len(char *buf, int n, CFILE *file); // functions for writing cfiles int cfwrite_char(char c, CFILE *file); @@ -589,14 +587,14 @@ int cfwrite_vector(vector *vec, CFILE *file); int cfwrite_angles(angles *ang, CFILE *file); // writes variable length, null-termined string. -int cfwrite_string(char *buf, CFILE *file); +int cfwrite_string(const char *buf, CFILE *file); // write a fixed length that is null-terminatedm, and has the length // stored in file -int cfwrite_string_len(char *buf, CFILE *file); +int cfwrite_string_len(const char *buf, CFILE *file); -int cf_get_file_list( int max, char **list, int type, char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL ); -int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int type, char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL ); +int cf_get_file_list( int max, char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL ); +int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL ); void cf_sort_filenames( int n, char **list, int sort, file_list_info *info = NULL ); // Searches for a file. Follows all rules and precedence and searches @@ -607,7 +605,7 @@ void cf_sort_filenames( int n, char **list, int sort, file_list_info *info = NUL // size - File size // offset - Offset into pack file. 0 if not a packfile. // Returns: If not found returns 0. -int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, int *size, int *offset, bool localize = false); +int cf_find_file_location( const char *filespec, int pathtype, char *pack_filename, int *size, int *offset, bool localize = false); // Functions to change directories int cfile_chdir(char *dir); diff --git a/include/cfilesystem.h b/include/cfilesystem.h index 02e0e3f..ca34bb5 100644 --- a/include/cfilesystem.h +++ b/include/cfilesystem.h @@ -55,14 +55,14 @@ #define _CFILESYSTEM_H // Builds a list of all the files -void cf_build_secondary_filelist( char *cdrom_path ); +void cf_build_secondary_filelist( const char *cdrom_path ); void cf_free_secondary_filelist(); // Internal stuff typedef struct cf_pathtype { int index; // To verify that the CF_TYPE define is correctly indexed into this array - char *path; // Path relative to Freespace root, has ending backslash. - char *extensions; // Extensions used in this pathtype, separated by spaces + const char *path; // Path relative to Freespace root, has ending backslash. + const char *extensions; // Extensions used in this pathtype, separated by spaces int parent_index; // Index of this directory's parent. Used for creating directories when writing. } cf_pathtype; @@ -77,7 +77,7 @@ extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES]; // Input: pathtype - CF_TYPE_?? // filename - optional, if set, tacks the filename onto end of path. // Output: path - Fully qualified pathname. -void cf_create_default_path_string( char *path, int pathtype, char *filename=NULL, bool localize = false); +void cf_create_default_path_string( char *path, int pathtype, const char *filename=NULL, bool localize = false); #endif //_CFILESYSTEM_H diff --git a/include/chatbox.h b/include/chatbox.h index d401d36..a74d1f0 100644 --- a/include/chatbox.h +++ b/include/chatbox.h @@ -126,7 +126,7 @@ int chatbox_scroll_down(); void chatbox_clear(); // add a line of text (from the player identified by pid) to the chatbox -void chatbox_add_line(char *msg,int pid,int add_id = 1); +void chatbox_add_line(const char *msg, int pid, int add_id = 1); // force the chatbox to go into small mode (if its in large mode) - will not wotk if in multi paused chatbox mode void chatbox_force_small(); diff --git a/include/controlsconfig.h b/include/controlsconfig.h index a1a9488..289e0c0 100644 --- a/include/controlsconfig.h +++ b/include/controlsconfig.h @@ -295,7 +295,7 @@ typedef struct config_item { short key_default; // default key bound to action short joy_default; // default joystick button bound to action char tab; // what tab (catagory) it belongs in - char *text; // describes the action in the config screen + const char *text; // describes the action in the config screen char type; // manner control should be checked in short key_id; // actual key bound to action short joy_id; // joystick button bound to action @@ -463,8 +463,8 @@ extern int Invert_axis[]; extern int Invert_axis_defaults[]; extern config_item Control_config[]; // stores the keyboard configuration -extern char **Scan_code_text; -extern char **Joy_button_text; +extern const char **Scan_code_text; +extern const char **Joy_button_text; // initialize common control config stuff - call at game startup after localization has been initialized void control_config_common_init(); @@ -476,9 +476,9 @@ void control_config_close(); void control_config_cancel_exit(); void control_config_reset_defaults(); -int translate_key_to_index(char *key); -char *translate_key(char *key); -char *textify_scancode(int code); +int translate_key_to_index(const char *key); +const char *translate_key(const char *key); +const char *textify_scancode(int code); float check_control_timef(int id); int check_control(int id, int key = -1); void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr); diff --git a/include/cutscenes.h b/include/cutscenes.h index 2c85b55..7d66202 100644 --- a/include/cutscenes.h +++ b/include/cutscenes.h @@ -84,8 +84,8 @@ void cutscenes_screen_init(); void cutscenes_screen_close(); void cutscenes_screen_do_frame(); -int cutscenes_validate_cd(char *mve_name, int prompt_for_cd = 1); -void cutscene_mark_viewable(char *filename); +int cutscenes_validate_cd(const char *mve_name, int prompt_for_cd = 1); +void cutscene_mark_viewable(const char *filename); #endif diff --git a/include/demo.h b/include/demo.h index e0f0a9b..82a6866 100644 --- a/include/demo.h +++ b/include/demo.h @@ -70,10 +70,10 @@ int demo_do_frame_end(); // initialize a demo for recording // NOTE : call this after loading the mission and going through the briefing, but _before_ physically moving into the mission -int demo_start_record(char *file); +int demo_start_record(const char *file); // initialize a demo for playback - calling this will load up the demo file and move the player into the playback state -int demo_start_playback(char *file); +int demo_start_playback(const char *file); // finish the demo, whether recording or playing back void demo_close(); @@ -91,13 +91,13 @@ void demo_POST_object_dump(); void demo_POST_primary_fired(object *objp, int banks, int linked); // post a unique message -void demo_POST_unique_message(char *id, char *who_from, int m_source, int priority); +void demo_POST_unique_message(const char *id, const char *who_from, int m_source, int priority); // post a builtin message void demo_POST_builtin_message(int type, ship *shipp, int priority, int timing); // post an object create message -void demo_POST_obj_create(char *pobj_name, int signature); +void demo_POST_obj_create(const char *pobj_name, int signature); // post a warpin event void demo_POST_warpin(int signature, int ship_flags); diff --git a/include/emp.h b/include/emp.h index b782bf7..d379448 100644 --- a/include/emp.h +++ b/include/emp.h @@ -146,10 +146,10 @@ void emp_process_local(); int emp_should_blit_gauge(); // emp hud string -void emp_hud_string(int x, int y, int gauge_id, char *str); +void emp_hud_string(int x, int y, int gauge_id, const char *str); // emp hud printf -void emp_hud_printf(int x, int y, int gauge_id, char *format, ...); +void emp_hud_printf(int x, int y, int gauge_id, const char *format, ...); // throw some jitter into HUD x and y coords void emp_hud_jitter(int *x, int *y); diff --git a/include/eventmusic.h b/include/eventmusic.h index efdfea2..7b501cd 100644 --- a/include/eventmusic.h +++ b/include/eventmusic.h @@ -234,8 +234,8 @@ void event_music_get_info(char *outbuf); void event_music_get_soundtrack_name(char *outbuf); int event_music_next_soundtrack(int delta); void event_music_set_soundtrack(char *name); -void event_music_set_score(int score_index, char *name); -int event_music_get_spooled_music_index(char *name); +void event_music_set_score(int score_index, const char *name); +int event_music_get_spooled_music_index(const char *name); void event_music_reset_choices(); int event_music_player_respawn(); int event_music_player_respawn_as_observer(); diff --git a/include/font.h b/include/font.h index 6d547fd..4b6a58a 100644 --- a/include/font.h +++ b/include/font.h @@ -154,7 +154,7 @@ extern font *Current_font; // extern definitions for basic font functions extern void grx_set_font(int fontnum); -extern void gr8_string(int x,int y,char * text); +extern void gr8_string(int x, int y, const char * text); void gr_print_timestamp(int x, int y, int timestamp); char *gr_force_fit_string(char *str, int max_str, int max_width); @@ -163,7 +163,7 @@ void gr_font_close(); extern font * Current_font; extern int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing); -extern int get_centered_x(char *s); +extern int get_centered_x(const char *s); #endif diff --git a/include/freespace.h b/include/freespace.h index 43a3911..63d7053 100644 --- a/include/freespace.h +++ b/include/freespace.h @@ -309,7 +309,7 @@ bool game_using_low_mem(); // misc --------------------------------------------------------------- // lookup the specified filename. return an fs_builtin_mission* if found, NULL otherwise -fs_builtin_mission *game_find_builtin_mission(char *filename); +fs_builtin_mission *game_find_builtin_mission(const char *filename); @@ -351,11 +351,11 @@ void game_shudder_apply(int time, float intensity); //=================================================================== // make sure a CD is in the drive before continuing (returns 1 to continue, otherwise 0). -int game_do_cd_check(char *volume_name=NULL); -int game_do_cd_check_specific(char *volume_name, int cdnum); -int find_freespace_cd(char *volume_name=NULL); +int game_do_cd_check(const char *volume_name = NULL); +int game_do_cd_check_specific(const char *volume_name, int cdnum); +int find_freespace_cd(const char *volume_name = NULL); int set_cdrom_path(int drive_num); -int game_do_cd_mission_check(char *filename); +int game_do_cd_mission_check(const char *filename); // Used to tell the player that a feature isn't available in the demo version of FreeSpace void game_feature_not_in_demo_popup(); @@ -364,7 +364,7 @@ void game_feature_not_in_demo_popup(); void get_version_string(char *str); // format the specified time (fixed point) into a nice string -void game_format_time(fix m_time,char *time_str); +void game_format_time(fix m_time, char *time_str); // if the game is running using hacked data int game_hacked_data(); diff --git a/include/gamesequence.h b/include/gamesequence.h index af9e284..692f326 100644 --- a/include/gamesequence.h +++ b/include/gamesequence.h @@ -405,7 +405,7 @@ // IMPORTANT: When you add a new event, update the initialization for GS_event_text[] // which is done in GameSequence.cpp // -extern char *GS_event_text[]; // text description for the GS_EVENT_* #defines above +extern const char *GS_event_text[]; // text description for the GS_EVENT_* #defines above // defines for game sequencing states @@ -465,7 +465,7 @@ extern char *GS_event_text[]; // text description for the GS_EVENT_* #defines a // IMPORTANT: When you add a new state, update the initialization for GS_state_text[] // which is done in GameSequence.cpp // -extern char *GS_state_text[]; // text description for the GS_STATE_* #defines above +extern const char *GS_state_text[]; // text description for the GS_STATE_* #defines above // function prototypes diff --git a/include/hud.h b/include/hud.h index a637373..a49c0bf 100644 --- a/include/hud.h +++ b/include/hud.h @@ -341,7 +341,7 @@ void HUD_reset_clip(); void HUD_set_clip(int x, int y, int w, int h); // do flashing text gauge -void hud_start_text_flash(char *txt, int t); +void hud_start_text_flash(const char *txt, int t); // convert a string to use mono spaced numbers void hud_num_make_mono(char *num_str); @@ -350,13 +350,13 @@ void hud_num_make_mono(char *num_str); void hud_end_string_at_first_hash_symbol(char *src); // functions for handling hud animations -void hud_anim_init(hud_anim *ha, int sx, int sy, char *filename); +void hud_anim_init(hud_anim *ha, int sx, int sy, const char *filename); int hud_anim_render(hud_anim *ha, float frametime, int draw_alpha=0, int loop=1, int hold_last=0, int reverse=0); int hud_anim_load(hud_anim *ha); void hud_anim_release(hud_anim *ha); // flash text at the given y -void hud_show_text_flash_icon(char *txt, int y, int bright); +void hud_show_text_flash_icon(const char *txt, int y, int bright); // functions for displaying the support view popup void hud_support_view_start(); @@ -395,7 +395,7 @@ int hud_team_matches_filter(int team_filter, int ship_team); void hud_maybe_clear_head_area(); int hud_wing_index_from_ship(int shipnum); -int hud_wing_slot_from_name(char *name); +int hud_wing_slot_from_name(const char *name); int hud_support_get_dock_time( int objnum ); void hud_show_radar(); void hud_show_target_model(); diff --git a/include/hudconfig.h b/include/hudconfig.h index 297fcb4..3fc114b 100644 --- a/include/hudconfig.h +++ b/include/hudconfig.h @@ -149,7 +149,7 @@ #define RR_LONG 1 #define RR_INFINITY 2 extern float Radar_ranges[RR_MAX_RANGES]; -extern char *Radar_range_text(int range_num); +extern const char *Radar_range_text(int range_num); #define RP_SHOW_DEBRIS (1<<0) #define RP_SHOW_FRIENDLY_MISSILES (1<<1) @@ -195,7 +195,7 @@ void hud_config_as_observer(ship *shipp,ai_info *aif); void hud_config_as_observer(); void hud_config_as_player(); -void hud_config_display_text(char* gauge_text, int x, int y); +void hud_config_display_text(const char* gauge_text, int x, int y); void hud_set_display_gauge_cbox(); // leave hud config without accepting changes @@ -215,7 +215,7 @@ void hud_config_popup_flag_clear(int i); void hud_config_record_color(int color); // load up the given hcf file -void hud_config_color_load(char *name); +void hud_config_color_load(const char *name); #endif diff --git a/include/hudgauges.h b/include/hudgauges.h index 981e8f3..bdbdbb4 100644 --- a/include/hudgauges.h +++ b/include/hudgauges.h @@ -124,7 +124,7 @@ #define HUD_SUPPORT_GAUGE 37 #define HUD_LAG_GAUGE 38 -extern char *HUD_gauge_text[NUM_HUD_GAUGES]; // defined in sexp.cpp!!!! +extern const char *HUD_gauge_text[NUM_HUD_GAUGES]; // defined in sexp.cpp!!!! #endif /* __HUD_COMMON_H__ */ diff --git a/include/hudmessage.h b/include/hudmessage.h index 53a7ff4..bbd0d27 100644 --- a/include/hudmessage.h +++ b/include/hudmessage.h @@ -191,16 +191,16 @@ void hud_init_msg_window(); void hud_show_msg_window(); void hud_show_fixed_text(); int HUD_get_team_source(int team); -void HUD_printf(char *format, ...); +void HUD_printf(const char *format, ...); void hud_sourced_print(int source, char *msg); -void HUD_sourced_printf(int source, char *format, ...); // send hud message from specified source -void HUD_ship_sent_printf(int sh, char *format, ...); // send hud message from a specific ship -void HUD_fixed_printf(float duration, char *format, ...); // Display a single message for duration seconds. +void HUD_sourced_printf(int source, const char *format, ...); // send hud message from specified source +void HUD_ship_sent_printf(int sh, const char *format, ...); // send hud message from a specific ship +void HUD_fixed_printf(float duration, const char *format, ...); // Display a single message for duration seconds. void HUD_init_fixed_text(); // Clear all pending fixed text. -void HUD_add_to_scrollback(char *text, int source); -void hud_add_line_to_scrollback(char *text, int source, int t, int x, int y, int w); -void hud_add_msg_to_scrollback(char *text, int source, int t); +void HUD_add_to_scrollback(const char *text, int source); +void hud_add_line_to_scrollback(const char *text, int source, int t, int x, int y, int w); +void hud_add_msg_to_scrollback(const char *text, int source, int t); void hud_free_scrollback_list(); #endif diff --git a/include/hudsquadmsg.h b/include/hudsquadmsg.h index 61baa66..4d97372 100644 --- a/include/hudsquadmsg.h +++ b/include/hudsquadmsg.h @@ -202,7 +202,7 @@ extern void hud_squadmsg_shortcut( int command ); // use of a shortcut key extern int hud_squadmsg_hotkey_select( int k ); // a hotkey was hit -- maybe send a message to those ship(s) extern void hud_squadmsg_save_keys( int do_scroll = 0 ); // saves into local area keys which need to be saved/restored when in messaging mode extern int hud_squadmsg_do_frame(); -extern int hud_query_order_issued(char *name, char *order, char *target); +extern int hud_query_order_issued(const char *name, const char *order, const char *target); extern int hud_squadmsg_read_key( int k ); // called from high level keyboard code extern void hud_squadmsg_repair_rearm( int toggle_state, object *obj = NULL ); diff --git a/include/hudtarget.h b/include/hudtarget.h index 74175b0..00b0df5 100644 --- a/include/hudtarget.h +++ b/include/hudtarget.h @@ -334,8 +334,8 @@ extern int Hud_target_w, Hud_target_h; extern shader Training_msg_glass; extern char *Ai_class_names[]; -extern char *Submode_text[]; -extern char *Strafe_submode_text[]; +extern const char *Submode_text[]; +extern const char *Strafe_submode_text[]; extern void hud_init_targeting_colors(); diff --git a/include/managepilot.h b/include/managepilot.h index bc8639e..7d1d126 100644 --- a/include/managepilot.h +++ b/include/managepilot.h @@ -144,8 +144,8 @@ void write_string(char *s, CFILE *f); int is_pilot_multi(CFILE *fp); // pass a newly opened (at the beginning) file pointer to the pilot file itself int is_pilot_multi(player *p); // pass a pointer to a player struct -int verify_pilot_file(char *filename, int single = 1, int *rank = NULL); -int read_pilot_file(char* callsign, int single = 1, player *p = NULL); +int verify_pilot_file(const char *filename, int single = 1, int *rank = NULL); +int read_pilot_file(const char* callsign, int single = 1, player *p = NULL); int write_pilot_file(player *p = NULL); // function to get default pilot callsign for game @@ -169,7 +169,7 @@ void pilot_set_random_pic(player *p); void pilot_set_random_squad_pic(player *p); // format a pilot's callsign into a "personal" form - ie, adding a 's or just an ' as appropriate -void pilot_format_callsign_personal(char *in_callsign,char *out_callsign); +void pilot_format_callsign_personal(const char *in_callsign, char *out_callsign); // throw up a popup asking the user to verify the overwrite of an existing pilot name // 1 == ok to overwrite, 0 == not ok diff --git a/include/missionbrief.h b/include/missionbrief.h index cf47c9f..dd1d656 100644 --- a/include/missionbrief.h +++ b/include/missionbrief.h @@ -177,7 +177,7 @@ void brief_turn_off_closeup_icon(); void briefing_stop_music(); void briefing_start_music(); -void briefing_load_music(char* fname); +void briefing_load_music(const char* fname); void brief_stop_voices(); int brief_only_allow_briefing(); diff --git a/include/missionbriefcommon.h b/include/missionbriefcommon.h index 2450e99..2ef3335 100644 --- a/include/missionbriefcommon.h +++ b/include/missionbriefcommon.h @@ -338,7 +338,7 @@ extern int Brief_bmap_coords[GR_NUM_RESOLUTIONS][2]; extern int Brief_grid_coords[GR_NUM_RESOLUTIONS][4]; extern int Brief_text_coords[GR_NUM_RESOLUTIONS][4]; extern int Brief_text_max_lines[GR_NUM_RESOLUTIONS]; -extern char *Brief_static_name[GR_NUM_RESOLUTIONS]; +extern const char *Brief_static_name[GR_NUM_RESOLUTIONS]; extern int Brief_static_coords[GR_NUM_RESOLUTIONS][2]; // Needed for Fred diff --git a/include/missioncampaign.h b/include/missioncampaign.h index 841aa42..02b3d62 100644 --- a/include/missioncampaign.h +++ b/include/missioncampaign.h @@ -320,7 +320,7 @@ #define CAMPAIGN_LOOP_MISSION_UNINITIALIZED -2 -extern char *campaign_types[MAX_CAMPAIGN_TYPES]; +extern const char *campaign_types[MAX_CAMPAIGN_TYPES]; // structure for a campaign definition. It contains the mission names and other interesting // information about a campaign and the mission strucuture within. @@ -402,23 +402,23 @@ extern int Num_campaigns; void mission_campaign_init( void ); // called to reload the default campaign -int mission_campaign_load_by_name( char *filename ); -int mission_campaign_load_by_name_csfe( char *filename, char *callsign ); +int mission_campaign_load_by_name( const char *filename ); +int mission_campaign_load_by_name_csfe( const char *filename, const char *callsign ); // load up and initialize a new campaign -int mission_campaign_load( char *filename, int load_savefile = 1 ); +int mission_campaign_load( const char *filename, int load_savefile = 1 ); // function to save the state of the campaign between missions or to load a campaign save file extern int mission_campaign_save( void ); // declaration for local campaign save game load function -extern void mission_campaign_savefile_load( char *cfilename ); -extern void mission_campaign_savefile_delete( char *cfilename, int is_multi = -1 ); -extern void mission_campaign_delete_all_savefiles( char *pilot_name, int is_multi ); +extern void mission_campaign_savefile_load( const char *cfilename ); +extern void mission_campaign_savefile_delete( const char *cfilename, int is_multi = -1 ); +extern void mission_campaign_delete_all_savefiles( const char *pilot_name, int is_multi ); // if a given campaign is a multiplayer campaign, we can load and save the multiplayer info portion with these functions -extern int mission_campaign_parse_is_multi(char *filename, char *name); +extern int mission_campaign_parse_is_multi(const char *filename, char *name); // function which sets up internal variable for player to play next mission in the campaign extern int mission_campaign_next_mission( void ); @@ -431,7 +431,7 @@ extern void mission_campaign_close( void ); // gets called in more than game cl extern void mission_campaign_shutdown( void ); // only called in game close // read in a campaign file. Used by Fred. -int mission_campaign_load_fred(char *filename, char *name_verify = NULL); +int mission_campaign_load_fred(const char *filename, const char *name_verify = NULL); // used by Fred to get a mission's list of goals. void read_mission_goal_list(int num); @@ -439,7 +439,7 @@ void read_mission_goal_list(int num); void mission_campaign_build_list( int multiplayer ); // returns index of mission with passed name -extern int mission_campaign_find_mission( char *name ); +extern int mission_campaign_find_mission( const char *name ); // maybe play a movie. type indicates before or after mission extern void mission_campaign_maybe_play_movie(int type); @@ -453,17 +453,17 @@ void mission_campaign_savefile_generate_root(char *filename); // execute the corresponding mission_campaign_savefile functions. // Saves the campaign camp under the player name pname -int campaign_savefile_save(char *pname); +int campaign_savefile_save(const char *pname); // Deletes the campaign save camp under the player name pname -void campaign_delete_save( char *cfn, char *pname); +void campaign_delete_save( const char *cfn, const char *pname); // Loads campaign camp from fname under player name pname -void campaign_savefile_load(char *fname, char *pname); +void campaign_savefile_load(const char *fname, const char *pname); // get name and type of specified campaign file -int mission_campaign_get_info(char *filename, char *name, int *type, int *max_players, char **desc = NULL); +int mission_campaign_get_info(const char *filename, char *name, int *type, int *max_players, char **desc = NULL); // get a listing of missions in a campaign -int mission_campaign_get_mission_list(char *filename, char **list, int max); +int mission_campaign_get_mission_list(const char *filename, char **list, int max); // load up a campaign for the current player. int mission_load_up_campaign(); @@ -484,7 +484,7 @@ void mission_campaign_skip_to_next(int start_game = 1); void mission_campaign_exit_loop(); // jump to specified mission -void mission_campaign_jump_to_mission(char *name); +void mission_campaign_jump_to_mission(const char *name); // stuff for the end of the campaign of the single player game void mission_campaign_end_init(); diff --git a/include/missiongoals.h b/include/missiongoals.h index 0bb9cab..7ce7db0 100644 --- a/include/missiongoals.h +++ b/include/missiongoals.h @@ -146,7 +146,7 @@ #define PRIMARY_GOALS_INCOMPLETE 0 #define PRIMARY_GOALS_FAILED -1 -extern char *Goal_type_text(int n); +extern const char *Goal_type_text(int n); // structures for primary and secondary goals diff --git a/include/missionlog.h b/include/missionlog.h index 2e26882..07d4361 100644 --- a/include/missionlog.h +++ b/include/missionlog.h @@ -165,15 +165,15 @@ extern void mission_log_init(); // adds an entry to the mission log. The name is a string identifier that is the object // of the event. The multiplayer version of this takes the actual entry number to modify. -extern void mission_log_add_entry(int type, char *pname, char *sname, int index = -1 ); -extern void mission_log_add_entry_multi( int type, char *pname, char *sname, int index, fix timestamp, int flags ); +extern void mission_log_add_entry(int type, const char *pname, const char *sname, int index = -1 ); +extern void mission_log_add_entry_multi( int type, const char *pname, const char *sname, int index, fix timestamp, int flags ); // function to determine if event happened and what time it happened -extern int mission_log_get_time( int type, char *name, char *sname, fix *time); +extern int mission_log_get_time( int type, const char *name, const char *sname, fix *time); // function to determine if event happend count times and return time that the count event // happened -extern int mission_log_get_time_indexed( int type, char *name, char *sname, int count, fix *time); +extern int mission_log_get_time_indexed( int type, const char *name, const char *sname, int count, fix *time); // function to show all message log entries during or after mission // (code stolen liberally from Alan!) diff --git a/include/missionmessage.h b/include/missionmessage.h index bbf0656..528dcd7 100644 --- a/include/missionmessage.h +++ b/include/missionmessage.h @@ -260,7 +260,7 @@ extern message_extra Message_waves[MAX_MESSAGE_WAVES]; // this number in this define should match the number of elements in the next array #define MAX_BUILTIN_MESSAGE_TYPES 41 -extern char *Builtin_message_types[MAX_BUILTIN_MESSAGE_TYPES]; +extern const char *Builtin_message_types[MAX_BUILTIN_MESSAGE_TYPES]; #define MESSAGE_ARRIVE_ENEMY 0 #define MESSAGE_ATTACK_TARGET 1 @@ -368,14 +368,14 @@ void message_maybe_distort(); int message_anim_is_playing(); void message_kill_all( int kill_all ); -void message_queue_message( int message_num, int priority, int timing, char *who_from, int source, int group, int delay, int builtin_type=-1 ); +void message_queue_message( int message_num, int priority, int timing, const char *who_from, int source, int group, int delay, int builtin_type=-1 ); // functions which send messages to player -- called externally void message_send_unique_to_player( char *id, void *data, int source, int priority, int group, int delay); void message_send_builtin_to_player( int type, ship *shipp, int priority, int timing, int group, int delay, int multi_target, int multi_team_filter ); // functions to deal with personas -int message_persona_name_lookup( char *name ); +int message_persona_name_lookup( const char *name ); // preload mission messages (this is called by the level paging code when running with low memory) void message_pagein_mission_messages(); diff --git a/include/missionparse.h b/include/missionparse.h index a4e47cd..09428fb 100644 --- a/include/missionparse.h +++ b/include/missionparse.h @@ -199,7 +199,7 @@ // maximum number of starting wings for the player #define MAX_STARTING_WINGS 3 -extern char *Starting_wing_names[MAX_STARTING_WINGS+1]; +extern const char *Starting_wing_names[MAX_STARTING_WINGS+1]; #define WING_PLAYER_BASE 0x80000 // used by Fred to tell ship_index in a wing points to a player @@ -308,25 +308,25 @@ extern int Mission_alt_type_count; #endif #define MAX_SPECIAL_ARRIVAL_ANCHORS 6 -extern char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS]; +extern const char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS]; extern char *Ship_class_names[MAX_SHIP_TYPES]; -extern char *Iff_names[MAX_IFF]; -extern char *Ai_behavior_names[MAX_AI_BEHAVIORS]; +extern const char *Iff_names[MAX_IFF]; +extern const char *Ai_behavior_names[MAX_AI_BEHAVIORS]; extern char *Formation_names[MAX_FORMATION_NAMES]; -extern char *Team_names[MAX_TEAM_NAMES]; +extern const char *Team_names[MAX_TEAM_NAMES]; extern int Team_names_index_xlate[MAX_TEAM_NAMES_INDEX+1]; -extern char *Status_desc_names[MAX_STATUS_NAMES]; -extern char *Status_type_names[MAX_STATUS_NAMES]; -extern char *Status_target_names[MAX_STATUS_NAMES]; -extern char *Arrival_location_names[MAX_ARRIVAL_NAMES]; -extern char *Departure_location_names[MAX_ARRIVAL_NAMES]; -extern char *Goal_type_names[MAX_GOAL_TYPE_NAMES]; -extern char *Species_names[MAX_SPECIES_NAMES]; -extern char *Reinforcement_type_names[]; +extern const char *Status_desc_names[MAX_STATUS_NAMES]; +extern const char *Status_type_names[MAX_STATUS_NAMES]; +extern const char *Status_target_names[MAX_STATUS_NAMES]; +extern const char *Arrival_location_names[MAX_ARRIVAL_NAMES]; +extern const char *Departure_location_names[MAX_ARRIVAL_NAMES]; +extern const char *Goal_type_names[MAX_GOAL_TYPE_NAMES]; +extern const char *Species_names[MAX_SPECIES_NAMES]; +extern const char *Reinforcement_type_names[]; extern char *Object_flags[]; -extern char *Parse_object_flags[]; -extern char *Icon_names[]; +extern const char *Parse_object_flags[]; +extern const char *Icon_names[]; extern char *Cargo_names[MAX_CARGO]; extern char Cargo_names_buf[MAX_CARGO][NAME_LENGTH]; @@ -507,15 +507,15 @@ extern p_object Player_start_pobject; extern int Mission_palette; // index of palette file to use for mission extern int Nebula_index; // index into Nebula_filenames[] of nebula to use in mission. -extern char *Nebula_filenames[NUM_NEBULAS]; -extern char *Nebula_colors[NUM_NEBULA_COLORS]; +extern const char *Nebula_filenames[NUM_NEBULAS]; +extern const char *Nebula_colors[NUM_NEBULA_COLORS]; extern p_object *Arriving_support_ship; extern char Neb2_texture_name[MAX_FILENAME_LEN]; -int parse_main(char *mission_name, int flags = 0); -int mission_parse_ship_arrived(char *shipname); -p_object *mission_parse_get_arrival_ship( char *name ); +int parse_main(const char *mission_name, int flags = 0); +int mission_parse_ship_arrived(const char *shipname); +p_object *mission_parse_get_arrival_ship( const char *name ); p_object *mission_parse_get_arrival_ship( ushort net_signature ); p_object *mission_parse_get_original_ship( ushort net_signature ); int parse_create_object(p_object *objp); @@ -524,8 +524,8 @@ int parse_create_object(p_object *objp); int parse_wing_create_ships(wing *wingp, int num_to_create, int force = 0, int specific_instance = -1 ); // function for getting basic mission data without loading whole mission -int mission_parse_is_multi(char *filename, char *mission_name ); -int mission_parse_get_multi_mission_info(char *filename); +int mission_parse_is_multi(const char *filename, char *mission_name ); +int mission_parse_get_multi_mission_info(const char *filename); // called externally from multiplayer code void mission_do_departure(object *objp); @@ -534,7 +534,7 @@ void mission_do_departure(object *objp); void mission_parse_fixup_players(void); // get a index to a perminently kept around name of a ship or wing -int get_parse_name_index(char *name); +int get_parse_name_index(const char *name); // called from freespace game level loop void mission_parse_eval_stuff(); diff --git a/include/missionscreencommon.h b/include/missionscreencommon.h index 05bbe80..05710fa 100644 --- a/include/missionscreencommon.h +++ b/include/missionscreencommon.h @@ -40,14 +40,14 @@ #define NUM_COMMON_BUTTONS 6 struct brief_common_buttons { - char *filename; + const char *filename; int x, y; int xt, yt; int hotspot; int repeat; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - brief_common_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int r = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), repeat(r) {} + brief_common_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h, int r = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), repeat(r) {} }; extern brief_common_buttons Common_buttons[3][GR_NUM_RESOLUTIONS][NUM_COMMON_BUTTONS]; @@ -93,10 +93,10 @@ void common_redraw_pressed_buttons(); void common_maybe_clear_focus(); void ship_select_common_init(); -void common_set_interface_palette(char *filename = NULL); // set the interface palette +void common_set_interface_palette(const char *filename = NULL); // set the interface palette void common_free_interface_palette(); // restore game palette -void load_wing_icons(char *filename); +void load_wing_icons(const char *filename); void unload_wing_icons(); void common_flash_button_init(); diff --git a/include/model.h b/include/model.h index 93ff64e..5a09264 100644 --- a/include/model.h +++ b/include/model.h @@ -721,7 +721,7 @@ void model_level_post_init(); void model_free_all(); // Loads a model from disk and returns the model number it loaded into. -int model_load(char *filename, int n_subsystems, model_subsystem *subsystems); +int model_load(const char *filename, int n_subsystems, model_subsystem *subsystems); // notify the model system that a ship has died void model_notify_dead_ship(int objnum); diff --git a/include/movie.h b/include/movie.h index 9629573..7286e0e 100644 --- a/include/movie.h +++ b/include/movie.h @@ -1,7 +1,7 @@ #ifndef MOVIE_H #define MOVIE_H -int movie_play(char *filename, int unknown = 0); -int movie_play_two(char *filename1, char *filename2); +int movie_play(const char *filename, int unknown = 0); +int movie_play_two(const char *filename1, const char *filename2); #endif diff --git a/include/multi_log.h b/include/multi_log.h index 3f33234..d071d18 100644 --- a/include/multi_log.h +++ b/include/multi_log.h @@ -59,10 +59,10 @@ void multi_log_close(); void multi_log_process(); // printf function itself called by the ml_printf macro -void ml_printf(char *format, ...); +void ml_printf(const char *format, ...); // string print function -void ml_string(char *string, int add_time = 1); +void ml_string(const char *string, int add_time = 1); #endif diff --git a/include/multi_pmsg.h b/include/multi_pmsg.h index 75cd00e..32cfde7 100644 --- a/include/multi_pmsg.h +++ b/include/multi_pmsg.h @@ -105,10 +105,10 @@ int multi_msg_text_mode(); int multi_msg_message_text(char *txt); // display ingame,inmission message text -void multi_msg_display_mission_text(char *msg,int player_index); +void multi_msg_display_mission_text(const char *msg, int player_index); // if the passed net_player's callsign matches the reg expression of the passed expr -int multi_msg_matches_expr(net_player *player,char *expr); +int multi_msg_matches_expr(net_player *player, const char *expr); // if text input mode is active, clear it void multi_msg_text_flush(); diff --git a/include/multi_rate.h b/include/multi_rate.h index c26deb4..769a1ad 100644 --- a/include/multi_rate.h +++ b/include/multi_rate.h @@ -47,7 +47,7 @@ void multi_rate_reset(int np_index); // add data of the specified type to datarate processing, returns 0 on fail (if we ran out of types, etc, etc) -int multi_rate_add(int np_index, char *type, int size); +int multi_rate_add(int np_index, const char *type, int size); // process. call _before_ doing network operations each frame void multi_rate_process(); diff --git a/include/multimsgs.h b/include/multimsgs.h index abf0706..c0c79c7 100644 --- a/include/multimsgs.h +++ b/include/multimsgs.h @@ -458,7 +458,7 @@ void send_join_packet(net_addr_t* addr,join_request *jr); void send_accept_packet(int new_player_num, int code, int ingame_join_team = -1); // send a general game chat packet (if msg_mode == MULTI_MSG_TARGET, need to pass in "to", if == MULTI_MSG_EXPR, need to pass in expr) -void send_game_chat_packet(net_player *from, char *msg, int msg_mode, net_player *to = NULL,char *expr = NULL,int server_msg = 0); +void send_game_chat_packet(net_player *from, const char *msg, int msg_mode, net_player *to = NULL, const char *expr = NULL,int server_msg = 0); // send a game information update void send_game_info_packet( void ); @@ -508,7 +508,7 @@ void send_ship_depart_packet( object *objp ); void send_mission_log_packet( int entry ); // send a mission message packet -void send_mission_message_packet(int id, char *who_from, int priority, int timing, int source, int builtin_type, int multi_target, int multi_team_filter); +void send_mission_message_packet(int id, const char *who_from, int priority, int timing, int source, int builtin_type, int multi_target, int multi_team_filter); // broadcast a query for active games. IPX will use net broadcast and TCP will either request from the MT or from the specified list void broadcast_game_query(); @@ -637,7 +637,7 @@ void send_shield_explosion_packet(int objnum, int tri_num, vector hit_pos); void send_player_stats_block_packet(net_player *pl, int stats_type, net_player *target = NULL); -void send_host_restr_packet(char *callsign, int code, int mode); +void send_host_restr_packet(const char *callsign, int code, int mode); void send_netgame_end_error_packet(int notify_code, int err_code); diff --git a/include/multiteamselect.h b/include/multiteamselect.h index 96df2b5..2bd8130 100644 --- a/include/multiteamselect.h +++ b/include/multiteamselect.h @@ -190,7 +190,7 @@ int multi_ts_get_team(char *ship_name); void multi_ts_get_team_and_slot(char *ship_name,int *team_index,int *slot_index); // function to return the shipname of the ship belonging in slot N -char *multi_ts_get_shipname( int team, int slot_index ); +const char *multi_ts_get_shipname( int team, int slot_index ); // blit the proper "locked" button - used for weapon select and briefing screens void multi_ts_blit_locked_button(); diff --git a/include/multiui.h b/include/multiui.h index 2fc5aa2..9635850 100644 --- a/include/multiui.h +++ b/include/multiui.h @@ -323,8 +323,8 @@ struct net_player; -void multi_common_add_text(char *txt,int auto_scroll = 0); -void multi_common_set_text(char *str,int auto_scroll = 0); +void multi_common_add_text(const char *txt, int auto_scroll = 0); +void multi_common_set_text(const char *str, int auto_scroll = 0); // time between sending refresh packets to known servers #define MULTI_JOIN_REFRESH_TIME 45000 @@ -467,7 +467,7 @@ int multi_debrief_stats_accept_code(); // call this to determine the status o void multi_debrief_server_process(); // process all details regarding moving the netgame to its next state // add a notification string, drawing appropriately depending on the state/screen we're in -void multi_common_add_notify(char *str); +void multi_common_add_notify(const char *str); // bring up the password string popup, fill in passwd (return 1 if accept was pressed, 0 if cancel was pressed) int multi_passwd_popup(char *passwd); diff --git a/include/multiutil.h b/include/multiutil.h index e1af792..894bfec 100644 --- a/include/multiutil.h +++ b/include/multiutil.h @@ -175,9 +175,9 @@ extern int find_player_id(short player_id); extern int find_player_socket(PSNET_SOCKET_RELIABLE sock); // note this is only valid to do on a server! extern int multi_find_player_by_object( object *obj ); extern int multi_find_player_by_signature( int signature ); -extern int multi_find_player_by_callsign(char *callsign); +extern int multi_find_player_by_callsign(const char *callsign); extern int multi_find_player_by_net_signature(ushort net_signature); -extern int multi_find_player_by_ship_name(char *ship_name); +extern int multi_find_player_by_ship_name(const char *ship_name); extern int multi_create_player(int player_num, player *pl,char* name, net_addr_t* addr, int ship_class, short id); extern int multi_find_open_netplayer_slot(); extern int multi_find_open_player_slot(); @@ -188,10 +188,10 @@ extern int multi_num_players(); extern int multi_num_observers(); extern int multi_num_connections(); -extern char* multi_random_death_word(); -extern char* multi_random_chat_start(); +extern const char* multi_random_death_word(); +extern const char* multi_random_chat_start(); -extern int multi_ship_class_lookup(char* ship_name); +extern int multi_ship_class_lookup(const char* ship_name); extern ushort netmisc_calc_checksum( void * vptr, int len ); extern void fill_net_addr(net_addr_t* addr, ubyte* address, ubyte* net_id, ushort port); extern char* get_text_address( char * text, ubyte * address ); @@ -309,10 +309,10 @@ int multi_ignore_controls(int key = -1); int multi_kill_limit_reached(); // display a chat message (write to the correct spot - hud, standalone gui, chatbox, etc) -void multi_display_chat_msg(char *msg, int player_index, int add_id); +void multi_display_chat_msg(const char *msg, int player_index, int add_id); // fill in Current_file_checksum and Current_file_length -void multi_get_mission_checksum(char *filename); +void multi_get_mission_checksum(const char *filename); // Packs/unpacks an object position. // Returns number of bytes read or written. diff --git a/include/mvelib.h b/include/mvelib.h index c77f2d1..9e41550 100644 --- a/include/mvelib.h +++ b/include/mvelib.h @@ -36,7 +36,7 @@ typedef struct MVEFILE } MVEFILE; // open a .MVE file -MVEFILE *mvefile_open(char *filename); +MVEFILE *mvefile_open(const char *filename); // close a .MVE file void mvefile_close(MVEFILE *movie); @@ -66,7 +66,7 @@ typedef struct MVESTREAM } MVESTREAM; // open an MVE stream -MVESTREAM *mve_open(char *filename); +MVESTREAM *mve_open(const char *filename); // close an MVE stream void mve_close(MVESTREAM *movie); diff --git a/include/nebula.h b/include/nebula.h index 382f108..6667725 100644 --- a/include/nebula.h +++ b/include/nebula.h @@ -50,8 +50,8 @@ extern int Nebula_heading; // You shouldn't pass the extension for filename. // PBH = Pitch, Bank, Heading. Pass NULL for default orientation. -void nebula_init( char *filename, int pitch, int bank, int heading ); -void nebula_init( char *filename, angles *pbh = NULL ); +void nebula_init( const char *filename, int pitch, int bank, int heading ); +void nebula_init( const char *filename, angles *pbh = NULL ); void nebula_close(); void nebula_render(); diff --git a/include/object.h b/include/object.h index 69fed3b..000037a 100644 --- a/include/object.h +++ b/include/object.h @@ -372,7 +372,7 @@ #define UNUSED_OBJNUM (-MAX_OBJECTS*2) // Newer systems use this instead of -1 for invalid object. #ifndef NDEBUG -extern char *Object_type_names[MAX_OBJECT_TYPES]; +extern const char *Object_type_names[MAX_OBJECT_TYPES]; #endif // each object type should have these functions: (I will use weapon as example) diff --git a/include/optionsmenu.h b/include/optionsmenu.h index da367f8..2c38056 100644 --- a/include/optionsmenu.h +++ b/include/optionsmenu.h @@ -68,22 +68,22 @@ struct op_sliders { // base slider - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; int dot_w; int dots; // left and right buttons - char *left_filename; + const char *left_filename; int left_mask, left_x, left_y; - char *right_filename; + const char *right_filename; int right_mask, right_x, right_y; // slider control UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below.. - op_sliders(char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, char *_left_filename, int _left_mask, int _left_x, int _left_y, char *_right_filename, int _right_mask, int _right_x, int _right_y) : + op_sliders(const char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, const char *_left_filename, int _left_mask, int _left_x, int _left_y, const char *_right_filename, int _right_mask, int _right_x, int _right_y) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), dot_w(_dot_w), dots(_dots), left_filename(_left_filename), left_mask(_left_mask), left_x(_left_x), left_y(_left_y), right_filename(_right_filename), right_mask(_right_mask), right_x(_right_x), right_y(_right_y) {} }; diff --git a/include/osapi.h b/include/osapi.h index a688d91..ed0d3c3 100644 --- a/include/osapi.h +++ b/include/osapi.h @@ -43,10 +43,10 @@ extern const char *detect_home(void); // If app_name is NULL or ommited, then TITLE is used // for the app name, which is where registry keys are stored. -void os_init(char * wclass, char * title, char *app_name=NULL, char *version_string=NULL ); +void os_init(const char *wclass, const char *title, const char *app_name = NULL, const char *version_string = NULL); // set the main window title -void os_set_title( char * title ); +void os_set_title( const char *title ); // call at program end void os_cleanup(); diff --git a/include/osregistry.h b/include/osregistry.h index ecb35fa..42c2249 100644 --- a/include/osregistry.h +++ b/include/osregistry.h @@ -16,12 +16,12 @@ // // exectuable defines -extern char *Osreg_company_name; -extern char *Osreg_class_name; -extern char *Osreg_app_name; -extern char *Osreg_title; +extern const char *Osreg_company_name; +extern const char *Osreg_class_name; +extern const char *Osreg_app_name; +extern const char *Osreg_title; #ifdef PLAT_UNIX -extern char *Osreg_user_dir; +extern const char *Osreg_user_dir; #endif // ------------------------------------------------------------------------------------------------------------ @@ -30,37 +30,37 @@ extern char *Osreg_user_dir; // initialize the registry. setup default keys to use -void os_init_registry_stuff(char *company, char *app, char *version); +void os_init_registry_stuff(const char *company, const char *app, const char *version); // Removes a value from to the INI file. Passing // name=NULL will delete the section. -void os_config_remove( char *section, char *name ); +void os_config_remove( const char *section, const char *name ); // Writes a string to the registry -void os_config_write_string( char *section, char *name, char *value ); +void os_config_write_string( const char *section, const char *name, const char *value ); // same as previous function except we don't use the application name to build up the keyname -void os_config_write_string2( char *section, char *name, char *value ); +void os_config_write_string2( const char *section, const char *name, const char *value ); // Writes an unsigned int to the INI file. -void os_config_write_uint( char *section, char *name, unsigned int value ); +void os_config_write_uint( const char *section, const char *name, unsigned int value ); // Reads a string from the INI file. If default is passed, // and the string isn't found, returns ptr to default otherwise // returns NULL; Copy the return value somewhere before // calling os_read_string again, because it might reuse the // same buffer. -char * os_config_read_string( char *section, char *name, char *default_value=NULL ); +const char * os_config_read_string( const char *section, const char *name, const char *default_value=NULL ); // same as previous function except we don't use the application name to build up the keyname -char * os_config_read_string2( char *section, char *name, char *default_value=NULL ); +const char * os_config_read_string2( const char *section, const char *name, const char *default_value=NULL ); // Reads a string from the INI file. Default_value must // be passed, and if 'name' isn't found, then returns default_value -unsigned int os_config_read_uint( char *section, char *name, unsigned int default_value ); +unsigned int os_config_read_uint( const char *section, const char *name, unsigned int default_value ); // uses Ex versions of Windows registry functions -char * os_config_read_string_ex( char *keyname, char *name, char *default_value ); +const char * os_config_read_string_ex( const char *keyname, const char *name, const char *default_value ); #if defined(__APPLE__) && !defined(MACOSX) extern char full_path[]; diff --git a/include/outwnd.h b/include/outwnd.h index a58da09..1728b32 100644 --- a/include/outwnd.h +++ b/include/outwnd.h @@ -14,8 +14,8 @@ void load_filter_info(void); void outwnd_init(int display_under_freespace_window=0); void outwnd_close(); -void outwnd_printf(char *id, char *format, ...); -void outwnd_printf2(char *format, ...); +void outwnd_printf(const char *id, const char *format, ...); +void outwnd_printf2(const char *format, ...); #ifndef NDEBUG extern int Log_debug_output_to_file; diff --git a/include/palman.h b/include/palman.h index 05128aa..38bf047 100644 --- a/include/palman.h +++ b/include/palman.h @@ -78,7 +78,7 @@ // Calculate tables for this palette. // Assumes gr_palette is filled in. -extern void palette_update(char *name, int restrict_colors_to_upper_128 ); +extern void palette_update(const char *name, int restrict_colors_to_upper_128 ); // Writes current tables to disk. extern void palette_flush(); @@ -98,7 +98,7 @@ extern uint gr_palette_checksum; // Functions to deal with changing the palette. // These just call gr_set_palette, which will in turn // call palette_flush and palette_update. -extern void palette_load_table( char * filename ); +extern void palette_load_table( const char * filename ); extern void palette_use_bm_palette(int n); extern void palette_restore_palette( void ); diff --git a/include/parselo.h b/include/parselo.h index 909b006..74a3402 100644 --- a/include/parselo.h +++ b/include/parselo.h @@ -241,7 +241,7 @@ extern char Mission_text[MISSION_TEXT_SIZE]; extern char Mission_text_raw[MISSION_TEXT_SIZE]; extern char *Mp; -extern char *token_found; +extern const char *token_found; extern int fred_parse_flag; extern int Token_found_flag; extern jmp_buf parse_abort; @@ -295,32 +295,32 @@ void ignore_gray_space(); // error extern int get_line_num(); extern char *next_tokens(); -extern void diag_printf(char *format, ...); -extern void error_display(int error_level, char *format, ...); +extern void diag_printf(const char *format, ...); +extern void error_display(int error_level, const char *format, ...); // skip -extern int skip_to_string(char *pstr, char *end = NULL); -extern int skip_to_start_of_strings(char *pstr1, char *pstr2); -extern void advance_to_eoln(char *terminators); +extern int skip_to_string(const char *pstr, const char *end = NULL); +extern int skip_to_start_of_strings(const char *pstr1, const char *pstr2); +extern void advance_to_eoln(const char *terminators); extern void skip_token(); // required -extern int required_string(char *pstr); -extern int optional_string(char *pstr); -extern int required_string_either(char *str1, char *str2); -extern int required_string_3(char *str1, char *str2, char *str3); +extern int required_string(const char *pstr); +extern int optional_string(const char *pstr); +extern int required_string_either(const char *str1, const char *str2); +extern int required_string_3(const char *str1, const char *str2, const char *str3); // stuff -extern void copy_to_eoln(char *outstr, char *more_terminators, char *instr, int max); -extern void copy_text_until(char *outstr, char *instr, char *endstr, int max_chars); +extern void copy_to_eoln(char *outstr, const char *more_terminators, const char *instr, int max); +extern void copy_text_until(char *outstr, const char *instr, const char *endstr, int max_chars); extern void stuff_string_white(char *pstr); -extern void stuff_string(char *pstr, int type, char *terminators, int len = 0); +extern void stuff_string(char *pstr, int type, const char *terminators, int len = 0); extern void stuff_string_line(char *pstr, int len); // Exactly the same as stuff string only Malloc's the buffer. // Supports various FreeSpace primitive types. If 'len' is supplied, it will override // the default string length if using the F_NAME case. -char *stuff_and_malloc_string( int type, char *terminators, int len); +char *stuff_and_malloc_string( int type, const char *terminators, int len); extern void stuff_float(float *f); extern void stuff_int(int *i); extern void stuff_byte(ubyte *i); @@ -329,16 +329,16 @@ extern int stuff_int_list(int *ilp, int max_ints, int lookup_type); extern int stuff_vector_list(vector *vlp, int max_vecs); extern void stuff_vector(vector *vp); extern void stuff_matrix(matrix *mp); -extern int string_lookup(char *str1, char *strlist[], int max, char *description = NULL, int say_errors = 0); -extern void find_and_stuff(char *id, int *addr, int f_type, char *strlist[], int max, char *description); -extern int match_and_stuff(int f_type, char *strlist[], int max, char *description); -extern void find_and_stuff_or_add(char *id, int *addr, int f_type, char *strlist[], int *total, - int max, char *description); +extern int string_lookup(const char *str1, const char *strlist[], int max, const char *description = NULL, int say_errors = 0); +extern void find_and_stuff(const char *id, int *addr, int f_type, const char *strlist[], int max, const char *description); +extern int match_and_stuff(int f_type, const char *strlist[], int max, const char *description); +extern void find_and_stuff_or_add(const char *id, int *addr, int f_type, char *strlist[], int *total, + int max, const char *description); extern int get_string(char *str); extern void stuff_parenthesized_vector(vector *vp); void stuff_boolean(int *i); -int check_for_string(char *pstr); -int check_for_string_raw(char *pstr); +int check_for_string(const char *pstr); +int check_for_string_raw(const char *pstr); // general extern void init_parse(); @@ -349,15 +349,15 @@ extern void parse_main(); // utility extern void mark_int_list(int *ilp, int max_ints, int lookup_type); extern void compact_multitext_string(char *str); -extern void read_file_text(char *filename, int mode = CF_TYPE_ANY ); +extern void read_file_text(const char *filename, int mode = CF_TYPE_ANY ); extern void debug_show_mission_text(); extern void convert_sexp_to_string(int cur_node, char *outstr, int mode); char *split_str_once(char *src, int max_pixel_w); -int split_str(char *src, int max_pixel_w, int *n_chars, char **p_str, int max_lines, char ignore_char = -1); +int split_str(const char *src, int max_pixel_w, int *n_chars, char **p_str, int max_lines, char ignore_char = -1); // fred -extern int required_string_fred(char *pstr, char *end = NULL); -extern int required_string_either_fred(char *str1, char *str2); -extern int optional_string_fred(char *pstr, char *end = NULL, char *end2 = NULL); +extern int required_string_fred(const char *pstr, const char *end = NULL); +extern int required_string_either_fred(const char *str1, const char *str2); +extern int optional_string_fred(const char *pstr, const char *end = NULL, const char *end2 = NULL); #endif diff --git a/include/player.h b/include/player.h index a8ccb25..74a75f0 100644 --- a/include/player.h +++ b/include/player.h @@ -357,10 +357,10 @@ void player_stop_cargo_scan_sound(); void player_maybe_start_cargo_scan_sound(); // will attempt to load an insignia bitmap and set it as active for the player -void player_set_squad_bitmap(player *p, char *fname); +void player_set_squad_bitmap(player *p, const char *fname); // set squadron -void player_set_squad(player *p, char *squad_name); +void player_set_squad(player *p, const char *squad_name); int player_inspect_cargo(float frametime, char *outstr); diff --git a/include/popup.h b/include/popup.h index b57f655..0ced202 100644 --- a/include/popup.h +++ b/include/popup.h @@ -186,7 +186,7 @@ int popup(int flags, int nchoices, ... ); int popup_till_condition( int(*condition)() , ...); // popup to return the value from an input box -char *popup_input(int flags, char *caption, int max_output_len = -1); +char *popup_input(int flags, const char *caption, int max_output_len = -1); int popup_active(); @@ -196,7 +196,7 @@ int popup_running_state(); void popup_kill_any_active(); // change the text inside of the popup -void popup_change_text(char *new_text); +void popup_change_text(const char *new_text); #endif diff --git a/include/pstypes.h b/include/pstypes.h index f28ecdd..8aa1fd3 100644 --- a/include/pstypes.h +++ b/include/pstypes.h @@ -392,9 +392,9 @@ typedef struct bitmap { } bitmap; //This are defined in MainWin.c -extern void _cdecl WinAssert(char * text,char *filename, int line); -extern void _cdecl Error( char * filename, int line, char * format, ... ); -extern void _cdecl Warning( char * filename, int line, char * format, ... ); +extern void _cdecl WinAssert(const char * text, const char *filename, int line); +extern void _cdecl Error( const char * filename, int line, const char * format, ... ); +extern void _cdecl Warning( const char * filename, int line, const char * format, ... ); #include "outwnd.h" @@ -484,10 +484,10 @@ DCF(toggle_it,"description") class debug_command { public: - char *name; - char *help; + const char *name; + const char *help; void (*func)(); - debug_command(char *name,char *help,void (*func)()); // constructor + debug_command(const char *name, const char *help, void (*func)()); // constructor }; #define DCF(function_name,help_text) \ @@ -519,12 +519,12 @@ void dc_get_arg(uint flags); // Gets the next argument. If it doesn't match t extern char *Dc_arg; // The (lowercased) string value of the argument retrieved from dc_arg extern char *Dc_arg_org; // Dc_arg before it got converted to lowercase extern uint Dc_arg_type; // The type of dc_arg. -extern char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on. +extern const char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on. extern int Dc_arg_int; // If Dc_arg_type & ARG_INT or ARG_HEX is set, then this is the value extern float Dc_arg_float; // If Dc_arg_type & ARG_FLOAT is set, then this is the value // Outputs text to the console -void dc_printf( char *format, ... ); +void dc_printf( const char *format, ... ); // Each dc_arg_type can have one or more of these flags set. // This is because some things can fit into two catagories. @@ -662,10 +662,10 @@ extern void game_busy(); class monitor { public: - char *name; + const char *name; int value; // Value that gets cleared to 0 each frame. int min, max, sum, cnt; // Min & Max of value. Sum is used to calculate average - monitor(char *name); // constructor + monitor(const char *name); // constructor }; // Creates a monitor variable @@ -690,7 +690,7 @@ void monitor_update(); #define NOX(s) s -char *XSTR(char *str, int index); +const char *XSTR(const char *str, int index); // Caps V between MN and MX. template void CAP( T& v, T mn, T mx ) @@ -741,13 +741,13 @@ template void CAP( T& v, T mn, T mx ) int vm_init(int min_heap_size); // Allocates some RAM. - void *vm_malloc( int size, char *filename=NULL, int line=-1 ); + void *vm_malloc( int size, const char *filename=NULL, int line=-1 ); // - char *vm_strdup( const char *ptr, char *filename, int line ); + char *vm_strdup( const char *ptr, const char *filename, int line ); // Frees some RAM. - void vm_free( void *ptr, char *filename=NULL, int line=-1 ); + void vm_free( void *ptr, const char *filename=NULL, int line=-1 ); // Frees all RAM. void vm_free_all(); diff --git a/include/sexp.h b/include/sexp.h index 0a53b3b..bda0221 100644 --- a/include/sexp.h +++ b/include/sexp.h @@ -735,7 +735,7 @@ typedef struct sexp_ai_goal_link { } sexp_ai_goal_link; typedef struct sexp_oper { - char *text; + const char *text; int value; int min, max; } sexp_oper; @@ -782,7 +782,7 @@ extern int Players_target_timestamp; extern int Sexp_clipboard; // used by Fred extern void init_sexp(); -extern int alloc_sexp(char *text, int type, int subtype, int first, int rest); +extern int alloc_sexp(const char *text, int type, int subtype, int first, int rest); extern int find_free_sexp(); extern int free_one_sexp(int num); extern int free_sexp(int num); @@ -792,8 +792,8 @@ extern int cmp_sexp_chains(int node1, int node2); extern int find_sexp_list(int num); extern int find_parent_operator(int num); extern int is_sexp_top_level( int node ); -extern int identify_operator(char *token); -extern int find_operator(char *token); +extern int identify_operator(const char *token); +extern int find_operator(const char *token); extern int query_sexp_args_count(int index); extern int check_sexp_syntax(int index, int return_type = OPR_BOOL, int recursive = 0, int *bindex = NULL, int mode = 0); extern int get_sexp_main(void); // Returns start node @@ -809,7 +809,7 @@ extern void skip_white(char **str); extern int validate_float(char **str); extern int build_sexp_string(int cur_node, int level, int mode); extern int sexp_query_type_match(int opf, int opr); -extern char *sexp_error_message(int num); +extern const char *sexp_error_message(int num); extern int count_free_sexp_nodes(); // functions to change the attributes of an sexpression tree to persistent or not persistent diff --git a/include/ship.h b/include/ship.h index fe2c143..e2ceb69 100644 --- a/include/ship.h +++ b/include/ship.h @@ -674,7 +674,7 @@ extern exited_ship Ships_exited[MAX_EXITED_SHIPS]; // a couple of functions to get at the data extern void ship_add_exited_ship( ship *shipp, int reason ); -extern int ship_find_exited_ship_by_name( char *name ); +extern int ship_find_exited_ship_by_name( const char *name ); extern int ship_find_exited_ship_by_signature( int signature); #define SIF_DO_COLLISION_CHECK (1 << 0) @@ -978,7 +978,7 @@ typedef struct ship_counts { int killed; } ship_counts; -extern char *Ship_type_names[MAX_SHIP_TYPE_COUNTS]; +extern const char *Ship_type_names[MAX_SHIP_TYPE_COUNTS]; extern int Ship_type_flags[MAX_SHIP_TYPE_COUNTS]; // SIF_* flags for each ship type extern ship_counts Ship_counts[MAX_SHIP_TYPE_COUNTS]; @@ -1027,12 +1027,12 @@ extern void physics_ship_init(object *objp); // Stuff vector *pos with absolute position. extern int get_subsystem_pos(vector *pos, object *objp, ship_subsys *subsysp); -extern int ship_info_lookup(char *name); -extern int ship_info_base_lookup(int si_index); -extern int ship_name_lookup(char *name, int inc_players = 0); // returns the index into Ship array of name -extern int ship_type_name_lookup(char *name); +extern int ship_info_lookup(const char *name); +extern int ship_info_base_lookup(const int si_index); +extern int ship_name_lookup(const char *name, int inc_players = 0); // returns the index into Ship array of name +extern int ship_type_name_lookup(const char *name); -extern int wing_lookup(char *name); +extern int wing_lookup(const char *name); // returns 0 if no conflict, 1 if conflict, -1 on some kind of error with wing struct extern int wing_has_conflicting_teams(int wing_index); @@ -1040,7 +1040,7 @@ extern int wing_has_conflicting_teams(int wing_index); // next function takes optional second parameter which says to ignore the current count of ships // in the wing -- used to tell is the wing exists or not, not whether it exists and has ships currently // present. -extern int wing_name_lookup(char *name, int ignore_count = 0); +extern int wing_name_lookup(const char *name, int ignore_count = 0); extern int Player_ship_class; diff --git a/include/snazzyui.h b/include/snazzyui.h index 8d67d6f..c08d94d 100644 --- a/include/snazzyui.h +++ b/include/snazzyui.h @@ -100,8 +100,8 @@ typedef struct menu_region { #define SNAZZY_CLICKED 2 // mouse button has gone from down to up over a region int snazzy_menu_do(ubyte *data, int mask_w, int mask_h, int num_regions, MENU_REGION *regions, int *action, int poll_key = 1, int *key = NULL); -void read_menu_tbl(char *menu_name, char *bkg_filename, char *mask_filename, MENU_REGION *regions, int* num_regions, int play_sound=1); -void snazzy_menu_add_region(MENU_REGION *region, char* text, int mask, int key, int click_sound = -1); +void read_menu_tbl(const char *menu_name, char *bkg_filename, char *mask_filename, MENU_REGION *regions, int* num_regions, int play_sound=1); +void snazzy_menu_add_region(MENU_REGION *region, const char* text, int mask, int key, int click_sound = -1); void snazzy_menu_init(); // Call the first time a snazzy menu is inited void snazzy_menu_close(); diff --git a/include/stand_gui.h b/include/stand_gui.h index 4027c59..51255d6 100644 --- a/include/stand_gui.h +++ b/include/stand_gui.h @@ -139,14 +139,14 @@ struct net_player; // // create the validate dialog -void std_create_gen_dialog(char *title); +void std_create_gen_dialog(const char *title); // kill the validate dialog(); void std_destroy_gen_dialog(); // set the text in the filename of the validate dialog // valid values for field_num == 0 .. 2 -void std_gen_set_text(char *str, int field_num); +void std_gen_set_text(const char *str, int field_num); // is the validate dialog active int std_gen_is_active(); @@ -163,13 +163,13 @@ int std_connect_set_connect_count(); void std_connect_set_host_connect_status(); // add an ip string to the connect page listbox -void std_connect_add_ip_string(char *string); +void std_connect_add_ip_string(const char *string); // remove an ip string from the connect page listbox -void std_connect_remove_ip_string(char *string); +void std_connect_remove_ip_string(const char *string); // set an ip string on the connect page listbox -void std_connect_set_ip_string(char *lookup,char *string); +void std_connect_set_ip_string(const char *lookup, const char *string); // kick a player (the one currently selected in the listbox) void std_connect_kick_player(); @@ -181,7 +181,7 @@ void std_connect_update_ping(net_player *p); void std_connect_clear_controls(); // set the game name for the standalone. passing NULL uses the default -void std_connect_set_gamename(char *name); +void std_connect_set_gamename(const char *name); // the user has changed the text in the server name text box. handle this void std_connect_handle_name_change(); @@ -198,7 +198,7 @@ void std_connect_handle_passwd_change(); void std_multi_set_standalone_missiontime(float mission_time); // set the mission name -void std_multi_set_standalone_mission_name(char *mission_name); +void std_multi_set_standalone_mission_name(const char *mission_name); // initialize the goal tree for this mission void std_multi_setup_goal_tree(); @@ -268,7 +268,7 @@ void std_gs_clear_controls(); // // set the text on the standalones state indicator box -void std_debug_set_standalone_state_string(char *str); +void std_debug_set_standalone_state_string(const char *str); // clear all the controls for this page void std_debug_clear_controls(); @@ -315,7 +315,7 @@ void std_tracker_login(); void std_reset_timestamps(); // add a line of text chat to the standalone -void std_add_chat_text(char *text,int player_index,int add_id); +void std_add_chat_text(const char *text, int player_index, int add_id); // if the standalone is host password protected int std_is_host_passwd(); @@ -324,10 +324,10 @@ int std_is_host_passwd(); void std_mutate_sheet(); // if the given callsign is banned from the server -int std_player_is_banned(char *name); +int std_player_is_banned(const char *name); // add a callsign to the ban list -void std_add_ban(char *name); +void std_add_ban(const char *name); #endif diff --git a/include/starfield.h b/include/starfield.h index 4bf184b..7dd442f 100644 --- a/include/starfield.h +++ b/include/starfield.h @@ -184,13 +184,13 @@ void stars_draw_sun_glow(int sun_n); void stars_camera_cut(); // call this to set a specific model as the background model -void stars_set_background_model(char *model_name, char *texture_name); +void stars_set_background_model(const char *model_name, const char *texture_name); // lookup a starfield bitmap, return index or -1 on fail -int stars_find_bitmap(char *name); +int stars_find_bitmap(const char *name); // lookup a sun by bitmap filename, return index or -1 on fail -int stars_find_sun(char *name); +int stars_find_sun(const char *name); // get the world coords of the sun pos on the unit sphere. void stars_get_sun_pos(int sun_n, vector *pos); diff --git a/include/ui.h b/include/ui.h index f389567..373d46d 100644 --- a/include/ui.h +++ b/include/ui.h @@ -394,7 +394,6 @@ class UI_GADGET friend class UI_DOT_SLIDER_NEW; protected: - char *bm_filename; int kind; int hotkey; int x, y, w, h; @@ -470,7 +469,7 @@ class UI_GADGET // anything < start_frame will not be loaded. // this keeps the loading code from trying to load bitmaps which don't exist // and taking an unnecessary disk hit. - int set_bmaps(char *ani_filename, int nframes = 3, int start_frame = 1); // extracts MAX_BMAPS_PER_GADGET from .ani file + int set_bmaps(const char *ani_filename, int nframes = 3, int start_frame = 1); // extracts MAX_BMAPS_PER_GADGET from .ani file void reset(); // zero out m_flags int is_hidden() { return hidden; } @@ -481,7 +480,7 @@ class UI_GADGET #define UI_XSTR_COLOR_GREEN 0 // shades of green/gray #define UI_XSTR_COLOR_PINK 1 // pinkish hue typedef struct UI_XSTR { - char *xstr; // base string + const char *xstr; // base string int xstr_id; // xstring id int x, y; // coords of the string int clr; // color to use @@ -558,7 +557,7 @@ class UI_BUTTON : public UI_GADGET int button_hilighted(); // is the mouse over this button? void set_button_hilighted(); // force button to be highlighted void press_button(); // force button to get pressed - void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus = 0); + void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus = 0); void set_highlight_action( void (*user_function)(void) ); void set_disabled_action( void (*user_function)(void) ); void draw_forced(int frame_num); @@ -630,13 +629,13 @@ class UI_INPUTBOX : public UI_GADGET public: // int first_time; - void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, char *text, int _flags = 0, int pixel_lim = -1, color *clr = NULL); - void set_valid_chars(char *vchars); - void set_invalid_chars(char *ichars); + void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, const char *text, int _flags = 0, int pixel_lim = -1, color *clr = NULL); + void set_valid_chars(const char *vchars); + void set_invalid_chars(const char *ichars); int changed(); int pressed(); void get_text(char *out); - void set_text(char *in); + void set_text(const char *in); }; // Icon flags @@ -658,7 +657,7 @@ class UI_ICON : public UI_GADGET virtual void destroy(); public: - void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h); + void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h); }; class UI_CHECKBOX : public UI_GADGET @@ -682,7 +681,7 @@ class UI_CHECKBOX : public UI_GADGET public: int changed(); int checked(); - void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state ); + void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state ); void set_state(int _state); }; @@ -708,7 +707,7 @@ class UI_RADIO : public UI_GADGET public: int changed(); int checked(); - void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state, int _group ); + void create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state, int _group ); }; class UI_SCROLLBAR : public UI_GADGET @@ -746,7 +745,7 @@ class UI_SCROLLBAR : public UI_GADGET void unhide(); int get_hidden(); void link_hotspot(int up_button_num, int down_button_num); - int set_bmaps(char *up_button_fname, char *down_button_fname, char *line_fname); + int set_bmaps(const char *up_button_fname, const char *down_button_fname, const char *line_fname); }; class UI_SLIDER2 : public UI_GADGET @@ -783,7 +782,7 @@ class UI_SLIDER2 : public UI_GADGET public: // create the slider - void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl, + void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, const char *_bitmapSliderControl, void (*_upCallback)(), void (*_downCallback)(), void (*_captureCallback)()); // range management @@ -821,7 +820,7 @@ class UI_DOT_SLIDER : public UI_GADGET public: int pos; // 0 thru 10 - void create(UI_WINDOW *wnd, int _x, int _y, char *bm, int id, int end_buttons = 1, int num_pos = 10); + void create(UI_WINDOW *wnd, int _x, int _y, const char *bm, int id, int end_buttons = 1, int num_pos = 10); virtual void draw(); virtual void process(int focus = 0); virtual void destroy(); @@ -840,9 +839,9 @@ class UI_DOT_SLIDER_NEW : public UI_GADGET public: int pos; // 0 thru 10 - void create(UI_WINDOW *wnd, int _x, int _y, int num_pos, char *bm_slider, int slider_mask, - char *bm_left = NULL, int left_mask = -1, int left_x = -1, int left_y = -1, - char *bm_right = NULL, int right_mask = -1, int right_x = -1, int right_y = -1, + void create(UI_WINDOW *wnd, int _x, int _y, int num_pos, const char *bm_slider, int slider_mask, + const char *bm_left = NULL, int left_mask = -1, int left_x = -1, int left_y = -1, + const char *bm_right = NULL, int right_mask = -1, int right_x = -1, int right_y = -1, int dot_width = 19); virtual void draw(); virtual void process(int focus = 0); @@ -891,7 +890,7 @@ class UI_LISTBOX : public UI_GADGET int sel_changed(); // returns > 0 if the selected item has changed void set_new_list(int _numitems, char **_list); - int set_bmaps(char *lbox_fname, char *b_up_fname, char *b_down_fname, char *sb_fname); + int set_bmaps(const char *lbox_fname, const char *b_up_fname, const char *b_down_fname, const char *sb_fname); void link_hotspot(int up_button_num, int down_button_num); }; @@ -950,9 +949,9 @@ protected: public: UI_WINDOW(); // constructor ~UI_WINDOW(); // destructor - void set_mask_bmap(char *fname); - void set_mask_bmap(int bmap, char *name); - void set_foreground_bmap(char *fname); + void set_mask_bmap(const char *fname); + void set_mask_bmap(int bmap, const char *name); + void set_foreground_bmap(const char *fname); void create( int x, int y, int w, int h, int flags ); int process( int key_in = -1,int process_mouse = 1); void draw(); @@ -961,12 +960,12 @@ public: int get_current_hotspot(); void destroy(); ushort *get_mask_data(int *w, int *h) { *w = mask_w; *h = mask_h; return mask_data; } - void render_tooltip(char *str); + void render_tooltip(const char *str); void set_ignore_gadgets(int state); - void add_XSTR(char *string, int xstr_id, int x, int y, UI_GADGET *assoc, int color_type, int font_id = -1); + void add_XSTR(const char *string, int xstr_id, int x, int y, UI_GADGET *assoc, int color_type, int font_id = -1); void add_XSTR(UI_XSTR *xstr); - char *(*tooltip_handler)(char *text); + const char *(*tooltip_handler)(const char *text); int last_keypress; // filled in each frame int ttx, tty; int use_hack_to_get_around_stupid_problem_flag; @@ -974,12 +973,12 @@ public: // 2 extremely useful structs typedef struct ui_button_info { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - ui_button_info(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} + ui_button_info(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} } ui_button_info; diff --git a/include/uidefs.h b/include/uidefs.h index 82c492f..4feacd5 100644 --- a/include/uidefs.h +++ b/include/uidefs.h @@ -75,7 +75,7 @@ void ui_hline(int x1, int x2, int y ); void ui_vline(int y1, int y2, int x ); -void ui_string_centered( int x, int y, char * s ); +void ui_string_centered( int x, int y, const char * s ); void ui_draw_shad( int x1, int y1, int x2, int y2, int r1, int g1, int b1, int r2, int g2, int b2 ); void ui_draw_frame( int x1, int y1, int x2, int y2 ); void ui_rect( int x1, int y1, int x2, int y2 ); diff --git a/include/version.h b/include/version.h index 2a793d4..db9c3dd 100644 --- a/include/version.h +++ b/include/version.h @@ -176,7 +176,7 @@ // 1 if same version // 2 if higher version // fills in user version and latest version values if non-NULL -int version_compare(char *filename, int *u_major, int *u_minor, int *u_build, int *l_major, int *l_minor, int *l_build); +int version_compare(const char *filename, int *u_major, int *u_minor, int *u_build, int *l_major, int *l_minor, int *l_build); #endif diff --git a/include/weapon.h b/include/weapon.h index af80f71..ec19a79 100644 --- a/include/weapon.h +++ b/include/weapon.h @@ -556,7 +556,7 @@ extern char *Weapon_names[MAX_WEAPON_TYPES]; #define WEAPON_INFO_INDEX(wip) (wip-Weapon_info) -int weapon_info_lookup(char *name); +int weapon_info_lookup(const char *name); void weapon_init(); // called at game startup void weapon_level_init(); // called before the start of each level void weapon_render(object * obj); @@ -584,7 +584,7 @@ void weapon_maybe_spew_particle(object *obj); void weapon_hit( object * weapon_obj, object * other_obj, vector * hitpos ); -int weapon_name_lookup(char *name); +int weapon_name_lookup(const char *name); void spawn_child_weapons( object *objp ); // call to detonate a weapon. essentially calls weapon_hit() with other_obj as NULL, and sends a packet in multiplayer diff --git a/src/anim/animplay.cpp b/src/anim/animplay.cpp index d66adb0..3dc9858 100644 --- a/src/anim/animplay.cpp +++ b/src/anim/animplay.cpp @@ -898,7 +898,7 @@ void anim_read_header(anim *ptr, CFILE *fp) // returns: pointer to anim that is loaded => sucess // NULL => failure // -anim *anim_load(char *real_filename, int file_mapped) +anim *anim_load(const char *real_filename, int file_mapped) { anim *ptr; CFILE *fp; @@ -1131,7 +1131,7 @@ void anim_level_close() // return: 0 => success // -1 => failed // -int anim_write_frames_out(char *filename) +int anim_write_frames_out(const char *filename) { anim *source_anim; anim_instance *ai; @@ -1182,7 +1182,7 @@ int anim_write_frames_out(char *filename) // Display information and statistics about a .ani file. // This is called when -i switch is on when running ac.exe // -void anim_display_info(char *real_filename) +void anim_display_info(const char *real_filename) { CFILE *fp; anim A; diff --git a/src/bmpman/bmpman.cpp b/src/bmpman/bmpman.cpp index 1937acd..7d632a9 100644 --- a/src/bmpman/bmpman.cpp +++ b/src/bmpman/bmpman.cpp @@ -904,7 +904,7 @@ int bm_create( int bpp, int w, int h, void * data, int flags ) // 0 if it was found as a file // 1 if it already exists, fills in handle int Bm_ignore_duplicates = 0; -int bm_load_sub(char *real_filename, char *ext, int *handle) +int bm_load_sub(const char *real_filename, const char *ext, int *handle) { int i; char filename[MAX_FILENAME_LEN] = ""; @@ -944,7 +944,7 @@ int bm_load_sub(char *real_filename, char *ext, int *handle) // the bitmap. On success, it returns the bitmap // number. Function doesn't acutally load the data, only // width, height, and possibly flags. -int bm_load( char * real_filename ) +int bm_load( const char * real_filename ) { int i, n, first_slot = MAX_BITMAPS; int w, h, bpp; @@ -1072,7 +1072,7 @@ int bm_load( char * real_filename ) // special load function. basically allows you to load a bitmap which already exists (by filename). // this is useful because in some cases we need to have a bitmap which is locked in screen format // _and_ texture format, such as pilot pics and squad logos -int bm_load_duplicate(char *filename) +int bm_load_duplicate(const char *filename) { int ret; @@ -1156,7 +1156,7 @@ static int find_block_of(int n) // // returns: bitmap number of first frame in the animation // -int bm_load_animation( char *real_filename, int *nframes, int *fps, int can_drop_frames) +int bm_load_animation( const char *real_filename, int *nframes, int *fps, int can_drop_frames) { int i, n; anim the_anim; diff --git a/src/cfile/cfile.cpp b/src/cfile/cfile.cpp index a1d6718..a61fb85 100644 --- a/src/cfile/cfile.cpp +++ b/src/cfile/cfile.cpp @@ -400,7 +400,7 @@ int cfile_in_root_dir(char *exe_path) // returns: success ==> 0 // error ==> non-zero // -int cfile_init(char *exe_dir, char *cdrom_dir) +int cfile_init(const char *exe_dir, const char *cdrom_dir) { int i; @@ -451,7 +451,7 @@ int cfile_init(char *exe_dir, char *cdrom_dir) Cfile_block_list[i].type = CFILE_BLOCK_UNUSED; } - Cfile_cdrom_dir = cdrom_dir; + Cfile_cdrom_dir = (char *)cdrom_dir; cf_build_secondary_filelist(Cfile_cdrom_dir); // 32 bit CRC table init @@ -640,7 +640,7 @@ int cfile_flush_dir(int dir_type) // filename = name of filename or filepath to process // ext = extension to add. Must start with the period // Returns: new filename or filepath with extension. -char *cf_add_ext(char *filename, char *ext) +char *cf_add_ext(const char *filename, const char *ext) { int flen, elen; static char path[MAX_PATH_LEN]; @@ -658,7 +658,7 @@ char *cf_add_ext(char *filename, char *ext) } // Deletes a file. -void cf_delete( char *filename, int dir_type ) +void cf_delete( const char *filename, int dir_type ) { char longname[MAX_PATH_LEN]; @@ -677,7 +677,7 @@ void cf_delete( char *filename, int dir_type ) // Same as _access function to read a file's access bits -int cf_access( char *filename, int dir_type, int mode ) +int cf_access( const char *filename, int dir_type, int mode ) { char longname[MAX_PATH_LEN]; @@ -690,7 +690,7 @@ int cf_access( char *filename, int dir_type, int mode ) // Returns 1 if file exists, 0 if not. -int cf_exist( char *filename, int dir_type ) +int cf_exist( const char *filename, int dir_type ) { char longname[MAX_PATH_LEN]; @@ -707,7 +707,7 @@ int cf_exist( char *filename, int dir_type ) return 0; } -void cf_attrib(char *filename, int set, int clear, int dir_type) +void cf_attrib(const char *filename, int set, int clear, int dir_type) { char longname[MAX_PATH_LEN]; @@ -729,7 +729,7 @@ void cf_attrib(char *filename, int set, int clear, int dir_type) } -int cf_rename(char *old_name, char *name, int dir_type) +int cf_rename(const char *old_name, const char *name, int dir_type) { Assert( CF_TYPE_SPECIFIED(dir_type) ); @@ -809,7 +809,7 @@ extern int game_cd_changed(); // error ==> NULL // -CFILE *cfopen(char *file_path, char *mode, int type, int dir_type, bool localize) +CFILE *cfopen(const char *file_path, const char *mode, int type, int dir_type, bool localize) { char longname[_MAX_PATH]; @@ -1371,7 +1371,7 @@ int cfwrite_char(char b, CFILE *file) return cfwrite( &b, sizeof(b), 1, file); } -int cfwrite_string(char *buf, CFILE *file) +int cfwrite_string(const char *buf, CFILE *file) { if ( (!buf) || (buf && !buf[0]) ) { return cfwrite_char(0, file); @@ -1383,7 +1383,7 @@ int cfwrite_string(char *buf, CFILE *file) return cfwrite_char(0, file); // write out NULL termination } -int cfwrite_string_len(char *buf, CFILE *file) +int cfwrite_string_len(const char *buf, CFILE *file) { int len = strlen(buf); @@ -1419,7 +1419,7 @@ int cfilelength( CFILE * cfile ) // returns: number of full elements actually written // // -int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile) +int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile) { Assert(cfile != NULL); Assert(buf != NULL); @@ -1544,7 +1544,7 @@ char *cfgets(char *buf, int n, CFILE *cfile) // returns: success ==> non-negative value // error ==> EOF // -int cfputs(char *str, CFILE *cfile) +int cfputs(const char *str, CFILE *cfile) { Assert(cfile != NULL); Assert(str != NULL); @@ -1575,9 +1575,9 @@ unsigned long CRCTable[256]; #define CF_CHKSUM_SAMPLE_SIZE 512 // update cur_chksum with the chksum of the new_data of size new_data_size -ushort cf_add_chksum_short(ushort seed, char *buffer, int size) +ushort cf_add_chksum_short(ushort seed, const char *buffer, int size) { - ubyte * ptr = (ubyte *)buffer; + const ubyte * ptr = (const ubyte *)buffer; unsigned int sum1,sum2; sum1 = sum2 = (int)(seed); @@ -1593,14 +1593,14 @@ ushort cf_add_chksum_short(ushort seed, char *buffer, int size) } // update cur_chksum with the chksum of the new_data of size new_data_size -unsigned long cf_add_chksum_long(unsigned long seed, char *buffer, int size) +unsigned long cf_add_chksum_long(unsigned long seed, const char *buffer, int size) { unsigned long crc; - unsigned char *p; + unsigned const char *p; unsigned long temp1; unsigned long temp2; - p = (unsigned char*)buffer; + p = (unsigned const char*)buffer; crc = seed; while (size--!=0){ @@ -1686,7 +1686,7 @@ int cf_chksum_do(CFILE *cfile, ushort *chk_short, uint *chk_long, int max_size) } // get the 2 byte checksum of the passed filename - return 0 if operation failed, 1 if succeeded -int cf_chksum_short(char *filename, ushort *chksum, int max_size, int cf_type) +int cf_chksum_short(const char *filename, ushort *chksum, int max_size, int cf_type) { int ret_val; CFILE *cfile = NULL; @@ -1736,7 +1736,7 @@ int cf_chksum_short(CFILE *file, ushort *chksum, int max_size) } // get the 32 bit CRC checksum of the passed filename - return 0 if operation failed, 1 if succeeded -int cf_chksum_long(char *filename, uint *chksum, int max_size, int cf_type) +int cf_chksum_long(const char *filename, uint *chksum, int max_size, int cf_type) { int ret_val; CFILE *cfile = NULL; diff --git a/src/cfile/cfilesystem.cpp b/src/cfile/cfilesystem.cpp index 97b320b..0da2901 100644 --- a/src/cfile/cfilesystem.cpp +++ b/src/cfile/cfilesystem.cpp @@ -471,7 +471,7 @@ void cf_build_pack_list( cf_root *root ) } -void cf_build_root_list(char *cdrom_dir) +void cf_build_root_list(const char *cdrom_dir) { Num_roots = 0; @@ -533,7 +533,7 @@ void cf_build_root_list(char *cdrom_dir) // Given a lower case list of file extensions // separated by spaces, return zero if ext is // not in the list. -int is_ext_in_list( char *ext_list, char *ext ) +int is_ext_in_list( const char *ext_list, char *ext ) { char tmp_ext[128]; @@ -785,7 +785,7 @@ void cf_build_file_list() } -void cf_build_secondary_filelist(char *cdrom_dir) +void cf_build_secondary_filelist(const char *cdrom_dir) { int i; @@ -855,7 +855,7 @@ void cf_free_secondary_filelist() // size - File size // offset - Offset into pack file. 0 if not a packfile. // Returns: If not found returns 0. -int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, int *size, int *offset, bool localize ) +int cf_find_file_location( const char *filespec, int pathtype, char *pack_filename, int *size, int *offset, bool localize ) { int i; @@ -930,11 +930,11 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in if (localize) { // create localized filespec - char temp[MAX_PATH_LEN]; - strcpy(temp, filespec); - lcl_add_dir_to_path_with_filename(filespec); + char loc_filespec[MAX_PATH_LEN]; + strcpy(loc_filespec, filespec); + lcl_add_dir_to_path_with_filename(loc_filespec); - if ( !stricmp(filespec, f->name_ext) ) { + if ( !stricmp(loc_filespec, f->name_ext) ) { if ( size ) *size = f->size; if ( offset ) *offset = f->pack_offset; if ( pack_filename ) { @@ -949,8 +949,6 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in } return 1; } - // restore original filespec - strcpy(filespec, temp); } // file either not localized or localized version not found @@ -980,9 +978,9 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in // Returns true if filename matches filespec, else zero if not -int cf_matches_spec(char *filespec, char *filename) +int cf_matches_spec(const char *filespec, const char *filename) { - char *src_ext, *dst_ext; + const char *src_ext, *dst_ext; src_ext = strchr(filespec, '.'); if (!src_ext) @@ -997,7 +995,7 @@ int cf_matches_spec(char *filespec, char *filename) return !stricmp(dst_ext, src_ext); } -int (*Get_file_list_filter)(char *filename) = NULL; +int (*Get_file_list_filter)(const char *filename) = NULL; int Skip_packfile_search = 0; int cf_file_already_in_list( int num_files, char **list, char *filename ) @@ -1024,7 +1022,7 @@ int cf_file_already_in_list( int num_files, char **list, char *filename ) // This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory // location, 'filter' only needs to be the filter itself, with no path information. // See above descriptions of cf_get_file_list() for more information about how it all works. -int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort, file_list_info *info ) +int cf_get_file_list( int max, char **list, int pathtype, const char *filter, int sort, file_list_info *info ) { char *ptr; int i, l, num_files = 0, own_flag = 0; @@ -1186,7 +1184,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort return num_files; } -int cf_file_already_in_list_preallocated( int num_files, char arr[][MAX_FILENAME_LEN], char *filename ) +int cf_file_already_in_list_preallocated( int num_files, char arr[][MAX_FILENAME_LEN], const char *filename ) { int i; @@ -1210,7 +1208,7 @@ int cf_file_already_in_list_preallocated( int num_files, char arr[][MAX_FILENAME // This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory // location, 'filter' only needs to be the filter itself, with no path information. // See above descriptions of cf_get_file_list() for more information about how it all works. -int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int pathtype, char *filter, int sort, file_list_info *info ) +int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int pathtype, const char *filter, int sort, file_list_info *info ) { int i, num_files = 0, own_flag = 0; @@ -1380,7 +1378,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char * // Input: pathtype - CF_TYPE_?? // filename - optional, if set, tacks the filename onto end of path. // Output: path - Fully qualified pathname. -void cf_create_default_path_string( char *path, int pathtype, char *filename, bool localize ) +void cf_create_default_path_string( char *path, int pathtype, const char *filename, bool localize ) { #ifdef PLAT_UNIX if ( filename && strpbrk(filename, "/") ) { diff --git a/src/cmdline/cmdline.cpp b/src/cmdline/cmdline.cpp index 1c6036f..829e7f1 100644 --- a/src/cmdline/cmdline.cpp +++ b/src/cmdline/cmdline.cpp @@ -221,18 +221,18 @@ class cmdline_parm { public: cmdline_parm *next, *prev; - char *name; // name of parameter, must start with '-' char + const char *name; // name of parameter, must start with '-' char #ifdef PLAT_UNIX - char *name_s; // single letter argument + const char *name_s; // single letter argument #endif - char *help; // help text for this parameter + const char *help; // help text for this parameter char *args; // string value for parameter arguements (NULL if no arguements) int name_found; // true if parameter on command line, otherwise false #ifndef PLAT_UNIX - cmdline_parm(char *name, char *help); + cmdline_parm(const char *name, const char *help); #else - cmdline_parm(char *name, char *name_s, char *help); + cmdline_parm(const char *name, const char *name_s, const char *help); #endif ~cmdline_parm(); int found(); @@ -576,9 +576,9 @@ void print_instructions() // name_ - name of the parameter, must start with '-' character // help_ - help text for this parameter #ifndef PLAT_UNIX -cmdline_parm::cmdline_parm(char *name_, char *help_) +cmdline_parm::cmdline_parm(const char *name_, const char *help_) #else -cmdline_parm::cmdline_parm(char *name_, char *name_s_, char *help_) +cmdline_parm::cmdline_parm(const char *name_, const char *name_s_, const char *help_) #endif { name = name_; diff --git a/src/controlconfig/controlsconfig.cpp b/src/controlconfig/controlsconfig.cpp index 02af2b4..7d3027a 100644 --- a/src/controlconfig/controlsconfig.cpp +++ b/src/controlconfig/controlsconfig.cpp @@ -351,12 +351,12 @@ #define CONTROL_W_COORD 2 #define CONTROL_H_COORD 3 -char* Conflict_background_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char* Conflict_background_bitmap_fname[GR_NUM_RESOLUTIONS] = { "ControlConfig", // GR_640 "2_ControlConfig" // GR_1024 }; -char* Conflict_background_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char* Conflict_background_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "ControlConfig-m", // GR_640 "2_ControlConfig-m" // GR_1024 }; @@ -445,7 +445,7 @@ int Conflict_bright = 0; static int Num_cc_lines; static struct { - char *label; + const char *label; int cc_index; // index into Control_config of item int y; // Y coordinate of line int kx, kw, jx, jw; // x start and width of keyboard and joystick bound text @@ -1569,7 +1569,7 @@ void control_config_button_pressed(int n) } } -char *control_config_tooltip_handler(char *str) +const char *control_config_tooltip_handler(const char *str) { int i; @@ -1749,7 +1749,7 @@ void control_config_close() void control_config_do_frame(float frametime) { - char buf[256], *str, *jptr; + char buf[256], *jptr; int i, j, k, w, x, y, z, len, line, conflict; int font_height = gr_get_font_height(); int select_tease_line = -1; // line mouse is down on, but won't be selected until button released @@ -2236,7 +2236,7 @@ void control_config_do_frame(float frametime) i = Conflicts[z].joy; gr_set_color_fast(&Color_text_normal); - str = XSTR( "Control conflicts with:", 209); + const char *str = XSTR( "Control conflicts with:", 209); gr_get_string_size(&w, NULL, str); gr_printf(x - w / 2, y - font_height, str); diff --git a/src/controlconfig/controlsconfigcommon.cpp b/src/controlconfig/controlsconfigcommon.cpp index 89f390b..39f3b19 100644 --- a/src/controlconfig/controlsconfigcommon.cpp +++ b/src/controlconfig/controlsconfigcommon.cpp @@ -547,7 +547,7 @@ config_item Control_config[CCFG_MAX + 1] = { { -1, -1, -1, "" } }; -char *Scan_code_text_german[] = { +const char *Scan_code_text_german[] = { "", "Esc", "1", "2", "3", "4", "5", "6", #ifndef MAKE_FS1 "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab", @@ -597,7 +597,7 @@ char *Scan_code_text_german[] = { "", "", "", "", "", "", "", "", }; -char *Joy_button_text_german[] = { +const char *Joy_button_text_german[] = { "Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6", "Knopf 7", "Knopf 8", "Knopf 9", "Knopf 10", "Knopf 11", "Knopf 12", "Knopf 13", "Knopf 14", "Knopf 15", "Knopf 16", "Knopf 17", "Knopf 18", @@ -606,7 +606,7 @@ char *Joy_button_text_german[] = { "Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts" }; -char *Scan_code_text_french[] = { +const char *Scan_code_text_french[] = { "", "\x90""chap", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", @@ -648,7 +648,7 @@ char *Scan_code_text_french[] = { "", "", "", "", "", "", "", "", }; -char *Joy_button_text_french[] = { +const char *Joy_button_text_french[] = { "Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6", "Bouton 7", "Bouton 8", "Bouton 9", "Bouton 10", "Bouton 11", "Bouton 12", "Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18", @@ -658,7 +658,7 @@ char *Joy_button_text_french[] = { }; // This is the text that is displayed on the screen for the keys a player selects -char *Scan_code_text_english[] = { +const char *Scan_code_text_english[] = { "", "Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", @@ -700,7 +700,7 @@ char *Scan_code_text_english[] = { "", "", "", "", "", "", "", "", }; -char *Joy_button_text_english[] = { +const char *Joy_button_text_english[] = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8", "Button 9", "Button 10", "Button 11", "Button 12", "Button 13", "Button 14", "Button 15", "Button 16", "Button 17", "Button 18", @@ -709,7 +709,7 @@ char *Joy_button_text_english[] = { "Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right" }; -char *Scan_code_text_polish[] = { +const char *Scan_code_text_polish[] = { "", "Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", @@ -751,7 +751,7 @@ char *Scan_code_text_polish[] = { "", "", "", "", "", "", "", "", }; -char *Joy_button_text_polish[] = { +const char *Joy_button_text_polish[] = { "Przyc.1", "Przyc.2", "Przyc.3", "Przyc.4", "Przyc.5", "Przyc.6", "Przyc.7", "Przyc.8", "Przyc.9", "Przyc.10", "Przyc.11", "Przyc.12", "Przyc.13", "Przyc.14", "Przyc.15", "Przyc.16", "Przyc.17", "Przyc.18", @@ -760,8 +760,8 @@ char *Joy_button_text_polish[] = { "Przyc.31", "Przyc.32", "Hat Ty\xB3", "Hat Prz\xF3\x64", "Hat Lewo", "Hat Prawo" }; -char **Scan_code_text = Scan_code_text_english; -char **Joy_button_text = Joy_button_text_english; +const char **Scan_code_text = Scan_code_text_english; +const char **Joy_button_text = Joy_button_text_english; void set_modifier_status() { @@ -788,7 +788,7 @@ void set_modifier_status() } } -int translate_key_to_index(char *key) +int translate_key_to_index(const char *key) { int i, index = -1, alt = 0, shift = 0, max_scan_codes; @@ -811,7 +811,7 @@ int translate_key_to_index(char *key) key++; } - char *translated_shift; + const char *translated_shift; if(Lcl_gr){ translated_shift = "Shift"; @@ -872,7 +872,7 @@ int translate_key_to_index(char *key) // Both are 'key' and the return value are descriptive strings that can be displayed // directly to the user. If 'key' isn't a real key or not normally bound to anything, // or there is no key current bound to the function, NULL is returned. -char *translate_key(char *key) +const char *translate_key(const char *key) { int index = -1, code = -1; @@ -891,7 +891,7 @@ char *translate_key(char *key) return textify_scancode(code); } -char *textify_scancode(int code) +const char *textify_scancode(int code) { static char text[40]; diff --git a/src/cutscene/cutscenes.cpp b/src/cutscene/cutscenes.cpp index 496fed8..7147abf 100644 --- a/src/cutscene/cutscenes.cpp +++ b/src/cutscene/cutscenes.cpp @@ -181,11 +181,11 @@ #include "alphacolors.h" #include "localize.h" -char *Cutscene_bitmap_name[GR_NUM_RESOLUTIONS] = { +const char *Cutscene_bitmap_name[GR_NUM_RESOLUTIONS] = { "ViewFootage", "2_ViewFootage" }; -char *Cutscene_mask_name[GR_NUM_RESOLUTIONS] = { +const char *Cutscene_mask_name[GR_NUM_RESOLUTIONS] = { "ViewFootage-m", "2_ViewFootage-m" }; @@ -259,7 +259,7 @@ void cutscene_tbl_close() // function to return 0 based index of which CD a particular movie is on // returns -1 on failure. -int cutscenes_get_cd_num( char *filename ) +int cutscenes_get_cd_num( const char *filename ) { #if defined(OEM_BUILD) return 0; // only 1 cd for OEM @@ -277,7 +277,7 @@ int cutscenes_get_cd_num( char *filename ) } // marks a cutscene as viewable -void cutscene_mark_viewable(char *filename) +void cutscene_mark_viewable(const char *filename) { int i; @@ -411,7 +411,7 @@ static int Text_line_size[MAX_TEXT_LINES]; static char *Text_lines[MAX_TEXT_LINES]; -int cutscenes_validate_cd(char *mve_name, int prompt_for_cd) +int cutscenes_validate_cd(const char *mve_name, int prompt_for_cd) { int cd_present = 0; int cd_drive_num; diff --git a/src/debris/debris.cpp b/src/debris/debris.cpp index 665eb96..d2a19ec 100644 --- a/src/debris/debris.cpp +++ b/src/debris/debris.cpp @@ -259,7 +259,7 @@ int Debris_inited = 0; int Debris_model = -1; int Debris_vaporize_model = -1; int Debris_num_submodels = 0; -char * Debris_texture_files[MAX_SPECIES_NAMES] = { +const char * Debris_texture_files[MAX_SPECIES_NAMES] = { NOX("debris01a"), // Terran NOX("debris01b"), // Species B NOX("debris01c"), // Shivan diff --git a/src/debugconsole/console.cpp b/src/debugconsole/console.cpp index 0a6702f..19cd30d 100644 --- a/src/debugconsole/console.cpp +++ b/src/debugconsole/console.cpp @@ -124,7 +124,7 @@ static int Num_debug_commands = 0; static debug_command *Debug_command[MAX_COMMANDS]; -debug_command::debug_command(char *_name, char *_help, void (*_func)() ) +debug_command::debug_command(const char *_name, const char *_help, void (*_func)() ) { int i; @@ -172,7 +172,7 @@ int Dc_status; // If this is set, then print out the current status of the comm char *Dc_arg; // The (lowercased) string value of the argument retrieved from dc_arg char *Dc_arg_org; // Dc_arg before it got converted to lowercase uint Dc_arg_type; // The type of dc_arg. -char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on. +const char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on. int Dc_arg_int; // If Dc_arg_type & ARG_INT is set, then this is the value float Dc_arg_float; // If Dc_arg_type & ARG_FLOAT is set, then this is the value @@ -211,7 +211,7 @@ TOKEN_CODE scanner_token; char scanner_token_string[MAX_TOKEN_STRING_LENGTH]; char scanner_word_string[MAX_TOKEN_STRING_LENGTH]; -char * scanner_bufferp = ""; +const char * scanner_bufferp = ""; char * scanner_tokenp = scanner_token_string; CHAR_CODE scanner_char_table[256]; @@ -325,7 +325,7 @@ void scanner_get_token() scanner_downshift_word(); } -void scanner_start_command( char * s ) +void scanner_start_command( const char * s ) { scanner_bufferp = s; scanner_get_char(); @@ -435,7 +435,7 @@ void dc_get_arg(uint type) void debug_help(); -void debug_do_command(char * command) +void debug_do_command(const char * command) { int i; @@ -613,7 +613,7 @@ void debug_output( char c ) debug_text[debug_y][debug_x] = 0; } -void dc_printf(char *format, ...) +void dc_printf(const char *format, ...) { char tmp[DCOLS*2]; va_list args; diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 9da8e99..7ff42b8 100644 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -138,7 +138,7 @@ int Demo_error = DEMO_ERROR_NONE; #define DEMO_FLOAT(vl) do { DEMO_DATA(vl, sizeof(float)); } while(0) #define DEMO_VECTOR(vl) do { DEMO_DATA(vl, sizeof(vector)); } while(0) #define DEMO_MATRIX(vl) do { DEMO_DATA(vl, sizeof(matrix)); } while(0) -#define DEMO_STRING(vl) do { int stlen; if(Game_mode & GM_DEMO_RECORD){ stlen = strlen(vl); if(stlen <= 0){ break; } DEMO_DATA(stlen, sizeof(ushort)); DEMO_DATA(*vl, strlen(vl)); } else { ushort len = 0; DEMO_USHORT(len); DEMO_DATA(*vl, len); vl[len] = '\0'; } } while(0) +#define DEMO_STRING(vl) do { /*int stlen; if(Game_mode & GM_DEMO_RECORD){ stlen = strlen(vl); if(stlen <= 0){ break; } DEMO_DATA(stlen, sizeof(ushort)); DEMO_DATA(*vl, strlen(vl)); } else { ushort len = 0; DEMO_USHORT(len); DEMO_DATA(*vl, len); vl[len] = '\0'; }*/ } while(0) // demo events types #define DE_DUMP 1 // standard object dump @@ -275,7 +275,7 @@ int demo_do_frame_end() // initialize a demo for recording // NOTE : call this after loading the mission and going through the briefing, but _before_ physically moving into the mission -int demo_start_record(char *file) +int demo_start_record(const char *file) { #ifndef DEMO_SYSTEM return 0; @@ -319,7 +319,7 @@ int demo_start_record(char *file) } // initialize a demo for playback - calling this will load up the demo file and move the player into the playback state -int demo_start_playback(char *file) +int demo_start_playback(const char *file) { #ifndef DEMO_SYSTEM return 0; @@ -578,7 +578,7 @@ void demo_POST_primary_fired(object *objp, int banks, int linked) } // post a unique message -void demo_POST_unique_message(char *id, char *who_from, int m_source, int priority) +void demo_POST_unique_message(const char *id, const char *who_from, int m_source, int priority) { // sanity if((id == NULL) || (who_from == NULL) || (strlen(id) <= 0) || (strlen(who_from) <= 0)){ @@ -620,7 +620,7 @@ void demo_POST_builtin_message(int type, ship *shipp, int priority, int timing) } // post an object create message -void demo_POST_obj_create(char *pobj_name, int signature) +void demo_POST_obj_create(const char *pobj_name, int signature) { // write it ubyte event = DE_OBJ_CREATE; diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 6eff45c..707911e 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -1227,7 +1227,7 @@ int Player_multi_died_check = -1; // Internal function prototypes void game_maybe_draw_mouse(float frametime); void init_animating_pointer(); -void load_animating_pointer(char *filename, int dx, int dy); +void load_animating_pointer(const char *filename, int dx, int dy); void unload_animating_pointer(); void game_do_training_checks(); void game_shutdown(void); @@ -1242,19 +1242,19 @@ void verify_weapons_tbl(); void display_title_screen(); // loading background filenames -static char *Game_loading_bground_fname[GR_NUM_RESOLUTIONS] = { +static const char *Game_loading_bground_fname[GR_NUM_RESOLUTIONS] = { "LoadingBG", // GR_640 "2_LoadingBG" // GR_1024 }; -static char *Game_loading_ani_fname[GR_NUM_RESOLUTIONS] = { +static const char *Game_loading_ani_fname[GR_NUM_RESOLUTIONS] = { "Loading.ani", // GR_640 "2_Loading.ani" // GR_1024 }; #if defined(FS2_DEMO) || defined(FS1_DEMO) -static char *Game_demo_title_screen_fname[GR_NUM_RESOLUTIONS] = { +static const char *Game_demo_title_screen_fname[GR_NUM_RESOLUTIONS] = { #ifdef FS1_DEMO "DemoTitle1", #else @@ -1263,7 +1263,7 @@ static char *Game_demo_title_screen_fname[GR_NUM_RESOLUTIONS] = { "2_PreLoad" }; #elif defined(OEM_BUILD) -static char *Game_demo_title_screen_fname[GR_NUM_RESOLUTIONS] = { +static const char *Game_demo_title_screen_fname[GR_NUM_RESOLUTIONS] = { "OEMPreLoad", "2_OEMPreLoad" }; @@ -1303,7 +1303,7 @@ int Game_sound_env_update_timestamp; // WARPIN CRAP END -------------------------------------------------------------------------------------------- -fs_builtin_mission *game_find_builtin_mission(char *filename) +fs_builtin_mission *game_find_builtin_mission(const char *filename) { int idx; @@ -2346,7 +2346,7 @@ DCF(gamma,"Sets Gamma factor") void game_init() { - char *ptr; + const char *ptr; int depth = 16; Game_current_mission_filename[0] = 0; @@ -7465,7 +7465,7 @@ void init_animating_pointer() // // input: filename => filename of animation file that holds the animation // -void load_animating_pointer(char *filename, int dx, int dy) +void load_animating_pointer(const char *filename, int dx, int dy) { int fps; animating_obj *am; @@ -8499,7 +8499,7 @@ uint game_get_cd_used_space(char *path) // if volume_name is non-null, the CD name must match that -int find_freespace_cd(char *volume_name) +int find_freespace_cd(const char *volume_name) { #ifndef PLAT_UNIX char oldpath[MAX_PATH]; @@ -8720,7 +8720,7 @@ int game_cd_changed() // check if _any_ FreeSpace2 CDs are in the drive // return: 1 => CD now in drive // 0 => Could not find CD, they refuse to put it in the drive -int game_do_cd_check(char *volume_name) +int game_do_cd_check(const char *volume_name) { #if !defined(GAME_CD_CHECK) return 1; @@ -8771,7 +8771,7 @@ int game_do_cd_check(char *volume_name) // check if _any_ FreeSpace2 CDs are in the drive // return: 1 => CD now in drive // 0 => Could not find CD, they refuse to put it in the drive -int game_do_cd_check_specific(char *volume_name, int cdnum) +int game_do_cd_check_specific(const char *volume_name, int cdnum) { int cd_present = 0; int cd_drive_num; @@ -8819,7 +8819,7 @@ int game_do_cd_check_specific(char *volume_name, int cdnum) } // only need to do this in RELEASE_REAL -int game_do_cd_mission_check(char *filename) +int game_do_cd_mission_check(const char *filename) { #ifdef RELEASE_REAL int cd_num; diff --git a/src/freespace2/unixmain.cpp b/src/freespace2/unixmain.cpp index a552aa2..f5ee280 100644 --- a/src/freespace2/unixmain.cpp +++ b/src/freespace2/unixmain.cpp @@ -4,6 +4,9 @@ #include "osregistry.h" #include "osapi.h" +#undef malloc +#undef free + int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow); #if defined(__APPLE__) && !defined(MACOSX) diff --git a/src/gamehelp/contexthelp.cpp b/src/gamehelp/contexthelp.cpp index fff58a1..452dedd 100644 --- a/src/gamehelp/contexthelp.cpp +++ b/src/gamehelp/contexthelp.cpp @@ -188,7 +188,7 @@ typedef struct { } help_overlay; // Added for FS1 -char *Help_overlays[MAX_HELP_OVERLAYS] = { +const char *Help_overlays[MAX_HELP_OVERLAYS] = { "ship_help_over", "weapon_help_over", #ifndef FS1_DEMO @@ -214,7 +214,7 @@ char *Help_overlays[MAX_HELP_OVERLAYS] = { }; // new help.tbl file way -char *help_overlay_section_names[MAX_HELP_OVERLAYS] = { +const char *help_overlay_section_names[MAX_HELP_OVERLAYS] = { "$ship", // ship_help "$weapon", // weapon_help "$briefing", // briefing diff --git a/src/gamehelp/gameplayhelp.cpp b/src/gamehelp/gameplayhelp.cpp index 94cc6ac..e0293e1 100644 --- a/src/gamehelp/gameplayhelp.cpp +++ b/src/gamehelp/gameplayhelp.cpp @@ -184,14 +184,14 @@ int Gp_last_screen; #define CONTINUE_BUTTON 2 struct gameplay_help_buttons { - char *filename; + const char *filename; int x, y; int hotspot; int tab; int flags; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - gameplay_help_buttons(char *name, int x1, int y1, int h) : filename(name), x(x1), y(y1), hotspot(h) {} + gameplay_help_buttons(const char *name, int x1, int y1, int h) : filename(name), x(x1), y(y1), hotspot(h) {} }; static gameplay_help_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = { @@ -232,12 +232,12 @@ static UI_XSTR Game_help_text[GR_NUM_RESOLUTIONS][GAME_HELP_NUM_TEXT] = { }; #endif -static char *Game_help_filename[GR_NUM_RESOLUTIONS] = { +static const char *Game_help_filename[GR_NUM_RESOLUTIONS] = { "F1", "2_F1" }; -static char *Game_help_mask_filename[GR_NUM_RESOLUTIONS] = { +static const char *Game_help_mask_filename[GR_NUM_RESOLUTIONS] = { "F1-m", "2_F1-m" }; @@ -314,7 +314,7 @@ void gameplay_help_blit_control_line(int x, int y, int id) gr_string(x+KEY_DESCRIPTION_OFFSET, y, XSTR(ci->text, CONTROL_CONFIG_XSTR + id)); } -void gameplay_help_blit_control_line_raw(int x, int y, char *control_text, char *control_description) +void gameplay_help_blit_control_line_raw(int x, int y, const char *control_text, const char *control_description) { gr_string(x,y,control_text); gr_string(x+KEY_DESCRIPTION_OFFSET,y,control_description); @@ -322,7 +322,7 @@ void gameplay_help_blit_control_line_raw(int x, int y, char *control_text, char // game_play_help_set_title() will display the title for the help screen and // set the font for the rest of the screen -void gameplay_help_set_title(char *title) +void gameplay_help_set_title(const char *title) { int sy=TITLE_Y; char buf[128]; diff --git a/src/gamesequence/gamesequence.cpp b/src/gamesequence/gamesequence.cpp index f7b4c13..6021ff3 100644 --- a/src/gamesequence/gamesequence.cpp +++ b/src/gamesequence/gamesequence.cpp @@ -266,7 +266,7 @@ static int state_in_event_processer = 0; // Text of state, corresponding to #define values for GS_STATE_* //XSTR:OFF -char *GS_event_text[] = +const char *GS_event_text[] = { "GS_EVENT_MAIN_MENU", "GS_EVENT_START_GAME", @@ -347,7 +347,7 @@ char *GS_event_text[] = // Text of state, corresponding to #define values for GS_STATE_* //XSTR:OFF -char *GS_state_text[] = +const char *GS_state_text[] = { "NOT A VALID STATE", "GS_STATE_MAIN_MENU", // 1 diff --git a/src/gamesnd/eventmusic.cpp b/src/gamesnd/eventmusic.cpp index 5911f66..2f6a880 100644 --- a/src/gamesnd/eventmusic.cpp +++ b/src/gamesnd/eventmusic.cpp @@ -205,7 +205,7 @@ float Pattern_num_measures[MAX_SOUNDTRACKS][MAX_PATTERNS]; // stores the number of bytes per measure (data from music.tbl) int Pattern_bytes_per_measure[MAX_SOUNDTRACKS][MAX_PATTERNS]; -char* Pattern_names[MAX_PATTERNS] = +const char* Pattern_names[MAX_PATTERNS] = { //XSTR:OFF "NRML_1", // Normal Song 1 @@ -227,7 +227,7 @@ char* Pattern_names[MAX_PATTERNS] = //XSTR:ON }; -char* Pattern_description[MAX_PATTERNS] = +const char* Pattern_description[MAX_PATTERNS] = { //XSTR:OFF "normal 1", @@ -1504,7 +1504,7 @@ void event_music_set_soundtrack(char *name) } } -int event_music_get_spooled_music_index(char *name) +int event_music_get_spooled_music_index(const char *name) { // find the correct index for the event music for ( int i = 0; i < Num_music_files; i++ ) { @@ -1517,7 +1517,7 @@ int event_music_get_spooled_music_index(char *name) } // set a score based on name -void event_music_set_score(int score_index, char *name) +void event_music_set_score(int score_index, const char *name) { Assert(score_index < NUM_SCORES); diff --git a/src/gamesnd/gamesnd.cpp b/src/gamesnd/gamesnd.cpp index 1732734..b30f054 100644 --- a/src/gamesnd/gamesnd.cpp +++ b/src/gamesnd/gamesnd.cpp @@ -301,7 +301,7 @@ void gamesnd_unload_interface_sounds() // // Parse a sound effect line // -void gamesnd_parse_line(game_snd *gs, char *tag) +void gamesnd_parse_line(game_snd *gs, const char *tag) { int is_3d; diff --git a/src/globalincs/systemvars.cpp b/src/globalincs/systemvars.cpp index 3f7965b..7c4de5c 100644 --- a/src/globalincs/systemvars.cpp +++ b/src/globalincs/systemvars.cpp @@ -349,7 +349,7 @@ void game_busy() static int Num_monitors = 0; static monitor *Monitor[MAX_MONITORS]; -monitor::monitor( char *_name ) +monitor::monitor( const char *_name ) { int i; @@ -385,7 +385,7 @@ monitor::monitor( char *_name ) Num_monitors++; } - name = _name; + name = (char*)_name; value = 0; } diff --git a/src/globalincs/version.cpp b/src/globalincs/version.cpp index 1e13922..b68499d 100644 --- a/src/globalincs/version.cpp +++ b/src/globalincs/version.cpp @@ -63,7 +63,7 @@ // 1 if same version // 2 if higher version // fills in user version and latest version values if non-NULL -int version_compare(char *filename, int *u_major, int *u_minor, int *u_build, int *l_major, int *l_minor, int *l_build) +int version_compare(const char *filename, int *u_major, int *u_minor, int *u_build, int *l_major, int *l_minor, int *l_build) { int usr_major, usr_minor, usr_build; int latest_major, latest_minor, latest_build; diff --git a/src/graphics/2d.cpp b/src/graphics/2d.cpp index bde61c5..ef5e17f 100644 --- a/src/graphics/2d.cpp +++ b/src/graphics/2d.cpp @@ -655,7 +655,7 @@ DCF(clear_color, "set clear color r, g, b") gr_set_clear_color(r, g, b); } -void gr_set_palette_internal( char *name, ubyte * palette, int restrict_font_to_128 ) +void gr_set_palette_internal( const char *name, ubyte * palette, int restrict_font_to_128 ) { if ( palette == NULL ) { // Create a default palette @@ -700,7 +700,7 @@ void gr_set_palette_internal( char *name, ubyte * palette, int restrict_font_to_ } -void gr_set_palette( char *name, ubyte * palette, int restrict_font_to_128 ) +void gr_set_palette( const char *name, ubyte * palette, int restrict_font_to_128 ) { char *p; palette_flush(); diff --git a/src/graphics/font.cpp b/src/graphics/font.cpp index 137de10..7e7efa2 100644 --- a/src/graphics/font.cpp +++ b/src/graphics/font.cpp @@ -342,7 +342,7 @@ int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing) return letter; } -int get_centered_x(char *s) +int get_centered_x(const char *s) { int w,w2,s2; @@ -407,7 +407,7 @@ int gr_get_font_height() } } -void gr_get_string_size(int *w1, int *h1, char *text, int len) +void gr_get_string_size(int *w1, int *h1, const char *text, int len) { int longest_width; int width,spacing; @@ -526,7 +526,7 @@ void gr8_string( int sx, int sy, char *s ) } */ -void gr8_string(int sx, int sy, char *s ) +void gr8_string(int sx, int sy, const char *s ) { int row,width, spacing, letter; int x, y; @@ -669,7 +669,7 @@ HFONT MyhFont = NULL; extern HDC hDibDC; #endif -void gr_string_win(int x, int y, char *s) +void gr_string_win(int x, int y, const char *s) { #ifdef PLAT_UNIX // STUB_FUNCTION; @@ -728,7 +728,7 @@ void gr_string_win(int x, int y, char *s) #endif } -void gr_get_string_size_win(int *w, int *h, char *text) +void gr_get_string_size_win(int *w, int *h, const char *text) { #ifdef PLAT_UNIX // STUB_FUNCTION; @@ -765,7 +765,7 @@ void gr_get_string_size_win(int *w, int *h, char *text) char grx_printf_text[2048]; -void _cdecl gr_printf( int x, int y, char * format, ... ) +void _cdecl gr_printf( int x, int y, const char * format, ... ) { va_list args; @@ -823,7 +823,7 @@ void gr_font_close() // Returns -1 if couldn't init font, otherwise returns the // font id number. -int gr_create_font(char * typeface) +int gr_create_font(const char * typeface) { CFILE *fp; font *fnt; @@ -982,7 +982,7 @@ void gr_font_init() // Returns -1 if couldn't init font, otherwise returns the // font id number. -int gr_init_font(char * typeface) +int gr_init_font(const char * typeface) { int Loaded_fontnum; diff --git a/src/graphics/gropengl.cpp b/src/graphics/gropengl.cpp index 3081771..16542cb 100644 --- a/src/graphics/gropengl.cpp +++ b/src/graphics/gropengl.cpp @@ -999,7 +999,7 @@ void gr_opengl_aabitmap(int x, int y) gr_aabitmap_ex(dx1,dy1,dx2-dx1+1,dy2-dy1+1,sx,sy); } -void gr_opengl_string( int sx, int sy, char *s ) +void gr_opengl_string( int sx, int sy, const char *s ) { int width, spacing, letter; int x, y; @@ -1615,7 +1615,7 @@ void gr_opengl_set_color_fast(color *dst) gr_screen.current_color = *dst; } -void gr_opengl_print_screen(char *filename) +void gr_opengl_print_screen(const char *filename) { #ifdef GL_VERSION_1_2 char tmp[MAX_FILENAME_LEN]; @@ -2896,7 +2896,7 @@ void opengl_zbias(int bias) } } -extern char *Osreg_title; +extern const char *Osreg_title; void gr_opengl_init() { if ( Inited ) { diff --git a/src/hud/hud.cpp b/src/hud/hud.cpp index 005ef18..d192f43 100644 --- a/src/hud/hud.cpp +++ b/src/hud/hud.cpp @@ -416,7 +416,7 @@ int Hud_text_flash_coords[GR_NUM_RESOLUTIONS][2] = { } }; void hud_init_text_flash_gauge(); -void hud_start_text_flash(char *txt, int t); +void hud_start_text_flash(const char *txt, int t); void hud_maybe_show_text_flash_icon(); @@ -517,7 +517,7 @@ int Netlag_coords[GR_NUM_RESOLUTIONS][2] = { 627, 529 } }; -char Netlag_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Netlag_fname[GR_NUM_RESOLUTIONS] = { "netlag1", "netlag1" }; @@ -561,7 +561,7 @@ int Kills_text_val_coords[GR_NUM_RESOLUTIONS][2] = { } }; -char Kills_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Kills_fname[GR_NUM_RESOLUTIONS] = { "kills1", "kills1" }; @@ -577,7 +577,7 @@ int Head_frame_coords[GR_NUM_RESOLUTIONS][2] = { 5, 56 } }; -char Head_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Head_fname[GR_NUM_RESOLUTIONS] = { "head1", "head1" }; @@ -609,7 +609,7 @@ int Mission_time_text_val_coords[GR_NUM_RESOLUTIONS][2] = { 995, 728 } }; -char Mission_time_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Mission_time_fname[GR_NUM_RESOLUTIONS] = { "time1", "time1" }; @@ -661,7 +661,7 @@ int Support_text_dock_val_coords[GR_NUM_RESOLUTIONS][2] = { // time value for " 524, -1 } }; -char Support_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Support_fname[GR_NUM_RESOLUTIONS] = { "support1", "support1" }; @@ -670,7 +670,7 @@ char Support_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { #define NUM_DAMAGE_GAUGES 3 static hud_frames Damage_gauges[NUM_DAMAGE_GAUGES]; static int Damage_gauges_loaded = 0; -char *Damage_gauge_fnames[GR_NUM_RESOLUTIONS][NUM_DAMAGE_GAUGES] = +const char *Damage_gauge_fnames[GR_NUM_RESOLUTIONS][NUM_DAMAGE_GAUGES] = { //XSTR:OFF { // GR_640 @@ -1944,7 +1944,7 @@ void hud_show_damage_popup() } // init the members of the hud_anim struct to default values -void hud_anim_init(hud_anim *ha, int sx, int sy, char *filename) +void hud_anim_init(hud_anim *ha, int sx, int sy, const char *filename) { ha->first_frame = -1; ha->num_frames = 0; @@ -2055,7 +2055,7 @@ void hud_init_text_flash_gauge() { } -void hud_start_text_flash(char *txt, int t) +void hud_start_text_flash(const char *txt, int t) { // bogus if(txt == NULL){ @@ -2089,7 +2089,7 @@ void hud_maybe_show_text_flash_icon() hud_show_text_flash_icon(Hud_text_flash, Hud_text_flash_coords[gr_screen.res][1], bright); } -void hud_show_text_flash_icon(char *txt, int y, int bright) +void hud_show_text_flash_icon(const char *txt, int y, int bright) { int w, h; @@ -2957,7 +2957,7 @@ void hud_maybe_display_objective_message() // return wing slot (0->3) based on name of ship. Assumes ship is from Alpha,Beta, or // Gamma wings -int hud_wing_slot_from_name(char *name) +int hud_wing_slot_from_name(const char *name) { int rval; char num[2]; diff --git a/src/hud/hudconfig.cpp b/src/hud/hudconfig.cpp index 8421dc5..54e92f1 100644 --- a/src/hud/hudconfig.cpp +++ b/src/hud/hudconfig.cpp @@ -313,7 +313,7 @@ float Radar_ranges[RR_MAX_RANGES] = { 10000000.0f, // infinity }; -char *Radar_range_text(int n) +const char *Radar_range_text(int n) { #if RR_MAX_RANGES != 3 #error Number of ranges is wrong! @@ -435,7 +435,7 @@ int HUD_default_popup_mask2 = 0 // kills gauge }; -void hud_config_color_save(char *name); +void hud_config_color_save(const char *name); void hud_config_select_all_toggle(int toggle); int HC_select_all = 0; @@ -448,19 +448,19 @@ int HC_select_all = 0; #pragma warning(disable:4710) #endif -char *Hud_config_fname[GR_NUM_RESOLUTIONS] = { +const char *Hud_config_fname[GR_NUM_RESOLUTIONS] = { "HUDConfig", "2_HUDConfig" }; -char *Hud_config_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Hud_config_mask_fname[GR_NUM_RESOLUTIONS] = { "HUDConfig-m", "2_HUDConfig-m" }; struct HC_gauge_region { - char *filename; + const char *filename; int x,y; int hotspot; int use_iff; @@ -470,7 +470,7 @@ struct HC_gauge_region int color; UI_BUTTON button; - HC_gauge_region(char *name, int x1, int y1, int h, int iff, int cp, int b, int nf, int cl) : filename(name), x(x1), y(y1), hotspot(h), use_iff(iff), can_popup(cp), bitmap(b), nframes(nf), color(cl){} + HC_gauge_region(const char *name, int x1, int y1, int h, int iff, int cp, int b, int nf, int cl) : filename(name), x(x1), y(y1), hotspot(h), use_iff(iff), can_popup(cp), bitmap(b), nframes(nf), color(cl){} }; // hud config gauges @@ -623,7 +623,7 @@ int HC_gauge_description_coords[GR_NUM_RESOLUTIONS][3] = { } }; -char *HC_gauge_descriptions(int n) +const char *HC_gauge_descriptions(int n) { switch(n) { case 0: @@ -861,7 +861,7 @@ void hud_config_set_alpha(int gauge, int a); #define HC_SPECIAL_TEXT 1 typedef struct HC_special_bitmap { - char *filename; + const char *filename; int x,y; int bitmap; } HC_special_bitmap; @@ -887,22 +887,22 @@ static int HC_gauge_selected; // gauge is selected #define HC_BRIGHTNESS_SLIDER 0 struct hc_sliders { // base slider - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; int dot_w; int dots; // left and right buttons - char *left_filename; + const char *left_filename; int left_mask, left_x, left_y; - char *right_filename; + const char *right_filename; int right_mask, right_x, right_y; // slider control UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below.. - hc_sliders(char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, char *_left_filename, int _left_mask, int _left_x, int _left_y, char *_right_filename, int _right_mask, int _right_x, int _right_y) : + hc_sliders(const char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, const char *_left_filename, int _left_mask, int _left_x, int _left_y, const char *_right_filename, int _right_mask, int _right_x, int _right_y) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), dot_w(_dot_w), dots(_dots), left_filename(_left_filename), left_mask(_left_mask), left_x(_left_x), left_y(_left_y), right_filename(_right_filename), right_mask(_right_mask), right_x(_right_x), right_y(_right_y) {} }; @@ -974,7 +974,7 @@ int HC_slider_coords[GR_NUM_RESOLUTIONS][NUM_HC_SLIDERS][4] = { }; #define HCS_CONV(__v) ( 255 - (__v) ) -char *HC_slider_fname[GR_NUM_RESOLUTIONS] = { +const char *HC_slider_fname[GR_NUM_RESOLUTIONS] = { "slider", "2_slider" }; @@ -1975,7 +1975,7 @@ void hud_config_as_player() // RGB color stuff // -void hud_config_color_save(char *name) +void hud_config_color_save(const char *name) { int idx; CFILE *out = cfopen(name, "wt", CFILE_NORMAL, CF_TYPE_PLAYERS); @@ -2001,7 +2001,7 @@ void hud_config_color_save(char *name) cfclose(out); } -void hud_config_color_load(char *name) +void hud_config_color_load(const char *name) { int idx, rval; char str[1024] = ""; diff --git a/src/hud/hudescort.cpp b/src/hud/hudescort.cpp index 9614b1e..9073f68 100644 --- a/src/hud/hudescort.cpp +++ b/src/hud/hudescort.cpp @@ -205,7 +205,7 @@ int Monitoring_coords[GR_NUM_RESOLUTIONS][2] = { } }; -char *Escort_gauge_filenames[GR_NUM_RESOLUTIONS][MAX_ESCORT_SHIPS] = +const char *Escort_gauge_filenames[GR_NUM_RESOLUTIONS][MAX_ESCORT_SHIPS] = { //XSTR:OFF { // GR_640 diff --git a/src/hud/hudmessage.cpp b/src/hud/hudmessage.cpp index 5b81212..adbad13 100644 --- a/src/hud/hudmessage.cpp +++ b/src/hud/hudmessage.cpp @@ -531,13 +531,13 @@ static int Hud_mission_log_status_coords[GR_NUM_RESOLUTIONS][2] = { #endif struct scrollback_buttons { - char *filename; + const char *filename; int x, y; int xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - scrollback_buttons(char *name, int x1, int y1, int x2, int y2, int h) : filename(name), x(x1), y(y1), xt(x2), yt(y2), hotspot(h) {} + scrollback_buttons(const char *name, int x1, int y1, int x2, int y2, int h) : filename(name), x(x1), y(y1), xt(x2), yt(y2), hotspot(h) {} }; int Scroll_time_id; @@ -590,20 +590,20 @@ static int Status_bitmap; static int Background_bitmap; static UI_WINDOW Ui_window; -static char* Hud_mission_log_fname[GR_NUM_RESOLUTIONS] = { +static const char* Hud_mission_log_fname[GR_NUM_RESOLUTIONS] = { "MissionLog", // GR_640 "2_MissionLog" // GR_1024 }; #ifdef MAKE_FS1 // No longer used - DDOI -static char* Hud_mission_log_status_fname[GR_NUM_RESOLUTIONS] = { +static const char* Hud_mission_log_status_fname[GR_NUM_RESOLUTIONS] = { "MLStatus", // GR_640 "MLStatus" // GR_1024 }; #endif -static char* Hud_mission_log_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char* Hud_mission_log_mask_fname[GR_NUM_RESOLUTIONS] = { "MissionLog-m", // GR_640 "2_MissionLog-m" // GR_1024 }; @@ -835,7 +835,7 @@ void hud_show_fixed_text() } // Similar to HUD printf, but shows only one message at a time, at a fixed location. -void HUD_fixed_printf(float duration, char * format, ...) +void HUD_fixed_printf(float duration, const char * format, ...) { va_list args; char tmp[HUD_MSG_LENGTH_MAX]; @@ -885,7 +885,7 @@ void HUD_fixed_printf_reset() // Print a single line of text to the HUD. We know that the text will fit on the screen, // since that was taken care of in HUD_printf(); // -void HUD_printf_line(char *text, int source, int time = 0, int x = 0) +void HUD_printf_line(const char *text, int source, int time = 0, int x = 0) { Assert(text != NULL); @@ -937,7 +937,7 @@ int HUD_get_team_source(int team) return 0; } -void HUD_printf(char *format, ...) +void HUD_printf(const char *format, ...) { va_list args; char tmp[HUD_MSG_LENGTH_MAX]; @@ -958,7 +958,7 @@ void HUD_printf(char *format, ...) hud_sourced_print(HUD_SOURCE_COMPUTER, tmp); } -void HUD_ship_sent_printf(int sh, char *format, ...) +void HUD_ship_sent_printf(int sh, const char *format, ...) { va_list args; char tmp[HUD_MSG_LENGTH_MAX]; @@ -984,7 +984,7 @@ void HUD_ship_sent_printf(int sh, char *format, ...) // message on the HUD. Text is split into multiple lines if width exceeds msg display area // width. 'source' is used to indicate who send the message, and is used to color code text. // -void HUD_sourced_printf(int source, char *format, ...) +void HUD_sourced_printf(int source, const char *format, ...) { va_list args; char tmp[HUD_MSG_LENGTH_MAX]; @@ -1061,7 +1061,7 @@ int hud_query_scrollback_size() } // add text directly to the hud scrollback log, without displaying on the hud -void HUD_add_to_scrollback(char *text, int source) +void HUD_add_to_scrollback(const char *text, int source) { if (!strlen(text)) { nprintf(("Warning", "HUD ==> attempt to print a 0 length string in msg window\n")); @@ -1074,7 +1074,7 @@ void HUD_add_to_scrollback(char *text, int source) // hud_add_msg_to_scrollback() adds the new_msg to the scroll-back message list. If there // are no more free slots, the first slot is released to make room for the new message. // -void hud_add_line_to_scrollback(char *text, int source, int t, int x, int y, int underline_width) +void hud_add_line_to_scrollback(const char *text, int source, int t, int x, int y, int underline_width) { line_node *new_line; @@ -1102,7 +1102,7 @@ void hud_add_line_to_scrollback(char *text, int source, int t, int x, int y, int list_append(&Msg_scrollback_used_list, new_line); } -void hud_add_msg_to_scrollback(char *text, int source, int t) +void hud_add_msg_to_scrollback(const char *text, int source, int t) { char buf[HUD_MSG_LENGTH_MAX], *ptr, *str; int msg_len, w, max_width, x, offset = 0; diff --git a/src/hud/hudsquadmsg.cpp b/src/hud/hudsquadmsg.cpp index 73f0c67..fbbb7a6 100644 --- a/src/hud/hudsquadmsg.cpp +++ b/src/hud/hudsquadmsg.cpp @@ -395,7 +395,7 @@ int keys_used[] = { KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_ #define NUM_TYPE_SELECT 6 -char *type_select_str(int n) +const char *type_select_str(int n) { #if NUM_TYPE_SELECT != 6 #error type_select_Str is not up to date @@ -446,7 +446,7 @@ comm_order Comm_orders[MAX_SHIP_ORDERS] = { // Text to display on the menu // Given an index into the Comm_orders array, return the text associated with it. // MUST BE 1:1 with Comm_orders. -char *comm_order_menu_text(int index) +const char *comm_order_menu_text(int index) { switch( index ) { case 0: return XSTR( "Destroy my target", 299); break; @@ -469,7 +469,7 @@ char *comm_order_menu_text(int index) } // Text to display on the messaging menu when using the shortcut keys -char *comm_order_hotkey_text( int index ) +const char *comm_order_hotkey_text( int index ) { int i; @@ -493,7 +493,7 @@ squadmsg_history Squadmsg_history[SQUADMSG_HISTORY_MAX] = { 0 }; static hud_frames Mbox_gauge[NUM_MBOX_FRAMES]; static int Mbox_frames_loaded = 0; -static char *Mbox_fnames[GR_NUM_RESOLUTIONS][NUM_MBOX_FRAMES] = +static const char *Mbox_fnames[GR_NUM_RESOLUTIONS][NUM_MBOX_FRAMES] = { //XSTR:OFF { // GR_640 @@ -530,7 +530,7 @@ static int Mbox_item_coord[GR_NUM_RESOLUTIONS][2] = { #define MESSAGE_ALL_FIGHTERS -999 // forward declarations -void hud_add_issued_order(char *name, int order, char *target); +void hud_add_issued_order(const char *name, int order, const char *target); int hud_squadmsg_is_target_order_valid(int order, int find_order, ai_info *aip = NULL ); int hud_squadmsg_ship_order_valid( int shipnum, int order ); @@ -937,7 +937,7 @@ int hud_squadmsg_get_key() // function which will essentially print out the contents of the current state of the messaging // menu. Parameters will be a title. The menu items and the number of items will be // in global vars since they don't get recomputed every frame. -void hud_squadmsg_display_menu( char *title ) +void hud_squadmsg_display_menu( const char *title ) { int bx, by, sx, sy, i, nitems, none_valid, messaging_allowed; @@ -2711,7 +2711,7 @@ int hud_squadmsg_do_frame( ) return 0; } -void hud_add_issued_order(char *name, int order, char *target) +void hud_add_issued_order(const char *name, int order, const char *target) { Squadmsg_history[squadmsg_history_index].ship = get_parse_name_index(name); Squadmsg_history[squadmsg_history_index].order = order; @@ -2725,7 +2725,7 @@ void hud_add_issued_order(char *name, int order, char *target) squadmsg_history_index = 0; } -int hud_query_order_issued(char *name, char *order, char *target) +int hud_query_order_issued(const char *name, const char *order, const char *target) { int i, o=-1, ship, t; diff --git a/src/hud/hudtarget.cpp b/src/hud/hudtarget.cpp index 3bad971..2945eb4 100644 --- a/src/hud/hudtarget.cpp +++ b/src/hud/hudtarget.cpp @@ -366,7 +366,7 @@ float Lead_indicator_half[GR_NUM_RESOLUTIONS][2] = { }; hud_frames Lead_indicator_gauge; int Lead_indicator_gauge_loaded = 0; -char Lead_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Lead_fname[GR_NUM_RESOLUTIONS] = { "lead1", "2_lead1" }; @@ -378,7 +378,7 @@ char Lead_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { // 3 => gun energy light hud_frames Energy_bar_gauges; int Energy_bar_gauges_loaded = 0; -char Energy_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Energy_fname[GR_NUM_RESOLUTIONS] = { "energy2", "2_energy2" }; @@ -419,7 +419,7 @@ int Cm_text_val_coords[GR_NUM_RESOLUTIONS][2] = { 889, 606 } }; -char Cm_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Cm_fname[GR_NUM_RESOLUTIONS] = { "countermeasure1", "countermeasure1" }; @@ -447,7 +447,7 @@ int Toggle_speed_gauge_coords[GR_NUM_RESOLUTIONS][2] = { 960, 672 } }; -char Toggle_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Toggle_fname[GR_NUM_RESOLUTIONS] = { "toggle1", "toggle1" }; @@ -573,7 +573,7 @@ int Weapon_secondary_reload_x[GR_NUM_RESOLUTIONS] = { 615, // x location of where to draw the weapon reload time 998 }; -char *Weapon_gauge_fnames[GR_NUM_RESOLUTIONS][NUM_WEAPON_GAUGES] = +const char *Weapon_gauge_fnames[GR_NUM_RESOLUTIONS][NUM_WEAPON_GAUGES] = { //XSTR:OFF { // GR_640 diff --git a/src/hud/hudtargetbox.cpp b/src/hud/hudtargetbox.cpp index 179c733..82e35fd 100644 --- a/src/hud/hudtargetbox.cpp +++ b/src/hud/hudtargetbox.cpp @@ -259,7 +259,7 @@ extern int Show_target_weapons; #endif // used to print out + or - after target distance and speed -char* modifiers[] = { +const char* modifiers[] = { //XSTR:OFF "+", "-", @@ -267,15 +267,15 @@ char* modifiers[] = { //XSTR:ON }; -char Target_view_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Target_view_fname[GR_NUM_RESOLUTIONS] = { "targetview1", "targetview1" }; -char Target_integ_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Target_integ_fname[GR_NUM_RESOLUTIONS] = { "targetview2", "targetview2" }; -char Target_extra_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN] = { +const char *Target_extra_fname[GR_NUM_RESOLUTIONS] = { "targetview3", "targetview3" }; diff --git a/src/hud/hudwingmanstatus.cpp b/src/hud/hudwingmanstatus.cpp index bc8a68a..25c5c6d 100644 --- a/src/hud/hudwingmanstatus.cpp +++ b/src/hud/hudwingmanstatus.cpp @@ -123,7 +123,7 @@ #define WINGMAN_STATUS_DOTS 3 #define WINGMAN_STATUS_NAMES 4 -static char *Wingman_status_filenames[GR_NUM_RESOLUTIONS][HUD_WINGMAN_STATUS_NUM_FRAMES] = +static const char *Wingman_status_filenames[GR_NUM_RESOLUTIONS][HUD_WINGMAN_STATUS_NUM_FRAMES] = { //XSTR:OFF { // GR_640 @@ -355,7 +355,7 @@ int HUD_wingman_status_coords[GR_NUM_RESOLUTIONS][HUD_WINGMAN_MAX_WINGS][HUD_WIN } }; -int hud_wingman_status_wing_index(char *wing_name) +int hud_wingman_status_wing_index(const char *wing_name) { //XSTR:OFF if ( !stricmp("alpha", wing_name) ) { diff --git a/src/io/keycontrol.cpp b/src/io/keycontrol.cpp index c816463..e6a5b6d 100644 --- a/src/io/keycontrol.cpp +++ b/src/io/keycontrol.cpp @@ -365,18 +365,18 @@ typedef struct asteroid_field { char CheatBuffer[CHEAT_BUFFER_LEN+1]; #if defined(FS2_DEMO) - char *Cheat_code_demo = NOX("33BE^(8]C01(:=BHt"); + const char *Cheat_code_demo = NOX("33BE^(8]C01(:=BHt"); #elif defined(MAKE_FS1) - char *Cheat_code_gr = NOX("BNdEgDB\\s?0XD1?0)"); // de:www.volition-inc.com - char *Cheat_code = NOX("E5B?(\"=H'5UTE$o%D"); // www.volition-inc.com - char *Cheat_code_movies = NOX("iC:1C06,'00SoXyY6"); // freespacestandsalone + const char *Cheat_code_gr = NOX("BNdEgDB\\s?0XD1?0)"); // de:www.volition-inc.com + const char *Cheat_code = NOX("E5B?(\"=H'5UTE$o%D"); // www.volition-inc.com + const char *Cheat_code_movies = NOX("iC:1C06,'00SoXyY6"); // freespacestandsalone #else - char *Cheat_code = NOX("33BE^(8]C01(:=BHt"); // www.freespace2.com - char *Cheat_code_fish = NOX("bDc9y+$;#AIDRoouM"); // vasudanswuvfishes - char *Cheat_code_headz = NOX("!;:::@>F7L?@@2:@A"); // humanheadsinside. - char *Cheat_code_tooled = NOX("sipp-^rM@L!U^usjX"); // tooledworkedowned - char *Cheat_code_pirate = NOX("MAP4YP[4=-2uC(yJ^"); // arrrrwalktheplank - char *Cheat_code_skip = NOX("7!ICkSI\"(8n3JesBP"); // skipmemymissionyo + const char *Cheat_code = NOX("33BE^(8]C01(:=BHt"); // www.freespace2.com + const char *Cheat_code_fish = NOX("bDc9y+$;#AIDRoouM"); // vasudanswuvfishes + const char *Cheat_code_headz = NOX("!;:::@>F7L?@@2:@A"); // humanheadsinside. + const char *Cheat_code_tooled = NOX("sipp-^rM@L!U^usjX"); // tooledworkedowned + const char *Cheat_code_pirate = NOX("MAP4YP[4=-2uC(yJ^"); // arrrrwalktheplank + const char *Cheat_code_skip = NOX("7!ICkSI\"(8n3JesBP"); // skipmemymissionyo #endif // 666)6=N79+Z45=BE0e int Tool_enabled = 0; diff --git a/src/localization/localize.cpp b/src/localization/localize.cpp index aecf5af..a3d0391 100644 --- a/src/localization/localize.cpp +++ b/src/localization/localize.cpp @@ -425,7 +425,7 @@ extern char *FS1_trans[LCL_NUM_LANGUAGES_FS1][LCL_NUM_STRINGS_FS1]; // // associate table file externalization with the specified input file -void lcl_ext_associate(char *filename); +void lcl_ext_associate(const char *filename); // given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success int lcl_ext_get_text(char *xstr, char *out); @@ -459,7 +459,7 @@ void lcl_ext_setup_pointers(); void lcl_init(int lang_init) { char lang_string[128]; - char *ret; + const char *ret; int lang, idx; // initialize encryption @@ -939,7 +939,7 @@ void lcl_ext_localize(char *in, char *out, int max_len, int *id) } // translate the specified string based upon the current language -char *XSTR(char *str, int index) +const char *XSTR(const char *str, int index) { if(!Xstr_inited){ return str; @@ -972,7 +972,7 @@ int lcl_get_xstr_offset(int index, int res) // // associate table file externalization with the specified input file -void lcl_ext_associate(char *filename) +void lcl_ext_associate(const char *filename) { #ifndef MAKE_FS1 // if the filename already exists, free it up diff --git a/src/menuui/barracks.cpp b/src/menuui/barracks.cpp index 5165c06..000de08 100644 --- a/src/menuui/barracks.cpp +++ b/src/menuui/barracks.cpp @@ -123,7 +123,7 @@ #include "osregistry.h" #include "alphacolors.h" -void delete_pilot_file( char *pilot_name, int single ); // manage_pilot.cpp +void delete_pilot_file( const char *pilot_name, int single ); // manage_pilot.cpp // stats defines #define NUM_STAT_LINES 85 @@ -279,12 +279,12 @@ int Barracks_squad_number_coords[GR_NUM_RESOLUTIONS][2] = { //XSTR:OFF // bitmaps defs -static char *Barracks_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Barracks_bitmap_fname[GR_NUM_RESOLUTIONS] = { "Barracks", // GR_640 "2_Barracks" // GR_1024 }; -static char *Barracks_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Barracks_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "Barracks-M", // GR_640 "2_Barracks-M" // GR_1024 }; @@ -294,20 +294,20 @@ static char *Barracks_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { #define BARRACKS_IMAGE_NOT_LOADED -2 struct barracks_bitmaps { - char *filename; + const char *filename; int x, y; int b; }; struct barracks_buttons { - char *filename; + const char *filename; int x, y; int text_x, text_y; // this is where the text label is int hotspot; int repeat; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - barracks_buttons(char *name, int x1, int y1, int x2, int y2, int h, int r = 0) : filename(name), x(x1), y(y1), text_x(x2), text_y(y2), hotspot(h), repeat(r) {} + barracks_buttons(const char *name, int x1, int y1, int x2, int y2, int h, int r = 0) : filename(name), x(x1), y(y1), text_x(x2), text_y(y2), hotspot(h), repeat(r) {} }; #if defined(MAKE_FS1) && !defined(FS1_DEMO) @@ -953,7 +953,7 @@ void barracks_delete_pilot() } // Filter out pilots of wrong type (which shouldn't be in the directory we are checking, but just to be safe..) -int barracks_pilot_filter(char *filename) +int barracks_pilot_filter(const char *filename) { int r, rank; @@ -1116,7 +1116,8 @@ void barracks_button_pressed(int n) #if defined(DEMO) || defined(OEM_BUILD) game_feature_not_in_demo_popup(); #else - char temp[256], *str; + const char *str; + char temp[256]; char old_pic[256] = ""; char old_squad_pic[256] = ""; char old_squad[256] = ""; diff --git a/src/menuui/credits.cpp b/src/menuui/credits.cpp index dbfab78..1096195 100644 --- a/src/menuui/credits.cpp +++ b/src/menuui/credits.cpp @@ -203,12 +203,12 @@ #define CREDITS_W_COORD 2 #define CREDITS_H_COORD 3 -static char* Credits_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char* Credits_bitmap_fname[GR_NUM_RESOLUTIONS] = { "Credits", // GR_640 "2_Credits" }; -static char* Credits_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char* Credits_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "Credits-M", // GR_640 "2_Credits-M" }; @@ -241,12 +241,12 @@ int Credits_text_coords[GR_NUM_RESOLUTIONS][4] = { }; struct credits_screen_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - credits_screen_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} + credits_screen_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} }; static int Background_bitmap; @@ -317,7 +317,6 @@ static int Credits_artwork_index; static int Credits_bmps[NUM_IMAGES]; char *Credit_text = NULL; -int Credit_text_malloced = 0; // TRUE if credit_text was malloced // Positions for credits... float Credit_start_pos, Credit_stop_pos, Credit_position = 0.0f; @@ -330,7 +329,7 @@ void credits_stop_music() } } -void credits_load_music(char* fname) +void credits_load_music(const char* fname) { if ( Credits_music_handle != -1 ){ return; @@ -402,7 +401,6 @@ void credits_init() Credits_last_time = timer_get_milliseconds(); Credit_text = NULL; - Credit_text_malloced = 0; // allocate enough space for credits text CFILE *fp = cfopen( NOX("credits.tbl"), "rb" ); @@ -410,7 +408,6 @@ void credits_init() int size; size = cfilelength(fp); Credit_text = (char *) malloc(size + 200); - Credit_text_malloced = 1; cfclose(fp); // open localization and parse @@ -456,7 +453,8 @@ void credits_init() // close localization lcl_ext_close(); } else { - Credit_text = NOX("No credits available.\n"); + Credit_text = (char *) malloc(25 + 200); + strcpy(Credit_text, NOX("No credits available.\n")); } int ch; @@ -649,10 +647,7 @@ void credits_close() credits_stop_music(); if (Credit_text) { - if (Credit_text_malloced){ - free(Credit_text); - } - + free(Credit_text); Credit_text = NULL; } diff --git a/src/menuui/fishtank.cpp b/src/menuui/fishtank.cpp index 2a59f3f..17ac023 100644 --- a/src/menuui/fishtank.cpp +++ b/src/menuui/fishtank.cpp @@ -52,8 +52,8 @@ typedef struct fish { fish Fish[MAX_FISH]; // fish anim name -#define FISH_LEFT_ANIM_NAME "f_left.ani" -#define FISH_RIGHT_ANIM_NAME "f_right.ani" +static const char *FISH_LEFT_ANIM_NAME = "f_left.ani"; +static const char *FISH_RIGHT_ANIM_NAME = "f_right.ani"; #define FISH_ANIM_WIDTH 100 #define FISH_ANIM_HEIGHT 30 diff --git a/src/menuui/mainhallmenu.cpp b/src/menuui/mainhallmenu.cpp index 59e8419..9b6472e 100644 --- a/src/menuui/mainhallmenu.cpp +++ b/src/menuui/mainhallmenu.cpp @@ -455,7 +455,7 @@ typedef struct main_hall_defines { // region descriptions ---------------- // text (tooltip) description - char *region_descript[NUM_REGIONS]; + const char *region_descript[NUM_REGIONS]; // y coord of where to draw tooltip text int region_yval; @@ -648,7 +648,7 @@ int Main_hall_notify_stamp = -1; char Main_hall_notify_text[300]=""; // set the current notification string and the associated timestamp -void main_hall_set_notify_string(char *str); +void main_hall_set_notify_string(const char *str); // handle any drawing, culling, etc of notification messages void main_hall_notify_do(); @@ -1828,7 +1828,7 @@ void main_hall_handle_random_intercom_sounds() } // set the notification string with its decay timeout -void main_hall_set_notify_string(char *str) +void main_hall_set_notify_string(const char *str) { strcpy(Main_hall_notify_text,str); Main_hall_notify_stamp = timestamp(MAIN_HALL_NOTIFY_TIME); diff --git a/src/menuui/mainhalltemp.cpp b/src/menuui/mainhalltemp.cpp index 7b58a1e..e721b5a 100644 --- a/src/menuui/mainhalltemp.cpp +++ b/src/menuui/mainhalltemp.cpp @@ -54,12 +54,12 @@ #define MHT_NUM_BUTTONS 6 -char *Mht_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char *Mht_bitmap_fname[GR_NUM_RESOLUTIONS] = { "mht_background", // GR_640 "2_mht_background" // GR_1024 }; -char *Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Mht_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "mht_mask", // GR_640 "2_mht_mask" // GR_1024 }; diff --git a/src/menuui/optionsmenu.cpp b/src/menuui/optionsmenu.cpp index 9b983bd..b72887b 100644 --- a/src/menuui/optionsmenu.cpp +++ b/src/menuui/optionsmenu.cpp @@ -320,14 +320,14 @@ #define OPTIONS_H_COORD 3 struct options_buttons { - char *filename; + const char *filename; int x, y; int hotspot; int tab; int flags; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - options_buttons(char *name, int x1, int y1, int h, int t, int f = 0) : filename(name), x(x1), y(y1), hotspot(h), tab(t), flags(f) {} + options_buttons(const char *name, int x1, int y1, int h, int t, int f = 0) : filename(name), x(x1), y(y1), hotspot(h), tab(t), flags(f) {} }; static options_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = { @@ -489,8 +489,8 @@ op_sliders Options_sliders[GR_NUM_RESOLUTIONS][NUM_OPTIONS_SLIDERS] = { }; static struct { - char *filename; - char *mask_filename; + const char *filename; + const char *mask_filename; int bitmap; int mask; @@ -541,7 +541,7 @@ void options_force_button_frame(int n, int frame_num); extern float Freespace_gamma; -void options_add_notify(char *str); +void options_add_notify(const char *str); void options_notify_do_frame(); int Options_gamma_coords[GR_NUM_RESOLUTIONS][4] = { @@ -801,7 +801,7 @@ void options_play_voice_clip() Voice_vol_handle = snd_play_raw( snd_id, 0.0f, 1.0f, SND_PRIORITY_SINGLE_INSTANCE ); } -void options_add_notify(char *str) +void options_add_notify(const char *str) { strcpy(Options_notify_string, str); Options_notify_stamp = timestamp(OPTIONS_NOTIFY_TIME); diff --git a/src/menuui/optionsmenumulti.cpp b/src/menuui/optionsmenumulti.cpp index 0667785..7ed9243 100644 --- a/src/menuui/optionsmenumulti.cpp +++ b/src/menuui/optionsmenumulti.cpp @@ -245,22 +245,22 @@ UI_WINDOW *Om_window = NULL; #ifndef FS1_DEMO -static char* Om_background_0_fname[GR_NUM_RESOLUTIONS] = { +static const char* Om_background_0_fname[GR_NUM_RESOLUTIONS] = { "OptionsMultiGen", // GR_640 "2_OptionsMultiGen" // GR_1024 }; -static char* Om_background_0_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char* Om_background_0_mask_fname[GR_NUM_RESOLUTIONS] = { "OptionsMultiGen-M", // GR_640 "2_OptionsMultiGen-M" // GR_1024 }; -static char* Om_background_1_fname[GR_NUM_RESOLUTIONS] = { +static const char* Om_background_1_fname[GR_NUM_RESOLUTIONS] = { "OptionsMultiVox", // GR_640 "2_OptionsMultiVox" // GR_1024 }; -static char* Om_background_1_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char* Om_background_1_mask_fname[GR_NUM_RESOLUTIONS] = { "OptionsMultiVox-M", // GR_640 "2_OptionsMultiVox-M" // GR_1024 }; @@ -292,7 +292,7 @@ void options_multi_load_bmaps(); void options_multi_unload_bmaps(); // add a notification message -void options_multi_add_notify(char *str); +void options_multi_add_notify(const char *str); // process and blit any notification messages void options_multi_notify_process(); @@ -928,7 +928,7 @@ void options_multi_unload_bmaps() } // add a notification message -void options_multi_add_notify(char *str) +void options_multi_add_notify(const char *str) { // copy the string memset(Om_notify_string,0,255); diff --git a/src/menuui/playermenu.cpp b/src/menuui/playermenu.cpp index 8257a91..0be3e99 100644 --- a/src/menuui/playermenu.cpp +++ b/src/menuui/playermenu.cpp @@ -227,7 +227,7 @@ static int Demo_title_active = 0; static int Demo_title_bitmap = -1; static int Demo_title_expire_timestamp = 0; static int Demo_title_need_fade_in = 1; -static char *Demo_title_bitmap_filename = NOX("DemoTitle1"); +static const char *Demo_title_bitmap_filename = NOX("DemoTitle1"); #endif // -------------------------------------------------------------------------------------------------------- @@ -266,11 +266,11 @@ int Choose_list_coords[GR_NUM_RESOLUTIONS][4] = { } }; -char *Player_select_background_bitmap_name[GR_NUM_RESOLUTIONS] = { +const char *Player_select_background_bitmap_name[GR_NUM_RESOLUTIONS] = { "ChoosePilot", "2_ChoosePilot" }; -char *Player_select_background_mask_bitmap[GR_NUM_RESOLUTIONS] = { +const char *Player_select_background_mask_bitmap[GR_NUM_RESOLUTIONS] = { "ChoosePilot-m", "2_ChoosePilot-m" }; @@ -280,12 +280,12 @@ char *Player_select_background_mask_bitmap[GR_NUM_RESOLUTIONS] = { // convenient struct for handling all button controls struct barracks_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - barracks_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} + barracks_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} }; static barracks_buttons Player_select_buttons[GR_NUM_RESOLUTIONS][NUM_PLAYER_SELECT_BUTTONS] = { @@ -399,8 +399,8 @@ static int Player_select_middle_text_y[GR_NUM_RESOLUTIONS] = { char Player_select_bottom_text[150] = ""; char Player_select_middle_text[150] = ""; -void player_select_set_bottom_text(char *txt); -void player_select_set_middle_text(char *txt); +void player_select_set_bottom_text(const char *txt); +void player_select_set_middle_text(const char *txt); // FORWARD DECLARATIONS @@ -413,12 +413,11 @@ int player_select_create_new_pilot(); void player_select_delete_pilot(); void player_select_display_all_text(); void player_select_display_copyright(); -void player_select_set_bottom_text(char *txt); void player_select_set_controls(int gray); void player_select_draw_list(); void player_select_process_noninput(int k); void player_select_process_input(int k); -int player_select_pilot_file_filter(char *filename); +int player_select_pilot_file_filter(const char *filename); int player_select_get_last_pilot_info(); void player_select_eval_very_first_pilot(); void player_select_commit(); @@ -1087,7 +1086,7 @@ void player_select_scroll_list_down() // fill in the data on the last played pilot (callsign and is_multi or not) int player_select_get_last_pilot_info() { - char *last_player; + const char *last_player; last_player = os_config_read_string( NULL, "LastPlayer", NULL); @@ -1441,19 +1440,19 @@ void player_select_display_all_text() } } -int player_select_pilot_file_filter(char *filename) +int player_select_pilot_file_filter(const char *filename) { return !verify_pilot_file(filename, Player_select_mode == PLAYER_SELECT_MODE_SINGLE); } -void player_select_set_bottom_text(char *txt) +void player_select_set_bottom_text(const char *txt) { if (txt) { strncpy(Player_select_bottom_text, txt, 149); } } -void player_select_set_middle_text(char *txt) +void player_select_set_middle_text(const char *txt) { if (txt) { strncpy(Player_select_middle_text, txt, 149); diff --git a/src/menuui/readyroom.cpp b/src/menuui/readyroom.cpp index f545f16..a1dfe6e 100644 --- a/src/menuui/readyroom.cpp +++ b/src/menuui/readyroom.cpp @@ -189,12 +189,12 @@ int Campaign_list_coords[GR_NUM_RESOLUTIONS][4] = { #define CAMPAIGN_MISSION_HASH_SIZE 307 struct sim_room_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - sim_room_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} + sim_room_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} }; static sim_room_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = { @@ -245,20 +245,20 @@ static sim_room_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = { //XSTR:ON }; -char *Sim_filename[GR_NUM_RESOLUTIONS] = { +const char *Sim_filename[GR_NUM_RESOLUTIONS] = { "LoadMission", "2_LoadMission" }; -char *Sim_mask_filename[GR_NUM_RESOLUTIONS] = { +const char *Sim_mask_filename[GR_NUM_RESOLUTIONS] = { "LoadMission-m", "2_LoadMission-m" }; -char *Campaign_filename[GR_NUM_RESOLUTIONS] = { +const char *Campaign_filename[GR_NUM_RESOLUTIONS] = { "Campaign", "2_Campaign" }; -char *Campaign_mask_filename[GR_NUM_RESOLUTIONS] = { +const char *Campaign_mask_filename[GR_NUM_RESOLUTIONS] = { "Campaign-m", "2_Campaign-m" }; @@ -291,8 +291,8 @@ int Sim_misc_text_coords[GR_NUM_RESOLUTIONS][NUM_SIM_MISC_TEXT][2] = { #endif static struct { int type; // see READYROOM_LINE_* defines above - char *name; - char *filename; + const char *name; + const char *filename; int x; // X coordinate of line int y; // Y coordinate of line int flags; // special flags, see READYROOM_FLAG_* defines above @@ -330,7 +330,7 @@ static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of te typedef struct hash_node { hash_node *next; - char *filename; + const char *filename; } hash_node; static hash_node *Campaign_mission_hash_table[CAMPAIGN_MISSION_HASH_SIZE]; @@ -374,7 +374,7 @@ static int Sim_silent_icon_x[GR_NUM_RESOLUTIONS] = { // special icons themselves int Mission_icon_bitmaps[NUM_MISSION_ICONS]; //XSTR:OFF -char *Mission_icon_bitmap_filenames[NUM_MISSION_ICONS] = { +const char *Mission_icon_bitmap_filenames[NUM_MISSION_ICONS] = { #ifdef MAKE_FS1 "icon-volition", "icon-silent" @@ -390,9 +390,9 @@ void sim_room_blit_icons(int line_index, int y_start, fs_builtin_mission *fb = N // Finds a hash value for mission filename // // returns hash value -int hash_filename(char *filename) { +int hash_filename(const char *filename) { unsigned __int64 hash_val = 0; - char *ptr = filename; + const char *ptr = filename; // Dont hash .fsm extension, convert all to upper case for (int i=0; i < ((signed int)(strlen(filename)) - 4); i++) { @@ -405,7 +405,7 @@ int hash_filename(char *filename) { // insert filename into Campaign_mission_hash_table // // returns 1 if successful, 0 if could not allocate memory -int hash_insert(char *filename) { +int hash_insert(const char *filename) { int hash_val = hash_filename(filename); hash_node *cur_node; @@ -448,7 +448,7 @@ int hash_insert(char *filename) { // Checks if a filename already exitst in the hash table // // returns 1 if found (collision), 0 if no collision -int campaign_mission_hash_collision(char *filename) +int campaign_mission_hash_collision(const char *filename) { int hash_val = hash_filename(filename); hash_node *cur_node = Campaign_mission_hash_table[hash_val]; @@ -529,7 +529,7 @@ int sim_room_line_add(int type, char *name, char *filename, int x, int y, int fl } // filter out all multiplayer campaigns -int campaign_room_campaign_filter(char *filename) +int campaign_room_campaign_filter(const char *filename) { int type, max_players; char name[NAME_LENGTH], *desc = NULL; @@ -555,7 +555,7 @@ int campaign_room_campaign_filter(char *filename) } // build up a list of all missions in all campaigns. -int sim_room_campaign_mission_filter(char *filename) +int sim_room_campaign_mission_filter(const char *filename) { int num; @@ -568,7 +568,7 @@ int sim_room_campaign_mission_filter(char *filename) } // filter out all missions already used in existing campaigns -int sim_room_standalone_mission_filter(char *filename) +int sim_room_standalone_mission_filter(const char *filename) { int type; char mission_name[255]; diff --git a/src/menuui/snazzyui.cpp b/src/menuui/snazzyui.cpp index 5b8328d..ea21c3a 100644 --- a/src/menuui/snazzyui.cpp +++ b/src/menuui/snazzyui.cpp @@ -354,7 +354,7 @@ int snazzy_menu_do(ubyte *data, int mask_w, int mask_h, int num_regions, MENU_RE // // -void snazzy_menu_add_region(MENU_REGION* region, char* text, int mask, int key, int click_sound) +void snazzy_menu_add_region(MENU_REGION* region, const char* text, int mask, int key, int click_sound) { region->mask = mask; region->key = key; @@ -369,7 +369,7 @@ void snazzy_menu_add_region(MENU_REGION* region, char* text, int mask, int key, // // -void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MENU_REGION* regions, int* num_regions, int play_sound) +void read_menu_tbl(const char* menu_name, char* bkg_filename, char* mask_filename, MENU_REGION* regions, int* num_regions, int play_sound) { CFILE* fp; int state=0; diff --git a/src/menuui/techmenu.cpp b/src/menuui/techmenu.cpp index f29c5ee..4758b78 100644 --- a/src/menuui/techmenu.cpp +++ b/src/menuui/techmenu.cpp @@ -329,16 +329,16 @@ // background filename for species // note weapon filename is now same as ship filename -char *Tech_background_filename[GR_NUM_RESOLUTIONS] = { +const char *Tech_background_filename[GR_NUM_RESOLUTIONS] = { "TechShipData", "2_TechShipData" }; -char *Tech_mask_filename[GR_NUM_RESOLUTIONS] = { +const char *Tech_mask_filename[GR_NUM_RESOLUTIONS] = { "TechShipData-M", "2_TechShipData-M" }; #ifndef MAKE_FS1 -char *Tech_slider_filename[GR_NUM_RESOLUTIONS] = { +const char *Tech_slider_filename[GR_NUM_RESOLUTIONS] = { "slider", "2_slider" }; @@ -346,10 +346,10 @@ char *Tech_slider_filename[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 // need the second background for FS1 -char *Tech_data_background_filename = { +const char *Tech_data_background_filename = { "TechData" }; -char *Tech_data_mask_filename = { +const char *Tech_data_mask_filename = { "TechData-M" }; #endif @@ -436,14 +436,14 @@ int Tech_texture_backup; #define MAX_TEXT_LINE_LEN 256 struct techroom_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; int tab; int flags; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - techroom_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int t, int f = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), tab(t), flags(f) {} + techroom_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h, int t, int f = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), tab(t), flags(f) {} }; static techroom_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = { @@ -583,7 +583,7 @@ static UI_SLIDER2 Tech_slider; //XSTR:OFF #ifdef MAKE_FS1 -static char *Intel_anim_filenames[MAX_INTEL_ENTRIES] = { +static const char *Intel_anim_filenames[MAX_INTEL_ENTRIES] = { "tech_tpilot.ani", "tech_vasudan.ani", "tech_shivan.ani", diff --git a/src/mission/missionbriefcommon.cpp b/src/mission/missionbriefcommon.cpp index 0eebbc6..64e616e 100644 --- a/src/mission/missionbriefcommon.cpp +++ b/src/mission/missionbriefcommon.cpp @@ -230,7 +230,7 @@ brief_screen bscreen; #define BRIEF_CUPINFO_X2 639 #define BRIEF_CUPINFO_Y2 438 -char *Brief_static_name[GR_NUM_RESOLUTIONS] = { +const char *Brief_static_name[GR_NUM_RESOLUTIONS] = { "BriefMap", "2_BriefMap" }; diff --git a/src/mission/missioncampaign.cpp b/src/mission/missioncampaign.cpp index 647064e..866cfab 100644 --- a/src/mission/missioncampaign.cpp +++ b/src/mission/missioncampaign.cpp @@ -236,7 +236,7 @@ char *Campaign_names[MAX_CAMPAIGNS]; char *Campaign_file_names[MAX_CAMPAIGNS]; int Num_campaigns; -char *campaign_types[MAX_CAMPAIGN_TYPES] = +const char *campaign_types[MAX_CAMPAIGN_TYPES] = { //XSTR:OFF "single", @@ -272,7 +272,7 @@ campaign Campaign; // mission_campaign_get_name returns a string (which is malloced in this routine) of the name // of the given freespace campaign file. In the type field, we return if the campaign is a single // player or multiplayer campaign. The type field will only be valid if the name returned is non-NULL -int mission_campaign_get_info(char *filename, char *name, int *type, int *max_players, char **desc) +int mission_campaign_get_info(const char *filename, char *name, int *type, int *max_players, char **desc) { int rval, i; char campaign_type[NAME_LENGTH], fname[MAX_FILENAME_LEN]; @@ -359,7 +359,7 @@ int mission_campaign_get_info(char *filename, char *name, int *type, int *max_pl // parses campaign and returns a list of missions in it. Returns number of missions added to // the 'list', and up to 'max' missions may be added to 'list'. Returns negative on error. // -int mission_campaign_get_mission_list(char *filename, char **list, int max) +int mission_campaign_get_mission_list(const char *filename, char **list, int max) { int rval, i, num = 0; char name[NAME_LENGTH]; @@ -388,7 +388,7 @@ int mission_campaign_get_mission_list(char *filename, char **list, int max) return num; } -void mission_campaign_maybe_add( char *filename, int multiplayer ) +void mission_campaign_maybe_add( const char *filename, int multiplayer ) { char name[NAME_LENGTH]; int type,max_players; @@ -523,7 +523,7 @@ void mission_campaign_get_sw_info() // Note: Due to difficulties in generalizing this function, parts of it are duplicated throughout // this file. If you change the format of the campaign file, you should be sure these related // functions work properly and update them if it breaks them. -int mission_campaign_load( char *filename, int load_savefile ) +int mission_campaign_load( const char *filename, int load_savefile ) { int len, rval, i; char name[NAME_LENGTH], type[NAME_LENGTH]; @@ -731,38 +731,41 @@ int mission_campaign_load( char *filename, int load_savefile ) // mission_campaign_load_by_name() loads up a freespace campaign given the filename. This routine // is used to load up campaigns when a pilot file is loaded. Generally, the // filename will probably be the freespace campaign file, but not necessarily. -int mission_campaign_load_by_name( char *filename ) +int mission_campaign_load_by_name( const char *filename ) { + char real_filename[MAX_FILENAME_LEN+1] = { 0 }; char name[NAME_LENGTH],test[5]; int type,max_players; // make sure to tack on .fsc on the end if its not there already if(strlen(filename) > 0){ - if(strlen(filename) > 4){ - strcpy(test,filename+(strlen(filename)-4)); + strncpy(real_filename, filename, MAX_FILENAME_LEN); + + if(strlen(real_filename) > 4){ + strcpy(test,real_filename+(strlen(real_filename)-4)); if(strcmp(test, FS_CAMPAIGN_FILE_EXT)!=0){ - strcat(filename, FS_CAMPAIGN_FILE_EXT); + strcat(real_filename, FS_CAMPAIGN_FILE_EXT); } } else { - strcat(filename, FS_CAMPAIGN_FILE_EXT); + strcat(real_filename, FS_CAMPAIGN_FILE_EXT); } } else { Error(LOCATION,"Tried to load campaign file with illegal length/extension!"); } - if (!mission_campaign_get_info(filename, name, &type, &max_players)){ + if (!mission_campaign_get_info(real_filename, name, &type, &max_players)){ return -1; } Num_campaigns = 0; - Campaign_file_names[Num_campaigns] = filename; + Campaign_file_names[Num_campaigns] = real_filename; Campaign_names[Num_campaigns] = name; Num_campaigns++; - mission_campaign_load(filename); + mission_campaign_load(real_filename); return 0; } -int mission_campaign_load_by_name_csfe( char *filename, char *callsign ) +int mission_campaign_load_by_name_csfe( const char *filename, const char *callsign ) { Game_mode |= GM_NORMAL; strcpy(Player->callsign, callsign); @@ -907,7 +910,7 @@ int mission_campaign_savefile_save() } // The following function always only ever ever ever called by CSFE!!!!! -int campaign_savefile_save(char *pname) +int campaign_savefile_save(const char *pname) { if (Campaign.type == CAMPAIGN_TYPE_SINGLE) Game_mode &= ~GM_MULTIPLAYER; @@ -926,7 +929,7 @@ int campaign_savefile_save(char *pname) // mission_campaign_savefile_delete deletes any save file in the players directory for the given // campaign filename -void mission_campaign_savefile_delete( char *cfilename, int is_multi ) +void mission_campaign_savefile_delete( const char *cfilename, int is_multi ) { char filename[_MAX_FNAME], base[_MAX_FNAME]; @@ -941,7 +944,7 @@ void mission_campaign_savefile_delete( char *cfilename, int is_multi ) cf_delete( filename, CF_TYPE_SINGLE_PLAYERS ); } -void campaign_delete_save( char *cfn, char *pname) +void campaign_delete_save( const char *cfn, const char *pname) { strcpy(Player->callsign, pname); mission_campaign_savefile_delete(cfn); @@ -950,12 +953,13 @@ void campaign_delete_save( char *cfn, char *pname) // next function deletes all the save files for this particular pilot. Just call cfile function // which will delete multiple files // Player_select_mode tells us whether we are deleting single or multiplayer files -void mission_campaign_delete_all_savefiles( char *pilot_name, int is_multi ) +void mission_campaign_delete_all_savefiles( const char *pilot_name, int is_multi ) { int dir_type, num_files, i; - char *names[MAX_CAMPAIGNS], spec[MAX_FILENAME_LEN + 2], *ext; + char *names[MAX_CAMPAIGNS], spec[MAX_FILENAME_LEN + 2]; + const char *ext; char filename[1024]; - int (*filter_save)(char *filename); + int (*filter_save)(const char *filename); if ( is_multi ) { return; // can't have multiplayer campaign save files @@ -983,7 +987,7 @@ void mission_campaign_delete_all_savefiles( char *pilot_name, int is_multi ) // mission_campaign_savefile_load takes a filename of a campaign file as a parameter and loads all // of the information stored in the campaign file. -void mission_campaign_savefile_load( char *cfilename ) +void mission_campaign_savefile_load( const char *cfilename ) { char filename[_MAX_FNAME], base[_MAX_FNAME]; int version, i, num, j, num_stats_blocks; @@ -1152,7 +1156,7 @@ void mission_campaign_savefile_load( char *cfilename ) } // the following code only ever called by CSFE!!!! -void campaign_savefile_load(char *fname, char *pname) +void campaign_savefile_load(const char *fname, const char *pname) { if (Campaign.type==CAMPAIGN_TYPE_SINGLE) { Game_mode &= ~GM_MULTIPLAYER; @@ -1600,7 +1604,7 @@ void mission_campaign_shutdown() // num => output parameter for the number of mission filenames in the campaign // // note that dest should allocate at least dest[MAX_CAMPAIGN_MISSIONS][NAME_LENGTH] -int mission_campaign_get_filenames(char *filename, char dest[][NAME_LENGTH], int *num) +int mission_campaign_get_filenames(const char *filename, char dest[][NAME_LENGTH], int *num) { int rval; @@ -1740,7 +1744,7 @@ void read_mission_goal_list(int num) // filename. This function tried to be a little smart about filename looking for the .fsm // extension since filenames are stored with the extension in the campaign file. Returns // index of mission in campaign structure. -1 if mission name not found. -int mission_campaign_find_mission( char *name ) +int mission_campaign_find_mission( const char *name ) { int i; char realname[_MAX_PATH]; @@ -1796,7 +1800,7 @@ void mission_campaign_maybe_play_movie(int type) } // return nonzero if the passed filename is a multiplayer campaign, 0 otherwise -int mission_campaign_parse_is_multi(char *filename, char *name) +int mission_campaign_parse_is_multi(const char *filename, char *name) { int i; char temp[50]; @@ -1954,27 +1958,25 @@ void mission_campaign_exit_loop() // used for jumping to a particular campaign mission // all pvs missions marked skipped // this relies on correct mission ordering in the campaign file -void mission_campaign_jump_to_mission(char *name) +void mission_campaign_jump_to_mission(const char *name) { int i = 0; - char dest_name[64]; + char dest_name[64] = { 0 }; // load in the campaign junk mission_load_up_campaign(); #ifdef MAKE_FS1 // tack the .fsm onto the input name - strcpy(dest_name, name); - strcat(name, ".fsm"); + strncpy(dest_name, cf_add_ext(name, ".fsm"), sizeof(dest_name)-1); #else // tack the .fs2 onto the input name - strcpy(dest_name, name); - strcat(name, ".fs2"); + strncpy(dest_name, cf_add_ext(name, ".fs2"), sizeof(dest_name)-1); #endif // search for our mission for (i=0; i= MAX_LINES) return 0; @@ -724,7 +724,7 @@ int hotkey_line_add(char *text, int type, int index, int y) } // insert a line of hotkey smuck before line 'n'. -int hotkey_line_insert(int n, char *text, int type, int index) +int hotkey_line_insert(int n, const char *text, int type, int index) { int z; @@ -745,7 +745,7 @@ int hotkey_line_insert(int n, char *text, int type, int index) // insert a line of hotkey smuck somewhere between 'start' and end of list such that it is // sorted by name -int hotkey_line_add_sorted(char *text, int type, int index, int start) +int hotkey_line_add_sorted(const char *text, int type, int index, int start) { int z; @@ -774,7 +774,7 @@ int hotkey_get_team(int i) int hotkey_build_team_listing(int team, int y) { ship_obj *so; - char *str = NULL; + const char *str = NULL; int i, j, s, z, start; int font_height = gr_get_font_height(); diff --git a/src/mission/missionload.cpp b/src/mission/missionload.cpp index dd7e421..c65f8d6 100644 --- a/src/mission/missionload.cpp +++ b/src/mission/missionload.cpp @@ -354,7 +354,7 @@ static char Campaign_name_list[MAX_CAMPAIGNS+2][NAME_LENGTH]; static int Num_campaign_missions; // get the mission filenames that make up a campaign -extern int mission_campaign_get_filenames(char *filename, char dest[][NAME_LENGTH], int *num); +extern int mission_campaign_get_filenames(const char *filename, char dest[][NAME_LENGTH], int *num); void mission_load_menu_init() { diff --git a/src/mission/missionlog.cpp b/src/mission/missionlog.cpp index f231c3b..2d60abf 100644 --- a/src/mission/missionlog.cpp +++ b/src/mission/missionlog.cpp @@ -306,7 +306,7 @@ void mission_log_cull_obsolete_entries() // function to mark entries as obsolete. Passed is the type of entry that is getting added // to the log. Some entries might get marked obsolete as a result of this type -void mission_log_obsolete_entries(int type, char *pname) +void mission_log_obsolete_entries(int type, const char *pname) { int i; log_entry *entry = NULL; @@ -383,7 +383,7 @@ void mission_log_flag_team( log_entry *entry, int which_entry, int team ) // following function adds an entry into the mission log. // pass a type and a string which indicates the object // that this event is for. Don't add entries with this function for multiplayer -void mission_log_add_entry(int type, char *pname, char *sname, int info_index) +void mission_log_add_entry(int type, const char *pname, const char *sname, int info_index) { int last_entry_save; log_entry *entry; @@ -580,7 +580,7 @@ void mission_log_add_entry(int type, char *pname, char *sname, int info_index) // function, used in multiplayer only, which adds an entry sent by the host of the game, into // the mission log. The index of the log entry is passed as one of the parameters in addition to // the normal parameters used for adding an entry to the log -void mission_log_add_entry_multi( int type, char *pname, char *sname, int index, fix timestamp, int flags ) +void mission_log_add_entry_multi( int type, const char *pname, const char *sname, int index, fix timestamp, int flags ) { log_entry *entry; @@ -617,7 +617,7 @@ void mission_log_add_entry_multi( int type, char *pname, char *sname, int index, // function to determine is the given event has taken place count number of times. -int mission_log_get_time_indexed( int type, char *pname, char *sname, int count, fix *time) +int mission_log_get_time_indexed( int type, const char *pname, const char *sname, int count, fix *time) { int i, found; log_entry *entry; @@ -662,12 +662,12 @@ next_entry: // this function determines if the given type of event on the specified // object has taken place yet. If not, it returns 0. If it has, the // timestamp that the event happened is returned in the time parameter -int mission_log_get_time( int type, char *pname, char *sname, fix *time ) +int mission_log_get_time( int type, const char *pname, const char *sname, fix *time ) { return mission_log_get_time_indexed( type, pname, sname, 1, time ); } -void message_log_add_seg(int n, int x, int color, char *text, int flags = 0) +void message_log_add_seg(int n, int x, int color, const char *text, int flags = 0) { log_text_seg *seg, **parent; @@ -688,44 +688,54 @@ void message_log_add_seg(int n, int x, int color, char *text, int flags = 0) *parent = seg; } -void message_log_add_segs(char *text, int color, int flags = 0) +void message_log_add_segs(const char *text, int color, int flags = 0) { + char *log_text = NULL, *log_text_ptr = NULL; char *ptr; int w; + if (!text) { + mprintf(("Why are you passing a NULL pointer to message_log_add_segs?\n")); + return; + } + + log_text = strdup(text); + log_text_ptr = log_text; + + if (!log_text) { + return; + } + while (1) { if (X == ACTION_X) { - while (is_white_space(*text)) - text++; - } - - if (!text) { - mprintf(("Why are you passing a NULL pointer to message_log_add_segs?\n")); - return; + while (is_white_space(*log_text_ptr)) + log_text_ptr++; } - if ( !text[0] ) { - return; + if ( !log_text_ptr[0] ) { + break; } if (P_width - X < 1) - ptr = text; + ptr = log_text_ptr; else - ptr = split_str_once(text, P_width - X); + ptr = split_str_once(log_text_ptr, P_width - X); - if (ptr != text) - message_log_add_seg(Num_log_lines, X, color, text, flags); + if (ptr != log_text_ptr) + message_log_add_seg(Num_log_lines, X, color, log_text_ptr, flags); if (!ptr) { - gr_get_string_size(&w, NULL, text); + gr_get_string_size(&w, NULL, log_text_ptr); X += w; - return; + break; } Num_log_lines++; X = ACTION_X; - text = ptr; + log_text_ptr = ptr; } + + free(log_text); } void message_log_remove_segs(int n) @@ -856,7 +866,7 @@ void message_log_init_scrollback(int pw) message_log_add_segs(XSTR( "Subsystem ", 410), LOG_COLOR_NORMAL); //message_log_add_segs(entry->sname, LOG_COLOR_BRIGHT); - char *subsys_name = Ship_info[si_index].subsystems[model_index].name; + const char *subsys_name = Ship_info[si_index].subsystems[model_index].name; if (Ship_info[si_index].subsystems[model_index].type == SUBSYSTEM_TURRET) { subsys_name = XSTR("Turret", 1487); } diff --git a/src/mission/missionmessage.cpp b/src/mission/missionmessage.cpp index f4245da..6e090ee 100644 --- a/src/mission/missionmessage.cpp +++ b/src/mission/missionmessage.cpp @@ -408,7 +408,7 @@ // names read in for builtin message radio bits to see what message to play. These are // generic names, meaning that there will be the same message type for a number of different // personas -char *Builtin_message_types[MAX_BUILTIN_MESSAGE_TYPES] = +const char *Builtin_message_types[MAX_BUILTIN_MESSAGE_TYPES] = { //XSTR:OFF "Arrive Enemy", @@ -532,7 +532,7 @@ int MessageQ_num; // keeps track of number of entries on the queue. int Num_personas; Persona Personas[MAX_PERSONAS]; -char *Persona_type_names[MAX_PERSONA_TYPES] = +const char *Persona_type_names[MAX_PERSONA_TYPES] = { //XSTR:OFF "wingman", @@ -618,7 +618,7 @@ void persona_parse() } // two functions to add avi/wave names into a table -int add_avi( char *avi_name ) +int add_avi( const char *avi_name ) { int i; @@ -638,7 +638,7 @@ int add_avi( char *avi_name ) return (Num_message_avis - 1); } -int add_wave( char *wave_name ) +int add_wave( const char *wave_name ) { int i; @@ -1587,7 +1587,7 @@ all_done: } // queues up a message to display to the player -void message_queue_message( int message_num, int priority, int timing, char *who_from, int source, int group, int delay, int builtin_type ) +void message_queue_message( int message_num, int priority, int timing, const char *who_from, int source, int group, int delay, int builtin_type ) { int i, m_persona; @@ -1808,7 +1808,7 @@ int message_filter_multi(int id) void message_send_unique_to_player( char *id, void *data, int m_source, int priority, int group, int delay ) { int i, source; - char *who_from; + const char *who_from; source = 0; who_from = NULL; @@ -1823,7 +1823,7 @@ void message_send_unique_to_player( char *id, void *data, int m_source, int prio who_from = TERRAN_COMMAND; source = HUD_SOURCE_TERRAN_CMD; } else if ( m_source == MESSAGE_SOURCE_SPECIAL ) { - who_from = (char *)data; + who_from = (const char *)data; source = HUD_SOURCE_TERRAN_CMD; } else if ( m_source == MESSAGE_SOURCE_WINGMAN ) { int m_persona, ship_index; @@ -1918,7 +1918,7 @@ void message_send_builtin_to_player( int type, ship *shipp, int priority, int ti // persona if we can't find the right message for the given persona do { for ( i = 0; i < Num_builtin_messages; i++ ) { - char *name, *who_from; + const char *name, *who_from; name = Builtin_message_types[type]; @@ -2003,7 +2003,7 @@ int message_is_playing() // Functions below pertain only to personas!!!! // given a character string, try to find the persona index -int message_persona_name_lookup( char *name ) +int message_persona_name_lookup( const char *name ) { int i; diff --git a/src/mission/missionparse.cpp b/src/mission/missionparse.cpp index 2ef7aa6..0487659 100644 --- a/src/mission/missionparse.cpp +++ b/src/mission/missionparse.cpp @@ -456,20 +456,20 @@ int Num_parse_names; //XSTR:OFF -char *Nebula_filenames[NUM_NEBULAS] = { +const char *Nebula_filenames[NUM_NEBULAS] = { "Nebula01", "Nebula02", "Nebula03" }; -char *Neb2_filenames[NUM_NEBULAS] = { +const char *Neb2_filenames[NUM_NEBULAS] = { "Nebfull01", "Nebfull02", "Nebfull03" }; // Note: Nebula_colors[] and Nebula_palette_filenames are linked via index numbers -char *Nebula_colors[NUM_NEBULA_COLORS] = { +const char *Nebula_colors[NUM_NEBULA_COLORS] = { "Red", "Blue", "Gold", @@ -481,9 +481,9 @@ char *Nebula_colors[NUM_NEBULA_COLORS] = { "Grey Green", }; -char *Iff_names[MAX_IFF] = { "IFF 1", "IFF 2", "IFF 3" }; +const char *Iff_names[MAX_IFF] = { "IFF 1", "IFF 2", "IFF 3" }; -char *Ai_behavior_names[MAX_AI_BEHAVIORS] = { +const char *Ai_behavior_names[MAX_AI_BEHAVIORS] = { "Chase", "Evade", "Get behind", @@ -512,7 +512,7 @@ char Cargo_names_buf[MAX_CARGO][NAME_LENGTH]; char *Ship_class_names[MAX_SHIP_TYPES]; // to be filled in from Ship_info array -char *Icon_names[MAX_BRIEF_ICONS] = { +const char *Icon_names[MAX_BRIEF_ICONS] = { "Fighter", "Fighter Wing", "Cargo", "Cargo Wing", "Largeship", "Largeship Wing", "Capital", "Planet", "Asteroid Field", "Waypoint", "Support Ship", "Freighter(no cargo)", "Freighter(has cargo)", @@ -530,28 +530,28 @@ char *Icon_names[MAX_BRIEF_ICONS] = { // -1 means an illegal value. int Team_names_index_xlate[MAX_TEAM_NAMES_INDEX+1] = {-1, 0, 1, -1, 2, -1, -1, -1, 3}; -char *Team_names[MAX_TEAM_NAMES] = { +const char *Team_names[MAX_TEAM_NAMES] = { "Hostile", "Friendly", "Neutral", "Unknown", }; -char *Status_desc_names[MAX_STATUS_NAMES] = { +const char *Status_desc_names[MAX_STATUS_NAMES] = { "Shields Critical", "Engines Damaged", "Fully Operational", }; -char *Status_type_names[MAX_STATUS_NAMES] = { +const char *Status_type_names[MAX_STATUS_NAMES] = { "Damaged", "Disabled", "Corroded", }; -char *Status_target_names[MAX_STATUS_NAMES] = { +const char *Status_target_names[MAX_STATUS_NAMES] = { "Weapons", "Engines", "Cable TV", }; // definitions for arrival locations for ships/wings -char *Arrival_location_names[MAX_ARRIVAL_NAMES] = { +const char *Arrival_location_names[MAX_ARRIVAL_NAMES] = { "Hyperspace", "Near Ship", "In front of ship", "Docking Bay", }; -char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS] = +const char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS] = { "", "", @@ -561,31 +561,31 @@ char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS] = "", }; -char *Departure_location_names[MAX_ARRIVAL_NAMES] = { +const char *Departure_location_names[MAX_ARRIVAL_NAMES] = { "Hyperspace", "Docking Bay", }; -char *Goal_type_names[MAX_GOAL_TYPE_NAMES] = { +const char *Goal_type_names[MAX_GOAL_TYPE_NAMES] = { "Primary", "Secondary", "Bonus", }; -char *Species_names[MAX_SPECIES_NAMES] = { +const char *Species_names[MAX_SPECIES_NAMES] = { "Terran", "Vasudan", "Shivan", }; -char *Reinforcement_type_names[] = { +const char *Reinforcement_type_names[] = { "Attack/Protect", "Repair/Rearm", }; -char *Old_game_types[OLD_MAX_GAME_TYPES] = { +const char *Old_game_types[OLD_MAX_GAME_TYPES] = { "Single Player Only", "Multiplayer Only", "Single/Multi Player", "Training mission" }; -char *Parse_object_flags[MAX_PARSE_OBJECT_FLAGS] = { +const char *Parse_object_flags[MAX_PARSE_OBJECT_FLAGS] = { "cargo-known", "ignore-count", "protect-ship", @@ -608,7 +608,7 @@ char *Parse_object_flags[MAX_PARSE_OBJECT_FLAGS] = { "special-warp" }; -char *Starting_wing_names[MAX_STARTING_WINGS+1] = { +const char *Starting_wing_names[MAX_STARTING_WINGS+1] = { "Alpha", "Beta", "Gamma", @@ -658,7 +658,7 @@ int allocate_subsys_status(); void parse_common_object_data(p_object *objp); void parse_asteroid_fields(mission *pm); int mission_set_arrival_location(int anchor, int location, int distance, int objnum, vector *new_pos, matrix *new_orient); -int get_parse_name_index(char *name); +int get_parse_name_index(const char *name); int get_anchor(char *name); void mission_parse_do_initial_docks(); void mission_parse_set_arrival_locations(); @@ -1203,7 +1203,7 @@ void parse_briefing(mission *pm) Assert((team_index >= 0) && (team_index < MAX_TEAM_NAMES)); bi->team = 1 << team_index; - find_and_stuff("$class:", &bi->ship_class, F_NAME, Ship_class_names, Num_ship_types, "ship class"); + find_and_stuff("$class:", &bi->ship_class, F_NAME, (const char **)Ship_class_names, Num_ship_types, "ship class"); required_string("$pos:"); stuff_vector(&bi->pos); @@ -1822,7 +1822,7 @@ int parse_object(mission *pm, int flag, p_object *objp) error_display(0, NOX("Redundant ship name: %s\n"), objp->name); - find_and_stuff("$Class:", &objp->ship_class, F_NAME, Ship_class_names, Num_ship_types, "ship class"); + find_and_stuff("$Class:", &objp->ship_class, F_NAME, (const char **)Ship_class_names, Num_ship_types, "ship class"); if (objp->ship_class < 0) { Warning(LOCATION, "Ship \"%s\" has an invalid ship type (ships.tbl probably changed). Making it type 0", objp->name); @@ -1871,7 +1871,7 @@ int parse_object(mission *pm, int flag, p_object *objp) objp->ai_goals = -1; if ( optional_string("+AI Class:")) { - objp->ai_class = match_and_stuff(F_NAME, Ai_class_names, Num_ai_classes, "AI class"); + objp->ai_class = match_and_stuff(F_NAME, (const char **)Ai_class_names, Num_ai_classes, "AI class"); Assert(objp->ai_class > -1 ); } else { objp->ai_class = Ship_info[objp->ship_class].ai_class; @@ -2212,7 +2212,7 @@ void parse_common_object_data(p_object *objp) if (optional_string("+Cargo Name:")) { char cargo_name[256]; stuff_string(cargo_name, F_NAME, NULL); - int index = string_lookup(cargo_name, Cargo_names, Num_cargo, "cargo", 0); + int index = string_lookup(cargo_name, (const char **)Cargo_names, Num_cargo, "cargo", 0); if (index == -1 && (Num_cargo < MAX_CARGO)) { index = Num_cargo; strcpy(Cargo_names[Num_cargo++], cargo_name); @@ -2221,7 +2221,7 @@ void parse_common_object_data(p_object *objp) } if (optional_string("+AI Class:")) - Subsys_status[i].ai_class = match_and_stuff(F_NAME, Ai_class_names, Num_ai_classes, "AI class"); + Subsys_status[i].ai_class = match_and_stuff(F_NAME, (const char **)Ai_class_names, Num_ai_classes, "AI class"); if (optional_string("+Primary Banks:")) stuff_int_list(Subsys_status[i].primary_banks, MAX_PRIMARY_BANKS, WEAPON_LIST_TYPE); @@ -3829,7 +3829,7 @@ int get_mission_info(char *filename, mission *mission_p) // mai parse routine for parsing a mission. The default parameter flags tells us which information // to get when parsing the mission. 0 means get everything (default). Other flags just gets us basic // info such as game type, number of players etc. -int parse_main(char *mission_name, int flags) +int parse_main(const char *mission_name, int flags) { int rval, i; @@ -4024,7 +4024,7 @@ void mission_parse_do_initial_docks() } // function which returns true or false if the given mission support multiplayers -int mission_parse_is_multi(char *filename, char *mission_name) +int mission_parse_is_multi(const char *filename, char *mission_name) { int rval, game_type; int filelength; @@ -4090,7 +4090,7 @@ int mission_parse_is_multi(char *filename, char *mission_name) // The calling function can use the information in The_mission to get the name/description of the mission // if needed. -int mission_parse_get_multi_mission_info( char *filename ) +int mission_parse_get_multi_mission_info( const char *filename ) { if ( parse_main(filename, MISSION_PARSE_MISSION_INFO) ){ return -1; @@ -4106,7 +4106,7 @@ int mission_parse_get_multi_mission_info( char *filename ) } // returns true or false if this is on the yet to arrive list -int mission_parse_ship_arrived( char *shipname ) +int mission_parse_ship_arrived( const char *shipname ) { p_object *objp; @@ -4118,7 +4118,7 @@ int mission_parse_ship_arrived( char *shipname ) } // return the parse object on the ship arrival list associated with the given name -p_object *mission_parse_get_arrival_ship( char *name ) +p_object *mission_parse_get_arrival_ship( const char *name ) { p_object *objp; @@ -4821,7 +4821,7 @@ int allocate_subsys_status() } // find (or add) the name in the list and return an index to it. -int get_parse_name_index(char *name) +int get_parse_name_index(const char *name) { int i; diff --git a/src/mission/missiontraining.cpp b/src/mission/missiontraining.cpp index d20be16..a41c78d 100644 --- a/src/mission/missiontraining.cpp +++ b/src/mission/missiontraining.cpp @@ -359,7 +359,7 @@ void message_translate_tokens(char *buf, char *text); static hud_frames Directive_gauge[NUM_DIRECTIVE_GAUGES]; static int Directive_frames_loaded = 0; -static char *Directive_fnames[3] = +static const char *Directive_fnames[3] = { //XSTR:OFF "directives1", @@ -819,7 +819,7 @@ void message_translate_tokens(char *buf, char *text) strncpy(temp, text, toke2 - text); // isolate token into seperate buffer temp[toke2 - text] = 0; // null terminate string - ptr = translate_key(temp); // try and translate key + ptr = (char *)translate_key(temp); // try and translate key if (ptr) { // was key translated properly? if (!stricmp(ptr, NOX("none")) && (Training_bind_warning != Missiontime)) { if ( The_mission.game_type & MISSION_TYPE_TRAINING ) { diff --git a/src/missionui/chatbox.cpp b/src/missionui/chatbox.cpp index 4342a6d..79dbe62 100644 --- a/src/missionui/chatbox.cpp +++ b/src/missionui/chatbox.cpp @@ -311,13 +311,13 @@ // SMALL CHATBOX ---------------------------------------------------------------------------------- // background bitmap -char* Chatbox_small_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_small_bitmap_fname[GR_NUM_RESOLUTIONS] = { "Chatbox", // GR_640 "2_Chatbox" // GR_1024 }; // background mask -char* Chatbox_small_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_small_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "Chatbox-m", // GR_640 "2_Chatbox-m" // GR_1024 }; @@ -377,13 +377,13 @@ int Chatbox_small_max_lines[GR_NUM_RESOLUTIONS] = { // BIG CHATBOX ---------------------------------------------------------------------------------- // background bitmap -char* Chatbox_big_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_big_bitmap_fname[GR_NUM_RESOLUTIONS] = { "ChatboxBig", // GR_640 "2_ChatboxBig" // GR_1024 }; // mask -char* Chatbox_big_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_big_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "Chatbox-m", // GR_640 "2_Chatbox-m" // GR_1024 }; @@ -443,13 +443,13 @@ int Chatbox_big_max_lines[GR_NUM_RESOLUTIONS] = { // PAUSED CHATBOX ---------------------------------------------------------------------------------- // mask -char* Chatbox_p_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_p_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MPPause", // GR_640 "2_MPPause" // GR_1024 }; // mask -char* Chatbox_p_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char* Chatbox_p_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MPPause-m", // GR_640 "2_MPPause-m" // GR_1024 }; @@ -696,14 +696,14 @@ void chatbox_set_mode(int mode_flags) // automatically split up any input text, send it, and leave the remainder void chatbox_autosplit_line() { - char *remainder,msg[150]; + char *remainder = NULL, msg[150]; int msg_pixel_width; // if the chat line is getting too long, fire off the message, putting the last // word on the next input line. memset(msg,0,150); Chat_inputbox.get_text(msg); - remainder = ""; + // determine if the width of the string in pixels is > than the inputbox width -- if so, // then send the message gr_get_string_size(&msg_pixel_width, NULL, msg); @@ -713,16 +713,17 @@ void chatbox_autosplit_line() if ( remainder ) { *remainder = '\0'; remainder++; - } else { - remainder = ""; - } + } + // if I'm the server, then broadcast the packet chatbox_recall_add(msg); send_game_chat_packet(Net_player, msg, MULTI_MSG_ALL,NULL); chatbox_add_line(msg, MY_NET_PLAYER_NUM); - // display any remainder of text on the next line - Chat_inputbox.set_text(remainder); + if ( remainder ) { + // display any remainder of text on the next line + Chat_inputbox.set_text(remainder); + } } else if((Chat_inputbox.pressed() && (strlen(msg) > 0)) || (strlen(msg) >= CHATBOX_MAX_LEN)) { // tack on the null terminator in the boundary case int x = strlen(msg); @@ -732,10 +733,7 @@ void chatbox_autosplit_line() // if I'm the server, then broadcast the packet chatbox_recall_add(msg); send_game_chat_packet(Net_player, msg, MULTI_MSG_ALL,NULL); - chatbox_add_line(msg, MY_NET_PLAYER_NUM); - - // display any remainder of text on the next line - Chat_inputbox.set_text(remainder); + chatbox_add_line(msg, MY_NET_PLAYER_NUM); } } @@ -1016,7 +1014,7 @@ void chatbox_chat_init() } // int Test_color = 0; -void chatbox_add_line(char *msg, int pid, int add_id) +void chatbox_add_line(const char *msg, int pid, int add_id) { int backup; int n_lines,idx; diff --git a/src/missionui/missionbrief.cpp b/src/missionui/missionbrief.cpp index 18c7989..afdf0aa 100644 --- a/src/missionui/missionbrief.cpp +++ b/src/missionui/missionbrief.cpp @@ -410,17 +410,17 @@ static int Brief_infobox_coords[GR_NUM_RESOLUTIONS][2] = { } }; -static char *Brief_infobox_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_infobox_filename[GR_NUM_RESOLUTIONS] = { "InfoBox", "2_Infobox" }; -static char *Brief_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_filename[GR_NUM_RESOLUTIONS] = { "Brief", "2_Brief" }; -static char *Brief_multi_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_multi_filename[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "Brief", // use the standard bitmap and slap the chatbox on later #else @@ -429,18 +429,18 @@ static char *Brief_multi_filename[GR_NUM_RESOLUTIONS] = { "2_BriefMulti" }; -static char *Brief_mask_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_mask_filename[GR_NUM_RESOLUTIONS] = { "Brief-m", "2_Brief-m" }; -static char *Brief_multi_mask_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_multi_mask_filename[GR_NUM_RESOLUTIONS] = { "BriefMulti-m", "2_BriefMulti-m" }; -static char *Brief_win_filename[GR_NUM_RESOLUTIONS] = { +static const char *Brief_win_filename[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "mapwin", "mapwin" @@ -466,12 +466,12 @@ int Closeup_region[GR_NUM_RESOLUTIONS][4] = { }, }; -char *Closeup_background_filename[GR_NUM_RESOLUTIONS] = { +const char *Closeup_background_filename[GR_NUM_RESOLUTIONS] = { NOX("BriefPop"), // GR_640 NOX("2_BriefPop") // GR_1024 }; -char *Closeup_button_filename[GR_NUM_RESOLUTIONS] = { +const char *Closeup_button_filename[GR_NUM_RESOLUTIONS] = { NOX("BPB_00"), // GR_640 NOX("2_BPB_00"), // GR_1024 }; @@ -523,26 +523,26 @@ int Brief_inited = FALSE; #define BRIEF_PAUSE_MASK 16 //XSTR:OFF -static char *Brief_mask_single[GR_NUM_RESOLUTIONS] = { +static const char *Brief_mask_single[GR_NUM_RESOLUTIONS] = { "brief-m", // GR_640 "2_brief-m" // GR_1024 }; -static char *Brief_mask_multi[GR_NUM_RESOLUTIONS] = { +static const char *Brief_mask_multi[GR_NUM_RESOLUTIONS] = { "briefmulti-m", // GR_640 "2_briefmulti-m" // GR_1024 }; //XSTR:ON struct brief_buttons { - char *filename; + const char *filename; int x, y; int xt, yt; int hotspot; int repeat; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - brief_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int r = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), repeat(r) {} + brief_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h, int r = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), repeat(r) {} }; int Brief_grid_bitmap = -1; @@ -654,7 +654,7 @@ int brief_setup_closeup(brief_icon *bi); void brief_maybe_blit_scene_cut(float frametime); void brief_transition_reset(); -char *brief_tooltip_handler(char *str) +const char *brief_tooltip_handler(const char *str) { if (!stricmp(str, NOX("@close"))) { if (Closeup_icon) @@ -2289,7 +2289,7 @@ void briefing_stop_music() } } -void briefing_load_music(char* fname) +void briefing_load_music(const char* fname) { if ( Cmdline_freespace_no_music ) { return; diff --git a/src/missionui/missioncmdbrief.cpp b/src/missionui/missioncmdbrief.cpp index 7a2f42e..380853a 100644 --- a/src/missionui/missioncmdbrief.cpp +++ b/src/missionui/missioncmdbrief.cpp @@ -255,12 +255,12 @@ #include "alphacolors.h" #include "animplay.h" -char *Cmd_brief_fname[GR_NUM_RESOLUTIONS] = { +const char *Cmd_brief_fname[GR_NUM_RESOLUTIONS] = { "CommandBrief", "2_CommandBrief" }; -char *Cmd_brief_mask[GR_NUM_RESOLUTIONS] = { +const char *Cmd_brief_mask[GR_NUM_RESOLUTIONS] = { "CommandBrief-m", "2_Commandbrief-m" }; @@ -620,7 +620,7 @@ void cmd_brief_button_pressed(int n) void cmd_brief_ani_wave_init(int index) { - char *name; + const char *name; int i; // first, search and see if anim is already used in another stage diff --git a/src/missionui/missiondebrief.cpp b/src/missionui/missiondebrief.cpp index 1596c0c..96c1945 100644 --- a/src/missionui/missiondebrief.cpp +++ b/src/missionui/missiondebrief.cpp @@ -578,15 +578,15 @@ int Debrief_award_text_width[GR_NUM_RESOLUTIONS][2] = { } }; -char *Debrief_single_name[GR_NUM_RESOLUTIONS] = { +const char *Debrief_single_name[GR_NUM_RESOLUTIONS] = { "DebriefSingle", // GR_640 "2_DebriefSingle" // GR_1024 }; -char *Debrief_multi_name[GR_NUM_RESOLUTIONS] = { +const char *Debrief_multi_name[GR_NUM_RESOLUTIONS] = { "DebriefMulti", // GR_640 "2_DebriefMulti" // GR_1024 }; -char *Debrief_mask_name[GR_NUM_RESOLUTIONS] = { +const char *Debrief_mask_name[GR_NUM_RESOLUTIONS] = { "Debrief-m", // GR_640 "2_Debrief-m" // GR_1024 }; @@ -616,7 +616,7 @@ char *Debrief_mask_name[GR_NUM_RESOLUTIONS] = { #define REPEAT 1 //XSTR:OFF -char* Debrief_loading_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char* Debrief_loading_bitmap_fname[GR_NUM_RESOLUTIONS] = { "PleaseWait", // GR_640 "2_PleaseWait" // GR_1024 }; @@ -878,7 +878,7 @@ voice_map Debrief_promotion_voice_mapping[NUM_VOLITION_CAMPAIGNS][MAX_CAMPAIGN_M #define DB_AWARD_RANK 2 #define DB_AWARD_BADGE 3 #define DB_AWARD_BG 4 -static char* Debrief_award_filename[GR_NUM_RESOLUTIONS][5] = { +static const char* Debrief_award_filename[GR_NUM_RESOLUTIONS][5] = { { "DebriefWings", "DebriefMedal", @@ -899,7 +899,7 @@ static char* Debrief_award_filename[GR_NUM_RESOLUTIONS][5] = { #define DB_AWARD_RANK 3 #define DB_AWARD_BADGE 4 #define DB_AWARD_BG 5 -static char* Debrief_award_filename[GR_NUM_RESOLUTIONS][6] = { +static const char* Debrief_award_filename[GR_NUM_RESOLUTIONS][6] = { { "DebriefWings", "DebriefMedal", @@ -933,7 +933,7 @@ void debrief_award_text_clear(); // functions -char *debrief_tooltip_handler(char *str) +const char *debrief_tooltip_handler(const char *str) { if (!stricmp(str, NOX("@.Medal"))) { if (Award_active){ @@ -1747,7 +1747,7 @@ void debrief_accept(int ok_to_post_start_game_event) int go_loop = 0; if ( (/*Cheats_enabled ||*/ Turned_traitor || Must_replay_mission) && (Game_mode & GM_CAMPAIGN_MODE) ) { - char *str; + const char *str; int z; if (Game_mode & GM_MULTIPLAYER) { @@ -2282,7 +2282,7 @@ void debrief_check_buttons() */ } -void debrief_text_stage_init(char *src, int type) +void debrief_text_stage_init(const char *src, int type) { int i, n_lines, n_chars[MAX_DEBRIEF_LINES]; char line[MAX_DEBRIEF_LINE_LEN]; @@ -2324,7 +2324,7 @@ void debrief_free_text() void debrief_text_init() { int i, r_count = 0; - char *src; + const char *src; // release old text lines first debrief_free_text(); @@ -2753,7 +2753,7 @@ void debrief_add_award_text(char *str) void debrief_do_frame(float frametime) { int k=0, new_k=0; - char *please_wait_str = XSTR("Please Wait", 1242); + const char *please_wait_str = XSTR("Please Wait", 1242); int str_w, str_h; char buf[256]; diff --git a/src/missionui/missionloopbrief.cpp b/src/missionui/missionloopbrief.cpp index 2b4a408..74c6adf 100644 --- a/src/missionui/missionloopbrief.cpp +++ b/src/missionui/missionloopbrief.cpp @@ -58,12 +58,12 @@ // MISSION LOOP BRIEF DEFINES/VARS // -char *Loop_brief_fname[GR_NUM_RESOLUTIONS] = { +const char *Loop_brief_fname[GR_NUM_RESOLUTIONS] = { "LoopBrief", // GR_640 "2_LoopBrief", // GR_1024 }; -char *Loop_brief_mask[GR_NUM_RESOLUTIONS] = { +const char *Loop_brief_mask[GR_NUM_RESOLUTIONS] = { "LoopBrief-m", // GR_640 "2_Loopbrief-m", // GR_1024 }; diff --git a/src/missionui/missionpause.cpp b/src/missionui/missionpause.cpp index 2bfd18c..fdd6b3b 100644 --- a/src/missionui/missionpause.cpp +++ b/src/missionui/missionpause.cpp @@ -64,7 +64,7 @@ // // pause bitmap name -char *Pause_bmp_name[GR_NUM_RESOLUTIONS] = { +const char *Pause_bmp_name[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "Pause", #else @@ -87,11 +87,11 @@ int Please_wait_coords[GR_NUM_RESOLUTIONS][4] = { } }; -char *Pause_multi_fname[GR_NUM_RESOLUTIONS] = { +const char *Pause_multi_fname[GR_NUM_RESOLUTIONS] = { "MPPause", "2_MPPause" }; -char *Pause_multi_mask[GR_NUM_RESOLUTIONS] = { +const char *Pause_multi_mask[GR_NUM_RESOLUTIONS] = { "MPPause-m", "2_MPPause-m" }; @@ -171,11 +171,7 @@ void pause_init(int multi) void pause_do(int multi) { int k; -#ifdef MAKE_FS1 - char *pause_str = XSTR(" ", -1); -#else - char *pause_str = XSTR("Paused", 767); -#endif + const char *pause_str = XSTR("Paused", 767); int str_w, str_h; if(Game_mode & GM_STANDALONE_SERVER){ @@ -191,12 +187,14 @@ void pause_do(int multi) // draw the bitmap gr_bitmap(Please_wait_coords[gr_screen.res][0], Please_wait_coords[gr_screen.res][1]); +#ifndef MAKE_FS1 // draw "Paused" on it gr_set_color_fast(&Color_normal); gr_set_font(FONT2); gr_get_string_size(&str_w, &str_h, pause_str); gr_string((gr_screen.max_w - str_w) / 2, (gr_screen.max_h - str_h) / 2, pause_str); gr_set_font(FONT1); +#endif } } diff --git a/src/missionui/missionscreencommon.cpp b/src/missionui/missionscreencommon.cpp index 7d2c3b4..3e75fb2 100644 --- a/src/missionui/missionscreencommon.cpp +++ b/src/missionui/missionscreencommon.cpp @@ -634,7 +634,7 @@ void common_music_close() // function that sets the current palette to the interface palette. This function // needs to be followed by common_free_interface_palette() to restore the game palette. -void common_set_interface_palette(char *filename) +void common_set_interface_palette(const char *filename) { static char buf[MAX_FILENAME_LEN + 1] = {0}; @@ -1212,7 +1212,7 @@ void common_select_close() // ------------------------------------------------------------------------ // load_wing_icons() creates the bitmaps for wing icons // -void load_wing_icons(char *filename) +void load_wing_icons(const char *filename) { int first_frame, num_frames; diff --git a/src/missionui/missionshipchoice.cpp b/src/missionui/missionshipchoice.cpp index afc5c17..b3ea68c 100644 --- a/src/missionui/missionshipchoice.cpp +++ b/src/missionui/missionshipchoice.cpp @@ -601,7 +601,7 @@ static int SS_active_list_size; ////////////////////////////////////////////////////// // Background bitmaps data for ship_select ////////////////////////////////////////////////////// -static char* Ship_select_background_fname[GR_NUM_RESOLUTIONS] = { +static const char* Ship_select_background_fname[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "Brief", "Brief" @@ -611,7 +611,7 @@ static char* Ship_select_background_fname[GR_NUM_RESOLUTIONS] = { #endif }; -static char* Ship_select_background_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char* Ship_select_background_mask_fname[GR_NUM_RESOLUTIONS] = { "ShipSelect-m", "2_ShipSelect-m" }; @@ -629,13 +629,13 @@ int Ship_select_background_bitmap; // convenient struct for handling all button controls struct ss_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; int scrollable; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - ss_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int s) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), scrollable(s) {} + ss_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h, int s) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), scrollable(s) {} }; static ss_buttons Ship_select_buttons[GR_NUM_RESOLUTIONS][NUM_SS_BUTTONS] = { @@ -735,7 +735,7 @@ void ss_set_carried_icon(int from_slot, int ship_class); #define SHIP_DESC_X 445 #define SHIP_DESC_Y 273 -char *ss_tooltip_handler(char *str) +const char *ss_tooltip_handler(const char *str) { if (Selected_ss_class < 0) return NULL; diff --git a/src/missionui/missionweaponchoice.cpp b/src/missionui/missionweaponchoice.cpp index 26ae2c2..9bbb443 100644 --- a/src/missionui/missionweaponchoice.cpp +++ b/src/missionui/missionweaponchoice.cpp @@ -557,23 +557,23 @@ typedef struct wl_bitmap_group UI_WINDOW Weapon_ui_window; //UI_BUTTON Weapon_buttons[NUM_WEAPON_BUTTONS]; -static char *Wl_mask_single[GR_NUM_RESOLUTIONS] = { +static const char *Wl_mask_single[GR_NUM_RESOLUTIONS] = { "weaponloadout-m", "2_weaponloadout-m" }; -static char *Wl_mask_multi[GR_NUM_RESOLUTIONS] = { +static const char *Wl_mask_multi[GR_NUM_RESOLUTIONS] = { "weaponloadoutmulti-m", "2_weaponloadoutmulti-m" }; -static char *Wl_loadout_select_mask[GR_NUM_RESOLUTIONS] = { +static const char *Wl_loadout_select_mask[GR_NUM_RESOLUTIONS] = { "weaponloadout-m", "2_weaponloadout-m" }; -static char *Weapon_select_background_fname[GR_NUM_RESOLUTIONS] = { +static const char *Weapon_select_background_fname[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "Brief", "Brief" @@ -583,7 +583,7 @@ static char *Weapon_select_background_fname[GR_NUM_RESOLUTIONS] = { #endif }; -static char *Weapon_select_multi_background_fname[GR_NUM_RESOLUTIONS] = { +static const char *Weapon_select_multi_background_fname[GR_NUM_RESOLUTIONS] = { #ifdef MAKE_FS1 "Brief", "Brief" @@ -607,12 +607,12 @@ static int WeaponSelectMaskBitmap; // bitmap id of the weapon select mask bitma // convenient struct for handling all button controls struct wl_buttons { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; UI_BUTTON button; // because we have a class inside this struct, we need the constructor below.. - wl_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} + wl_buttons(const char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {} }; static wl_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_WEAPON_BUTTONS] = { @@ -947,7 +947,7 @@ int wl_fury_missile_offset_hack(int weapon_class, int num_missiles) return 0; } -char *wl_tooltip_handler(char *str) +const char *wl_tooltip_handler(const char *str) { if (Selected_wl_class < 0) return NULL; diff --git a/src/missionui/redalert.cpp b/src/missionui/redalert.cpp index 7a8a8de..e55e650 100644 --- a/src/missionui/redalert.cpp +++ b/src/missionui/redalert.cpp @@ -217,12 +217,12 @@ static char Red_alert_precursor_mission[MAX_FILENAME_LEN]; // Red Alert Interface ///////////////////////////////////////////////////////////////////////////// -char *Red_alert_fname[GR_NUM_RESOLUTIONS] = { +const char *Red_alert_fname[GR_NUM_RESOLUTIONS] = { "RedAlert", "2_RedAlert" }; -char *Red_alert_mask[GR_NUM_RESOLUTIONS] = { +const char *Red_alert_mask[GR_NUM_RESOLUTIONS] = { "RedAlert-m", "2_RedAlert-m" }; @@ -404,7 +404,7 @@ float Ra_flash_time = 0.0f; int Ra_flash_up = 0; void red_alert_blit_title() { - char *str = XSTR("Incoming Transmission", 1406); + const char *str = XSTR("Incoming Transmission", 1406); int w, h; // get the string size diff --git a/src/model/modelread.cpp b/src/model/modelread.cpp index eb949b7..d5c2b5e 100644 --- a/src/model/modelread.cpp +++ b/src/model/modelread.cpp @@ -1164,7 +1164,7 @@ void do_new_subsystem( int n_subsystems, model_subsystem *slist, int subobj_num, } -void print_family_tree( polymodel *obj, int modelnum, char * ident, int islast ) +void print_family_tree( polymodel *obj, int modelnum, const char * ident, int islast ) { char temp[50]; @@ -1242,7 +1242,7 @@ int Bogus_warning_flag_1903 = 0; #endif //reads a binary file containing a 3d model -int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subsystem *subsystems) +int read_model_file(polymodel * pm, const char *filename, int n_subsystems, model_subsystem *subsystems) { CFILE *fp; int version; @@ -2055,7 +2055,7 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs //returns the number of this model -int model_load(char *filename, int n_subsystems, model_subsystem *subsystems) +int model_load(const char *filename, int n_subsystems, model_subsystem *subsystems) { int i, num, arc_idx; diff --git a/src/movie/movie.cpp b/src/movie/movie.cpp index 5f2fcea..471d83d 100644 --- a/src/movie/movie.cpp +++ b/src/movie/movie.cpp @@ -34,7 +34,7 @@ #include "gamesequence.h" #include "mainhallmenu.h" -int movie_play(char *filename, int cd_prompt) +int movie_play(const char *filename, int cd_prompt) { // mark the movie as viewable in the techroom if in a campaign if (Game_mode & GM_CAMPAIGN_MODE) { @@ -90,7 +90,7 @@ int movie_play(char *filename, int cd_prompt) return 1; } -int movie_play_two(char *filename1, char *filename2) +int movie_play_two(const char *filename1, const char *filename2) { // FIXME: part of the CD code which isn't included yet int require_cd = 0; diff --git a/src/movie/mvelib.cpp b/src/movie/mvelib.cpp index ff9f877..8273b074 100644 --- a/src/movie/mvelib.cpp +++ b/src/movie/mvelib.cpp @@ -56,7 +56,7 @@ int mve_get_int(ubyte *data) } // open an MVE file -MVEFILE *mvefile_open(char *filename) +MVEFILE *mvefile_open(const char *filename) { int cf_opened = 0; int mve_valid = 1; @@ -297,7 +297,7 @@ int mvefile_fetch_next_chunk(MVEFILE *file) // ----------------------------------------------------------- // open an MVE stream -MVESTREAM *mve_open(char *filename) +MVESTREAM *mve_open(const char *filename) { MVESTREAM *stream; diff --git a/src/network/multi_dogfight.cpp b/src/network/multi_dogfight.cpp index 5ba8a9c..8162e7a 100644 --- a/src/network/multi_dogfight.cpp +++ b/src/network/multi_dogfight.cpp @@ -102,11 +102,11 @@ ui_button_info Multi_df_buttons[GR_NUM_RESOLUTIONS][NUM_MULTI_DF_BUTTONS] = { }; int Multi_df_background_bitmap = -1; -char *Multi_df_background_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_df_background_fname[GR_NUM_RESOLUTIONS] = { "KillMatrix", "2_KillMatrix" }; -char *Multi_df_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_df_mask_fname[GR_NUM_RESOLUTIONS] = { "KillMatrix-m", "2_KillMatrix-m" }; diff --git a/src/network/multi_ingame.cpp b/src/network/multi_ingame.cpp index d230ed5..757f4c8 100644 --- a/src/network/multi_ingame.cpp +++ b/src/network/multi_ingame.cpp @@ -613,12 +613,12 @@ void multi_ingame_sync_close() // -------------------------------------------------------------------------------------------------- // INGAME SHIP SELECT SCREEN // -static char *Multi_ingame_join_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_ingame_join_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiIngame", // GR_640 "2_MultiIngame" // GR_1024 }; -static char *Multi_ingame_join_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_ingame_join_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiIngame-M", // GR_640 "2_MultiIngame-M" // GR_1024 }; @@ -1809,7 +1809,7 @@ void multi_ingame_validate_players() for ( i = 0; i < MAX_PLAYERS; i++ ) { if( MULTI_CONNECTED(Net_players[i]) && (Net_player != &Net_players[i]) && !MULTI_STANDALONE(Net_players[i]) ) { - char *ship_name; + const char *ship_name; int shipnum, objnum, player_objnum; player_objnum = Net_players[i].player->objnum; diff --git a/src/network/multi_log.cpp b/src/network/multi_log.cpp index dd91403..4bcf0cf 100644 --- a/src/network/multi_log.cpp +++ b/src/network/multi_log.cpp @@ -186,7 +186,7 @@ void multi_log_process() } // printf function itself called by the ml_printf macro -void ml_printf(char *format, ...) +void ml_printf(const char *format, ...) { char tmp[MAX_LOGFILE_LINE_LEN*4]; va_list args; @@ -206,7 +206,7 @@ void ml_printf(char *format, ...) } // string print function -void ml_string(char *string, int add_time) +void ml_string(const char *string, int add_time) { char tmp[MAX_LOGFILE_LINE_LEN*4]; char time_str[128]; diff --git a/src/network/multi_pinfo.cpp b/src/network/multi_pinfo.cpp index 42c25aa..87c4898 100644 --- a/src/network/multi_pinfo.cpp +++ b/src/network/multi_pinfo.cpp @@ -118,11 +118,11 @@ #define MULTI_PINFO_NUM_BUTTONS 4 // bitmaps defs -char *Multi_pinfo_bitmap_name[GR_NUM_RESOLUTIONS] = { +const char *Multi_pinfo_bitmap_name[GR_NUM_RESOLUTIONS] = { "PilotInfo", "2_PilotInfo" }; -char *Multi_pinfo_bitmap_mask[GR_NUM_RESOLUTIONS] = { +const char *Multi_pinfo_bitmap_mask[GR_NUM_RESOLUTIONS] = { "PilotInfo-M", "2_PilotInfo-M" }; diff --git a/src/network/multi_pmsg.cpp b/src/network/multi_pmsg.cpp index 5c32ac5..4bee51f 100644 --- a/src/network/multi_pmsg.cpp +++ b/src/network/multi_pmsg.cpp @@ -187,7 +187,7 @@ char Multi_msg_text[MULTI_MSG_MAX_TEXT_LEN+1]; #define MULTI_MSG_CMD_KICK 0 // kick command //XSTR:OFF -char *Multi_msg_commands[MULTI_MSG_CMD_COUNT] = { // commands themselves +const char *Multi_msg_commands[MULTI_MSG_CMD_COUNT] = { // commands themselves "kick" }; //XSTR:ON @@ -417,7 +417,7 @@ int multi_msg_message_text(char *txt) } // display ingame,inmission message text -void multi_msg_display_mission_text(char *msg,int player_index) +void multi_msg_display_mission_text(const char *msg, int player_index) { // play a cue voice sound snd_play(&Snds[MULTI_MSG_TEXT_SOUND]); @@ -430,7 +430,7 @@ void multi_msg_display_mission_text(char *msg,int player_index) } // if the passed net_player's callsign matches the reg expression of the passed expr -int multi_msg_matches_expr(net_player *player,char *expr) +int multi_msg_matches_expr(net_player *player, const char *expr) { char callsign[CALLSIGN_LEN+1]; int len,idx; @@ -558,7 +558,7 @@ void multi_msg_perform_command(int command,char *param) //XSTR:OFF -char *Multi_msg_subsys_name[SUBSYSTEM_MAX] = { +const char *Multi_msg_subsys_name[SUBSYSTEM_MAX] = { "None", "Engine", "Turret", diff --git a/src/network/multi_rate.cpp b/src/network/multi_rate.cpp index ca1a1c4..e00ef06 100644 --- a/src/network/multi_rate.cpp +++ b/src/network/multi_rate.cpp @@ -115,7 +115,7 @@ void multi_rate_reset(int np_index) } // add data of the specified type to datarate processing, returns 0 on fail (if we ran out of types, etc, etc) -int multi_rate_add(int np_index, char *type, int size) +int multi_rate_add(int np_index, const char *type, int size) { // release builds #ifndef MULTI_RATE diff --git a/src/network/multi_team.cpp b/src/network/multi_team.cpp index 713e838..2de5a7d 100644 --- a/src/network/multi_team.cpp +++ b/src/network/multi_team.cpp @@ -168,10 +168,10 @@ //XSTR:OFF -char *Multi_team0_names[4] = { // ships on team 0 (TEAM_FRIENDLY) +const char *Multi_team0_names[4] = { // ships on team 0 (TEAM_FRIENDLY) "alpha 1", "alpha 2", "alpha 3", "alpha 4" }; -char *Multi_team1_names[4] = { // ships on team 1 (TEAM_HOSTILE) +const char *Multi_team1_names[4] = { // ships on team 1 (TEAM_HOSTILE) "zeta 1", "zeta 2", "zeta 3", "zeta 4" }; diff --git a/src/network/multimsgs.cpp b/src/network/multimsgs.cpp index 8b8a9ca..97d3a99 100644 --- a/src/network/multimsgs.cpp +++ b/src/network/multimsgs.cpp @@ -947,7 +947,7 @@ void multi_io_send_buffered_packets() } // send a general game chat packet (if msg_mode == MULTI_MSG_TARGET, need to pass in "to", if == MULTI_MSG_EXPR, need to pass in expr) -void send_game_chat_packet(net_player *from, char *msg, int msg_mode, net_player *to, char *expr, int server_msg) +void send_game_chat_packet(net_player *from, const char *msg, int msg_mode, net_player *to, const char *expr, int server_msg) { ubyte data[MAX_PACKET_SIZE],mode; int packet_size,idx; @@ -3431,7 +3431,7 @@ void process_mission_log_packet( ubyte *data, header *hinfo ) } // send a mission message packet -void send_mission_message_packet( int id, char *who_from, int priority, int timing, int source, int builtin_type, int multi_target, int multi_team_filter) +void send_mission_message_packet( int id, const char *who_from, int priority, int timing, int source, int builtin_type, int multi_target, int multi_team_filter) { int packet_size; ubyte data[MAX_PACKET_SIZE], up, us, utime; @@ -4752,7 +4752,7 @@ void process_jump_into_mission_packet(ubyte *data, header *hinfo) //XSTR:OFF -char *repair_text[] = { +const char *repair_text[] = { "unknown", "REPAIR_INFO_BEGIN", "REPAIR_INFO_END", @@ -6705,7 +6705,7 @@ void process_asteroid_info( ubyte *data, header *hinfo ) PACKET_SET_SIZE(); } -void send_host_restr_packet(char *callsign,int code,int mode) +void send_host_restr_packet(const char *callsign, int code, int mode) { ubyte data[MAX_PACKET_SIZE],val; int packet_size = 0; diff --git a/src/network/multiteamselect.cpp b/src/network/multiteamselect.cpp index 0af54c1..0d9ad7d 100644 --- a/src/network/multiteamselect.cpp +++ b/src/network/multiteamselect.cpp @@ -222,12 +222,12 @@ extern int Next_screen; // bitmap defines #define MULTI_TS_PALETTE "InterfacePalette" -char *Multi_ts_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_ts_bitmap_fname[GR_NUM_RESOLUTIONS] = { "TeamSelect", // GR_640 "2_TeamSelect" // GR_1024 }; -char *Multi_ts_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_ts_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "TeamSelect-M", // GR_640 "2_TeamSelect-M" // GR_1024 }; @@ -283,7 +283,7 @@ ui_button_info Multi_ts_buttons[GR_NUM_RESOLUTIONS][MULTI_TS_NUM_BUTTONS] = { // players locked ani graphic #define MULTI_TS_NUM_LOCKED_BITMAPS 3 -char *Multi_ts_bmap_names[GR_NUM_RESOLUTIONS][3] = { +const char *Multi_ts_bmap_names[GR_NUM_RESOLUTIONS][3] = { { // GR_640 "TSB_340000", "TSB_340001", @@ -349,12 +349,12 @@ UI_WINDOW Multi_ts_window; #define MULTI_TS_NUM_SHIP_SLOTS_TEAM 4 // # of ship slots in team v team #define MULTI_TS_FLAG_NONE -2 // never has any ships #define MULTI_TS_FLAG_EMPTY -1 // currently empty -char *Multi_ts_slot_names[MULTI_TS_NUM_SHIP_SLOTS] = { // +const char *Multi_ts_slot_names[MULTI_TS_NUM_SHIP_SLOTS] = { // "alpha 1", "alpha 2", "alpha 3", "alpha 4", "beta 1", "beta 2", "beta 3", "beta 4", "gamma 1", "gamma 2", "gamma 3", "gamma 4" }; -char *Multi_ts_slot_team_names[MULTI_TS_MAX_TEAMS][MULTI_TS_NUM_SHIP_SLOTS_TEAM] = { +const char *Multi_ts_slot_team_names[MULTI_TS_MAX_TEAMS][MULTI_TS_NUM_SHIP_SLOTS_TEAM] = { {"alpha 1", "alpha 2", "alpha 3", "alpha 4"}, {"zeta 1", "zeta 2", "zeta 3", "zeta 4"} }; @@ -1904,7 +1904,7 @@ void multi_ts_get_team_and_slot(char *ship_name,int *team_index,int *slot_index) // function to return the shipname of the ship in the slot designated by the team and slot // parameters -char *multi_ts_get_shipname( int team, int slot_index ) +const char *multi_ts_get_shipname( int team, int slot_index ) { if ( Netgame.type_flags & NG_TYPE_TEAM ) { Assert( (team >= 0) && (team < MULTI_TS_MAX_TEAMS) ); diff --git a/src/network/multiui.cpp b/src/network/multiui.cpp index 7a0f2bf..14789eb 100644 --- a/src/network/multiui.cpp +++ b/src/network/multiui.cpp @@ -612,7 +612,7 @@ void multi_common_move_to_bottom() Multi_common_top_text_line = Multi_common_num_text_lines - Multi_common_text_max_display[gr_screen.res]; } -void multi_common_set_text(char *str,int auto_scroll) +void multi_common_set_text(const char *str, int auto_scroll) { // make sure it fits // store the entire string as well @@ -631,7 +631,7 @@ void multi_common_set_text(char *str,int auto_scroll) } } -void multi_common_add_text(char *str,int auto_scroll) +void multi_common_add_text(const char *str, int auto_scroll) { // make sure it fits // store the entire string as well @@ -723,7 +723,7 @@ void multi_common_notify_init() } // add a notification string, drawing appropriately depending on the state/screen we're in -void multi_common_add_notify(char *str) +void multi_common_add_notify(const char *str) { if(str){ strcpy(Multi_common_notify_text,str); @@ -768,7 +768,7 @@ void multi_common_notify_do() // common icon stuff int Multi_common_icons[MULTI_NUM_COMMON_ICONS]; //XSTR:OFF -char *Multi_common_icon_names[MULTI_NUM_COMMON_ICONS] = { +const char *Multi_common_icon_names[MULTI_NUM_COMMON_ICONS] = { "DotRed", // voice denied "DotGreen", // voice recording "OvalGreen", // team 0 @@ -940,12 +940,12 @@ void multi_common_verify_cd() // bitmaps defs #define MULTI_JOIN_PALETTE "InterfacePalette" -static char *Multi_join_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_join_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiJoin", // GR_640 "2_MultiJoin" // GR_1024 }; -static char *Multi_join_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_join_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiJoin-M", // GR_640 "2_MultiJoin-M" // GR_1024 }; @@ -953,7 +953,7 @@ static char *Multi_join_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { // slider #ifndef MAKE_FS1 -char *Mj_slider_name[GR_NUM_RESOLUTIONS] = { +const char *Mj_slider_name[GR_NUM_RESOLUTIONS] = { "slider", "2_slider" }; @@ -1148,7 +1148,7 @@ int Mj_ping_coords[GR_NUM_RESOLUTIONS][4] = { // game speed labels #define MJ_NUM_SPEED_LABELS 5 -char *Multi_join_speed_labels[MJ_NUM_SPEED_LABELS] = { +const char *Multi_join_speed_labels[MJ_NUM_SPEED_LABELS] = { "< 56k", "56k", "isdn", @@ -2606,12 +2606,12 @@ void multi_join_blit_protocol() // bitmap defs #define MULTI_SG_PALETTE "InterfacePalette" -static char *Multi_sg_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_sg_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiStartGame", // GR_640 "2_MultiStartGame" // GR_1024 }; -static char *Multi_sg_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_sg_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiStartGame-M", // GR_640 "2_MultiStartGame-M" // GR_1024 }; @@ -3594,17 +3594,17 @@ void multi_sg_select_rank_default() //XSTR:OFF // bitmaps defs -char *Multi_create_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_create_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiCreate", // GR_640 "2_MultiCreate" // GR_1024 }; -char *Multi_create_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_create_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiCreate-M", // GR_640 "2_MultiCreate-M" // GR_1024 }; -char *Multi_create_loading_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_create_loading_fname[GR_NUM_RESOLUTIONS] = { "PleaseWait", // GR_640 "2_PleaseWait" // GR_1024 }; @@ -3780,7 +3780,7 @@ UI_XSTR Multi_create_text[GR_NUM_RESOLUTIONS][MULTI_CREATE_NUM_BUTTONS] = { // squad war checkbox UI_CHECKBOX Multi_create_sw_checkbox; -char *Multi_create_sw_checkbox_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_create_sw_checkbox_fname[GR_NUM_RESOLUTIONS] = { "MC_SW_00", "MC_SW_00", }; @@ -3933,7 +3933,7 @@ int Mc_slider_coords[GR_NUM_RESOLUTIONS][4] = { } }; -char *Mc_slider_bitmap[GR_NUM_RESOLUTIONS] = { +const char *Mc_slider_bitmap[GR_NUM_RESOLUTIONS] = { "slider", "2_slider" }; @@ -4233,7 +4233,7 @@ void multi_create_game_do() { int player_index; #ifndef MAKE_FS1 - char *loading_str = XSTR("Loading", 1336); + const char *loading_str = XSTR("Loading", 1336); int str_w, str_h; #endif @@ -5963,12 +5963,12 @@ void multi_create_sw_clicked() // bitmaps defs #define MULTI_HO_PALETTE "InterfacePalette" -static char *Multi_ho_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_ho_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiHost", // GR_640 "2_MultiHost" // GR_1024 }; -static char *Multi_ho_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_ho_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiHost-M", // GR_640 "2_MultiHost-M" // GR_1024 }; @@ -6141,14 +6141,14 @@ int Multi_ho_radio_info[MULTI_HO_NUM_RADIO_BUTTONS][3] = { // info related to ea #define MULTI_HO_SLIDER_VOICE_DUR 1 // max duration of voice recording #define MULTI_HO_SLIDER_SKILL 2 // skill level struct ho_sliders { - char *filename; + const char *filename; int x, y, xt, yt; int hotspot; int dot_w; int dots; UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below.. - ho_sliders(char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), dot_w(_dot_w), dots(_dots){} + ho_sliders(const char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), dot_w(_dot_w), dots(_dots){} }; ho_sliders Multi_ho_sliders[GR_NUM_RESOLUTIONS][MULTI_HO_NUM_SLIDERS] = { { // GR_640 @@ -7049,12 +7049,12 @@ void multi_ho_display_skill_level() // bitmaps defs #define MULTI_JW_PALETTE "InterfacePalette" -static char *Multi_jw_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_jw_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiJoinWait", // GR_640 "2_MultiJoinWait" // GR_1024 }; -static char *Multi_jw_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_jw_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiJoinWait-M", // GR_640 "2_MultiJoinWait-M" // GR_1024 }; @@ -7163,7 +7163,7 @@ int Mjw_mission_name_coords[GR_NUM_RESOLUTIONS][2] = { // squad war checkbox UI_CHECKBOX Multi_jw_sw_checkbox; -char *Multi_jw_sw_checkbox_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_jw_sw_checkbox_fname[GR_NUM_RESOLUTIONS] = { "MC_SW_00", "MC_SW_00", }; @@ -7790,12 +7790,12 @@ short multi_jw_get_mouse_id() #define MULTI_SYNC_HOST_COUNT 4 // host uses 4 buttons (and sometimes 5) #define MULTI_SYNC_CLIENT_COUNT 3 // client only uses 3 buttons -char *Multi_sync_bitmap_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_sync_bitmap_fname[GR_NUM_RESOLUTIONS] = { "MultiSynch", // GR_640 "2_MultiSynch" // GR_1024 }; -char *Multi_sync_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +const char *Multi_sync_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "MultiSynch-M", // GR_640 "2_MultiSynch-M" // GR_1024 }; @@ -7918,7 +7918,7 @@ int Multi_launch_button_created; //XSTR:OFF // countdown animation timer -char* Multi_sync_countdown_fname[GR_NUM_RESOLUTIONS] = { +const char* Multi_sync_countdown_fname[GR_NUM_RESOLUTIONS] = { "Count", // GR_640 "2_Count" // GR_1024 }; @@ -7962,8 +7962,8 @@ void multi_sync_check_buttons(); void multi_sync_button_pressed(int n); void multi_sync_scroll_info_up(); void multi_sync_scroll_info_down(); -void multi_sync_display_name(char *name,int index,int np_index); // display info on the left hand portion of the status window thingie -void multi_sync_display_status(char *status,int index); // display info on the right hand portion of the status window thingie +void multi_sync_display_name(const char *name, int index, int np_index); // display info on the left hand portion of the status window thingie +void multi_sync_display_status(const char *status, int index); // display info on the right hand portion of the status window thingie void multi_sync_force_start_pre(); void multi_sync_force_start_post(); void multi_sync_launch(); @@ -8074,7 +8074,7 @@ void multi_sync_close() } } -char *multi_sync_tooltip_handler(char *str) +const char *multi_sync_tooltip_handler(const char *str) { if (!stricmp(str, NOX("@launch"))) { if (Multi_launch_button_created){ @@ -8930,7 +8930,7 @@ void multi_sync_post_close() */ } -void multi_sync_display_name(char *name,int index,int np_index) +void multi_sync_display_name(const char *name, int index, int np_index) { char fit[CALLSIGN_LEN]; @@ -9007,7 +9007,7 @@ void multi_sync_display_name(char *name,int index,int np_index) } } -void multi_sync_display_status(char *status,int index) +void multi_sync_display_status(const char *status, int index) { char fit[250]; @@ -9601,12 +9601,12 @@ void multi_debrief_server_process() //XSTR:OFF // bitmaps defs -static char *Multi_pwd_bitmap_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_pwd_bitmap_fname[GR_NUM_RESOLUTIONS] = { "Password", // GR_640 "2_Password" // GR_1024 }; -static char *Multi_pwd_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { +static const char *Multi_pwd_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = { "Password-M", // GR_640 "2_Password-M" // GR_1024 }; diff --git a/src/network/multiutil.cpp b/src/network/multiutil.cpp index 9535460..a4f80c1 100644 --- a/src/network/multiutil.cpp +++ b/src/network/multiutil.cpp @@ -461,7 +461,7 @@ object *multi_get_network_object( ushort net_signature ) #define NUM_DEATH_WORDS 40 -char *multi_random_death_word() +const char *multi_random_death_word() { int index; @@ -560,7 +560,7 @@ char *multi_random_death_word() #define NUM_CHAT_START_WORDS 8 #define MAX_CHAT_PHRASE_LEN 25 // be careful not to exceed (or update if exceeded) -char *multi_random_chat_start() +const char *multi_random_chat_start() { int index; @@ -593,7 +593,7 @@ char *multi_random_chat_start() // // -int multi_ship_class_lookup(char* ship_name) +int multi_ship_class_lookup(const char* ship_name) { int i, player_ship_class; @@ -748,7 +748,7 @@ int multi_find_player_by_net_signature(ushort net_signature) return -1; } -int multi_find_player_by_ship_name(char *ship_name) +int multi_find_player_by_ship_name(const char *ship_name) { int idx; @@ -1484,7 +1484,7 @@ void multi_subsys_update_all() */ } -int multi_find_player_by_callsign(char *callsign) +int multi_find_player_by_callsign(const char *callsign) { int idx; for(idx=0;idx #include -char *Osreg_company_name = "Volition"; +const char *Osreg_company_name = "Volition"; #if defined(MAKE_FS1) -char *Osreg_class_name = "FreespaceClass"; +const char *Osreg_class_name = "FreespaceClass"; #else -char *Osreg_class_name = "Freespace2Class"; +const char *Osreg_class_name = "Freespace2Class"; #endif #if defined(FS1_DEMO) -char *Osreg_app_name = "FreeSpaceDemo"; -char *Osreg_title = "Freespace Demo"; +const char *Osreg_app_name = "FreeSpaceDemo"; +const char *Osreg_title = "Freespace Demo"; #ifndef __APPLE__ -char *Osreg_user_dir = ".freespace_demo"; +const char *Osreg_user_dir = ".freespace_demo"; #else -char *Osreg_user_dir = "Library/Application Support/FreeSpace Demo"; +const char *Osreg_user_dir = "Library/Application Support/FreeSpace Demo"; #endif #define PROFILE_NAME "FreeSpaceDemo.ini" #elif defined(FS2_DEMO) -char *Osreg_app_name = "FreeSpace2Demo"; -char *Osreg_title = "Freespace 2 Demo"; +const char *Osreg_app_name = "FreeSpace2Demo"; +const char *Osreg_title = "Freespace 2 Demo"; #ifndef __APPLE__ -char *Osreg_user_dir = ".freespace2_demo"; +const char *Osreg_user_dir = ".freespace2_demo"; #else -char *Osreg_user_dir = "Library/Application Support/Freespace 2 Demo"; +const char *Osreg_user_dir = "Library/Application Support/Freespace 2 Demo"; #endif #define PROFILE_NAME "FreeSpace2Demo.ini" #elif defined(OEM_BUILD) -char *Osreg_app_name = "FreeSpace2OEM"; -char *Osreg_title = "Freespace 2 OEM"; +const char *Osreg_app_name = "FreeSpace2OEM"; +const char *Osreg_title = "Freespace 2 OEM"; #define PROFILE_NAME "FreeSpace2OEM.ini" #elif defined(MAKE_FS1) -char *Osreg_app_name = "FreeSpace"; -char *Osreg_title = "FreeSpace"; +const char *Osreg_app_name = "FreeSpace"; +const char *Osreg_title = "FreeSpace"; #ifndef __APPLE__ -char *Osreg_user_dir = ".freespace"; +const char *Osreg_user_dir = ".freespace"; #else -char *Osreg_user_dir = "Library/Application Support/FreeSpace"; +const char *Osreg_user_dir = "Library/Application Support/FreeSpace"; #endif #define PROFILE_NAME "FreeSpace.ini" #else -char *Osreg_app_name = "FreeSpace2"; -char *Osreg_title = "Freespace 2"; +const char *Osreg_app_name = "FreeSpace2"; +const char *Osreg_title = "Freespace 2"; #ifndef __APPLE__ -char *Osreg_user_dir = ".freespace2"; +const char *Osreg_user_dir = ".freespace2"; #else -char *Osreg_user_dir = "Library/Application Support/Freespace 2"; +const char *Osreg_user_dir = "Library/Application Support/Freespace 2"; #endif #define PROFILE_NAME "FreeSpace2.ini" #endif @@ -164,7 +164,7 @@ static char *trim_string(char *str) return ptr; } -static Profile *profile_read(char *file) +static Profile *profile_read(const char *file) { CFILE *fp = cfopen(file, "rt", CFILE_NORMAL, CF_TYPE_ROOT); if (fp == NULL) @@ -270,7 +270,7 @@ static void profile_free(Profile *profile) free(profile); } -static Profile *profile_update(Profile *profile, char *section, char *key, char *value) +static Profile *profile_update(Profile *profile, const char *section, const char *key, const char *value) { if (profile == NULL) { profile = (Profile *)malloc(sizeof(Profile)); @@ -343,7 +343,7 @@ static Profile *profile_update(Profile *profile, char *section, char *key, char return profile; } -static char *profile_get_value(Profile *profile, char *section, char *key) +static const char *profile_get_value(Profile *profile, const char *section, const char *key) { if (profile == NULL) return NULL; @@ -368,7 +368,7 @@ static char *profile_get_value(Profile *profile, char *section, char *key) return NULL; } -static void profile_save(Profile *profile, char *file) +static void profile_save(Profile *profile, const char *file) { CFILE *fp; @@ -404,14 +404,14 @@ static void profile_save(Profile *profile, char *file) static char tmp_string_data[1024]; -char *os_config_read_string(char *section, char *name, char *default_value) +const char *os_config_read_string(const char *section, const char *name, const char *default_value) { Profile *p = profile_read(PROFILE_NAME); if (section == NULL) section = DEFAULT_SECTION; - char *ptr = profile_get_value(p, section, name); + const char *ptr = profile_get_value(p, section, name); if (ptr != NULL) { strncpy(tmp_string_data, ptr, 1023); default_value = tmp_string_data; @@ -422,14 +422,14 @@ char *os_config_read_string(char *section, char *name, char *default_value) return default_value; } -unsigned int os_config_read_uint(char *section, char *name, unsigned int default_value) +unsigned int os_config_read_uint(const char *section, const char *name, unsigned int default_value) { Profile *p = profile_read(PROFILE_NAME); if (section == NULL) section = DEFAULT_SECTION; - char *ptr = profile_get_value(p, section, name); + const char *ptr = profile_get_value(p, section, name); if (ptr != NULL) { default_value = atoi(ptr); } @@ -439,7 +439,7 @@ unsigned int os_config_read_uint(char *section, char *name, unsigned int default return default_value; } -void os_config_write_string(char *section, char *name, char *value) +void os_config_write_string(const char *section, const char *name, const char *value) { Profile *p = profile_read(PROFILE_NAME); @@ -451,7 +451,7 @@ void os_config_write_string(char *section, char *name, char *value) profile_free(p); } -void os_config_write_uint(char *section, char *name, unsigned int value) +void os_config_write_uint(const char *section, const char *name, unsigned int value) { static char buf[21]; diff --git a/src/osapi/outwnd_unix.cpp b/src/osapi/outwnd_unix.cpp index c7b0136..a3f9315 100644 --- a/src/osapi/outwnd_unix.cpp +++ b/src/osapi/outwnd_unix.cpp @@ -174,7 +174,7 @@ extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES]; -void outwnd_print(char *id, char *tmp); +void outwnd_print(const char *id, const char *tmp); #define MAX_FILTERS 48 #define MAX_LINE_WIDTH 128 @@ -197,7 +197,7 @@ int outwnd_filter_loaded = 0; #ifndef NDEBUG int Log_debug_output_to_file = 1; FILE *Log_fp; - char *Freespace_logfilename = "fs_debug.log"; + const char *Freespace_logfilename = "fs_debug.log"; #endif void load_filter_info(void) @@ -299,7 +299,7 @@ void save_filter_info(void) } } -void outwnd_printf2(char *format, ...) +void outwnd_printf2(const char *format, ...) { char tmp[MAX_LINE_WIDTH*4]; va_list args; @@ -310,7 +310,7 @@ void outwnd_printf2(char *format, ...) outwnd_print("General", tmp); } -void outwnd_printf(char *id, char *format, ...) +void outwnd_printf(const char *id, const char *format, ...) { char tmp[MAX_LINE_WIDTH*4]; va_list args; @@ -321,7 +321,7 @@ void outwnd_printf(char *id, char *format, ...) outwnd_print(id, tmp); } -void outwnd_print(char *id, char *tmp) +void outwnd_print(const char *id, const char *tmp) { int i; outwnd_filter_struct *temp; diff --git a/src/palman/palman.cpp b/src/palman/palman.cpp index 510e7e9..372cfe2 100644 --- a/src/palman/palman.cpp +++ b/src/palman/palman.cpp @@ -345,7 +345,7 @@ void palette_cache_add( int r, int g, int b, int index ) char palette_base_filename[128] = { "default" }; int palette_base_loaded = 0; -void palette_load_table( char * filename ) +void palette_load_table( const char * filename ) { int i; int w, h; @@ -494,7 +494,7 @@ uint palette_find( int r, int g, int b ) #define PAL_VERSION 20 #define PAL_LAST_COMPATIBLE_VERSION 20 -void palette_write_cached1( char *name ) +void palette_write_cached1( const char *name ) { CFILE *fp; char new_name[128]; @@ -536,7 +536,7 @@ void palette_write_cached1( char *name ) // Returns TRUE if successful, else 0 -int palette_read_cached( char *name ) +int palette_read_cached( const char *name ) { CFILE *fp; char new_name[128]; @@ -713,7 +713,7 @@ void palette_flush() // When gr_set_palette is called, it fills in gr_palette and then calls this // function, which should update all the tables. // Pass NULL to flush current palette. -void palette_update(char *name_with_extension, int restrict_font_to_128) +void palette_update(const char *name_with_extension, int restrict_font_to_128) { // int i; uint tmp_checksum; diff --git a/src/parse/parselo.cpp b/src/parse/parselo.cpp index bc76770..8fd0a49 100644 --- a/src/parse/parselo.cpp +++ b/src/parse/parselo.cpp @@ -139,7 +139,7 @@ jmp_buf parse_abort; char Mission_text[MISSION_TEXT_SIZE]; char Mission_text_raw[MISSION_TEXT_SIZE]; char *Mp; -char *token_found; +const char *token_found; // Return true if this character is white space, else false. int is_white_space(char ch) @@ -233,7 +233,7 @@ void skip_token() // Display a diagnostic message if Verbose is set. // (Verbose is set if -v command line switch is present.) -void diag_printf(char *format, ...) +void diag_printf(const char *format, ...) { char buffer[8192]; va_list args; @@ -314,7 +314,7 @@ int get_line_num() // error_level == 0 means this is just a warning. // !0 means it's an error message. // Prints line number and other useful information. -void error_display(int error_level, char *format, ...) +void error_display(int error_level, const char *format, ...) { char buffer[1024]; char error_text[128]; @@ -340,7 +340,7 @@ void error_display(int error_level, char *format, ...) } // Advance Mp to the next eoln character. -void advance_to_eoln(char *more_terminators) +void advance_to_eoln(const char *more_terminators) { char terminators[128]; @@ -375,7 +375,7 @@ void advance_to_next_white() // Search for specified string, skipping everything up to that point. Returns 1 if found, // 0 if string wasn't found (and hit end of file), or -1 if not found, but end of checking // block was reached. -int skip_to_string(char *pstr, char *end) +int skip_to_string(const char *pstr, const char *end) { int len, len2 = 0; @@ -403,7 +403,7 @@ int skip_to_string(char *pstr, char *end) } // Advance to start of either pstr1 or pstr2. Return 0 is successful, otherwise return !0 -int skip_to_start_of_strings(char *pstr1, char *pstr2) +int skip_to_start_of_strings(const char *pstr1, const char *pstr2) { int len1, len2; @@ -428,7 +428,7 @@ int skip_to_start_of_strings(char *pstr1, char *pstr2) // lines. // If unable to find the required string after RS_MAX_TRIES tries, then // abort using longjmp to parse_abort. -int required_string(char *pstr) +int required_string(const char *pstr) { int count = 0; @@ -455,7 +455,7 @@ int required_string(char *pstr) // similar to optional_string, but just checks if next token is a match. // It doesn't advance Mp. // -int check_for_string(char *pstr) +int check_for_string(const char *pstr) { ignore_white_space(); @@ -466,7 +466,7 @@ int check_for_string(char *pstr) } // like check for string, but doesn't skip past any whitespace -int check_for_string_raw(char *pstr) +int check_for_string_raw(const char *pstr) { if (!strnicmp(pstr, Mp, strlen(pstr))){ return 1; @@ -478,7 +478,7 @@ int check_for_string_raw(char *pstr) // Find an optional string. // If found, return 1, else return 0. // If found, point past string, else don't update pointer. -int optional_string(char *pstr) +int optional_string(const char *pstr) { ignore_white_space(); @@ -490,7 +490,7 @@ int optional_string(char *pstr) return 0; } -int required_string_fred(char *pstr, char *end) +int required_string_fred(const char *pstr, const char *end) { char *backup = Mp;; @@ -527,7 +527,7 @@ int required_string_fred(char *pstr, char *end) // further complicate things, we should only search to a certain point, since we don't want // a token that belongs to another section which might match the token we want. Thus, we // also pass in an ending token, which marks the point we should stop looking at. -int optional_string_fred(char *pstr, char *end, char *end2) +int optional_string_fred(const char *pstr, const char *end, const char *end2) { char *mp_save = Mp; @@ -563,7 +563,7 @@ int optional_string_fred(char *pstr, char *end, char *end2) // Return 0 or 1 for str1 match, str2 match. Return -1 if neither matches. // Does not update Mp if token found. If not found, advances, trying to // find the string. Doesn't advance past the found string. -int required_string_either(char *str1, char *str2) +int required_string_either(const char *str1, const char *str2) { int count = 0; @@ -600,7 +600,7 @@ int required_string_either(char *str1, char *str2) // Return 0 or 1 for str1 match, str2 match. Return -1 if neither matches. // Does not update Mp if token found. If not found, advances, trying to // find the string. Doesn't advance past the found string. -int required_string_3(char *str1, char *str2, char *str3) +int required_string_3(const char *str1, const char *str2, const char *str3) { int count = 0; @@ -631,7 +631,7 @@ int required_string_3(char *str1, char *str2, char *str3) // exit (1); } -int required_string_either_fred(char *str1, char *str2) +int required_string_either_fred(const char *str1, const char *str2) { ignore_white_space(); @@ -660,7 +660,7 @@ int required_string_either_fred(char *str1, char *str2) // Copy characters from instr to outstr until eoln is found, or until max // characters have been copied (including terminator). -void copy_to_eoln(char *outstr, char *more_terminators, char *instr, int max) +void copy_to_eoln(char *outstr, const char *more_terminators, const char *instr, int max) { int count = 0; char ch; @@ -688,7 +688,7 @@ void copy_to_eoln(char *outstr, char *more_terminators, char *instr, int max) // Copy characters from instr to outstr until next white space is found, or until max // characters have been copied (including terminator). -void copy_to_next_white(char *outstr, char *instr, int max) +void copy_to_next_white(char *outstr, const char *instr, int max) { int count = 0; int in_quotes = 0; @@ -714,9 +714,9 @@ void copy_to_next_white(char *outstr, char *instr, int max) // Copy text until a certain string is matched. // For example, this is used to copy mission notes, scanning until $END NOTES: // is found. -void copy_text_until(char *outstr, char *instr, char *endstr, int max_chars) +void copy_text_until(char *outstr, const char *instr, const char *endstr, int max_chars) { - char *foundstr; + const char *foundstr; foundstr = strstr(instr, endstr); @@ -751,7 +751,7 @@ void stuff_string_white(char *pstr) // Stuff a string into a string buffer. // Supports various FreeSpace primitive types. If 'len' is supplied, it will override // the default string length if using the F_NAME case. -void stuff_string(char *pstr, int type, char *terminators, int len) +void stuff_string(char *pstr, int type, const char *terminators, int len) { char read_str[2048] = ""; int read_len = 2048; @@ -878,7 +878,7 @@ void stuff_string_line(char *pstr, int len) // Exactly the same as stuff string only Malloc's the buffer. // Supports various FreeSpace primitive types. If 'len' is supplied, it will override // the default string length if using the F_NAME case. -char *stuff_and_malloc_string( int type, char *terminators, int len) +char *stuff_and_malloc_string( int type, const char *terminators, int len) { int l; @@ -1113,7 +1113,7 @@ void strip_all_comments( char *readp, char *writep ) } #endif -int parse_get_line(char *lineout, int max_line_len, char *start, int max_size, char *cur) +int parse_get_line(char *lineout, int max_line_len, const char *start, int max_size, const char *cur) { char * t = lineout; int i, num_chars_read=0; @@ -1145,7 +1145,7 @@ int parse_get_line(char *lineout, int max_line_len, char *start, int max_size, c // Read mission text, stripping comments. // When a comment is found, it is removed. If an entire line // consisted of a comment, a blank line is left in the input file. -void read_file_text(char *filename, int mode) +void read_file_text(const char *filename, int mode) { CFILE *mf; char outbuf[BUF_SIZE], *str; @@ -1633,7 +1633,7 @@ void stuff_matrix(matrix *mp) // *str1 is the string to be found. // *strlist is the list of strings to search. // max is the number of entries in *strlist to scan. -int string_lookup(char *str1, char *strlist[], int max, char *description, int say_errors) +int string_lookup(const char *str1, const char *strlist[], int max, const char *description, int say_errors) { int i; @@ -1653,7 +1653,7 @@ int string_lookup(char *str1, char *strlist[], int max, char *description, int s // Find a required string (*id), then stuff the text of type f_type that // follows it at *addr. *strlist[] contains the strings it should try to // match. -void find_and_stuff(char *id, int *addr, int f_type, char *strlist[], int max, char *description) +void find_and_stuff(const char *id, int *addr, int f_type, const char *strlist[], int max, const char *description) { char token[128]; @@ -1665,7 +1665,7 @@ void find_and_stuff(char *id, int *addr, int f_type, char *strlist[], int max, c // Mp points at a string. // Find the string in the list of strings *strlist[]. // Returns the index of the match, -1 if none. -int match_and_stuff(int f_type, char *strlist[], int max, char *description) +int match_and_stuff(int f_type, const char *strlist[], int max, const char *description) { char token[128]; @@ -1673,8 +1673,8 @@ int match_and_stuff(int f_type, char *strlist[], int max, char *description) return string_lookup(token, strlist, max, description, 0); } -void find_and_stuff_or_add(char *id, int *addr, int f_type, char *strlist[], int *total, - int max, char *description) +void find_and_stuff_or_add(const char *id, int *addr, int f_type, char *strlist[], int *total, + int max, const char *description) { char token[128]; @@ -1682,7 +1682,7 @@ void find_and_stuff_or_add(char *id, int *addr, int f_type, char *strlist[], int required_string(id); stuff_string(token, f_type, NULL); if (*total) - *addr = string_lookup(token, strlist, *total, description, 0); + *addr = string_lookup(token, (const char **)strlist, *total, description, 0); if (*addr == -1) // not in list, so lets try and add it. { @@ -1801,7 +1801,7 @@ char *split_str_once(char *src, int max_pixel_w) // returns: number of lines src is broken into // -1 is returned when an error occurs // -int split_str(char *src, int max_pixel_w, int *n_chars, char **p_str, int max_lines, char ignore_char) +int split_str(const char *src, int max_pixel_w, int *n_chars, char **p_str, int max_lines, char ignore_char) { char buffer[SPLIT_STR_BUFFER_SIZE]; char *breakpoint = NULL; @@ -1838,7 +1838,7 @@ int split_str(char *src, int max_pixel_w, int *n_chars, char **p_str, int max_li if (is_gray_space(*src)) continue; - p_str[line_num] = src; + p_str[line_num] = (char*)src; breakpoint = NULL; new_line = 0; } @@ -1870,7 +1870,7 @@ int split_str(char *src, int max_pixel_w, int *n_chars, char **p_str, int max_li if (is_gray_space(*src)) { if (!last_was_white) // track at first whitespace in a series of whitespace - breakpoint = src; + breakpoint = (char*)src; last_was_white = 1; @@ -1889,10 +1889,10 @@ int split_str(char *src, int max_pixel_w, int *n_chars, char **p_str, int max_li char *end; if (breakpoint) { - end = src = breakpoint; - + end = breakpoint; + src = breakpoint; } else { - end = src; // force a split here since to whitespace + end = (char*)src; // force a split here since to whitespace src--; // reuse this character in next line } diff --git a/src/parse/sexp.cpp b/src/parse/sexp.cpp index db9cc5e..a78885a 100644 --- a/src/parse/sexp.cpp +++ b/src/parse/sexp.cpp @@ -587,7 +587,7 @@ sexp_ai_goal_link Sexp_ai_goal_links[] = { { AI_GOAL_PLAY_DEAD, OP_AI_PLAY_DEAD }, }; -char *HUD_gauge_text[NUM_HUD_GAUGES] = +const char *HUD_gauge_text[NUM_HUD_GAUGES] = { "LEAD_INDICATOR", "ORIENTATION_TEE", @@ -689,7 +689,7 @@ void init_sexp() } // allocates an sexp node. -int alloc_sexp(char *text, int type, int subtype, int first, int rest) +int alloc_sexp(const char *text, int type, int subtype, int first, int rest) { int i; @@ -1044,7 +1044,7 @@ int is_sexp_top_level( int node ) return 1; } -int identify_operator(char *token) +int identify_operator(const char *token) { int i; @@ -1057,7 +1057,7 @@ int identify_operator(char *token) return -1; } -int find_operator(char *token) +int find_operator(const char *token) { int i; @@ -9231,7 +9231,7 @@ int sexp_query_type_match(int opf, int opr) return 0; } -char *sexp_error_message(int num) +const char *sexp_error_message(int num) { switch (num) { case SEXP_CHECK_NONOP_ARGS: diff --git a/src/platform/unix.cpp b/src/platform/unix.cpp index 866241b..e0a4f7e 100644 --- a/src/platform/unix.cpp +++ b/src/platform/unix.cpp @@ -168,7 +168,7 @@ static RAM *RamTable; #endif #ifndef NDEBUG -void vm_free(void* ptr, char *file, int line) +void vm_free(void* ptr, const char *file, int line) #else void vm_free(void* ptr) #endif @@ -203,7 +203,7 @@ void vm_free(void* ptr) } #ifndef NDEBUG -void *vm_malloc(int size, char *file, int line) +void *vm_malloc(int size, const char *file, int line) #else void *vm_malloc(int size) #endif @@ -228,7 +228,7 @@ void *vm_malloc(int size) } #ifndef NDEBUG -char *vm_strdup(char const* str, char *file, int line) +char *vm_strdup(char const* str, const char *file, int line) #else char *vm_strdup(char const* str) #endif @@ -312,7 +312,7 @@ void outwnd_close() // STUB_FUNCTION; } */ -void Warning( char * filename, int line, char * format, ... ) +void Warning( const char * filename, int line, const char * format, ... ) { char tmp[MAX_LINE_WIDTH*4]; va_list args; @@ -323,7 +323,7 @@ void Warning( char * filename, int line, char * format, ... ) fprintf (stderr, "Warning: (%s:%d): %s\n", filename, line, tmp); } -void Error( char * filename, int line, char * format, ... ) +void Error( const char * filename, int line, const char * format, ... ) { char tmp[MAX_LINE_WIDTH*4]; va_list args; @@ -335,7 +335,7 @@ void Error( char * filename, int line, char * format, ... ) exit (1); } -void WinAssert(char * text,char *filename, int line) +void WinAssert(const char * text, const char *filename, int line) { fprintf (stderr, "Assertion: (%s:%d) %s\n", filename, line, text); // exit(1); diff --git a/src/playerman/managepilot.cpp b/src/playerman/managepilot.cpp index 06d33e0..8e99370 100644 --- a/src/playerman/managepilot.cpp +++ b/src/playerman/managepilot.cpp @@ -296,7 +296,7 @@ void write_multiplayer_options(player *p,CFILE *file); // internal function to delete a player file. Called after a pilot is obsoleted, and when a pilot is deleted // used in barracks and player_select -void delete_pilot_file( char *pilot_name, int single ) +void delete_pilot_file( const char *pilot_name, int single ) { char filename[MAX_FILENAME_LEN]; char basename[MAX_FILENAME_LEN]; @@ -319,7 +319,7 @@ void delete_pilot_file( char *pilot_name, int single ) // check if a pilot file is valid or not (i.e. is usable, not out of date, etc) // used in barracks and player_select -int verify_pilot_file(char *filename, int single, int *rank) +int verify_pilot_file(const char *filename, int single, int *rank) { CFILE *file; uint id, file_version; @@ -542,7 +542,7 @@ void pilot_read_loadout(CFILE *file) // >0 - errno from fopen error // if single == 1, look for players in the single players directory, otherwise look in the // multiplayers directory -int read_pilot_file(char *callsign, int single, player *p) +int read_pilot_file(const char *callsign, int single, player *p) { ubyte num_ctrls; ubyte is_multi = 0; @@ -1375,7 +1375,7 @@ void pilot_set_random_squad_pic(player *p) } // format a pilot's callsign into a "personal" form - ie, adding a 's or just an ' as appropriate -void pilot_format_callsign_personal(char *in_callsign,char *out_callsign) +void pilot_format_callsign_personal(const char *in_callsign, char *out_callsign) { // don't do anything if we've got invalid strings if((in_callsign == NULL) || (out_callsign == NULL)){ @@ -1428,7 +1428,7 @@ void pilot_load_squad_pic_list() } // will attempt to load an insignia bitmap and set it as active for the player -void player_set_squad_bitmap(player *p, char *fname) +void player_set_squad_bitmap(player *p, const char *fname) { // sanity check if(p == NULL){ @@ -1467,7 +1467,7 @@ void player_set_squad_bitmap(player *p, char *fname) } // set squadron -void player_set_squad(player *p, char *squad_name) +void player_set_squad(player *p, const char *squad_name) { // sanity check if(p == NULL){ diff --git a/src/playerman/playercontrol.cpp b/src/playerman/playercontrol.cpp index 70032c6..e205b32 100644 --- a/src/playerman/playercontrol.cpp +++ b/src/playerman/playercontrol.cpp @@ -1761,7 +1761,7 @@ int player_inspect_cap_subsys_cargo(float frametime, char *outstr) // if cargo is already revealed if ( subsys->subsys_cargo_revealed ) { - char *cargo_name; + const char *cargo_name; if (subsys->subsys_cargo_name == -1) { cargo_name = XSTR("Nothing", 1493); } else { diff --git a/src/popup/popup.cpp b/src/popup/popup.cpp index 5b7f88a..e54d6ad 100644 --- a/src/popup/popup.cpp +++ b/src/popup/popup.cpp @@ -222,7 +222,7 @@ int Popup_max_display[GR_NUM_RESOLUTIONS] = { }; #ifndef MAKE_FS1 // to avoid trying to find the interface tool -char *Popup_slider_name[GR_NUM_RESOLUTIONS] = { +const char *Popup_slider_name[GR_NUM_RESOLUTIONS] = { "slider", "2_slider" }; @@ -300,7 +300,7 @@ int Popup_input_text_y_offset[GR_NUM_RESOLUTIONS] = { typedef struct popup_background { - char *filename; // filename for background + const char *filename; // filename for background int coords[2]; // coords to draw background at } popup_background; @@ -382,19 +382,19 @@ static popup_background Popup_background[GR_NUM_RESOLUTIONS][4] = { { // GR_640 #ifdef MAKE_FS1 - {"Pop2a", 131, 122}, - {"Pop2a", 131, 122}, - {"Pop3", 131, 122}, + { "Pop2a", { 131, 122} }, + { "Pop2a", { 131, 122 } }, + { "Pop3", { 131, 122 } }, #else - {"Pop2", 129, 99}, - {"Pop2", 129, 99}, - {"Pop3", 129, 99}, + { "Pop2", { 129, 99 } }, + { "Pop2", { 129, 99 } }, + { "Pop3", { 129, 99 } }, #endif }, { // GR_1024 - {"2_Pop2", 206, 158}, - {"2_Pop2", 206, 158}, - {"2_Pop3", 206, 158}, + { "2_Pop2", { 206, 158 } }, + { "2_Pop2", { 206, 158 } }, + { "2_Pop3", { 206, 158 } }, } }; @@ -403,7 +403,7 @@ static popup_background Popup_background[GR_NUM_RESOLUTIONS][4] = #define BUTTON_GENERIC_FIRST 2 #define BUTTON_GENERIC_SECOND 3 #define BUTTON_GENERIC_THIRD 4 -static char *Popup_button_filenames[GR_NUM_RESOLUTIONS][2][5] = +static const char *Popup_button_filenames[GR_NUM_RESOLUTIONS][2][5] = { { // GR_640 #ifdef MAKE_FS1 @@ -616,9 +616,9 @@ void popup_split_lines(popup_info *pi, int flags) } // figure out what filename to use for the button icon -char *popup_get_button_filename(popup_info *pi, int i, int flags) +const char *popup_get_button_filename(popup_info *pi, int i, int flags) { - char *fname = NULL; + const char *fname = NULL; int is_tiny=0; // check for special button texts and if found, use specialized buttons for them. @@ -692,7 +692,7 @@ int popup_init(popup_info *pi, int flags) int i; UI_BUTTON *b; popup_background *pbg; - char *fname; + const char *fname; if(pi->nchoices == 0){ pbg = &Popup_background[gr_screen.res][0]; @@ -856,7 +856,7 @@ void popup_set_title_color(int flags) } // Draw the title centered within the popup -void popup_draw_title(int sy, char *line, int flags) +void popup_draw_title(int sy, const char *line, int flags) { int w, h, sx; @@ -1307,7 +1307,7 @@ int popup_till_condition(int (*condition)(), ...) } // popup to return the value from an input box -char *popup_input(int flags, char *caption, int max_output_len) +char *popup_input(int flags, const char *caption, int max_output_len) { if ( Popup_is_active ) { Int3(); // should never happen @@ -1365,7 +1365,7 @@ void popup_kill_any_active() } // change the text inside of the popup -void popup_change_text(char *new_text) +void popup_change_text(const char *new_text) { // copy the raw text strncpy(Popup_info.raw_text,new_text,POPUP_MAX_CHARS); diff --git a/src/popup/popupdead.cpp b/src/popup/popupdead.cpp index 0fb7767..42aa59d 100644 --- a/src/popup/popupdead.cpp +++ b/src/popup/popupdead.cpp @@ -196,7 +196,7 @@ int Popupdead_button_coords[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX][2] = } }; -char *Popupdead_background_filename[GR_NUM_RESOLUTIONS] = { +const char *Popupdead_background_filename[GR_NUM_RESOLUTIONS] = { "PopDeath", // GR_640 "2_PopDeath" // GR-1024 }; @@ -211,7 +211,7 @@ int Popupdead_background_coords[GR_NUM_RESOLUTIONS][2] = } }; -char *Popupdead_button_filenames[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX] = +const char *Popupdead_button_filenames[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX] = { { // GR_640 "PopD_00", // first choice @@ -237,7 +237,7 @@ int Popupdead_skip_message_y[GR_NUM_RESOLUTIONS] = { }; -static char *Popupdead_button_text[POPUPDEAD_NUM_CHOICES_MAX]; +static const char *Popupdead_button_text[POPUPDEAD_NUM_CHOICES_MAX]; // multiplayer specifics to help with return values since they can vary #define POPUPDEAD_OBS_ONLY 1 diff --git a/src/render/3dsetup.cpp b/src/render/3dsetup.cpp index fb09a4e..9cb7b0d 100644 --- a/src/render/3dsetup.cpp +++ b/src/render/3dsetup.cpp @@ -141,7 +141,7 @@ int G3_frame_count = 0; //start the frame // Pass true for zbuffer_flag to turn on zbuffering -void g3_start_frame_func(int zbuffer_flag, char * filename, int lineno) +void g3_start_frame_func(int zbuffer_flag, const char * filename, int lineno) { float s; int width, height; diff --git a/src/ship/ai.cpp b/src/ship/ai.cpp index b6f0e35..e34544a 100644 --- a/src/ship/ai.cpp +++ b/src/ship/ai.cpp @@ -82,7 +82,7 @@ void set_wingnum(int objnum, int wingnum) Ai_info[ai_index].wing = wingnum; } -char *ai_get_goal_ship_name(char *name, int *index) +char *ai_get_goal_ship_name(const char *name, int *index) { int i; diff --git a/src/ship/aicode.cpp b/src/ship/aicode.cpp index efa2d6b..ed5de16 100644 --- a/src/ship/aicode.cpp +++ b/src/ship/aicode.cpp @@ -520,7 +520,7 @@ //XSTR:OFF -char *Mode_text[MAX_AI_BEHAVIORS] = { +const char *Mode_text[MAX_AI_BEHAVIORS] = { "CHASE", "EVADE", "GET_BEHIND", @@ -545,7 +545,7 @@ char *Mode_text[MAX_AI_BEHAVIORS] = { }; // Submode text is only valid for CHASE mode. -char *Submode_text[] = { +const char *Submode_text[] = { "undefined", "CONT_TURN", "ATTACK ", @@ -566,7 +566,7 @@ char *Submode_text[] = { "BIG_PARL" }; -char *Strafe_submode_text[5] = { +const char *Strafe_submode_text[5] = { "ATTACK", "AVOID", "RETREAT1", @@ -660,9 +660,9 @@ int AI_watch_object = 0; // Debugging, object to spew debug info for. int Num_waypoint_lists = 0; int Mission_all_attack = 0; // !0 means all teams attack all teams. -char *Skill_level_names(int level, int translate) +const char *Skill_level_names(int level, int translate) { - char *str = NULL; + const char *str = NULL; #if NUM_SKILL_LEVELS != 5 #error Number of skill levels is wrong! diff --git a/src/ship/aigoals.cpp b/src/ship/aigoals.cpp index 65a0dfa..18e2645 100644 --- a/src/ship/aigoals.cpp +++ b/src/ship/aigoals.cpp @@ -509,7 +509,7 @@ char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH]; // HUD what a ship's current orders are. If the AI goal doesn't correspond to something that // ought to be printable, then NULL is used. // JAS: Converted to a function in order to externalize the strings -char *Ai_goal_text(int goal) +const char *Ai_goal_text(int goal) { switch(goal) { case 1: @@ -777,7 +777,7 @@ void ai_clear_wing_goals( int wingnum ) void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp ) { int mode, submode, priority, i; - char *name; + const char *name; ai_goal *aigp; wing *wingp; @@ -845,7 +845,7 @@ void ai_mission_goal_complete( ai_info *aip ) } -int ai_get_subsystem_type( char *subsystem ) +int ai_get_subsystem_type( const char *subsystem ) { if ( strstr(subsystem, "engine") ) { return SUBSYSTEM_ENGINE; @@ -885,7 +885,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list ) { int i; ai_goal *purge_goal; - char *name; + const char *name; int mode, ship_index, wingnum; // get locals for easer access @@ -1006,7 +1006,7 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp) // from the mission goals (i.e. those goals which come from events) in that we don't // use sexpressions for goals from the player...so we enumerate all the parameters -void ai_add_goal_sub_player(int type, int mode, int submode, char *shipname, ai_goal *aigp ) +void ai_add_goal_sub_player(int type, int mode, int submode, const char *shipname, ai_goal *aigp ) { Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) ); @@ -1068,7 +1068,7 @@ int ai_goal_find_empty_slot( ai_goal *goals ) // is issued to ship or wing (from player), mode is AI_GOAL_*. submode is the submode the // ship should go into. shipname is the object of the action. aip is the ai_info pointer // of the ship receiving the order -void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip ) +void ai_add_ship_goal_player( int type, int mode, int submode, const char *shipname, ai_info *aip ) { int empty_index; ai_goal *aigp; @@ -1094,7 +1094,7 @@ void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, a // adds a goal from the player to the given wing (which in turn will add it to the proper // ships in the wing -void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum ) +void ai_add_wing_goal_player( int type, int mode, int submode, const char *shipname, int wingnum ) { int i, empty_index; wing *wingp = &Wings[wingnum]; @@ -1331,7 +1331,7 @@ void ai_add_wing_goal_sexp(int sexp, int type, int wingnum) // this name can be a shipname or a wingname) // docker_point and dockee_point are used for the AI_GOAL_DOCK command to tell two ships where to dock // immediate means to process this order right away -void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate ) +void ai_add_goal_ship_internal( ai_info *aip, int goal_type, const char *name, int docker_point, int dockee_point, int immediate ) { int gindex; ai_goal *aigp; @@ -1395,7 +1395,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc // across waves of the wing so we merely need to add the goal to each ship in the wing. Certain // goal are simply not valid for wings (like dock, undock). Immediate parameter gets passed to add_ship_goal // to say whether or not we should process this goal right away -void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate ) +void ai_add_goal_wing_internal( wing *wingp, int goal_type, const char *name, int immediate ) { int i; @@ -2201,7 +2201,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) } -void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *new_name) +void ai_update_goal_references(ai_goal *goals, int type, const char *old_name, char *new_name) { int i, mode, flag, dummy; @@ -2267,7 +2267,7 @@ void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *n } } -int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name) +int query_referenced_in_ai_goals(ai_goal *goals, int type, const char *name) { int i, mode, flag; @@ -2331,7 +2331,7 @@ int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name) return 0; } -char *ai_add_dock_name(char *str) +char *ai_add_dock_name(const char *str) { char *ptr; int i; diff --git a/src/ship/shield.cpp b/src/ship/shield.cpp index 5c00b69..d5f3540 100644 --- a/src/ship/shield.cpp +++ b/src/ship/shield.cpp @@ -245,7 +245,7 @@ int Num_tris; // Number of triangles in current shield. Would be a local shield_hit Shield_hits[MAX_SHIELD_HITS]; typedef struct shield_ani { - char *filename; + const char *filename; int first_frame; int nframes; } shield_ani; diff --git a/src/ship/ship.cpp b/src/ship/ship.cpp index 84d35a9..0be1df8 100644 --- a/src/ship/ship.cpp +++ b/src/ship/ship.cpp @@ -805,7 +805,7 @@ static int Missile_out_snd_timer; // timer so we play out of laser sound effect // structure used to hold ship counts of particular types. The order in which these appear is crucial // since the goal code relies on this placement to find the array index in the Ship_counts array -char *Ship_type_names[MAX_SHIP_TYPE_COUNTS] = { +const char *Ship_type_names[MAX_SHIP_TYPE_COUNTS] = { //XSTR:OFF "no type", "cargo", @@ -1434,7 +1434,7 @@ int parse_ship() Warning(LOCATION, "Bogus string in ship flags: %s\n", ship_strings[i]); } - find_and_stuff("$AI Class:", &sip->ai_class, F_NAME, Ai_class_names, Num_ai_classes, "AI class names"); + find_and_stuff("$AI Class:", &sip->ai_class, F_NAME, (const char **)Ai_class_names, Num_ai_classes, "AI class names"); // Get Afterburner information // Be aware that if $Afterburner is not 1, the other Afterburner fields are not read in @@ -1866,7 +1866,7 @@ void ship_add_exited_ship( ship *sp, int reason ) } // function which attempts to find information about an exited ship based on shipname -int ship_find_exited_ship_by_name( char *name ) +int ship_find_exited_ship_by_name( const char *name ) { int i; @@ -6092,7 +6092,7 @@ int get_available_secondary_weapons(object *objp, int *outlist, int *outbanklist } // Return the object index of the ship with name *name. -int wing_name_lookup(char *name, int ignore_count) +int wing_name_lookup(const char *name, int ignore_count) { int i, wing_limit; @@ -6117,7 +6117,7 @@ int wing_name_lookup(char *name, int ignore_count) // this function is needed in addition to wing_name_lookup because it does a straight lookup without // caring about how many ships are in the wing, etc. -int wing_lookup(char *name) +int wing_lookup(const char *name) { int idx; for(idx=0;idxai_index >= 0); aip = &Ai_info[sp->ai_index]; diff --git a/src/sound/audiostr-openal.cpp b/src/sound/audiostr-openal.cpp index 2ce489b..2ceb6c5 100644 --- a/src/sound/audiostr-openal.cpp +++ b/src/sound/audiostr-openal.cpp @@ -165,7 +165,7 @@ class WaveFile public: void Init(void); void Close(void); - BOOL Open (char *pszFilename); + BOOL Open (const char *pszFilename); BOOL Cue (void); int Read (ubyte *pbDest, uint cbSize, int service=1); uint GetNumBytesRemaining (void) { return (m_nDataSize - m_nBytesPlayed); } @@ -201,7 +201,7 @@ class AudioStream public: AudioStream (void); ~AudioStream (void); - BOOL Create (char *pszFilename); + BOOL Create (const char *pszFilename); BOOL Destroy (void); void Play (long volume, int looping); int Is_Playing(){ return(m_fPlaying); } @@ -375,7 +375,7 @@ void WaveFile::Close(void) // Open -BOOL WaveFile::Open (char *pszFilename) +BOOL WaveFile::Open (const char *pszFilename) { int done = FALSE; WORD cbExtra = 0; @@ -792,7 +792,7 @@ void AudioStream::Init_Data () } // Create -BOOL AudioStream::Create (char *pszFilename) +BOOL AudioStream::Create (const char *pszFilename) { BOOL fRtn = SUCCESS; // assume success @@ -1413,7 +1413,7 @@ void audiostream_close() // // returns: success => handle to identify streaming sound // failure => -1 -int audiostream_open( char *filename, int type ) +int audiostream_open( const char *filename, int type ) { int i, rc; diff --git a/src/starfield/nebula.cpp b/src/starfield/nebula.cpp index eba7505..450d7ae 100644 --- a/src/starfield/nebula.cpp +++ b/src/starfield/nebula.cpp @@ -217,7 +217,7 @@ void project_2d_onto_sphere( vector *pnt, float u, float v ) // 1.00 - initial version // returns 0 if failed -int load_nebula_sub(char *filename) +int load_nebula_sub(const char *filename) { CFILE *fp; char id[16]; @@ -283,7 +283,7 @@ int load_nebula_sub(char *filename) return 1; } -void nebula_init( char *filename, int pitch, int bank, int heading ) +void nebula_init( const char *filename, int pitch, int bank, int heading ) { angles a; @@ -293,7 +293,7 @@ void nebula_init( char *filename, int pitch, int bank, int heading ) nebula_init(filename, &a); } -void nebula_init( char *filename, angles * pbh ) +void nebula_init( const char *filename, angles * pbh ) { if ( Nebula_loaded ) { nebula_close(); diff --git a/src/starfield/starfield.cpp b/src/starfield/starfield.cpp index 781ce33..9aade26 100644 --- a/src/starfield/starfield.cpp +++ b/src/starfield/starfield.cpp @@ -1470,14 +1470,14 @@ void stars_draw_background() } // call this to set a specific model as the background model -void stars_set_background_model(char *model_name, char *texture_name) +void stars_set_background_model(const char *model_name, const char *texture_name) { Nmodel_num = model_load(model_name, 0, NULL); Nmodel_bitmap = bm_load(texture_name); } // lookup a starfield bitmap, return index or -1 on fail -int stars_find_bitmap(char *name) +int stars_find_bitmap(const char *name) { int idx; @@ -1493,7 +1493,7 @@ int stars_find_bitmap(char *name) } // lookup a sun by bitmap filename, return index or -1 on fail -int stars_find_sun(char *name) +int stars_find_sun(const char *name) { int idx; diff --git a/src/stats/medals.cpp b/src/stats/medals.cpp index a5b91ce..261ca2c 100644 --- a/src/stats/medals.cpp +++ b/src/stats/medals.cpp @@ -373,12 +373,12 @@ UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = { }; #endif -static char* Medals_background_filename[GR_NUM_RESOLUTIONS] = { +static const char* Medals_background_filename[GR_NUM_RESOLUTIONS] = { "MedalsDisplayEmpty", "2_MedalsDisplayEmpty" }; -static char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = { +static const char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = { "Medals-m", "2_Medals-m" }; diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 1d2069e..ec78bb9 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -210,7 +210,7 @@ // ignore_focus => whether to allow Enter/Spacebar to affect pressed state when // control has focus // -void UI_BUTTON::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat, int ignore_focus) +void UI_BUTTON::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h, int do_repeat, int ignore_focus) { text = NULL; diff --git a/src/ui/checkbox.cpp b/src/ui/checkbox.cpp index df87b58..b8d40d0 100644 --- a/src/ui/checkbox.cpp +++ b/src/ui/checkbox.cpp @@ -76,7 +76,7 @@ #include "ui.h" #include "alphacolors.h" -void UI_CHECKBOX::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state ) +void UI_CHECKBOX::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state ) { int _w, _h; diff --git a/src/ui/gadget.cpp b/src/ui/gadget.cpp index fc1a52b..770797c 100644 --- a/src/ui/gadget.cpp +++ b/src/ui/gadget.cpp @@ -179,7 +179,6 @@ // constructor UI_GADGET::UI_GADGET() { - bm_filename = NULL; } // destructor @@ -224,7 +223,7 @@ void UI_GADGET::link_hotspot(int num) // anything < start_frame will not be loaded. // this keeps the loading code from trying to load bitmaps which don't exist // and taking an unnecessary disk hit. -int UI_GADGET::set_bmaps(char *ani_fname, int nframes, int start_frame) +int UI_GADGET::set_bmaps(const char *ani_fname, int nframes, int start_frame) { int i; #ifndef MAKE_FS1 @@ -242,7 +241,6 @@ int UI_GADGET::set_bmaps(char *ani_fname, int nframes, int start_frame) } // load all the bitmaps - bm_filename = ani_fname; Assert(nframes < MAX_BMAPS_PER_GADGET); m_num_frames = nframes; diff --git a/src/ui/icon.cpp b/src/ui/icon.cpp index 83533da..b4be923 100644 --- a/src/ui/icon.cpp +++ b/src/ui/icon.cpp @@ -67,7 +67,7 @@ // UI_ICON::create() // // -void UI_ICON::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h) +void UI_ICON::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w, int _h) { if (_text) text = strdup(_text); diff --git a/src/ui/inputbox.cpp b/src/ui/inputbox.cpp index 1e5f074..e4e97da 100644 --- a/src/ui/inputbox.cpp +++ b/src/ui/inputbox.cpp @@ -285,7 +285,7 @@ void UI_INPUTBOX::init_cursor() cursor_current_frame=0; } -void UI_INPUTBOX::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _text_len, char *_text, int _flags, int pixel_lim, color *clr) +void UI_INPUTBOX::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _text_len, const char *_text, int _flags, int pixel_lim, color *clr) { int tw, th; @@ -337,7 +337,7 @@ void UI_INPUTBOX::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _text_len, invalid_chars = NULL; }; -void UI_INPUTBOX::set_valid_chars(char *vchars) +void UI_INPUTBOX::set_valid_chars(const char *vchars) { // free up any existing string if(valid_chars != NULL){ @@ -348,7 +348,7 @@ void UI_INPUTBOX::set_valid_chars(char *vchars) valid_chars = strdup(vchars); } -void UI_INPUTBOX::set_invalid_chars(char *ichars) +void UI_INPUTBOX::set_invalid_chars(const char *ichars) { // free up any existing string if(invalid_chars != NULL){ @@ -703,7 +703,7 @@ void UI_INPUTBOX::get_text(char *out) out[length] = 0; } -void UI_INPUTBOX::set_text(char *in) +void UI_INPUTBOX::set_text(const char *in) { int in_length; diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp index be49ab4..167ddfe 100644 --- a/src/ui/listbox.cpp +++ b/src/ui/listbox.cpp @@ -136,7 +136,7 @@ void UI_LISTBOX::link_hotspot(int up_button_num, int down_button_num) // returns: -1 ==> error // 0 ==> success // -int UI_LISTBOX::set_bmaps(char *lbox_fname, char *b_up_fname, char *b_down_fname, char *sb_fname) +int UI_LISTBOX::set_bmaps(const char *lbox_fname, const char *b_up_fname, const char *b_down_fname, const char *sb_fname) { if (has_scrollbar) { scrollbar.set_bmaps(b_up_fname, b_down_fname, sb_fname); diff --git a/src/ui/radio.cpp b/src/ui/radio.cpp index 9069422..853f67c 100644 --- a/src/ui/radio.cpp +++ b/src/ui/radio.cpp @@ -75,7 +75,7 @@ #include "ui.h" #include "alphacolors.h" -void UI_RADIO::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _state, int _group ) +void UI_RADIO::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _state, int _group ) { int _w, _h; diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 83abc56..1c996b4 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -117,7 +117,7 @@ void UI_SCROLLBAR::link_hotspot(int up_button_num, int down_button_num) // returns: -1 ==> error // 0 ==> success // -int UI_SCROLLBAR::set_bmaps(char *up_button_fname, char *down_button_fname, char *line_fname) +int UI_SCROLLBAR::set_bmaps(const char *up_button_fname, const char *down_button_fname, const char *line_fname) { int bx, by, bh, bw; @@ -155,8 +155,8 @@ int UI_SCROLLBAR::get_hidden() void UI_SCROLLBAR::create(UI_WINDOW *wnd, int _x, int _y, int _h, int _start, int _stop, int _position, int _window_size) { - char *up = "^"; - char *down = "v"; + const char *up = "^"; + const char *down = "v"; int bw = 20; base_create( wnd, UI_KIND_SCROLLBAR, _x, _y + bw, bw, _h - bw * 2 ); diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index 4767073..e58e793 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -110,9 +110,9 @@ #include "alphacolors.h" /// DOT_SLIDER class down here -void UI_DOT_SLIDER_NEW::create(UI_WINDOW *wnd, int _x, int _y, int _num_pos, char *bm_slider, int slider_mask, - char *bm_left, int left_mask, int left_x, int left_y, - char *bm_right, int right_mask, int right_x, int right_y, +void UI_DOT_SLIDER_NEW::create(UI_WINDOW *wnd, int _x, int _y, int _num_pos, const char *bm_slider, int slider_mask, + const char *bm_left, int left_mask, int left_x, int left_y, + const char *bm_right, int right_mask, int right_x, int right_y, int _dot_width) { // no end buttons yet @@ -260,7 +260,7 @@ void UI_DOT_SLIDER_NEW::process(int focus) // /// DOT_SLIDER class down here -void UI_DOT_SLIDER::create(UI_WINDOW *wnd, int _x, int _y, char *bm, int id, int end_buttons, int _num_pos) +void UI_DOT_SLIDER::create(UI_WINDOW *wnd, int _x, int _y, const char *bm, int id, int end_buttons, int _num_pos) { char filename[MAX_PATH_LEN]; int bx, by, bw, hotspot; diff --git a/src/ui/slider2.cpp b/src/ui/slider2.cpp index 6215dbe..0d1b31d 100644 --- a/src/ui/slider2.cpp +++ b/src/ui/slider2.cpp @@ -65,7 +65,7 @@ // captureCallback is called when an item is "selected" by mouse release. That is, the user has clicked, dragged and _released_. // the callback is called when the scrollbar has been released -void UI_SLIDER2::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl, void (* _upCallback)(), void (*_downCallback)(), +void UI_SLIDER2::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, const char *_bitmapSliderControl, void (* _upCallback)(), void (*_downCallback)(), void (* _captureCallback)()) { int buttonHeight, buttonWidth; diff --git a/src/ui/uidraw.cpp b/src/ui/uidraw.cpp index 76c5bb4..e9fe4b6 100644 --- a/src/ui/uidraw.cpp +++ b/src/ui/uidraw.cpp @@ -63,7 +63,7 @@ void ui_vline(int y1, int y2, int x ) gr_line(x,y1,x,y2); } -void ui_string_centered( int x, int y, char * s ) +void ui_string_centered( int x, int y, const char * s ) { int height, width; diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 743b54b..806cbae 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -192,7 +192,7 @@ UI_WINDOW::~UI_WINDOW() // Specify the filename for the mask bitmap to use. This has the hotspots // for all the different controls. // -void UI_WINDOW::set_mask_bmap(char *fname) +void UI_WINDOW::set_mask_bmap(const char *fname) { int bmap; @@ -206,7 +206,7 @@ void UI_WINDOW::set_mask_bmap(char *fname) } } -void UI_WINDOW::set_mask_bmap(int bmap, char *name) +void UI_WINDOW::set_mask_bmap(int bmap, const char *name) { // int i; @@ -244,7 +244,7 @@ void UI_WINDOW::set_mask_bmap(int bmap, char *name) // Specify the filename for the mask bitmap to display on the ui window as // a background. // -void UI_WINDOW::set_foreground_bmap(char *fname) +void UI_WINDOW::set_foreground_bmap(const char *fname) { // load in the background bitmap foreground_bmap_id = bm_load(fname); @@ -328,7 +328,7 @@ void UI_WINDOW::destroy() // free up this struct if(xstrs[idx] != NULL){ if(xstrs[idx]->xstr != NULL){ - free(xstrs[idx]->xstr); + free((char *)xstrs[idx]->xstr); } free(xstrs[idx]); xstrs[idx] = NULL; @@ -489,7 +489,7 @@ void UI_WINDOW::draw_tooltip() */ } -void UI_WINDOW::render_tooltip(char *str) +void UI_WINDOW::render_tooltip(const char *str) { int w, h; @@ -591,7 +591,7 @@ void UI_WINDOW::set_ignore_gadgets(int state) ignore_gadgets = state; } -void UI_WINDOW::add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id) +void UI_WINDOW::add_XSTR(const char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id) { int idx; int found = -1; diff --git a/src/weapon/emp.cpp b/src/weapon/emp.cpp index 26aba90..8b1abd2 100644 --- a/src/weapon/emp.cpp +++ b/src/weapon/emp.cpp @@ -108,7 +108,7 @@ wacky_text Emp_wacky_text[NUM_TEXT_STAMPS]; // for randomly inserting characters #define NUM_RANDOM_CHARS 51 -char Emp_random_char[NUM_RANDOM_CHARS] = +const char Emp_random_char[NUM_RANDOM_CHARS] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', '4', 'h', '8', '_', '$', ')', '-', '~', 'u', 'q', '.', 'x', 'h', '&', '%', '*', '1', '3', 't', 'h', 'o', 'p', '@', 'h', 'i','v', '+', '=', '|', '{', '}', ':', ';', '^', 'l', 'z', 'u', 'v', '<', '>', '?', '5', '8' }; @@ -512,7 +512,7 @@ int emp_should_blit_gauge() } // emp hud string -void emp_hud_string(int x, int y, int gauge_id, char *str) +void emp_hud_string(int x, int y, int gauge_id, const char *str) { char tmp[256] = ""; @@ -532,7 +532,7 @@ void emp_hud_string(int x, int y, int gauge_id, char *str) } // emp hud printf -void emp_hud_printf(int x, int y, int gauge_id, char *format, ...) +void emp_hud_printf(int x, int y, int gauge_id, const char *format, ...) { char tmp[256] = ""; va_list args; diff --git a/src/weapon/shockwave.cpp b/src/weapon/shockwave.cpp index 517e8d8..1b6f8b3 100644 --- a/src/weapon/shockwave.cpp +++ b/src/weapon/shockwave.cpp @@ -240,7 +240,7 @@ // Module-wide globals // ----------------------------------------------------------- -static char *Shockwave_filenames[MAX_SHOCKWAVE_TYPES] = +static const char *Shockwave_filenames[MAX_SHOCKWAVE_TYPES] = { //XSTR:OFF "shockwave01" diff --git a/src/weapon/weapons.cpp b/src/weapon/weapons.cpp index 836d8fd..0a7294c 100644 --- a/src/weapon/weapons.cpp +++ b/src/weapon/weapons.cpp @@ -683,7 +683,7 @@ missile_obj *missile_obj_return_address(int index) } // Return the index of Weapon_info[].name that is *name. -int weapon_info_lookup(char *name) +int weapon_info_lookup(const char *name) { int i; @@ -3320,7 +3320,7 @@ void weapon_detonate(object *objp) } // Return the Weapon_info[] index of the weapon with name *name. -int weapon_name_lookup(char *name) +int weapon_name_lookup(const char *name) { int i; -- 2.39.2