Merge branch 'Rosalie241-fix-linux' into develop-SoapyMan

This commit is contained in:
Ilya Shurumov 2020-11-20 21:16:13 +06:00
commit dd9725e35c
18 changed files with 73 additions and 42 deletions

View File

@ -25,6 +25,7 @@
#include "SKY.H"
#include "DEBRIS.H"
#include <stdint.h>
#include <math.h>
#include "FELONY.H"

View File

@ -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"
@ -18,7 +17,6 @@
#ifndef PSX
#include <stdlib.h>
#include <PLATFORM.H>
// [A]

View File

@ -29,6 +29,7 @@
#include <string.h>
#ifndef PSX
#include <stdint.h>
#include <SDL.h>
#endif // PSX

View File

@ -8,6 +8,7 @@
#include "CARS.H"
#include "CAMERA.H"
#include <stdint.h>
#include "SDL.h"
ushort distanceCache[16384];

View File

@ -1,6 +1,7 @@
#include "DRIVER2.H"
#ifndef PSX
#include <stdint.h>
#include <SDL.h>
#endif // !PSX

View File

@ -1,12 +1,14 @@
#include "DRIVER2.H"
#ifndef PSX
#include <stdint.h>
#include <SDL.h>
#endif // !PSX
#include "LIBETC.H"
#include "SYSTEM.H"
#include "PLATFORM.H"
#include "XAPLAY.H"
#include "LOADVIEW.H"
#include "MISSION.H"
@ -14,7 +16,8 @@
#include "MAIN.H"
#include "PAD.H"
#include "DRAW.H"
#include <string.h>
#include "STRINGS.H"
#include "PLATFORM.H"
// Initialized in redriver2_main
char* _overlay_buffer = NULL; // 0x1C0000
@ -375,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)
@ -460,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)
@ -791,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");
@ -1376,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");
@ -1387,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;
}
@ -1506,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)

View File

@ -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");

View File

@ -4729,8 +4729,8 @@ int GameNameScreen(int bSetup)
else
offset = (GameType - 4U) * 8;
strcpy_s(pCurrScreen->buttons[0].Name, GAMEMODE_AREA_NAME(GameLevel, offset, 0));
strcpy_s(pCurrScreen->buttons[1].Name, GAMEMODE_AREA_NAME(GameLevel, offset, 1));
strcpy(pCurrScreen->buttons[0].Name, GAMEMODE_AREA_NAME(GameLevel, offset, 0));
strcpy(pCurrScreen->buttons[1].Name, GAMEMODE_AREA_NAME(GameLevel, offset, 1));
}
return 0;

View File

@ -2,18 +2,34 @@
#define PLATFORM_H
#ifdef _WIN32
#include <direct.h>
#define HOME_ENV "USERPROFILE"
#elif defined (__unix__)
#include <sys/stat.h>
#define HOME_ENV "HOME"
#define _mkdir(str) mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
inline void fixslashes(char* pathbuff)
#include <direct.h>
#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 <sys/stat.h>
#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++;
}
}

View File

@ -1,4 +1,8 @@
#ifdef _WIN32
#include <windows.h>
#else
#include <stddef.h>
#endif // _WIN32
#include "EMULATOR_TIMER.H"
void Emulator_InitHPCTimer(timerCtx_t* timer)
@ -6,7 +10,7 @@ void Emulator_InitHPCTimer(timerCtx_t* timer)
#ifdef _WIN32
QueryPerformanceFrequency(&timer->performanceFrequency);
#else
gettimeofday(&timer.timeStart, NULL);
gettimeofday(&timer->timeStart, NULL);
#endif // _WIN32
}
@ -27,7 +31,7 @@ double Emulator_GetHPCTime(timerCtx_t* timer, int reset)
gettimeofday(&curr, NULL);
double value = (float(curr.tv_sec - timer->timeStart.tv_sec) + 0.000001f * float(curr.tv_usec - timer.timeStart->tv_usec));
double value = (float(curr.tv_sec - timer->timeStart.tv_sec) + 0.000001f * float(curr.tv_usec - timer->timeStart.tv_usec));
if (reset)
timer->timeStart = curr;

View File

@ -1,6 +1,7 @@
#ifndef RAND_H
#define RAND_H
#include <stdint.h>
#include <stdlib.h>
#endif

View File

@ -1,6 +1,9 @@
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#include <stdint.h>
#include <stddef.h>
#if !defined(__APPLE__)
/* major part of a device */
#define major(x) ((int)(((unsigned)(x)>>8)&0377))

View File

@ -53,6 +53,7 @@
#define GLAPIENTRY APIENTRY
#endif
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {

View File

@ -131,6 +131,7 @@ project "REDRIVER2"
"GL",
"openal",
"SDL2",
"dl",
}
linkoptions {

View File

@ -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 <stdlib.h>
#include <SDL_scancode.h>
#include "C/CUTSCENE.H"

View File

@ -1,6 +1,7 @@
#include "snd_wav_source.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
//---------------------------------------------------------------------

View File

@ -10,6 +10,10 @@
#define INI_VERSION "0.1.1"
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
typedef struct ini_t ini_t;
ini_t* ini_load(const char *filename);
@ -17,4 +21,8 @@ void ini_free(ini_t *ini);
const char* ini_get(ini_t *ini, const char *section, const char *key);
int ini_sget(ini_t *ini, const char *section, const char *key, const char *scanfmt, void *dst);
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif

View File

@ -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();