- added an amount parameter to the 'drop' CCMD.
This commit is contained in:
parent
fc101049c6
commit
e2d5a708f8
12 changed files with 45 additions and 27 deletions
|
|
@ -713,7 +713,7 @@ public:
|
|||
virtual bool UseInventory (AInventory *item);
|
||||
|
||||
// Tosses an item out of the inventory.
|
||||
AInventory *DropInventory (AInventory *item);
|
||||
AInventory *DropInventory (AInventory *item, int amt = -1);
|
||||
|
||||
// Removes all items from the inventory.
|
||||
void ClearInventory();
|
||||
|
|
|
|||
|
|
@ -2271,6 +2271,9 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
case DEM_INVDROP:
|
||||
{
|
||||
DWORD which = ReadLong (stream);
|
||||
int amt = -1;
|
||||
|
||||
if (type == DEM_INVDROP) amt = ReadLong(stream);
|
||||
|
||||
if (gamestate == GS_LEVEL && !paused
|
||||
&& players[player].playerstate != PST_DEAD)
|
||||
|
|
@ -2288,7 +2291,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
}
|
||||
else
|
||||
{
|
||||
players[player].mo->DropInventory (item);
|
||||
players[player].mo->DropInventory (item, amt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2764,10 +2767,13 @@ void Net_SkipCommand (int type, BYTE **stream)
|
|||
break;
|
||||
|
||||
case DEM_INVUSE:
|
||||
case DEM_INVDROP:
|
||||
skip = 4;
|
||||
break;
|
||||
|
||||
case DEM_INVDROP:
|
||||
skip = 8;
|
||||
break;
|
||||
|
||||
case DEM_GENERICCHEAT:
|
||||
case DEM_DROPPLAYER:
|
||||
case DEM_FOV:
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ FString BackupSaveName;
|
|||
|
||||
bool SendLand;
|
||||
const AInventory *SendItemUse, *SendItemDrop;
|
||||
int SendItemDropAmount;
|
||||
|
||||
EXTERN_CVAR (Int, team)
|
||||
|
||||
|
|
@ -457,12 +458,14 @@ CCMD (invdrop)
|
|||
if (players[consoleplayer].mo)
|
||||
{
|
||||
SendItemDrop = players[consoleplayer].mo->InvSel;
|
||||
SendItemDropAmount = -1;
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (weapdrop)
|
||||
{
|
||||
SendItemDrop = players[consoleplayer].ReadyWeapon;
|
||||
SendItemDropAmount = -1;
|
||||
}
|
||||
|
||||
CCMD (drop)
|
||||
|
|
@ -470,6 +473,7 @@ CCMD (drop)
|
|||
if (argv.argc() > 1 && who != NULL)
|
||||
{
|
||||
SendItemDrop = who->FindInventory(argv[1]);
|
||||
SendItemDropAmount = argv.argc() > 2 ? atoi(argv[2]) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -762,6 +766,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
{
|
||||
Net_WriteByte (DEM_INVDROP);
|
||||
Net_WriteLong (SendItemDrop->InventoryID);
|
||||
Net_WriteLong(SendItemDropAmount);
|
||||
SendItemDrop = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ extern AActor *bodyque[BODYQUESIZE];
|
|||
extern int bodyqueslot;
|
||||
class AInventory;
|
||||
extern const AInventory *SendItemUse, *SendItemDrop;
|
||||
extern int SendItemDropAmount;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1035,14 +1035,14 @@ DEFINE_ACTION_FUNCTION(AActor, UseInventory)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AActor::DropInventory (AInventory *item)
|
||||
AInventory *AActor::DropInventory (AInventory *item, int amt)
|
||||
{
|
||||
AInventory *drop = nullptr;
|
||||
IFVIRTUALPTR(item, AInventory, CreateTossable)
|
||||
{
|
||||
VMValue params[1] = { (DObject*)item };
|
||||
VMValue params[] = { (DObject*)item, amt };
|
||||
VMReturn ret((void**)&drop);
|
||||
GlobalVMStack.Call(func, params, 1, &ret, 1, nullptr);
|
||||
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||
}
|
||||
if (drop == nullptr) return NULL;
|
||||
drop->SetOrigin(PosPlusZ(10.), false);
|
||||
|
|
@ -1059,7 +1059,8 @@ DEFINE_ACTION_FUNCTION(AActor, DropInventory)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_OBJECT_NOT_NULL(item, AInventory);
|
||||
ACTION_RETURN_OBJECT(self->DropInventory(item));
|
||||
PARAM_INT(amt);
|
||||
ACTION_RETURN_OBJECT(self->DropInventory(item, amt));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue