# move iconv's headers and libs out of the main developer directory, so that it isn...
[AROS-Contrib.git] / Games / Doom / p_tick.c
blobcb7c58d62347178c14b6105737fecd191e8732c0
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
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
15 // for more details.
17 // $Log$
18 // Revision 1.1 2000/02/29 18:21:05 stegerg
19 // Doom port based on ADoomPPC. Read README.AROS!
22 // DESCRIPTION:
23 // Archiving: SaveGame I/O.
24 // Thinker, Ticker.
26 //-----------------------------------------------------------------------------
28 static const char
29 rcsid[] = "$Id$";
31 #include "z_zone.h"
32 #include "p_local.h"
34 #include "doomstat.h"
37 int leveltime;
40 // THINKERS
41 // All thinkers should be allocated by Z_Malloc
42 // so they can be operated on uniformly.
43 // The actual structures will vary in size,
44 // but the first element must be thinker_t.
49 // Both the head and tail of the thinker list.
50 thinker_t thinkercap;
54 // P_InitThinkers
56 void P_InitThinkers (void)
58 thinkercap.prev = thinkercap.next = &thinkercap;
65 // P_AddThinker
66 // Adds a new thinker at the end of the list.
68 void P_AddThinker (thinker_t* thinker)
70 thinkercap.prev->next = thinker;
71 thinker->next = &thinkercap;
72 thinker->prev = thinkercap.prev;
73 thinkercap.prev = thinker;
79 // P_RemoveThinker
80 // Deallocation is lazy -- it will not actually be freed
81 // until its thinking turn comes up.
83 void P_RemoveThinker (thinker_t* thinker)
85 // FIXME: NOP.
86 thinker->function.acv = (actionf_v)(-1);
92 // P_AllocateThinker
93 // Allocates memory and adds a new thinker at the end of the list.
95 void P_AllocateThinker (thinker_t* thinker)
102 // P_RunThinkers
104 void P_RunThinkers (void)
106 thinker_t* currentthinker;
108 currentthinker = thinkercap.next;
109 while (currentthinker != &thinkercap)
111 if ( currentthinker->function.acv == (actionf_v)(-1) )
113 // time to remove it
114 currentthinker->next->prev = currentthinker->prev;
115 currentthinker->prev->next = currentthinker->next;
116 Z_Free (currentthinker);
118 else
120 if (currentthinker->function.acp1)
121 currentthinker->function.acp1 (currentthinker);
123 currentthinker = currentthinker->next;
130 // P_Ticker
133 void P_Ticker (void)
135 int i;
137 // run the tic
138 if (paused)
139 return;
140 // pause if in menu and at least one tic has been run
141 if ( !netgame
142 && menuactive
143 && !demoplayback
144 && players[consoleplayer].viewz != 1)
146 return;
150 for (i=0 ; i<MAXPLAYERS ; i++)
151 if (playeringame[i])
153 P_PlayerThink (&players[i]);
156 P_RunThinkers ();
157 P_UpdateSpecials ();
158 P_RespawnSpecials ();
160 // for par times
161 leveltime++;