From 8fede44c3dda241e7c8096612e2cb70482ddedb3 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 15 Dec 2016 11:37:05 -0500 Subject: [PATCH 1/2] - fixed: Some RenderStyles would crash ZDoom. --- src/r_draw.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 12aa3484bc..a461e1877d 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -175,6 +175,7 @@ namespace swrenderer { identitymap[i] = i; } + identitycolormap.Maps = identitymap; } void R_InitFuzzTable(int fuzzoff) From 9ef551b84af4392566658032217c1c851421c9ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 16 Dec 2016 00:26:51 +0100 Subject: [PATCH 2/2] - fixed: Start items for players were never actually checked for their type and could cause crashes if non-inventories were given. --- src/p_user.cpp | 59 ++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index e2d799834e..47c64d0637 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1366,42 +1366,49 @@ void APlayerPawn::GiveDefaultInventory () PClassActor *ti = PClass::FindActor (di->Name); if (ti) { - AInventory *item = FindInventory (ti); - if (item != NULL) + if (!ti->IsDescendantOf(RUNTIME_CLASS(AInventory))) { - item->Amount = clamp( - item->Amount + (di->Amount ? di->Amount : ((AInventory *)item->GetDefault ())->Amount), - 0, item->MaxAmount); + Printf(TEXTCOLOR_ORANGE "%s is not an inventory item and cannot be given to a player as start item.\n", ti->TypeName.GetChars()); } else { - item = static_cast(Spawn (ti)); - item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here - item->Amount = di->Amount; - if (item->IsKindOf (RUNTIME_CLASS (AWeapon))) + AInventory *item = FindInventory(ti); + if (item != NULL) { - // To allow better control any weapon is emptied of - // ammo before being given to the player. - static_cast(item)->AmmoGive1 = - static_cast(item)->AmmoGive2 = 0; + item->Amount = clamp( + item->Amount + (di->Amount ? di->Amount : ((AInventory *)item->GetDefault())->Amount), + 0, item->MaxAmount); } - AActor *check; - if (!item->CallTryPickup(this, &check)) + else { - if (check != this) + item = static_cast(Spawn(ti)); + item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here + item->Amount = di->Amount; + if (item->IsKindOf(RUNTIME_CLASS(AWeapon))) { - // Player was morphed. This is illegal at game start. - // This problem is only detectable when it's too late to do something about it... - I_Error("Cannot give morph items when starting a game"); + // To allow better control any weapon is emptied of + // ammo before being given to the player. + static_cast(item)->AmmoGive1 = + static_cast(item)->AmmoGive2 = 0; + } + AActor *check; + if (!item->CallTryPickup(this, &check)) + { + if (check != this) + { + // Player was morphed. This is illegal at game start. + // This problem is only detectable when it's too late to do something about it... + I_Error("Cannot give morph items when starting a game"); + } + item->Destroy(); + item = NULL; } - item->Destroy (); - item = NULL; } - } - if (item != NULL && item->IsKindOf (RUNTIME_CLASS (AWeapon)) && - static_cast(item)->CheckAmmo(AWeapon::EitherFire, false)) - { - player->ReadyWeapon = player->PendingWeapon = static_cast (item); + if (item != NULL && item->IsKindOf(RUNTIME_CLASS(AWeapon)) && + static_cast(item)->CheckAmmo(AWeapon::EitherFire, false)) + { + player->ReadyWeapon = player->PendingWeapon = static_cast (item); + } } } di = di->Next;