Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge pull request #533 from erorcun/master
Linux build support
  • Loading branch information
erorcun committed May 11, 2020
2 parents 70a8234 + c4a1545 commit 5f40f06bf024e3806e0fe5a92ca14ee6b22a9933
Showing with 1,391 additions and 370 deletions.
  1. +6 −1 eax/eax.h
  2. +49 −27 premake5.lua
  3. BIN premake5Linux
  4. +4 −0 src/animation/AnimBlendAssocGroup.cpp
  5. +1 −1 src/animation/CutsceneMgr.cpp
  6. +1 −0 src/audio/DMAudio.cpp
  7. +8 −2 src/audio/oal/aldlist.cpp
  8. +5 −1 src/audio/oal/channel.cpp
  9. +22 −5 src/audio/oal/stream.cpp
  10. +13 −9 src/audio/sampman_oal.cpp
  11. +1 −1 src/control/CarCtrl.cpp
  12. +4 −4 src/control/Phones.cpp
  13. +6 −6 src/control/Pickups.cpp
  14. +124 −79 src/control/Script.cpp
  15. +7 −3 src/core/CdStream.cpp
  16. +5 −1 src/core/CdStream.h
  17. +516 −0 src/core/CdStreamPosix.cpp
  18. +15 −14 src/core/ControllerConfig.cpp
  19. +55 −4 src/core/FileMgr.cpp
  20. +4 −4 src/core/Fire.cpp
  21. +28 −13 src/core/Frontend.cpp
  22. +0 −1 src/core/Frontend.h
  23. +1 −1 src/core/Game.cpp
  24. +4 −4 src/core/Streaming.cpp
  25. +24 −7 src/core/Timer.cpp
  26. +3 −2 src/core/ZoneCull.cpp
  27. +6 −6 src/core/Zones.cpp
  28. +7 −4 src/core/config.h
  29. +3 −0 src/core/main.cpp
  30. +18 −2 src/core/patcher.cpp
  31. +44 −7 src/core/re3.cpp
  32. +2 −1 src/extras/debugmenu.cpp
  33. +19 −0 src/fakerw/fake.cpp
  34. +3 −3 src/modelinfo/VehicleModelInfo.cpp
  35. +5 −5 src/peds/Ped.cpp
  36. +1 −1 src/peds/PlayerPed.cpp
  37. +1 −1 src/render/Console.cpp
  38. +4 −8 src/render/ParticleMgr.h
  39. +1 −1 src/render/PlayerSkin.cpp
  40. +3 −3 src/render/Shadows.cpp
  41. +3 −9 src/render/Shadows.h
  42. +20 −20 src/rw/RwHelper.cpp
  43. +1 −0 src/rw/TexRead.cpp
  44. +4 −4 src/rw/VisibilityPlugins.cpp
  45. +1 −1 src/save/GenericGameStorage.cpp
  46. +1 −1 src/save/PCSave.cpp
  47. +125 −5 src/skel/crossplatform.cpp
  48. +49 −32 src/skel/crossplatform.h
  49. +125 −50 src/skel/glfw/glfw.cpp
  50. +17 −1 src/skel/platform.h
  51. +5 −1 src/skel/skeleton.cpp
  52. +5 −1 src/skel/skeleton.h
  53. +8 −8 src/skel/win/win.cpp
  54. +0 −1 src/skel/win/win.h
  55. +4 −4 src/vehicles/Cranes.cpp
@@ -50,8 +50,13 @@ extern "C" {


#else // OPENAL
#ifndef _WIN32
#include <AL/al.h>
#include <string.h>
#else
#include <al.h>

#endif

#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID
@@ -29,13 +29,19 @@ workspace "re3"
location "build"
symbols "Full"
staticruntime "off"

filter { "system:windows" }
platforms {
"win-x86-RW33_d3d8-mss",
"win-x86-librw_d3d9-mss",
"win-x86-librw_gl3_glfw-mss",
}

filter { "system:linux" }
platforms {
"linux-x86-librw_gl3_glfw-oal",
}

filter "configurations:Debug"
defines { "DEBUG" }

@@ -45,6 +51,9 @@ workspace "re3"

filter { "platforms:win*" }
system "windows"

filter { "platforms:linux*" }
system "linux"

filter { "platforms:*x86*" }
architecture "x86"
@@ -57,33 +66,32 @@ workspace "re3"

filter "platforms:*librw_gl3_glfw*"
defines { "RW_GL3" }
includedirs { path.join(_OPTIONS["glfwdir"], "include") }
includedirs { path.join(_OPTIONS["glewdir"], "include") }

filter "platforms:win*librw_gl3_glfw*"
defines { "GLEW_STATIC" }
if(not _OPTIONS["with-librw"]) then
libdirs { path.join(Librw, "lib/win-x86-gl3/%{cfg.buildcfg}") }
end
defines { "GLEW_STATIC" }
includedirs { path.join(_OPTIONS["glfwdir"], "include") }
includedirs { path.join(_OPTIONS["glewdir"], "include") }

filter "platforms:linux*librw_gl3_glfw*"
if(not _OPTIONS["with-librw"]) then
libdirs { path.join(Librw, "lib/linux-x86-gl3/%{cfg.buildcfg}") }
end

filter {}

pbcommands = {
"setlocal EnableDelayedExpansion",
"set file=$(TargetPath)",
"FOR %%i IN (\"%file%\") DO (",
"set filename=%%~ni",
"set fileextension=%%~xi",
"set target=!path!!filename!!fileextension!",
"copy /y \"!file!\" \"!target!\"",
")" }


function setpaths (gamepath, exepath, scriptspath)
scriptspath = scriptspath or ""
if (gamepath) then
cmdcopy = { "set \"path=" .. gamepath .. scriptspath .. "\"" }
table.insert(cmdcopy, pbcommands)
postbuildcommands (cmdcopy)
postbuildcommands {
"{COPY} %{cfg.buildtarget.abspath} " .. gamepath .. scriptspath .. "%{cfg.buildtarget.name}"
}
debugdir (gamepath)
if (exepath) then
debugcommand (gamepath .. exepath)
-- Used VS variable $(TargetFileName) because it doesn't accept premake tokens. Does debugcommand even work outside VS??
debugcommand (gamepath .. "$(TargetFileName)")
dir, file = exepath:match'(.*/)(.*)'
debugdir (gamepath .. (dir or ""))
end
@@ -111,16 +119,12 @@ project "re3"
kind "WindowedApp"
targetname "re3"
targetdir "bin/%{cfg.platform}/%{cfg.buildcfg}"
targetextension ".exe"
characterset ("MBCS")
linkoptions "/SAFESEH:NO"


files { addSrcFiles("src") }
files { addSrcFiles("src/animation") }
files { addSrcFiles("src/audio") }
--files { addSrcFiles("src/audio/miles") }
--files { addSrcFiles("src/audio/openal") }
--files { addSrcFiles("src/audio/oal") }
files { addSrcFiles("src/control") }
files { addSrcFiles("src/core") }
files { addSrcFiles("src/entities") }
@@ -132,7 +136,6 @@ project "re3"
files { addSrcFiles("src/rw") }
files { addSrcFiles("src/save") }
files { addSrcFiles("src/skel") }
files { addSrcFiles("src/skel/win") }
files { addSrcFiles("src/skel/glfw") }
files { addSrcFiles("src/text") }
files { addSrcFiles("src/vehicles") }
@@ -143,6 +146,7 @@ project "re3"
includedirs { "src" }
includedirs { "src/animation" }
includedirs { "src/audio" }
--includedirs { "src/audio/oal" }
includedirs { "src/control" }
includedirs { "src/core" }
includedirs { "src/entities" }
@@ -154,7 +158,6 @@ project "re3"
includedirs { "src/rw" }
includedirs { "src/save/" }
includedirs { "src/skel/" }
includedirs { "src/skel/win" }
includedirs { "src/skel/glfw" }
includedirs { "src/text" }
includedirs { "src/vehicles" }
@@ -167,8 +170,24 @@ project "re3"

libdirs { "milessdk/lib" }

setpaths("$(GTA_III_RE_DIR)/", "$(TargetFileName)", "")
if(os.getenv("GTA_III_RE_DIR")) then
setpaths("$(GTA_III_RE_DIR)/", "%(cfg.buildtarget.name)", "")
end

filter "platforms:win*"
files { addSrcFiles("src/skel/win") }
includedirs { "src/skel/win" }
linkoptions "/SAFESEH:NO"
characterset ("MBCS")
targetextension ".exe"

filter "platforms:linux*"
targetextension ".elf"
defines { "OPENAL" }
links { "openal", "mpg123", "sndfile", "pthread" }
files { addSrcFiles("src/audio/oal") }
includedirs { "src/audio/oal" }

filter "platforms:*RW33*"
staticruntime "on"
includedirs { "rwsdk/include/d3d8" }
@@ -194,7 +213,10 @@ project "re3"
filter "platforms:*d3d9*"
links { "d3d9" }

filter "platforms:*gl3_glfw*"
filter "platforms:win*gl3_glfw*"
libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") }
libdirs { path.join(_OPTIONS["glfwdir"], "lib-" .. string.gsub(_ACTION or '', "vs", "vc")) }
links { "opengl32", "glew32s", "glfw3" }

filter "platforms:linux*gl3_glfw*"
links { "GL", "GLEW", "glfw" }
BIN +1.94 MB premake5Linux
Binary file not shown.
@@ -1,6 +1,10 @@
#include "common.h"

#if defined _WIN32 && !defined __MINGW32__
#include "ctype.h"
#else
#include <cwctype>
#endif

#include "General.h"
#include "RwHelper.h"
@@ -103,7 +103,7 @@ const struct {
{ "MT_PH2", STREAMED_SOUND_CUTSCENE_MARTY_PH2 },
{ "MT_PH3", STREAMED_SOUND_CUTSCENE_MARTY_PH3 },
{ "MT_PH4", STREAMED_SOUND_CUTSCENE_MARTY_PH4 },
{ NULL, NULL }
{ NULL, 0 }
};

int
@@ -6,6 +6,7 @@
#include "AudioScriptObject.h"
#include "sampman.h"
#include "Text.h"
#include "crossplatform.h"

cDMAudio DMAudio;

@@ -23,6 +23,12 @@
*/

#include "aldlist.h"

#ifndef _WIN32
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#endif

#ifdef AUDIO_OAL
/*
* Init call
@@ -67,7 +73,7 @@ ALDeviceList::ALDeviceList()
if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) {
memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO));
ALDeviceInfo.bSelected = true;
ALDeviceInfo.strDeviceName = std::string(actualDeviceName, strlen(actualDeviceName));
ALDeviceInfo.strDeviceName.assign(actualDeviceName, strlen(actualDeviceName));
alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion);
alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion);

@@ -326,4 +332,4 @@ unsigned int ALDeviceList::GetMaxNumSources()

return iSourceCount;
}
#endif
#endif
@@ -4,6 +4,10 @@
#include "common.h"
#include "sampman.h"

#ifndef _WIN32
#include <float.h>
#endif

extern bool IsFXSupported();

CChannel::CChannel()
@@ -207,4 +211,4 @@ void CChannel::UpdateReverb(ALuint slot)
alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter);
}

#endif
#endif
@@ -4,13 +4,15 @@
#include "common.h"
#include "sampman.h"

typedef long ssize_t;

#include <sndfile.h>
#include <mpg123.h>

#ifdef _WIN32
typedef long ssize_t;
#pragma comment( lib, "libsndfile-1.lib" )
#pragma comment( lib, "libmpg123.lib" )
#else
#include "crossplatform.h"
#endif

class CSndFile : public IDecoder
{
@@ -192,7 +194,22 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF
m_nPosBeforeReset(0)

{
strcpy(m_aFilename, filename);
// Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/)
#if !defined(_WIN32)
FILE *test = fopen(filename, "r");
if (!test) {
char *r = (char*)alloca(strlen(filename) + 2);
if (casepath(filename, r))
{
strcpy(m_aFilename, r);
}
} else {
fclose(test);
#else
{
#endif
strcpy(m_aFilename, filename);
}

DEV("Stream %s\n", m_aFilename);

@@ -517,4 +534,4 @@ void CStream::ProviderTerm()
ClearBuffers();
}

#endif
#endif
@@ -5,16 +5,18 @@
#include "sampman.h"

#include <time.h>
#include <io.h>

#include "eax.h"
#include "eax-util.h"

#ifdef _WIN32
#include <io.h>
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#include <AL/efx.h>
#include <AL/efx-presets.h>
#endif

#include "oal/oal_utils.h"
#include "oal/aldlist.h"
@@ -31,7 +33,9 @@
//TODO: loop count
//TODO: mp3 player

#ifdef _WIN32
#pragma comment( lib, "OpenAL32.lib" )
#endif

cSampleManager SampleManager;
bool _bSampmanInitialised = false;
@@ -61,15 +65,15 @@ struct
int defaultProvider;


char SampleBankDescFilename[] = "AUDIO\\SFX.SDT";
char SampleBankDataFilename[] = "AUDIO\\SFX.RAW";
char SampleBankDescFilename[] = "audio/sfx.SDT";
char SampleBankDataFilename[] = "audio/sfx.RAW";

FILE *fpSampleDescHandle;
FILE *fpSampleDataHandle;
bool bSampleBankLoaded [MAX_SAMPLEBANKS];
int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS];
int32 nSampleBankSize [MAX_SAMPLEBANKS];
int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS];
int32 _nSampleDataEndOffset;

int32 nPedSlotSfx [MAX_PEDSFX];
@@ -88,7 +92,7 @@ struct
{
ALuint buffer;
ALuint timer;

bool IsEmpty() { return timer == 0; }
void Set(ALuint buf) { buffer = buf; }
void Wait() { timer = 10000; }
@@ -573,7 +577,7 @@ cSampleManager::Initialise(void)
return false;
}

nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)malloc(nSampleBankSize[SAMPLEBANK_MAIN]);
nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (uintptr)malloc(nSampleBankSize[SAMPLEBANK_MAIN]);
ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != NULL);

if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == NULL )
@@ -582,7 +586,7 @@ cSampleManager::Initialise(void)
return false;
}

nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != NULL);
}

@@ -985,7 +989,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
if ( !IsSampleBankLoaded(nBank) )
return false;

int32 addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
uintptr addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;

if ( ALBuffers[nSfx].IsEmpty() )
{
@@ -1401,4 +1405,4 @@ cSampleManager::InitialiseSampleBanks(void)
return true;
}

#endif
#endif

0 comments on commit 5f40f06

Please sign in to comment.