1 /*
2  * cfg_player.h - player configuration data
3  *
4  * $Id: cfg_player.h,v 1.10 2006/02/09 21:21:23 fzago Exp $
5  *
6  * Program XBLAST
7  * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published
11  * by the Free Software Foundation; either version 2; or (at your option)
12  * any later version
13  *
14  * This program is distributed in the hope that it will be entertaining,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.
21  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 #ifndef XBLAST_CFG_PLAYER_H
24 #define XBLAST_CFG_PLAYER_H
25 
26 /*
27  * macros
28  */
29 #define NUM_PLAYER_COLORS   7
30 #define NUM_DEFAULT_PLAYERS 6
31 
32 /*
33  * type definitions
34  */
35 
36 /* player graphics */
37 typedef struct
38 {
39 	XBAtom shape;
40 	XBColor helmet;
41 	XBColor face;
42 	XBColor body;
43 	XBColor handsFeet;
44 	XBColor armsLegs;
45 	XBColor backpack;
46 	XBColor white;				/* needed for convenience */
47 	XBColor bodySave;
48 	XBColor handsFeetSave;
49 } CFGPlayerGraphics;
50 
51 /* player messages */
52 typedef struct
53 {
54 	const char *msgWinLevel;
55 	const char *msgWinGame;
56 	const char *msgLoseLife;
57 	const char *msgLoseLevel;
58 	const char *msgLaola;
59 	const char *msgLoser;
60 	const char *msgGloat;
61 	const char *msgWelcome;
62 } CFGPlayerMessages;
63 
64 /* misc player options */
65 typedef struct
66 {
67 	XBBool useStopKey;
68 	int turnStepKeyboard;
69 	int turnStepJoystick;
70 } CFGPlayerMisc;
71 
72 /* player identity */
73 typedef struct
74 {
75 	int PID;
76 	const char *pass;
77 } CFGPlayerID;
78 
79 /* player rating */
80 typedef struct
81 {
82 	double rating;
83 	int gamesPlayed;
84 	int realWins;
85 	int relativeWins;
86 	time_t timeUpdate;
87 	time_t timeRegister;
88 } CFGPlayerRating;
89 
90 /* all in one */
91 typedef struct
92 {
93 	CFGPlayerGraphics graphics;
94 	CFGPlayerMessages messages;
95 	CFGPlayerMisc misc;
96 	CFGPlayerID id;
97 	const char *name;
98 } CFGPlayer;
99 
100 /* all in one */
101 typedef struct
102 {
103 	CFGPlayerGraphics graphics;
104 	CFGPlayerMessages messages;
105 	CFGPlayerMisc misc;
106 	CFGPlayerID id;
107 	CFGPlayerRating rating;
108 	const char *name;
109 } CFGPlayerEx;
110 
111 /*
112  * function prototypes
113  */
114 extern void LoadPlayerCentral (XBBool amCentral);	/* XBCC  */
115 extern void SavePlayerCentral (void);
116 extern void FinishPlayerCentral (void);
117 
118 extern void LoadPlayerConfig (void);
119 extern void SavePlayerConfig (void);
120 extern void FinishPlayerConfig (void);
121 
122 extern void RemoveAllPlayers (CFGType);
123 
124 extern XBBool ComparePlayerGraphics (const CFGPlayerGraphics *, const CFGPlayerGraphics *);
125 
126 extern int GetNumPlayerConfigs (CFGType);
127 extern XBAtom GetPlayerAtom (CFGType, int index);
128 extern const char *GetPlayerName (CFGType, XBAtom atom);
129 extern int FindDoubleName (CFGType cfgType, XBAtom newplayer);
130 
131 extern void StorePlayer (CFGType, XBAtom, const CFGPlayer *);
132 extern void StorePlayerEx (CFGType, XBAtom, const CFGPlayerEx *);	// XBCC extended player format
133 extern void StorePlayerRating (CFGType, XBAtom, const CFGPlayerRating *);	// XBCC extended player format
134 extern void StorePlayerID (CFGType, XBAtom, const CFGPlayerID *);	// XBCC
135 extern void StorePlayerGraphics (CFGType, XBAtom, const CFGPlayerGraphics *);
136 extern void StorePlayerMessages (CFGType, XBAtom, const CFGPlayerMessages *);
137 extern void StorePlayerMisc (CFGType, XBAtom, const CFGPlayerMisc *);
138 
139 extern XBBool RetrievePlayer (CFGType, XBAtom, XBColor, CFGPlayer *);
140 extern XBBool RetrievePlayerEx (CFGType, XBAtom, CFGPlayerEx *);	// XBCC extended player format
141 extern XBBool RetrievePlayerRating (CFGType, XBAtom, CFGPlayerRating *);	// XBCC extended player format
142 extern XBBool RetrievePlayerID (CFGType, XBAtom, CFGPlayerID *);	// XBCC
143 extern XBBool RetrievePlayerMessages (CFGType, XBAtom, CFGPlayerMessages *);
144 extern XBBool RetrievePlayerGraphics (CFGType, XBAtom, XBColor, CFGPlayerGraphics *);
145 extern XBBool RetrievePlayerMisc (CFGType, XBAtom, CFGPlayerMisc *);
146 
147 extern XBAtom CreateNewPlayerConfig (CFGType, const char *name);
148 extern XBAtom RenamePlayerConfig (CFGType, XBAtom atom, const char *name);
149 extern void DeletePlayerConfig (CFGType, XBAtom atom);
150 extern XBBool SendPlayerConfig (CFGType, XBSndQueue * sndQueue, XBTeleCOT cot, XBTeleIOB iob,
151 								XBAtom atom, XBBool toCentral);
152 extern void AddToPlayerConfig (CFGType, XBAtom atom, const char *text);
153 
154 extern XBBool RetrievePlayerID (CFGType cfgType, XBAtom atom, CFGPlayerID *);
155 extern void StorePlayerID (CFGType cfgType, XBAtom atom, const CFGPlayerID *);
156 
157 extern void StoreGameResult (CFGType cfgType, XBAtom atom, int k, int *regPl, int *PID, int *Score);	// XBST
158 extern void AppendGameResult (CFGType cfgType, XBAtom fname, XBAtom atom, int k, int *regPl,
159 							  int *PID, int *Score);
160 
161 extern void StoreTimePlayerRating (CFGType cfgType, XBAtom atom, int k, int *regPl, int *PID, float *rating);	// XBST
162 extern void AppendTimePlayerRating (CFGType cfgType, XBAtom fname, XBAtom atom, int k, int *regPl,
163 									int *PID, float *rating);
164 
165 /*
166  * global variables
167  */
168 extern const CFGPlayerGraphics *DefaultPlayerGraphics (size_t);
169 #endif
170 /*
171  * end of file cfg_player.h
172  */
173