I/O systems initialization */
| 1397 | I/O systems initialization |
| 1398 | */ |
| 1399 | void InitIOSystems(bool editor) { |
| 1400 | ddio_init_info io_info; |
| 1401 | |
| 1402 | // Set the base directory |
| 1403 | int dirarg = FindArg("-setdir"); |
| 1404 | int exedirarg = FindArg("-useexedir"); |
| 1405 | if (dirarg) { |
| 1406 | strncpy(Base_directory, GameArgs[dirarg + 1], sizeof(Base_directory) - 1); |
| 1407 | Base_directory[sizeof(Base_directory) - 1] = '\0'; |
| 1408 | } else if (exedirarg) { |
| 1409 | char exec_path[_MAX_PATH]; |
| 1410 | memset(exec_path, 0, sizeof(exec_path)); |
| 1411 | // Populate exec_path with the executable path |
| 1412 | if (!ddio_GetBinaryPath(exec_path, sizeof(exec_path))) { |
| 1413 | Error("Failed to get executable path\n"); |
| 1414 | } else { |
| 1415 | std::filesystem::path executablePath(exec_path); |
| 1416 | std::string baseDirectoryString = executablePath.parent_path().string(); |
| 1417 | strncpy(Base_directory, baseDirectoryString.c_str(), sizeof(Base_directory) - 1); |
| 1418 | Base_directory[sizeof(Base_directory) - 1] = '\0'; |
| 1419 | mprintf(0, "Using working directory of %s\n", Base_directory); |
| 1420 | } |
| 1421 | } else { |
| 1422 | ddio_GetWorkingDir(Base_directory, sizeof(Base_directory)); |
| 1423 | } |
| 1424 | |
| 1425 | ddio_SetWorkingDir(Base_directory); |
| 1426 | |
| 1427 | Descent->set_defer_handler(D3DeferHandler); |
| 1428 | |
| 1429 | #ifndef RELEASE |
| 1430 | if (!editor && !FindArg("-windowed")) { |
| 1431 | if (Dedicated_server) { |
| 1432 | ddio_MouseMode(MOUSE_STANDARD_MODE); |
| 1433 | } else { |
| 1434 | ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); |
| 1435 | } |
| 1436 | } |
| 1437 | #else |
| 1438 | ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); |
| 1439 | #endif |
| 1440 | |
| 1441 | // do io init stuff |
| 1442 | io_info.obj = Descent; |
| 1443 | io_info.joy_emulation = (bool)((FindArg("-alternatejoy") == 0) && (FindArg("-directinput") == 0)); |
| 1444 | io_info.key_emulation = true; //(bool)(FindArg("-slowkey")!=0); WIN95: DirectInput is flaky for some keys. |
| 1445 | INIT_MESSAGE(("Initializing DDIO systems.")); |
| 1446 | if (!ddio_Init(&io_info)) { |
| 1447 | Error("I/O initialization failed."); |
| 1448 | } |
| 1449 | |
| 1450 | rtp_Init(); |
| 1451 | RTP_ENABLEFLAGS(RTI_FRAMETIME | RTI_RENDERFRAMETIME | RTI_MULTIFRAMETIME | RTI_MUSICFRAMETIME | |
| 1452 | RTI_AMBSOUNDFRAMETIME); |
| 1453 | RTP_ENABLEFLAGS(RTI_WEATHERFRAMETIME | RTI_PLAYERFRAMETIME | RTI_DOORFRAMETIME | RTI_LEVELGOALTIME | |
| 1454 | RTI_MATCENFRAMETIME); |
| 1455 | RTP_ENABLEFLAGS(RTI_OBJFRAMETIME | RTI_AIFRAMETIME | RTI_PROCESSKEYTIME); |
| 1456 |
no test coverage detected