From 06630b0feebd35747699f9d054e6c2eb67d23763 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Sep 2006 08:55:47 +0000 Subject: [PATCH] - Added support for scaled textures to DCanvas::DrawTexture. - Changed deh.MaxHealth use to be consistent with other source ports. - Added NULL pointer checks to APlayerPawn's state set functions. If these remove the player from the game a crash is the inevitable result. SVN r325 (trunk) --- docs/rh-log.txt | 6 ++++++ src/d_dehacked.cpp | 10 +++------- src/p_map.cpp | 1 + src/p_user.cpp | 6 +++--- src/r_data.cpp | 8 ++++---- src/v_draw.cpp | 41 ++++++++++++++++++++++------------------- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 05a1445b6e..17334ed9ea 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,9 @@ +September 9, 2006 (Changes by Graf Zahl) +- Added support for scaled textures to DCanvas::DrawTexture. +- Changed deh.MaxHealth use to be consistent with other source ports. +- Added NULL pointer checks to APlayerPawn's state set functions. If these + remove the player from the game a crash is the inevitable result. + 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 diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 7888c2d8e0..fb0e1ef469 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -129,7 +129,7 @@ DehInfo deh = { 100, // .StartHealth 50, // .StartBullets - -1, // .MaxHealth + 100, // .MaxHealth 200, // .MaxArmor 1, // .GreenAC 2, // .BlueAC @@ -1649,9 +1649,9 @@ static int PatchMisc (int dummy) AHealth *health; health = static_cast (GetDefaultByName ("HealthBonus")); - if (deh.MaxHealth != -1 && health!=NULL) + if (health!=NULL) { - health->MaxAmount = deh.MaxHealth; + health->MaxAmount = 2 * deh.MaxHealth; } health = static_cast (GetDefaultByName ("Soulsphere")); @@ -2542,10 +2542,6 @@ void FinishDehPatch () DPrintf ("%s replaces %s\n", subclass->TypeName.GetChars(), type->TypeName.GetChars()); } - // Since deh.MaxHealth was used incorrectly this can only be set - // after finishing with the DEH stuff. - if (deh.MaxHealth == -1) deh.MaxHealth = 100; - // Now that all Dehacked patches have been processed, it's okay to free StateMap. if (StateMap != NULL) { diff --git a/src/p_map.cpp b/src/p_map.cpp index c75f927cfd..e6d677db19 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1426,6 +1426,7 @@ AActor *P_CheckOnmobj (AActor *thing) oldz = thing->z; P_FakeZMovement (thing); good = P_TestMobjZ (thing, false); + thing->z = oldz; return good ? NULL : onmobj; diff --git a/src/p_user.cpp b/src/p_user.cpp index 8dd8e16228..01e4545786 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -838,18 +838,18 @@ void APlayerPawn::PlayIdle () void APlayerPawn::PlayRunning () { - if (state == SpawnState) + if (InStateSequence(state, SpawnState) && SeeState != NULL) SetState (SeeState); } void APlayerPawn::PlayAttacking () { - SetState (MissileState); + if (MissileState != NULL) SetState (MissileState); } void APlayerPawn::PlayAttacking2 () { - SetState (MeleeState); + if (MeleeState != NULL) SetState (MeleeState); } void APlayerPawn::ThrowPoisonBag () diff --git a/src/r_data.cpp b/src/r_data.cpp index 5b60c59dfd..767dc5f09d 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -388,8 +388,8 @@ void FTextureManager::LoadHiresTex() // 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); + newtex->LeftOffset = MulScale3(oldtex->LeftOffset, newtex->ScaleX); + newtex->TopOffset = MulScale3(oldtex->TopOffset, newtex->ScaleY); ReplaceTexture(tex, newtex, true); } } @@ -417,8 +417,8 @@ void FTextureManager::LoadHiresTex() // Replace the entire texture and adjust the scaling and offset factors. newtex->ScaleX = 8 * width / newtex->GetWidth(); newtex->ScaleY = 8 * height / newtex->GetHeight(); - newtex->LeftOffset = Scale(newtex->LeftOffset, newtex->ScaleX, 8); - newtex->TopOffset = Scale(newtex->TopOffset, newtex->ScaleY, 8); + newtex->LeftOffset = MulScale3(newtex->LeftOffset, newtex->ScaleX); + newtex->TopOffset = MulScale3(newtex->TopOffset, newtex->ScaleY); memcpy(newtex->Name, src, sizeof(newtex->Name)); int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index cf9124d1ee..845006836a 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -71,16 +71,19 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ return; } + int texwidth = img->GetScaledWidth(); + int texheight = img->GetScaledHeight(); + int windowleft = 0; - int windowright = img->GetWidth(); + int windowright = texwidth; int dclip = this->GetHeight(); int uclip = 0; int lclip = 0; int rclip = this->GetWidth(); int destwidth = windowright << FRACBITS; - int destheight = img->GetHeight() << FRACBITS; - int top = img->TopOffset; - int left = img->LeftOffset; + int destheight = texheight << FRACBITS; + int top = img->GetScaledTopOffset(); + int left = img->GetScaledLeftOffset(); fixed_t alpha = FRACUNIT; int fillcolor = -1; const BYTE *translation = NULL; @@ -137,8 +140,8 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ { x0 = (x0 - 160*FRACUNIT) * CleanXfac + (Width * (FRACUNIT/2)); y0 = (y0 - 100*FRACUNIT) * CleanYfac + (Height * (FRACUNIT/2)); - destwidth = img->GetWidth() * CleanXfac * FRACUNIT; - destheight = img->GetHeight() * CleanYfac * FRACUNIT; + destwidth = texwidth * CleanXfac * FRACUNIT; + destheight = texheight * CleanYfac * FRACUNIT; } break; @@ -146,8 +149,8 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ boolval = va_arg (tags, BOOL); if (boolval) { - destwidth = img->GetWidth() * CleanXfac * FRACUNIT; - destheight = img->GetHeight() * CleanYfac * FRACUNIT; + destwidth = texwidth * CleanXfac * FRACUNIT; + destheight = texheight * CleanYfac * FRACUNIT; } break; @@ -176,8 +179,8 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ y0 *= CleanYfac; if (ybot) y0 = Height * FRACUNIT + y0; - destwidth = img->GetWidth() * CleanXfac * FRACUNIT; - destheight = img->GetHeight() * CleanYfac * FRACUNIT; + destwidth = texwidth * CleanXfac * FRACUNIT; + destheight = texheight * CleanYfac * FRACUNIT; } else { @@ -230,16 +233,16 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ case DTA_CenterOffset: if (va_arg (tags, int)) { - left = img->GetWidth() / 2; - top = img->GetHeight() / 2; + left = texwidth / 2; + top = texheight / 2; } break; case DTA_CenterBottomOffset: if (va_arg (tags, int)) { - left = img->GetWidth() / 2; - top = img->GetHeight(); + left = texwidth / 2; + top = texheight; } break; @@ -395,8 +398,8 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); - x0 -= Scale (left, destwidth, img->GetWidth()); - y0 -= Scale (top, destheight, img->GetHeight()); + x0 -= Scale (left, destwidth, texwidth); + y0 -= Scale (top, destheight, texheight); if (mode != DontDraw) { @@ -461,12 +464,12 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x0, int y0, DWORD tags_ } dc_x = x0 >> FRACBITS; - if (windowleft > 0 || windowright < img->GetWidth()) + if (windowleft > 0 || windowright < texwidth) { - fixed_t xscale = destwidth / img->GetWidth(); + fixed_t xscale = destwidth / texwidth; dc_x += (windowleft * xscale) >> FRACBITS; frac += windowleft << FRACBITS; - x2 -= ((img->GetWidth() - windowright) * xscale) >> FRACBITS; + x2 -= ((texwidth - windowright) * xscale) >> FRACBITS; } if (dc_x < lclip) {