From 4999c3b4aa890ce2e21648a3e6c1755c19dc0d1e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 9 Sep 2006 01:14:13 +0000 Subject: [PATCH] - Fixed: Weapons did not give you double ammo at baby and nightmare skills. - Fixed: SetTexture() in p_setup.cpp assumed that all color values were six characters. Although this was the intended way to specify colors, earlier versions did no error checking, so other lengths worked too. - Fixed: FPatchTexture waited until MakeTexture() to call CalcBitSize(), so the width and height bit sizes weren't available when using it as a source for a warp texture. - Fixed: R_InitSkyMap() should only warn about two sky textures not being the same height when they are used as part of a double sky. - Added a NULL state check in AActor::Tick() before advancing the current state. Note that this should not happen, so there's an assert there for the debug build as well as a regular check for the release build. SVN r324 (trunk) --- docs/rh-log.txt | 14 ++++++++++++++ src/g_shared/a_pickups.cpp | 2 +- src/g_shared/a_weapons.cpp | 17 +++++++++++++++++ src/p_mobj.cpp | 13 +++++++++++++ src/p_setup.cpp | 2 +- src/r_sky.cpp | 2 +- src/textures/patchtexture.cpp | 10 +--------- src/textures/warptexture.cpp | 9 ++++----- 8 files changed, 52 insertions(+), 17 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4f428c4db..05a1445b6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,17 @@ +September 8, 2006 +- Fixed: Weapons did not give you double ammo at baby and nightmare skills. +- Fixed: SetTexture() in p_setup.cpp assumed that all color values were + six characters. Although this was the intended way to specify colors, + earlier versions did no error checking, so other lengths worked too. +- Fixed: FPatchTexture waited until MakeTexture() to call CalcBitSize(), + so the width and height bit sizes weren't available when using it as a + source for a warp texture. +- Fixed: R_InitSkyMap() should only warn about two sky textures not being + the same height when they are used as part of a double sky. +- Added a NULL state check in AActor::Tick() before advancing the current + state. Note that this should not happen, so there's an assert there for + the debug build as well as a regular check for the release build. + September 1, 2006 - Version bump to 2.1.5. - Fixed: P_LoadSegs() checked for invalid vertices too late. diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index a4893a565..93b490f9f 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -79,7 +79,7 @@ bool AAmmo::HandlePickup (AInventory *item) if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife)) { if (gameinfo.gametype & (GAME_Doom|GAME_Strife)) - receiving <<= 1; + receiving += receiving; else receiving += receiving >> 1; } diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 195e98590..c1ef7544f 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -202,6 +202,7 @@ AInventory *AWeapon::CreateTossable () { SisterWeapon->Destroy (); } + // To avoid exploits, the tossed weapon must not have any ammo. copy->AmmoGive1 = 0; copy->AmmoGive2 = 0; } @@ -250,6 +251,14 @@ AAmmo *AWeapon::AddAmmo (AActor *other, const PClass *ammotype, int amount) { return NULL; } + // extra ammo in baby mode and nightmare mode + if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife)) + { + if (gameinfo.gametype & (GAME_Doom|GAME_Strife)) + amount += amount; + else + amount += amount >> 1; + } ammo = static_cast(other->FindInventory (ammotype)); if (ammo == NULL) { @@ -280,6 +289,14 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount) { if (ammo != NULL && ammo->Amount < ammo->MaxAmount) { + // extra ammo in baby mode and nightmare mode + if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife)) + { + if (gameinfo.gametype & (GAME_Doom|GAME_Strife)) + amount += amount; + else + amount += amount >> 1; + } ammo->Amount += amount; if (ammo->Amount > ammo->MaxAmount) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c1eb16534..71537c7ef 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2479,6 +2479,13 @@ void AActor::Tick () AActor *onmo; int i; + assert (state != NULL); + if (state == NULL) + { + Destroy(); + return; + } + PrevX = x; PrevY = y; PrevZ = z; @@ -2895,6 +2902,12 @@ void AActor::Tick () // of 0 tics work as expected. if (tics <= 0) { + assert (state != NULL); + if (state == NULL) + { + Destroy(); + return; + } if (!SetState (state->GetNextState())) return; // freed itself } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 61d1ceafe..1824d5149 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -428,7 +428,7 @@ static void SetTextureNoErr (short *texture, DWORD *color, char *name8, bool *va name2[8] = 0; *color = strtoul (name2, &stop, 16); *texture = 0; - *validcolor = (*stop == 0) && (stop == name2 + 6); + *validcolor = (*stop == 0) && (stop >= name2 + 2) && (stop <= name2 + 6); } else { diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 64179ea69..ec719f739 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -79,7 +79,7 @@ void R_InitSkyMap () if (skytex1 == NULL) return; - if (skytex1->GetHeight() != skytex2->GetHeight()) + if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetHeight() != skytex2->GetHeight()) { Printf (TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n"); sky2texture = sky1texture; diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index d0289dd34..056ac032b 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -102,6 +102,7 @@ FPatchTexture::FPatchTexture (int lumpnum, patch_t * header) Height = header->height; LeftOffset = header->leftoffset; TopOffset = header->topoffset; + CalcBitSize (); } FPatchTexture::~FPatchTexture () @@ -185,15 +186,6 @@ void FPatchTexture::MakeTexture () Printf (PRINT_BOLD, "Patch %s is too big.\n", Name); } - if (Width == 0xFFFF) - { - Width = LittleShort(patch->width); - Height = LittleShort(patch->height); - LeftOffset = LittleShort(patch->leftoffset); - TopOffset = LittleShort(patch->topoffset); - } - CalcBitSize (); - // Add a little extra space at the end if the texture's height is not // a power of 2, in case somebody accidentally makes it repeat vertically. int numpix = Width * Height + (1 << HeightBits) - Height; diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index d87e3e737..87e8691a0 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -214,9 +214,10 @@ void FWarp2Texture::MakeTexture (DWORD time) } DWORD timebase = time * 40 / 28; - for (x = xsize-1; x >= 0; x--) + for (x = 0; x < xsize; ++x) { - for (y = ysize-1; y >= 0; y--) + BYTE *dest = Pixels + (x << ybits); + for (y = 0; y < ysize; ++y) { int xt = (x + 128 + ((finesine[(y*128 + timebase*5 + 900) & FINEMASK]*2)>>FRACBITS) @@ -224,9 +225,7 @@ void FWarp2Texture::MakeTexture (DWORD time) int yt = (y + 128 + ((finesine[(y*128 + timebase*3 + 700) & FINEMASK]*2)>>FRACBITS) + ((finesine[(x*256 + timebase*4 + 1200) & FINEMASK]*2)>>FRACBITS)) & ymask; - const BYTE *source = otherpix + (xt << ybits) + yt; - BYTE *dest = Pixels + (x << ybits) + y; - *dest = *source; + *dest++ = otherpix[(xt << ybits) + yt]; } } }