Annotation of doom/p_tick.c, revision 1.1.1.6

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.6 ! root        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.
1.1.1.4   root       11: //
1.1.1.6 ! root       12: // The source is distributed in the hope that it will be useful,
1.1.1.4   root       13: // but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1.1.6 ! root       14: // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
        !            15: // for more details.
1.1.1.4   root       16: //
                     17: // $Log:$
                     18: //
                     19: // DESCRIPTION:
                     20: //     Archiving: SaveGame I/O.
                     21: //     Thinker, Ticker.
                     22: //
                     23: //-----------------------------------------------------------------------------
1.1       root       24: 
1.1.1.4   root       25: static const char
                     26: rcsid[] = "$Id: p_tick.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";
1.1.1.2   root       27: 
1.1.1.4   root       28: #include "z_zone.h"
1.1.1.3   root       29: #include "p_local.h"
1.1       root       30: 
1.1.1.4   root       31: #include "doomstat.h"
                     32: 
1.1       root       33: 
1.1.1.4   root       34: int    leveltime;
1.1       root       35: 
1.1.1.4   root       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: //
1.1.1.2   root       43: 
                     44: 
                     45: 
1.1.1.4   root       46: // Both the head and tail of the thinker list.
                     47: thinker_t      thinkercap;
1.1       root       48: 
                     49: 
1.1.1.4   root       50: //
                     51: // P_InitThinkers
                     52: //
                     53: void P_InitThinkers (void)
                     54: {
                     55:     thinkercap.prev = thinkercap.next  = &thinkercap;
                     56: }
1.1       root       57: 
1.1.1.2   root       58: 
1.1       root       59: 
                     60: 
1.1.1.2   root       61: //
1.1.1.4   root       62: // P_AddThinker
                     63: // Adds a new thinker at the end of the list.
1.1.1.2   root       64: //
1.1.1.4   root       65: void P_AddThinker (thinker_t* thinker)
1.1       root       66: {
1.1.1.4   root       67:     thinkercap.prev->next = thinker;
                     68:     thinker->next = &thinkercap;
                     69:     thinker->prev = thinkercap.prev;
                     70:     thinkercap.prev = thinker;
1.1       root       71: }
                     72: 
1.1.1.4   root       73: 
                     74: 
1.1.1.3   root       75: //
1.1.1.4   root       76: // P_RemoveThinker
                     77: // Deallocation is lazy -- it will not actually be freed
                     78: // until its thinking turn comes up.
1.1.1.3   root       79: //
1.1.1.4   root       80: void P_RemoveThinker (thinker_t* thinker)
1.1       root       81: {
1.1.1.4   root       82:   // FIXME: NOP.
                     83:   thinker->function.acv = (actionf_v)(-1);
1.1       root       84: }
                     85: 
1.1.1.4   root       86: 
                     87: 
1.1.1.3   root       88: //
1.1.1.4   root       89: // P_AllocateThinker
                     90: // Allocates memory and adds a new thinker at the end of the list.
1.1.1.3   root       91: //
1.1.1.4   root       92: void P_AllocateThinker (thinker_t*     thinker)
1.1       root       93: {
1.1.1.2   root       94: }
1.1       root       95: 
1.1.1.4   root       96: 
                     97: 
1.1.1.3   root       98: //
1.1.1.4   root       99: // P_RunThinkers
1.1.1.3   root      100: //
1.1.1.4   root      101: void P_RunThinkers (void)
1.1.1.2   root      102: {
1.1.1.4   root      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:     }
1.1.1.2   root      122: }
                    123: 
1.1.1.4   root      124: 
                    125: 
1.1.1.2   root      126: //
1.1.1.4   root      127: // P_Ticker
1.1.1.2   root      128: //
1.1.1.6 ! root      129: void WriteDebug(char *);
1.1       root      130: 
1.1.1.6 ! root      131: void P_Ticker(void)
1.1       root      132: {
1.1.1.4   root      133:     int                i;
                    134:     
                    135:     // run the tic
1.1.1.6 ! root      136:     if (paused) return;
1.1.1.4   root      137:                
                    138:     // pause if in menu and at least one tic has been run
1.1.1.6 ! root      139:     if (!netgame && menuactive && !demoplayback && players[consoleplayer].viewz != 1)
        !           140:        {
        !           141:         return;
        !           142:        }
1.1.1.4   root      143:     
1.1.1.6 ! root      144:     /* 11.9.98 optimized
        !           145:        for (i = 0; i < MAXPLAYERS; i++)
        !           146:                if (playeringame[i])
        !           147:        */
        !           148:        for(i=0; i<doomcom->numplayers; i++)
        !           149:                P_PlayerThink(&players[i]);
1.1.1.4   root      150:                        
1.1.1.6 ! root      151:     P_RunThinkers();
        !           152:     P_UpdateSpecials();
        !           153:     P_RespawnSpecials();
1.1.1.4   root      154: 
                    155:     // for par times
1.1.1.6 ! root      156:     leveltime++;
1.1.1.2   root      157: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.