diff --git a/src/command.c b/src/command.c index 459938aa8..d12ae5d49 100644 --- a/src/command.c +++ b/src/command.c @@ -277,7 +277,7 @@ static xcommand_t *com_commands = NULL; // current commands #define MAX_ARGS 80 static size_t com_argc; -char *com_argv[MAX_ARGS]; +char *com_argv[MAX_ARGS] = {}; static const char *com_null_string = ""; static char *com_args = NULL; // current command args or NULL diff --git a/src/console.c b/src/console.c index 3172b9f20..2757b22e7 100644 --- a/src/console.c +++ b/src/console.c @@ -58,7 +58,7 @@ I_mutex con_mutex; static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing static boolean con_forcepic = true; // at startup toggle console translucency when first off - boolean con_recalc; // set true when screen size has changed + boolean con_recalc = false; // set true when screen size has changed static tic_t con_tick; // console ticker for anim or blinking prompt cursor // con_scrollup should use time (currenttime - lasttime).. @@ -66,8 +66,8 @@ static tic_t con_tick; // console ticker for anim or blinking prompt cursor static boolean consoletoggle; // true when console key pushed, ticker will handle static boolean consoleready; // console prompt is ready - INT32 con_destlines; // vid lines used by console at final position -static INT32 con_curlines; // vid lines currently used by console + INT32 con_destlines = 0; // vid lines used by console at final position +static INT32 con_curlines; // vid lines currently used by console static UINT8 con_hudlines; // number of console heads up message lines static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines @@ -83,7 +83,7 @@ static size_t con_totallines; // lines of console text into the console buf static size_t con_width; // columns of chars, depend on vid mode width static size_t con_scrollup; // how many rows of text to scroll up (pgup/pgdn) -UINT32 con_scalefactor; // text size scale factor +UINT32 con_scalefactor = 0; // text size scale factor // hold 32 last lines of input for history #define CON_MAXPROMPTCHARS 256 diff --git a/src/dehacked.c b/src/dehacked.c index bc0490415..2d2824100 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -47,9 +47,9 @@ // Free slot names // The crazy word-reading stuff uses these. -char *FREE_STATES[NUMSTATEFREESLOTS]; -char *FREE_MOBJS[NUMMOBJFREESLOTS]; -UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. +char *FREE_STATES[NUMSTATEFREESLOTS] = {}; +char *FREE_MOBJS[NUMMOBJFREESLOTS] = {}; +UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1] = {}; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. #define initfreeslots() {\ memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ diff --git a/src/f_finale.c b/src/f_finale.c index 55cf3f5e5..3b54096d4 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -208,7 +208,7 @@ static void F_SkyScroll(INT32 scrollspeed) INT32 intro_scenenum = 0; INT32 intro_curtime = 0; -const char *introtext[NUMINTROSCENES]; +const char *introtext[NUMINTROSCENES] = {}; static tic_t introscenetime[NUMINTROSCENES] = { diff --git a/src/filesrch.c b/src/filesrch.c index eb68222e2..c0940b2eb 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -44,16 +44,16 @@ consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}}; consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -char menupath[MAXFILEPATH]; -size_t menupathindex[menudepth]; +char menupath[MAXFILEPATH] = {}; +size_t menupathindex[menudepth] = {}; size_t menudepthleft = menudepth; char menusearchbuf[MAXSTRINGLENGTH+1]; textinput_t menusearch; -char **dirmenu, **coredirmenu; // core only local for this file -size_t sizedirmenu, sizecoredirmenu; // ditto -size_t dir_on[menudepth]; +char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file +size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto +size_t dir_on[menudepth] = {}; UINT8 refreshdirmenu = 0; char *refreshdirname = NULL; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 9d0d46674..a03740e02 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -25,7 +25,7 @@ // Eeeeh not sure is this right way, but it works < sry :c < sry again it had to go :c -#if defined (HWRENDER) && !defined (NOROPENGL) +#if defined (HWRENDER) #include "../../r_fps.h" // For R_GetTimeFrac, used for the leveltime shader uniform @@ -101,7 +101,7 @@ static LTListItem *LightTablesHead = NULL; static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256]; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -128,7 +128,7 @@ int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) static GLfloat modelMatrix[16]; -GLfloat projMatrix[16]; +GLfloat projMatrix[16] = {0}; static GLint viewport[4]; #ifdef USE_FBO_OGL @@ -183,7 +183,7 @@ static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; // -----------------+ #ifdef DEBUG_TO_FILE -FILE *gllogstream; +FILE *gllogstream = NULL; #endif FUNCPRINTF void GL_DBG_Printf(const char *format, ...) @@ -1108,7 +1108,6 @@ static void GL_Perspective(GLfloat fovy, GLfloat aspect) { 0.0f, 0.0f, 0.0f, 0.0f}, }; - const GLfloat focallength = (GLfloat)(1.0f / (GLfloat)tan(fovy * (GLfloat)M_PIl / 360.0f)); const GLfloat deltaZ = FAR_CLIPPING_PLANE - NEAR_CLIPPING_PLANE; if ((fabsf((float)deltaZ) < 1.0E-36f) || fpclassify(aspect) == FP_ZERO) @@ -1116,6 +1115,8 @@ static void GL_Perspective(GLfloat fovy, GLfloat aspect) return; } + const GLfloat focallength = (GLfloat)(1.0f / (GLfloat)tan(fovy * (GLfloat)M_PIl / 360.0f)); + m[0][0] = focallength / aspect; m[1][1] = focallength; m[2][2] = -(FAR_CLIPPING_PLANE + NEAR_CLIPPING_PLANE) / deltaZ; @@ -1469,10 +1470,11 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale) void GL_SetPalette(RGBA_t *palette) { const size_t palsize = (sizeof(RGBA_t) * 256); + // on a palette change, you have to reload all of the textures - if (memcmp(&myPaletteData, palette, palsize)) + if (memcmp(myPaletteData, palette, palsize)) { - memcpy(&myPaletteData, palette, palsize); + memcpy(myPaletteData, palette, palsize); GL_Flush(); } } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3ed978e95..5571a4e50 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -68,32 +68,32 @@ //------------------------------------------- // heads up font //------------------------------------------- -patch_t *hu_font[HU_FONTSIZE]; -patch_t *kart_font[KART_FONTSIZE]; // SRB2kart -patch_t *tny_font[HU_FONTSIZE]; -patch_t *tallnum[10]; // 0-9 +patch_t *hu_font[HU_FONTSIZE] = {}; +patch_t *kart_font[KART_FONTSIZE] = {}; // SRB2kart +patch_t *tny_font[HU_FONTSIZE] = {}; +patch_t *tallnum[10] = {}; // 0-9 // Level title and credits fonts -patch_t *lt_font[LT_FONTSIZE]; -patch_t *cred_font[CRED_FONTSIZE]; +patch_t *lt_font[LT_FONTSIZE] = {}; +patch_t *cred_font[CRED_FONTSIZE] = {}; // ping font // Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat' -patch_t *pingnum[10]; -patch_t *pinggfx[5]; // small ping graphic -patch_t *pingmeasure[2]; // ping measurement graphic +patch_t *pingnum[10] = {}; +patch_t *pinggfx[5] = {}; // small ping graphic +patch_t *pingmeasure[2] = {}; // ping measurement graphic -patch_t *ranknum[10]; // rank numbers +patch_t *ranknum[10] = {}; // rank numbers -patch_t *framecounter; -patch_t *frameslash; // framerate stuff. Used in screen.c +patch_t *framecounter = NULL; +patch_t *frameslash = NULL; // framerate stuff. Used in screen.c -static player_t *plr; -boolean chat_on; // entering a chat message? +static player_t *plr = NULL; +boolean chat_on = false; // entering a chat message? static char w_chat_buf[HU_MAXMSGLEN + 1]; static textinput_t w_chat; static boolean headsupactive = false; -boolean hu_showscores; // draw rankings +boolean hu_showscores = false; // draw rankings static char hu_tick; static tic_t hu_emoteanim = 0; #define MAXEMOTESUGGESTIONS 8 @@ -101,14 +101,14 @@ static emote_t *emote_suggestions[MAXEMOTESUGGESTIONS] = {0}; static huddrawlist_h luahuddrawlist_scores; -patch_t *rflagico; -patch_t *bflagico; -patch_t *rmatcico; -patch_t *bmatcico; -patch_t *tallminus; +patch_t *rflagico = NULL; +patch_t *bflagico = NULL; +patch_t *rmatcico = NULL; +patch_t *bmatcico = NULL; +patch_t *tallminus = NULL; // song credits -static patch_t *songcreditbg; +static patch_t *songcreditbg = NULL; // ------- // protos. @@ -122,7 +122,7 @@ consvar_t cv_showspecstuff = {"showspecstuff", "No", CV_SAVE, CV_YesNo, NULL, 0, // KEYBOARD LAYOUTS FOR ENTERING TEXT //====================================================================== -char *shiftxform; +char *shiftxform = NULL; char english_shiftxform[] = { diff --git a/src/lua_script.c b/src/lua_script.c index e84ae5cfc..557be2cee 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -41,7 +41,7 @@ lua_State *gL = NULL; // Mathlib global state static lua_State *mL = NULL; -int hook_defrosting; +int hook_defrosting = 0; // List of internal libraries to load from SRB2 static lua_CFunction liblist[] = { diff --git a/src/m_argv.c b/src/m_argv.c index b62d390d9..36c73d61c 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -20,11 +20,11 @@ /** \brief number of arg */ -INT32 myargc; +INT32 myargc = 0; /** \brief string table */ -char **myargv; +char **myargv = NULL; /** \brief did we alloc myargv ourselves? */ diff --git a/src/m_cond.c b/src/m_cond.c index f9d871969..acf78e6ef 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -25,10 +25,10 @@ // Map triggers for linedef executors // 32 triggers, one bit each -UINT32 unlocktriggers; +UINT32 unlocktriggers = 0; // The meat of this system lies in condition sets -conditionset_t conditionSets[MAXCONDITIONSETS]; +conditionset_t conditionSets[MAXCONDITIONSETS] = {}; // Default Emblem locations emblem_t emblemlocations[MAXEMBLEMS] = diff --git a/src/m_menu.c b/src/m_menu.c index a483afa7f..d891d0a87 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -145,19 +145,19 @@ I_mutex m_menu_mutex; M_waiting_mode_t m_waiting_mode = M_NOT_WAITING; -const char *quitmsg[NUM_QUITMESSAGES]; +const char *quitmsg[NUM_QUITMESSAGES] = {}; // Stuff for customizing the player select screen Tails 09-22-2003 -description_t description[MAXSKINS]; +description_t description[MAXSKINS] = {}; -INT32 mapwads[NUMMAPS]; +INT32 mapwads[NUMMAPS] = {}; boolean browselocalskins = false; boolean menuactive = false; boolean fromlevelselect = false; -char menu_text_input_buf[MAXSTRINGLENGTH]; +char menu_text_input_buf[MAXSTRINGLENGTH] = {}; static textinput_t menuinput; static INT32 coolalphatimer = 9; @@ -171,7 +171,6 @@ typedef enum } levellist_mode_t; levellist_mode_t levellistmode = LLM_CREATESERVER; -UINT8 maplistoption = 0; static char joystickInfo[8][29]; @@ -181,10 +180,6 @@ static float serverlistslidex; static INT32 serverlistsearched[MAXSERVERLIST] = {0}; static UINT32 serverlistsearchedcount = 0; -//static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games. - -INT16 startmap; // Mario, NiGHTS, or just a plain old normal game? - static INT16 itemOn = 1; // menu item skull is on, Hack by Tails 09-18-2002 static INT16 skullAnimCounter = 10; // skull animation counter static boolean interpTimerHackAllow = 0; diff --git a/src/m_menu.h b/src/m_menu.h index 476629db9..2e7cedbbb 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -274,9 +274,6 @@ extern CV_PossibleValue_t gametype_cons_t[]; extern char dummystaffname[22]; -extern INT16 startmap; -extern INT32 ultimate_selectable; - #define MAXSAVEGAMES 31 //note: last save game is "no save" #define NOSAVESLOT MAXSAVEGAMES-1 //slot where Play Without Saving appears diff --git a/src/mserv.c b/src/mserv.c index e60d556e2..f830cd6e2 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -89,10 +89,10 @@ consvar_t cv_masterserver_nagattempts = {"masterserver_nagattempts", "5", CV_SAV #if defined (MASTERSERVER) && defined (HAVE_THREADS) -int ms_QueryId; +int ms_QueryId = 0; I_mutex ms_QueryId_mutex; -msg_server_t *ms_ServerList; +msg_server_t *ms_ServerList = NULL; I_mutex ms_ServerList_mutex; #endif diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 8170343c9..a00d78008 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -24,9 +24,6 @@ // CEILINGS // ========================================================================== -// the list of ceilings moving currently, including crushers -INT32 ceilmovesound = sfx_None; - /** Moves a moving ceiling. * * \param ceiling Thinker for the ceiling to be moved. diff --git a/src/p_local.h b/src/p_local.h index 454368c3d..6633c6fd8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -477,8 +477,6 @@ void P_DoNightsScore(player_t *player); // #include "p_spec.h" -extern INT32 ceilmovesound; - // Factor to scale scrolling effect into mobj-carrying properties = 3/32. // (This is so scrolling floors and objects on them can move at same speed.) #define CARRYFACTOR (FRACUNIT-ORIG_FRICTION) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 5e5590ced..15090a7ea 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -90,14 +90,14 @@ // // The Polyobjects -polyobj_t *PolyObjects; -INT32 numPolyObjects; +polyobj_t *PolyObjects = NULL; +INT32 numPolyObjects = 0; // Polyobject Blockmap -- initialized in P_LoadBlockMap -polymaplink_t **polyblocklinks; +polymaplink_t **polyblocklinks = NULL; -static size_t *KnownPolySides; -static size_t KnownPolySidesCount; +static size_t *KnownPolySides = NULL; +static size_t KnownPolySidesCount = 0; // // Static Data diff --git a/src/p_slopes.c b/src/p_slopes.c index 850813331..2ec2898b9 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -38,7 +38,6 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) fixed_t light = FRACUNIT; fixed_t extralight = 0; - if (slope->normal.z == 0) { slope->lightOffset = 0; @@ -296,7 +295,7 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) // Find furthest vertex from the reference line. It, along with the two ends // of the line, will define the plane. - for(i = 0; i < sector->linecount; i++) + for (i = 0; i < sector->linecount; i++) { line_t *li = sector->lines[i]; vertex_t tempv; diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index b2ab7777f..cc04dc6a6 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -53,7 +53,7 @@ extern int SDL_main(int argc, char *argv[]); #ifdef LOGMESSAGES FILE *logstream = NULL; -char logfilename[1024]; +char logfilename[1024] = {}; #endif #ifndef DOXYGEN diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 0af5eeae6..e700a0548 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -233,7 +233,7 @@ typedef struct char buffer[256]; } feild_t; -feild_t tty_con; +feild_t tty_con = {}; // lock to prevent clearing partial lines, since not everything // printed ends on a newline. diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5692319d5..b59ac8d59 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -155,9 +155,9 @@ static UINT32 localPalette[256]; Uint16 realwidth = BASEVIDWIDTH; Uint16 realheight = BASEVIDHEIGHT; #define HalfWarpMouse(x,y) if (wrapmouseok) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2)) -static SDL_bool exposevideo = SDL_FALSE; -static SDL_bool usesdl2soft = SDL_FALSE; -static SDL_bool borderlesswindow = SDL_FALSE; +static SDL_bool exposevideo = SDL_FALSE; +static SDL_bool usesdl2soft = SDL_FALSE; +static SDL_bool borderlesswindow = SDL_FALSE; // SDL2 vars SDL_Window *window = NULL; diff --git a/src/sounds.c b/src/sounds.c index c1e2f83a7..dbd5478bd 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -972,7 +972,7 @@ sfxinfo_t S_sfx[NUMSFX] = // initialized to NULL }; -char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][7]; +char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][7] = {}; // Prepare free sfx slots to add sfx at run time void S_InitRuntimeSounds (void) diff --git a/src/st_stuff.c b/src/st_stuff.c index 5c4b833b3..4e12f2660 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -61,13 +61,13 @@ tic_t directortoggletimer = 0; // STATUS BAR DATA // -patch_t *facerankprefix[MAXSKINS]; // ranking -patch_t *facewantprefix[MAXSKINS]; // wanted -patch_t *facemmapprefix[MAXSKINS]; // minimap +patch_t *facerankprefix[MAXSKINS] = {}; // ranking +patch_t *facewantprefix[MAXSKINS] = {}; // wanted +patch_t *facemmapprefix[MAXSKINS] = {}; // minimap -patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking -patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted -patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap +patch_t *localfacerankprefix[MAXLOCALSKINS] = {}; // ranking +patch_t *localfacewantprefix[MAXLOCALSKINS] = {}; // wanted +patch_t *localfacemmapprefix[MAXLOCALSKINS] = {}; // minimap /*char *facerankprefix_name[MAXSKINS]; // ranking char *facewantprefix_name[MAXSKINS]; // wanted @@ -91,8 +91,8 @@ static patch_t *envelope; #endif // current player for overlay drawing -player_t *stplyr; -UINT8 stplyrnum; +player_t *stplyr = NULL; +UINT8 stplyrnum = 0; // SRB2kart @@ -342,7 +342,7 @@ void ST_changeDemoView(void) // STATUS BAR OVERLAY // ========================================================================= -boolean st_overlay; +boolean st_overlay = true; // ========================================================================= // INTERNAL DRAWING diff --git a/src/w_wad.c b/src/w_wad.c index b55d0e98f..640ee0367 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -107,7 +107,7 @@ static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; // GLOBALS //=========================================================================== UINT16 numwadfiles = 0; // number of active wadfiles -wadfile_t *wadfiles[MAX_WADFILES]; // 0 to numwadfiles-1 are valid +wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid // W_Shutdown // Closes all of the WAD files before quitting