// Log the player in
setPlaying(user);
+ // Start the player at the beginning
+ reset(user->stats);
+
// Add the stick and clothes
tempItem = findItemByID(3001);
user->stats->inventory->addItem((*Items.begin()))->use(user->stats); // Add the stick
}
else
{
- updateTS(user->stats);
+ if (!is_fighting(user))
+ updateTS(user->stats);
showstats(u, user->stats->getName().c_str());
}
}
return;
}
id = stringtoint(item);
- updateTS(user->stats);
+ if (!is_fighting(user))
+ updateTS(user->stats);
p = user->stats->inventory;
equip->use(user->stats);
}
}
+
void do_use(char *u)
{
aClient *user;
p->setExp(stringtoint(strtok(NULL, " ")));
p->setGold(stringtoint(strtok(NULL, " ")));
p->setBank(stringtoint(strtok(NULL, " ")));
- p->setHP(stringtoint(strtok(NULL, " ")));
+ tempnum = stringtoint(strtok(NULL, " "));
p->setMaxHP(stringtoint(strtok(NULL, " ")));
+ p->setHP(tempnum);
p->setStrength(stringtoint(strtok(NULL, " ")));
p->setDefense(stringtoint(strtok(NULL, " ")));
p->setForestFights(stringtoint(strtok(NULL, " ")));
notice(s_GameServ, u, "You must be playing to check your inventory!");
return;
}
- updateTS(user->stats);
+ if (!is_fighting(user))
+ updateTS(user->stats);
showinventory(user->stats, user);
}
void reset(Player *p)
{
item *tempItem;
+
if (!p)
return;
p->reset();
+ // Add the stick and clothes
tempItem = findItemByID(3001);
p->inventory->addItem((*Items.begin()))->use(p); // Add the stick
- p->inventory->addItem(tempItem)->use(p); // Add Clothes
-
+ p->inventory->addItem(tempItem)->use(p); // Add Clothes
}
void updateTS(Player *p)
using namespace std;
char *PACKAGE = "GameServ";
-char *VERSION = "1.3.2 +devel";
+char *VERSION = "1.3.3 +devel";
int sock;
long lastrefresh;
ignore_pipe();
sock = conn(remoteserver, remoteport, localhost, 0);
// sock = make_connection(remoteport, SOCK_STREAM, remoteserver);
- if (sock == -1) {
- fprintf(stderr,"make_connection failed.\n");
- unload_config_file();
- return -1;
- }
+ if (sock == -1)
+ {
+ fprintf(stderr,"make_connection failed.\n");
+ unload_config_file();
+ return -1;
+ }
log("%S socket connected.");
#ifdef UNREAL
cmd = strtok(NULL, " ");
}
else
- cmd = strtok(buf, " ");
+ {
+ cmd = strtok(buf, " ");
+ }
#else
source = strtok(buf, " ");
cmd = strtok(NULL, " ");
// Refresh players and clear news if the time is up
currentTime = time(NULL);
-
+
if (isRolloverForestFights())
{
if (currentTime - lastrollover >= rolloverperiod)
#if !defined(P10)
- if (stricmp(cmd, "PING") == 0) {
- char *timestamp;
- timestamp = strtok(NULL, "");
- raw("PONG %s", timestamp);
- #else
- if (stricmp(cmd, "G") == 0) {
- char *timestamp;
- timestamp = strtok(NULL, " ");
- raw("[] Z [] %s 0 %s", timestamp + 1, timestamp);
- #endif
- #ifdef P10
- } else if (stricmp(cmd, "EB") == 0) {
- raw("[] EA");
- #endif
- } else if (stricmp(cmd, "VERSION") == 0) {
- char *server;
- server = strtok(NULL, " ");
- server++;
- raw(":%s 351 %s %s_%s. %s", servername, source+1, PACKAGE, VERSION, servername);
- #if !defined(P10)
- } else if (strncmp(cmd, "NICK", 4) == 0) {
- if (buffer[0] == ':')
- {
- aClient *tempPtr;
- if ((tempPtr = find((source + 1))))
+ if (stricmp(cmd, "PING") == 0)
{
- char *nick;
- unsigned long oldhv, newhv;
- nick = strtok(NULL, " ");
- oldhv = iHASH((unsigned char *) tempPtr->getNick());
- newhv = iHASH((unsigned char *) nick);
- tempPtr->setNick(nick);
- clients[oldhv].remove(tempPtr);
- clients[newhv].push_back(tempPtr);
+ char *timestamp;
+ timestamp = strtok(NULL, "");
+ raw("PONG %s", timestamp);
}
- }
- else
- {
- char *nick;
- #else
+#else
+ // P10 Ping
+ if (stricmp(cmd, "G") == 0)
+ {
+ char *timestamp;
+ timestamp = strtok(NULL, " ");
+ raw("[] Z [] %s 0 %s", timestamp + 1, timestamp);
+ }
+#endif
+#ifdef P10
+ else if (stricmp(cmd, "EB") == 0)
+ {
+ raw("[] EA");
+ }
+#endif
+ else if (stricmp(cmd, "VERSION") == 0)
+ {
+ char *server;
+ server = strtok(NULL, " ");
+ server++;
+ raw(":%s 351 %s %s_%s. %s", servername, source+1, PACKAGE, VERSION, servername);
+ }
+ // Code indenting is clean up until here!
+#if !defined(P10)
+ else if (strncmp(cmd, "NICK", 4) == 0)
+ {
+ if (buffer[0] == ':')
+ {
+ aClient *tempPtr;
+ if ((tempPtr = find((source + 1))))
+ {
+ char *nick;
+ unsigned long oldhv, newhv;
+ nick = strtok(NULL, " ");
+ oldhv = iHASH((unsigned char *) tempPtr->getNick());
+ newhv = iHASH((unsigned char *) nick);
+ tempPtr->setNick(nick);
+ clients[oldhv].remove(tempPtr);
+ clients[newhv].push_back(tempPtr);
+ }
+ }
+ else
+ {
+ char *nick;
+#else
} else if (stricmp(cmd, "N") == 0 && strlen(source) == 2) {
{
char *nick, *realnick;
if (nick[0] == '+')
{
- #ifdef DEBUGMODE
+#ifdef DEBUGMODE
log ("aClient has modes");
- #endif
-
+#endif
// Searching for the +r mode (extra parameter)
for (unsigned int count = 1; count < strlen(nick); count++)
{
}
nick = strtok(NULL, " ");
}
- #endif
+#endif
aClient *newuser;
nick = strtok(NULL, " ");
- #ifdef P10
+#ifdef P10
newuser = new aClient(nick, realnick);
- #else
+#else
newuser = new aClient(nick);
- #endif
+#endif
if (loaded)
#endif
clients[hv].push_back(newuser);
}
- #if defined(P10)
+#if defined(P10)
} else if (stricmp(cmd, "Q") == 0) {
// unsigned long hv = sHASH((unsigned char *) source);
- #else
+#else
} else if (stricmp(cmd, "QUIT") == 0)
{
goto end;
}
-
- notice(s_GameServ, "Kain", "Nick: %s", quitter->getNick());
clients[hv].remove(quitter);
// logout(quitter);
if (z == ':')
source--;
- #if defined(P10)
+#if defined(P10)
} else if (stricmp(cmd, "P") == 0) {
char *rest, *dest;
char *longname;
delete [] longname;
forest(source, rest);
}
- #else
+#else
} else if (stricmp(cmd, "PRIVMSG") == 0) {
char *rest, *dest;
dest = strtok(NULL, " ");
gameserv(source, rest);
else if (stricmp(dest, c_Forest) == 0 && isListenOnCF())
forest(source, rest);
- #endif
- #if defined(P10)
+#endif
+#if defined(P10)
} else if (stricmp(cmd, "J") == 0) {
- #else
+#else
} else if (stricmp(cmd, "JOIN") == 0) {
- #endif
+#endif
char *channel;
aClient *joiner;
channel = strtok(NULL, " ");
if (stricmp(channel, c_Forest) == 0 && is_playing(joiner))
{
- #ifdef DEBUGMODE
- log("Player %s (IRC: %s) joined %s",
- joiner->stats->getName().c_str(),
- #ifdef P10
- joiner->getRealNick(),
- #else
- joiner->getNick(),
- #endif
- c_Forest);
- #endif
- raw(":%S MODE %s +v %s", c_Forest, (source));
+#ifdef DEBUGMODE
+ log("Player %s (IRC: %s) joined %s",
+ joiner->stats->getName().c_str(),
+#ifdef P10
+ joiner->getRealNick(),
+#else
+ joiner->getNick(),
+#endif
+ c_Forest);
+#endif
+ raw(":%S MODE %s +v %s", c_Forest, (source));
}
if (z == ':')
source--;
- #if defined(BAHAMUT)
+#if defined(BAHAMUT)
} else if (stricmp(cmd, "SJOIN") == 0) {
char *channel, *nick, *tmp, *rest;
strtok(NULL, " "); // Ignore the TS
}
#endif
} else {
- #ifdef DEBUGMODE
+#ifdef DEBUGMODE
log("Unrecognized Message: cmd = %s source = %s", cmd, source);
- #endif
+#endif
}
}
delete_monsters();
- #ifdef DEBUGMODE
+#ifdef DEBUGMODE
log("<CLOSED>");
- #endif
+#endif
close(sock);
unload_config_file();
for (iter = clients[hv].begin(); iter != clients[hv].end(); iter++)
{
client = (*iter);
- #ifdef P10
+#ifdef P10
if (strcmp(client->getNick(), nick) == 0)
#else
if (stricmp(client->getNick(), nick) == 0)
infile.open(".gsrefresh");
if (infile.fail())
{
- #ifdef DEBUGMODE
+#ifdef DEBUGMODE
log("Error opening .gsrefresh");
- #endif
+#endif
generate:
long mytime = time(NULL);
- #ifdef DEBUGMODE
+#ifdef DEBUGMODE
log("Generating new refresh time");
- #endif
+#endif
// Just a safety measure... tho no one should
// get anywhere near the actual time as their refreshperiod