1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
4 // Copyright(C) 1993-1996 Id Software, Inc.
5 // Copyright(C) 2005 Simon Howard
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 // Archiving: SaveGame I/O.
26 //-----------------------------------------------------------------------------
39 // All thinkers should be allocated by Z_Malloc
40 // so they can be operated on uniformly.
41 // The actual structures will vary in size,
42 // but the first element must be thinker_t.
47 // Both the head and tail of the thinker list.
54 void P_InitThinkers (void)
56 thinkercap
.prev
= thinkercap
.next
= &thinkercap
;
64 // Adds a new thinker at the end of the list.
66 void P_AddThinker (thinker_t
* thinker
)
68 thinkercap
.prev
->next
= thinker
;
69 thinker
->next
= &thinkercap
;
70 thinker
->prev
= thinkercap
.prev
;
71 thinkercap
.prev
= thinker
;
78 // Deallocation is lazy -- it will not actually be freed
79 // until its thinking turn comes up.
81 void P_RemoveThinker (thinker_t
* thinker
)
84 thinker
->function
.acv
= (actionf_v
)(-1);
91 // Allocates memory and adds a new thinker at the end of the list.
93 void P_AllocateThinker (thinker_t
* thinker
)
102 void P_RunThinkers (void)
104 thinker_t
* currentthinker
;
106 currentthinker
= thinkercap
.next
;
107 while (currentthinker
!= &thinkercap
)
109 if ( currentthinker
->function
.acv
== (actionf_v
)(-1) )
112 currentthinker
->next
->prev
= currentthinker
->prev
;
113 currentthinker
->prev
->next
= currentthinker
->next
;
114 Z_Free (currentthinker
);
118 if (currentthinker
->function
.acp1
)
119 currentthinker
->function
.acp1 (currentthinker
);
121 currentthinker
= currentthinker
->next
;
139 // pause if in menu and at least one tic has been run
143 && players
[consoleplayer
].viewz
!= 1)
149 for (i
=0 ; i
<MAXPLAYERS
; i
++)
151 P_PlayerThink (&players
[i
]);
155 P_RespawnSpecials ();