Skip to content

Commit

Permalink
Merge pull request #591 from winterheart/ddio-update
Browse files Browse the repository at this point in the history
Update DDIO and related to it's code OSIRIS
  • Loading branch information
Lgt2x authored Sep 23, 2024
2 parents 515b8b5 + 09ab370 commit 0e228aa
Show file tree
Hide file tree
Showing 22 changed files with 312 additions and 658 deletions.
2 changes: 1 addition & 1 deletion AudioEncode/audio_encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// input_channels (default 1)
// input_factor (compression factor) (default 4 for 22K, 8 for 44K)
// input_volscale (Volume scaling) (slightly <= 1.0, default ,97)
bool aenc_Compress(char *input_filename, char *output_filename, const int *input_levels = nullptr,
bool aenc_Compress(const char *input_filename, const char *output_filename, const int *input_levels = nullptr,
const int *input_samples = nullptr, const int *input_rate = nullptr,
const int *input_channels = nullptr, const float *input_factor = nullptr,
const float *input_volscale = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion AudioEncode/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int32_t aenc_ReadSamp(void *data) {
return (b << 8) | a;
}

bool aenc_Compress(char *input_filename, char *output_filename, const int *input_levels, const int *input_samples,
bool aenc_Compress(const char *input_filename, const char *output_filename, const int *input_levels, const int *input_samples,
const int *input_rate, const int *input_channels, const float *input_factor,
const float *input_volscale) {
FILE *in, *out;
Expand Down
6 changes: 3 additions & 3 deletions Descent3/D3ForceFeedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,10 @@ void ForceEffectsInit(void) {
int lowid;
Force_time_since_last_shake = 0;
FORCEPROJECT prj;
char path[_MAX_PATH];
std::filesystem::path path;

if (cfexist("D3Force.ifr")) {
ddio_MakePath(path, Descent3_temp_directory, "D3Force.ifr", NULL);
path = Descent3_temp_directory / "D3Force.ifr";
cf_CopyFile(path, "D3Force.ifr", 0);
prj = ddio_ForceLoadProject(IGNORE_TABLE(path), kJoy1);
} else {
Expand Down Expand Up @@ -708,6 +708,6 @@ void ForceEffectsInit(void) {

ddio_ForceUnloadProject(prj);
if (cfexist(path)) {
ddio_DeleteFile(path);
std::filesystem::remove(path);
}
}
38 changes: 17 additions & 21 deletions Descent3/Game2DLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ DLLGameClose_fp DLLGameClose = NULL;
DLLGetGameInfo_fp DLLGetGameInfo = NULL;
dllinfo DLLInfo;
tOSIRISModuleInit Multi_d3m_osiris_funcs;
char Multi_game_dll_name[_MAX_PATH * 2];
std::filesystem::path Multi_game_dll_name;

static void DUMMYrend_DrawScaledBitmap(int x1, int y1, int x2, int y2, int bm, float u0, float v0, float u1, float v1,
float zval, int color, float *alphas) {
Expand Down Expand Up @@ -551,48 +551,44 @@ void CloseGameModule(module *mod) {
// Clear out error queue
mod_GetLastError();
mod_FreeModule(mod);
if (Multi_game_dll_name[0] != '\0') {
if (Multi_game_dll_name.empty()) {
// Try deleting the file now!
if (!ddio_DeleteFile(Multi_game_dll_name)) {
if (!std::filesystem::remove(Multi_game_dll_name)) {
LOG_WARNING << "Couldn't delete the tmp dll";
}
}
mod->handle = NULL;
}
// this function will load up the DLL, but not get any symbols
bool InitGameModule(const char *name, module *mod) {
char lib_name[_MAX_PATH * 2];
char dll_name[_MAX_PATH * 2];
char tmp_dll_name[_MAX_PATH * 2];
std::filesystem::path lib_name;
std::filesystem::path dll_name;
std::filesystem::path tmp_dll_name;
// Make the hog filename
ddio_MakePath(lib_name, Base_directory, "netgames", name, NULL);
strcat(lib_name, ".d3m");
// Make the dll filename
#if defined(WIN32)
snprintf(dll_name, sizeof(dll_name), "%s.dll", name);
#elif defined(MACOSX)
snprintf(dll_name, sizeof(dll_name), "%s.dylib", name);
#else
snprintf(dll_name, sizeof(dll_name), "%s.so", name);
#endif
lib_name = std::filesystem::path(Base_directory) / "netgames" / name;
lib_name.replace_extension(".d3m");
// Make the dll filename
dll_name = name;
dll_name.replace_extension(MODULE_EXT);

// Open the hog file
if (!cf_OpenLibrary(lib_name)) {
ddio_MakePath(tmp_dll_name, Base_directory, "netgames", name, NULL);
strcat(tmp_dll_name, ".d3m");
Multi_game_dll_name[0] = '\0';
tmp_dll_name = std::filesystem::path(Base_directory) / "netgames" / name;
tmp_dll_name.replace_extension(".d3m");
Multi_game_dll_name.clear();
goto loaddll;
}
// get a temp file name
if (!ddio_GetTempFileName(Descent3_temp_directory, "d3m", tmp_dll_name)) {
tmp_dll_name = ddio_GetTmpFileName(Descent3_temp_directory, "d3m");
if (tmp_dll_name.empty()) {
return false;
}
// Copy the DLL
if (!cf_CopyFile(tmp_dll_name, dll_name)) {
LOG_WARNING << "DLL copy failed!";
return false;
}
strcpy(Multi_game_dll_name, tmp_dll_name);
Multi_game_dll_name = tmp_dll_name;
loaddll:
// Clear out error queue
mod_GetLastError();
Expand Down
Loading

0 comments on commit 0e228aa

Please sign in to comment.