diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..94b41b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,332 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ diff --git a/OpenGTA-win/OpenGTA-win.sln b/OpenGTA-win/OpenGTA-win.sln new file mode 100755 index 0000000..6c9bd93 --- /dev/null +++ b/OpenGTA-win/OpenGTA-win.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2015 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGTA-win", "OpenGTA-win.vcxproj", "{029D8A0B-123A-400E-9954-700F8CFF3F81}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Debug|x64.ActiveCfg = Debug|x64 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Debug|x64.Build.0 = Debug|x64 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Debug|x86.ActiveCfg = Debug|Win32 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Debug|x86.Build.0 = Debug|Win32 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Release|x64.ActiveCfg = Release|x64 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Release|x64.Build.0 = Release|x64 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Release|x86.ActiveCfg = Release|Win32 + {029D8A0B-123A-400E-9954-700F8CFF3F81}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {867B0492-13C4-4F6B-8DC5-5DDFEF60B309} + EndGlobalSection +EndGlobal diff --git a/OpenGTA-win/OpenGTA-win.vcxproj b/OpenGTA-win/OpenGTA-win.vcxproj new file mode 100755 index 0000000..d6b6555 --- /dev/null +++ b/OpenGTA-win/OpenGTA-win.vcxproj @@ -0,0 +1,277 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {029D8A0B-123A-400E-9954-700F8CFF3F81} + OpenGTAwin + 10.0.17134.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + Unicode + false + + + Application + false + v141 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + $(VC_IncludePath);$(WindowsSDK_IncludePath); + + + $(VC_IncludePath);$(WindowsSDK_IncludePath); + + + + Level3 + Disabled + true + true + ..\;..\math;..\coldet\;..\util;..\..\SDL2-2.0.8\include;..\..\physfs-3.0.1\build\install\include + + + + + Level3 + Disabled + true + true + ..\;..\math;..\coldet\;..\util;..\..\SDL2-2.0.8\include;..\..\physfs-3.0.1\build\install\include;..\..\loki-0.1.7\include\loki;..\opensteer\include + _CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + + + Console + ..\..\SDL2-2.0.8\lib\x64;..\..\loki-0.1.7\lib;..\..\physfs-3.0.1\build\install\lib + physfs-static.lib;loki_D.lib;SDL2.lib;SDL2main.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + MaxSpeed + true + true + true + true + ..\;..\math;..\coldet\;..\util;..\..\SDL2-2.0.8\include;..\..\physfs-3.0.1\build\install\include + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + ..\;..\math;..\coldet\;..\util;..\..\SDL2-2.0.8\include;..\..\physfs-3.0.1\build\install\include;..\..\loki-0.1.7\include\loki;..\opensteer\include + _SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + false + + + true + true + Console + ..\..\SDL2-2.0.8\lib\x64;..\..\loki-0.1.7\lib;..\..\physfs-3.0.1\build\install\lib + physfs-static.lib;loki_D.lib;SDL2.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenGTA-win/OpenGTA-win.vcxproj.filters b/OpenGTA-win/OpenGTA-win.vcxproj.filters new file mode 100755 index 0000000..4a2289c --- /dev/null +++ b/OpenGTA-win/OpenGTA-win.vcxproj.filters @@ -0,0 +1,407 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {61d3b438-8ce2-448d-8dd9-378b1eba1e3d} + + + {29273c88-3c60-4004-a50d-4e73bab65145} + + + {973c556e-0197-448e-9484-234647c2a827} + + + {dd602175-4834-4446-99a4-2df1bb9aa58d} + + + {b411155d-6ed1-42eb-b97b-2236cdffc485} + + + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\ogta + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\coldet + + + Source Files\opensteer + + + Source Files\opensteer + + + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\ogta + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\math + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\util + + + Source Files\coldet + + + + + Source Files\ogta + + + \ No newline at end of file diff --git a/OpenGTA-win/SDL2.dll b/OpenGTA-win/SDL2.dll new file mode 100755 index 0000000..6cf858c Binary files /dev/null and b/OpenGTA-win/SDL2.dll differ diff --git a/coldet/math3d.cpp b/coldet/math3d.cpp old mode 100644 new mode 100755 index 7a0fb35..166edb5 --- a/coldet/math3d.cpp +++ b/coldet/math3d.cpp @@ -24,6 +24,9 @@ #include "sysdep.h" #include "math3d.h" +#define _USE_MATH_DEFINES +#include + const Vector3D Vector3D::Zero(0.0f,0.0f,0.0f); const Matrix3D Matrix3D::Identity(1.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.0f, diff --git a/coldet/math3d.h b/coldet/math3d.h old mode 100644 new mode 100755 index 47d9a73..433cdbf --- a/coldet/math3d.h +++ b/coldet/math3d.h @@ -66,22 +66,6 @@ struct Vector3D float& operator[] (int i) { return ((float*)&x)[i]; } }; -#define _11 sclr.s11 -#define _12 sclr.s12 -#define _13 sclr.s13 -#define _14 sclr.s14 -#define _21 sclr.s21 -#define _22 sclr.s22 -#define _23 sclr.s23 -#define _24 sclr.s24 -#define _31 sclr.s31 -#define _32 sclr.s32 -#define _33 sclr.s33 -#define _34 sclr.s34 -#define _41 sclr.s41 -#define _42 sclr.s42 -#define _43 sclr.s43 -#define _44 sclr.s44 struct Matrix3 { @@ -119,10 +103,10 @@ struct Matrix3D float f31, float f32, float f33, float f34, float f41, float f42, float f43, float f44) { - _11=f11; _12=f12; _13=f13; _14=f14; - _21=f21; _22=f22; _23=f23; _24=f24; - _31=f31; _32=f32; _33=f33; _34=f34; - _41=f41; _42=f42; _43=f43; _44=f44; + sclr.s11=f11; sclr.s12=f12; sclr.s13=f13; sclr.s14=f14; + sclr.s21=f21; sclr.s22=f22; sclr.s23=f23; sclr.s24=f24; + sclr.s31=f31; sclr.s32=f32; sclr.s33=f33; sclr.s34=f34; + sclr.s41=f41; sclr.s42=f42; sclr.s43=f43; sclr.s44=f44; } Matrix3D& operator*= (const Matrix3D& m) @@ -199,16 +183,16 @@ inline Vector3D CrossProduct(const Vector3D& v1, const Vector3D& v2) inline Vector3D Transform(const Vector3D& v, const Matrix3D& m) { - return Vector3D(v.x*m._11 + v.y*m._21 + v.z*m._31 + m._41, - v.x*m._12 + v.y*m._22 + v.z*m._32 + m._42, - v.x*m._13 + v.y*m._23 + v.z*m._33 + m._43); + return Vector3D(v.x*m.sclr.s11 + v.y*m.sclr.s21 + v.z*m.sclr.s31 + m.sclr.s41, + v.x*m.sclr.s12 + v.y*m.sclr.s22 + v.z*m.sclr.s32 + m.sclr.s42, + v.x*m.sclr.s13 + v.y*m.sclr.s23 + v.z*m.sclr.s33 + m.sclr.s43); } inline Vector3D rotateVector(const Vector3D& v, const Matrix3D& m) { - return Vector3D(v.x*m._11 + v.y*m._21 + v.z*m._31, - v.x*m._12 + v.y*m._22 + v.z*m._32, - v.x*m._13 + v.y*m._23 + v.z*m._33); + return Vector3D(v.x*m.sclr.s11 + v.y*m.sclr.s21 + v.z*m.sclr.s31, + v.x*m.sclr.s12 + v.y*m.sclr.s22 + v.z*m.sclr.s32, + v.x*m.sclr.s13 + v.y*m.sclr.s23 + v.z*m.sclr.s33); } inline Matrix3D operator*(float scalar, const Matrix3D& m) @@ -222,22 +206,22 @@ inline Matrix3D operator*(float scalar, const Matrix3D& m) inline Matrix3D operator*(const Matrix3D& m1, const Matrix3D& m2) { return Matrix3D( - m1._11*m2._11 + m1._12*m2._21 + m1._13*m2._31 + m1._14*m2._41, - m1._11*m2._12 + m1._12*m2._22 + m1._13*m2._32 + m1._14*m2._42, - m1._11*m2._13 + m1._12*m2._23 + m1._13*m2._33 + m1._14*m2._43, - m1._11*m2._14 + m1._12*m2._24 + m1._13*m2._34 + m1._14*m2._44, - m1._21*m2._11 + m1._22*m2._21 + m1._23*m2._31 + m1._24*m2._41, - m1._21*m2._12 + m1._22*m2._22 + m1._23*m2._32 + m1._24*m2._42, - m1._21*m2._13 + m1._22*m2._23 + m1._23*m2._33 + m1._24*m2._43, - m1._21*m2._14 + m1._22*m2._24 + m1._23*m2._34 + m1._24*m2._44, - m1._31*m2._11 + m1._32*m2._21 + m1._33*m2._31 + m1._34*m2._41, - m1._31*m2._12 + m1._32*m2._22 + m1._33*m2._32 + m1._34*m2._42, - m1._31*m2._13 + m1._32*m2._23 + m1._33*m2._33 + m1._34*m2._43, - m1._31*m2._14 + m1._32*m2._24 + m1._33*m2._34 + m1._34*m2._44, - m1._41*m2._11 + m1._42*m2._21 + m1._43*m2._31 + m1._44*m2._41, - m1._41*m2._12 + m1._42*m2._22 + m1._43*m2._32 + m1._44*m2._42, - m1._41*m2._13 + m1._42*m2._23 + m1._43*m2._33 + m1._44*m2._43, - m1._41*m2._14 + m1._42*m2._24 + m1._43*m2._34 + m1._44*m2._44); + m1.sclr.s11*m2.sclr.s11 + m1.sclr.s12*m2.sclr.s21 + m1.sclr.s13*m2.sclr.s31 + m1.sclr.s14*m2.sclr.s41, + m1.sclr.s11*m2.sclr.s12 + m1.sclr.s12*m2.sclr.s22 + m1.sclr.s13*m2.sclr.s32 + m1.sclr.s14*m2.sclr.s42, + m1.sclr.s11*m2.sclr.s13 + m1.sclr.s12*m2.sclr.s23 + m1.sclr.s13*m2.sclr.s33 + m1.sclr.s14*m2.sclr.s43, + m1.sclr.s11*m2.sclr.s14 + m1.sclr.s12*m2.sclr.s24 + m1.sclr.s13*m2.sclr.s34 + m1.sclr.s14*m2.sclr.s44, + m1.sclr.s21*m2.sclr.s11 + m1.sclr.s22*m2.sclr.s21 + m1.sclr.s23*m2.sclr.s31 + m1.sclr.s24*m2.sclr.s41, + m1.sclr.s21*m2.sclr.s12 + m1.sclr.s22*m2.sclr.s22 + m1.sclr.s23*m2.sclr.s32 + m1.sclr.s24*m2.sclr.s42, + m1.sclr.s21*m2.sclr.s13 + m1.sclr.s22*m2.sclr.s23 + m1.sclr.s23*m2.sclr.s33 + m1.sclr.s24*m2.sclr.s43, + m1.sclr.s21*m2.sclr.s14 + m1.sclr.s22*m2.sclr.s24 + m1.sclr.s23*m2.sclr.s34 + m1.sclr.s24*m2.sclr.s44, + m1.sclr.s31*m2.sclr.s11 + m1.sclr.s32*m2.sclr.s21 + m1.sclr.s33*m2.sclr.s31 + m1.sclr.s34*m2.sclr.s41, + m1.sclr.s31*m2.sclr.s12 + m1.sclr.s32*m2.sclr.s22 + m1.sclr.s33*m2.sclr.s32 + m1.sclr.s34*m2.sclr.s42, + m1.sclr.s31*m2.sclr.s13 + m1.sclr.s32*m2.sclr.s23 + m1.sclr.s33*m2.sclr.s33 + m1.sclr.s34*m2.sclr.s43, + m1.sclr.s31*m2.sclr.s14 + m1.sclr.s32*m2.sclr.s24 + m1.sclr.s33*m2.sclr.s34 + m1.sclr.s34*m2.sclr.s44, + m1.sclr.s41*m2.sclr.s11 + m1.sclr.s42*m2.sclr.s21 + m1.sclr.s43*m2.sclr.s31 + m1.sclr.s44*m2.sclr.s41, + m1.sclr.s41*m2.sclr.s12 + m1.sclr.s42*m2.sclr.s22 + m1.sclr.s43*m2.sclr.s32 + m1.sclr.s44*m2.sclr.s42, + m1.sclr.s41*m2.sclr.s13 + m1.sclr.s42*m2.sclr.s23 + m1.sclr.s43*m2.sclr.s33 + m1.sclr.s44*m2.sclr.s43, + m1.sclr.s41*m2.sclr.s14 + m1.sclr.s42*m2.sclr.s24 + m1.sclr.s43*m2.sclr.s34 + m1.sclr.s44*m2.sclr.s44); } inline void diff --git a/coldet/sysdep.h b/coldet/sysdep.h old mode 100644 new mode 100755 index 57e1c43..bce7f50 --- a/coldet/sysdep.h +++ b/coldet/sysdep.h @@ -24,14 +24,6 @@ #ifndef H_SYSDEP #define H_SYSDEP -#ifdef GCC - -typedef unsigned long DWORD; -DWORD GetTickCount(); -#define __CD__BEGIN -#define __CD__END - -#elif defined(WIN32) #define WIN32_LEAN_AND_MEAN #include @@ -42,11 +34,6 @@ DWORD GetTickCount(); #else #define EXPORT __declspec(dllimport) #endif -#else - -#error No system specified (WIN32 GCC) - -#endif #ifndef EXPORT #define EXPORT diff --git a/common_sdl_gl.cpp b/common_sdl_gl.cpp old mode 100644 new mode 100755 index d459fec..eea6a95 --- a/common_sdl_gl.cpp +++ b/common_sdl_gl.cpp @@ -2,6 +2,11 @@ #include #include + + +#include "gl/gl.h" +#include "gl/glu.h" + extern int global_EC; #ifndef VIEWGL_FOVY @@ -14,7 +19,7 @@ extern int global_EC; #define VIEWGL_ZFAR 250.0f #endif -extern SDL_Surface* screen; +extern SDL_Window* screen; int videoFlags = 0; /* @@ -43,27 +48,21 @@ int resize(int w, int h) { } void initVideo(int w, int h, int bpp) { - const SDL_VideoInfo *videoInfo; - /* - SDL_Rect **modes; - int i; - - videoInfo = SDL_GetVideoInfo( ); - modes=SDL_ListModes(videoInfo->vfmt, SDL_FULLSCREEN|SDL_HWSURFACE); - if(modes == (SDL_Rect **)0){ - printf("No modes available!\n"); - exit(1); - } - if(modes == (SDL_Rect **)-1){ - printf("All resolutions available.\n"); - } - else{ - printf("Available Modes\n"); - for(i=0;modes[i];++i) - printf(" %d x %d\n", modes[i]->w, modes[i]->h); - } - */ + + screen = SDL_CreateWindow("My Game Window", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + w, h, + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL); + + + resize(w, h); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* + const SDL_VideoInfo *videoInfo; if (!videoInfo) ERROR("VideoInfo query failed"); @@ -71,7 +70,7 @@ void initVideo(int w, int h, int bpp) { videoFlags |= SDL_GL_DOUBLEBUFFER; videoFlags |= SDL_HWPALETTE; //videoFlags |= SDL_RESIZABLE; - //videoFlags |= SDL_FULLSCREEN; + //videoFlags |= SDL_WINDOW_FULLSCREEN; if ( videoInfo->hw_available ) { std::cerr << "Info: Using HWSURFACE" << std::endl; @@ -91,7 +90,7 @@ void initVideo(int w, int h, int bpp) { if (!screen) ERROR("SDL failed to generate requested VideoSurface!"); - resize(w, h); + resize(w, h);*/ } void initGL() { diff --git a/font_cache.cpp b/font_cache.cpp old mode 100644 new mode 100755 index 1bd9146..0bdd7bf --- a/font_cache.cpp +++ b/font_cache.cpp @@ -39,8 +39,9 @@ namespace OpenGTA { if (i == loadedFonts.end()) { OpenGL::DrawableFont* fnt = createFont(file, scale); assert(fnt); - loadedFonts.insert(std::make_pair( - FontIdentifier(file, scale), fnt)); + + loadedFonts[FontIdentifier(file, scale)] = fnt; + return *fnt; } return *i->second; diff --git a/fx_sdt.h b/fx_sdt.h old mode 100644 new mode 100755 index 175a5b5..8ac9f60 --- a/fx_sdt.h +++ b/fx_sdt.h @@ -40,6 +40,7 @@ namespace OpenGTA { ~SoundsDB(); void load(const std::string & sdt_file); struct Entry { + Entry(); Entry(PHYSFS_uint32, PHYSFS_uint32, PHYSFS_uint32); PHYSFS_uint32 rawStart; PHYSFS_uint32 rawSize; diff --git a/game_objects.cpp b/game_objects.cpp old mode 100644 new mode 100755 index 37d2878..e94290c --- a/game_objects.cpp +++ b/game_objects.cpp @@ -30,11 +30,6 @@ #include "ai.h" #include "localplayer.h" -// ugly fix for win32 -#ifdef WIN32 -#undef ERROR -#define ERROR Util::Log::error(__FILE__, __LINE__) -#endif #define INT2FLOAT_WRLD(c) (float(c >> 6) + float(c % 64) / 64.0f) #define INT2F_DIV64(v) (float(v) / 64.0f) @@ -520,7 +515,8 @@ activeWeapon = chooseWeapon; void CarSprite::setSirenAnim(bool on) { if (!(assertDeltaById(15) && assertDeltaById(16))) { - ERROR << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl; + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + //ERROR << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl; return; } animState.set_item(10, on); diff --git a/gl_camera.cpp b/gl_camera.cpp old mode 100644 new mode 100755 index f77b4c2..1af95e4 --- a/gl_camera.cpp +++ b/gl_camera.cpp @@ -233,7 +233,11 @@ namespace OpenGL { h = screen.getHeight() / 2; int mx, my; SDL_GetMouseState(&mx, &my); - SDL_WarpMouse(w, h); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + //SDL_WarpMouse(w, h); + SDL_WarpMouseInWindow(screen.surface, w, h); + if ((mx == w) && (my == h)) return; float rot_x = (float(w) - mx) / 100; diff --git a/gl_screen.cpp b/gl_screen.cpp old mode 100644 new mode 100755 index 0d3e7ae..0036a2d --- a/gl_screen.cpp +++ b/gl_screen.cpp @@ -27,6 +27,7 @@ #include "m_exceptions.h" #include "image_loader.h" + namespace OpenGL { #ifndef DEFAULT_SCREEN_WIDTH #define DEFAULT_SCREEN_WIDTH 640 @@ -86,7 +87,7 @@ namespace OpenGL { } bool Screen::getFullscreen() { - return (videoFlags & SDL_FULLSCREEN); + return (videoFlags & SDL_WINDOW_FULLSCREEN); } void Screen::setFullScreenFlag(bool v) { @@ -95,9 +96,9 @@ namespace OpenGL { else if (!v && !getFullscreen()) return; if (v) - videoFlags |= SDL_FULLSCREEN; + videoFlags |= SDL_WINDOW_FULLSCREEN; else - videoFlags ^= SDL_FULLSCREEN; + videoFlags ^= SDL_WINDOW_FULLSCREEN; } Screen::~Screen() { @@ -108,14 +109,40 @@ namespace OpenGL { } void Screen::toggleFullscreen() { - if (videoFlags & SDL_FULLSCREEN) - videoFlags ^= SDL_FULLSCREEN; + if (videoFlags & SDL_WINDOW_FULLSCREEN) + videoFlags ^= SDL_WINDOW_FULLSCREEN; else - videoFlags |= SDL_FULLSCREEN; + videoFlags |= SDL_WINDOW_FULLSCREEN; resize(width, height); } void Screen::initSDL() { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + size_t color_depth_triple[3]; + + for (int i = 0; i < 3; ++i) + color_depth_triple[i] = 8; + + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, color_depth_triple[0]); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, color_depth_triple[1]); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, color_depth_triple[2]); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); +#ifdef HAVE_SDL_VSYNC + if (useVsync == 1) { + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); + INFO << "enabling vertical sync:" << " SDL" << std::endl; + } +#else + if (useVsync == 1) + WARN << "Cannot use SDL vsync - option disabled while compiling" << std::endl; +#endif + + + /* int err = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); if (err) //throw "SDL_Init failed: " + std::string(SDL_GetError()); @@ -189,7 +216,7 @@ namespace OpenGL { sdl_err = SDL_GetError(); if (strlen(sdl_err) > 0) ERROR << "setting sdl_gl attributes: " << sdl_err << std::endl; - + */ } void Screen::initGL() { @@ -250,6 +277,25 @@ namespace OpenGL { } void Screen::resize(Uint32 w, Uint32 h) { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + if (h == 0) + h = 1; + + surface = SDL_CreateWindow( + "SDL2/OpenGL Demo", 0, 0, w, h, + SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + + // Create an OpenGL context associated with the window. + glcontext = SDL_GL_CreateContext(surface); + + glViewport(0, 0, w, h); + width = w; + height = h; + GL_CHECKERROR; + + /* if (h == 0) h = 1; surface = SDL_SetVideoMode(w, h, bpp, videoFlags); @@ -259,11 +305,11 @@ namespace OpenGL { " hw-blit: " << (videoFlags & SDL_HWACCEL == SDL_HWACCEL ? "on" : "off") << std::endl; throw E_NOTSUPPORTED(SDL_GetError()); } - + glViewport(0, 0, w, h); width = w; height = h; - GL_CHECKERROR; + GL_CHECKERROR;*/ } void Screen::set3DProjection() { diff --git a/gl_screen.h b/gl_screen.h old mode 100644 new mode 100755 index 630f95b..fb0fba3 --- a/gl_screen.h +++ b/gl_screen.h @@ -28,6 +28,10 @@ #include "Singleton.h" +#include "gl/gl.h" +#include "gl/glu.h" + + namespace OpenGL { class Screen { public: @@ -62,11 +66,12 @@ namespace OpenGL { float fieldOfView; float nearPlane; float farPlane; - static const Uint32 defaultVideoFlags = - SDL_OPENGL | SDL_GL_DOUBLEBUFFER;// | SDL_HWPALETTE | SDL_HWACCEL; - //FIXME: use ^ here as well? not just SDL_GL_SetAttribute? - SDL_Surface *surface; + static const Uint32 defaultVideoFlags = SDL_WINDOW_OPENGL | SDL_GL_DOUBLEBUFFER; + + public: + SDL_Window *surface; + SDL_GLContext glcontext; }; using namespace Loki; diff --git a/gl_spritecache.cpp b/gl_spritecache.cpp old mode 100644 new mode 100755 index 97c4203..dd5aaab --- a/gl_spritecache.cpp +++ b/gl_spritecache.cpp @@ -22,7 +22,7 @@ ************************************************************************/ #include #include -#include +//#include #include "gl_spritecache.h" #include "image_loader.h" #include "opengta.h" @@ -144,13 +144,12 @@ namespace OpenGL { } void SpriteCache::add(PHYSFS_uint16 sprNum, PHYSFS_sint16 remap, PagedTexture & t) { - loadedSprites.insert( - std::make_pair( - SpriteIdentifier(sprNum, remap, 0), t)); + + loadedSprites[SpriteIdentifier(sprNum, remap, 0)] = t; } void SpriteCache::add(const SpriteIdentifier & si, PagedTexture & t) { - loadedSprites.insert(std::make_pair(si, t)); + loadedSprites[si] = t; } PagedTexture SpriteCache::create(PHYSFS_uint16 sprNum, diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index 9ee6791..4579356 --- a/main.cpp +++ b/main.cpp @@ -8,12 +8,16 @@ void initVideo(int w, int h, int bpp); int global_EC = 0; int global_Done = 0; -SDL_Surface* screen = NULL; + +SDL_Window* screen = NULL; SDL_Surface* surface = NULL; int city_num = 0; int main(int argc, char* argv[]) { + + + if (SDL_Init(SDL_INIT_VIDEO) < 0) { std::cerr << "Fatal error initialising SDL!" << std::endl; global_EC = 1; @@ -23,10 +27,14 @@ int main(int argc, char* argv[]) { if (argc == 2) { city_num = atoi(argv[1]); } - SDL_EnableKeyRepeat( 100, SDL_DEFAULT_REPEAT_INTERVAL ); - initVideo(1024, 768, 32); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + //SDL_EnableKeyRepeat( 100, SDL_DEFAULT_REPEAT_INTERVAL ); + . initVideo(1024, 768, 32); initGL(); run_main(); exit(0); + + return 0; } diff --git a/read_cmp.cpp b/read_cmp.cpp old mode 100644 new mode 100755 index d732041..5b740b2 --- a/read_cmp.cpp +++ b/read_cmp.cpp @@ -17,6 +17,9 @@ #include "m_exceptions.h" #include "datahelper.h" + +#include + /* see http://members.aol.com/form1/fixed.htm for fixed point floats: * int_var = (long) fixed_var >> 8; // for 8 bits after point */ diff --git a/read_fnt.cpp b/read_fnt.cpp old mode 100644 new mode 100755 index 8b69586..573c063 --- a/read_fnt.cpp +++ b/read_fnt.cpp @@ -15,6 +15,9 @@ #include "m_exceptions.h" #include "log.h" + +#include + namespace OpenGTA { Font::Font(const std::string &file) { PHYSFS_file *fd = PHYSFS_openRead(file.c_str()); @@ -105,6 +108,10 @@ namespace OpenGTA { */ } void Font::dumpAs(const char* filename, size_t id) { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* unsigned int len = chars[id]->width; len *= charHeight; palette.apply(len, chars[id]->rawData, workBuffer, true); @@ -133,7 +140,7 @@ namespace OpenGTA { } SDL_UnlockSurface(s); SDL_SaveBMP(s, filename); - SDL_FreeSurface(s); + SDL_FreeSurface(s);*/ } Font::Character::Character(PHYSFS_file *fd, uint8_t height) { PHYSFS_read(fd, static_cast(&width), 1, 1); diff --git a/read_fxt.cpp b/read_fxt.cpp old mode 100644 new mode 100755 index cf7f18f..e6f7efd --- a/read_fxt.cpp +++ b/read_fxt.cpp @@ -13,6 +13,8 @@ #include "opengta.h" #include "m_exceptions.h" #include "log.h" + +#include namespace OpenGTA { MessageDB::MessageDB() { diff --git a/read_g24.cpp b/read_g24.cpp old mode 100644 new mode 100755 index b9f8282..9068c43 --- a/read_g24.cpp +++ b/read_g24.cpp @@ -320,6 +320,10 @@ namespace OpenGTA { } void Graphics24Bit::dumpClut(const char* fname) { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* assert(pagedClutSize % 1024 == 0); //PHYSFS_uint32 num_clut = pagedClutSize / 1024; PHYSFS_uint32 num_pal = paletteIndexSize / 2; @@ -358,7 +362,7 @@ namespace OpenGTA { } SDL_UnlockSurface(s); SDL_SaveBMP(s, fname); - SDL_FreeSurface(s); + SDL_FreeSurface(s);*/ } unsigned char* Graphics24Bit::getSpriteBitmap(size_t id, int remap = -1, Uint32 delta = 0) { diff --git a/read_sdt.cpp b/read_sdt.cpp old mode 100644 new mode 100755 index 6f83a3f..e14e1d8 --- a/read_sdt.cpp +++ b/read_sdt.cpp @@ -24,11 +24,19 @@ #include #include "m_exceptions.h" #include "fx_sdt.h" + +#include #ifdef SOUND_DUMPER #include #endif namespace OpenGTA { + + SoundsDB::Entry::Entry() { + rawStart = 0; + rawSize = 0; + sampleRate = 0; + } SoundsDB::Entry::Entry(PHYSFS_uint32 r1, PHYSFS_uint32 r2, PHYSFS_uint32 sr) { rawStart = r1; rawSize = r2; @@ -65,7 +73,10 @@ namespace OpenGTA { #ifdef SOUND_DUMPER std::cout << i << " " << r1 << " " << r2 << " " << sr << std::endl; #endif - knownEntries.insert( std::make_pair(i, Entry(r1, r2, sr))); + + auto entry = Entry(r1, r2, sr); + knownEntries[i] = entry; + } PHYSFS_close(dataFile); @@ -74,6 +85,7 @@ namespace OpenGTA { dataFile = PHYSFS_openRead(raw_file.c_str()); if (!dataFile) { std::string sdt2(raw_file); + transform(sdt2.begin(), sdt2.end(), sdt2.begin(), tolower); dataFile = PHYSFS_openRead(sdt2.c_str()); } diff --git a/sprite_anim_player.cpp b/sprite_anim_player.cpp old mode 100644 new mode 100755 index 7774c33..e6fed4d --- a/sprite_anim_player.cpp +++ b/sprite_anim_player.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +//#include #include "gl_screen.h" #include "opengta.h" #include "log.h" @@ -89,11 +89,15 @@ namespace OpenGTA { } void run_init(const char*) { + + PHYSFS_init("mapview"); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1); PHYSFS_addToSearchPath("gtadata.zip", 1); OpenGL::ScreenHolder::Instance().activate(640, 480); - SDL_EnableKeyRepeat( 100, SDL_DEFAULT_REPEAT_INTERVAL ); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + //SDL_EnableKeyRepeat( 100, SDL_DEFAULT_REPEAT_INTERVAL ); OpenGTA::StyleHolder::Instance().load(style_file); OpenGTA::StyleHolder::Instance().get().setDeltaHandling(true); @@ -218,10 +222,15 @@ void drawScene(Uint32 ticks) { glPopMatrix(); } - SDL_GL_SwapBuffers(); + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + SDL_GL_SwapWindow(OpenGL::ScreenHolder::Instance().surface); + + GL_CHECKERROR; } +/* void handleKeyPress( SDL_keysym *keysym ) { OpenGL::Camera & cam = OpenGL::CameraHolder::Instance(); OpenGTA::GraphicsBase & style = OpenGTA::StyleHolder::Instance().get(); @@ -384,7 +393,7 @@ void handleKeyPress( SDL_keysym *keysym ) { if (playWithCar) safe_try_model(car_model); } -} +}*/ void usage(const char* a0) { std::cout << "USAGE: " << a0 << " [style-filename]" << std::endl; @@ -408,6 +417,10 @@ void usage(const char* a0) { } void parse_args(int argc, char* argv[]) { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* int index; int c; @@ -429,7 +442,7 @@ void parse_args(int argc, char* argv[]) { } for (index = optind; index < argc; index++) - style_file = std::string(argv[index]); + style_file = std::string(argv[index]);*/ } void run_main() { @@ -449,14 +462,19 @@ void run_main() { while (SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: - handleKeyPress(&event.key.keysym); + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + //handleKeyPress(&event.key.keysym); break; case SDL_KEYUP: // handleKeyUp(&event.key.keysym); break; + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com +/* case SDL_VIDEORESIZE: OpenGL::ScreenHolder::Instance().resize(event.resize.w, event.resize.h); - break; + break;*/ case SDL_QUIT: global_Done = 1; break; diff --git a/spritemanager.cpp b/spritemanager.cpp old mode 100644 new mode 100755 index 176db9a..a0c6267 --- a/spritemanager.cpp +++ b/spritemanager.cpp @@ -628,7 +628,8 @@ SpriteObject::Animation & SpriteManager::getAnimationById(const Uint32 & id) { void SpriteManager::registerAnimation(const Uint32 & id, const SpriteObject::Animation & anim) { - animations.insert(std::make_pair(id, anim)); + + animations[id] = anim; } void SpriteManager::setDrawBBox(bool v) { diff --git a/util/cell_iterator.cpp b/util/cell_iterator.cpp old mode 100644 new mode 100755 index 99fa5b0..012e165 --- a/util/cell_iterator.cpp +++ b/util/cell_iterator.cpp @@ -75,20 +75,20 @@ namespace Util { std::pair CellIterator::findTypeInCol(uint8_t t) const { if (isBlockType(t)) - return std::make_pair(true, *this); + return std::make_pair(true, CellIterator(*this)); CellIterator below = down(); while (below.isValid()) { if (below.isBlockType(t)) - return std::make_pair(true, below); + return std::make_pair(true, CellIterator(below)); below = below.down(); } CellIterator above = up(); while (above.isValid()) { if (above.isBlockType(t)) - return std::make_pair(true, above); + return std::make_pair(true, CellIterator(above)); above = above.up(); } - return std::make_pair(false, *this); + return std::make_pair(false, CellIterator(*this)); } std::pair CellIterator::findNeighbourWithType( @@ -135,7 +135,7 @@ namespace Util { // if (p.first) INFO << p.second.x << " " << p.second.y << " " << p.second.z << std::endl; if (p.first) return p; } - return std::make_pair(false, *this); + return std::make_pair(false, CellIterator(*this)); } diff --git a/util/gui.cpp b/util/gui.cpp old mode 100644 new mode 100755 index 754f700..49a46e8 --- a/util/gui.cpp +++ b/util/gui.cpp @@ -15,13 +15,13 @@ namespace GUI { id(0), rect(), color(), borderColor(), drawBorder(false), manager(ManagerHolder::Instance()) { copyRect(r); - color.r = 255; color.g = 255; color.b = 255; color.unused = 255; + color.r = 255; color.g = 255; color.b = 255; color.a = 255; } Object::Object(const size_t Id, const SDL_Rect & r) : id(Id), rect(), color(), borderColor(), drawBorder(false), manager(ManagerHolder::Instance()) { copyRect(r); - color.r = 255; color.g = 255; color.b = 255; color.unused = 255; + color.r = 255; color.g = 255; color.b = 255; color.a = 255; } Object::Object(const size_t Id, const SDL_Rect & r, const SDL_Color & c) : id(Id), rect(), color(), borderColor(), drawBorder(false), @@ -33,7 +33,7 @@ namespace GUI { glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); glVertex2i(rect.x, rect.y); @@ -47,7 +47,7 @@ namespace GUI { } void Object::draw_border() { glColor4ub(borderColor.r, borderColor.g, borderColor.b, - borderColor.unused); + borderColor.a); glBegin(GL_LINE_LOOP); glVertex2i(rect.x, rect.y); glVertex2i(rect.x + rect.w, rect.y); @@ -65,13 +65,13 @@ namespace GUI { color.r = src.r; color.g = src.g; color.b = src.b; - color.unused = src.unused; + color.a = src.a; } void TexturedObject::draw() { if (texId == 0) return; const OpenGL::PagedTexture & tex = manager.getCachedImage(texId); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex.inPage); glBegin(GL_QUADS); @@ -96,7 +96,7 @@ namespace GUI { assert(animation); size_t texId = animation->getCurrentFrame(); const OpenGL::PagedTexture & tex = manager.getCachedImage(texId); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex.inPage); glBegin(GL_QUADS); @@ -116,7 +116,7 @@ namespace GUI { void Label::draw() { glPushMatrix(); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glEnable(GL_TEXTURE_2D); if (align == 0) { glTranslatef(rect.x, rect.y, 0); @@ -146,7 +146,7 @@ namespace GUI { void Pager::draw() { const OpenGL::PagedTexture & tex = manager.getCachedImage(texId); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex.inPage); glBegin(GL_QUADS); @@ -163,11 +163,11 @@ namespace GUI { glEnable(GL_SCISSOR_TEST); glPushMatrix(); - glColor4ub(color.r, color.g, color.b, color.unused); + glColor4ub(color.r, color.g, color.b, color.a); glTranslatef(rect.x+offset, rect.y+4, 0); int slen = (int)font->drawString("test - hello world, this is a really long message. it will not end. never... or maybe sometime, but not yet. The end."); if (slen + offset < -10) { - color.unused = 0; + color.a = 0; manager.remove(this); } INFO << slen <<" " << offset << std::endl; @@ -254,11 +254,11 @@ namespace GUI { } void Manager::cacheImageRAW(const std::string & file, size_t k) { - texCache.insert(std::make_pair(k, ImageUtil::loadImageRAW(file))); + texCache.insert(std::make_pair(k, ImageUtil::loadImageRAW(file))); } void Manager::cacheImageRAT(const std::string & file, const std::string & palette, size_t k) { - texCache.insert(std::make_pair(k, + texCache.insert(std::make_pair(k, ImageUtil::loadImageRATWithPalette(file, palette))); } @@ -266,7 +266,7 @@ namespace GUI { OpenGTA::GraphicsBase & graphics = OpenGTA::StyleHolder::Instance().get(); PHYSFS_uint16 t = graphics.spriteNumbers.reIndex(id, OpenGTA::GraphicsBase::SpriteNumbers::ARROW); OpenGTA::GraphicsBase::SpriteInfo * info = graphics.getSprite(t); - texCache.insert(std::make_pair( + texCache.insert(std::make_pair( id, OpenGL::SpriteCacheHolder::Instance().createSprite(size_t(t), remap, 0, info) )); return ImageUtil::WidthHeightPair(info->w, info->h); @@ -284,7 +284,7 @@ namespace GUI { if (l == guiLayers.end()) { GuiObjectList list; list.push_back(obj); - guiLayers.insert(std::make_pair(onLevel, list)); + guiLayers.insert(std::make_pair(onLevel, list)); return; } GuiObjectList & list = l->second; @@ -375,7 +375,7 @@ namespace GUI { } void Manager::createAnimation(const std::vector & indices, uint16_t fps, size_t k) { Animation * anim = new Animation(indices, fps); - guiAnimations.insert(std::make_pair(k, anim)); + guiAnimations.insert(std::make_pair(k, anim)); anim->set(Util::Animation::PLAY_FORWARD, Util::Animation::LOOP); } @@ -455,6 +455,9 @@ namespace GUI { void screen_gamma_callback(float v) { + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* screen_gamma = v; SDL_SetGamma(v, v, v); #ifdef WITH_LUA @@ -481,12 +484,8 @@ namespace GUI { os << "Gamma: " << v; static_cast(o)->text = os.str(); } - /* - Object * o2 = ManagerHolder::Instance().findObject(1001); - if (o2) { - static_cast(o2)->number = screen_gamma * 3; - }*/ + */ } AnimStatusDisplay* wantedLevel = NULL; diff --git a/util/image_loader.cpp b/util/image_loader.cpp old mode 100644 new mode 100755 index 46e5981..d0d4528 --- a/util/image_loader.cpp +++ b/util/image_loader.cpp @@ -29,7 +29,9 @@ #include "cistring.h" #include "opengta.h" #include "physfsrwops.h" -#include "SDL_image.h" + +//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com +//#include "SDL_image.h" #include "m_exceptions.h" namespace ImageUtil { @@ -76,7 +78,7 @@ using OpenGL::PagedTexture; if (!(bpp && bpp * width * height == size)) ERROR << "could not identify image: " << name << " size: " << size << std::endl; - return std::make_pair(width, height); + return std::make_pair(width, height); } @@ -169,6 +171,16 @@ using OpenGL::PagedTexture; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + if (rgba) { + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + } + else { + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); + } + /* if (rgba) { if (mipmapTextures) gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); @@ -180,7 +192,10 @@ using OpenGL::PagedTexture; gluBuild2DMipmaps(GL_TEXTURE_2D, 3, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); - } + }*/ + + + if (supportedMaxAnisoDegree > 1.0f) glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &supportedMaxAnisoDegree); diff --git a/util/key_handler.cpp b/util/key_handler.cpp old mode 100644 new mode 100755 index 2853862..2c7e12f --- a/util/key_handler.cpp +++ b/util/key_handler.cpp @@ -20,7 +20,9 @@ * 3. This notice may not be removed or altered from any source * * distribution. * ************************************************************************/ -#include + +//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com +//#include #include "key_handler.h" #include "log.h" diff --git a/util/map_helper.cpp b/util/map_helper.cpp old mode 100644 new mode 100755 index c2a1165..b2ba74f --- a/util/map_helper.cpp +++ b/util/map_helper.cpp @@ -3,7 +3,7 @@ namespace Util { void SpriteCreationArea::setRects(const SDL_Rect & allowed, const SDL_Rect & denied) { - validRects = std::make_pair(allowed, denied); + validRects = std::make_pair(allowed, denied); onScreen = denied; } @@ -25,11 +25,12 @@ namespace Util { TupleOfUint8 SpriteCreationArea::getValidCoord() { uint32_t x = rnd.nextUint(validRects.first.w) + validRects.first.x; uint32_t y = rnd.nextUint(validRects.first.h) + validRects.first.y; - return std::make_pair(x, y); + return std::make_pair(x, y); } int item_count(MapOfPair2Int & m, int a, int b) { - MapOfPair2Int::iterator j = m.find( std::make_pair(a, b) ); + + const auto& j = m.find({a, b}); if (j == m.end()) return 0; return j->second; @@ -37,13 +38,13 @@ namespace Util { void register_item1(MapOfPair2Int & m, int a, int b) { m.insert( std::make_pair< Pair2Int, int>( - std::make_pair(a, b), + std::make_pair(a, b), 1) ); } void register_item(MapOfPair2Int & m, int a, int b) { - Pair2Int _p(std::make_pair(a, b)); + Pair2Int _p(std::make_pair(a, b)); MapOfPair2Int::iterator j = m.find(_p); if (j == m.end()) register_item1(m, a, b); diff --git a/util/map_helper.h b/util/map_helper.h old mode 100644 new mode 100755 index a53d7b1..55f6ef8 --- a/util/map_helper.h +++ b/util/map_helper.h @@ -31,7 +31,7 @@ namespace Util { */ template struct lt_pair { - bool operator() (const T & a, const T & b) { + bool operator() (const T & a, const T & b) const { if (a.first < b.first) return true; if (a.first > b.first) diff --git a/util/physfsrwops.h b/util/physfsrwops.h old mode 100644 new mode 100755 index 91ff2eb..11c22cd --- a/util/physfsrwops.h +++ b/util/physfsrwops.h @@ -25,6 +25,9 @@ #include "physfs.h" #include "SDL.h" + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com +#define __EXPORT__ + #ifdef __cplusplus extern "C" { #endif diff --git a/util/timer.cpp b/util/timer.cpp old mode 100644 new mode 100755 index 1f81c2e..c7f739c --- a/util/timer.cpp +++ b/util/timer.cpp @@ -134,16 +134,16 @@ void Timer::checkSimEvents() { void Timer::registerCallback(bool simTime, CallbackType & c, const uint32_t & b, const uint32_t & e) { if (simTime) - simTimeEvents.insert(std::make_pair(b, TimeEvent(b, e, c))); + simTimeEvents.insert(std::make_pair(b, TimeEvent(b, e, c))); else - realTimeEvents.insert(std::make_pair(b, TimeEvent(b, e, c))); + realTimeEvents.insert(std::make_pair(b, TimeEvent(b, e, c))); } void Timer::registerCallback(bool simTime, CallbackType & c, const uint32_t & b) { if (simTime) - simTimeEvents.insert(std::make_pair(b, TimeEvent(b, c))); + simTimeEvents.insert(std::make_pair(b, TimeEvent(b, c))); else - realTimeEvents.insert(std::make_pair(b, TimeEvent(b, c))); + realTimeEvents.insert(std::make_pair(b, TimeEvent(b, c))); } void Timer::clearAllEvents() { diff --git a/viewer.cpp b/viewer.cpp old mode 100644 new mode 100755 index 274cbeb..15f9f78 --- a/viewer.cpp +++ b/viewer.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +//#include #include "blockanim.h" #include "dataholder.h" #include "entity_controller.h" @@ -56,7 +56,7 @@ #define removePedById removePed #define addPed add -extern SDL_Surface* screen; +extern SDL_Window* screen; extern int global_EC; extern int global_Done; extern int global_Restart; @@ -66,7 +66,8 @@ OpenGTA::CityView *city = NULL; //OpenGL::DrawableFont* m_font = NULL; GUI::Label * fps_label = NULL; -int city_num = 0; +extern int city_num; //In main.cpp - Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + const char* styles_8[3] = { "STYLE001.GRY", "STYLE002.GRY", "STYLE003.GRY" }; const char* styles_24[3] = { "STYLE001.G24", "STYLE002.G24", "STYLE003.G24" }; const char* cities[3] = { "NYC.CMP", "SANB.CMP", "MIAMI.CMP" }; @@ -142,11 +143,16 @@ void print_usage(const char* argv0) { " -M k : texture mipmaps: 0 = disable, 1 = enable" << std::endl << " -x k : scale2x sprites: 0 = disable, 1 = enable" << std::endl << " -v k : vertical sync: 0 = disable, 1 = try with SDL" << + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* #ifdef LINUX ", 2 = try with GLX" << #elif WIN32 ", 2 = try with GLW" << #endif +*/ std::endl << " -a f : anisotropic texture filtering degree: 1.0 = disabled" << std::endl << @@ -164,6 +170,10 @@ void print_usage(const char* argv0) { } void print_version_info() { + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* #define PRINT_FORMATED(spaces) std::setw(spaces) << std::left << #define PRINT_OFFSET PRINT_FORMATED(19) std::cout << PRINT_OFFSET "OpenGTA version:" << OGTA_VERSION_INFO << std::endl << @@ -222,9 +232,16 @@ void print_version_info() { PRINT_OFFSET "compiler: " << USED_GCC_VERSION << std::endl; + + */ } void parse_args(int argc, char* argv[]) { + + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* int index; int c; @@ -299,7 +316,7 @@ void parse_args(int argc, char* argv[]) { if (city_num > 2) { ERROR << "Invalid city number: " << city_num << std::endl; exit(1); - } + }*/ } void run_init(const char* prg_name) { @@ -438,8 +455,9 @@ void run_init(const char* prg_name) { // create screen screen.activate(arg_screen_w, arg_screen_h); - SDL_EnableKeyRepeat( 0, 0 ); - //SDL_EnableKeyRepeat( 100, SDL_DEFAULT_REPEAT_INTERVAL ); + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + //SDL_EnableKeyRepeat( 0, 0 ); // more setup; that requires an active screen #ifdef WITH_LUA @@ -516,6 +534,8 @@ void print_position() { } + +/* void handleKeyUp( SDL_keysym *keysym) { switch ( keysym->sym ) { case 'j': @@ -544,7 +564,7 @@ void handleKeyUp( SDL_keysym *keysym) { default: break; } -} +}*/ void draw_mapmode(); @@ -672,7 +692,6 @@ void show_gamma_config() { GUI::ScrollBar * sb = new GUI::ScrollBar(GUI::GAMMA_SCROLLBAR_ID, r); sb->color.r = sb->color.g = sb->color.b = 180; - sb->color.unused = 255; sb->innerColor.r = 250; sb->value = screen_gamma/2; sb->changeCB = GUI::ScrollBar::SC_Functor(GUI::screen_gamma_callback); @@ -722,6 +741,8 @@ void car_toggle() { } + +/* void handleKeyPress( SDL_keysym *keysym ) { GLfloat* cp = city->getCamPos(); mapPos[0] = cp[0]; mapPos[1] = cp[1]; mapPos[2] = cp[2]; @@ -822,13 +843,6 @@ void handleKeyPress( SDL_keysym *keysym ) { case SDLK_LSHIFT: toggle_player_run(); break; - /* - case SDLK_F6: - tex_flip = (tex_flip ? 0 : 1); - INFO << "flipping: " << tex_flip << std::endl; - city->setTexFlipTest(tex_flip); - break; - */ case SDLK_LCTRL: OpenGTA::LocalPlayer::Instance().getCtrl().setFireWeapon(); break; @@ -862,21 +876,9 @@ void handleKeyPress( SDL_keysym *keysym ) { break; case '9': //OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).equip(9); - /* - ped_anim -= 1; if (ped_anim < 0) ped_anim = 0; - pedAnim.firstFrameOffset = ped_anim; - INFO << "switching to sprite: " << ped_anim << std::endl; - OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).setAnimation(pedAnim); - */ break; case '0': OpenGTA::LocalPlayer::Instance().getCtrl().setActiveWeapon(0); - /* - ped_anim += 1; if (ped_anim > 200) ped_anim = 200; - pedAnim.firstFrameOffset = ped_anim; - INFO << "switching to sprite: " << ped_anim << std::endl; - OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).setAnimation(pedAnim); - */ //OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).equip(0); break; case 'w': @@ -960,7 +962,7 @@ void handleKeyPress( SDL_keysym *keysym ) { } city->setPosition(mapPos[0], mapPos[1], mapPos[2]); -} +}*/ void drawScene(Uint32 ticks) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -998,7 +1000,7 @@ void drawScene(Uint32 ticks) { num_frames_drawn += 1; glEnable(GL_DEPTH_TEST); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(OpenGL::ScreenHolder::Instance().surface); } void draw_mapmode() { @@ -1086,7 +1088,7 @@ void draw_mapmode() { } glEnable(GL_TEXTURE_2D); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(screen.surface); SDL_Delay(20); } @@ -1162,6 +1164,9 @@ void run_main() { while(!global_Done && !global_EC) { while (SDL_PollEvent(&event)) { switch(event.type) { + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + + /* case SDL_ACTIVEEVENT: if (event.active.gain == 0) paused = 1; @@ -1176,7 +1181,7 @@ void run_main() { break; case SDL_VIDEORESIZE: OpenGL::ScreenHolder::Instance().resize(event.resize.w, event.resize.h); - break; + break;*/ case SDL_QUIT: global_Done = 1; break;