Merge branch 'Inventory.Transfer-flag' of https://github.com/Edward850/zdoom

This commit is contained in:
Christoph Oelckers 2015-02-07 13:12:15 +01:00
commit 2d4299608c
9 changed files with 51 additions and 10 deletions

View file

@ -1372,6 +1372,8 @@ bool AInventory::TryPickupRestricted (AActor *&toucher)
bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
{ {
TObjPtr<AInventory> Invstack = Inventory; // A pointer of the inventories item stack.
// unmorphed versions of a currently morphed actor cannot pick up anything. // unmorphed versions of a currently morphed actor cannot pick up anything.
if (toucher->flags & MF_UNMORPHED) return false; if (toucher->flags & MF_UNMORPHED) return false;
@ -1392,7 +1394,27 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
GoAwayAndDie(); GoAwayAndDie();
} }
if (res) GiveQuest(toucher); if (res)
{
GiveQuest(toucher);
// Transfer all inventory accross that the old object had, if requested.
if ((ItemFlags & IF_TRANSFER))
{
while (Invstack)
{
AInventory* titem = Invstack;
Invstack = titem->Inventory;
if (titem->Owner == this)
{
if (!titem->CallTryPickup(toucher)) // The object no longer can exist
{
titem->Destroy();
}
}
}
}
}
return res; return res;
} }

View file

@ -136,7 +136,7 @@ enum
IF_NOSCREENFLASH = 1<<21, // No pickup flash on the player's screen IF_NOSCREENFLASH = 1<<21, // No pickup flash on the player's screen
IF_TOSSED = 1<<22, // Was spawned by P_DropItem (i.e. as a monster drop) IF_TOSSED = 1<<22, // Was spawned by P_DropItem (i.e. as a monster drop)
IF_ALWAYSRESPAWN = 1<<23, // Always respawn, regardless of dmflag IF_ALWAYSRESPAWN = 1<<23, // Always respawn, regardless of dmflag
IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper
}; };

View file

@ -196,9 +196,9 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller)
--mDesc->mSelectedItem; --mDesc->mSelectedItem;
if (mDesc->mScrollPos > 0 && if (mDesc->mScrollPos > 0 &&
mDesc->mSelectedItem == mDesc->mScrollTop + mDesc->mScrollPos) mDesc->mSelectedItem <= mDesc->mScrollTop + mDesc->mScrollPos)
{ {
mDesc->mScrollPos--; mDesc->mScrollPos = MAX(mDesc->mSelectedItem - mDesc->mScrollTop - 1, 0);
} }
if (mDesc->mSelectedItem < 0) if (mDesc->mSelectedItem < 0)

View file

@ -587,6 +587,7 @@ void AActor::RemoveInventory (AInventory *item)
*invp = item->Inventory; *invp = item->Inventory;
item->DetachFromOwner (); item->DetachFromOwner ();
item->Owner = NULL; item->Owner = NULL;
item->Inventory = NULL;
break; break;
} }
} }

View file

@ -66,10 +66,20 @@ void I_ShutdownGraphics ()
} }
if (Video) if (Video)
delete Video, Video = NULL; delete Video, Video = NULL;
SDL_QuitSubSystem (SDL_INIT_VIDEO);
} }
void I_InitGraphics () void I_InitGraphics ()
{ {
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{
I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError());
return;
}
Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver());
UCVarValue val; UCVarValue val;
val.Bool = !!Args->CheckParm ("-devparm"); val.Bool = !!Args->CheckParm ("-devparm");

View file

@ -1,4 +1,4 @@
#include <SDL_joystick.h> #include <SDL.h>
#include "doomdef.h" #include "doomdef.h"
#include "templates.h" #include "templates.h"
@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager;
void I_StartupJoysticks() void I_StartupJoysticks()
{ {
JoystickManager = new SDLInputJoystickManager(); if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0)
JoystickManager = new SDLInputJoystickManager();
} }
void I_ShutdownJoysticks() void I_ShutdownJoysticks()
{ {
delete JoystickManager; if(JoystickManager)
{
delete JoystickManager;
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
} }
void I_GetJoysticks(TArray<IJoystickConfig *> &sticks) void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)

View file

@ -265,14 +265,13 @@ int main (int argc, char **argv)
setlocale (LC_ALL, "C"); setlocale (LC_ALL, "C");
if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1) if (SDL_Init (0) < 0)
{ {
fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError()); fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
return -1; return -1;
} }
atterm (SDL_Quit); atterm (SDL_Quit);
printf("Using video driver %s\n", SDL_GetCurrentVideoDriver());
printf("\n"); printf("\n");
try try

View file

@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms)
void I_InitTimer () void I_InitTimer ()
{ {
if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0)
I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError());
I_GetTime = I_GetTimeSelect; I_GetTime = I_GetTimeSelect;
I_WaitForTic = I_WaitForTicSelect; I_WaitForTic = I_WaitForTicSelect;
I_FreezeTime = I_FreezeTimeSelect; I_FreezeTime = I_FreezeTimeSelect;
@ -202,5 +205,5 @@ void I_InitTimer ()
void I_ShutdownTimer () void I_ShutdownTimer ()
{ {
SDL_QuitSubSystem(SDL_INIT_TIMER);
} }

View file

@ -324,6 +324,7 @@ static FFlagDef InventoryFlags[] =
DEFINE_FLAG(IF, NOSCREENFLASH, AInventory, ItemFlags), DEFINE_FLAG(IF, NOSCREENFLASH, AInventory, ItemFlags),
DEFINE_FLAG(IF, TOSSED, AInventory, ItemFlags), DEFINE_FLAG(IF, TOSSED, AInventory, ItemFlags),
DEFINE_FLAG(IF, ALWAYSRESPAWN, AInventory, ItemFlags), DEFINE_FLAG(IF, ALWAYSRESPAWN, AInventory, ItemFlags),
DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags),
DEFINE_DEPRECATED_FLAG(PICKUPFLASH), DEFINE_DEPRECATED_FLAG(PICKUPFLASH),
DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),}; DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),};