]> jfr.im git - irc/gameservirc.git/blob - gameserv/extern.h
Added code for the start of the DataLayer format as well as a basic FilePlayerDAO...
[irc/gameservirc.git] / gameserv / extern.h
1 #ifndef EXTERN_H
2 #define EXTERN_H
3
4 #define E extern
5
6 #define LEVELS 12 // Levels in the game
7 #define REALLEVELS 12 // Levels to load from monsters.dat
8 #define MONSTERS 12 // Monsters per level
9 #define WNA 16 // Weapons and armor
10
11 #include <stdarg.h>
12 #include <list>
13 #include <string>
14
15 #include "config.h"
16 #include "options.h"
17
18 using namespace std;
19
20 #if TIME_WITH_SYS_TIME
21 # include <sys/time.h>
22 # include <time.h>
23 #else
24 # if HAVE_SYS_TIME_H
25 # include <sys/time.h>
26 # else
27 # include <time.h>
28 # endif
29 #endif
30
31 // Forward declarations
32 class toplist;
33 class Player;
34 class aClient;
35 class Level;
36 class item;
37 class itemContainer;
38 class weapon;
39 class armor;
40 class potion;
41 class tavernItem;
42 class Monster;
43
44 // Hash.cpp stuff start
45 #define U_TABLE_SIZE 1999
46 E unsigned long sHASH(const unsigned char *name);
47 E unsigned long iHASH(const unsigned char *name);
48 // hash.cpp stuff end
49
50 E long lastrefresh;
51 E long lastrollover;
52 E void save_lastrefresh();
53 E void load_lastrefresh();
54 E void save_lastrollover();
55 E void load_lastrollover();
56
57 // The socket
58 E int sock;
59
60
61 /* config.cpp start */
62 E int load_config_file(char *config = "gameserv.conf");
63 E void unload_config_file();
64 E char *s_GameServ;
65 E char *c_Forest;
66 E char *c_ForestTopic;
67 E char *gshost;
68 E char *gsident;
69 E char *pidfile;
70 E char *newsdata;
71 E char *nsname;
72 E char *nspass;
73 E Monster dragon;
74
75 #if defined(P10)
76 E char *gsnum;
77 #endif
78
79 E char *servername;
80 E char *localhost;
81 E char *remoteserver;
82 E int remoteport;
83 E char *remotepass;
84 E char *playerdata;
85 E char *itemdata;
86 E char *tavernitemdata;
87 E char *storeitemdata;
88 E char *dragondata;
89 E char *masterdata;
90 E char *logfile;
91 E char *adminpass;
92 E char *VERSION;
93 E char *PACKAGE;
94 E char *welcomemsg;
95 E char *ignoreserverslist;
96
97 E long configflags;
98 E long refreshperiod;
99 E long rolloverperiod;
100 E long numrolloverfights;
101 E int level1expire;
102 E int defaultexpire;
103 E bool shuttingdown;
104 E int welcomedelay;
105 E int updateperiod;
106 E int forestfights;
107 E int maxafightdistance;
108 E int maxbfightdistance;
109 E int maxidletime;
110 E int idlecheckperiod;
111 E int maxitems;
112 E long maxforestfights;
113 E unsigned int maxnicklen;
114
115 /* config.cpp end */
116
117 E list<Player*> players[U_TABLE_SIZE];
118 E list<aClient*> clients[U_TABLE_SIZE];
119 E list<string> todaysnews;
120 E list<item*> store; // The list of items available at the store
121
122 /* misc.cpp begin */
123 E void end_turn(aClient *user);
124 E void see_master(char *u);
125
126 /* misc.cpp end */
127 /* find.cpp begin */
128 E item *findItemByID(int id);
129 E item *findStoreItemByID(int id);
130 E tavernItem *findTavernItemByID(int id);
131 /* find.cpp end */
132
133 /* messages.cpp begin */
134 E void display_help(char *u, char *file);
135 E void display_monster(char *u);
136 E void display_players(char *u);
137 E void display_players(aClient *user);
138 E void showBankBalance(const char *u);
139 void showTavern(aClient *user);
140 /* messages.cpp end */
141
142 /* boolean.cpp begin */
143 E bool check_password(char *name, char *plaintext);
144 /* boolean.cpp end */
145
146 /** tcpclient.cpp **/
147 E void check_idles();
148 E void clearClients();
149 E void clearPlayers();
150
151 /** List search functions **/
152 E aClient *find(char *nick);
153 E aClient *find(const char *nick);
154 E aClient *findbynick(char *nick);
155 E aClient *findbynick(const char *nick);
156 E aClient *findbyrealnick(char *realnick);
157 E Player *findplayer(const char *name);
158 #ifdef P10
159 E aClient *findbyrealnick(char *realnick);
160 #endif
161
162 /** tcpclient.cpp **/
163
164 /** Sock writing functions **/
165 E void notice(const char *source, const char *dest, const char *fmt, ...);
166 E void raw(const char *fmt, ...);
167
168 /** news.cpp **/
169 E void addNews(list<string> &news, const char *fmt, ...);
170
171 E void clearNews(list<string> &news);
172 E void loadNews(char *filename, list<string> &news);
173 E void saveNews(char *filename, list<string> &news);
174 E void showNews(char *nick, list<string> &news);
175
176 /** gameserv.cpp **/
177 E void do_admin(char *u);
178 E void do_attack(char *u);
179 E void do_bank(char *u);
180 E void do_check(char *u);
181 E void do_equip(char *u);
182 E void do_fight(char *u);
183 E void do_heal(char *u);
184 E void do_help(char *u);
185 E void do_identify(char *u);
186 E void do_inventory(char *u);
187 E void do_refresh(char *u);
188 E void do_register(char *u);
189 E void do_list(char *u);
190 E void do_load(char *u);
191 E void do_logout(char *u);
192 E void do_master(char *u);
193 E void do_news(char *u);
194 E void do_dragon(char *u);
195 E void do_play(char *u);
196 E void do_quitg(char *u);
197 E void do_raw(char *u);
198 E void do_reset(char *u);
199 E void do_run(char *u);
200 E void do_save(char *u);
201 E void do_set(char *u);
202 E void do_shutdown(char *u);
203 E void do_stats(char *u);
204 E void do_store(char *u);
205 E void do_tavern(char *u);
206 E void do_use(char *u);
207
208 E item *findItemByID(int id);
209 E int hpbonus[LEVELS - 1];
210 E int strbonus[LEVELS - 1];
211 E int defbonus[LEVELS - 1];
212 E void gameserv(char *source, char *buf);
213 E Level levels[LEVELS];
214 E list<item*> Items;
215 E list<tavernItem> tavern;
216 E toplist myToplist;
217
218 /** forest.cpp **/
219 E void forest(char *source, char *buf);
220
221 /** functions.cpp **/
222
223 E bool is_playing(char *u);
224 E bool is_playing(aClient *user);
225
226 E bool is_fighting(char *u);
227 E bool is_fighting(aClient *user);
228
229 E bool player_fight(char *u);
230 E bool player_fight(aClient *user);
231
232 E bool dragon_fight(aClient *user);
233
234 E bool master_fight(char *u);
235 E bool master_fight(aClient *user);
236
237 E bool alphaNumeric(const char *str);
238
239 #ifndef HAVE_STRTOK
240 E char *strtok(char *str, const char *delim);
241 #endif
242
243 E char *spaces(int len, char *seperator);
244
245 E int stricmp(const char *s1, const char *s2);
246 E int strnicmp(const char *s1, const char *s2, size_t len);
247 E long int chartoint(char ch);
248 E int isstringnum(char *num);
249 E long int pow (int x, int y);
250 E long int stringtoint(char *number);
251 E bool load_masters();
252 E bool load_monsters();
253 E bool load_levels();
254 E void delete_monsters();
255 E void delete_masters();
256 E void deleteMonster(Monster *m);
257 E void refresh(Player *p);
258 E void refreshall();
259 E void rolloverall();
260 E void rollover(Player *p);
261 E void updateTS(Player *p);
262 E bool timedOut(Player *p);
263 E void timeOutEvent(Player *p);
264 E void reset(Player *p);
265 E void resetall();
266
267 E void do_attack(char *u);
268 E void do_bank(char *u);
269 E void do_check(char *u);
270 E void do_equip(char *u);
271 E void do_fight(char *u);
272 E void do_forest(char *u);
273 E void do_heal(char *u);
274 E void do_invenory(char *u);
275 E void do_list(char *u);
276 E void do_logout(char *u);
277 E void do_play(char *u);
278 E void do_quitg(char *u);
279 E void do_refresh(char *u);
280 E void do_register(char *u);
281 E void do_reset(char *u);
282 E void do_run(char *u);
283 E void do_set(char *u);
284 E void do_stats(char *u);
285 E void do_store(char *u);
286 E void do_tavern(char *u);
287 E void do_use(char *u);
288 E void see_mystic(char *u);
289
290 E void logout(aClient *user); // log a user off the game
291 E void showstats(const char *u, const char *nick);
292 E void showinventory(Player *from, aClient *to);
293 /* Database saving stuff */
294
295 E int save_gs_dbase();
296 E int load_gs_dbase();
297 E int load_tavern();
298 E int load_items();
299 E int load_store();
300 E int load_dragon();
301 E int save_dragon();
302
303 // Log File Stuff
304 E void log(const char *fmt, ...);
305
306 #endif