]> jfr.im git - irc/gameservirc.git/blob - gameserv/extern.h
89216e942f1b1deb8342dae927247809ca7bb0d6
[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 E list<item*> store; // The list of items available at the store
122
123 /* find.cpp begin */
124 E item *findItemByID(int id);
125 E item *findStoreItemByID(int id);
126 E tavernItem *findTavernItemByID(int id);
127 /* find.cpp end */
128
129 /** tcpclient.cpp **/
130 E void check_idles();
131 E void clearClients();
132 E void clearPlayers();
133
134 /** List search functions **/
135 E aClient *find(char *nick);
136 E aClient *find(const char *nick);
137 E aClient *findbynick(char *nick);
138 E aClient *findbynick(const char *nick);
139 E aClient *findbyrealnick(char *realnick);
140 E Player *findplayer(const char *name);
141 #ifdef P10
142 E aClient *findbyrealnick(char *realnick);
143 #endif
144
145 /** tcpclient.cpp **/
146
147 /** Sock writing functions **/
148 E void notice(const char *source, const char *dest, const char *fmt, ...);
149 E void raw(const char *fmt, ...);
150
151 /** news.cpp **/
152 E void addNews(list<string> &news, const char *fmt, ...);
153 E void do_news(char *u);
154 E void clearNews(list<string> &news);
155 E void loadNews(char *filename, list<string> &news);
156 E void saveNews(char *filename, list<string> &news);
157 E void showNews(char *nick, list<string> &news);
158
159 /** gameserv.cpp **/
160 E item *findItemByID(int id);
161 E int hpbonus[LEVELS - 1];
162 E int strbonus[LEVELS - 1];
163 E int defbonus[LEVELS - 1];
164 E void gameserv(char *source, char *buf);
165 E Level levels[LEVELS];
166 E list<item*> Items;
167 E list<tavernItem> tavern;
168 E toplist myToplist;
169
170 /** forest.cpp **/
171 E void forest(char *source, char *buf);
172
173 /** functions.cpp **/
174
175 E bool is_playing(char *u);
176 E bool is_playing(aClient *user);
177
178 E bool is_fighting(char *u);
179 E bool is_fighting(aClient *user);
180
181 E bool player_fight(char *u);
182 E bool player_fight(aClient *user);
183
184 E bool dragon_fight(aClient *user);
185
186 E bool master_fight(char *u);
187 E bool master_fight(aClient *user);
188
189 E bool alphaNumeric(const char *str);
190
191 #ifndef HAVE_STRTOK
192 E char *strtok(char *str, const char *delim);
193 #endif
194
195 E char *spaces(int len, char *seperator);
196 E void display_monster(char *u);
197 E void display_players(char *u);
198 E void display_players(aClient *user);
199 E int stricmp(const char *s1, const char *s2);
200 E int strnicmp(const char *s1, const char *s2, size_t len);
201 E long int chartoint(char ch);
202 E int isstringnum(char *num);
203 E long int pow (int x, int y);
204 E long int stringtoint(char *number);
205 E bool load_masters();
206 E bool load_monsters();
207 E bool load_levels();
208 E void delete_monsters();
209 E void delete_masters();
210 E Monster *getNewMonster(Monster *m);
211 E void deleteMonster(Monster *m);
212 E void refresh(Player *p);
213 E void refreshall();
214 E void rolloverall();
215 E void rollover(Player *p);
216 E void updateTS(Player *p);
217 E bool timedOut(Player *p);
218 E void timeOutEvent(Player *p);
219 E void reset(Player *p);
220 E void resetall();
221
222 E void do_attack(char *u);
223 E void do_bank(char *u);
224 E void do_check(char *u);
225 E void do_equip(char *u);
226 E void do_fight(char *u);
227 E void do_forest(char *u);
228 E void do_heal(char *u);
229 E void do_identify(char *u);
230 E void do_invenory(char *u);
231 E void do_list(char *u);
232 E void do_logout(char *u);
233 E void do_play(char *u);
234 E void do_quitg(char *u);
235 E void do_refresh(char *u);
236 E void do_register(char *u);
237 E void do_reset(char *u);
238 E void do_run(char *u);
239 E void do_set(char *u);
240 E void do_stats(char *u);
241 E void do_store(char *u);
242 E void do_tavern(char *u);
243 E void do_use(char *u);
244 E void see_mystic(char *u);
245
246 E void logout(aClient *user); // log a user off the game
247 E void showstats(const char *u, const char *nick);
248 E void showinventory(Player *from, aClient *to);
249 /* Database saving stuff */
250
251 E int save_gs_dbase();
252 E int load_gs_dbase();
253 E int load_tavern();
254 E int load_items();
255 E int load_store();
256 E int load_dragon();
257 E int save_dragon();
258
259 // Log File Stuff
260 E void log(const char *fmt, ...);
261
262 #endif