- Update scripting branch to trunk.
SVN r3758 (scripting)
This commit is contained in:
commit
562cf04db2
614 changed files with 63691 additions and 31256 deletions
141
src/d_net.cpp
141
src/d_net.cpp
|
|
@ -25,7 +25,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "m_menu.h"
|
||||
#include "menu/menu.h"
|
||||
#include "m_random.h"
|
||||
#include "i_system.h"
|
||||
#include "i_video.h"
|
||||
|
|
@ -57,9 +57,10 @@
|
|||
#include "g_level.h"
|
||||
#include "d_event.h"
|
||||
#include "m_argv.h"
|
||||
|
||||
int P_StartScript (AActor *who, line_t *where, int script, char *map, bool backSide,
|
||||
int arg0, int arg1, int arg2, int always, bool wantResultCode, bool net);
|
||||
#include "p_lnspec.h"
|
||||
#include "v_video.h"
|
||||
#include "p_spec.h"
|
||||
#include "intermission/intermission.h"
|
||||
|
||||
EXTERN_CVAR (Int, disableautosave)
|
||||
EXTERN_CVAR (Int, autosavecount)
|
||||
|
|
@ -119,6 +120,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, int always);
|
||||
|
||||
int reboundpacket;
|
||||
BYTE reboundstore[MAX_MSGLEN];
|
||||
|
|
@ -590,13 +592,16 @@ void PlayerIsGone (int netnode, int netconsole)
|
|||
Printf ("%s left the game\n", players[netconsole].userinfo.netname);
|
||||
}
|
||||
|
||||
// [RH] Revert to your own view if spying through the player who left
|
||||
if (players[consoleplayer].camera == players[netconsole].mo)
|
||||
// [RH] Revert each player to their own view if spying through the player who left
|
||||
for (int ii = 0; ii < MAXPLAYERS; ++ii)
|
||||
{
|
||||
players[consoleplayer].camera = players[consoleplayer].mo;
|
||||
if (StatusBar != NULL)
|
||||
if (playeringame[ii] && players[ii].camera == players[netconsole].mo)
|
||||
{
|
||||
StatusBar->AttachToPlayer (&players[consoleplayer]);
|
||||
players[ii].camera = players[ii].mo;
|
||||
if (ii == consoleplayer && StatusBar != NULL)
|
||||
{
|
||||
StatusBar->AttachToPlayer (&players[ii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -607,6 +612,11 @@ void PlayerIsGone (int netnode, int netconsole)
|
|||
P_DisconnectEffect (players[netconsole].mo);
|
||||
players[netconsole].mo->player = NULL;
|
||||
players[netconsole].mo->Destroy ();
|
||||
if (!(players[netconsole].mo->ObjectFlags & OF_EuthanizeMe))
|
||||
{ // We just destroyed a morphed player, so now the original player
|
||||
// has taken their place. Destroy that one too.
|
||||
players[netconsole].mo->Destroy();
|
||||
}
|
||||
players[netconsole].mo = NULL;
|
||||
players[netconsole].camera = NULL;
|
||||
}
|
||||
|
|
@ -746,6 +756,7 @@ void GetPackets (void)
|
|||
}
|
||||
|
||||
if (netbuffer[0] & NCMD_QUITTERS)
|
||||
|
||||
{
|
||||
numplayers = netbuffer[k++];
|
||||
for (int i = 0; i < numplayers; ++i)
|
||||
|
|
@ -1538,7 +1549,6 @@ static void SendSetup (DWORD playersdetected[MAXNETNODES], BYTE gotsetup[MAXNETN
|
|||
// D_CheckNetGame
|
||||
// Works out player numbers among the net participants
|
||||
//
|
||||
extern int viewangleoffset;
|
||||
|
||||
void D_CheckNetGame (void)
|
||||
{
|
||||
|
|
@ -1917,7 +1927,7 @@ BYTE *FDynamicBuffer::GetData (int *len)
|
|||
}
|
||||
|
||||
|
||||
static int KillAll(const PClass *cls)
|
||||
static int KillAll(PClassActor *cls)
|
||||
{
|
||||
AActor *actor;
|
||||
int killcount = 0;
|
||||
|
|
@ -2057,10 +2067,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
break;
|
||||
|
||||
case DEM_CENTERVIEW:
|
||||
if (players[player].mo != NULL)
|
||||
{
|
||||
players[player].mo->pitch = 0;
|
||||
}
|
||||
players[player].centering = true;
|
||||
break;
|
||||
|
||||
case DEM_INVUSEALL:
|
||||
|
|
@ -2312,22 +2319,47 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
{
|
||||
int snum = ReadWord (stream);
|
||||
int argn = ReadByte (stream);
|
||||
int arg[3] = { 0, 0, 0 };
|
||||
|
||||
|
||||
RunScript(stream, players[player].mo, snum, argn, (type == DEM_RUNSCRIPT2) ? ACS_ALWAYS : 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEM_RUNNAMEDSCRIPT:
|
||||
{
|
||||
char *sname = ReadString(stream);
|
||||
int argn = ReadByte(stream);
|
||||
|
||||
RunScript(stream, players[player].mo, -FName(sname), argn & 127, (argn & 128) ? ACS_ALWAYS : 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEM_RUNSPECIAL:
|
||||
{
|
||||
int snum = ReadByte(stream);
|
||||
int argn = ReadByte(stream);
|
||||
int arg[5] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
for (i = 0; i < argn; ++i)
|
||||
{
|
||||
arg[i] = ReadLong (stream);
|
||||
int argval = ReadLong(stream);
|
||||
if ((unsigned)i < countof(arg))
|
||||
{
|
||||
arg[i] = argval;
|
||||
}
|
||||
}
|
||||
if (!CheckCheatmode(player == consoleplayer))
|
||||
{
|
||||
P_ExecuteSpecial(snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]);
|
||||
}
|
||||
P_StartScript (players[player].mo, NULL, snum, level.mapname, false,
|
||||
arg[0], arg[1], arg[2], type == DEM_RUNSCRIPT2, false, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEM_CROUCH:
|
||||
if (gamestate == GS_LEVEL && players[player].mo != NULL &&
|
||||
players[player].health > 0 && !(players[player].oldbuttons & BT_JUMP))
|
||||
players[player].health > 0 && !(players[player].oldbuttons & BT_JUMP) &&
|
||||
!P_IsPlayerTotallyFrozen(&players[player]))
|
||||
{
|
||||
players[player].crouching = players[player].crouchdir<0? 1 : -1;
|
||||
players[player].crouching = players[player].crouchdir < 0 ? 1 : -1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2371,7 +2403,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
if (cls != NULL)
|
||||
{
|
||||
killcount = KillAll(cls);
|
||||
const PClass *cls_rep = cls->GetReplacement();
|
||||
PClassActor *cls_rep = cls->GetReplacement();
|
||||
if (cls != cls_rep)
|
||||
{
|
||||
killcount += KillAll(cls_rep);
|
||||
|
|
@ -2393,17 +2425,27 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
break;
|
||||
|
||||
case DEM_SETSLOT:
|
||||
case DEM_SETSLOTPNUM:
|
||||
{
|
||||
int pnum;
|
||||
if (type == DEM_SETSLOTPNUM)
|
||||
{
|
||||
pnum = ReadByte(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
pnum = player;
|
||||
}
|
||||
unsigned int slot = ReadByte(stream);
|
||||
int count = ReadByte(stream);
|
||||
if (slot < NUM_WEAPON_SLOTS)
|
||||
{
|
||||
players[player].weapons.Slots[slot].Clear();
|
||||
players[pnum].weapons.Slots[slot].Clear();
|
||||
}
|
||||
for(int i = 0; i < count; ++i)
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
PClassWeapon *wpn = Net_ReadWeapon(stream);
|
||||
players[player].weapons.AddSlot(slot, wpn, player == consoleplayer);
|
||||
players[pnum].weapons.AddSlot(slot, wpn, pnum == consoleplayer);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -2424,6 +2466,19 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
}
|
||||
break;
|
||||
|
||||
case DEM_SETPITCHLIMIT:
|
||||
players[player].MinPitch = ReadByte(stream) * -ANGLE_1; // up
|
||||
players[player].MaxPitch = ReadByte(stream) * ANGLE_1; // down
|
||||
break;
|
||||
|
||||
case DEM_ADVANCEINTER:
|
||||
F_AdvanceIntermission();
|
||||
break;
|
||||
|
||||
case DEM_REVERTCAMERA:
|
||||
players[player].camera = players[player].mo;
|
||||
break;
|
||||
|
||||
default:
|
||||
I_Error ("Unknown net command: %d", type);
|
||||
break;
|
||||
|
|
@ -2433,6 +2488,23 @@ 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, int always)
|
||||
{
|
||||
int arg[4] = { 0, 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, arg, MIN<int>(countof(arg), argn), ACS_NET | always);
|
||||
}
|
||||
|
||||
void Net_SkipCommand (int type, BYTE **stream)
|
||||
{
|
||||
BYTE t;
|
||||
|
|
@ -2521,14 +2593,24 @@ 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;
|
||||
|
||||
case DEM_CONVREPLY:
|
||||
skip = 3;
|
||||
break;
|
||||
|
||||
case DEM_SETSLOT:
|
||||
case DEM_SETSLOTPNUM:
|
||||
{
|
||||
skip = 2;
|
||||
for(int numweapons = (*stream)[1]; numweapons > 0; numweapons--)
|
||||
skip = 2 + (type == DEM_SETSLOTPNUM);
|
||||
for(int numweapons = (*stream)[skip-1]; numweapons > 0; numweapons--)
|
||||
{
|
||||
skip += 1 + ((*stream)[skip] >> 7);
|
||||
}
|
||||
|
|
@ -2540,6 +2622,9 @@ void Net_SkipCommand (int type, BYTE **stream)
|
|||
skip = 2 + ((*stream)[1] >> 7);
|
||||
break;
|
||||
|
||||
case DEM_SETPITCHLIMIT:
|
||||
skip = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue