1 /*
2    playerlist.h
3 
4    All functions which update the playerlist should include this
5    header file.
6  */
7 
8 #ifndef h_playerlist
9 #define h_playerlist
10 
11 
12 /*
13    Constants.
14 */
15 
16 #define PLISTLASTSTYLE 4  /* The number of the default last plist style */
17 
18 
19 /*
20    Global Variables
21 
22    partitionPlist    : Separate the goodies from baddies in the sorted list?
23    plistCustomLayout : The value of `playerlist' in the defaults file.
24    plistReorder      : True only if the order of the playerlist is out of date.
25    plistStyle        : The current style number for the player list.
26    plistUpdated      : True only if the player list is out of date.
27    sortMyTeamFirst   : Should my team go first or second in the sorted list?
28    sortPlayers       : Should the player list be sorted?
29    updatePlayer[plr] : The playerlist entry for "plr" is old.
30 
31    plistHasHostile   : True if "Hostile" is a field in the current list.
32    plistHasSpeed     : True if "Speed" is true in the current playerlist.
33 */
34 
35 extern int partitionPlist;
36 extern char *plistCustomLayout;
37 extern int plistReorder;
38 extern int plistStyle;
39 extern int plistUpdated;
40 extern int sortMyTeamFirst;
41 extern int sortPlayers;
42 extern char updatePlayer[MAXPLAYER+1];
43 
44 #ifdef PLIST2
45 extern int plistHasHostile = FALSE;
46 extern int plistHasSpeed = FALSE;
47 #endif
48 
49 
50 /*
51    Macro Declarations
52 */
53 
54 
55 /*
56    void PlistNoteUpdate(i)
57 	int i;
58 
59    Note the update of a player so that the entry in the player list
60    can be update.
61 */
62 #define PlistNoteUpdate(i) { updatePlayer[i] = 1; plistUpdated = 1; }
63 
64 
65 /*
66    void PlistNoteArrive(i)
67 	int i;
68 
69    Note the arrive or leaving of a player from a team.  This
70    call should also be made if a player changes teams.
71 */
72 #define PlistNoteArrive(i) { plistReorder = 1; }
73 
74 
75 /*
76    void PlistNoteHostile(i)
77 	int i;
78 
79    Note the change in war status of player `i'.  Only update if
80    the war status is shown on the current player list.
81 */
82 #ifdef PLIST2
83 #define PlistNoteHostile(i) { if (plistHasHostile) PlistNoteUpdate(i); }
84 #else
85 #define PlistNoteHostile(i) {};
86 #endif
87 
88 
89 /*
90    void PlistNoteSpeed(i)
91 	int i;
92 
93    Note the change in speed of player `i'.  Only update if
94    speed is shown on the current player list.
95 */
96 #ifdef PLIST2
97 #define PlistNoteSpeed(i) { if (plistHasSpeed) PlistNoteUpdate(i); }
98 #else
99 #define PlistNoteSpeed(i) {};
100 #endif
101 
102 
103 /*
104    Function Declarations
105 */
106 
107 void InitPlayerList(void);
108 /*
109    Set the global variables associtated with the player list.
110 
111    This should be called when the defaults file is loaded or reloaded.
112 */
113 
114 
115 int PlistMaxWidth(void);
116 /*
117    Calculate the maximum width of all the defined player lists so
118    that the width of the player list window can be defined.
119 */
120 
121 
122 void RedrawPlayerList(void);
123 /*
124    Completly redraw the player list, rather than incrimentally updating
125    the list as with UpdatePlayerList().
126 
127    This function should be called if the plistStyle changes or if the
128    window has just been revealed.
129 
130    This function is called automatically from InitPlayerList.
131 */
132 
133 
134 /*
135    void UpdatePlayerList()
136 
137 
138    Update the player list.
139 
140    This function works incrimentally.  If a dramatic change has taken
141    place (i.e. if plistStyle changes) then RedrawPlayerList() should
142    be called instead.
143 
144    This function is called through a macro.  It is expected that 9
145    times out of 10 the call will not do any work.  We can predict
146    when work will be done by looking at "plistUpdated".  To avoid
147    redundant procedure calls, the macro only calls the function if
148    plistUpdated suggests that work will be done.
149 */
150 void UpdatePlistFn(void);
151 #define UpdatePlayerList()	if (plistUpdated) UpdatePlistFn()
152 
153 
154 #endif /* defined h_playerlist */
155