| 
					
				 | 
			
			
				@@ -6,7 +6,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Verion 0.1-dev 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define VERSION_MAJOR 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-#define VERSION_MINOR 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#define VERSION_MINOR 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #ifndef VERSION_TYPE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define VERSION_TYPE "dev" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #endif 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,10 +56,19 @@ typedef struct user_info { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int armorpoints; // Points we get from armors (Repairable but costs 1 metal per point, but can break if taking too much damage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int shieldpoints; // Points we get from shields (Self-Regenerates, and does not get destroyed) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int shieldsup; // 0 means yes, anything else means shields are offline, deduct if not 0 for each attack. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int laston; // 20200630 is 6-30-2020 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char nick[256]; // What they go by on score board, this allows duping since we really go by real 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char real[256]; // Their real name to match with drop file info, prevents someone from loging in as another 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } user_inf; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// DateStamp Structure to provide date difference 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+typedef struct dateTamp { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int year;  // YYYY, or number of years difference 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int month; // MM, or number of months difference 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int day;   // DD, or number of days difference. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int age;   // Taking down to aproximate day count. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} dT; // YYYYMMDD it in int form 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void dolog(char *fmt, ...) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Low end Logging 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char buffer[PATH_MAX]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -92,11 +101,70 @@ void dolog(char *fmt, ...) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   fclose(logfptr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-void db_test() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int dateStamp() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // YYYYMMDD \o/ In a INT so we can store it and compare against it! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  struct tm *time_now; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  time_t timen; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int result = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  timen = time(NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  time_now = localtime(&timen); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result += ((time_now->tm_year + 1900) * 10000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result += (time_now->tm_mon * 100) + 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result += time_now->tm_mday; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int compareDate(int dt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Returns integer of difference, from now. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  struct tm *time_now; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  time_t timen; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int now = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  timen = time(NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  time_now = localtime(&timen); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  now += ((time_now->tm_year + 1900) * 10000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  now += (time_now->tm_mon * 100) + 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  now += time_now->tm_mday; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return (now - dt); // 10000 = 1 Year, 100 = 1 Month, 1 = 1 Day 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+dT formDate(int diff) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Reverse process so we can compare exact days or get the structure back out too. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  dT result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result.year = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result.month = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result.day = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  result.age = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int notDone = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while(notDone) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(diff >= 10000) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      diff -= 10000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      result.year += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else if(diff >= 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      diff -= 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      result.month += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else if(diff >= 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      diff -= 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      result.day += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      notDone = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } // Process Aprox day count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(result.year != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    result.age += (365 * result.year); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } else if(result.month != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    result.age += (30 * result.month); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } else if(result.day != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    result.age += result.day; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int db_test() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char sqlbuffer[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char strbuffer[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int sizeofdb = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int rc = sqlite3_open("spaceconstruct.db3", &db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -108,34 +176,7 @@ void db_test() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   strcpy(sqlbuffer, "SELECT * FROM user;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer), &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   while(sqlite3_step(stmt) == SQLITE_ROW) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /* Disabled to reduce logs to errors/warnings 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    dolog("%s=%d %s=%s %s=%s %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 0), // int,  uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 0), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 1), // text, nick 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_text(stmt, 1), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 2), // text, real 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_text(stmt, 2), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 3), // int,  experiece 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 3), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 4), // int,  metal 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 4), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 5), // int,  fuel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 5), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 6), // int,  guns 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 6), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 7), // int,  armors 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 7), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 8), // int,  shields 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 8), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 9), // int,  armorpoints 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 9), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 10), // int, shieldpoints 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 10), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_name(stmt, 11), // int,  hitpoints 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 11) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ); */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_printf("`white`%s=%d %s=%s %s=%s %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`white`%s=%d %s=%s %s=%s %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d %s=%d\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_name(stmt, 0), // int,  uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_int(stmt, 0), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_name(stmt, 1), // text, nick 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -161,11 +202,15 @@ void db_test() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_name(stmt, 11), // int,  hitpoints 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_int(stmt, 11), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sqlite3_column_name(stmt, 12), // int,  shieldsup 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      sqlite3_column_int(stmt, 12) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sqlite3_column_int(stmt, 12), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sqlite3_column_name(stmt, 13), // int,  laston 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sqlite3_column_int(stmt, 13) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sizeofdb += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } // Clean up database 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return sizeofdb; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int check_lock() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -212,19 +257,6 @@ void rel_lock() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void log_drop() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Spits out info from Drop File: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* Disabled to reduce logs to errors/warnings 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  dolog("First=%s Last=%s Alias=%s TimeLeft=%d SecLevel=%d Location=%s Node=%d Socket=%d Sysop=%s", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_firstname, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_lastname, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_alias, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_timeleft, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_seclevel, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.user_location, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.node, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.socket, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    mdcontrol.sysop_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   md_printf("`white`First=%s Last=%s Alias=%s TimeLeft=%d SecLevel=%d Location=%s Node=%d Socket=%d Sysop=%s\r\n", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     mdcontrol.user_firstname, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     mdcontrol.user_lastname, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -245,6 +277,23 @@ void paws() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   md_printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ch = md_get_answer("YyNn\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  md_printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  switch(tolower(ch)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    case 'y': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    case 'n': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return done; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int locate_player(char first[], char last[]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // returns user id for given real name and 0 for no record found 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3 *db; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -256,7 +305,7 @@ int locate_player(char first[], char last[]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_exit(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Form Real Name 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -293,12 +342,12 @@ user_inf load_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_exit(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  strcpy(sqlbuffer, "SELECT * from user where uid=?;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  strcpy(sqlbuffer, "SELECT * FROM user WHERE uid=?;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  sqlite3_bind_int(stmt, uuid, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 1, uuid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   rc = sqlite3_step(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if (rc == SQLITE_ROW) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result.uid = sqlite3_column_int(stmt, 0); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -314,8 +363,9 @@ user_inf load_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result.shieldpoints = sqlite3_column_int(stmt, 10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result.hitpoints = sqlite3_column_int(stmt, 11); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     result.shieldsup = sqlite3_column_int(stmt, 12); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    result.laston = sqlite3_column_int(stmt, 13); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    dolog("E: Unable to locate user with id=%d", uuid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: Unable to locate user with id=%d got %s (%d)", uuid, sqlite3_errmsg(db), rc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     md_exit(-1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -333,13 +383,13 @@ void update_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_exit(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Bad, don't do this... opens to SQL injection! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //snprintf(sqlbuffer, 1024, "UPDATE user SET nick = '%s', experience = %d, metal = %d, fuel = %d, guns = %d, armors = %d, shields = %d, armorpoints = %d, shieldpoints = %d, hitpoints = %d WHERE uid=%d;", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   //  data.nick, data.experience, data.metal, data.fuel, data.guns, data.armors, data.shields, data.armorpoints, data.shieldpoints, data.hitpoints, data.uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  strcpy(sqlbuffer, "UPDATE user SET nick=?, experience=?, metal=?, fuel=?, guns=?, armors=?, shields=?, armorpoints=?, shieldpoints=?, hitpoints=?, shieldsup=? WHERE uid=?;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  strcpy(sqlbuffer, "UPDATE user SET nick=?, experience=?, metal=?, fuel=?, guns=?, armors=?, shields=?, armorpoints=?, shieldpoints=?, hitpoints=?, shieldsup=?, laston=? WHERE uid=?;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Bind All data values 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_bind_text(stmt, 1, data.nick, strlen(data.nick), SQLITE_STATIC); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -353,7 +403,8 @@ void update_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_bind_int(stmt, 9, data.shieldpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_bind_int(stmt, 10, data.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_bind_int(stmt, 11, data.shieldsup); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  sqlite3_bind_int(stmt, 12, data.uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 12, data.laston); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 13, data.uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Execute 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   rc = sqlite3_step(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(rc != SQLITE_DONE) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -366,19 +417,603 @@ void update_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int create_player(user_inf data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char sqlbuffer[1024]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int rc = sqlite3_open("spaceconstruct.db3", &db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  strcpy(sqlbuffer, "INSERT INTO user (nick, real, experience, metal, fuel, guns, armors, shields, armorpoints, shieldpoints, hitpoints, shieldsup, laston) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_text(stmt, 1, data.nick, strlen(data.nick), SQLITE_STATIC); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_text(stmt, 2, data.real, strlen(data.real), SQLITE_STATIC); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 3, data.experience); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 4, data.metal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 5, data.fuel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 6, data.guns); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 7, data.armors); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 8, data.shields); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 9, data.armorpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 10, data.shieldpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 11, data.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 12, data.shieldsup); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 13, data.laston); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  rc = sqlite3_step(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(rc != SQLITE_DONE) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: failed inserting player=%d got error %s (%d)", data.nick, sqlite3_errmsg(db), rc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return 1; // Good 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void delete_player(int uuid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char sqlbuffer[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int rc = sqlite3_open("spaceconstruct.db3", &db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  strcpy(sqlbuffer, "DELETE FROM user WHERE uid=?;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_bind_int(stmt, 1, uuid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  rc = sqlite3_step(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (rc != SQLITE_DONE){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: Unable to locate user with id=%d got %s (%d)", uuid, sqlite3_errmsg(db), rc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int display_all_players() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3 *db; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_stmt *stmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char sqlbuffer[1024]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int rc = sqlite3_open("spaceconstruct.db3", &db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(rc) { // Did we do a successful open? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dolog("E: failed opening database %s", sqlite3_errmsg(db)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_exit(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_busy_timeout(db, 5000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  strcpy(sqlbuffer, "SELECT * from user ORDER BY experience DESC, nick DESC;"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_prepare_v2(db, sqlbuffer, strlen(sqlbuffer) + 1, &stmt, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int total = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  md_printf("`bright green`___ The Players ___\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while(sqlite3_step(stmt) == SQLITE_ROW) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright white`  %s (%d)\r\n", sqlite3_column_text(stmt, 1), sqlite3_column_int(stmt, 3)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    total += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  md_printf("`green`There are a total of `bright green`%d`green` players\r\n", total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_finalize(stmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  sqlite3_close(db); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return total; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+user_inf build_menu(user_inf my) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int didUp = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char ch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(my.metal != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    while(!done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_sendfile("ansis/sc_build.ans", FALSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`You have %d metal\r\n", my.metal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ch = md_get_answer("GgAaSsCcRr\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      switch(tolower(ch)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 'g': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.metal >= 4) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.metal -= 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.guns += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            didUp = 1; // We need to save 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Added a new gun!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You don't have the 4 metal for this!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 'a': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.metal >= 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.metal -= 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.armors += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.armorpoints += 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            didUp = 1; // We need to save 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Added a new armor!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You don't have the 3 metal for this!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 's': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.metal >= 6) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.metal -= 6; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shields += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(my.shieldsup == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.shieldpoints += 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.shieldpoints += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            didUp = 1; // We need to save 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Added a new shield!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You don't have the 6 metal for this!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 'c': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        case 'r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.experience > 25) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(my.metal > 10) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.experience -= 25; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.metal -= 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.fuel += 5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              didUp = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              md_printf("`bright green`Made 5 fuel using 25 experience and 10 metal!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              md_printf("`bright red`You need 25 experience and 10 metal to make fuel!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You need 25 experience and 10 metal to make fuel!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(didUp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      update_player(my); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return my; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return my; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+user_inf combat_menu(user_inf my, int targ_hp, int targ_dmg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int playerWon = 0; // Did the player win? (1 = Yes, 2 = No, 3 = Flee) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char ch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int armorRep = 0; // Can armor be repaired? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int temp = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int temp1 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int temp2 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int flee = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int fire = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int regen = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while(!done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright red`Target ship has %d hitpoints left\r\n", targ_hp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Proccess Shields comming back online 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(my.shieldsup != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      my.shieldsup -= 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Proccess Crew repairing hull 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(my.hitpoints < (my.guns + my.armors + my.shields + 2)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      regen = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(regen >= 95) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.hitpoints += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.hitpoints > (my.guns + my.armors + my.shields + 2)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.hitpoints = (my.guns + my.armors + my.shields + 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf("`bright green`Your crew repaired your hull for 1 point!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(my.shieldsup == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // Proccess Shield Regeneration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(my.shieldpoints < (my.shields * 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        regen = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(regen >= 75) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.shieldpoints += (my.shields + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.shieldpoints > (my.shields * 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shieldpoints = (my.shields * 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright green`Your shields regenerate %d points!\r\n", my.shields); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`Your ship has %d armor, `bright blue`%d`bright yellow` shields and %d hitpoints left:\r\n", my.armorpoints, my.shieldpoints, my.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // Shields should still regenerate some 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(my.shieldpoints < (my.shields * 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        regen = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(regen >= 75) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.shieldpoints += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.shieldpoints > (my.shields * 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shieldpoints = (my.shields * 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright green`Your shields regenerate 1 points!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`Your ship has %d armor, `blue`%d`bright yellow` shields and %d hitpoints left:\r\n", my.armorpoints, my.shieldpoints, my.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Forming Combat Menu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright black`(`bright white`A`bright black`)`white`ttack\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(my.armorpoints < (my.armors * 4)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright black`(`bright white`R`bright black`)`white`epair Armor\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      armorRep = 1; // Yes we can repair armor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright black`(`bright white`F`bright black`)`white`lee\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Proccess User action 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ch = md_get_answer("AaRrFf\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    switch(tolower(ch)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'a': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fire = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(fire >= 50) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          targ_hp -= my.guns; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(targ_hp <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`Target Destroyed!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            playerWon = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`Target took %d damage!\r\n", my.guns); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`white`Target Missed!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(armorRep) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.metal > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.metal -= 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.armorpoints += 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(my.armorpoints < (my.armors * 4)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.armorpoints = (my.armors * 4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Repaired 2 Armor points!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You need metal inorder to repair!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright yellow`You don't seem to need repairs!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'f': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        flee = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(flee >= 82) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          playerWon = 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright green`You ran away!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright red`Target found us!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } // If Enemy is alive proccess incomming attack 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(targ_hp > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      temp = targ_dmg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      fire = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(fire >= 40) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Shields 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.shieldsup == 0 && my.shieldpoints != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(temp >= my.shieldpoints) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Damage will lower shields! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shieldsup = (my.shields + 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp -= my.shieldpoints; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shieldpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright blue`Shields absorbed %d damage and went offline!\r\n`white`", targ_dmg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Damage to shields but not lower them 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp1 = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp -= my.shieldpoints; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.shieldpoints -= temp1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp1 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright blue`Shields absorbed %d damage!\r\n`white`", targ_dmg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // shields now armor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(temp > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(my.armorpoints != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // We do have armor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(temp >= my.armorpoints) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              // Damage will destroy armor! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp2 = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp -= my.armorpoints; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.armorpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              md_printf("`yellow`Armor took %d damage and broke!\r\n`white`", temp2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              // Nope armor is good 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp1 = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp2 = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp -= my.armorpoints; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              my.armorpoints -= temp1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              temp1 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              md_printf("`bright yellow`Armor took %d damage!\r\n`white`", temp2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // armor now hull 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(temp > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(temp < my.hitpoints) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp1 = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp -= my.hitpoints; // should be 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.hitpoints -= temp1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`Hull took %d damage!\r\n", temp1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            playerWon = 2; // Nope the target did us in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            my.hitpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`red`Hull took %d damage and broke!\r\n", temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // firing 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Winning move? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(playerWon) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(playerWon == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Player won 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.experience += (my.guns + my.hitpoints + my.armorpoints + my.shieldpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.metal += (my.guns + my.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.fuel -= 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.fuel < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.fuel = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf("`bright green`Congrats on your victory!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        update_player(my); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return my; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else if(playerWon == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Target won 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.experience -= (targ_hp + my.guns); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.metal -= (targ_hp + my.guns); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.fuel -= 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.experience < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.experience = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.metal < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.metal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(my.fuel < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          my.fuel = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf("`bright red`Sorry for your loss! (We rebuild your ship)\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.hitpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.armorpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.shieldpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.shieldsup = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.armors = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.shields = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.guns = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        update_player(my); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return my; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else if(playerWon == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Chicken! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        my.fuel -= 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        update_player(my); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return my; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void play_game() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char ch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  char ch1[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  user_inf myself; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int reset = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int doRefuel = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int pirate_encounter = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int pirate_hp = 0; // Reused for asteroid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int pirate_dmg = 0; // Reused for asteroid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int asteroid = 0; // 1 means yes we need to remove damage... completely. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  int me = locate_player(mdcontrol.user_firstname, mdcontrol.user_lastname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(me != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    myself = load_player(me); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dT age = formDate(compareDate(myself.laston)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Process player inactivity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.age >= 180) { // 6 Months or 1/2 a Year 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      me = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      reset = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Processing fuel regeneration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.age != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      doRefuel = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(me != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright white`Welcome back `bright green`%s\r\n", myself.nick); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    dT age = formDate(compareDate(myself.laston)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    myself.laston = dateStamp(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.day != 0 || age.month != 0 || age.year != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`Haven't seen you for"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.day != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(age.day > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d days", age.day); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d day", age.day); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.month != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(age.month > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d months", age.month); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d month", age.month); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.year != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(age.year > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d years", age.year); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf(" %d year", age.year); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(age.day != 0 || age.month != 0 || age.year != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(doRefuel) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      myself.fuel += (age.age * 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright green`You now have %d fuel\r\n", myself.fuel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    update_player(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright white`You look new here. (Hit Enter to use your alias)\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    while(done == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`What's your name: "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_getstring(ch1, 26, 32, 126); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(strlen(ch1) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //md_getstring(ch1, 256, 32, 126); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strcpy(myself.nick, ch1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strcpy(myself.nick, mdcontrol.user_alias); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright white`Are you sure you want to be called `bright green`%s\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      done = yesNo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(reset) { // So we are reseting the user, this wipes all values and uses update instead of create 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.experience = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.metal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.fuel = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.guns = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.armors = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shields = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.armorpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shieldpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.hitpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shieldsup = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.laston = dateStamp(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          update_player(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { // Brand new user 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          char name[256]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          strcpy(name, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          strcat(name, mdcontrol.user_firstname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          strcat(name, " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          strcat(name, mdcontrol.user_lastname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          strcpy(myself.real, name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.experience = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.metal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.fuel = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.guns = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.armors = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shields = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.armorpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shieldpoints = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.hitpoints = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.shieldsup = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself.laston = dateStamp(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          create_player(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    done = 0; // Reset this for our next loop. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Ok user is here now lets ask what they want to do... build/attack 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while(!done) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_printf("`bright yellow`You have %d fuel left for today,\r\n", myself.fuel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(myself.shieldsup == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`Your ship has %d armor, `bright blue`%d`bright yellow` shields and %d hitpoints left:\r\n", myself.armorpoints, myself.shieldpoints, myself.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_printf("`bright yellow`Your ship has %d armor, `blue`%d`bright yellow` shields and %d hitpoints left:\r\n", myself.armorpoints, myself.shieldpoints, myself.hitpoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(myself.fuel != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_sendfile("ansis/sc_gameh.ans", FALSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ch = md_get_answer("SsHhBbQqRr\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      md_sendfile("ansis/sc_gamel.ans", FALSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ch = md_get_answer("BbQqRr\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    switch(tolower(ch)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 's': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(myself.fuel != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          pirate_encounter = rand() % 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(pirate_encounter >= 75) { // 25% chance to encounter a Pirate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            asteroid = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(asteroid == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            pirate_hp = (myself.hitpoints + 1) + (rand() % 4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(myself.armors >= 2 && myself.shields >= 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              pirate_dmg = (myself.guns + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              pirate_dmg = myself.guns; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Send off to combat menu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            myself = combat_menu(myself, pirate_hp, pirate_dmg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            pirate_hp = (myself.hitpoints + 1) + (rand() % 10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Send off to combat menu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            myself = combat_menu(myself, pirate_hp, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'h': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        md_printf("Hunt\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'b': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(myself.metal != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // Send off to build menu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //md_sendfile("ansis/sc_build.ans", FALSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          myself = build_menu(myself); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright white`I am sorry you have no metal go fight a `bright red`Asteroid`bright white` or `bright red`Pirate`bright white`.`white`\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'q': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        done = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      case 'r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(myself.armorpoints < (myself.armors * 4)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(myself.metal > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            myself.metal -= 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            myself.armorpoints += 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(myself.armorpoints > (myself.armors * 4)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              myself.armorpoints = (myself.armors * 4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright green`Repaired 3 Armor Points!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            md_printf("`bright red`You need metal inorder to repair!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright yellow`You don't seem to need repairs!\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Main menu for once things are done being initalized 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   int done = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   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) { // Display a menu for sysops 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      md_sendfile("ansis/sc_mainh.ans", TRUE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ch = md_get_answer("PpLlVvQqEe\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } else { // And display a different menu for non-sysops 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      md_sendfile("ansis/sc_mainl.ans", TRUE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ch = md_get_answer("PpLlVvQq\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    md_sendfile("ansis/sc_mainl.ans", TRUE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ch = md_get_answer("PpLlVvQq\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     switch(tolower(ch)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'q': 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -392,14 +1027,17 @@ void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // Play Game (Default if the player just hits enter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (inuse == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           md_printf("`bright red`Game in use!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          md_printf("`bright white`Play\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          //md_printf("`bright white`Play\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          play_game(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'l': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // List Players in the game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        md_printf("`bright red`There are no players!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(display_all_players() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          md_printf("`bright red`There are no players!\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       case 'v': 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -410,15 +1048,12 @@ void main_menu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         md_printf("`bright yellow`|--------------------------|\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      case 'e': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // Edit Game (User Editor, Game Settings) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(mdcontrol.user_seclevel == 99 || mdcontrol.user_seclevel == 255) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          md_printf("`bright green`Sysop Menu\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Unlock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    rel_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int main(int argc, char **argv) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -456,41 +1091,14 @@ int main(int argc, char **argv) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       md_printf("Lock is: Taken\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       md_printf("CANCELED Database Dump\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_printf("`bright green`Continue to Program?\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_printf("`bright black`(`bright white`Y`bright black`)`white`es `bright black`(`bright red`N`bright black`)`red`o"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    char t = md_get_answer("YyNn\r"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    md_printf("\r\n`white`"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    switch(tolower(t)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      case '\r': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      case 'y': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      case 'n': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        md_exit(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    paws(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     md_clr_scr(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     dolog("--- Debug ---"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // 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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Main Menu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //main_menu(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //user_inf ply = load_player(locate_player(mdcontrol.user_firstname, mdcontrol.user_lastname)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //update_player(ply); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // Unlock game 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if (inuse == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    rel_lock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  main_menu(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Goodbye 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   md_exit(0); 
			 |