|
|
1.1.1.4 root 1: // Emacs style mode select -*- C++ -*-
2: //-----------------------------------------------------------------------------
3: //
4: // $Id:$
5: //
6: // Copyright (C) 1993-1996 by id Software, Inc.
7: //
1.1.1.5 ! root 8: // This program is free software; you can redistribute it and/or
! 9: // modify it under the terms of the GNU General Public License
! 10: // as published by the Free Software Foundation; either version 2
! 11: // of the License, or (at your option) any later version.
1.1.1.4 root 12: //
1.1.1.5 ! root 13: // This program is distributed in the hope that it will be useful,
1.1.1.4 root 14: // but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1.1.5 ! root 15: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 16: // GNU General Public License for more details.
1.1.1.4 root 17: //
18: // $Log:$
19: //
20: // DESCRIPTION:
21: // Archiving: SaveGame I/O.
22: // Thinker, Ticker.
23: //
24: //-----------------------------------------------------------------------------
1.1 root 25:
1.1.1.4 root 26: static const char
27: rcsid[] = "$Id: p_tick.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";
1.1.1.2 root 28:
1.1.1.4 root 29: #include "z_zone.h"
1.1.1.3 root 30: #include "p_local.h"
1.1 root 31:
1.1.1.4 root 32: #include "doomstat.h"
33:
1.1 root 34:
1.1.1.4 root 35: int leveltime;
1.1 root 36:
1.1.1.4 root 37: //
38: // THINKERS
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.
43: //
1.1.1.2 root 44:
45:
46:
1.1.1.4 root 47: // Both the head and tail of the thinker list.
48: thinker_t thinkercap;
1.1 root 49:
50:
1.1.1.4 root 51: //
52: // P_InitThinkers
53: //
54: void P_InitThinkers (void)
55: {
56: thinkercap.prev = thinkercap.next = &thinkercap;
57: }
1.1 root 58:
1.1.1.2 root 59:
1.1 root 60:
61:
1.1.1.2 root 62: //
1.1.1.4 root 63: // P_AddThinker
64: // Adds a new thinker at the end of the list.
1.1.1.2 root 65: //
1.1.1.4 root 66: void P_AddThinker (thinker_t* thinker)
1.1 root 67: {
1.1.1.4 root 68: thinkercap.prev->next = thinker;
69: thinker->next = &thinkercap;
70: thinker->prev = thinkercap.prev;
71: thinkercap.prev = thinker;
1.1 root 72: }
73:
1.1.1.4 root 74:
75:
1.1.1.3 root 76: //
1.1.1.4 root 77: // P_RemoveThinker
78: // Deallocation is lazy -- it will not actually be freed
79: // until its thinking turn comes up.
1.1.1.3 root 80: //
1.1.1.4 root 81: void P_RemoveThinker (thinker_t* thinker)
1.1 root 82: {
1.1.1.4 root 83: // FIXME: NOP.
84: thinker->function.acv = (actionf_v)(-1);
1.1 root 85: }
86:
1.1.1.4 root 87:
88:
1.1.1.3 root 89: //
1.1.1.4 root 90: // P_AllocateThinker
91: // Allocates memory and adds a new thinker at the end of the list.
1.1.1.3 root 92: //
1.1.1.4 root 93: void P_AllocateThinker (thinker_t* thinker)
1.1 root 94: {
1.1.1.2 root 95: }
1.1 root 96:
1.1.1.4 root 97:
98:
1.1.1.3 root 99: //
1.1.1.4 root 100: // P_RunThinkers
1.1.1.3 root 101: //
1.1.1.4 root 102: void P_RunThinkers (void)
1.1.1.2 root 103: {
1.1.1.4 root 104: thinker_t* currentthinker;
105:
106: currentthinker = thinkercap.next;
107: while (currentthinker != &thinkercap)
108: {
109: if ( currentthinker->function.acv == (actionf_v)(-1) )
110: {
111: // time to remove it
112: currentthinker->next->prev = currentthinker->prev;
113: currentthinker->prev->next = currentthinker->next;
114: Z_Free (currentthinker);
115: }
116: else
117: {
118: if (currentthinker->function.acp1)
119: currentthinker->function.acp1 (currentthinker);
120: }
121: currentthinker = currentthinker->next;
122: }
1.1.1.2 root 123: }
124:
1.1.1.4 root 125:
126:
1.1.1.2 root 127: //
1.1.1.4 root 128: // P_Ticker
1.1.1.2 root 129: //
1.1 root 130:
1.1.1.4 root 131: void P_Ticker (void)
1.1 root 132: {
1.1.1.4 root 133: int i;
134:
135: // run the tic
136: if (paused)
137: return;
138:
139: // pause if in menu and at least one tic has been run
140: if ( !netgame
141: && menuactive
142: && !demoplayback
143: && players[consoleplayer].viewz != 1)
144: {
145: return;
146: }
147:
148:
149: for (i=0 ; i<MAXPLAYERS ; i++)
150: if (playeringame[i])
151: P_PlayerThink (&players[i]);
152:
153: P_RunThinkers ();
154: P_UpdateSpecials ();
155: P_RespawnSpecials ();
156:
157: // for par times
158: leveltime++;
1.1.1.2 root 159: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.