Annotation of doom/p_tick.c, revision 1.1.1.3

1.1       root        1: 
1.1.1.3 ! root        2: //**************************************************************************
        !             3: //**
        !             4: //** p_tick.c : Heretic 2 : Raven Software, Corp.
        !             5: //**
        !             6: //** $RCSfile: p_tick.c,v $
        !             7: //** $Revision: 1.5 $
        !             8: //** $Date: 95/10/08 21:53:00 $
        !             9: //** $Author: bgokey $
        !            10: //**
        !            11: //**************************************************************************
1.1       root       12: 
1.1.1.3 ! root       13: // HEADER FILES ------------------------------------------------------------
1.1.1.2   root       14: 
1.1.1.3 ! root       15: #include "h2def.h"
        !            16: #include "p_local.h"
1.1       root       17: 
1.1.1.3 ! root       18: // MACROS ------------------------------------------------------------------
1.1       root       19: 
1.1.1.3 ! root       20: // TYPES -------------------------------------------------------------------
1.1       root       21: 
1.1.1.3 ! root       22: // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
1.1.1.2   root       23: 
1.1.1.3 ! root       24: // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
1.1.1.2   root       25: 
1.1.1.3 ! root       26: // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
1.1.1.2   root       27: 
1.1.1.3 ! root       28: static void RunThinkers(void);
1.1       root       29: 
1.1.1.3 ! root       30: // EXTERNAL DATA DECLARATIONS ----------------------------------------------
1.1       root       31: 
1.1.1.3 ! root       32: // PUBLIC DATA DEFINITIONS -------------------------------------------------
1.1       root       33: 
1.1.1.3 ! root       34: int leveltime;
        !            35: int TimerGame;
        !            36: thinker_t thinkercap; // The head and tail of the thinker list
1.1.1.2   root       37: 
1.1.1.3 ! root       38: // PRIVATE DATA DEFINITIONS ------------------------------------------------
1.1       root       39: 
1.1.1.3 ! root       40: // CODE --------------------------------------------------------------------
1.1       root       41: 
1.1.1.3 ! root       42: //==========================================================================
1.1.1.2   root       43: //
1.1.1.3 ! root       44: // P_Ticker
1.1.1.2   root       45: //
1.1.1.3 ! root       46: //==========================================================================
1.1.1.2   root       47: 
1.1.1.3 ! root       48: void P_Ticker(void)
1.1       root       49: {
1.1.1.3 ! root       50:        int i;
1.1       root       51: 
1.1.1.3 ! root       52:        if(paused)
1.1       root       53:        {
1.1.1.3 ! root       54:                return;
1.1.1.2   root       55:        }
1.1.1.3 ! root       56:        for(i = 0; i < MAXPLAYERS; i++)
1.1.1.2   root       57:        {
1.1.1.3 ! root       58:                if(playeringame[i])
1.1       root       59:                {
1.1.1.3 ! root       60:                        P_PlayerThink(&players[i]);
1.1       root       61:                }
                     62:        }
1.1.1.3 ! root       63:        if(TimerGame)
1.1       root       64:        {
1.1.1.3 ! root       65:                if(!--TimerGame)
1.1.1.2   root       66:                {
1.1.1.3 ! root       67:                        G_Completed(P_TranslateMap(P_GetMapNextMap(gamemap)), 0);
1.1       root       68:                }
                     69:        }
1.1.1.3 ! root       70:        RunThinkers();
        !            71:        P_UpdateSpecials();
        !            72:        P_AnimateSurfaces();
        !            73:        leveltime++;
1.1       root       74: }
                     75: 
1.1.1.3 ! root       76: //==========================================================================
        !            77: //
        !            78: // RunThinkers
        !            79: //
        !            80: //==========================================================================
1.1.1.2   root       81: 
1.1.1.3 ! root       82: static void RunThinkers(void)
1.1       root       83: {
1.1.1.3 ! root       84:        thinker_t *currentthinker;
        !            85: 
        !            86:        currentthinker = thinkercap.next;
        !            87:        while(currentthinker != &thinkercap)
1.1       root       88:        {
1.1.1.3 ! root       89:                if(currentthinker->function == (think_t)-1)
        !            90:                { // Time to remove it
        !            91:                        currentthinker->next->prev = currentthinker->prev;
        !            92:                        currentthinker->prev->next = currentthinker->next;
        !            93:                        Z_Free(currentthinker);
        !            94:                }
        !            95:                else if(currentthinker->function)
1.1.1.2   root       96:                {
1.1.1.3 ! root       97:                        currentthinker->function(currentthinker);
1.1.1.2   root       98:                }
1.1.1.3 ! root       99:                currentthinker = currentthinker->next;
1.1       root      100:        }
                    101: }
                    102: 
1.1.1.3 ! root      103: //==========================================================================
        !           104: //
        !           105: // P_InitThinkers
        !           106: //
        !           107: //==========================================================================
1.1       root      108: 
1.1.1.3 ! root      109: void P_InitThinkers(void)
1.1       root      110: {
1.1.1.2   root      111:        thinkercap.prev = thinkercap.next  = &thinkercap;
                    112: }
1.1       root      113: 
1.1.1.3 ! root      114: //==========================================================================
        !           115: //
        !           116: // P_AddThinker
        !           117: //
        !           118: // Adds a new thinker at the end of the list.
        !           119: //
        !           120: //==========================================================================
1.1       root      121: 
1.1.1.3 ! root      122: void P_AddThinker(thinker_t *thinker)
1.1.1.2   root      123: {
                    124:        thinkercap.prev->next = thinker;
                    125:        thinker->next = &thinkercap;
                    126:        thinker->prev = thinkercap.prev;
                    127:        thinkercap.prev = thinker;
                    128: }
                    129: 
1.1.1.3 ! root      130: //==========================================================================
        !           131: //
        !           132: // P_RemoveThinker
1.1.1.2   root      133: //
1.1.1.3 ! root      134: // Deallocation is lazy -- it will not actually be freed until its
        !           135: // thinking turn comes up.
1.1.1.2   root      136: //
1.1.1.3 ! root      137: //==========================================================================
1.1       root      138: 
1.1.1.3 ! root      139: void P_RemoveThinker(thinker_t *thinker)
1.1       root      140: {
1.1.1.3 ! root      141:        thinker->function = (think_t)-1;
1.1.1.2   root      142: }

unix.superglobalmegacorp.com

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