From 671cf5a888063d5108abf5ee667ad429591154a8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Dec 2007 08:44:13 +0000 Subject: [PATCH] - added UseInventory/UseActorInventory ACS functions. SVN r636 (trunk) --- docs/rh-log.txt | 3 ++ src/p_acs.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++ src/p_acs.h | 2 ++ src/sdl/i_main.cpp | 4 +-- src/win32/win32iface.h | 5 +++ 5 files changed, 93 insertions(+), 2 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f3aaa5362..7f396de02 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,6 @@ +December 25, 2007 (Changes by Graf Zahl) +- added UseInventory/UseActorInventory ACS functions. + December 24, 2007 (Changes by Graf Zahl) - added some functionality to FDynamicColormap to allow not creating the colormap data. diff --git a/src/p_acs.cpp b/src/p_acs.cpp index f965246f2..99e362021 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -357,6 +357,61 @@ static void TakeInventory (AActor *activator, const char *type, int amount) } } +//============================================================================ +// +// DoUseInv +// +// Makes a single actor use an inventory item +// +//============================================================================ + +static bool DoUseInv (AActor *actor, const PClass *info) +{ + AInventory *item = actor->FindInventory (info); + if (item != NULL) + { + return actor->UseInventory(item); + } + return false; +} + +//============================================================================ +// +// UseInventory +// +// makes one or more actors use an inventory item. +// +//============================================================================ + +static int UseInventory (AActor *activator, const char *type) +{ + const PClass *info; + int ret = 0; + + if (type == NULL) + { + return 0; + } + info = PClass::FindClass (type); + if (info == NULL) + { + return 0; + } + if (activator == NULL) + { + for (int i = 0; i < MAXPLAYERS; ++i) + { + if (playeringame[i]) + ret += DoUseInv (players[i].mo, info); + } + } + else + { + ret = DoUseInv (activator, info); + } + return ret; +} + //============================================================================ // // CheckInventory @@ -4322,6 +4377,32 @@ int DLevelScript::RunScript () pc += 1; break; + case PCD_USEINVENTORY: + STACK(1) = UseInventory (activator, FBehavior::StaticLookupString (STACK(1))); + break; + + case PCD_USEACTORINVENTORY: + { + int ret; + const char *type = FBehavior::StaticLookupString(STACK(1)); + if (STACK(2) == 0) + { + ret = UseInventory(NULL, type); + } + else + { + FActorIterator it(STACK(2)); + AActor *actor; + for (actor = it.Next(); actor != NULL; actor = it.Next()) + { + ret += UseInventory(actor, type); + } + } + STACK(2) = ret; + sp--; + } + break; + case PCD_GETSIGILPIECES: { ASigil *sigil; diff --git a/src/p_acs.h b/src/p_acs.h index ac72de473..f34d5a098 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -541,6 +541,8 @@ public: PCD_PRINTBIND, PCD_SETACTORSTATE, PCD_THINGDAMAGE2, + PCD_USEINVENTORY, + PCD_USEACTORINVENTORY, PCODE_COMMAND_COUNT }; diff --git a/src/sdl/i_main.cpp b/src/sdl/i_main.cpp index aebc6d8de..4d7ac911d 100644 --- a/src/sdl/i_main.cpp +++ b/src/sdl/i_main.cpp @@ -135,7 +135,7 @@ static int DoomSpecificInfo (char *buffer, char *end) SDL_Quit(); p = 0; - p += snprintf (buffer+p, size-p, "ZDoom version " DOTVERSIONSTR " (" __DATE__ ")\n"); + p += snprintf (buffer+p, size-p, GAMENAME" version " DOTVERSIONSTR " (" __DATE__ ")\n"); p += snprintf (buffer+p, size-p, "\nCommand line:"); for (i = 0; i < Args.NumArgs(); ++i) { @@ -182,7 +182,7 @@ static int DoomSpecificInfo (char *buffer, char *end) int main (int argc, char **argv) { - printf("ZDoom v%s - SVN revision %s - SDL version\nCompiled on %s\n\n", + printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n", DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__); { diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 247734687..bd91df1a5 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -31,6 +31,9 @@ ** */ +#ifndef __WIN32IFACE_H +#define __WIN32IFACE_H + #ifndef DIRECTDRAW_VERSION #define DIRECTDRAW_VERSION 0x0300 #endif @@ -306,3 +309,5 @@ FILE *dbg; #define LOG4(x,y,z,a,b) #define LOG5(x,y,z,a,b,c) #endif + +#endif // __WIN32IFACE_H