1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
20 // Archiving: SaveGame I/O.
23 //-----------------------------------------------------------------------------
26 rcsid[] = "$Id: p_tick.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";
38 // All thinkers should be allocated by Z_Malloc
39 // so they can be operated on uniformly.
40 // The actual structures will vary in size,
41 // but the first element must be thinker_t.
46 // Both the head and tail of the thinker list.
53 void P_InitThinkers (void)
55 thinkercap.prev = thinkercap.next = &thinkercap;
63 // Adds a new thinker at the end of the list.
65 void P_AddThinker (thinker_t* thinker)
67 thinkercap.prev->next = thinker;
68 thinker->next = &thinkercap;
69 thinker->prev = thinkercap.prev;
70 thinkercap.prev = thinker;
77 // Deallocation is lazy -- it will not actually be freed
78 // until its thinking turn comes up.
80 void P_RemoveThinker (thinker_t* thinker)
83 thinker->function = (actionf_t)(-1);
90 void P_RunThinkers (void)
92 thinker_t* currentthinker;
94 currentthinker = thinkercap.next;
95 while (currentthinker != &thinkercap)
97 if ( currentthinker->function == (actionf_t)(-1) )
100 currentthinker->next->prev = currentthinker->prev;
101 currentthinker->prev->next = currentthinker->next;
102 Z_Free (currentthinker);
106 if (currentthinker->function)
107 currentthinker->function(currentthinker, NULL);
109 currentthinker = currentthinker->next;
127 // pause if in menu and at least one tic has been run
131 && players[consoleplayer].viewz != 1)
137 for (i=0 ; i<MAXPLAYERS ; i++)
139 P_PlayerThink (&players[i]);
143 P_RespawnSpecials ();