int main(int argc, char *argv[])
{
char buffer[1024], buf[1024];
- int connected = 1;
+ int connected;
char *cmd, *source = NULL, *conf = "gameserv.conf";
srand(time(NULL));
exit(2);
}
+ init_masters();
+ load_gs_dbase();
+
+ if (load_monsters() == false)
+ goto end;
+
+ shuttingdown = false;
+
+ strcpy(boss.name, "Red Dragon");
+ strcpy(boss.weapon, "Breath of Unholy Fire");
+ boss.strength = 6667;
+ boss.gold = 2000000000;
+ boss.exp = 2000000000;
+ 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!");
+
+ // This loop will retry the connection 3 times
+ for (int retry = 0; retry < 3 && !shuttingdown; retry++)
+ {
+ connected = 1;
+ load_day();
+
+ long int loadtime = time(NULL);
+ long int currentTime;
+ long int oldTime = loadtime;
+ bool loaded = false;
+
ignore_pipe();
sock = make_connection(remoteport, SOCK_STREAM, remoteserver);
if (sock == -1) {
log("Server: %s",buffer);
#endif
- strcpy(boss.name, "Red Dragon");
- strcpy(boss.weapon, "Breath of Unholy Fire");
- boss.strength = 6667;
- boss.gold = 2000000000;
- boss.exp = 2000000000;
- 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!");
-
- init_masters();
- load_gs_dbase();
- load_day();
- long int loadtime = time(NULL);
- long int currentTime;
- long int oldTime = loadtime;
- bool loaded = false;
-
- if (load_monsters() == false)
- goto end;
-
while (connected) {
if (sock_gets(sock,buffer,sizeof(buffer)) == -1) {
connected = 0;
if (!loaded)
{
if (time(NULL) >= welcomedelay + loadtime)
+ {
loaded = true;
+ retry = 0; // Start the reconnection cycle over
+ }
}
// Save the player data every updateperiod seconds
}
}
+ } // for loop for connection retry
+
end:
save_gs_dbase();