Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
298 serge 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.
11
//
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.
16
//
17
// $Log:$
18
//
19
// DESCRIPTION:
20
//	Archiving: SaveGame I/O.
21
//	Thinker, Ticker.
22
//
23
//-----------------------------------------------------------------------------
24
 
25
static const char
26
rcsid[] = "$Id: p_tick.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";
27
 
28
#include "z_zone.h"
29
#include "p_local.h"
30
 
31
#include "doomstat.h"
32
 
33
 
34
int	leveltime;
35
 
36
//
37
// THINKERS
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.
42
//
43
 
44
 
45
 
46
// Both the head and tail of the thinker list.
47
thinker_t	thinkercap;
48
 
49
 
50
//
51
// P_InitThinkers
52
//
53
void P_InitThinkers (void)
54
{
55
    thinkercap.prev = thinkercap.next  = &thinkercap;
56
}
57
 
58
 
59
 
60
 
61
//
62
// P_AddThinker
63
// Adds a new thinker at the end of the list.
64
//
65
void P_AddThinker (thinker_t* thinker)
66
{
67
    thinkercap.prev->next = thinker;
68
    thinker->next = &thinkercap;
69
    thinker->prev = thinkercap.prev;
70
    thinkercap.prev = thinker;
71
}
72
 
73
 
74
 
75
//
76
// P_RemoveThinker
77
// Deallocation is lazy -- it will not actually be freed
78
// until its thinking turn comes up.
79
//
80
void P_RemoveThinker (thinker_t* thinker)
81
{
82
  // FIXME: NOP.
83
  thinker->function.acv = (actionf_v)(-1);
84
}
85
 
86
 
87
 
88
//
89
// P_AllocateThinker
90
// Allocates memory and adds a new thinker at the end of the list.
91
//
92
void P_AllocateThinker (thinker_t*	thinker)
93
{
94
}
95
 
96
 
97
 
98
//
99
// P_RunThinkers
100
//
101
void P_RunThinkers (void)
102
{
103
    thinker_t*	currentthinker;
104
 
105
    currentthinker = thinkercap.next;
106
    while (currentthinker != &thinkercap)
107
    {
108
	if ( currentthinker->function.acv == (actionf_v)(-1) )
109
	{
110
	    // time to remove it
111
	    currentthinker->next->prev = currentthinker->prev;
112
	    currentthinker->prev->next = currentthinker->next;
113
	    Z_Free (currentthinker);
114
	}
115
	else
116
	{
117
	    if (currentthinker->function.acp1)
118
		currentthinker->function.acp1 (currentthinker);
119
	}
120
	currentthinker = currentthinker->next;
121
    }
122
}
123
 
124
 
125
 
126
//
127
// P_Ticker
128
//
129
 
130
void P_Ticker (void)
131
{
132
    int		i;
133
 
134
    // run the tic
135
    if (paused)
136
	return;
137
 
138
    // pause if in menu and at least one tic has been run
139
    if ( !netgame
140
	 && menuactive
141
	 && !demoplayback
142
	 && players[consoleplayer].viewz != 1)
143
    {
144
	return;
145
    }
146
 
147
 
148
    for (i=0 ; i
149
	if (playeringame[i])
150
	    P_PlayerThink (&players[i]);
151
 
152
    P_RunThinkers ();
153
    P_UpdateSpecials ();
154
    P_RespawnSpecials ();
155
 
156
    // for par times
157
    leveltime++;
158
}