add Swords 'n Magic and Stuff
This commit is contained in:
		| @@ -275,6 +275,7 @@ If you are reading this it looks like you are looking to add an egg to your serv | |||||||
| * [Stormworks: Build and Rescue](game_eggs/steamcmd_servers/stormworks) | * [Stormworks: Build and Rescue](game_eggs/steamcmd_servers/stormworks) | ||||||
| * [Subnautica: Nitrox Mod](game_eggs/steamcmd_servers/subnautica_nitrox_mod) | * [Subnautica: Nitrox Mod](game_eggs/steamcmd_servers/subnautica_nitrox_mod) | ||||||
| * [Sven Co-op](game_eggs/steamcmd_servers/svencoop) | * [Sven Co-op](game_eggs/steamcmd_servers/svencoop) | ||||||
|  | * [Swords 'n Magic and Stuff](game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff) | ||||||
| * [The Forest](game_eggs/steamcmd_servers/the_forest) | * [The Forest](game_eggs/steamcmd_servers/the_forest) | ||||||
| * [The Isle](game_eggs/steamcmd_servers/the_isle) | * [The Isle](game_eggs/steamcmd_servers/the_isle) | ||||||
|   * [Evrima](game_eggs/steamcmd_servers/the_isle/evrima) |   * [Evrima](game_eggs/steamcmd_servers/the_isle/evrima) | ||||||
|   | |||||||
| @@ -176,6 +176,7 @@ | |||||||
| * [Stormworks: Build and Rescue](steamcmd_servers/stormworks) | * [Stormworks: Build and Rescue](steamcmd_servers/stormworks) | ||||||
| * [Subnautica: Nitrox Mod](steamcmd_servers/subnautica_nitrox_mod) | * [Subnautica: Nitrox Mod](steamcmd_servers/subnautica_nitrox_mod) | ||||||
| * [Sven Co-op](steamcmd_servers/svencoop) | * [Sven Co-op](steamcmd_servers/svencoop) | ||||||
|  | * [Swords 'n Magic and Stuff](steamcmd_servers/Swords_'n_Magic_and_Stuff) | ||||||
| * [Team Fortress 2 Classic](steamcmd_servers/team_fortress_2_classic) | * [Team Fortress 2 Classic](steamcmd_servers/team_fortress_2_classic) | ||||||
| * [The Forest](steamcmd_servers/the_forest) | * [The Forest](steamcmd_servers/the_forest) | ||||||
| * [The Isle](steamcmd_servers/the_isle) | * [The Isle](steamcmd_servers/the_isle) | ||||||
|   | |||||||
| @@ -215,6 +215,10 @@ This is a collection of servers that use SteamCMD to install. | |||||||
|  |  | ||||||
| [Sven Co-op](svencoop) | [Sven Co-op](svencoop) | ||||||
|  |  | ||||||
|  | ## Swords 'n Magic and Stuff | ||||||
|  |  | ||||||
|  | [Swords 'n Magic and Stuff](Swords_'n_Magic_and_Stuff) | ||||||
|  |  | ||||||
| ## Team Fortress 2 Classic | ## Team Fortress 2 Classic | ||||||
|  |  | ||||||
| [Team Fortress 2 Classic](team_fortress_2_classic) | [Team Fortress 2 Classic](team_fortress_2_classic) | ||||||
|   | |||||||
| @@ -0,0 +1,16 @@ | |||||||
|  | # Swords 'n Magic and Stuff | ||||||
|  |  | ||||||
|  | Grab your friends and set out for adventure in a world of swords, magic, and stuff. Discover tons of cool loot, uncover hidden secrets, and meet new friends and foes along the way. Make your mark and find a place to call home in this cute, multiplayer, open world RPG.  | ||||||
|  |  | ||||||
|  | ## Console | ||||||
|  | Because there is not yet a real console this egg uses a wrapper that prints the log file to the console but it is a continue loop so it will keep sending the contents of the latest log file to the console. The console does not accept any input. | ||||||
|  |  | ||||||
|  | ## Server Ports | ||||||
|  |  | ||||||
|  |  | ||||||
|  | | Port      | default | | ||||||
|  | |-----------|---------| | ||||||
|  | | Game      | 7777    | | ||||||
|  | | Query     | 27015   | | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										118
									
								
								game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								game_eggs/steamcmd_servers/Swords_'n_Magic_and_Stuff/wrapper.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,118 @@ | |||||||
|  | #include <stdio.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <unistd.h> | ||||||
|  | #include <dirent.h> | ||||||
|  | #include <signal.h> | ||||||
|  | #include <fcntl.h> | ||||||
|  | #include <time.h> | ||||||
|  | #include <sys/stat.h> | ||||||
|  |  | ||||||
|  | void print_latest_log(const char* log_directory) { | ||||||
|  |     DIR *dir; | ||||||
|  |     struct dirent *entry; | ||||||
|  |     time_t latest_time = 0; | ||||||
|  |     char latest_file[256]; | ||||||
|  |  | ||||||
|  |     dir = opendir(log_directory); | ||||||
|  |     if (dir == NULL) { | ||||||
|  |         printf("Error opening directory %s\n", log_directory); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     while ((entry = readdir(dir)) != NULL) { | ||||||
|  |         if (strstr(entry->d_name, "SnMDedSrv-") == entry->d_name && | ||||||
|  |             strstr(entry->d_name, ".log") != NULL) { | ||||||
|  |             char filename[256]; | ||||||
|  |             sprintf(filename, "%s/%s", log_directory, entry->d_name); | ||||||
|  |             struct stat file_stat; | ||||||
|  |             stat(filename, &file_stat); | ||||||
|  |             if (file_stat.st_mtime > latest_time) { | ||||||
|  |                 latest_time = file_stat.st_mtime; | ||||||
|  |                 strcpy(latest_file, filename); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (latest_time == 0) { | ||||||
|  |         printf("No log files found in directory %s\n", log_directory); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     printf("\nLatest log file: %s\n", latest_file); | ||||||
|  |  | ||||||
|  |     int fd = open(latest_file, O_RDONLY); | ||||||
|  |     if (fd < 0) { | ||||||
|  |         printf("Error opening file %s\n", latest_file); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     char buffer[4096]; | ||||||
|  |     int bytes_read; | ||||||
|  |     int last_line_printed = 0; // Flag to check whether we have printed the last line | ||||||
|  |     do { | ||||||
|  |         bytes_read = read(fd, buffer, sizeof(buffer)); | ||||||
|  |         if (bytes_read > 0) { | ||||||
|  |             // Check if the last character is a newline | ||||||
|  |             if (buffer[bytes_read - 1] == '\n') { | ||||||
|  |                 fwrite(buffer, 1, bytes_read, stdout); | ||||||
|  |                 fflush(stdout); | ||||||
|  |             } else { | ||||||
|  |                 // If the last character is not a newline, add one | ||||||
|  |                 char* temp = (char*) malloc(bytes_read + 1); | ||||||
|  |                 memcpy(temp, buffer, bytes_read); | ||||||
|  |                 temp[bytes_read] = '\n'; | ||||||
|  |                 fwrite(temp, 1, bytes_read + 1, stdout); | ||||||
|  |                 fflush(stdout); | ||||||
|  |                 free(temp); | ||||||
|  |             } | ||||||
|  |             last_line_printed = (buffer[bytes_read - 1] == '\n'); | ||||||
|  |         } | ||||||
|  |     } while (bytes_read > 0); | ||||||
|  |  | ||||||
|  |     // If the last line was not printed, print it now | ||||||
|  |     if (!last_line_printed) { | ||||||
|  |         printf("\n"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     close(fd); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | int main(int argc, char** argv) { | ||||||
|  |     if (argc < 2) { | ||||||
|  |         printf("Usage: winewrapper wine_path wine_args exe_path exe_args\n"); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     char* wine_path = argv[1]; | ||||||
|  |  | ||||||
|  |     pid_t pid = fork(); | ||||||
|  |     if (pid == 0) { | ||||||
|  |         char** wine_argv = (char**) malloc(sizeof(char*) * (argc - 1)); | ||||||
|  |         wine_argv[0] = wine_path; | ||||||
|  |         for (int i = 2; i < argc; i++) { | ||||||
|  |             wine_argv[i - 1] = argv[i]; | ||||||
|  |         } | ||||||
|  |         wine_argv[argc - 1] = NULL; | ||||||
|  |         execv(wine_path, wine_argv); | ||||||
|  |         printf("Error launching wine process\n"); | ||||||
|  |         exit(1); | ||||||
|  |     } else if (pid < 0) { | ||||||
|  |         printf("Error forking process\n"); | ||||||
|  |         exit(1); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     sleep(30); | ||||||
|  |  | ||||||
|  |     char* log_directory = "/home/container/SNM2020/Saved/Logs"; | ||||||
|  |     print_latest_log(log_directory); | ||||||
|  |  | ||||||
|  |     while (1) { | ||||||
|  |         sleep(1); | ||||||
|  |         print_latest_log(log_directory); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     kill(pid, SIGTERM); | ||||||
|  |  | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user