diff options
author | /dev/humancontroller <devhc@example.com> | 2017-04-15 17:22:08 +0200 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-04-15 17:23:08 +0200 |
commit | 6d4cacd5ad49d654e99c458f5002c70732c9e0a6 (patch) | |
tree | d1d29524dd7baf15e2309cb14bec4c94c3cd6c9c /src/cgame/cg_snapshot.c | |
parent | 8f6cc0930258d39570676d349db062b0c54ba1ad (diff) |
multi-protocol: largely port the (gamelogic part of the) multi-protocol code to the 1.1-ish code base
also update .gitignore accordingly
Diffstat (limited to 'src/cgame/cg_snapshot.c')
-rw-r--r-- | src/cgame/cg_snapshot.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c index f439a69..84b419f 100644 --- a/src/cgame/cg_snapshot.c +++ b/src/cgame/cg_snapshot.c @@ -245,6 +245,55 @@ static void CG_SetNextSnap( snapshot_t *snap ) } +#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 + /* ======================== CG_ReadNextSnapshot @@ -276,7 +325,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 ) |