- Added pukename console command. This is mostly the same as puke, except the scripts are

named, and to run a script using ACS_ExecuteAlways, you need to add "always" after the script
  name but before any arguments. e.g.:
    pukename "A Script" 1
  Will run the script "A Script" with a single argument of 1, provided the script is not 
  already running.
    pukename "A Script" always 1
  Will always run the script "A Script" with a single argument of 1.

SVN r3365 (trunk)
This commit is contained in:
Randy Heit 2012-02-16 22:13:46 +00:00
parent 7561beb212
commit 8f516a1007
4 changed files with 76 additions and 14 deletions

View file

@ -489,6 +489,44 @@ CCMD (puke)
}
}
CCMD (pukename)
{
int argc = argv.argc();
if (argc < 2 || argc > 6)
{
Printf ("Usage: pukename \"<script>\" [\"always\"] [arg1] [arg2] [arg3]\n");
}
else
{
bool always = false;
int argstart = 2;
int arg[3] = { 0, 0, 0 };
int argn = 0, i;
if (argc > 2)
{
if (stricmp(argv[2], "always") == 0)
{
always = true;
argstart = 3;
}
argn = MIN(argc - argstart, 3);
for (i = 0; i < argn; ++i)
{
arg[i] = atoi(argv[argstart + i]);
}
}
Net_WriteByte(DEM_RUNNAMEDSCRIPT);
Net_WriteString(argv[1]);
Net_WriteByte(argn | (always << 7));
for (i = 0; i < argn; ++i)
{
Net_WriteLong(arg[i]);
}
}
}
CCMD (special)
{
int argc = argv.argc();

View file

@ -122,6 +122,7 @@ void G_BuildTiccmd (ticcmd_t *cmd);
void D_DoAdvanceDemo (void);
static void SendSetup (DWORD playersdetected[MAXNETNODES], BYTE gotsetup[MAXNETNODES], int len);
static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, bool always);
int reboundpacket;
BYTE reboundstore[MAX_MSGLEN];
@ -2315,18 +2316,17 @@ void Net_DoCommand (int type, BYTE **stream, int player)
{
int snum = ReadWord (stream);
int argn = ReadByte (stream);
int arg[3] = { 0, 0, 0 };
for (i = 0; i < argn; ++i)
{
int argval = ReadLong(stream);
if ((unsigned)i < countof(arg))
{
arg[i] = argval;
}
}
P_StartScript (players[player].mo, NULL, snum, level.mapname, false,
arg[0], arg[1], arg[2], type == DEM_RUNSCRIPT2, false, true);
RunScript(stream, players[player].mo, snum, argn, type == DEM_RUNSCRIPT2);
}
break;
case DEM_RUNNAMEDSCRIPT:
{
char *sname = ReadString(stream);
int argn = ReadByte(stream);
RunScript(stream, players[player].mo, -FName(sname), argn & 127, !!(argn & 128));
}
break;
@ -2471,6 +2471,24 @@ void Net_DoCommand (int type, BYTE **stream, int player)
delete[] s;
}
// Used by DEM_RUNSCRIPT, DEM_RUNSCRIPT2, and DEM_RUNNAMEDSCRIPT
static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, bool always)
{
int arg[3] = { 0, 0, 0 };
int i;
for (i = 0; i < argn; ++i)
{
int argval = ReadLong(stream);
if ((unsigned)i < countof(arg))
{
arg[i] = argval;
}
}
P_StartScript (pawn, NULL, snum, level.mapname, false,
arg[0], arg[1], arg[2], always, false, true);
}
void Net_SkipCommand (int type, BYTE **stream)
{
BYTE t;
@ -2559,6 +2577,11 @@ void Net_SkipCommand (int type, BYTE **stream)
skip = 3 + *(*stream + 2) * 4;
break;
case DEM_RUNNAMEDSCRIPT:
skip = strlen((char *)(*stream)) + 2;
skip += ((*(*stream + skip - 1)) & 127) * 4;
break;
case DEM_RUNSPECIAL:
skip = 2 + *(*stream + 1) * 4;
break;

View file

@ -161,6 +161,7 @@ enum EDemoCommand
DEM_RUNSPECIAL, // 62 Byte: Special number, Byte: Arg count, Ints: Args
DEM_SETPITCHLIMIT, // 63 Byte: Up limit, Byte: Down limit (in degrees)
DEM_ADVANCEINTER, // 64 Advance intermission screen state
DEM_RUNNAMEDSCRIPT, // 65 String: Script name, Byte: Arg count + Always flag; each arg is a 4-byte int
};
// The following are implemented by cht_DoCheat in m_cheat.cpp

View file

@ -54,7 +54,7 @@
// Version identifier for network games.
// Bump it every time you do a release unless you're certain you
// didn't change anything that will affect sync.
#define NETGAMEVERSION 225
#define NETGAMEVERSION 226
// Version stored in the ini's [LastRun] section.
// Bump it if you made some configuration change that you want to
@ -64,7 +64,7 @@
// Protocol version used in demos.
// Bump it if you change existing DEM_ commands or add new ones.
// Otherwise, it should be safe to leave it alone.
#define DEMOGAMEVERSION 0x216
#define DEMOGAMEVERSION 0x217
// Minimum demo version we can play.
// Bump it whenever you change or remove existing DEM_ commands.