From 3a3e0dd66438e83c79847793b0b52ed4295272d4 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Thu, 19 Nov 2020 21:48:39 +0600 Subject: [PATCH] - remove __unix__ and make fixslashes always here --- src_rebuild/GAME/C/LOADSAVE.C | 3 -- src_rebuild/GAME/C/SYSTEM.C | 32 ++++++------------- src_rebuild/GAME/C/XAPLAY.C | 4 +++ src_rebuild/GAME/PLATFORM.H | 32 ++++++++++++++----- src_rebuild/PsyX/TYPES.H | 3 ++ src_rebuild/redriver2_psxpc.cpp | 3 -- .../utils/video_source/VideoPlayer.cpp | 9 ++++-- 7 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src_rebuild/GAME/C/LOADSAVE.C b/src_rebuild/GAME/C/LOADSAVE.C index ecb22079..4baf2315 100644 --- a/src_rebuild/GAME/C/LOADSAVE.C +++ b/src_rebuild/GAME/C/LOADSAVE.C @@ -8,7 +8,6 @@ #include "SOUND.H" #include "PAD.H" #include "MISSION.H" -#include "COP_AI.H" #include "SCORES.H" #include "LIBGPU.H" #include "LIBETC.H" @@ -17,9 +16,7 @@ #include "PAUSE.H" #ifndef PSX -#include #include - #include // [A] diff --git a/src_rebuild/GAME/C/SYSTEM.C b/src_rebuild/GAME/C/SYSTEM.C index cbd4038b..b3ab49d8 100644 --- a/src_rebuild/GAME/C/SYSTEM.C +++ b/src_rebuild/GAME/C/SYSTEM.C @@ -16,7 +16,8 @@ #include "MAIN.H" #include "PAD.H" #include "DRAW.H" -#include +#include "STRINGS.H" +#include "PLATFORM.H" // Initialized in redriver2_main char* _overlay_buffer = NULL; // 0x1C0000 @@ -377,10 +378,7 @@ int Loadfile(char* name, char* addr) int fileSize; sprintf(namebuffer, "%s%s", gDataFolder, name); - -#ifdef __unix__ - fixslashes(namebuffer); -#endif + FixPathSlashes(namebuffer); FILE* fptr = fopen(namebuffer, "rb"); if (!fptr) @@ -462,13 +460,10 @@ int LoadfileSeg(char* name, char* addr, int offset, int loadsize) { char namebuffer[64]; #ifndef PSX - int fileSize = 0; + int fileSize; sprintf(namebuffer, "%s%s", gDataFolder, name); - -#ifdef __unix__ - fixslashes(namebuffer); -#endif + FixPathSlashes(namebuffer); FILE* fptr = fopen(namebuffer, "rb"); if (!fptr) @@ -793,13 +788,9 @@ void loadsectors(char* addr, int sector, int nsectors) // It has to be this way void loadsectorsPC(char* filename, char* addr, int sector, int nsectors) { -#ifdef __unix__ char namebuffer[64]; strcpy(namebuffer, filename); - fixslashes(namebuffer); -#else - char* namebuffer = filename; -#endif + FixPathSlashes(namebuffer); FILE* fp = fopen(namebuffer, "rb"); @@ -1378,10 +1369,7 @@ void SetCityType(CITYTYPE type) } sprintf(filename, format, gDataFolder, LevelFiles[GameLevel]); - -#ifdef __unix__ - fixslashes(filename); -#endif + FixPathSlashes(filename); FILE* levFp = fopen(filename, "rb"); @@ -1389,6 +1377,7 @@ void SetCityType(CITYTYPE type) { char errPrint[1024]; sprintf(errPrint, "SetCityType: cannot open level '%s'\n", filename); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "ERROR", errPrint, NULL); return; } @@ -1508,10 +1497,7 @@ int FileExists(char* filename) char namebuffer[128]; sprintf(namebuffer, "%s%s", gDataFolder, filename); - -#ifdef __unix__ - fixslashes(namebuffer); -#endif + FixPathSlashes(namebuffer); FILE* fp = fopen(namebuffer, "rb"); if (fp) diff --git a/src_rebuild/GAME/C/XAPLAY.C b/src_rebuild/GAME/C/XAPLAY.C index eb05029d..c6499e60 100644 --- a/src_rebuild/GAME/C/XAPLAY.C +++ b/src_rebuild/GAME/C/XAPLAY.C @@ -5,6 +5,7 @@ #include "CAMERA.H" #include "FMVPLAY.H" #include "PAUSE.H" +#include "PLATFORM.H" #include "SOUND.H" #include "PRES.H" #include "SYSTEM.H" @@ -353,6 +354,7 @@ void PlayXA(int num, int index) { char fileName[250]; sprintf(fileName, XANameFormat, gDataFolder, num+1, index); + fixslashes(fileName); g_wavData = new CSoundSource_WaveCache(); @@ -362,6 +364,7 @@ void PlayXA(int num, int index) // Save subtitles file { sprintf(fileName, "%sXA\\XABNK0%d.XA[%d].SBN", gDataFolder, num + 1, index); + fixslashes(fileName); FILE* fp = fopen(fileName, "wb"); @@ -389,6 +392,7 @@ void PlayXA(int num, int index) #else // Load subtitles for XA sprintf(fileName, "%sXA\\XABNK0%d.XA[%d].SBN", gDataFolder, num + 1, index); + fixslashes(fileName); FILE* fp = fopen(fileName, "rb"); diff --git a/src_rebuild/GAME/PLATFORM.H b/src_rebuild/GAME/PLATFORM.H index 46e445c7..e4f88b3f 100644 --- a/src_rebuild/GAME/PLATFORM.H +++ b/src_rebuild/GAME/PLATFORM.H @@ -2,18 +2,34 @@ #define PLATFORM_H #ifdef _WIN32 -#include -#define HOME_ENV "USERPROFILE" -#elif defined (__unix__) -#include -#define HOME_ENV "HOME" -#define _mkdir(str) mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) -inline void fixslashes(char* pathbuff) +#include + +#define HOME_ENV "USERPROFILE" + +inline void FixPathSlashes(char* pathbuff) { while (*pathbuff) { - if (*pathbuff == '\\') *pathbuff = '/'; + if (*pathbuff == '/') // make windows-style path + *pathbuff = '\\'; + pathbuff++; + } +} + +#elif defined (__unix__) + +#include + +#define HOME_ENV "HOME" +#define _mkdir(str) mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) + +inline void FixPathSlashes(char* pathbuff) +{ + while (*pathbuff) + { + if (*pathbuff == '\\') // make unix-style path + *pathbuff = '/'; pathbuff++; } } diff --git a/src_rebuild/PsyX/TYPES.H b/src_rebuild/PsyX/TYPES.H index 2c9dd14d..45440a81 100644 --- a/src_rebuild/PsyX/TYPES.H +++ b/src_rebuild/PsyX/TYPES.H @@ -1,6 +1,9 @@ #ifndef _SYS_TYPES_H #define _SYS_TYPES_H +#include +#include + #if !defined(__APPLE__) /* major part of a device */ #define major(x) ((int)(((unsigned)(x)>>8)&0377)) diff --git a/src_rebuild/redriver2_psxpc.cpp b/src_rebuild/redriver2_psxpc.cpp index d5c3bf3b..7faa12b5 100644 --- a/src_rebuild/redriver2_psxpc.cpp +++ b/src_rebuild/redriver2_psxpc.cpp @@ -4,15 +4,12 @@ #include "DRIVER2.H" #include "C/MAIN.H" #include "C/SYSTEM.H" -#include "C/GLAUNCH.H" -#include "C/PLAYERS.H" #include "C/GAMESND.H" #include "EMULATOR.H" #include "EMULATOR_PRIVATE.H" #include "utils/ini.h" -#include #include #include "C/CUTSCENE.H" diff --git a/src_rebuild/utils/video_source/VideoPlayer.cpp b/src_rebuild/utils/video_source/VideoPlayer.cpp index e8e2d976..59e9e1ed 100644 --- a/src_rebuild/utils/video_source/VideoPlayer.cpp +++ b/src_rebuild/utils/video_source/VideoPlayer.cpp @@ -464,6 +464,7 @@ void DoPlayFMV(RENDER_ARG* arg, int subtitles) char filename[250]; sprintf(filename, "%sFMV\\%d\\RENDER%d.STR[0].AVI", gDataFolder, fd, arg->render); + FixPathSlashes(filename); ReadAVI readAVI(filename); @@ -471,6 +472,8 @@ void DoPlayFMV(RENDER_ARG* arg, int subtitles) if (subtitles) { sprintf(filename, "%sFMV\\%d\\RENDER%d.SBN", gDataFolder, fd, arg->render); + FixPathSlashes(filename); + InitSubtitles(filename); } else @@ -481,6 +484,8 @@ void DoPlayFMV(RENDER_ARG* arg, int subtitles) if(arg->credits) { sprintf(filename, "%sDATA\\CREDITS.ENG", gDataFolder); + FixPathSlashes(filename); + InitCredits(filename); } @@ -489,7 +494,8 @@ void DoPlayFMV(RENDER_ARG* arg, int subtitles) ReadAVI::stream_format_t stream_format = readAVI.GetVideoFormat(); ReadAVI::stream_format_auds_t audio_format = readAVI.GetAudioFormat(); - if (strcmp(stream_format.compression_type, "MJPG")) { + if (strcmp(stream_format.compression_type, "MJPG")) + { printf("Only MJPG supported\n"); return; } @@ -639,7 +645,6 @@ int FMV_main(RENDER_ARGS* args) DRAWENV draw; FMVPlayerInitGL(); - //LoadFont(NULL); InitFMVFont();