#define E extern
#define LEVELS 12 // Levels in the game
+#define REALLEVELS 12 // Levels to load from monsters.dat
#define MONSTERS 12 // Monsters per level
+#define WNA 16 // Weapons and armor
#include <stdarg.h>
-#include "player.h"
-#include "list.h"
+#include <list>
+#include <string>
+
+#include "config.h"
+#include "options.h"
+
+using namespace std;
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+// Forward declarations
+class toplist;
+class Player;
+class aClient;
+class Level;
+class item;
+class itemContainer;
+class weapon;
+class armor;
+class potion;
+class tavernItem;
+class Monster;
+
+// Hash.cpp stuff start
+#define U_TABLE_SIZE 1999
+E unsigned long sHASH(const unsigned char *name);
+E unsigned long iHASH(const unsigned char *name);
+// hash.cpp stuff end
+
+E long lastrefresh;
+E long lastrollover;
+E void save_lastrefresh();
+E void load_lastrefresh();
+E void save_lastrollover();
+E void load_lastrollover();
// The socket
E int sock;
-// Random configuration stuff
-E void load_config_file(char *config = "gameserv.conf");
+/* config.cpp start */
+E int load_config_file(char *config = "gameserv.conf");
E void unload_config_file();
E char *s_GameServ;
E char *c_Forest;
E char *c_ForestTopic;
E char *gshost;
E char *gsident;
+E char *pidfile;
+E char *newsdata;
+E char *nsname;
+E char *nspass;
+E Monster dragon;
+
+#if defined(P10)
+E char *gsnum;
+#endif
+
E char *servername;
+E char *localhost;
E char *remoteserver;
-E char *remoteport;
+E int remoteport;
E char *remotepass;
E char *playerdata;
+E char *itemdata;
+E char *tavernitemdata;
+E char *storeitemdata;
+E char *dragondata;
+E char *masterdata;
+E char *logfile;
+E char *adminpass;
+E char *VERSION;
+E char *PACKAGE;
+E char *welcomemsg;
+E char *ignoreserverslist;
+
+E long configflags;
+E long refreshperiod;
+E long rolloverperiod;
+E long numrolloverfights;
+E int level1expire;
+E int defaultexpire;
+E bool shuttingdown;
+E int welcomedelay;
+E int updateperiod;
+E int forestfights;
+E int maxafightdistance;
+E int maxbfightdistance;
+E int maxidletime;
+E int idlecheckperiod;
+E int maxitems;
+E long maxforestfights;
+E unsigned int maxnicklen;
+
+/* config.cpp end */
+
+E list<Player*> players[U_TABLE_SIZE];
+E list<aClient*> clients[U_TABLE_SIZE];
+E list<string> todaysnews;
+E list<item*> store; // The list of items available at the store
+
+/* misc.cpp begin */
+E void end_turn(aClient *user);
+E void see_master(char *u);
+
+/* misc.cpp end */
+/* find.cpp begin */
+E item *findItemByID(int id);
+E item *findStoreItemByID(int id);
+E tavernItem *findTavernItemByID(int id);
+/* find.cpp end */
+
+/* messages.cpp begin */
+E void display_help(char *u, char *file);
+E void display_monster(char *u);
+E void display_players(char *u);
+E void display_players(aClient *user);
+E void showBankBalance(const char *u);
+void showTavern(aClient *user);
+/* messages.cpp end */
-E List<aClient> clients;
-E List<aClient> players;
+/* boolean.cpp begin */
+E bool check_password(char *name, char *plaintext);
+/* boolean.cpp end */
+
+/** tcpclient.cpp **/
+E void check_idles();
+E void clearClients();
+E void clearPlayers();
/** List search functions **/
E aClient *find(char *nick);
E aClient *find(const char *nick);
E aClient *findbynick(char *nick);
E aClient *findbynick(const char *nick);
-E aClient *findplayer(const char *name);
+E aClient *findbyrealnick(char *realnick);
+E Player *findplayer(const char *name);
+#ifdef P10
+E aClient *findbyrealnick(char *realnick);
+#endif
+
+/** tcpclient.cpp **/
/** Sock writing functions **/
E void notice(const char *source, const char *dest, const char *fmt, ...);
E void raw(const char *fmt, ...);
+/** news.cpp **/
+E void addNews(list<string> &news, const char *fmt, ...);
+
+E void clearNews(list<string> &news);
+E void loadNews(char *filename, list<string> &news);
+E void saveNews(char *filename, list<string> &news);
+E void showNews(char *nick, list<string> &news);
+
/** gameserv.cpp **/
+E void do_admin(char *u);
+E void do_attack(char *u);
+E void do_bank(char *u);
+E void do_check(char *u);
+E void do_equip(char *u);
+E void do_fight(char *u);
+E void do_heal(char *u);
+E void do_help(char *u);
+E void do_identify(char *u);
+E void do_inventory(char *u);
+E void do_refresh(char *u);
+E void do_register(char *u);
+E void do_list(char *u);
+E void do_load(char *u);
+E void do_logout(char *u);
+E void do_master(char *u);
+E void do_news(char *u);
+E void do_dragon(char *u);
+E void do_play(char *u);
+E void do_quitg(char *u);
+E void do_raw(char *u);
+E void do_reset(char *u);
+E void do_run(char *u);
+E void do_save(char *u);
+E void do_set(char *u);
+E void do_shutdown(char *u);
+E void do_stats(char *u);
+E void do_store(char *u);
+E void do_tavern(char *u);
+E void do_use(char *u);
+
+E item *findItemByID(int id);
+E int hpbonus[LEVELS - 1];
+E int strbonus[LEVELS - 1];
+E int defbonus[LEVELS - 1];
E void gameserv(char *source, char *buf);
-E Monster *monsters[LEVELS][MONSTERS];
+E Level levels[LEVELS];
+E list<item*> Items;
+E list<tavernItem> tavern;
+E toplist myToplist;
/** forest.cpp **/
E void forest(char *source, char *buf);
/** functions.cpp **/
-E bool is_fighting(char *u);
-E bool isnt_fighting(char *u);
E bool is_playing(char *u);
-E bool has_started(char *u);
+E bool is_playing(aClient *user);
+
E bool is_fighting(char *u);
-E bool isnt_fighting(char *u);
+E bool is_fighting(aClient *user);
+
E bool player_fight(char *u);
+E bool player_fight(aClient *user);
+
+E bool dragon_fight(aClient *user);
+
E bool master_fight(char *u);
+E bool master_fight(aClient *user);
+
+E bool alphaNumeric(const char *str);
#ifndef HAVE_STRTOK
E char *strtok(char *str, const char *delim);
#endif
E char *spaces(int len, char *seperator);
-E void display_monster(char *u);
-E void display_players(char *u);
+
E int stricmp(const char *s1, const char *s2);
E int strnicmp(const char *s1, const char *s2, size_t len);
E long int chartoint(char ch);
E int isstringnum(char *num);
E long int pow (int x, int y);
E long int stringtoint(char *number);
-E void init_masters();
-E void init_monsters();
+E bool load_masters();
+E bool load_monsters();
+E bool load_levels();
E void delete_monsters();
E void delete_masters();
-E Monster *getNewMonster(Monster *m);
E void deleteMonster(Monster *m);
-E void refresh(aClient *ni);
+E void refresh(Player *p);
E void refreshall();
-E void reset(aClient *ni);
+E void rolloverall();
+E void rollover(Player *p);
+E void updateTS(Player *p);
+E bool timedOut(Player *p);
+E void timeOutEvent(Player *p);
+E void reset(Player *p);
+E void resetall();
+E void do_attack(char *u);
+E void do_bank(char *u);
+E void do_check(char *u);
+E void do_equip(char *u);
+E void do_fight(char *u);
+E void do_forest(char *u);
+E void do_heal(char *u);
+E void do_invenory(char *u);
E void do_list(char *u);
-E void do_register(char *u);
-E void do_identify(char *u);
+E void do_logout(char *u);
E void do_play(char *u);
E void do_quitg(char *u);
+E void do_refresh(char *u);
+E void do_register(char *u);
E void do_reset(char *u);
-E void do_fight(char *u);
-E void do_store(char *u);
-E void do_heal(char *u);
-E void do_bank(char *u);
-E void do_attack(char *u);
E void do_run(char *u);
-E void do_visit(char *u);
+E void do_set(char *u);
E void do_stats(char *u);
-E void do_forest(char *u);
+E void do_store(char *u);
+E void do_tavern(char *u);
+E void do_use(char *u);
E void see_mystic(char *u);
-E void showstats(const char *u, const char *nick);
+E void logout(aClient *user); // log a user off the game
+E void showstats(const char *u, const char *nick);
+E void showinventory(Player *from, aClient *to);
/* Database saving stuff */
E int save_gs_dbase();
E int load_gs_dbase();
+E int load_tavern();
+E int load_items();
+E int load_store();
+E int load_dragon();
+E int save_dragon();
+
+// Log File Stuff
+E void log(const char *fmt, ...);
#endif