From 6fe9c98b47d10bd32305f0bffffaad000d98ecde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Oct 2006 20:32:16 +0000 Subject: [PATCH] - Fixed: Hires texture replacements and auto-scaled flats require the bWorldPanning flag. Also added some NULL pointer checks to the hires texture loading code. - Added Sector_SetFloorScale2 and Sector_SetCeilingScale2 line specials. They are mostly the same as Sector_Set*Scale but take fixed point parameters. This makes them easier to use and more precise than the old ones which offered very small fractional precision. - Changed Thing_Deactivate so that passing a tid of 0 deactivates the calling actor. - Added MeansOfDeath parameter to DamageThing. SVN r350 (trunk) --- docs/rh-log.txt | 12 ++++++ src/p_lnspec.cpp | 87 +++++++++++++++++++++++++++++++--------- src/p_lnspec.h | 5 ++- src/r_data.cpp | 74 ++++++++++++++++++++-------------- src/textures/texture.cpp | 12 +++++- 5 files changed, 137 insertions(+), 53 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 19799c2a4..d37cf5165 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,15 @@ +October 5, 2006 (Changes by Graf Zahl) +- Fixed: Hires texture replacements and auto-scaled flats require the + bWorldPanning flag. Also added some NULL pointer checks to the + hires texture loading code. +- Added Sector_SetFloorScale2 and Sector_SetCeilingScale2 line specials. + They are mostly the same as Sector_Set*Scale but take fixed point parameters. + This makes them easier to use and more precise than the old ones which + offered very small fractional precision. +- Changed Thing_Deactivate so that passing a tid of 0 deactivates the calling + actor. +- Added MeansOfDeath parameter to DamageThing. + October 4, 2006 - Added alias parameter substitution. Instances of %x in the alias command string will be replaced with parameter x when the alias is executed. diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index a3ed2e8ee..be6a53bac 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -916,7 +916,7 @@ FUNC(LS_Thing_ChangeTID) } FUNC(LS_DamageThing) -// DamageThing (damage) +// DamageThing (damage, mod) { if (it) { @@ -935,11 +935,11 @@ FUNC(LS_DamageThing) } else if (arg0 > 0) { - P_DamageMobj (it, NULL, NULL, arg0, MOD_UNKNOWN); + P_DamageMobj (it, NULL, NULL, arg0, arg1); } else { // If zero damage, guarantee a kill - P_DamageMobj (it, NULL, NULL, 1000000, MOD_UNKNOWN); + P_DamageMobj (it, NULL, NULL, 1000000, arg1); } } @@ -1013,22 +1013,31 @@ FUNC(LS_Thing_Activate) FUNC(LS_Thing_Deactivate) // Thing_Deactivate (tid) { - AActor *actor; - FActorIterator iterator (arg0); - int count = 0; - - actor = iterator.Next (); - while (actor) + if (arg0 != 0) { - // Actor might removes itself as part of deactivation, so get next - // one before we activate it. - AActor *temp = iterator.Next (); - actor->Deactivate (it); - actor = temp; - count++; + AActor *actor; + FActorIterator iterator (arg0); + int count = 0; + + actor = iterator.Next (); + while (actor) + { + // Actor might removes itself as part of deactivation, so get next + // one before we activate it. + AActor *temp = iterator.Next (); + actor->Deactivate (it); + actor = temp; + count++; + } + + return count != 0; } - - return count != 0; + else if (it != NULL) + { + it->Deactivate(it); + return true; + } + return false; } static void RemoveThing(AActor * actor) @@ -2068,6 +2077,46 @@ FUNC(LS_Sector_SetCeilingScale) return true; } +FUNC(LS_Sector_SetFloorScale2) +// Sector_SetFloorScale2 (tag, x-factor, y-factor) +{ + int secnum = -1; + + if (arg1) + arg1 = FixedDiv (FRACUNIT, arg1); + if (arg2) + arg2 = FixedDiv (FRACUNIT, arg2); + + while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + { + if (arg1) + sectors[secnum].floor_xscale = arg1; + if (arg2) + sectors[secnum].floor_yscale = arg2; + } + return true; +} + +FUNC(LS_Sector_SetCeilingScale2) +// Sector_SetFloorScale2 (tag, x-factor, y-factor) +{ + int secnum = -1; + + if (arg1) + arg1 = FixedDiv (FRACUNIT, arg1); + if (arg2) + arg2 = FixedDiv (FRACUNIT, arg2); + + while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + { + if (arg1) + sectors[secnum].ceiling_xscale = arg1; + if (arg2) + sectors[secnum].ceiling_yscale = arg2; + } + return true; +} + FUNC(LS_Sector_SetFloorScale) // Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac) { @@ -2829,8 +2878,8 @@ lnSpecFunc LineSpecials[256] = LS_NOP, // 167 LS_NOP, // 168 LS_NOP, // 169 - LS_NOP, // 170 - LS_NOP, // 171 + LS_Sector_SetCeilingScale2, + LS_Sector_SetFloorScale2, LS_Plat_UpNearestWaitDownStay, LS_NoiseAlert, LS_SendToCommunicator, diff --git a/src/p_lnspec.h b/src/p_lnspec.h index 2b1ea13f5..82f0bc652 100644 --- a/src/p_lnspec.h +++ b/src/p_lnspec.h @@ -190,12 +190,15 @@ typedef enum { Sector_ChangeSound = 140, - // GZDoom/Vavoom specials (put here so that they don't accidentally redefined) + // GZDoom/Vavoom specials (put here so that they don't get accidentally redefined) Sector_SetPlaneReflection = 159, Sector_Set3DFloor = 160, Sector_SetContents = 161, // [RH] Begin new specials for ZDoom + Sector_SetCeilingScale2 = 170, + Sector_SetFloorScale2 = 171, + Plat_UpNearestWaitDownStay = 172, NoiseAlert = 173, SendToCommunicator = 174, diff --git a/src/r_data.cpp b/src/r_data.cpp index f67a6606f..1400f47b1 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -317,24 +317,28 @@ void FTextureManager::AddHiresTextures () if (Wads.CheckNumForName (name, ns_hires) == firsttx) { FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); - int oldtexno = CheckForTexture(name, FTexture::TEX_Wall, TEXMAN_Overridable|TEXMAN_TryAny); - - if (oldtexno<0) + if (newtex != NULL) { - // A texture with this name does not yet exist - newtex->UseType=FTexture::TEX_Override; - AddTexture(newtex); - } - else - { - FTexture * oldtex = Textures[oldtexno].Texture; - - // Replace the entire texture and adjust the scaling and offset factors. - newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetWidth(); - newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetHeight(); - newtex->LeftOffset = Scale(oldtex->LeftOffset, newtex->ScaleX, 8); - newtex->TopOffset = Scale(oldtex->TopOffset, newtex->ScaleY, 8); - ReplaceTexture(oldtexno, newtex, true); + int oldtexno = CheckForTexture(name, FTexture::TEX_Wall, TEXMAN_Overridable|TEXMAN_TryAny); + + newtex->bWorldPanning = true; + if (oldtexno<0) + { + // A texture with this name does not yet exist + newtex->UseType=FTexture::TEX_Override; + AddTexture(newtex); + } + else + { + FTexture * oldtex = Textures[oldtexno].Texture; + + // Replace the entire texture and adjust the scaling and offset factors. + newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetWidth(); + newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetHeight(); + newtex->LeftOffset = Scale(oldtex->LeftOffset, newtex->ScaleX, 8); + newtex->TopOffset = Scale(oldtex->TopOffset, newtex->ScaleY, 8); + ReplaceTexture(oldtexno, newtex, true); + } } } } @@ -385,12 +389,16 @@ void FTextureManager::LoadHiresTex() FTexture * oldtex = TexMan[tex]; FTexture * newtex = FTexture::CreateTexture (lumpnum, FTexture::TEX_Any); - // Replace the entire texture and adjust the scaling and offset factors. - newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetScaledWidth(); - newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetScaledHeight(); - newtex->LeftOffset = MulScale3(oldtex->GetScaledLeftOffset(), newtex->ScaleX); - newtex->TopOffset = MulScale3(oldtex->GetScaledTopOffset(), newtex->ScaleY); - ReplaceTexture(tex, newtex, true); + if (newtex != NULL) + { + // Replace the entire texture and adjust the scaling and offset factors. + newtex->bWorldPanning = true; + newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetScaledWidth(); + newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetScaledHeight(); + newtex->LeftOffset = MulScale3(oldtex->GetScaledLeftOffset(), newtex->ScaleX); + newtex->TopOffset = MulScale3(oldtex->GetScaledTopOffset(), newtex->ScaleY); + ReplaceTexture(tex, newtex, true); + } } } else if (SC_Compare("define")) // define a new "fake" texture @@ -414,14 +422,18 @@ void FTextureManager::LoadHiresTex() { FTexture *newtex = FTexture::CreateTexture(lumpnum, FTexture::TEX_Override); - // Replace the entire texture and adjust the scaling and offset factors. - newtex->ScaleX = 8 * newtex->GetWidth() / width; - newtex->ScaleY = 8 * newtex->GetHeight() / height; - memcpy(newtex->Name, src, sizeof(newtex->Name)); - - int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override); - if (oldtex>=0) TexMan.ReplaceTexture(oldtex, newtex, true); - else TexMan.AddTexture(newtex); + if (newtex != NULL) + { + // Replace the entire texture and adjust the scaling and offset factors. + newtex->bWorldPanning = true; + newtex->ScaleX = 8 * newtex->GetWidth() / width; + newtex->ScaleY = 8 * newtex->GetHeight() / height; + memcpy(newtex->Name, src, sizeof(newtex->Name)); + + int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override); + if (oldtex>=0) TexMan.ReplaceTexture(oldtex, newtex, true); + else TexMan.AddTexture(newtex); + } } //else Printf("Unable to define hires texture '%s'\n", tex->Name); } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 1a8808f6f..01c1bc13d 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -94,8 +94,16 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype) int h = tex->GetHeight(); // Auto-scale flats with dimensions 128x128 and 256x256 - if (w==128 && h==128) tex->ScaleX = tex->ScaleY = 16; - else if (w==256 && h==256) tex->ScaleX = tex->ScaleY = 32; + if (w==128 && h==128) + { + tex->ScaleX = tex->ScaleY = 16; + tex->bWorldPanning = true; + } + else if (w==256 && h==256) + { + tex->ScaleX = tex->ScaleY = 32; + tex->bWorldPanning = true; + } } return tex; }