using std::ifstream;
using std::ofstream;
+using std::ios;
#if defined(HAVE_CRYPT_H)
int strnicmp(const char *s1, const char *s2, size_t len);
// String Functions
-
/********** Password functions **********/
bool passcmp(char *encrypted, char *plaintext); // Compares an encrypted pass with a plain text one
/********** GameServ Booleans **********/
+bool shuttingdown;
bool is_playing(char *u); // True if the given nickname in the clients list is playing.
bool is_playing(aClient *user);
#else
raw("SQUIT %s :leaving: %s used the Shutdown command.", servername, source);
#endif
+ shuttingdown = true;
}
} else if (stricmp(cmd, "SAVE") == 0) {
aClient *user;
temp = new aClient;
temp->stats = new Player;
temp->stats->setData(user->stats);
- user->stats->user = NULL;
+ user->stats->client = NULL;
if (player_fight(user))
user->stats->battle->stats->battle = NULL;
delete user->stats;
user->stats = NULL;
- temp->stats->user = NULL;
+ temp->stats->client = NULL;
#ifdef P10
temp->setRealNick("!NULL!");
#endif
if (!user->stats && !p)
{
user->stats = new Player(user);
- user->stats->user = user; // Set the backwards pointer
+ user->stats->client = user; // Set the backwards pointer
strcpy(user->stats->password, crypt(password, salt));
strcpy(user->stats->name, name);
unsigned long hv = HASH((unsigned char *) name, U_TABLE_SIZE);
{
notice(s_GameServ, u, "You are already playing!");
}
- else if (p->stats->user != NULL && !isAdmin(user))
+ else if (p->stats->client != NULL && !isAdmin(user))
{
notice(s_GameServ, u, "That player has already identified.");
}
void display_players(char *u)
{
- if (is_playing(u))
+ aClient *user;
+ if (!(user = find(u)))
{
- aClient *ni = find(u);
-
- aClient *battle = ni->stats->battle;
-
- notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->stats->hp);
- notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->stats->name,
- battle->stats->hp);
- notice(s_GameServ, u, "Here are your commands:");
- notice(s_GameServ, u, "/msg %S attack");
- notice(s_GameServ, u, "/msg %S run");
- notice(s_GameServ, u, "What will you do?");
+ log("Fatal error in display_players(): Couldn't find %s", u);
}
+ else
+ display_players(user);
}
+
void display_players(aClient *user)
{
char *u = user->getNick();
notice(s_GameServ, battle->getNick(), "%s gets to go first "\
"because they initiated!", ni->stats->name);
notice(s_GameServ, battle->getNick(), "Please wait while %s decides what to do.", ni->stats->name);
- display_players(u);
+ display_players(ni);
}
}
void do_use(char *u)
weapons[ni->stats->weapon], hit);
clearYourTurn(ni->stats);
setYourTurn(battle->stats);
- display_players(battle->getNick());
+ display_players(battle);
}
else
{
notice(s_GameServ, battle->getNick(), "%s misses you completely!", ni->stats->name);
clearYourTurn(ni->stats);
setYourTurn(battle->stats);
- display_players(battle->getNick());
+ display_players(battle);
}
if (hit >= battle->stats->hp)
{
tempname = strtok(NULL, " ");
if (tempname)
p->inventory.setHP(stringtoint(tempname));
- temp->stats->user = NULL;
unsigned long hv = HASH((unsigned char *) temp->stats->name, U_TABLE_SIZE);
+
+ temp->stats->client = NULL;
players[hv].insertAtBack(temp);
delete temp;
}