diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 4826a6ca4..5d4320a4f 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2439,32 +2439,7 @@ static void FS_GiveInventory (AActor *actor, const char * type, int amount) return; } - AWeapon *savedPendingWeap = actor->player != NULL? actor->player->PendingWeapon : NULL; - bool hadweap = actor->player != NULL ? actor->player->ReadyWeapon != NULL : true; - - AInventory *item = static_cast(Spawn (info)); - - // This shouldn't count for the item statistics! - item->ClearCounters(); - if (info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)) || - info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - item->Amount = amount; - } - if (!item->CallTryPickup (actor)) - { - item->Destroy (); - } - // If the item was a weapon, don't bring it up automatically - // unless the player was not already using a weapon. - if (savedPendingWeap != NULL && hadweap) - { - actor->player->PendingWeapon = savedPendingWeap; - } + actor->GiveInventory(info, amount); } //============================================================================ diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index c9b478161..d7622b3d4 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -575,47 +575,6 @@ const char *cht_Morph (player_t *player, PClassPlayerPawn *morphclass, bool quic return ""; } -void GiveSpawner (player_t *player, PClassInventory *type, int amount) -{ - if (player->mo == NULL || player->health <= 0) - { - return; - } - - AInventory *item = static_cast - (Spawn (type, player->mo->Pos(), NO_REPLACE)); - if (item != NULL) - { - if (amount > 0) - { - if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup))) - { - if (static_cast(item)->SaveAmount != 0) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - static_cast(item)->SaveAmount *= amount; - } - } - else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - item->Amount = MIN (amount, item->MaxAmount); - } - } - item->ClearCounters(); - if (!item->CallTryPickup (player->mo)) - { - item->Destroy (); - } - } -} - void cht_Give (player_t *player, const char *name, int amount) { enum { ALL_NO, ALL_YES, ALL_YESYES } giveall; @@ -673,7 +632,7 @@ void cht_Give (player_t *player, const char *name, int amount) type = PClass::FindActor(gameinfo.backpacktype); if (type != NULL) { - GiveSpawner (player, static_cast(type), 1); + player->mo->GiveInventory(static_cast(type), 1, true); } if (!giveall) @@ -778,7 +737,7 @@ void cht_Give (player_t *player, const char *name, int amount) AWeapon *def = (AWeapon*)GetDefaultByType (type); if (giveall == ALL_YESYES || !(def->WeaponFlags & WIF_CHEATNOTWEAPON)) { - GiveSpawner (player, static_cast(type), 1); + player->mo->GiveInventory(static_cast(type), 1, true); } } } @@ -805,7 +764,7 @@ void cht_Give (player_t *player, const char *name, int amount) // Do not give replaced items unless using "give everything" if (giveall == ALL_YESYES || type->GetReplacement() == type) { - GiveSpawner (player, static_cast(type), amount <= 0 ? def->MaxAmount : amount); + player->mo->GiveInventory(static_cast(type), amount <= 0 ? def->MaxAmount : amount, true); } } } @@ -827,7 +786,7 @@ void cht_Give (player_t *player, const char *name, int amount) // Do not give replaced items unless using "give everything" if (giveall == ALL_YESYES || type->GetReplacement() == type) { - GiveSpawner (player, static_cast(type), amount <= 0 ? def->MaxAmount : amount); + player->mo->GiveInventory(static_cast(type), amount <= 0 ? def->MaxAmount : amount, true); } } } @@ -847,7 +806,7 @@ void cht_Give (player_t *player, const char *name, int amount) } else { - GiveSpawner (player, static_cast(type), amount); + player->mo->GiveInventory(static_cast(type), amount, true); } return; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e56aeb596..0437bc9f0 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1142,48 +1142,6 @@ static void ClearInventory (AActor *activator) } } -//============================================================================ -// -// DoGiveInv -// -// Gives an item to a single actor. -// -//============================================================================ - -static void DoGiveInv (AActor *actor, PClassActor *info, int amount) -{ - AWeapon *savedPendingWeap = actor->player != NULL - ? actor->player->PendingWeapon : NULL; - bool hadweap = actor->player != NULL ? actor->player->ReadyWeapon != NULL : true; - - AInventory *item = static_cast(Spawn (info)); - - // This shouldn't count for the item statistics! - item->ClearCounters(); - if (info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup))) - { - static_cast(item)->SaveAmount *= amount; - } - else if (info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - item->Amount = amount; - } - if (!item->CallTryPickup (actor)) - { - item->Destroy (); - } - // If the item was a weapon, don't bring it up automatically - // unless the player was not already using a weapon. - if (savedPendingWeap != NULL && hadweap && actor->player != NULL) - { - actor->player->PendingWeapon = savedPendingWeap; - } -} - //============================================================================ // // GiveInventory @@ -1218,12 +1176,12 @@ static void GiveInventory (AActor *activator, const char *type, int amount) for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) - DoGiveInv (players[i].mo, info, amount); + players[i].mo->GiveInventory(static_cast(info), amount); } } else { - DoGiveInv (activator, info, amount); + activator->GiveInventory(static_cast(info), amount); } } diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index e8aaa6912..64fe2cbab 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -102,8 +102,6 @@ struct TeaserSpeech static FRandom pr_randomspeech("RandomSpeech"); -void GiveSpawner (player_t *player, PClassActor *type); - TArray StrifeDialogues; typedef TMap FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)