- Allow for using ACS_NamedExecute and friends with SetLineSpecial.

SVN r3371 (trunk)
This commit is contained in:
Randy Heit 2012-02-18 02:17:33 +00:00
parent 9cd0e48ea3
commit cbf7162e16
3 changed files with 34 additions and 13 deletions

View file

@ -1882,14 +1882,14 @@ void FBehavior::StaticStopMyScripts (AActor *actor)
//========================================================================== //==========================================================================
// //
// SerializeScriptNumber // P_SerializeACSScriptNumber
// //
// Serializes a script number. If it's negative, it's really a name, so // Serializes a script number. If it's negative, it's really a name, so
// that will get serialized after it. // that will get serialized after it.
// //
//========================================================================== //==========================================================================
static void SerializeScriptNumber(FArchive &arc, int &scriptnum, bool was2byte) void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte)
{ {
if (SaveVersion < 3359) if (SaveVersion < 3359)
{ {
@ -1971,7 +1971,7 @@ void DACSThinker::Serialize (FArchive &arc)
assert(pair->Value != NULL); assert(pair->Value != NULL);
arc << pair->Value; arc << pair->Value;
scriptnum = pair->Key; scriptnum = pair->Key;
SerializeScriptNumber(arc, scriptnum, true); P_SerializeACSScriptNumber(arc, scriptnum, true);
} }
DLevelScript *nilptr = NULL; DLevelScript *nilptr = NULL;
arc << nilptr; arc << nilptr;
@ -1984,7 +1984,7 @@ void DACSThinker::Serialize (FArchive &arc)
arc << script; arc << script;
while (script) while (script)
{ {
SerializeScriptNumber(arc, scriptnum, true); P_SerializeACSScriptNumber(arc, scriptnum, true);
RunningScripts[scriptnum] = script; RunningScripts[scriptnum] = script;
arc << script; arc << script;
} }
@ -2048,7 +2048,7 @@ void DLevelScript::Serialize (FArchive &arc)
Super::Serialize (arc); Super::Serialize (arc);
arc << next << prev; arc << next << prev;
SerializeScriptNumber(arc, script, false); P_SerializeACSScriptNumber(arc, script, false);
arc << state arc << state
<< statedata << statedata
@ -5750,12 +5750,21 @@ int DLevelScript::RunScript ()
case PCD_SETLINESPECIAL: case PCD_SETLINESPECIAL:
{ {
int linenum = -1; int linenum = -1;
int specnum = STACK(6);
int arg0 = STACK(5);
while ((linenum = P_FindLineFromID (STACK(7), linenum)) >= 0) { // Convert named ACS "specials" into real specials.
if (specnum >= -ACSF_ACS_NamedExecuteAlways && specnum <= -ACSF_ACS_NamedExecute)
{
specnum = NamedACSToNormalACS[-specnum - ACSF_ACS_NamedExecute];
arg0 = -FName(FBehavior::StaticLookupString(arg0));
}
while ((linenum = P_FindLineFromID (STACK(7), linenum)) >= 0)
{
line_t *line = &lines[linenum]; line_t *line = &lines[linenum];
line->special = specnum;
line->special = STACK(6); line->args[0] = arg0;
line->args[0] = STACK(5);
line->args[1] = STACK(4); line->args[1] = STACK(4);
line->args[2] = STACK(3); line->args[2] = STACK(3);
line->args[3] = STACK(2); line->args[3] = STACK(2);
@ -7310,7 +7319,7 @@ FArchive &operator<< (FArchive &arc, acsdefered_t *&defertop)
arc << more; arc << more;
type = (BYTE)defer->type; type = (BYTE)defer->type;
arc << type; arc << type;
SerializeScriptNumber(arc, defer->script, false); P_SerializeACSScriptNumber(arc, defer->script, false);
arc << defer->playernum << defer->arg0 << defer->arg1 << defer->arg2; arc << defer->playernum << defer->arg0 << defer->arg1 << defer->arg2;
defer = defer->next; defer = defer->next;
} }
@ -7327,7 +7336,7 @@ FArchive &operator<< (FArchive &arc, acsdefered_t *&defertop)
*defer = new acsdefered_t; *defer = new acsdefered_t;
arc << more; arc << more;
(*defer)->type = (acsdefered_t::EType)more; (*defer)->type = (acsdefered_t::EType)more;
SerializeScriptNumber(arc, (*defer)->script, false); P_SerializeACSScriptNumber(arc, (*defer)->script, false);
arc << (*defer)->playernum << (*defer)->arg0 << (*defer)->arg1 << (*defer)->arg2; arc << (*defer)->playernum << (*defer)->arg0 << (*defer)->arg1 << (*defer)->arg2;
defer = &((*defer)->next); defer = &((*defer)->next);
arc << more; arc << more;

View file

@ -72,6 +72,7 @@ extern FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS];
void P_ReadACSVars(PNGHandle *); void P_ReadACSVars(PNGHandle *);
void P_WriteACSVars(FILE*); void P_WriteACSVars(FILE*);
void P_ClearACSVars(bool); void P_ClearACSVars(bool);
void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte);
// The in-memory version // The in-memory version
struct ScriptPtr struct ScriptPtr

View file

@ -50,6 +50,8 @@
#include "p_setup.h" #include "p_setup.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "farchive.h" #include "farchive.h"
#include "p_lnspec.h"
#include "p_acs.h"
static void CopyPlayer (player_t *dst, player_t *src, const char *name); static void CopyPlayer (player_t *dst, player_t *src, const char *name);
static void ReadOnePlayer (FArchive &arc, bool skipload); static void ReadOnePlayer (FArchive &arc, bool skipload);
@ -393,8 +395,17 @@ void P_SerializeWorld (FArchive &arc)
<< li->activation << li->activation
<< li->special << li->special
<< li->Alpha << li->Alpha
<< li->id << li->id;
<< li->args[0] << li->args[1] << li->args[2] << li->args[3] << li->args[4]; if ((li->special >= ACS_Execute && li->special <= ACS_LockedExecuteDoor) ||
li->special == ACS_ExecuteAlways)
{
P_SerializeACSScriptNumber(arc, li->args[0], false);
}
else
{
arc << li->args[0];
}
arc << li->args[1] << li->args[2] << li->args[3] << li->args[4];
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
{ {