summaryrefslogtreecommitdiff
path: root/src/cgame/cg_snapshot.c
diff options
context:
space:
mode:
authorIronClawTrem <louie.nutman@gmail.com>2020-04-09 18:30:35 +0100
committerIronClawTrem <louie.nutman@gmail.com>2020-04-09 18:31:16 +0100
commitf324890e9715490c909ca6123948f4157401324c (patch)
tree9db453bd1cf86ea2a5751dadd073c003635f9f3e /src/cgame/cg_snapshot.c
parentc378d3fb9f7f443ee6a6f78f490f2bc203aba5ea (diff)
multiprotocol: gamelogic code for 1.1
Diffstat (limited to 'src/cgame/cg_snapshot.c')
-rw-r--r--src/cgame/cg_snapshot.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c
index 673558d..d69da95 100644
--- a/src/cgame/cg_snapshot.c
+++ b/src/cgame/cg_snapshot.c
@@ -241,6 +241,54 @@ static void CG_SetNextSnap( snapshot_t *snap )
CG_BuildSolidList( );
}
+#ifdef MODULE_INTERFACE_11
+static moduleAlternateSnapshot_t moduleAlternateSnapshot;
+
+static qboolean CG_GetModuleAlternateSnapshot( int snapshotNumber, snapshot_t *snap )
+{
+ moduleAlternateSnapshot_t *alt = &moduleAlternateSnapshot;
+ int r = trap_GetSnapshot( snapshotNumber, alt );
+
+ if( r )
+ {
+ int i;
+
+ snap->snapFlags = alt->snapFlags;
+ snap->ping = alt->ping;
+ snap->serverTime = alt->serverTime;
+ snap->numEntities = alt->numEntities;
+ snap->numServerCommands = alt->numServerCommands;
+ snap->serverCommandSequence = alt->serverCommandSequence;
+ memcpy( &snap->areamask, &alt->areamask, sizeof( snap->areamask ) );
+
+#define PSFO(x) ((size_t)&(((playerState_t*)0)->x))
+ memcpy( &snap->ps.commandTime, &alt->ps.commandTime, PSFO(tauntTimer) - PSFO(commandTime) );
+ memcpy( &snap->ps.movementDir, &alt->ps.movementDir, PSFO(ammo) - PSFO(movementDir) );
+ memcpy( &snap->ps.generic1, &alt->ps.generic1, PSFO(entityEventSequence) - PSFO(generic1) );
+
+ snap->ps.weaponAnim = alt->ps.ammo[0] & 0xFF;
+ snap->ps.pm_flags |= ( alt->ps.ammo[0] & 0xFF00 ) << 8;
+ snap->ps.ammo = alt->ps.ammo[1] & 0xFFF;
+ snap->ps.clips = ( alt->ps.ammo[1] & 0xF000 ) >> 12;
+ snap->ps.tauntTimer = alt->ps.ammo[2] & 0xFFF;
+ snap->ps.generic1 |= ( alt->ps.ammo[2] & 0x3000 ) >> 4;
+
+ for( i = 0; i < alt->numEntities; ++i )
+ {
+ entityState_t *s = &snap->entities[ i ];
+ const moduleAlternateEntityState_t *a = &alt->entities[ i ];
+
+#define ESFO(x) ((size_t)&(((entityState_t*)0)->x))
+ memcpy( &s->number, &a->number, ESFO(weaponAnim) - ESFO(number) );
+
+ s->weaponAnim = 0;
+ s->generic1 = a->generic1;
+ }
+ }
+
+ return r;
+}
+#endif
/*
========================
@@ -273,7 +321,11 @@ static snapshot_t *CG_ReadNextSnapshot( void )
// try to read the snapshot from the client system
cgs.processedSnapshotNum++;
+#ifdef MODULE_INTERFACE_11
+ r = CG_GetModuleAlternateSnapshot( cgs.processedSnapshotNum, dest );
+#else
r = trap_GetSnapshot( cgs.processedSnapshotNum, dest );
+#endif
// FIXME: why would trap_GetSnapshot return a snapshot with the same server time
if( cg.snap && r && dest->serverTime == cg.snap->serverTime )