| 182 | } |
| 183 | |
| 184 | int AutoDetect::game_engine(Context *context) |
| 185 | { |
| 186 | context->gameexecutable = context->gamepath; |
| 187 | |
| 188 | /* Get file extension */ |
| 189 | std::filesystem::path ext = context->gamepath.extension(); |
| 190 | |
| 191 | /* Check for .AppImage format and mount image */ |
| 192 | if (ext.compare(".AppImage") == 0) { |
| 193 | const char *command[] = {context->gamepath.c_str(), "--appimage-mount", NULL}; |
| 194 | std::filesystem::path image_path = queryCmdPid(command, &context->appimage_pid); |
| 195 | std::cout << ".AppImage mounted to " << image_path << std::endl; |
| 196 | |
| 197 | /* Replace with new executable */ |
| 198 | context->gameexecutable = image_path / "AppRun"; |
| 199 | } |
| 200 | |
| 201 | /* Check for Unity: |
| 202 | * Old Unity executables end with `.x86` or `.x86_64` or no extention, and |
| 203 | * data directory is named after the executable with added `_Data` */ |
| 204 | |
| 205 | std::filesystem::path data = context->gameexecutable.parent_path() / context->gameexecutable.stem(); |
| 206 | data += "_Data"; |
| 207 | |
| 208 | if (std::filesystem::is_directory(data)) { |
| 209 | std::cout << "Unity game detected" << std::endl; |
| 210 | |
| 211 | std::filesystem::path data_unity = data / "Resources" / "unity_builtin_extra"; |
| 212 | if (!std::filesystem::exists(data_unity)) { |
| 213 | data_unity = data / "Resources" / "unity default resources"; |
| 214 | } |
| 215 | std::ostringstream oss; |
| 216 | oss << "strings " << data_unity << " | head -n 1"; |
| 217 | |
| 218 | std::string version = queryCmd(oss.str()); |
| 219 | if (!version.empty()) |
| 220 | std::cout << " Version " << version << std::endl; |
| 221 | else |
| 222 | std::cout << " Could not detect version " << std::endl; |
| 223 | |
| 224 | /* Check for -force-gfx-direct command-line option */ |
| 225 | if (context->config.gameargs.find("-force-gfx-direct") == std::string::npos) { |
| 226 | std::cout << " Adding -force-gfx-direct command-line option" << std::endl; |
| 227 | context->config.gameargs += " -force-gfx-direct"; |
| 228 | } |
| 229 | |
| 230 | return ENGINE_UNITY; |
| 231 | } |
| 232 | |
| 233 | /* Check for GM:S: |
| 234 | * Games have an asset folder which contains the `game.unx` file */ |
| 235 | std::filesystem::path assets = context->gameexecutable.parent_path() / "assets"; |
| 236 | if (std::filesystem::is_directory(assets)) { |
| 237 | std::filesystem::path gameunx = assets / "game.unx"; |
| 238 | if (std::filesystem::exists(gameunx)) { |
| 239 | std::cout << "GameMaker Studio game detected" << std::endl; |
| 240 | |
| 241 | /* Check time-tracking clockgettime monotonic */ |
nothing calls this directly
no test coverage detected