Parcourir la source

Moved locking to lock entire game.

  We lock the entire game but now atexit won't remove someone elses
lock.
david il y a 4 ans
Parent
commit
ef330b072b
1 fichiers modifiés avec 25 ajouts et 29 suppressions
  1. 25 29
      main.c

+ 25 - 29
main.c

@@ -648,8 +648,8 @@ user_inf build_menu(user_inf my) {
           done = 1;
           break;
         case 'r':
-          if(my.experience > 25) {
-            if(my.metal > 25) {
+          if(my.experience >= 25) {
+            if(my.metal >= 25) {
               my.experience -= 25;
               my.metal -= 25;
               my.fuel += 5;
@@ -936,7 +936,7 @@ void pvp_menu(user_inf my, user_inf targ) {
         my.guns = 1;
         break;
       case 3:
-        my.fuel -= 1;
+        my.fuel -= 4;
         break;
     }
   }
@@ -1589,6 +1589,11 @@ void sysop_menu() {
   od_clr_scr();
 }
 
+void cleanMe() {
+  rel_lock();
+  od_exit(0, FALSE);
+}
+
 void main_menu() {
   // Main menu for once things are done being initalized
   int done = 0;
@@ -1632,24 +1637,7 @@ void main_menu() {
             break;
           }
         }
-        inuse = check_lock();
-        if (inuse == 0) {
-          //od_printf("`bright white`Play\r\n");
-          int lock = grab_lock(); // Grab success and error rc from locking
-          if(lock == 1){
-            play_game();
-            rel_lock();
-          } else if(lock == -1) {
-            od_clr_scr();
-            od_printf("`bright red`Please contact your sysop there seems to be an issue.\r\n");
-            paws();
-            break;
-          }
-        } else {
-          od_clr_scr();
-          od_send_file("ansis/sc_inuse.ans");
-          paws();
-        }
+        play_game();
         break;
       case 'a':
         about_game();
@@ -1698,16 +1686,10 @@ void main_menu() {
   }
 }
 
-void cleanMe() {
-  rel_lock();
-  od_exit(0, FALSE);
-}
-
 int main(int argc, char *argv[]) {
   od_parse_cmd_line(argc, argv);
   // Initiate Door
   od_init();
-  atexit(cleanMe);
   od_clr_scr();
 
   // Debug System
@@ -1731,6 +1713,20 @@ int main(int argc, char *argv[]) {
     dolog("--- Debug ---");
   }
 
-  // Main Menu
-  main_menu();
+  inuse = check_lock();
+  if(!inuse) {
+    int lock = grab_lock();
+    if(!lock) {
+      od_printf("`white`Something went wrong getting the lock.\r\n");
+      paws();
+      od_exit(0, FALSE);
+    } else {
+      atexit(cleanMe);
+      main_menu();
+    }
+  } else {
+    od_send_file("ansis/sc_inuse.ans");
+    paws();
+    od_exit(0, FALSE);
+  }
 }