X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/dff2bbf42ac98466a763629634716e452824987d..91c0b563c77c5e5b271a7e7bcdd7fab60742798e:/gameserv/tcpclient.cpp diff --git a/gameserv/tcpclient.cpp b/gameserv/tcpclient.cpp index 12cc359..059907a 100644 --- a/gameserv/tcpclient.cpp +++ b/gameserv/tcpclient.cpp @@ -13,6 +13,7 @@ */ #include "sockhelp.h" +#include "options.h" #include "list.h" #include "aClient.h" #include "extern.h" @@ -24,6 +25,9 @@ #include #include +char *PACKAGE = "GameServ"; +char *VERSION = "1.1.2"; + int sock; long timestamp; @@ -61,14 +65,23 @@ int main(int argc, char *argv[]) return -1; } +#ifdef UNREAL raw("PROTOCTL NICKv2 VHP"); raw("PASS :%s", remotepass); - raw("SERVER %s 1 :Testing Server", servername); - raw("NICK %S 1 %d %S %s %s %d +owghraAxNt %s :GameServ", time(NULL), gshost, - servername, time(NULL), gshost); + raw("SERVER %s 1 :%s", servername, servername); + raw("NICK %S 1 %d %S %s %s %d +owghraAxNt %s :%s v%s", time(NULL), gshost, + servername, time(NULL), gshost, PACKAGE, VERSION); raw(":%S JOIN %s", c_Forest); + raw(":%S MODE %s +mtn", c_Forest); +#elif defined(BAHAMUT) + raw("PASS %s :TS", remotepass); + raw("SERVER %s 1 :%s", servername, servername); + raw("NICK %S 1 %d +o %s %s %s 0 :GameServ", time(NULL), gsident, gshost, + servername); + raw(":%s SJOIN %d %d %s +mnt :@%S", servername, time(NULL), time(NULL), c_Forest); +#endif raw(":%S MODE %s +o %S", c_Forest); - raw(":%S MODE %s +ntm", c_Forest); + raw(":%S TOPIC %s :%s", c_Forest, c_ForestTopic); sock_gets(sock,buffer,sizeof(buffer)-1); /* -1 added thanks to David Duchene for pointing out the possible @@ -80,6 +93,8 @@ int main(int argc, char *argv[]) init_masters(); load_gs_dbase(); load_timestamp(); + int loadtime = time(NULL); + bool loaded = false; while (connected) { if (sock_gets(sock,buffer,sizeof(buffer)) == -1) { @@ -96,6 +111,14 @@ int main(int argc, char *argv[]) cmd = strtok(buf, " "); cout << "Server: " << buffer << endl << flush; + + // Wait five seconds then we're loaded. + if (!loaded) + { + if (time(NULL) >= 5 + loadtime) + loaded = true; + } + if (stricmp(cmd, "PING") == 0) { char *timestamp; timestamp = strtok(NULL, ""); @@ -117,6 +140,9 @@ int main(int argc, char *argv[]) aClient *newuser; nick = strtok(NULL, " "); newuser = new aClient(nick); + if (loaded) + notice(s_GameServ, nick, "Hello, %s! This network utilizes a services package called GameServ. For info on how to play the game, type /msg %S help."); + clients.insertAtBack(newuser); delete newuser; } @@ -140,6 +166,20 @@ int main(int argc, char *argv[]) channel = strtok(NULL, " "); if (stricmp(channel, c_Forest) == 0 && is_playing(source + 1)) raw(":%S MODE %s +v %s", c_Forest, (source + 1)); + + #if defined(BAHAMUT) + } else if (stricmp(cmd, "SJOIN") == 0) { + char *channel, *nick; + strtok(NULL, " "); // Ignore the TS + strtok(NULL, " "); // Ignore the TS + channel = strtok(NULL, " "); + strtok(NULL, " "); + nick = strtok(NULL, " "); + nick++; // Get rid of the : + if (stricmp(channel, c_Forest) == 0 && is_playing(nick)) + raw(":%S MODE %s +v %s", channel, nick); + #endif + } else { // cout << "Unrecognized Message: cmd = " << cmd << setw(30) << "source = " << // source << endl; @@ -226,8 +266,8 @@ void load_timestamp() if (infile.fail()) { - cerr << "Error opening .gstimestamp" << endl; - cerr << "Generating new timestamp" << endl; + cout << "Error opening .gstimestamp" << endl; + cout << "Generating new timestamp" << endl; generate: timestamp = midnight(); save_timestamp(); @@ -248,7 +288,7 @@ void save_timestamp() if (outfile.fail()) { - cerr << "Error creating new file." << endl; + cout << "Error creating new file." << endl; return; }