diff --git a/src/d_main.c b/src/d_main.c index 82aad739b..bec5a3e2d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1207,12 +1207,7 @@ void D_SRB2Main(void) // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); - if (!W_InitMultipleFiles(startupwadfiles, mainwads)) -#ifdef _DEBUG - CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); -#else - I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); -#endif + W_InitMultipleFiles(startupwadfiles, mainwads); D_CleanFile(); #ifndef DEVELOP // md5s last updated 16/02/20 (ddmmyy) @@ -1292,13 +1287,17 @@ void D_SRB2Main(void) // Lactozilla: Does the render mode need to change? if ((setrenderneeded != 0) && (setrenderneeded != rendermode)) { + CONS_Printf("Switching the renderer...\n"); needpatchflush = true; needpatchrecache = true; VID_CheckRenderer(); SCR_ChangeRendererCVars(setrenderneeded); +<<<<<<< HEAD +======= + D_CheckRendererState(); +>>>>>>> origin/master setrenderneeded = 0; } - D_CheckRendererState(); wipegamestate = gamestate; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 306bf6839..f9dad6cb7 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1594,7 +1594,7 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) hook_p hookp; boolean hasSeenPlayer = true; if (!gL || !(hooksAvailable[hook_SeenPlayer/8] & (1<<(hook_SeenPlayer%8)))) - return 0; + return true; lua_settop(gL, 0); hud_running = true; // local hook diff --git a/src/m_misc.c b/src/m_misc.c index 3dfeef81e..d762712b6 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2618,14 +2618,15 @@ const char * M_Ftrim (double f) static char dig[9];/* "0." + 6 digits (6 is printf's default) */ int i; /* I know I said it's the default, but just in case... */ - sprintf(dig, "%.6g", modf(f, &f)); - if (dig[0]) + sprintf(dig, "%.6f", fabs(modf(f, &f))); + /* trim trailing zeroes */ + for (i = strlen(dig)-1; dig[i] == '0'; --i) + ; + if (dig[i] == '.')/* :NOTHING: */ + return ""; + else { - for (i = strlen(dig); dig[i] == '0'; --i) - ; dig[i + 1] = '\0'; return &dig[1];/* skip the 0 */ } - else - return ""; } diff --git a/src/p_setup.c b/src/p_setup.c index 64671c1ee..dcc28bae1 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3831,10 +3831,9 @@ boolean P_AddWadFile(const char *wadfilename) // UINT16 mapPos, mapNum = 0; // Init file. - if ((numlumps = W_InitFile(wadfilename, false)) == INT16_MAX) + if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; - CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); return false; } else diff --git a/src/r_patch.c b/src/r_patch.c index 80c0f846f..4304f3eab 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1212,14 +1212,23 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp INT32 width, height, leftoffset; fixed_t ca, sa; lumpnum_t lump = sprframe->lumppat[rot]; + size_t lumplength; if (lump == LUMPERROR) return; + + patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); + lumplength = W_LumpLength(lump); + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)patch, lumplength)) + patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL); + else +#endif // Because there's something wrong with SPR_DFLM, I guess if (!R_CheckIfPatch(lump)) return; - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); width = patch->width; height = patch->height; leftoffset = patch->leftoffset; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e2e7f38d8..9615a109a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1526,12 +1526,7 @@ void VID_CheckRenderer(void) else if (rendermode == render_opengl) { I_StartupHardwareGraphics(); - // Needs to check if switching failed somehow, too. - if (rendermode == render_opengl) - { - R_InitHardwareMode(); - HWR_Switch(); - } + R_InitHardwareMode(); } #else (void)oldrenderer; diff --git a/src/w_wad.c b/src/w_wad.c index 59c1e50b1..229bba53b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -637,6 +637,21 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) return lumpinfo; } +static UINT16 W_InitFileError (const char *filename, boolean exitworthy) +{ + if (exitworthy) + { +#ifdef _DEBUG + CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); +#else + I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); +#endif + } + else + CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), filename); + return INT16_MAX; +} + // Allocate a wadfile, setup the lumpinfo (directory) and // lumpcache, add the wadfile to the current active wadfiles // @@ -648,7 +663,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) // // Can now load dehacked files (.soc) // -UINT16 W_InitFile(const char *filename, boolean mainfile) +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) { FILE *handle; lumpinfo_t *lumpinfo = NULL; @@ -681,12 +696,12 @@ UINT16 W_InitFile(const char *filename, boolean mainfile) { CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); refreshdirmenu |= REFRESHDIR_MAX; - return INT16_MAX; + return W_InitFileError(filename, startup); } // open wad file if ((handle = W_OpenWadFile(&filename, true)) == NULL) - return INT16_MAX; + return W_InitFileError(filename, startup); // Check if wad files will overflow fileneededbuffer. Only the filename part // is send in the packet; cf. @@ -701,7 +716,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile) refreshdirmenu |= REFRESHDIR_MAX; if (handle) fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, startup); } packetsizetally = packetsize; @@ -722,7 +737,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile) CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename); if (handle) fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, false); } } #endif @@ -750,7 +765,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile) if (lumpinfo == NULL) { fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, startup); } // @@ -831,10 +846,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile) * backwards, so a later file overrides all earlier ones. * * \param filenames A null-terminated list of files to use. - * \return 1 if base files were loaded, 0 if at least one was missing or - * invalid. */ -INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles) +void W_InitMultipleFiles(char **filenames, UINT16 mainfiles) { // open all the files, load headers, and count lumps numwadfiles = 0; @@ -843,15 +856,8 @@ INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles) for (; *filenames; filenames++) { //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - if (W_InitFile(*filenames, numwadfiles < mainfiles) == INT16_MAX) - { - CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); - if (numwadfiles < mainfiles) - return 0; - } + W_InitFile(*filenames, numwadfiles < mainfiles, true); } - - return 1; } /** Make sure a lump number is valid. diff --git a/src/w_wad.h b/src/w_wad.h index 8008a577c..e47f68788 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -146,11 +146,10 @@ void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error -UINT16 W_InitFile(const char *filename, boolean mainfile); +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); -// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, -// so that it stops with a message if a file was not found, but not if all is okay. -INT32 W_InitMultipleFiles(char **filenames, UINT16 mainfiles); +// W_InitMultipleFiles exits if a file was not found, but not if all is okay. +void W_InitMultipleFiles(char **filenames, UINT16 mainfiles); const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum);