//#include <sys/wait.h>
//#include <errno.h>
-
-
using std::ofstream;
using std::ifstream;
using std::cerr;
using std::endl;
char *PACKAGE = "GameServ";
-char *VERSION = "1.2.0 +devel";
+char *VERSION = "1.2.3 +devel";
int sock;
int day;
int main(int argc, char *argv[])
{
- char buffer[1024], buf[1024];
- int connected;
- long lastidlecheck;
- char *cmd, *source = NULL, *conf = "gameserv.conf";
- srand(time(NULL));
+ char buffer[1024], buf[1024];
+ memset(buffer, 0, 1024);
+ memset(buf, 0, 1024);
+ int connected;
+ long lastidlecheck;
+ char *cmd, *source = NULL, *conf;
+ srand(time(NULL));
+ conf = new char[16];
+ strcpy(conf, "gameserv.conf");
/*
* This needs to be fixed to work for any number of arguments in any
cout << "--help Displays this help dialogue" << endl;
return 1;
}
- conf = new char[strlen(argv[1])];
- strcpy(conf, argv[1]);
+ delete []conf;
+ conf = argv[1];
}
prettyIntro();
else
exit(2);
+ if (argc <= 1)
+ delete []conf;
+
// Turn into a daemon
if (daemon(1,0) < 0)
{
perror("Could not turn into a daemon");
exit(3);
}
+
init_masters();
load_gs_dbase();
+ cout << "Loading news" << endl;
+ loadNews(newsdata, todaysnews);
if (load_monsters() == false)
goto end;
strcpy(boss.name, "Red Dragon");
strcpy(boss.weapon, "Breath of Unholy Fire");
- boss.strength = 6667;
+ boss.strength = 2500;
boss.gold = 2000000000;
boss.exp = 2000000000;
+ boss.maxhp = 6667;
+ boss.hp = 6667;
strcpy(boss.death, "You finally snuff out the deadly murderous "\
"dragon's dark flames. You have freed the land of its terror "\
"filled reign from above!");
raw("PROTOCTL NICKv2 VHP");
raw("PASS :%s", remotepass);
raw("SERVER %s 1 :%s", servername, servername);
- raw("NICK %S 1 %d %S %s %s %d +wghraAxNt %s :%s v%s", time(NULL), gshost,
- servername, time(NULL), gshost, PACKAGE, VERSION);
+ raw("NICK %S 1 %d %S %s %s %d +w%s %s :%s v%s", time(NULL), gshost,
+ servername, time(NULL), (isBOper() ? "o" : ""), gshost, PACKAGE, VERSION);
raw(":%S JOIN %s", c_Forest);
raw(":%S MODE %s +tn", c_Forest);
#elif defined(BAHAMUT)
raw("PASS %s :TS", remotepass);
raw("SERVER %s 1 :%s", servername, servername);
- raw("NICK %S 1 %d +w %s %s %s 0 :GameServ", time(NULL), gsident, gshost,
- servername);
+ raw("NICK %S 1 %d +w%s %s %s %s 0 :GameServ", time(NULL), (isBOper() ? "o" : ""),
+ gsident, gshost, servername);
raw(":%s SJOIN %d %d %s +nt :@%S", servername, time(NULL), time(NULL), c_Forest);
#elif defined(HYBRID)
raw("PASS %s :TS", remotepass);
raw("SERVER %s 1 :%s", servername, servername);
- raw("NICK %S 1 %d +w %s %s %s :GameServ", time(NULL), gsident, gshost,
- servername);
+ raw("NICK %S 1 %d +w%s %s %s %s :GameServ", time(NULL), (isBOper() ? "o" : ""),
+ gsident, gshost, servername);
raw(":%s SJOIN %ld %s +nt :@%S", servername, time(NULL), c_Forest);
+#elif defined(ULTIMATE2)
+ raw("PASS %s :TS", remotepass);
+ raw("SERVER %s 1 :%s", servername, servername);
+ raw("NICK %S 1 %d %s %s %s 0 :GameServ",
+ time(NULL), gsident, gshost, servername);
+ if (isBOper())
+ raw(":%S mode %S +o");
+ raw(":%S JOIN %s", c_Forest);
#elif defined(P10)
// Server numeric is: [] <-- must be unique
raw("PASS :%s", remotepass);
raw("SERVER %s 1 %d %d P10 []AAF :%s", servername, time(NULL), time(NULL), servername);
- raw("[] N %S 1 %d %s %s DAqAoB %s :%S", time(NULL), gsident, gshost, gsnum);
+ raw("[] N %S 1 %d %s %s %s DAqAoB %s :%S", time(NULL), gsident, gshost,
+ (isBOper() ? "+o" : ""), gsnum);
raw("[] B %s %d +tn %s:o", c_Forest, time(NULL) - 864000, gsnum);
#endif
raw("%s T %s :%s", gsnum, c_Forest, c_ForestTopic);
raw("[] EB"); // End burst
#else
-#ifndef HYBRID
- raw(":%S MODE %s +o %S", c_Forest);
-#endif
+ #ifndef HYBRID
+ #if defined(ULTIMATE2)
+ raw(":%s MODE %s +o %S %ld", servername, c_Forest,
+ time(NULL));
+ #else
+ raw(":%S MODE %s +o %S", c_Forest);
+ #endif
+ #endif
raw(":%S TOPIC %s :%s", c_Forest, c_ForestTopic);
#endif
oldTime = currentTime;
log("Saving to %s", playerdata);
save_gs_dbase();
+ saveNews(newsdata, todaysnews);
}
if (loaded)
+
+ if (isWelcome())
+ {
+ #ifdef P10
+ notice(s_GameServ, nick, welcomemsg, realnick);
+ #else
+ notice(s_GameServ, nick, welcomemsg, nick);
+ #endif
+ }
#ifdef P10
- notice(s_GameServ, nick, welcomemsg, realnick);
- #else
- notice(s_GameServ, nick, welcomemsg, nick);
- #endif
- #ifdef P10
- unsigned long hv = sHASH((unsigned char *) nick)
+ unsigned long hv = sHASH((unsigned char *) nick);
#else
unsigned long hv = iHASH((unsigned char *) nick);
#endif
temp = clients[hv].insertAtBack(newuser);
- #ifdef HYBRID
+ #if defined(HYBRID) || defined(BAHAMUT) || defined(ULTIMATE2)
char *nickserver;
strtok(NULL, " ");
strtok(NULL, " ");
if (nickserver[0] == '+')
strtok(NULL, " ");
strtok(NULL, " ");
-
+ nickserver = strtok(NULL, " ");
+ for (int x = 0; x < 32; x++)
+ {
+ if (stricmp(ignoreservers[x], nickserver) == 0)
+ {
+ setIgnore(temp);
+ break;
+ }
+ }
+ #elif defined(UNREAL)
+ char *nickserver;
+ strtok(NULL, " ");
+ strtok(NULL, " ");
+ strtok(NULL, " ");
+ strtok(NULL, " ");
nickserver = strtok(NULL, " ");
for (int x = 0; x < 32; x++)
{
}
#if defined(P10)
} else if (stricmp(cmd, "Q") == 0) {
- unsigned long hv = sHASH((unsigned char *) source);
+// unsigned long hv = sHASH((unsigned char *) source);
#else
} else if (stricmp(cmd, "QUIT") == 0) {
- unsigned long hv = iHASH((unsigned char *) source);
+// unsigned long hv = iHASH((unsigned char *) source);
#endif
aClient *quitter;
char z = source[0];
if (z == ':')
source++;
+ if (!(quitter = find(source)))
+ {
+ log("Fatal Error: could not find %s in the "\
+ "clients list", source);
+ goto end;
+ }
+
+ logout(quitter);
+
+ if (z == ':')
+ source--;
+
+ /* Attempting to use the logout() function
if ((quitter = find(source)))
clients[hv].remove(quitter);
if ((quitter = findIRCplayer(source)))
#endif
quitter->stats->client = NULL; // Unidentify them
}
-
- if (z == ':')
- source--;
+ */
#if defined(P10)
} else if (stricmp(cmd, "P") == 0) {
delete [] longname;
gameserv(source, rest);
}
- else if (stricmp(dest, c_Forest) == 0 && listenonc_forest)
+ else if (stricmp(dest, c_Forest) == 0 && isListenOnCF())
{
delete [] longname;
forest(source, rest);
rest = strtok(NULL, "");
if (strnicmp(dest, s_GameServ, strlen(s_GameServ)) == 0)
gameserv(source, rest);
- else if (stricmp(dest, c_Forest) == 0)
+ else if (stricmp(dest, c_Forest) == 0 && isListenOnCF())
forest(source, rest);
#endif
#if defined(P10)
end:
save_gs_dbase();
+ saveNews(newsdata, todaysnews);
save_day();
delete_monsters();