From 96e4cb90b7e48d40ae07353a34db60318b87b19c Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 1 Jun 2014 15:12:41 +0300 Subject: [PATCH 1/6] Fix crash on attempt to save cached OpenGL nodes on OS X Root permissions are required to be able to create directories inside /Library/Application Support So user's ~/Library/Application Support is used to store cached nodes --- src/m_specialpaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_specialpaths.cpp b/src/m_specialpaths.cpp index b4fcba3c38..e6f74eda61 100644 --- a/src/m_specialpaths.cpp +++ b/src/m_specialpaths.cpp @@ -335,7 +335,7 @@ FString M_GetCachePath(bool create) char pathstr[PATH_MAX]; FSRef folder; - if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, create ? kCreateFolder : 0, &folder) && + if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, create ? kCreateFolder : 0, &folder) && noErr == FSRefMakePath(&folder, (UInt8*)pathstr, PATH_MAX)) { path = pathstr; From 9cd074ddf3cf65fd2192320d34b8e5a05357deb6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Jun 2014 10:51:17 +0200 Subject: [PATCH 2/6] - fixed: plane equation vectors must be normalized when being loaded from UDMF. --- src/p_udmf.cpp | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 19dfdf08cd..7588199b4d 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1246,6 +1246,7 @@ public: int fadecolor = -1; int desaturation = -1; int fplaneflags = 0, cplaneflags = 0; + double fp[4] = { 0 }, cp[4] = { 0 }; memset(sec, 0, sizeof(*sec)); sec->lightlevel = 160; @@ -1449,44 +1450,42 @@ public: case NAME_floorplane_a: fplaneflags |= 1; - sec->floorplane.a = CheckFixed(key); + fp[0] = CheckFloat(key); break; case NAME_floorplane_b: fplaneflags |= 2; - sec->floorplane.b = CheckFixed(key); + fp[1] = CheckFloat(key); break; case NAME_floorplane_c: fplaneflags |= 4; - sec->floorplane.c = CheckFixed(key); - sec->floorplane.ic = FixedDiv(FRACUNIT, sec->floorplane.c); + fp[2] = CheckFloat(key); break; case NAME_floorplane_d: fplaneflags |= 8; - sec->floorplane.d = CheckFixed(key); + fp[3] = CheckFloat(key); break; case NAME_ceilingplane_a: cplaneflags |= 1; - sec->ceilingplane.a = CheckFixed(key); + cp[0] = CheckFloat(key); break; case NAME_ceilingplane_b: cplaneflags |= 2; - sec->ceilingplane.b = CheckFixed(key); + cp[1] = CheckFloat(key); break; case NAME_ceilingplane_c: cplaneflags |= 4; - sec->ceilingplane.c = CheckFixed(key); - sec->ceilingplane.ic = FixedDiv(FRACUNIT, sec->ceilingplane.c); + cp[2] = CheckFloat(key); break; case NAME_ceilingplane_d: cplaneflags |= 8; - sec->ceilingplane.d = CheckFixed(key); + cp[3] = CheckFloat(key); break; default: @@ -1509,6 +1508,17 @@ public: sec->floorplane.c = FRACUNIT; sec->floorplane.ic = FRACUNIT; } + else + { + double ulen = TVector3(fp[0], fp[1], fp[2]).Length(); + + // normalize the vector, it must have a length of 1 + sec->floorplane.a = FLOAT2FIXED(fp[0] / ulen); + sec->floorplane.b = FLOAT2FIXED(fp[1] / ulen); + sec->floorplane.c = FLOAT2FIXED(fp[2] / ulen); + sec->floorplane.d = FLOAT2FIXED(fp[3] / ulen); + sec->floorplane.ic = FLOAT2FIXED(ulen / fp[2]); + } if (cplaneflags != 15) { sec->ceilingplane.a = sec->ceilingplane.b = 0; @@ -1516,6 +1526,17 @@ public: sec->ceilingplane.c = -FRACUNIT; sec->ceilingplane.ic = -FRACUNIT; } + else + { + double ulen = TVector3(cp[0], cp[1], cp[2]).Length(); + + // normalize the vector, it must have a length of 1 + sec->floorplane.a = FLOAT2FIXED(cp[0] / ulen); + sec->floorplane.b = FLOAT2FIXED(cp[1] / ulen); + sec->floorplane.c = FLOAT2FIXED(cp[2] / ulen); + sec->floorplane.d = FLOAT2FIXED(cp[3] / ulen); + sec->floorplane.ic = FLOAT2FIXED(ulen / cp[2]); + } if (lightcolor == -1 && fadecolor == -1 && desaturation == -1) { From 3e7b0c29165114d543669bb00793920412f37c08 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 Jun 2014 10:44:29 +0300 Subject: [PATCH 3/6] Fix crash when GL nodes file cannot be opened for writing Report errors to console if nodes file cannot be opened or written --- src/p_glnodes.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index a8fa04c345..e59f3859af 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1168,8 +1168,21 @@ static void CreateCachedNodes(MapData *map) FString path = CreateCacheName(map, true); FILE *f = fopen(path, "wb"); - fwrite(compressed, 1, outlen+offset, f); - fclose(f); + + if (f != NULL) + { + if (fwrite(compressed, outlen+offset, 1, f) != 1) + { + Printf("Error saving nodes to file %s\n", path.GetChars()); + } + + fclose(f); + } + else + { + Printf("Cannot open nodes file %s for writing\n", path.GetChars()); + } + delete [] compressed; } From 20adcecb1d480724ebccc9448d2bef562c3ba59f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 2 Jun 2014 11:37:40 +0300 Subject: [PATCH 4/6] Remove redundant saving of GL nodes if they were loaded from cache --- src/p_glnodes.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index e59f3859af..899005ffa3 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -959,6 +959,7 @@ bool P_LoadGLNodes(MapData * map) bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) { bool ret = false; + bool loaded = false; // If the map loading code has performed a node rebuild we don't need to check for it again. if (!rebuilt && !P_CheckForGLNodes()) @@ -978,7 +979,8 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) numsegs = 0; // Try to load GL nodes (cached or GWA) - if (!P_LoadGLNodes(map)) + loaded = P_LoadGLNodes(map); + if (!loaded) { // none found - we have to build new ones! unsigned int startTime, endTime; @@ -1006,20 +1008,22 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) } } + if (!loaded) + { #ifdef DEBUG - // Building nodes in debug is much slower so let's cache them only if cachetime is 0 - buildtime = 0; + // Building nodes in debug is much slower so let's cache them only if cachetime is 0 + buildtime = 0; #endif - if (gl_cachenodes && buildtime/1000.f >= gl_cachetime) - { - DPrintf("Caching nodes\n"); - CreateCachedNodes(map); + if (gl_cachenodes && buildtime/1000.f >= gl_cachetime) + { + DPrintf("Caching nodes\n"); + CreateCachedNodes(map); + } + else + { + DPrintf("Not caching nodes (time = %f)\n", buildtime/1000.f); + } } - else - { - DPrintf("Not caching nodes (time = %f)\n", buildtime/1000.f); - } - if (!gamenodes) { From 842ef86e73efc3819b61289db0cba5e6c66ff364 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Mon, 9 Jun 2014 19:51:32 +1200 Subject: [PATCH 5/6] Don't reset the inventory of dead players --- src/g_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 65fa5733d4..b84ac890d9 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1307,7 +1307,7 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags) } // Clears the entire inventory and gives back the defaults for starting a game - if (flags & CHANGELEVEL_RESETINVENTORY) + if ((flags & CHANGELEVEL_RESETINVENTORY) && p->playerstate != PST_DEAD) { p->mo->ClearInventory(); p->mo->GiveDefaultInventory(); From 2d8813a1650e6bb2e12a13e275b75444523409f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Jun 2014 18:58:25 +0200 Subject: [PATCH 6/6] - fixed dynamic light definition for Hexen's blue candle. --- wadsrc_lights/static/hexndefs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc_lights/static/hexndefs.txt b/wadsrc_lights/static/hexndefs.txt index ae062bd855..6c03da6db9 100644 --- a/wadsrc_lights/static/hexndefs.txt +++ b/wadsrc_lights/static/hexndefs.txt @@ -1324,7 +1324,7 @@ flickerlight2 BCANDLE object ZBlueCandle { - frame CAND { light BCANDLE } + frame BCAN { light BCANDLE } } // Small flame