|
@@ -210,21 +210,23 @@ int check_lock() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void grab_lock() {
|
|
|
- // Attempt to grab lock
|
|
|
+int grab_lock() {
|
|
|
+ // Attempt to grab lock, (0 = Already gotten, 1 = Success, -1 = Error)
|
|
|
int valid = check_lock();
|
|
|
FILE *fhandle;
|
|
|
if (valid == 0) {
|
|
|
fhandle = fopen("lock.flg", "w");
|
|
|
if(!fhandle) {
|
|
|
dolog("E: Unable to make lock.flg!");
|
|
|
- fprintf(stderr, "Unable to establish lock!\r\n");
|
|
|
- md_exit(-1);
|
|
|
+ dolog("E: Something went wrong perhaps we don't have permissions?");
|
|
|
+ return -1;
|
|
|
}
|
|
|
fprintf(fhandle, "I am in use already!\n");
|
|
|
fclose(fhandle);
|
|
|
+ return 1;
|
|
|
} else {
|
|
|
dolog("W: Lock already established!");
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -233,9 +235,8 @@ void rel_lock() {
|
|
|
int valid = check_lock();
|
|
|
if (valid == 1) {
|
|
|
if (unlink("lock.flg") != 0) {
|
|
|
- dolog("E: Unable to release lock.flg!");
|
|
|
- fprintf(stderr, "Unable to release lock!\r\n");
|
|
|
- md_exit(-1);
|
|
|
+ dolog("C: Unable to release lock.flg!");
|
|
|
+ dolog("C: Something went wrong! Players might not be able to play now!");
|
|
|
}
|
|
|
} else {
|
|
|
dolog("W: Lock already released!");
|
|
@@ -1251,7 +1252,7 @@ void play_game() {
|
|
|
if(testing.uid != 0) {
|
|
|
myself = load_player(me);
|
|
|
}
|
|
|
- dT age = formDate(compareDate(myself.laston));
|
|
|
+ dT age = fromDate(compareDate(myself.laston));
|
|
|
// Process player inactivity
|
|
|
if(age.age >= 30) { // 30 days
|
|
|
md_printf("`bright green`Since you haven't played a while we have reset your account!\r\n");
|
|
@@ -1265,7 +1266,7 @@ void play_game() {
|
|
|
}
|
|
|
if(me != 0) {
|
|
|
md_printf("`bright white`Welcome back `bright green`%s\r\n", myself.nick);
|
|
|
- dT age = formDate(compareDate(myself.laston));
|
|
|
+ dT age = fromDate(compareDate(myself.laston));
|
|
|
dolog("%s is now playing (G=%d A=%d S=%d F=%d M=%d AP=%d SP=%d (%d) HP=%d LO=%d or %d days)",
|
|
|
myself.nick, myself.guns, myself.armors, myself.shields, myself.fuel, myself.metal, myself.armorpoints,
|
|
|
myself.shieldpoints, myself.shieldsup, myself.hitpoints, myself.laston, age.age);
|
|
@@ -1627,7 +1628,7 @@ void main_menu() {
|
|
|
// Play Game (Default if the player just hits enter)
|
|
|
// Check to see if we have a winner if so refuse to let anyone on! (Wait 3 days then reset the game!)
|
|
|
test = highest_player();
|
|
|
- dT test2 = formDate(compareDate(test.laston));
|
|
|
+ dT test2 = fromDate(compareDate(test.laston));
|
|
|
if(test.experience >= 8000) { // If the player has the minimum of 3000 exp to fight the Unkown One and wins earning 5000 thats 8000 minimum
|
|
|
if(test2.age >= 3) { // Auto reset the game or not allow the player to play!
|
|
|
delete_players();
|
|
@@ -1645,9 +1646,16 @@ void main_menu() {
|
|
|
inuse = check_lock();
|
|
|
if (inuse == 0) {
|
|
|
//md_printf("`bright white`Play\r\n");
|
|
|
- grab_lock();
|
|
|
- play_game();
|
|
|
- rel_lock();
|
|
|
+ int lock = grab_lock(); // Grab success and error rc from locking
|
|
|
+ if(lock == 1){
|
|
|
+ play_game();
|
|
|
+ rel_lock();
|
|
|
+ } else if(lock == -1) {
|
|
|
+ md_clr_scr();
|
|
|
+ md_printf("`bright red`Please contact your sysop there seems to be an issue.\r\n");
|
|
|
+ paws();
|
|
|
+ break;
|
|
|
+ }
|
|
|
} else {
|
|
|
md_clr_scr();
|
|
|
md_sendfile("ansis/sc_inuse.ans", FALSE);
|