]> jfr.im git - irc/gameservirc.git/blob - gameserv/extern.h
7a31bc0cf1dc275400d6f05403d36b0209503c6f
[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 std::list;
19 using std::string;
20
21 #if TIME_WITH_SYS_TIME
22 # include <sys/time.h>
23 # include <time.h>
24 #else
25 # if HAVE_SYS_TIME_H
26 # include <sys/time.h>
27 # else
28 # include <time.h>
29 # endif
30 #endif
31
32 // Forward declarations
33 class toplist;
34 class Player;
35 class aClient;
36 class Level;
37 class item;
38 class itemContainer;
39 class weapon;
40 class armor;
41 class potion;
42 class tavernItem;
43 class Monster;
44
45 // Hash.cpp stuff start
46 #define U_TABLE_SIZE 1999
47 E unsigned long sHASH(const unsigned char *name);
48 E unsigned long iHASH(const unsigned char *name);
49 // hash.cpp stuff end
50
51 E long lastrefresh;
52 E long lastrollover;
53 E void save_lastrefresh();
54 E void load_lastrefresh();
55 E void save_lastrollover();
56 E void load_lastrollover();
57
58 // The socket
59 E int sock;
60
61
62 /* config.cpp start */
63 E int load_config_file(char *config = "gameserv.conf");
64 E void unload_config_file();
65 E char *s_GameServ;
66 E char *c_Forest;
67 E char *c_ForestTopic;
68 E char *gshost;
69 E char *gsident;
70 E char *pidfile;
71 E char *newsdata;
72 E char *nsname;
73 E char *nspass;
74 E Monster dragon;
75
76 #if defined(P10)
77 E char *gsnum;
78 #endif
79
80 E char *servername;
81 E char *localhost;
82 E char *remoteserver;
83 E int remoteport;
84 E char *remotepass;
85 E char *playerdata;
86 E char *itemdata;
87 E char *tavernitemdata;
88 E char *storeitemdata;
89 E char *dragondata;
90 E char *masterdata;
91 E char *logfile;
92 E char *adminpass;
93 E char *VERSION;
94 E char *PACKAGE;
95 E char *welcomemsg;
96 E char *ignoreserverslist;
97
98 E long configflags;
99 E long refreshperiod;
100 E long rolloverperiod;
101 E long numrolloverfights;
102 E int level1expire;
103 E int defaultexpire;
104 E bool shuttingdown;
105 E int welcomedelay;
106 E int updateperiod;
107 E int forestfights;
108 E int maxafightdistance;
109 E int maxbfightdistance;
110 E int maxidletime;
111 E int idlecheckperiod;
112 E int maxitems;
113 E long maxforestfights;
114 E unsigned int maxnicklen;
115
116 /* config.cpp end */
117
118 E list<Player*> players[U_TABLE_SIZE];
119 E list<aClient*> clients[U_TABLE_SIZE];
120 E list<string> todaysnews;
121
122 /** tcpclient.cpp **/
123 E void check_idles();
124 E void clearClients();
125 E void clearPlayers();
126
127 /** List search functions **/
128 E aClient *find(char *nick);
129 E aClient *find(const char *nick);
130 E aClient *findbynick(char *nick);
131 E aClient *findbynick(const char *nick);
132 E aClient *findbyrealnick(char *realnick);
133 E Player *findplayer(const char *name);
134 #ifdef P10
135 E aClient *findbyrealnick(char *realnick);
136 #endif
137
138 /** tcpclient.cpp **/
139
140 /** Sock writing functions **/
141 E void notice(const char *source, const char *dest, const char *fmt, ...);
142 E void raw(const char *fmt, ...);
143
144 /** news.cpp **/
145 E void addNews(list<string> &news, const char *fmt, ...);
146 E void do_news(char *u);
147 E void clearNews(list<string> &news);
148 E void loadNews(char *filename, list<string> &news);
149 E void saveNews(char *filename, list<string> &news);
150 E void showNews(char *nick, list<string> &news);
151
152 /** gameserv.cpp **/
153 E item *findItemByID(int id);
154 E int hpbonus[LEVELS - 1];
155 E int strbonus[LEVELS - 1];
156 E int defbonus[LEVELS - 1];
157 E void gameserv(char *source, char *buf);
158 E Level levels[LEVELS];
159 E list<item*> Items;
160 E list<tavernItem> tavern;
161 E toplist myToplist;
162
163 /** forest.cpp **/
164 E void forest(char *source, char *buf);
165
166 /** functions.cpp **/
167
168 E bool is_playing(char *u);
169 E bool is_playing(aClient *user);
170
171 E bool is_fighting(char *u);
172 E bool is_fighting(aClient *user);
173
174 E bool player_fight(char *u);
175 E bool player_fight(aClient *user);
176
177 E bool dragon_fight(aClient *user);
178
179 E bool master_fight(char *u);
180 E bool master_fight(aClient *user);
181
182 E bool alphaNumeric(const char *str);
183
184 #ifndef HAVE_STRTOK
185 E char *strtok(char *str, const char *delim);
186 #endif
187
188 E char *spaces(int len, char *seperator);
189 E void display_monster(char *u);
190 E void display_players(char *u);
191 E void display_players(aClient *user);
192 E int stricmp(const char *s1, const char *s2);
193 E int strnicmp(const char *s1, const char *s2, size_t len);
194 E long int chartoint(char ch);
195 E int isstringnum(char *num);
196 E long int pow (int x, int y);
197 E long int stringtoint(char *number);
198 E bool load_masters();
199 E bool load_monsters();
200 E bool load_levels();
201 E void delete_monsters();
202 E void delete_masters();
203 E Monster *getNewMonster(Monster *m);
204 E void deleteMonster(Monster *m);
205 E void refresh(Player *p);
206 E void refreshall();
207 E void rolloverall();
208 E void rollover(Player *p);
209 E void updateTS(Player *p);
210 E bool timedOut(Player *p);
211 E void timeOutEvent(Player *p);
212 E void reset(Player *p);
213 E void resetall();
214
215 E void do_attack(char *u);
216 E void do_bank(char *u);
217 E void do_check(char *u);
218 E void do_equip(char *u);
219 E void do_fight(char *u);
220 E void do_forest(char *u);
221 E void do_heal(char *u);
222 E void do_identify(char *u);
223 E void do_invenory(char *u);
224 E void do_list(char *u);
225 E void do_logout(char *u);
226 E void do_play(char *u);
227 E void do_quitg(char *u);
228 E void do_refresh(char *u);
229 E void do_register(char *u);
230 E void do_reset(char *u);
231 E void do_run(char *u);
232 E void do_set(char *u);
233 E void do_stats(char *u);
234 E void do_store(char *u);
235 E void do_tavern(char *u);
236 E void do_use(char *u);
237 E void see_mystic(char *u);
238
239 E void logout(aClient *user); // log a user off the game
240 E void showstats(const char *u, const char *nick);
241 E void showinventory(Player *from, aClient *to);
242 /* Database saving stuff */
243
244 E int save_gs_dbase();
245 E int load_gs_dbase();
246 E int load_tavern();
247 E int load_items();
248 E int load_store();
249 E int load_dragon();
250 E int save_dragon();
251
252 // Log File Stuff
253 E void log(const char *fmt, ...);
254
255 #endif