--- /dev/null
+#include "extern.h"
+#include "aClient.h"
+#include "player.h"
+#include "flags.h"
+
+bool is_playing(char *u); // True if the given nickname in the clients list is playing.
+bool is_playing(aClient *user);
+
+bool is_fighting(char *u); // True if the given nick in the clients list is fighting anything.
+bool is_fighting(aClient *user);
+
+bool player_fight(char *u); // True if the player is fighting another player.
+bool player_fight(aClient *user);
+
+bool master_fight(char *u); // True if the player is fighting their master.
+bool master_fight(aClient *user);
+
+bool dragon_fight(char *u); // True if the player is fighting the dragon.
+bool dragon_fight(aClient *user);
+
+bool alphaNumeric(const char *str); // Returns true if all of the characters in str are alphanumeric non-special chars
+/********** GameServ Booleans **********/
+
+
+bool is_playing(char *u)
+{
+ aClient *user;
+ if (!(user = find(u)))
+ return false;
+ else
+ return is_playing(user);
+}
+
+bool is_playing(aClient *user)
+{
+ if (!user)
+ {
+ return false;
+ }
+ else if (!user->stats)
+ {
+ return false;
+ }
+ else if (!FL_is_playing(user))
+ {
+ return false;
+ }
+ else if (user->stats->getClient() != user)
+ {
+ return false;
+ }
+ else
+ return true;
+}
+
+bool is_fighting(char *u)
+{
+ aClient *user;
+
+ if (!(user = find(u)))
+ return false;
+ else
+ return is_fighting(user);
+}
+
+bool is_fighting(aClient *user)
+{
+ if (!is_playing(user))
+ return false;
+ else
+ return player_fight(user) || master_fight(user) || user->stats->getMonster() != NULL;
+}
+
+bool player_fight(char *u)
+{
+ aClient *user;
+
+ if (!(user = find(u)))
+ return false;
+ else
+ return player_fight(user);
+}
+
+bool player_fight(aClient *user)
+{
+ if (!is_playing(user))
+ return false;
+ else if (is_playing(user->stats->getBattle()))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool master_fight(char *u)
+{
+ aClient *user;
+
+ if (!(user = find(u)))
+ return false;
+ else
+ return master_fight(user);
+}
+
+bool master_fight(aClient *user)
+{
+ if (!is_playing(user))
+ return false;
+ else
+ return user->stats->getMaster() != NULL;
+}
+
+bool dragon_fight(char *u)
+{
+ aClient *user;
+ if (!(user = find(u)))
+ return false;
+ else
+ return dragon_fight(user);
+}
+
+bool dragon_fight(aClient *user)
+{
+ if (!is_playing(user))
+ return false;
+ else
+ return (isDragonFight(user->stats));
+}
+
+bool alphaNumeric(const char *str)
+{
+ int len = strlen(str);
+ for (int x = 0; x < len; x++)
+ {
+ if (!((int(str[x]) >= 65 && int(str[x]) <= 90) || (int(str[x]) >= 97 && int(str[x]) <= 122) || (int(str[x]) >= 48 && int(str[x]) <= 57) || int(str[x]) == 95))
+ return false;
+ }
+ return true;
+}
+
+bool passcmp(const char *encrypted, char *plaintext)
+{
+ char salt[3];
+ char *plaintext2, *plainToencrypt;
+ bool same = false;
+
+ plaintext2 = new char[strlen(encrypted) + strlen(plaintext)]; // Extra
+ strcpy(plaintext2, plaintext);
+
+ salt[0] = encrypted[0];
+ salt[1] = encrypted[1];
+ salt[3] = '\0';
+
+ plainToencrypt = crypt(plaintext2, salt);
+
+ same = (strcmp((const char *)encrypted, plainToencrypt) == 0 ? true : false);
+
+ delete []plaintext2;
+
+ return same;
+}
+
+bool check_password(char *name, char *plaintext)
+{
+ Player *p;
+
+ if (!(p = findplayer(name)))
+ return false;
+ else
+ {
+ return passcmp(p->getPassword().c_str(), plaintext);
+ }
+}
+
+bool timedOut(Player *p)
+{
+ if (!p)
+ return false;
+ else if (p->lastcommand == 0)
+ return false;
+ else
+ {
+ if ((time(NULL) - p->lastcommand) >= maxidletime)
+ return true;
+
+ return false;
+ }
+}
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);
+/* messages.cpp end */
+
+/* boolean.cpp begin */
+E bool check_password(char *name, char *plaintext);
+/* boolean.cpp end */
+
/** tcpclient.cpp **/
E void check_idles();
E void clearClients();
#endif
E char *spaces(int len, char *seperator);
-E void display_monster(char *u);
-E void display_players(char *u);
-E void display_players(aClient *user);
+
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);
Level levels[LEVELS]; // The newest way to store monsters
list<item*> Items; // The master list of items
list<tavernItem> tavern; // The list of items available at the tavern
+list<item*> store; // List of items available at the store
toplist myToplist; // List of the top 10 players
int strnicmp(const char *s1, const char *s2, size_t len);
// String Functions
-/********** Password functions **********/
-
-bool passcmp(const char *encrypted, char *plaintext); // Compares an encrypted pass with a plain text one
-
-bool check_password(char *name, char *plaintext); // Finds a password for the given name, and checks it with passcmp against the plaintext password given.
-
-/********** Password functions **********/
-
-
-/********** GameServ Booleans **********/
bool shuttingdown;
-bool timedOut(Player *p);
void updateTS(Player *p);
void timeOutEvent(Player *p);
-bool is_playing(char *u); // True if the given nickname in the clients list is playing.
-bool is_playing(aClient *user);
-
-bool is_fighting(char *u); // True if the given nick in the clients list is fighting anything.
-bool is_fighting(aClient *user);
-
-bool player_fight(char *u); // True if the player is fighting another player.
-bool player_fight(aClient *user);
-
-bool master_fight(char *u); // True if the player is fighting their master.
-bool master_fight(aClient *user);
-
-bool dragon_fight(char *u); // True if the player is fighting the dragon.
-bool dragon_fight(aClient *user);
-
-bool alphaNumeric(const char *str); // Returns true if all of the characters in str are alphanumeric non-special chars
-/********** GameServ Booleans **********/
-
-void display_help(char *u, char *file = NULL);
-void display_monster(char *u);
-void display_players(char *u);
-void display_players(aClient *user);
long int chartoint(char ch);
int isstringnum(char *num);
long int pow (int x, int y);
-bool is_playing(char *u)
-{
- aClient *user;
- if (!(user = find(u)))
- return false;
- else
- return is_playing(user);
-}
-
-bool is_playing(aClient *user)
-{
- if (!user)
- {
- return false;
- }
- else if (!user->stats)
- {
- return false;
- }
- else if (!FL_is_playing(user))
- {
- return false;
- }
- else if (user->stats->getClient() != user)
- {
- return false;
- }
- else
- return true;
-}
-
-bool is_fighting(char *u)
-{
- aClient *user;
-
- if (!(user = find(u)))
- return false;
- else
- return is_fighting(user);
-}
-
-bool is_fighting(aClient *user)
-{
- if (!is_playing(user))
- return false;
- else
- return player_fight(user) || master_fight(user) || user->stats->getMonster() != NULL;
-}
-
-bool player_fight(char *u)
-{
- aClient *user;
-
- if (!(user = find(u)))
- return false;
- else
- return player_fight(user);
-}
-
-bool player_fight(aClient *user)
-{
- if (!is_playing(user))
- return false;
- else if (is_playing(user->stats->getBattle()))
- {
- return true;
- }
- return false;
-}
-
-bool master_fight(char *u)
-{
- aClient *user;
-
- if (!(user = find(u)))
- return false;
- else
- return master_fight(user);
-}
-
-bool master_fight(aClient *user)
-{
- if (!is_playing(user))
- return false;
- else
- return user->stats->getMaster() != NULL;
-}
-
-bool dragon_fight(char *u)
-{
- aClient *user;
- if (!(user = find(u)))
- return false;
- else
- return dragon_fight(user);
-}
-
-bool dragon_fight(aClient *user)
-{
- if (!is_playing(user))
- return false;
- else
- return (isDragonFight(user->stats));
-}
-
-bool alphaNumeric(const char *str)
-{
- int len = strlen(str);
- for (int x = 0; x < len; x++)
- {
- if (!((int(str[x]) >= 65 && int(str[x]) <= 90) || (int(str[x]) >= 97 && int(str[x]) <= 122) || (int(str[x]) >= 48 && int(str[x]) <= 57) || int(str[x]) == 95))
- return false;
- }
- return true;
-}
void do_fight(char *u)
{
return 1;
}
-bool passcmp(const char *encrypted, char *plaintext)
-{
- char salt[3];
- char *plaintext2, *plainToencrypt;
- bool same = false;
-
- plaintext2 = new char[strlen(encrypted) + strlen(plaintext)]; // Extra
- strcpy(plaintext2, plaintext);
-
- salt[0] = encrypted[0];
- salt[1] = encrypted[1];
- salt[3] = '\0';
-
- plainToencrypt = crypt(plaintext2, salt);
-
- same = (strcmp((const char *)encrypted, plainToencrypt) == 0 ? true : false);
-
- delete []plaintext2;
-
- return same;
-}
-bool check_password(char *name, char *plaintext)
-{
- Player *p;
-
- if (!(p = findplayer(name)))
- return false;
- else
- {
- return passcmp(p->getPassword().c_str(), plaintext);
- }
-}
void do_store(char *u)
{
}
-bool timedOut(Player *p)
-{
- if (!p)
- return false;
- else if (p->lastcommand == 0)
- return false;
- else
- {
- if ((time(NULL) - p->lastcommand) >= maxidletime)
- return true;
-
- return false;
- }
-}
+
void timeOutEvent(Player *p)
{