mirror of
https://github.com/GTAmodding/re3.git
synced 2021-02-19 17:49:54 +01:00
Merge pull request #481 from erorcun/erorcun
Crossplatform work continues
This commit is contained in:
commit
9660594634
@ -1,4 +1,3 @@
|
||||
#define WITHWINDOWS // just for VK_SPACE
|
||||
#include "common.h"
|
||||
|
||||
#include "General.h"
|
||||
@ -416,7 +415,7 @@ CCutsceneMgr::Update(void)
|
||||
|| (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
|
||||
|| CPad::GetPad(0)->GetLeftMouseJustDown()
|
||||
|| CPad::GetPad(0)->GetEnterJustDown()
|
||||
|| CPad::GetPad(0)->GetCharJustDown(VK_SPACE))
|
||||
|| CPad::GetPad(0)->GetCharJustDown(' '))
|
||||
FinishCutscene();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "sampman.h"
|
||||
#include "AudioManager.h"
|
||||
#include "MusicManager.h"
|
||||
#include "Frontend.h"
|
||||
#include "Timer.h"
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#define WITHWINDOWS // for our script loading hack
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#include "Script.h"
|
||||
#include "ScriptCommands.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <windows.h>
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
|
||||
#include "CdStream.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4005)
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#pragma warning( pop )
|
||||
#include "common.h"
|
||||
#include "win.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <windows.h>
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
|
||||
#include "DMAudio.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <direct.h>
|
||||
#include <csignal>
|
||||
#include <windows.h>
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
#include "patcher.h"
|
||||
#include "Renderer.h"
|
||||
|
@ -1,9 +1,6 @@
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4005)
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#pragma warning( pop )
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
#include "win.h"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
#define USEALTERNATIVEWINFUNCS
|
||||
#include "crossplatform.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "AudioScriptObject.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#define WITHWINDOWS
|
||||
#include "common.h"
|
||||
#define USEALTERNATIVEWINFUNCS
|
||||
#include "crossplatform.h"
|
||||
|
||||
#include "FileMgr.h"
|
||||
#include "GenericGameStorage.h"
|
||||
@ -94,7 +95,7 @@ C_PcSave::PopulateSlotInfo()
|
||||
struct {
|
||||
int size;
|
||||
wchar FileName[24];
|
||||
_SYSTEMTIME SaveDateTime;
|
||||
SYSTEMTIME SaveDateTime;
|
||||
} header;
|
||||
sprintf(savename, "%s%i%s", DefaultPCSaveFileName, i + 1, ".b");
|
||||
int file = CFileMgr::OpenFile(savename, "rb");
|
||||
@ -110,8 +111,8 @@ C_PcSave::PopulateSlotInfo()
|
||||
}
|
||||
if (Slots[i + 1] == SLOT_OK) {
|
||||
if (CheckDataNotCorrupt(i, savename)) {
|
||||
_SYSTEMTIME st;
|
||||
memcpy(&st, &header.SaveDateTime, sizeof(_SYSTEMTIME));
|
||||
SYSTEMTIME st;
|
||||
memcpy(&st, &header.SaveDateTime, sizeof(SYSTEMTIME));
|
||||
const char *month;
|
||||
switch (st.wMonth)
|
||||
{
|
||||
|
81
src/skel/crossplatform.cpp
Normal file
81
src/skel/crossplatform.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include "common.h"
|
||||
#define USEALTERNATIVEWINFUNCS
|
||||
#include "crossplatform.h"
|
||||
|
||||
// For internal use
|
||||
// wMilliseconds is not needed
|
||||
void tmToSystemTime(const tm *tm, SYSTEMTIME *out) {
|
||||
out->wYear = tm->tm_year + 1900;
|
||||
out->wMonth = tm->tm_mon + 1;
|
||||
out->wDayOfWeek = tm->tm_wday;
|
||||
out->wDay = tm->tm_mday;
|
||||
out->wHour = tm->tm_hour;
|
||||
out->wMinute = tm->tm_min;
|
||||
out->wSecond = tm->tm_sec;
|
||||
}
|
||||
|
||||
void GetLocalTime_CP(SYSTEMTIME *out) {
|
||||
time_t timestamp = time(nil);
|
||||
tm *localTm = localtime(×tamp);
|
||||
tmToSystemTime(localTm, out);
|
||||
}
|
||||
|
||||
#if !defined _WIN32 || defined __MINGW32__
|
||||
HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
|
||||
char newpathname[32];
|
||||
strncpy(newpathname, pathname, 32);
|
||||
char* path = strtok(newpathname, "\\*");
|
||||
strncpy(firstfile->folder, path, sizeof(firstfile->folder));
|
||||
|
||||
// Both w/ extension and w/o extension is ok
|
||||
if (strlen(path) + 2 != strlen(pathname))
|
||||
strncpy(firstfile->extension, strtok(NULL, "\\*"), sizeof(firstfile->extension));
|
||||
else
|
||||
strncpy(firstfile->extension, "", sizeof(firstfile->extension));
|
||||
|
||||
HANDLE d;
|
||||
if ((d = opendir(path)) == NULL || !FindNextFile(d, firstfile))
|
||||
return NULL;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
bool FindNextFile(HANDLE d, WIN32_FIND_DATA* finddata) {
|
||||
dirent *file;
|
||||
static struct stat fileStats;
|
||||
static char path[PATH_MAX], relativepath[NAME_MAX + sizeof(finddata->folder) + 1];
|
||||
int extensionLen = strlen(finddata->extension);
|
||||
while ((file = readdir(d)) != NULL) {
|
||||
|
||||
// We only want "DT_REG"ular Files, but reportedly some FS and OSes gives DT_UNKNOWN as type.
|
||||
if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG) &&
|
||||
(extensionLen == 0 || strncmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) {
|
||||
|
||||
sprintf(relativepath, "%s/%s", finddata->folder, file->d_name);
|
||||
realpath(relativepath, path);
|
||||
stat(path, &fileStats);
|
||||
strncpy(finddata->cFileName, file->d_name, sizeof(finddata->cFileName));
|
||||
finddata->ftLastWriteTime = fileStats.st_mtime;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetDateFormat(int unused1, int unused2, SYSTEMTIME* in, int unused3, char* out, int size) {
|
||||
tm linuxTime;
|
||||
linuxTime.tm_year = in->wYear - 1900;
|
||||
linuxTime.tm_mon = in->wMonth - 1;
|
||||
linuxTime.tm_wday = in->wDayOfWeek;
|
||||
linuxTime.tm_mday = in->wDay;
|
||||
linuxTime.tm_hour = in->wHour;
|
||||
linuxTime.tm_min = in->wMinute;
|
||||
linuxTime.tm_sec = in->wSecond;
|
||||
strftime(out, size, nl_langinfo(D_FMT), &linuxTime);
|
||||
}
|
||||
|
||||
void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) {
|
||||
tm *ptm = gmtime(writeTime);
|
||||
tmToSystemTime(ptm, out);
|
||||
}
|
||||
#endif
|
65
src/skel/crossplatform.h
Normal file
65
src/skel/crossplatform.h
Normal file
@ -0,0 +1,65 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#if !defined _WIN32 || defined __MINGW32__
|
||||
#define MAX_PATH PATH_MAX
|
||||
#else
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Mostly wrappers around Windows functions
|
||||
|
||||
// TODO: Remove USEALTERNATIVEWINFUNCS and don't use it anywhere when re3 becomes fully cross-platform, this is for testing
|
||||
// Codes compatible with Windows and Linux
|
||||
#if defined USEALTERNATIVEWINFUNCS || !defined _WIN32 || defined __MINGW32__
|
||||
#define DeleteFile unlink
|
||||
|
||||
// Needed for save games
|
||||
struct SYSTEMTIME {
|
||||
uint16 wYear;
|
||||
uint16 wMonth;
|
||||
uint16 wDayOfWeek;
|
||||
uint16 wDay;
|
||||
uint16 wHour;
|
||||
uint16 wMinute;
|
||||
uint16 wSecond;
|
||||
uint16 wMilliseconds;
|
||||
};
|
||||
|
||||
#define GetLocalTime GetLocalTime_CP
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
void GetLocalTime_CP(SYSTEMTIME* out);
|
||||
|
||||
|
||||
// Only runs on GNU/POSIX/etc.
|
||||
#if !defined _WIN32 || defined __MINGW32__
|
||||
#define OutputDebugString(s) re3_debug("[DBG-2]: " s "\n")
|
||||
|
||||
#include <iostream>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <langinfo.h>
|
||||
|
||||
typedef DIR* HANDLE;
|
||||
#define INVALID_HANDLE_VALUE NULL
|
||||
#define FindClose closedir
|
||||
#define LOCALE_USER_DEFAULT 0
|
||||
#define DATE_SHORTDATE 0
|
||||
|
||||
struct WIN32_FIND_DATA {
|
||||
char extension[32]; // for searching
|
||||
char folder[32]; // for searching
|
||||
char cFileName[256]; // because tSkinInfo has it 256
|
||||
time_t ftLastWriteTime;
|
||||
};
|
||||
|
||||
HANDLE FindFirstFile(char*, WIN32_FIND_DATA*);
|
||||
bool FindNextFile(HANDLE, WIN32_FIND_DATA*);
|
||||
void FileTimeToSystemTime(time_t*, SYSTEMTIME*);
|
||||
void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int);
|
||||
#endif
|
@ -2,18 +2,12 @@
|
||||
#include "skeleton.h"
|
||||
#include "events.h"
|
||||
|
||||
//#include "main.h"
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include "common.h"
|
||||
#include "Pad.h"
|
||||
#include "ControllerConfig.h"
|
||||
#include "Frontend.h"
|
||||
#include "Camera.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
@ -1986,7 +1986,7 @@ WinMain(HINSTANCE instance,
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
|
||||
else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
||||
++gGameState;
|
||||
@ -2022,7 +2022,7 @@ WinMain(HINSTANCE instance,
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
|
||||
else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
|
||||
++gGameState;
|
||||
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
||||
++gGameState;
|
||||
|
@ -5,6 +5,11 @@
|
||||
#define RSREGSETBREAKALLOC(_name) /* No op */
|
||||
#endif /* (!defined(RSREGSETBREAKALLOC)) */
|
||||
|
||||
#ifndef _INC_WINDOWS
|
||||
#define _X86_
|
||||
#include <windef.h>
|
||||
#endif
|
||||
|
||||
enum eGameState
|
||||
{
|
||||
GS_START_UP = 0,
|
||||
@ -17,7 +22,9 @@ enum eGameState
|
||||
GS_FRONTEND,
|
||||
GS_INIT_PLAYING_GAME,
|
||||
GS_PLAYING_GAME,
|
||||
#ifndef MASTER
|
||||
GS_ANIMVIEWER,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum eWinVersion
|
||||
@ -33,6 +40,7 @@ extern DWORD _dwOperatingSystemVersion;
|
||||
|
||||
extern RwUInt32 gGameState;
|
||||
|
||||
#ifdef __DINPUT_INCLUDED__
|
||||
/* platform specfic global data */
|
||||
typedef struct
|
||||
{
|
||||
@ -86,6 +94,7 @@ public:
|
||||
};
|
||||
|
||||
extern CJoySticks AllValidWinJoys;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -97,6 +106,7 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
RwBool IsForegroundApp();
|
||||
|
||||
#ifdef __DINPUT_INCLUDED__
|
||||
HRESULT _InputInitialise();
|
||||
HRESULT _InputInitialiseMouse();
|
||||
HRESULT CapturePad(RwInt32 padID);
|
||||
@ -110,6 +120,7 @@ BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key);
|
||||
void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);;
|
||||
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);
|
||||
BOOL _InputIsExtended(INT flag);
|
||||
#endif
|
||||
|
||||
void InitialiseLanguage();
|
||||
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode);
|
||||
|
Loading…
Reference in New Issue
Block a user