static void CG_ReloadHud_f()
{
	CG_Rocket_LoadHuds();
	CG_OnPlayerWeaponChange();
}
Exemple #2
0
/*
===================
CG_TransitionSnapshot

The transition point from snap to nextSnap has passed
===================
*/
static void CG_TransitionSnapshot( void )
{
	centity_t  *cent;
	snapshot_t *oldFrame;
	int        i, oldWeapon;

	if ( !cg.snap )
	{
		CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
	}

	if ( !cg.nextSnap )
	{
		CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
	}

	// execute any server string commands before transitioning entities
	CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );

	// clear the currentValid flag for all entities in the existing snapshot
	for ( i = 0; i < cg.snap->numEntities; i++ )
	{
		cent = &cg_entities[ cg.snap->entities[ i ].number ];
		cent->currentValid = qfalse;
	}

	// move nextSnap to snap and do the transitions
	oldFrame = cg.snap;
	cg.snap = cg.nextSnap;

	// Need to store the previous weapon because BG_PlayerStateToEntityState might change it
	// so the CG_OnPlayerWeaponChange callback is never called
	oldWeapon = oldFrame->ps.weapon;

	BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
	cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;

	for ( i = 0; i < cg.snap->numEntities; i++ )
	{
		cent = &cg_entities[ cg.snap->entities[ i ].number ];
		CG_TransitionEntity( cent );

		// remember time of snapshot this entity was last updated in
		cent->snapShotTime = cg.snap->serverTime;
	}

	cg.nextSnap = NULL;

	// check for playerstate transition events
	if ( oldFrame )
	{
		playerState_t *ops, *ps;

		ops = &oldFrame->ps;
		ps = &cg.snap->ps;

		// teleporting checks are irrespective of prediction
		if ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT )
		{
			cg.thisFrameTeleport = qtrue; // will be cleared by prediction code
		}

		// if we are not doing client side movement prediction for any
		// reason, then the client events and view changes will be issued now
		if ( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
		     cg_nopredict.integer || cg_synchronousClients.integer )
		{
			CG_TransitionPlayerState( ps, ops );
		}

		// Callbacks for changes in playerState like weapon/class/team
		if ( oldWeapon != ps->weapon )
		{
			CG_OnPlayerWeaponChange( (weapon_t) ops->weapon );
		}

		if ( ops->stats[ STAT_ITEMS ] != ps->stats[ STAT_ITEMS ] )
		{
			CG_OnPlayerUpgradeChange();
		}
	}
}