// Emacs style mode select	 -*- C++ -*- 
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// $Log:$
//
// DESCRIPTION:
//		Ticker.
//
//-----------------------------------------------------------------------------


#include "z_zone.h"
#include "p_local.h"
#include "p_effect.h"
#include "p_acs.h"
#include "c_console.h"
#include "doomstat.h"
#include "cl_main.h"

extern constate_e ConsoleState;
extern gamestate_t wipegamestate;

EXTERN_CVAR (cl_predict_players)


void P_XYMovement (AActor *mo);
void P_ZMovement (AActor *mo);

//
// P_Ticker
//
void P_Ticker (void)
{
	if (noservermsgs)
		return;

	P_ThinkParticles ();   // [RH] make the particles think


	for (int i=0; i<MAXPLAYERS; i++)
	{
		if (!playeringame[i] || i==consoleplayer)
			continue;

		player_t *player = &players[i];

		if (!player->mo)
			continue;

		// Counter, time dependent invisibility.
		if (player->powers[pw_invisibility])
			if (! --player->powers[pw_invisibility] )
				player->mo->flags &= ~MF_SHADOW;
		
		if (player->last_received == gametic)
			continue;

		// predict players
		if (cl_predict_players.value || player->last_received == gametic-1 )
		{
			P_XYMovement (player->mo);
			P_ZMovement (player->mo);
		}
	}

	DThinker::RunThinkers ();

    P_UpdateSpecials ();

	P_RunEffects ();	// [RH] Run particle effects

	// for par times
	level.time++;
}
