| 
					
				 | 
			
			
				@@ -159,6 +159,7 @@ dT formDate(int diff) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int db_test() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Displays all users in the database 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char sqlbuffer[256]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -279,7 +280,7 @@ void paws() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int yesNo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char ch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  md_printf("`bright black`(`bright white`Y`bright black`)`white`es `bright black`(`bright red`N`bright black`)`red`o"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  md_printf("`bright black`(`bright white`Y`bright black`)`white`es `bright black`(`bright red`N`bright black`)`red`o`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ch = md_get_answer("YyNn\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   md_printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   switch(tolower(ch)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -379,6 +380,30 @@ user_inf load_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+user_inf highest_player() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Used to find if someone may have fought the Unknown One and won the game already! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  user_inf test; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int high = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int high_exp = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int id = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while(!done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    test = load_player(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(test.uid != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(test.experience > high_exp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Update highest player id and experience 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        high_exp = test.experience; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        high = id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    id += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } // Ok highest experiencing player found! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  test = load_player(high); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return test; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void update_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_stmt *stmt; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -459,7 +484,8 @@ int create_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   return 1; // Good 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void delete_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Removed due to fact it throws off the internal id system 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/*void delete_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char sqlbuffer[256]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -482,7 +508,7 @@ void delete_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void delete_players() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1126,8 +1152,9 @@ user_inf combat_menu(user_inf my, int targ_hp, int targ_dmg, int asteroid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           my.experience += 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           my.metal += 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else if(asteroid == 2) { // If it was the boss! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          my.experience += 8; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          my.metal += 8; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.experience += 5000; // Ensure the game triggers a reset! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.metal = 0; // Stop the player! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.fuel = 2; // Prevent the player from doing anything else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         my.fuel -= 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(my.fuel < 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1224,7 +1251,7 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dT age = formDate(compareDate(myself.laston)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Process player inactivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if(age.age >= 180) { // 6 Months or 1/2 a Year 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.age >= 30) { // 30 days 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       me = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       reset = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1360,8 +1387,8 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 's': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(myself.fuel >= 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           pirate_encounter = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          if(pirate_encounter >= 75) { // 25% chance to encounter a Pirate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(myself.experience > 5000) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(pirate_encounter >= 75) { // 25% chance to encounter a Pirate, or Unknown One 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(myself.experience > 3000) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               if(pirate_encounter >= 95) { // 5% chance to encounter unknown one 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 md_printf("`bright yellow`You encounter the `bright red`Unknown One\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 asteroid = 2; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1369,6 +1396,9 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 md_printf("`bright yellow`You encounter a `bright red`Pirate\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 asteroid = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { // The player is not skilled enough to fight the unknown one 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              md_printf("`bright yellow`You encounter a `bright red`Pirate\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              asteroid = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } else { // 75% chance to encounter a Asteroid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             md_printf("`bright yellow`You encounter a `bright red`Asteroid\r\n`white`"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1376,7 +1406,7 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           if(asteroid == 0 || asteroid == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             pirate_hp = ((myself.hitpoints + 1) + (rand() % 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(asteroid == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(asteroid == 2) { // Increase boss hitpoints 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               pirate_hp += 10;  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // Increase difficulty based on experience... 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1460,6 +1490,7 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(myself.armorpoints > (myself.armors * 8)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               myself.armorpoints = (myself.armors * 8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            update_player(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             md_printf("`bright green`Repaired 4 Armor Points!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             md_printf("`bright red`You need metal inorder to repair!\r\n`white`"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1471,6 +1502,8 @@ void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'g': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(myself.shieldpoints < (myself.shields * 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           myself.shieldpoints = (myself.shields * 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shieldsup = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          update_player(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           md_printf("`bright green`Regenerated Shields!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           md_printf("`bright yellow`You don't seem to need to regenerate shields!\r\n`white`"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1487,16 +1520,11 @@ void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int targ_ply = 1; // Target player to perform op! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int targ_max = 0; // Total number of players affected! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   user_inf targ; // Player Struct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  user_inf test; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   dT targ_age; // Date Struct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char targ_real[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char ch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Check Lock 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  inuse = check_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // 0 means we got the lock first, 1 means someone else has it already! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Lock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    grab_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   while(!done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(mdcontrol.user_seclevel == 99 || mdcontrol.user_seclevel == 255) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1514,15 +1542,40 @@ void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'p': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dolog("Auto-Reset Occured!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Game has been reset!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { // And the lucky winner is! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int resetage = 3 - test2.age; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`%s has won the game!\r\n", test.nick); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`The Game will reset in %d days!\r\n", resetage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        inuse = check_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Lock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          grab_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (inuse == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          md_printf("`bright red`______________\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          md_printf("`bright red` Game in use!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          md_printf("`bright red`______________\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_sendfile("ansis/sc_inuse.ans", FALSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           //md_printf("`bright white`Play\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           play_game(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Unlock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          rel_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'a': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         about_game(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1611,10 +1664,6 @@ void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Unlock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    rel_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int main(int argc, char **argv) { 
			 |