From d816747c7e6736c6d6338c0b4ddcecfa9da3113f Mon Sep 17 00:00:00 2001
From: Randy Heit <rheit@zdoom.fake>
Date: Fri, 25 Sep 2009 03:07:20 +0000
Subject: [PATCH] - Fixed: "give health" without an amount would set your
 health to IDDQD health   instead of the player class's maximum. - Fixed:
 A_CStaffCheck() assumed the player's max health was 100 instead   of getting
 checking for the true maximum.

SVN r1876 (trunk)
---
 docs/rh-log.txt               |  4 ++++
 src/g_hexen/a_clericstaff.cpp |  9 +++++----
 src/m_cheat.cpp               | 14 +++++++++-----
 src/p_lnspec.cpp              |  4 +---
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index 5d758f967..f78b398ee 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,4 +1,8 @@
 September 24, 2009
+- Fixed: "give health" without an amount would set your health to IDDQD health
+  instead of the player class's maximum.
+- Fixed: A_CStaffCheck() assumed the player's max health was 100 instead
+  of getting checking for the true maximum.
 - Changed P_XYMovement() to not call P_SlideMove() if the act of being
   blocked changed the actor's velocity. I'm not entirely happy with this,
   but it gets push-activated force fields to work.
diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp
index 220dc55e7..38018071c 100644
--- a/src/g_hexen/a_clericstaff.cpp
+++ b/src/g_hexen/a_clericstaff.cpp
@@ -46,9 +46,9 @@ int ACStaffMissile::DoSpecialDamage (AActor *target, int damage)
 
 DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
 {
-	AActor *pmo;
+	APlayerPawn *pmo;
 	int damage;
-	int newLife;
+	int newLife, max;
 	angle_t angle;
 	int slope;
 	int i;
@@ -63,6 +63,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
 
 	pmo = player->mo;
 	damage = 20+(pr_staffcheck()&15);
+	max = pmo->GetMaxHealth();
 	for (i = 0; i < 3; i++)
 	{
 		angle = pmo->angle+i*(ANG45/16);
@@ -76,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
 				&& (!(linetarget->flags2&(MF2_DORMANT+MF2_INVULNERABLE))))
 			{
 				newLife = player->health+(damage>>3);
-				newLife = newLife > 100 ? 100 : newLife;
+				newLife = newLife > max ? max : newLife;
 				if (newLife > player->health)
 				{
 					pmo->health = player->health = newLife;
@@ -99,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
 			if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
 			{
 				newLife = player->health+(damage>>4);
-				newLife = newLife > 100 ? 100 : newLife;
+				newLife = newLife > max ? max : newLife;
 				pmo->health = player->health = newLife;
 				P_SetPsprite (player, ps_weapon, weapon->FindState ("Drain"));
 			}
diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp
index bcf36d45d..508043f47 100644
--- a/src/m_cheat.cpp
+++ b/src/m_cheat.cpp
@@ -52,7 +52,7 @@
 
 void cht_DoCheat (player_t *player, int cheat)
 {
-	static const PClass *BeholdPowers[9] =
+	static const PClass * const BeholdPowers[9] =
 	{
 		RUNTIME_CLASS(APowerInvulnerable),
 		RUNTIME_CLASS(APowerStrength),
@@ -631,10 +631,14 @@ void cht_Give (player_t *player, const char *name, int amount)
 		}
 		else
 		{
-			if (player->mo)
-				player->mo->health = deh.GodHealth;
-	  
-			player->health = deh.GodHealth;
+			if (player->mo != NULL)
+			{
+				player->health = player->mo->health = player->mo->GetMaxHealth();
+			}
+			else
+			{
+				player->health = deh.GodHealth;
+			}
 		}
 
 		if (!giveall)
diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp
index 14585e016..17333f7d7 100644
--- a/src/p_lnspec.cpp
+++ b/src/p_lnspec.cpp
@@ -2796,9 +2796,7 @@ FUNC(LS_ForceField)
 	if (it != NULL)
 	{
 		P_DamageMobj (it, NULL, NULL, 16, NAME_None);
-		angle_t an = (it->angle + ANGLE_180) >> ANGLETOFINESHIFT;
-		it->velx = FixedMul(0x7D000, finecosine[an]);
-		it->vely = FixedMul(0x7D000, finesine[an]);
+		P_ThrustMobj (it, it->angle + ANGLE_180, 0x7D000);
 	}
 	return true;
 }