├── docs ├── CREST2.jpg ├── HTML_Example.jpg ├── Browser_Output.jpg └── Browser_Output_formatted.jpg ├── HttpMessageHandler.h ├── SharedMemoryRenderer.h ├── LICENSE ├── dist ├── LICENSE ├── FAQ.txt ├── README.md └── example.json.txt ├── MongooseUtils.h ├── CREST2.sln ├── Utils.h ├── Globals.h ├── examples ├── example.html └── CREST2_Example_formatted.json ├── .gitattributes ├── .gitignore ├── CREST.vcxproj ├── CRESTServer.cpp ├── README.md ├── HttpMessageHandler.cpp ├── example.json.txt ├── include └── zconf.h ├── SharedMemory_v6.h ├── SharedMemory_v9.h ├── SharedMemory_v10.h ├── SharedMemory_v11.h └── SharedMemory_v12.h /docs/CREST2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viper4gh/CREST2-AMS2/HEAD/docs/CREST2.jpg -------------------------------------------------------------------------------- /docs/HTML_Example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viper4gh/CREST2-AMS2/HEAD/docs/HTML_Example.jpg -------------------------------------------------------------------------------- /docs/Browser_Output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viper4gh/CREST2-AMS2/HEAD/docs/Browser_Output.jpg -------------------------------------------------------------------------------- /docs/Browser_Output_formatted.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viper4gh/CREST2-AMS2/HEAD/docs/Browser_Output_formatted.jpg -------------------------------------------------------------------------------- /HttpMessageHandler.h: -------------------------------------------------------------------------------- 1 | class HttpMessageHandler { 2 | public: 3 | // No-args constructor 4 | HttpMessageHandler(); 5 | // Handles the given HTTP message, using the supplied connection 6 | // to provide output (if there is output) 7 | void handle(struct mg_connection *nc, struct http_message *hm); 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /SharedMemoryRenderer.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SharedMemory.h" 3 | 4 | class SharedMemoryRenderer { 5 | public: 6 | // No-args constructor 7 | SharedMemoryRenderer(); 8 | // Renders the shared memory into a string representation 9 | // The queryString determines which sections are rendered or not 10 | std::string render(const SharedMemory* sharedData, std::string queryString); 11 | }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Lars Rosenquist 2 | All rights reserved 3 | 4 | This software is licensed under the GNU General Public License version 2. 5 | You can redistribute it and/or modify it under the terms of the 6 | GNU General Public License version 2 as published by the Free Software Foundation. 7 | For the terms of this license, see . 8 | 9 | You are free to use this software under the terms of the GNU General 10 | Public License, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU General Public License for more details. -------------------------------------------------------------------------------- /dist/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Lars Rosenquist 2 | All rights reserved 3 | 4 | This software is licensed under the GNU General Public License version 2. 5 | You can redistribute it and/or modify it under the terms of the 6 | GNU General Public License version 2 as published by the Free Software Foundation. 7 | For the terms of this license, see . 8 | 9 | You are free to use this software under the terms of the GNU General 10 | Public License, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU General Public License for more details. -------------------------------------------------------------------------------- /MongooseUtils.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mongoose.h" 3 | 4 | class FossaUtils { 5 | public: 6 | 7 | // Returns the value of the header with the given name from the supplied HTTP message, 8 | // or empty string if no header with that name present. 9 | static std::string getHeaderValue(std::string name, struct http_message *hm) { 10 | std::string result; 11 | for (size_t i = 0; i < ARRAY_SIZE(hm->header_names); i++) { 12 | mg_str headerName = hm->header_names[i]; 13 | std::string headerNameString(headerName.p, headerName.len); 14 | 15 | if (headerNameString.compare(name) == 0) { 16 | mg_str headerValue = hm->header_values[i]; 17 | result = std::string(headerValue.p, headerValue.len); 18 | } 19 | } 20 | return result; 21 | } 22 | 23 | }; -------------------------------------------------------------------------------- /CREST2.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CREST", "CREST.vcxproj", "{0F8E15F7-8365-4955-BC62-F91558F76878}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0F8E15F7-8365-4955-BC62-F91558F76878}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {0F8E15F7-8365-4955-BC62-F91558F76878}.Debug|Win32.Build.0 = Debug|Win32 16 | {0F8E15F7-8365-4955-BC62-F91558F76878}.Release|Win32.ActiveCfg = Release|Win32 17 | {0F8E15F7-8365-4955-BC62-F91558F76878}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /dist/FAQ.txt: -------------------------------------------------------------------------------- 1 | CREST2 - CARS2 REST API v0.0.1 2 | (C) 2015 Lars Rosenquist 3 | 4 | If you are reading this file it means you have successfully downloaded and extracted CREST2! To run the application: 5 | 6 | 1. Double click the CREST2 executable file, or execute from the command line. 7 | 2. Open a browser (preferrably Chrome or Firefox) or your favorite REST or HTTP client and go to http://localhost:8180/crest2/v1/api. 8 | 9 | This should give a JSON response with a notification that Project CARS 2 is not running or Shared Memory is not enabled. So: 10 | 11 | 3. Start Project CARS 2. 12 | 4. Go to Options -> Visuals -> Hardware and enable 'Shared Memory'. 13 | 5. Repeat step 2. 14 | 6. Success! 15 | 16 | FAQ 17 | 18 | Q: When trying to run CREST, Windows complains about security and it won't start. 19 | A: I didn't sign the binary, so Windows will not allow the binary to start by default. Please allow/unblock it to allow operation. Also, always be sure to download ONLY from http://cars-rest-api.com 20 | 21 | Q: When trying to run CREST, Windows complains about missing DDLs (e.g. MSVCR120.DLL or similar) 22 | A: Download and install the Visual C++ runtime from http://www.microsoft.com/en-us/download/details.aspx?id=40784 (vcredist_x86.exe) and try again. 23 | 24 | Q: When trying to run CREST, Windows Firewall asks for network access. 25 | A: CREST needs to access the local network, or you can't access it. Please allow access. 26 | 27 | If you have any other questions or remarks, please leave me a note at one of the following: 28 | 29 | Twitter: https://twitter.com/larsrosenquist 30 | GitHub: https://github.com/NLxAROSA/CREST 31 | Email: info@bymbl.com 32 | 33 | -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | #define ZLIB_WINAPI 2 | 3 | #include 4 | #include "zlib.h" 5 | 6 | // gzip constants 7 | #define MOD_GZIP_ZLIB_WINDOWSIZE 15 8 | #define MOD_GZIP_ZLIB_CFACTOR 9 9 | #define MOD_GZIP_ZLIB_BSIZE 8096 10 | 11 | class Utils { 12 | 13 | public: 14 | 15 | // Returns true if the stringToSearch contains the stringToFind 16 | static bool contains(std::string stringToSearch, std::string stringToFind) { 17 | if (stringToSearch.compare("") > 0) { 18 | return ((int)stringToSearch.find(stringToFind) > (int)std::string::npos); 19 | }else{ 20 | return false; 21 | } 22 | } 23 | 24 | // gzips an input string with the supplied compression level 25 | static std::string gzipString(const std::string& str, int compressionlevel = Z_BEST_COMPRESSION) { 26 | z_stream zs; 27 | memset(&zs, 0, sizeof(zs)); 28 | 29 | if (deflateInit2(&zs, 30 | compressionlevel, 31 | Z_DEFLATED, 32 | MOD_GZIP_ZLIB_WINDOWSIZE + 16, 33 | MOD_GZIP_ZLIB_CFACTOR, 34 | Z_DEFAULT_STRATEGY) != Z_OK 35 | ) { 36 | throw(std::runtime_error("deflateInit2 failed while compressing.")); 37 | } 38 | 39 | zs.next_in = (Bytef*)str.data(); 40 | zs.avail_in = str.size(); 41 | 42 | int ret; 43 | char* outbuffer = new char[32768]; 44 | std::string outstring; 45 | 46 | do { 47 | zs.next_out = reinterpret_cast(outbuffer); 48 | zs.avail_out = sizeof(outbuffer); 49 | 50 | ret = deflate(&zs, Z_FINISH); 51 | 52 | if (outstring.size() < zs.total_out) { 53 | outstring.append(outbuffer, 54 | zs.total_out - outstring.size()); 55 | } 56 | } while (ret == Z_OK); 57 | 58 | deflateEnd(&zs); 59 | 60 | if (ret != Z_STREAM_END) { 61 | printf("Error during gzip compression: %s", zs.msg); 62 | } 63 | 64 | delete[] outbuffer; 65 | return outstring; 66 | } 67 | 68 | }; -------------------------------------------------------------------------------- /Globals.h: -------------------------------------------------------------------------------- 1 | /*This is not the fine way, but Global Variables are needed in multiple files, because: 2 | For implementing integrity checks like Slightly Mad recommends it in their SMS_MemMapSample.txt example, 3 | you have to copy Shared Memory data to a local copy first to reduce the possibility of reading data while pcars writes the data at the same moment, which can lead to inconsistent readed data. 4 | In the main function (CRESTServer.cpp) is the while loop where the function ns_mgr_poll() is called only, which is part of the fossa framework. 5 | The reading of the Shared Memory data happens in the HttpMessageHandler (HttpMessageHandler.cpp) renderResponse function, which runs each while loop pass. 6 | In the SMS_MemMapSample.txt example the memory for the local copy is allocated outside the while loop, because then it must be allocated only one time and the local copy data is overwritten each while loop pass only. 7 | Without global variables there are only 2 solutions: 8 | 1. Allocate memory for the local copy in the HttpMessageHandler where the reading happens, but then it happens every while loop pass and you have to allocate and free it each pass. Further you loose the local copy data between the loop passes. If something fails in one loop pass you will have no data. 9 | With a global allocated copy you will have the data in the next loop till it is overwritten with new data. In case something fails the local copy data from the the previous loop pass can be used. 10 | 2. State of the art would be to pass the local copy variable via the ns_mgr_poll() function as parameter, but then you have to customize the complete framework, because you have to change it on multiple locations in code. And if the framework should be updated or replaced later you have to customize it again. 11 | 12 | In result none of the 2 solutions makes sense in my eyes, which leads me to use global variables. 13 | 14 | Same problem for the "index" variables, because you need the updateIndex value from the prevoius while loop pass for example 15 | */ 16 | #include "sharedmemory.h" 17 | 18 | #ifndef GLOBALS_H_ 19 | #define GLOBALS_H_ 20 | extern unsigned int updateIndex; 21 | extern unsigned int indexChange; 22 | extern SharedMemory* localCopy; 23 | extern SharedMemory* localCopyTmp; 24 | extern int debug_level; //Debug Mode 25 | #endif 26 | -------------------------------------------------------------------------------- /examples/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 44 | 45 | 46 | 50 |

51 |

52 |

53 | 54 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /dist/README.md: -------------------------------------------------------------------------------- 1 | # README # 2 | 3 | # Introducing CREST2 - also known as the CARS2 REST API # 4 | 5 | This project provides a way for developers to have access to the data provided by Project CARS 2 Shared Memory in a more portable and accessible format than a mapped memory file. 6 | 7 | It's a windows native command line application (written in C++ and a fair bit of plain old C) that will act as a local web/application server and serve the data via JSON over HTTP by accessing a URL. 8 | 9 | Any web browser or HTTP client will be able to access the data both locally and inside the local network, which facilitates easy add-on development in any language (e.g. JavaScript, Java, C, C++, C#, etc. etc.) and platform (e.g. web browser, iOS, Android, Windows Phone or other) with a vast array of client REST libraries at your disposal. 10 | 11 | * See http://www.wmdportal.com/projects/project-cars-2/ for more info on Project CARS. 12 | * Latest binary download is always available at http://cars-rest-api.com/#downloads 13 | 14 | # Building from source 15 | 16 | 1. Download the source code 17 | 2. Open it up in Visual Studio 2013 18 | 19 | The project won't build without the proper setup of zlib. To properly enable zlib: 20 | 21 | 1. Download and extract the compiled zlib.dll from http://www.zlib.net 22 | 2. Follow the directions in USAGE.txt to enable it in the project. More specifically this means: 23 | 24 | * Install the supplied header files "zlib.h" and "zconf.h" into a directory found in the INCLUDE path list. 25 | * Install the supplied library file "zdll.lib" into a directory found in the LIB path list. 26 | * Add "zdll.lib" to your project. 27 | 28 | # Running CREST 29 | 30 | 1. Download the executable from our website (http://www.cars-rest-api.com) at http://cars-rest-api.com/#downloads or build it yourself. 31 | 2. Start the application by double-clicking it. 32 | 3. Windows will complain about security (coming from an unknown/unverified source) both when downloading and starting the application. Please allow/unblock the application in order to allow it to start. Windows Firewall will also ask for permission to access the local network. Please allow it access for proper functioning. 33 | 4. If Windows complains about missing DLLs (e.g. MSVCR120.DLL or similar), please download and install the Visual C++ Redistributable Packages for Visual Studio 2013 from http://www.microsoft.com/en-us/download/details.aspx?id=40784 (vcredist_x86.exe), then start again. 34 | 5. Console will show a notification about the server being up and running and display port and URL information. 35 | 36 | # Connecting to Project CARS 37 | 38 | 1. Start Project CARS. 39 | 2. Enable Shared Memory in Options -> Visual -> Hardware 40 | 3. Open up a browser (Chrome for best results) and go to http://localhost:8180/crest2/v1/api 41 | 4. Profit! F5/Refresh until you drop! 42 | 43 | Be sure to checkout the website at http://www.cars-rest-api.com as well! 44 | 45 | # Advanced usage 46 | 47 | The basic URL (http://localhost:8180/crest2/v1/api) will expose the full set of data. If parameters are added to the request URL, the set will be limited to the parameters you specify. 48 | 49 | The following parameters are available: 50 | 51 | 1. buildInfo 52 | 2. gameStates 53 | 3. participants 54 | 4. unfilteredInputs 55 | 5. vehicleInformation 56 | 6. eventInformation 57 | 7. timings 58 | 8. flags 59 | 9. pitInfo 60 | 10. carState 61 | 11. motionDeviceRelated 62 | 12. wheelsAndTyres 63 | 13. carDamage 64 | 14. weather 65 | 66 | Example: http://localhost:8180/crest2/v1/api?buildInfo=true will give you just the buildInfo. 67 | 68 | Example2: http://localhost:8180/crest2/v1/api?timings=true&carState=true&weather=true will give you timings, carState and weather. 69 | 70 | Example3: http://localhost:8180/crest2/v1/api will give you the full set. 71 | 72 | NOTE: Sections are always in the order listed, never in the order of the request parameters. 73 | 74 | # Compression 75 | 76 | CREST can gzip the response body. Just add the following header to the HTTP request: "Accept-Encoding: gzip" and CREST will gzip the response and set the "Content-Encoding: gzip" HTTP response header. Regardless of the header, CREST will not compress output if the response is smaller than 128 bytes, to prevent overhead. 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | Debug/ 5 | CREST.sdf 6 | Release/ 7 | *.sdf 8 | 9 | zlibwapi.dll 10 | lib/ 11 | 12 | # User-specific files 13 | *.suo 14 | *.user 15 | *.userosscache 16 | *.sln.docstates 17 | 18 | # User-specific files (MonoDevelop/Xamarin Studio) 19 | *.userprefs 20 | 21 | # Build results 22 | [Dd]ebug/ 23 | [Dd]ebugPublic/ 24 | [Rr]elease/ 25 | [Rr]eleases/ 26 | [Xx]64/ 27 | [Xx]86/ 28 | [Bb]uild/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | 33 | # Visual Studio 2015 cache/options directory 34 | .vs/ 35 | # Uncomment if you have tasks that create the project's static files in wwwroot 36 | #wwwroot/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # DNX 52 | project.lock.json 53 | artifacts/ 54 | 55 | *_i.c 56 | *_p.c 57 | *_i.h 58 | *.ilk 59 | *.meta 60 | *.obj 61 | *.pch 62 | *.pdb 63 | *.pgc 64 | *.pgd 65 | *.rsp 66 | *.sbr 67 | *.tlb 68 | *.tli 69 | *.tlh 70 | *.tmp 71 | *.tmp_proj 72 | *.log 73 | *.vspscc 74 | *.vssscc 75 | .builds 76 | *.pidb 77 | *.svclog 78 | *.scc 79 | 80 | # Chutzpah Test files 81 | _Chutzpah* 82 | 83 | # Visual C++ cache files 84 | ipch/ 85 | *.aps 86 | *.ncb 87 | *.opendb 88 | *.opensdf 89 | *.sdf 90 | *.cachefile 91 | *.VC.db 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | *.sap 98 | 99 | # TFS 2012 Local Workspace 100 | $tf/ 101 | 102 | # Guidance Automation Toolkit 103 | *.gpState 104 | 105 | # ReSharper is a .NET coding add-in 106 | _ReSharper*/ 107 | *.[Rr]e[Ss]harper 108 | *.DotSettings.user 109 | 110 | # JustCode is a .NET coding add-in 111 | .JustCode 112 | 113 | # TeamCity is a build add-in 114 | _TeamCity* 115 | 116 | # DotCover is a Code Coverage Tool 117 | *.dotCover 118 | 119 | # NCrunch 120 | _NCrunch_* 121 | .*crunch*.local.xml 122 | nCrunchTemp_* 123 | 124 | # MightyMoose 125 | *.mm.* 126 | AutoTest.Net/ 127 | 128 | # Web workbench (sass) 129 | .sass-cache/ 130 | 131 | # Installshield output folder 132 | [Ee]xpress/ 133 | 134 | # DocProject is a documentation generator add-in 135 | DocProject/buildhelp/ 136 | DocProject/Help/*.HxT 137 | DocProject/Help/*.HxC 138 | DocProject/Help/*.hhc 139 | DocProject/Help/*.hhk 140 | DocProject/Help/*.hhp 141 | DocProject/Help/Html2 142 | DocProject/Help/html 143 | 144 | # Click-Once directory 145 | publish/ 146 | 147 | # Publish Web Output 148 | *.[Pp]ublish.xml 149 | *.azurePubxml 150 | 151 | # TODO: Un-comment the next line if you do not want to checkin 152 | # your web deploy settings because they may include unencrypted 153 | # passwords 154 | #*.pubxml 155 | *.publishproj 156 | 157 | # NuGet Packages 158 | *.nupkg 159 | # The packages folder can be ignored because of Package Restore 160 | **/packages/* 161 | # except build/, which is used as an MSBuild target. 162 | !**/packages/build/ 163 | # Uncomment if necessary however generally it will be regenerated when needed 164 | #!**/packages/repositories.config 165 | # NuGet v3's project.json files produces more ignoreable files 166 | *.nuget.props 167 | *.nuget.targets 168 | 169 | # Microsoft Azure Build Output 170 | csx/ 171 | *.build.csdef 172 | 173 | # Microsoft Azure Emulator 174 | ecf/ 175 | rcf/ 176 | 177 | # Windows Store app package directory 178 | AppPackages/ 179 | BundleArtifacts/ 180 | 181 | # Visual Studio cache files 182 | # files ending in .cache can be ignored 183 | *.[Cc]ache 184 | # but keep track of directories ending in .cache 185 | !*.[Cc]ache/ 186 | 187 | # Others 188 | ClientBin/ 189 | [Ss]tyle[Cc]op.* 190 | ~$* 191 | *~ 192 | *.dbmdl 193 | *.dbproj.schemaview 194 | *.pfx 195 | *.publishsettings 196 | node_modules/ 197 | orleans.codegen.cs 198 | 199 | # RIA/Silverlight projects 200 | Generated_Code/ 201 | 202 | # Backup & report files from converting an old project file 203 | # to a newer Visual Studio version. Backup files are not needed, 204 | # because we have git ;-) 205 | _UpgradeReport_Files/ 206 | Backup*/ 207 | UpgradeLog*.XML 208 | UpgradeLog*.htm 209 | 210 | # SQL Server files 211 | *.mdf 212 | *.ldf 213 | 214 | # Business Intelligence projects 215 | *.rdl.data 216 | *.bim.layout 217 | *.bim_*.settings 218 | 219 | # Microsoft Fakes 220 | FakesAssemblies/ 221 | 222 | # GhostDoc plugin setting file 223 | *.GhostDoc.xml 224 | 225 | # Node.js Tools for Visual Studio 226 | .ntvs_analysis.dat 227 | 228 | # Visual Studio 6 build log 229 | *.plg 230 | 231 | # Visual Studio 6 workspace options file 232 | *.opt 233 | 234 | # Visual Studio LightSwitch build output 235 | **/*.HTMLClient/GeneratedArtifacts 236 | **/*.DesktopClient/GeneratedArtifacts 237 | **/*.DesktopClient/ModelManifest.xml 238 | **/*.Server/GeneratedArtifacts 239 | **/*.Server/ModelManifest.xml 240 | _Pvt_Extensions 241 | 242 | # LightSwitch generated files 243 | GeneratedArtifacts/ 244 | ModelManifest.xml 245 | 246 | # Paket dependency manager 247 | .paket/paket.exe 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | -------------------------------------------------------------------------------- /CREST.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0F8E15F7-8365-4955-BC62-F91558F76878} 15 | Win32Proj 16 | SMS_MapTest 17 | CREST2 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | MultiByte 25 | v142 26 | 27 | 28 | Application 29 | false 30 | true 31 | Unicode 32 | v142 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | include;$(VC_IncludePath);$(WindowsSDK_IncludePath); 47 | lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 48 | 49 | 50 | false 51 | include;$(IncludePath) 52 | lib;$(LibraryPath) 53 | 54 | 55 | 56 | 57 | 58 | Level3 59 | Disabled 60 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 61 | 62 | 63 | Console 64 | true 65 | lib\zlibwapi.lib;%(AdditionalDependencies) 66 | 67 | 68 | 69 | 70 | Level3 71 | 72 | 73 | MaxSpeed 74 | true 75 | true 76 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 77 | 78 | 79 | Console 80 | true 81 | true 82 | true 83 | lib\zlibwapi.lib;%(AdditionalDependencies) 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /CRESTServer.cpp: -------------------------------------------------------------------------------- 1 | // Dependencies 2 | #include "mongoose.h" 3 | #include 4 | #include 5 | #include 6 | #include "HttpMessageHandler.h" 7 | #include "Globals.h" 8 | #include 9 | 10 | // Configuration properties 11 | #define CREST2_VERSION "v1.0.1" 12 | #define POLL_TIME_IN_MILLIS 17 13 | // fossa definition: maximum number of milliseconds to sleep for ns_mgr_poll/ fossa calls the winsock select() function with it, where it is a timeout: 14 | // The select function returns the total number of socket handles that are ready and contained in the fd_set structures, zero if the time limit expired. 15 | // It is the maximum time for select to wait 16 | #define ESC_KEY 27 17 | #define CREST_API_URL "/crest2/v1/api" 18 | 19 | // Constants 20 | #define HTTP_RESPONSE_404 "{\r\n \"status\": \"404 Not found, please use the correct URL: " CREST_API_URL "\"\r\n}" 21 | 22 | // Server variables 23 | static const char *s_http_port_default = "8180"; 24 | static struct mg_serve_http_opts s_http_server_opts; 25 | 26 | // Variables for integrity checks, definition in Globals.h 27 | SharedMemory* localCopy; 28 | SharedMemory* localCopyTmp; 29 | unsigned int updateIndex; 30 | unsigned int indexChange; 31 | // Debug Mode 32 | int debug_level = 0; 33 | 34 | // Response generator 35 | static HttpMessageHandler httpMessageHandler = HttpMessageHandler(); 36 | 37 | // Server request handler method 38 | static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { 39 | struct http_message *hm = (struct http_message *) ev_data; 40 | 41 | switch (ev) { 42 | case MG_EV_HTTP_REQUEST: 43 | // Only handle HTTP requests on the API url 44 | if (mg_vcmp(&hm->uri, CREST_API_URL) == 0) { 45 | httpMessageHandler.handle(nc, hm); 46 | }else{ 47 | // Unknown URI, return a 404 48 | mg_printf(nc, "HTTP/1.1 404 Not found\r\n" 49 | "Content-Type: application/json\r\n" 50 | "Cache-Control: no-cache\r\n" 51 | "Access-Control-Allow-Origin: *\r\n" 52 | "Content-Length: %d\r\n\r\n%s", 53 | (int)strlen(HTTP_RESPONSE_404), HTTP_RESPONSE_404); 54 | } 55 | break; 56 | default: 57 | break; 58 | } 59 | } 60 | 61 | int main() { 62 | 63 | // Handling of command line arguments 64 | LPWSTR* szArgList; 65 | int argCount; 66 | int port = -1; 67 | int PollTimeout = -1; 68 | bool help = false; 69 | 70 | szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); 71 | 72 | for (int i = 1; i < argCount; i++) 73 | { 74 | //printf("%d: %ws\n", i, szArgList[i]); 75 | if (i + 1 != argCount) 76 | { 77 | if (wcscmp(szArgList[i], L"-p") == 0 ) 78 | { 79 | port = _wtoi(szArgList[i + 1]); 80 | 81 | } 82 | else if (wcscmp(szArgList[i], L"-t") == 0) 83 | { 84 | PollTimeout = _wtoi(szArgList[i + 1]); 85 | } 86 | } 87 | if (wcscmp(szArgList[i], L"-d") == 0) 88 | { 89 | debug_level = 1; 90 | } 91 | if (wcscmp(szArgList[i], L"-dd") == 0) 92 | { 93 | debug_level = 2; 94 | } 95 | if (wcscmp(szArgList[i], L"-h") == 0) 96 | { 97 | help = true; 98 | } 99 | } 100 | 101 | LocalFree(szArgList); 102 | // End Handling of command line arguments 103 | 104 | if (help) { 105 | printf("# CREST2 - CARS2 REST API %s\n", CREST2_VERSION); 106 | printf("# (c) 2015 Lars Rosenquist\n"); 107 | printf("# updated by Viper\n\n"); 108 | printf("Usage:\n"); 109 | printf("CREST2.exe [-p 8180] [-t 17] [-d[d]] [-h]\n"); 110 | printf(" -p TCP Port, default: 8180, allowed: 1025-65534\n"); 111 | printf(" -t Websocket Timeout im ms, default: 17, allowed: 1-10000\n"); 112 | printf(" -d Debug Level 1, show some more info for Integrity Checks\n"); 113 | printf(" -dd Debug Level 2, show more info for Integrity Checks\n"); 114 | printf(" -h Help\n"); 115 | return 0; 116 | } 117 | 118 | //convert port from int to char* 119 | std::string s = std::to_string(port); 120 | static const char* s_http_port; 121 | 122 | // set HTTP Port 123 | if (port >= 1025 && port <= 65534) { 124 | s_http_port = s.c_str(); 125 | } 126 | else { 127 | s_http_port = s_http_port_default; 128 | } 129 | 130 | // set websocket timeout for winsock select function 131 | if (PollTimeout < 1 || PollTimeout > 10000) { 132 | PollTimeout = POLL_TIME_IN_MILLIS; 133 | } 134 | 135 | // Setup the server 136 | struct mg_mgr mgr; 137 | struct mg_connection* nc; 138 | mg_mgr_init(&mgr, NULL); 139 | nc = mg_bind(&mgr, s_http_port, ev_handler); 140 | 141 | // catch error if TCP port is already in use 142 | if (nc == NULL) { 143 | printf("\n# The port %s is already in use by another application.\n# Please change it with option \"-p\" or close the other application.\n\n Press any key to exit...\n", s_http_port); 144 | // wait for user input. Without it and if the application is executed by double click or via shortcut where it opens a new window, it will close directly and the user will not see the error. 145 | while (true) { 146 | if (_kbhit()) { 147 | return 1; 148 | } 149 | } 150 | } 151 | 152 | mg_set_protocol_http_websocket(nc); 153 | s_http_server_opts.document_root = "."; 154 | 155 | // initialize globals 156 | localCopy = new SharedMemory; 157 | localCopyTmp = new SharedMemory; 158 | updateIndex = 0; 159 | indexChange = 0; 160 | 161 | // Print some information on the console 162 | printf("# CREST2 - CARS2 REST API %s\n", CREST2_VERSION); 163 | printf("# (c) 2015 Lars Rosenquist\n"); 164 | printf("# updated by Viper\n\n"); 165 | printf("# Server started on TCP port: %s\n", s_http_port); 166 | printf("# Websocket Timeout: %i ms\n", PollTimeout); 167 | if (debug_level > 0) { printf("# Debug Level: %i\n", debug_level); } 168 | printf("# API is available at http://localhost:%s%s \n", s_http_port, CREST_API_URL); 169 | printf("# Press ESC to terminate\n"); 170 | 171 | // Keep polling until ESC is hit 172 | while (true) { 173 | 174 | mg_mgr_poll(&mgr, PollTimeout); 175 | 176 | if (_kbhit() && _getch() == ESC_KEY) { 177 | break; 178 | } 179 | } 180 | 181 | // We're done, free up the server and exit 182 | mg_mgr_free(&mgr); 183 | delete localCopy; 184 | delete localCopyTmp; 185 | 186 | return 0; 187 | } 188 | -------------------------------------------------------------------------------- /examples/CREST2_Example_formatted.json: -------------------------------------------------------------------------------- 1 | { 2 | "buildinfo":{ 3 | "mVersion":10, 4 | "mBuildVersionNumber":1938 5 | }, 6 | "gameStates":{ 7 | "mGameState":2, 8 | "mSessionState":5, 9 | "mRaceState":2 10 | }, 11 | "participants":{ 12 | "mViewedParticipantIndex":0, 13 | "mNumParticipants":1, 14 | "mParticipantInfo":[ 15 | { 16 | "mIsActive":true, 17 | "mName":"M. -VIPER- Morgan", 18 | "mWorldPosition":[523.413,22.2485,-459.836], 19 | "mCurrentLapDistance":421.552, 20 | "mRacePosition":1, 21 | "mLapsCompleted":0, 22 | "mCurrentLap":1, 23 | "mCurrentSector":0, 24 | "mRaceStates":2, 25 | "mPitModes":0, 26 | "mFastestLapTimes":-123, 27 | "mLastLapTimes":-123, 28 | "mFastestSector1Times":-1, 29 | "mFastestSector2Times":-1, 30 | "mFastestSector3Times":-1, 31 | "mCurrentSector1Times":63.101, 32 | "mCurrentSector2Times":-1, 33 | "mCurrentSector3Times":-1, 34 | "mLapsInvalidated":0, 35 | "mOrientations":[-0.0020886,0.0199151,0.00828566], 36 | "mSpeeds":11.0682, 37 | "mCarNames":"Porsche 911 RSR GTE", 38 | "mCarClassNames":"GTE", 39 | "mPitSchedules":0, 40 | "mHighestFlagColours":0, 41 | "mHighestFlagReasons":0, 42 | "mNationalities":0 43 | } 44 | ] 45 | }, 46 | "unfilteredInput":{ 47 | "mUnfilteredThrottle":0.28525, 48 | "mUnfilteredBrake":0, 49 | "mUnfilteredSteering":0.00360685, 50 | "mUnfilteredClutch":0, 51 | "mJoyPad0":0, 52 | "mDPad":0 53 | }, 54 | "vehicleInformation":{ 55 | "mCarName":"Porsche 911 RSR GTE", 56 | "mCarClassName":"GTE" 57 | }, 58 | "eventInformation":{ 59 | "mLapsInEvent":6, 60 | "mSessionDuration":0, 61 | "mSessionAdditionalLaps":1, 62 | "mTrackLocation":"Road_America", 63 | "mTrackVariation":"Road_America_RC", 64 | "mTrackLength":6440.41, 65 | "mTranslatedTrackLocation":"Road America", 66 | "mTranslatedTrackVariation":"Road America" 67 | }, 68 | "timings":{ 69 | "mLapInvalidated":false, 70 | "mBestLapTime":-1, 71 | "mLastLapTime":-1, 72 | "mCurrentTime":63.101, 73 | "mSplitTimeAhead":-1, 74 | "mSplitTimeBehind":-1, 75 | "mSplitTime":0, 76 | "mEventTimeRemaining":-1, 77 | "mPersonalFastestLapTime":-1, 78 | "mWorldFastestLapTime":-1, 79 | "mCurrentSector1Time":63.101, 80 | "mCurrentSector2Time":-1, 81 | "mCurrentSector3Time":-1, 82 | "mFastestSector1Time":-1, 83 | "mFastestSector2Time":-1, 84 | "mFastestSector3Time":-1, 85 | "mPersonalFastestSector1Time":-1, 86 | "mPersonalFastestSector2Time":-1, 87 | "mPersonalFastestSector3Time":-1, 88 | "mWorldFastestSector1Time":-1, 89 | "mWorldFastestSector2Time":-1, 90 | "mWorldFastestSector3Time":-1 91 | }, 92 | "flags":{ 93 | "mHighestFlagColour":0, 94 | "mHighestFlagReason":0 95 | }, 96 | "pitInfo":{ 97 | "mPitMode":0, 98 | "mPitSchedule":0, 99 | "mEnforcedPitStopLap":0 100 | }, 101 | "carState":{ 102 | "mCarFlags":2, 103 | "mOilTempCelsius":49.3144, 104 | "mWaterTempCelsius":47.6281, 105 | "mWaterPressureKPa":109.888, 106 | "mFuelPressureKPa":58.5, 107 | "mFuelLevel":0.287643, 108 | "mFuelCapacity":101, 109 | "mSpeed":11.0682, 110 | "mRpm":3573.06, 111 | "mMaxRPM":9400, 112 | "mBrake":0, 113 | "mThrottle":0.28525, 114 | "mClutch":0, 115 | "mSteering":0.00267174, 116 | "mGear":1, 117 | "mNumGears":6, 118 | "mOdometerKM":3.65491, 119 | "mAntiLockActive":false, 120 | "mLastOpponentCollisionIndex":-1, 121 | "mLastOpponentCollisionMagnitude":0, 122 | "mBoostActive":false, 123 | "mBoostAmount":0, 124 | "mEngineSpeed":374.324, 125 | "mEngineTorque":78.9802, 126 | "mWings":[0,0.5], 127 | "mHandBrake":0, 128 | "mBrakeBias":0.43, 129 | "mTurboBoostPressure":31767.4, 130 | "mDrsState":0 131 | }, 132 | "motionAndDeviceRelated":{ 133 | "mOrientation":[-0.0020886,0.0199151,0.00828566], 134 | "mLocalVelocity":[-0.00777138,0.0594001,-11.0627], 135 | "mWorldVelocity":[-0.22848,0.0372156,-11.0604], 136 | "mAngularVelocity":[0.024259,-0.00214078,0.0320465], 137 | "mLocalAcceleration":[-0.0168934,-0.220798,-1.47667], 138 | "mWorldAcceleration":[-0.0444295,-0.223886,-1.47562], 139 | "mExtentsCentre":[-0.00563502,0.675283,0.140845] 140 | }, 141 | "wheelsAndTyres":{ 142 | "mTyreFlags":[7,7,7,7], 143 | "mTerrain":[2,2,2,2], 144 | "mTyreY":[0.0127228,0.0140176,0.0226898,0.0192668], 145 | "mTyreRPS":[-32.4319,-32.4225,-31.3527,-31.3527], 146 | "mTyreSlipSpeed":[0.535747,0.400029,0.247712,0.204694], 147 | "mTyreTemp":[55.4056,55.6436,56.3948,57.0259], 148 | "mTyreTempLeft":[55.418,55.6368,56.3431,57.1797], 149 | "mTyreTempCenter":[55.4056,55.6436,56.3948,57.0259], 150 | "mTyreTempRight":[55.3965,55.6566,56.5227,57.0057], 151 | "mTyreGrip":[0.536009,0.639977,0.767629,0.805781], 152 | "mTyreHeightAboveGround":[-0.0111708,-0.0117892,-0.0187389,-0.01795], 153 | "mTyreLateralStiffness":[0,0,0,0], 154 | "mTyreWear":[2.80142e-06,2.74181e-06,0.000343919,0.000306129], 155 | "mBrakeDamage":[0,0,0,0], 156 | "mSuspensionDamage":[0,0,0,0], 157 | "mBrakeTempCelsius":[216.371,216.377,206.712,206.725], 158 | "mTyreTreadTemp":[328.561,328.801,329.576,330.227], 159 | "mTyreLayerTemp":[321.551,321.684,322.288,322.793], 160 | "mTyreCarcassTemp":[340.218,340.238,341.492,341.523], 161 | "mTyreRimTemp":[385.065,385.072,388.592,388.601], 162 | "mTyreInternalAirTemp":[369.046,369.057,371.498,371.514], 163 | "mWheelLocalPositionY":[0.00179119,0.00301761,-0.00267652,-0.00596524], 164 | "mSuspensionTravel":[0.054764,0.0534442,0.0709439,0.0742933], 165 | "mSuspensionVelocity":[-0.00144445,-0.0246663,-0.0187101,0.0168162], 166 | "mRideHeight":[5.90482,5.51946,7.30835,7.41029], 167 | "mAirPressure":[153.698,153.703,154.72,154.726], 168 | "mTyreCompound":["Soft Slick","Soft Slick","Soft Slick","Soft Slick"] 169 | }, 170 | "carDamage":{ 171 | "mCrashState":0, 172 | "mAeroDamage":0, 173 | "mEngineDamage":0.000171006 174 | }, 175 | "weather":{ 176 | "mAmbientTemperature":16.1621, 177 | "mTrackTemperature":28.1677, 178 | "mRainDensity":0, 179 | "mWindSpeed":0.303705, 180 | "mWindDirectionX":-0.389054, 181 | "mWindDirectionY":0.2546, 182 | "mCloudBrightness":7.01078, 183 | "mSnowDensity":0 184 | }, 185 | "timestamp":1643717511325 186 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README # 2 | 3 | First of all this Repository is a copy from here: https://github.com/NLxAROSA/CREST/tree/CREST2 4 | 5 | Thanks Lars for his hard work, but he is no longer developing the project and I hope a can update it to the current Shared Memory Version. 6 | 7 | # Introducing CREST2 - also known as the CARS REST API 2# 8 | 9 | This project provides a way for developers to have access to the data provided by Automobilista 2 Shared Memory in a more portable and accessible format than a mapped memory file. 10 | 11 | It's a windows native command line application (written in C++ and a fair bit of plain old C) that will act as a local web/application server and serve the data via JSON over HTTP by accessing a URL. 12 | 13 | Any web browser or HTTP client will be able to access the data both locally and inside the local network, which facilitates easy add-on development in any language (e.g. JavaScript, Java, C, C++, C#, etc. etc.) and platform (e.g. web browser, iOS, Android, Windows Phone or other) with a vast array of client REST libraries at your disposal.\ 14 | If you want to see what you can do with it, then look here: [Liveview (also supports CREST2)](https://github.com/eckhchri/pcars-ds-liveview/blob/master/README.md) 15 | 16 | * Latest binary download is always available at https://drive.google.com/drive/folders/1dR40S7Q-3xJhEr1C8QFEd87Hs8lpV62s 17 | 18 | # Running CREST2 19 | 20 | 1. Download the zip archive from https://drive.google.com/drive/folders/1dR40S7Q-3xJhEr1C8QFEd87Hs8lpV62s and extract it, or build it yourself -> look at the topic [Building from source](#building-from-source). 21 | The archive includes the following relevant files: 22 | ``` 23 | CREST2.exe - Binary 24 | zlibwapi.dll - Library for data compression 25 | CREST2_Example.json - Example how the browser output looks like 26 | CREST2_Example_formatted.json - Example how the browser output looks like - formatted for better readability 27 | example.html - Example how you can use the API in HTML 28 | Readme.txt - Basic info how to use it 29 | ``` 30 |        There are some [screenhots](#screenshots) below, where you can see how the outputs look like. 31 | 32 | 2. Start the application by double-clicking the CREST2.exe. 33 | 3. Windows will complain about security (coming from an unknown/unverified source) both when downloading and starting the application. Please allow/unblock the application in order to allow it to start. Windows Firewall will also ask for permission to access the local network. Please allow it access for proper functioning. 34 | 4. If Windows complains about missing DLLs (e.g. MSVCR120.DLL or similar), please download and install the Visual C++ Redistributable Packages for Visual Studio 2019 from https://www.visualstudio.com/de/downloads/ (vcredist_x86.exe, scroll down to "Other Tools and Frameworks"), then start again. 35 | 5. Console will show a notification about the server being up and running and display port and URL information. 36 | 37 | # Connecting to Automobilista 2 38 | 39 | 1. Start Automobilista 2. 40 | 2. Enable Shared Memory "Project CARS2" mode in the settings 41 | 3. Open up a browser (Chrome for best results) and go to http://localhost:8180/crest2/v1/api or for better readability to http://localhost:8180/crest2/v1/api?formatted=true 42 | 4. Profit! F5/Refresh until you drop! 43 | 44 | 45 | # Advanced usage 46 | 47 | The basic URL (http://localhost:8180/crest2/v1/api) will expose the full set of data. If parameters are added to the request URL, the set will be limited to the parameters you specify. 48 | 49 | The following parameters are available: 50 | 51 | 1. buildInfo 52 | 2. gameStates 53 | 3. participants 54 | 4. unfilteredInputs 55 | 5. vehicleInformation 56 | 6. eventInformation 57 | 7. timings 58 | 8. flags 59 | 9. pitInfo 60 | 10. carState 61 | 11. motionDeviceRelated 62 | 12. wheelsAndTyres 63 | 13. carDamage 64 | 14. weather 65 | 15. formatted 66 | 67 | Example: http://localhost:8180/crest2/v1/api?buildInfo=true will give you just the buildInfo. 68 | 69 | Example2: http://localhost:8180/crest2/v1/api?timings=true&carState=true&weather=true will give you timings, carState and weather. 70 | 71 | Example3: http://localhost:8180/crest2/v1/api will give you the full set. 72 | 73 | NOTE: Sections are always in the order listed, never in the order of the request parameters. 74 | 75 | # Command Line Options 76 | ``` 77 | CREST2.exe [-p 8180] [-t 17] [-d[d]] [-h] 78 | -p TCP Port, default: 8180, allowed: 1025-65534 79 | -t Websocket Timeout im ms, default: 17, allowed: 1-10000 80 | -d Debug Level 1, show some more info for Integrity Checks 81 | -dd Debug Level 2, show more info for Integrity Checks 82 | -h Help 83 | ``` 84 | The Websocket Timeout is the timeout for the winsock select() function which is used by the Mongoose Library. It returns the number of ready socket handles. The timeout is the maximum time for the select function to wait.\ 85 | Changing the value seems to have no effect, but maybe someone finds a use case where it is relevant. 86 | 87 | # Screenshots 88 | **CREST2.exe**\ 89 | ![Screenshot](docs/CREST2.jpg) 90 | 91 | **Browser Output default (Chrome)**\ 92 | ![Screenshot](docs/Browser_Output.jpg) 93 | 94 | **Browser Output formatted (Chrome)**\ 95 | ![Screenshot](docs/Browser_Output_formatted.jpg) 96 | 97 | **HTML Example opened in Chrome**\ 98 | If you open the example.html, open the developer console and click on Request (once), you will get some selected values in the browser window and the complete object of Shared Memory data in the developer console, where you can find all variables for use in your own code.\ 99 | If you click Request (Auto Reload) the data is updated every 500 ms: 100 | ![Screenshot](docs/HTML_Example.jpg) 101 | 102 | 103 | # Compression 104 | 105 | CREST can gzip the response body. Just add the following header to the HTTP request: "Accept-Encoding: gzip" and CREST will gzip the response and set the "Content-Encoding: gzip" HTTP response header. Regardless of the header, CREST will not compress output if the response is smaller than 128 bytes, to prevent overhead. 106 | 107 | # Building from source 108 | 109 | 1. Download the source code 110 | 2. Open it up in Visual Studio 2019 111 | 112 | The project won't build without the proper setup of zlib. To properly enable zlib: 113 | 1. Download and extract the source code from http://www.zlib.net (Used http://zlib.net/zlib1211.zip) 114 | 2. Extract and open .\contrib\vstudio\vc14\zlibvc.sln with Visual Studio 115 | 3. Compile as Release and you will find 2 files in the folder .\contrib\vstudio\vc14\x86\ZlibDllRelease: 116 | - zlibwapi.lib - copy this file to the CREST2 source into the folder CREST2\lib 117 | - zlibwapi.dll - After compiling CREST2 this file must be parallel to your CREST2.exe 118 | -------------------------------------------------------------------------------- /HttpMessageHandler.cpp: -------------------------------------------------------------------------------- 1 | // Dependencies 2 | #include "HttpMessageHandler.h" 3 | #include "MongooseUtils.h" 4 | #include "SharedMemoryRenderer.h" 5 | #include "Utils.h" 6 | #include "Globals.h" 7 | #include "mongoose.h" 8 | #include 9 | #include "time.h" 10 | 11 | // Constants 12 | #define MAP_OBJECT_NAME "$pcars2$" 13 | #define HTTP_RESPONSE_503 "{\r\n \"status\": \"503 Service unavailable, is AMS2 running and is Shared Memory enabled?\"\r\n}" 14 | #define HTTP_RESPONSE_409 "{\r\n \"status\": \"409 Conflict, are CREST2 and AMS2 both at the latest version?\"\r\n}" 15 | #define GZIP_THRESHOLD 128 16 | 17 | static SharedMemoryRenderer sharedMemoryRenderer = SharedMemoryRenderer(); 18 | 19 | HttpMessageHandler::HttpMessageHandler(){}; 20 | 21 | // Outputs an HTTP 503 on the supplied connection 22 | void sendServiceUnavailable(struct mg_connection *nc) { 23 | // Send HTTP 503 24 | mg_printf(nc, "HTTP/1.1 503 Service unavailable\r\n" 25 | "Content-Type: application/json\r\n" 26 | "Cache-Control: no-cache\r\n" 27 | "Access-Control-Allow-Origin: *\r\n" 28 | "Content-Length: %d\r\n\r\n%s", 29 | (int)strlen(HTTP_RESPONSE_503), HTTP_RESPONSE_503); 30 | } 31 | 32 | // Outputs an HTTP 409 on the supplied connection 33 | void sendConflict(struct mg_connection *nc) { 34 | // Send HTTP 409 35 | mg_printf(nc, "HTTP/1.1 409 Conflict\r\n" 36 | "Content-Type: application/json\r\n" 37 | "Cache-Control: no-cache\r\n" 38 | "Access-Control-Allow-Origin: *\r\n" 39 | "Content-Length: %d\r\n\r\n%s", 40 | (int)strlen(HTTP_RESPONSE_409), HTTP_RESPONSE_409); 41 | } 42 | 43 | // Outputs an HTTP 200 on the supplied connection for an OPTIONS request 44 | void sendOptions(struct mg_connection *nc) { 45 | // Send HTTP 200 46 | mg_printf(nc, "HTTP/1.1 200 Ok\r\n" 47 | "Access-Control-Allow-Origin: *\r\n" 48 | "Access-Control-Allow-Methods: GET, OPTIONS\r\n" 49 | "Access-Control-Max-Age: 86400\r\n" 50 | "Content-Length: 0\r\n"); 51 | 52 | } 53 | 54 | // Extracts the query string from the given HTTP message 55 | std::string getQueryString(struct http_message *hm) { 56 | if (hm->query_string.len > 0) { 57 | std::string queryString (hm->query_string.p, hm->query_string.len); 58 | return queryString; 59 | }else{ 60 | return ""; 61 | } 62 | } 63 | 64 | // Extracts the request method from the given HTTP message 65 | std::string getMethod(struct http_message *hm) { 66 | if (hm->method.len > 0) { 67 | std::string requestMethod (hm->method.p, hm->method.len); 68 | return requestMethod; 69 | }else{ 70 | return ""; 71 | } 72 | } 73 | 74 | // Returns true if the response to the given HTTP message should 75 | // be gzipped, based on the value of the Accept-Encoding header 76 | // and the size of the uncompressed response 77 | bool shouldGzipResponse(struct http_message *hm, int responseLength) { 78 | return Utils::contains(FossaUtils::getHeaderValue("Accept-Encoding", hm), "gzip") && responseLength > GZIP_THRESHOLD; 79 | } 80 | 81 | // Renders the response 82 | void renderResponse(struct mg_connection *nc, const SharedMemory* sharedData, struct http_message *hm) { 83 | 84 | // get current time for debugging info 85 | char sTime[100]; 86 | time_t TimeNow = time(0); 87 | strftime(sTime, 100, "%H:%M:%S", localtime(&TimeNow)); 88 | 89 | // Odd sequence number indicates, that write into the shared memory is just happening, go on with even sequence number only 90 | if (sharedData->mSequenceNumber % 2) 91 | { 92 | // activate it for a kind of debugging mode 93 | if (debug_level > 0) { 94 | printf("%s: INFO - Odd sequence number detected - Data not accessable during write process by game\n",sTime); 95 | } 96 | } 97 | else { 98 | 99 | indexChange = sharedData->mSequenceNumber - updateIndex; 100 | updateIndex = sharedData->mSequenceNumber; 101 | 102 | //Copy the whole structure before processing it, otherwise the risk of the game writing into it during processing is too high. 103 | memcpy(localCopyTmp, sharedData, sizeof(SharedMemory)); 104 | 105 | if (localCopyTmp->mSequenceNumber != updateIndex) 106 | { 107 | // More writes had happened during the read. Should be rare, but can happen. 108 | // activate it for a kind of debugging mode 109 | if (debug_level > 0) { 110 | printf("%s: INFO - Sequence number mismatch detected - Data not accessable during write process by game\n", sTime); 111 | } 112 | 113 | } 114 | else { 115 | // At this point all checks are passed without problem and the localCopy can be updated with new data. 116 | // In all other error cases the data from the previous loop pass is used 117 | memcpy(localCopy, localCopyTmp, sizeof(SharedMemory)); 118 | } 119 | } 120 | 121 | //for debugging 122 | if (debug_level > 1) { 123 | printf("%s: INFO - Sequence number increase %d, current index %d, previous index %d\n", sTime, indexChange, localCopy->mSequenceNumber, updateIndex); 124 | } 125 | 126 | // old way with direct access to the Shared Memory data 127 | //std::string responseJson = sharedMemoryRenderer.render(sharedData, getQueryString(hm)); 128 | // new way with using the local copy data 129 | std::string responseJson = sharedMemoryRenderer.render(localCopy, getQueryString(hm)); 130 | std::string response; 131 | 132 | bool gzipResponse = shouldGzipResponse(hm, responseJson.size()); 133 | 134 | if (gzipResponse) { 135 | response = Utils::gzipString(responseJson); 136 | } 137 | else { 138 | response = responseJson; 139 | } 140 | 141 | // build HTTP OK response with JSON response body 142 | mg_printf(nc, "HTTP/1.1 200 OK\r\n" 143 | "Content-Type: application/json\r\n" 144 | "Cache-Control: no-cache\r\n" 145 | "Access-Control-Allow-Origin: *\r\n"); 146 | if (gzipResponse) { 147 | mg_printf(nc, "Content-Encoding: gzip\r\n"); 148 | } 149 | mg_printf(nc, "Content-Length: %d\r\n\r\n", 150 | (int)response.size()); 151 | mg_send(nc, response.data(), response.size()); 152 | 153 | } 154 | 155 | // Processes the shared memory 156 | void processSharedMemoryData(struct mg_connection *nc, const SharedMemory* sharedData, struct http_message *hm) { 157 | // Ensure we're sync'd to the correct data version 158 | if (sharedData->mVersion != SHARED_MEMORY_VERSION) { 159 | // build conflict response 160 | sendConflict(nc); 161 | printf("Data version mismatch, please make sure that your AMS2 version matches your CREST2 version\n Expected: v%d, Current: v%d\n", SHARED_MEMORY_VERSION, sharedData->mVersion); 162 | }else{ 163 | renderResponse(nc, sharedData, hm); 164 | } 165 | 166 | } 167 | 168 | // Processes the memory mapped file 169 | void processFile(struct mg_connection *nc, HANDLE fileHandle, struct http_message *hm) { 170 | 171 | const SharedMemory* sharedData = (SharedMemory*)MapViewOfFile(fileHandle, PAGE_READONLY, 0, 0, sizeof(SharedMemory)); 172 | 173 | if (sharedData == NULL) { 174 | // File found, but could not be mapped to shared memory data 175 | sendServiceUnavailable(nc); 176 | } 177 | else{ 178 | // Process file 179 | processSharedMemoryData(nc, sharedData, hm); 180 | // Unmap file 181 | UnmapViewOfFile(sharedData); 182 | } 183 | 184 | } 185 | 186 | void handleGet(struct mg_connection *nc, struct http_message *hm) { 187 | // Open the memory mapped file 188 | HANDLE fileHandle = OpenFileMappingA(PAGE_READONLY, FALSE, MAP_OBJECT_NAME); 189 | 190 | if (fileHandle == NULL) { 191 | // File is not available, build service unavailable response 192 | sendServiceUnavailable(nc); 193 | } 194 | else{ 195 | // File is available, process the file 196 | processFile(nc, fileHandle, hm); 197 | // Close the file 198 | CloseHandle(fileHandle); 199 | } 200 | } 201 | 202 | void HttpMessageHandler::handle(struct mg_connection *nc, struct http_message *hm) { 203 | std::string requestMethod = getMethod(hm); 204 | if (requestMethod.compare("GET") == 0) { 205 | handleGet(nc, hm); 206 | }else if (requestMethod.compare("OPTIONS") == 0) { 207 | sendOptions(nc); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /example.json.txt: -------------------------------------------------------------------------------- 1 | { 2 | "buildinfo": { 3 | "mVersion": 5, 4 | "mBuildVersionNumber": 917 5 | }, 6 | "gameStates": { 7 | "mGameState": 3, 8 | "mSessionState": 5, 9 | "mRaceState": 2 10 | }, 11 | "participants": { 12 | "mViewedParticipantIndex": 0, 13 | "mNumParticipants": 18, 14 | "mParticipantInfo": [ 15 | { 16 | "mIsActive": true, 17 | "mName": "Lars Rosenquist", 18 | "mWorldPosition": [ 19 | 197.58, 20 | 20.4255, 21 | 226.268 22 | ], 23 | "mCurrentLapDistance": 400.639, 24 | "mRacePosition": 9, 25 | "mLapsCompleted": 0, 26 | "mCurrentLap": 1, 27 | "mCurrentSector": 1 28 | }, 29 | { 30 | "mIsActive": true, 31 | "mName": "Harald Immervoll", 32 | "mWorldPosition": [ 33 | 162.489, 34 | 30.1042, 35 | 143.497 36 | ], 37 | "mCurrentLapDistance": 492.188, 38 | "mRacePosition": 5, 39 | "mLapsCompleted": 0, 40 | "mCurrentLap": 1, 41 | "mCurrentSector": 1 42 | }, 43 | { 44 | "mIsActive": true, 45 | "mName": "Ludovic Heurtin", 46 | "mWorldPosition": [ 47 | 168.241, 48 | 28.4243, 49 | 158.737 50 | ], 51 | "mCurrentLapDistance": 476.478, 52 | "mRacePosition": 6, 53 | "mLapsCompleted": 0, 54 | "mCurrentLap": 1, 55 | "mCurrentSector": 1 56 | }, 57 | { 58 | "mIsActive": true, 59 | "mName": "Umut Rasim Tuzel", 60 | "mWorldPosition": [ 61 | 153.369, 62 | 33.4117, 63 | 112.878 64 | ], 65 | "mCurrentLapDistance": 525.234, 66 | "mRacePosition": 4, 67 | "mLapsCompleted": 0, 68 | "mCurrentLap": 1, 69 | "mCurrentSector": 1 70 | }, 71 | { 72 | "mIsActive": true, 73 | "mName": "Dene Smith", 74 | "mWorldPosition": [ 75 | 146.32, 76 | 34.9527, 77 | 96.9293 78 | ], 79 | "mCurrentLapDistance": 541.869, 80 | "mRacePosition": 3, 81 | "mLapsCompleted": 0, 82 | "mCurrentLap": 1, 83 | "mCurrentSector": 1 84 | }, 85 | { 86 | "mIsActive": true, 87 | "mName": "Rene Liivanurm", 88 | "mWorldPosition": [ 89 | 239.392, 90 | 9.59027, 91 | 323.967 92 | ], 93 | "mCurrentLapDistance": 292.442, 94 | "mRacePosition": 15, 95 | "mLapsCompleted": 0, 96 | "mCurrentLap": 1, 97 | "mCurrentSector": 1 98 | }, 99 | { 100 | "mIsActive": true, 101 | "mName": "Máté Bikfalvi", 102 | "mWorldPosition": [ 103 | 205.917, 104 | 18.0611, 105 | 246.642 106 | ], 107 | "mCurrentLapDistance": 378.394, 108 | "mRacePosition": 11, 109 | "mLapsCompleted": 0, 110 | "mCurrentLap": 1, 111 | "mCurrentSector": 1 112 | }, 113 | { 114 | "mIsActive": true, 115 | "mName": "John Atkinson", 116 | "mWorldPosition": [ 117 | 237.286, 118 | 9.0823, 119 | 331.216 120 | ], 121 | "mCurrentLapDistance": 286.446, 122 | "mRacePosition": 16, 123 | "mLapsCompleted": 0, 124 | "mCurrentLap": 1, 125 | "mCurrentSector": 1 126 | }, 127 | { 128 | "mIsActive": true, 129 | "mName": "Thomas Fischer", 130 | "mWorldPosition": [ 131 | 243.353, 132 | 8.74643, 133 | 332.164 134 | ], 135 | "mCurrentLapDistance": 286.446, 136 | "mRacePosition": 17, 137 | "mLapsCompleted": 0, 138 | "mCurrentLap": 1, 139 | "mCurrentSector": 1 140 | }, 141 | { 142 | "mIsActive": true, 143 | "mName": "Jarno Perala", 144 | "mWorldPosition": [ 145 | 127.394, 146 | 41.4575, 147 | 26.1581 148 | ], 149 | "mCurrentLapDistance": 615.849, 150 | "mRacePosition": 1, 151 | "mLapsCompleted": 0, 152 | "mCurrentLap": 1, 153 | "mCurrentSector": 1 154 | }, 155 | { 156 | "mIsActive": true, 157 | "mName": "Bastien Martorell", 158 | "mWorldPosition": [ 159 | 223.67, 160 | 12.2163, 161 | 301.609 162 | ], 163 | "mCurrentLapDistance": 319.532, 164 | "mRacePosition": 13, 165 | "mLapsCompleted": 0, 166 | "mCurrentLap": 1, 167 | "mCurrentSector": 1 168 | }, 169 | { 170 | "mIsActive": true, 171 | "mName": "Aleksi Latvala", 172 | "mWorldPosition": [ 173 | 173.669, 174 | 26.9418, 175 | 171.575 176 | ], 177 | "mCurrentLapDistance": 460.66, 178 | "mRacePosition": 7, 179 | "mLapsCompleted": 0, 180 | "mCurrentLap": 1, 181 | "mCurrentSector": 1 182 | }, 183 | { 184 | "mIsActive": true, 185 | "mName": "David Batts", 186 | "mWorldPosition": [ 187 | 202.145, 188 | 19.6887, 189 | 231.965 190 | ], 191 | "mCurrentLapDistance": 395.299, 192 | "mRacePosition": 10, 193 | "mLapsCompleted": 0, 194 | "mCurrentLap": 1, 195 | "mCurrentSector": 1 196 | }, 197 | { 198 | "mIsActive": true, 199 | "mName": "Florian Faistauer", 200 | "mWorldPosition": [ 201 | 248.629, 202 | 7.82159, 203 | 342.175 204 | ], 205 | "mCurrentLapDistance": 275.079, 206 | "mRacePosition": 18, 207 | "mLapsCompleted": 0, 208 | "mCurrentLap": 1, 209 | "mCurrentSector": 1 210 | }, 211 | { 212 | "mIsActive": true, 213 | "mName": "Alex Porter", 214 | "mWorldPosition": [ 215 | 182.659, 216 | 24.5153, 217 | 191.888 218 | ], 219 | "mCurrentLapDistance": 439.385, 220 | "mRacePosition": 8, 221 | "mLapsCompleted": 0, 222 | "mCurrentLap": 1, 223 | "mCurrentSector": 1 224 | }, 225 | { 226 | "mIsActive": true, 227 | "mName": "Ivan Lewaschiw", 228 | "mWorldPosition": [ 229 | 219.573, 230 | 14.3698, 231 | 279.789 232 | ], 233 | "mCurrentLapDistance": 342.757, 234 | "mRacePosition": 12, 235 | "mLapsCompleted": 0, 236 | "mCurrentLap": 1, 237 | "mCurrentSector": 1 238 | }, 239 | { 240 | "mIsActive": true, 241 | "mName": "Kevin Gourley", 242 | "mWorldPosition": [ 243 | 149.027, 244 | 35.0537, 245 | 95.3933 246 | ], 247 | "mCurrentLapDistance": 541.869, 248 | "mRacePosition": 2, 249 | "mLapsCompleted": 0, 250 | "mCurrentLap": 1, 251 | "mCurrentSector": 1 252 | }, 253 | { 254 | "mIsActive": true, 255 | "mName": "Günthar Rowe", 256 | "mWorldPosition": [ 257 | 232.777, 258 | 11.0543, 259 | 310.359 260 | ], 261 | "mCurrentLapDistance": 308.367, 262 | "mRacePosition": 14, 263 | "mLapsCompleted": 0, 264 | "mCurrentLap": 1, 265 | "mCurrentSector": 1 266 | } 267 | ] 268 | }, 269 | "unfilteredInput": { 270 | "mUnfilteredThrottle": 1, 271 | "mUnfilteredBrake": 0, 272 | "mUnfilteredSteering": 0, 273 | "mUnfilteredClutch": 0 274 | }, 275 | "vehicleInformation": { 276 | "mCarName": "Renault Megane R.S. 265", 277 | "mCarClassName": "Road C2" 278 | }, 279 | "eventInformation": { 280 | "mLapsInEvent": 10, 281 | "mTrackLocation": "Azure Circuit", 282 | "mTrackVariation": "Grand Prix", 283 | "mTrackLength": 3325.76 284 | }, 285 | "timings": { 286 | "mLapInvalidated": false, 287 | "mBestLapTime": -1, 288 | "mLastLapTime": -1, 289 | "mCurrentTime": 25.231, 290 | "mSplitTimeAhead": 1.02798, 291 | "mSplitTimeBehind": 0.194626, 292 | "mSplitTime": 0, 293 | "mEventTimeRemaining": -1, 294 | "mPersonalFastestLapTime": -1, 295 | "mWorldFastestLapTime": 115.046, 296 | "mCurrentSector1Time": -1, 297 | "mCurrentSector2Time": -1, 298 | "mCurrentSector3Time": -1, 299 | "mFastestSector1Time": -1, 300 | "mFastestSector2Time": -1, 301 | "mFastestSector3Time": -1, 302 | "mPersonalFastestSector1Time": -1, 303 | "mPersonalFastestSector2Time": -1, 304 | "mPersonalFastestSector3Time": -1, 305 | "mWorldFastestSector1Time": 33.497, 306 | "mWorldFastestSector2Time": 40.074, 307 | "mWorldFastestSector3Time": 41.475 308 | }, 309 | "flags": { 310 | "mHighestFlagColour": 0, 311 | "mHighestFlagReason": 0 312 | }, 313 | "pitInfo": { 314 | "mPitMode": 0, 315 | "mPitSchedule": 0 316 | }, 317 | "carState": { 318 | "mCarFlags": 2, 319 | "mOilTempCelsius": 52.7033, 320 | "mWaterTempCelsius": 49.0548, 321 | "mWaterPressureKPa": 182.547, 322 | "mFuelPressureKPa": 58.5, 323 | "mFuelLevel": 0.391907, 324 | "mFuelCapacity": 60, 325 | "mSpeed": 32.9303, 326 | "mRpm": 5871.44, 327 | "mMaxRPM": 6500, 328 | "mBrake": 0, 329 | "mThrottle": 1, 330 | "mClutch": 0, 331 | "mSteering": -0.0000142459, 332 | "mGear": 3, 333 | "mNumGears": 6, 334 | "mOdometerKM": 58.2071, 335 | "mAntiLockActive": false, 336 | "mLastOpponentCollisionIndex": -1, 337 | "mLastOpponentCollisionMagnitude": 0, 338 | "mBoostActive": false, 339 | "mBoostAmount": 0 340 | }, 341 | "motionAndDeviceRelated": { 342 | "mOrientation": [ 343 | 0.117326, 344 | 0.328209, 345 | 0.000313204 346 | ], 347 | "mLocalVelocity": [ 348 | -0.00461388, 349 | -0.290465, 350 | -32.9289 351 | ], 352 | "mWorldVelocity": [ 353 | -10.5572, 354 | 3.56614, 355 | -30.9876 356 | ], 357 | "mAngularVelocity": [ 358 | -0.00724832, 359 | 0.0010549, 360 | 0.00358948 361 | ], 362 | "mLocalAcceleration": [ 363 | 0.0248438, 364 | 0.194704, 365 | -2.17865 366 | ], 367 | "mWorldAcceleration": [ 368 | -0.666669, 369 | 0.4484, 370 | -2.03459 371 | ], 372 | "mExtentsCentre": [ 373 | -0.00000500679, 374 | 0.790445, 375 | -0.0407101 376 | ] 377 | }, 378 | "wheelsAndTyres": { 379 | "mTyreFlags": [ 380 | 7, 381 | 7, 382 | 7, 383 | 7 384 | ], 385 | "mTerrain": [ 386 | 0, 387 | 0, 388 | 0, 389 | 0 390 | ], 391 | "mTyreY": [ 392 | 0.0782597, 393 | 0.0768357, 394 | 0.095097, 395 | 0.0931077 396 | ], 397 | "mTyreRPS": [ 398 | -105.846, 399 | -105.864, 400 | -101.137, 401 | -101.143 402 | ], 403 | "mTyreSlipSpeed": [ 404 | 1.34283, 405 | 1.36286, 406 | 0.199473, 407 | 0.152253 408 | ], 409 | "mTyreTemp": [ 410 | 68.5149, 411 | 67.8133, 412 | 65.189, 413 | 65.1095 414 | ], 415 | "mTyreGrip": [ 416 | 0.644026, 417 | 0.634983, 418 | 0.933223, 419 | 0.948769 420 | ], 421 | "mTyreHeightAboveGround": [ 422 | -0.0149067, 423 | -0.0127458, 424 | -0.0095718, 425 | -0.00830468 426 | ], 427 | "mTyreLateralStiffness": [ 428 | 250000, 429 | 250000, 430 | 250000, 431 | 250000 432 | ], 433 | "mTyreWear": [ 434 | 0.00380903, 435 | 0.00269157, 436 | 0.000451088, 437 | 0.000247836 438 | ], 439 | "mBrakeDamage": [ 440 | 0, 441 | 0, 442 | 0, 443 | 0 444 | ], 445 | "mSuspensionDamage": [ 446 | 0, 447 | 0, 448 | 0, 449 | 0 450 | ], 451 | "mBrakeTempCelsius": [ 452 | 295.939, 453 | 291.019, 454 | 293.714, 455 | 290.159 456 | ], 457 | "mTyreTreadTemp": [ 458 | 341.801, 459 | 341.19, 460 | 338.399, 461 | 338.32 462 | ], 463 | "mTyreLayerTemp": [ 464 | 346.098, 465 | 341.062, 466 | 325.991, 467 | 324.604 468 | ], 469 | "mTyreCarcassTemp": [ 470 | 349.172, 471 | 347.887, 472 | 345.994, 473 | 345.379 474 | ], 475 | "mTyreRimTemp": [ 476 | 353.915, 477 | 353.854, 478 | 356.897, 479 | 356.825 480 | ], 481 | "mTyreInternalAirTemp": [ 482 | 350.446, 483 | 349.533, 484 | 349.373, 485 | 348.919 486 | ] 487 | }, 488 | "carDamage": { 489 | "mCrashState": 0, 490 | "mAeroDamage": 0, 491 | "mEngineDamage": 1.19209e-7 492 | }, 493 | "weather": { 494 | "mAmbientTemperature": 24.3459, 495 | "mTrackTemperature": 34.5188, 496 | "mRainDensity": 0, 497 | "mWindSpeed": 9.17293, 498 | "mWindDirectionX": 0.707107, 499 | "mWindDirectionY": -0.707107, 500 | "mCloudBrightness": 2.61409 501 | } 502 | } -------------------------------------------------------------------------------- /dist/example.json.txt: -------------------------------------------------------------------------------- 1 | { 2 | "buildinfo": { 3 | "mVersion": 5, 4 | "mBuildVersionNumber": 917 5 | }, 6 | "gameStates": { 7 | "mGameState": 3, 8 | "mSessionState": 5, 9 | "mRaceState": 2 10 | }, 11 | "participants": { 12 | "mViewedParticipantIndex": 0, 13 | "mNumParticipants": 18, 14 | "mParticipantInfo": [ 15 | { 16 | "mIsActive": true, 17 | "mName": "Lars Rosenquist", 18 | "mWorldPosition": [ 19 | 197.58, 20 | 20.4255, 21 | 226.268 22 | ], 23 | "mCurrentLapDistance": 400.639, 24 | "mRacePosition": 9, 25 | "mLapsCompleted": 0, 26 | "mCurrentLap": 1, 27 | "mCurrentSector": 1 28 | }, 29 | { 30 | "mIsActive": true, 31 | "mName": "Harald Immervoll", 32 | "mWorldPosition": [ 33 | 162.489, 34 | 30.1042, 35 | 143.497 36 | ], 37 | "mCurrentLapDistance": 492.188, 38 | "mRacePosition": 5, 39 | "mLapsCompleted": 0, 40 | "mCurrentLap": 1, 41 | "mCurrentSector": 1 42 | }, 43 | { 44 | "mIsActive": true, 45 | "mName": "Ludovic Heurtin", 46 | "mWorldPosition": [ 47 | 168.241, 48 | 28.4243, 49 | 158.737 50 | ], 51 | "mCurrentLapDistance": 476.478, 52 | "mRacePosition": 6, 53 | "mLapsCompleted": 0, 54 | "mCurrentLap": 1, 55 | "mCurrentSector": 1 56 | }, 57 | { 58 | "mIsActive": true, 59 | "mName": "Umut Rasim Tuzel", 60 | "mWorldPosition": [ 61 | 153.369, 62 | 33.4117, 63 | 112.878 64 | ], 65 | "mCurrentLapDistance": 525.234, 66 | "mRacePosition": 4, 67 | "mLapsCompleted": 0, 68 | "mCurrentLap": 1, 69 | "mCurrentSector": 1 70 | }, 71 | { 72 | "mIsActive": true, 73 | "mName": "Dene Smith", 74 | "mWorldPosition": [ 75 | 146.32, 76 | 34.9527, 77 | 96.9293 78 | ], 79 | "mCurrentLapDistance": 541.869, 80 | "mRacePosition": 3, 81 | "mLapsCompleted": 0, 82 | "mCurrentLap": 1, 83 | "mCurrentSector": 1 84 | }, 85 | { 86 | "mIsActive": true, 87 | "mName": "Rene Liivanurm", 88 | "mWorldPosition": [ 89 | 239.392, 90 | 9.59027, 91 | 323.967 92 | ], 93 | "mCurrentLapDistance": 292.442, 94 | "mRacePosition": 15, 95 | "mLapsCompleted": 0, 96 | "mCurrentLap": 1, 97 | "mCurrentSector": 1 98 | }, 99 | { 100 | "mIsActive": true, 101 | "mName": "Máté Bikfalvi", 102 | "mWorldPosition": [ 103 | 205.917, 104 | 18.0611, 105 | 246.642 106 | ], 107 | "mCurrentLapDistance": 378.394, 108 | "mRacePosition": 11, 109 | "mLapsCompleted": 0, 110 | "mCurrentLap": 1, 111 | "mCurrentSector": 1 112 | }, 113 | { 114 | "mIsActive": true, 115 | "mName": "John Atkinson", 116 | "mWorldPosition": [ 117 | 237.286, 118 | 9.0823, 119 | 331.216 120 | ], 121 | "mCurrentLapDistance": 286.446, 122 | "mRacePosition": 16, 123 | "mLapsCompleted": 0, 124 | "mCurrentLap": 1, 125 | "mCurrentSector": 1 126 | }, 127 | { 128 | "mIsActive": true, 129 | "mName": "Thomas Fischer", 130 | "mWorldPosition": [ 131 | 243.353, 132 | 8.74643, 133 | 332.164 134 | ], 135 | "mCurrentLapDistance": 286.446, 136 | "mRacePosition": 17, 137 | "mLapsCompleted": 0, 138 | "mCurrentLap": 1, 139 | "mCurrentSector": 1 140 | }, 141 | { 142 | "mIsActive": true, 143 | "mName": "Jarno Perala", 144 | "mWorldPosition": [ 145 | 127.394, 146 | 41.4575, 147 | 26.1581 148 | ], 149 | "mCurrentLapDistance": 615.849, 150 | "mRacePosition": 1, 151 | "mLapsCompleted": 0, 152 | "mCurrentLap": 1, 153 | "mCurrentSector": 1 154 | }, 155 | { 156 | "mIsActive": true, 157 | "mName": "Bastien Martorell", 158 | "mWorldPosition": [ 159 | 223.67, 160 | 12.2163, 161 | 301.609 162 | ], 163 | "mCurrentLapDistance": 319.532, 164 | "mRacePosition": 13, 165 | "mLapsCompleted": 0, 166 | "mCurrentLap": 1, 167 | "mCurrentSector": 1 168 | }, 169 | { 170 | "mIsActive": true, 171 | "mName": "Aleksi Latvala", 172 | "mWorldPosition": [ 173 | 173.669, 174 | 26.9418, 175 | 171.575 176 | ], 177 | "mCurrentLapDistance": 460.66, 178 | "mRacePosition": 7, 179 | "mLapsCompleted": 0, 180 | "mCurrentLap": 1, 181 | "mCurrentSector": 1 182 | }, 183 | { 184 | "mIsActive": true, 185 | "mName": "David Batts", 186 | "mWorldPosition": [ 187 | 202.145, 188 | 19.6887, 189 | 231.965 190 | ], 191 | "mCurrentLapDistance": 395.299, 192 | "mRacePosition": 10, 193 | "mLapsCompleted": 0, 194 | "mCurrentLap": 1, 195 | "mCurrentSector": 1 196 | }, 197 | { 198 | "mIsActive": true, 199 | "mName": "Florian Faistauer", 200 | "mWorldPosition": [ 201 | 248.629, 202 | 7.82159, 203 | 342.175 204 | ], 205 | "mCurrentLapDistance": 275.079, 206 | "mRacePosition": 18, 207 | "mLapsCompleted": 0, 208 | "mCurrentLap": 1, 209 | "mCurrentSector": 1 210 | }, 211 | { 212 | "mIsActive": true, 213 | "mName": "Alex Porter", 214 | "mWorldPosition": [ 215 | 182.659, 216 | 24.5153, 217 | 191.888 218 | ], 219 | "mCurrentLapDistance": 439.385, 220 | "mRacePosition": 8, 221 | "mLapsCompleted": 0, 222 | "mCurrentLap": 1, 223 | "mCurrentSector": 1 224 | }, 225 | { 226 | "mIsActive": true, 227 | "mName": "Ivan Lewaschiw", 228 | "mWorldPosition": [ 229 | 219.573, 230 | 14.3698, 231 | 279.789 232 | ], 233 | "mCurrentLapDistance": 342.757, 234 | "mRacePosition": 12, 235 | "mLapsCompleted": 0, 236 | "mCurrentLap": 1, 237 | "mCurrentSector": 1 238 | }, 239 | { 240 | "mIsActive": true, 241 | "mName": "Kevin Gourley", 242 | "mWorldPosition": [ 243 | 149.027, 244 | 35.0537, 245 | 95.3933 246 | ], 247 | "mCurrentLapDistance": 541.869, 248 | "mRacePosition": 2, 249 | "mLapsCompleted": 0, 250 | "mCurrentLap": 1, 251 | "mCurrentSector": 1 252 | }, 253 | { 254 | "mIsActive": true, 255 | "mName": "Günthar Rowe", 256 | "mWorldPosition": [ 257 | 232.777, 258 | 11.0543, 259 | 310.359 260 | ], 261 | "mCurrentLapDistance": 308.367, 262 | "mRacePosition": 14, 263 | "mLapsCompleted": 0, 264 | "mCurrentLap": 1, 265 | "mCurrentSector": 1 266 | } 267 | ] 268 | }, 269 | "unfilteredInput": { 270 | "mUnfilteredThrottle": 1, 271 | "mUnfilteredBrake": 0, 272 | "mUnfilteredSteering": 0, 273 | "mUnfilteredClutch": 0 274 | }, 275 | "vehicleInformation": { 276 | "mCarName": "Renault Megane R.S. 265", 277 | "mCarClassName": "Road C2" 278 | }, 279 | "eventInformation": { 280 | "mLapsInEvent": 10, 281 | "mTrackLocation": "Azure Circuit", 282 | "mTrackVariation": "Grand Prix", 283 | "mTrackLength": 3325.76 284 | }, 285 | "timings": { 286 | "mLapInvalidated": false, 287 | "mBestLapTime": -1, 288 | "mLastLapTime": -1, 289 | "mCurrentTime": 25.231, 290 | "mSplitTimeAhead": 1.02798, 291 | "mSplitTimeBehind": 0.194626, 292 | "mSplitTime": 0, 293 | "mEventTimeRemaining": -1, 294 | "mPersonalFastestLapTime": -1, 295 | "mWorldFastestLapTime": 115.046, 296 | "mCurrentSector1Time": -1, 297 | "mCurrentSector2Time": -1, 298 | "mCurrentSector3Time": -1, 299 | "mFastestSector1Time": -1, 300 | "mFastestSector2Time": -1, 301 | "mFastestSector3Time": -1, 302 | "mPersonalFastestSector1Time": -1, 303 | "mPersonalFastestSector2Time": -1, 304 | "mPersonalFastestSector3Time": -1, 305 | "mWorldFastestSector1Time": 33.497, 306 | "mWorldFastestSector2Time": 40.074, 307 | "mWorldFastestSector3Time": 41.475 308 | }, 309 | "flags": { 310 | "mHighestFlagColour": 0, 311 | "mHighestFlagReason": 0 312 | }, 313 | "pitInfo": { 314 | "mPitMode": 0, 315 | "mPitSchedule": 0 316 | }, 317 | "carState": { 318 | "mCarFlags": 2, 319 | "mOilTempCelsius": 52.7033, 320 | "mWaterTempCelsius": 49.0548, 321 | "mWaterPressureKPa": 182.547, 322 | "mFuelPressureKPa": 58.5, 323 | "mFuelLevel": 0.391907, 324 | "mFuelCapacity": 60, 325 | "mSpeed": 32.9303, 326 | "mRpm": 5871.44, 327 | "mMaxRPM": 6500, 328 | "mBrake": 0, 329 | "mThrottle": 1, 330 | "mClutch": 0, 331 | "mSteering": -0.0000142459, 332 | "mGear": 3, 333 | "mNumGears": 6, 334 | "mOdometerKM": 58.2071, 335 | "mAntiLockActive": false, 336 | "mLastOpponentCollisionIndex": -1, 337 | "mLastOpponentCollisionMagnitude": 0, 338 | "mBoostActive": false, 339 | "mBoostAmount": 0 340 | }, 341 | "motionAndDeviceRelated": { 342 | "mOrientation": [ 343 | 0.117326, 344 | 0.328209, 345 | 0.000313204 346 | ], 347 | "mLocalVelocity": [ 348 | -0.00461388, 349 | -0.290465, 350 | -32.9289 351 | ], 352 | "mWorldVelocity": [ 353 | -10.5572, 354 | 3.56614, 355 | -30.9876 356 | ], 357 | "mAngularVelocity": [ 358 | -0.00724832, 359 | 0.0010549, 360 | 0.00358948 361 | ], 362 | "mLocalAcceleration": [ 363 | 0.0248438, 364 | 0.194704, 365 | -2.17865 366 | ], 367 | "mWorldAcceleration": [ 368 | -0.666669, 369 | 0.4484, 370 | -2.03459 371 | ], 372 | "mExtentsCentre": [ 373 | -0.00000500679, 374 | 0.790445, 375 | -0.0407101 376 | ] 377 | }, 378 | "wheelsAndTyres": { 379 | "mTyreFlags": [ 380 | 7, 381 | 7, 382 | 7, 383 | 7 384 | ], 385 | "mTerrain": [ 386 | 0, 387 | 0, 388 | 0, 389 | 0 390 | ], 391 | "mTyreY": [ 392 | 0.0782597, 393 | 0.0768357, 394 | 0.095097, 395 | 0.0931077 396 | ], 397 | "mTyreRPS": [ 398 | -105.846, 399 | -105.864, 400 | -101.137, 401 | -101.143 402 | ], 403 | "mTyreSlipSpeed": [ 404 | 1.34283, 405 | 1.36286, 406 | 0.199473, 407 | 0.152253 408 | ], 409 | "mTyreTemp": [ 410 | 68.5149, 411 | 67.8133, 412 | 65.189, 413 | 65.1095 414 | ], 415 | "mTyreGrip": [ 416 | 0.644026, 417 | 0.634983, 418 | 0.933223, 419 | 0.948769 420 | ], 421 | "mTyreHeightAboveGround": [ 422 | -0.0149067, 423 | -0.0127458, 424 | -0.0095718, 425 | -0.00830468 426 | ], 427 | "mTyreLateralStiffness": [ 428 | 250000, 429 | 250000, 430 | 250000, 431 | 250000 432 | ], 433 | "mTyreWear": [ 434 | 0.00380903, 435 | 0.00269157, 436 | 0.000451088, 437 | 0.000247836 438 | ], 439 | "mBrakeDamage": [ 440 | 0, 441 | 0, 442 | 0, 443 | 0 444 | ], 445 | "mSuspensionDamage": [ 446 | 0, 447 | 0, 448 | 0, 449 | 0 450 | ], 451 | "mBrakeTempCelsius": [ 452 | 295.939, 453 | 291.019, 454 | 293.714, 455 | 290.159 456 | ], 457 | "mTyreTreadTemp": [ 458 | 341.801, 459 | 341.19, 460 | 338.399, 461 | 338.32 462 | ], 463 | "mTyreLayerTemp": [ 464 | 346.098, 465 | 341.062, 466 | 325.991, 467 | 324.604 468 | ], 469 | "mTyreCarcassTemp": [ 470 | 349.172, 471 | 347.887, 472 | 345.994, 473 | 345.379 474 | ], 475 | "mTyreRimTemp": [ 476 | 353.915, 477 | 353.854, 478 | 356.897, 479 | 356.825 480 | ], 481 | "mTyreInternalAirTemp": [ 482 | 350.446, 483 | 349.533, 484 | 349.373, 485 | 348.919 486 | ] 487 | }, 488 | "carDamage": { 489 | "mCrashState": 0, 490 | "mAeroDamage": 0, 491 | "mEngineDamage": 1.19209e-7 492 | }, 493 | "weather": { 494 | "mAmbientTemperature": 24.3459, 495 | "mTrackTemperature": 34.5188, 496 | "mRainDensity": 0, 497 | "mWindSpeed": 9.17293, 498 | "mWindDirectionX": 0.707107, 499 | "mWindDirectionY": -0.707107, 500 | "mCloudBrightness": 2.61409 501 | } 502 | } -------------------------------------------------------------------------------- /include/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 15 | * this permanently in zconf.h using "./configure --zprefix". 16 | */ 17 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 18 | # define Z_PREFIX_SET 19 | 20 | /* all linked symbols */ 21 | # define _dist_code z__dist_code 22 | # define _length_code z__length_code 23 | # define _tr_align z__tr_align 24 | # define _tr_flush_bits z__tr_flush_bits 25 | # define _tr_flush_block z__tr_flush_block 26 | # define _tr_init z__tr_init 27 | # define _tr_stored_block z__tr_stored_block 28 | # define _tr_tally z__tr_tally 29 | # define adler32 z_adler32 30 | # define adler32_combine z_adler32_combine 31 | # define adler32_combine64 z_adler32_combine64 32 | # ifndef Z_SOLO 33 | # define compress z_compress 34 | # define compress2 z_compress2 35 | # define compressBound z_compressBound 36 | # endif 37 | # define crc32 z_crc32 38 | # define crc32_combine z_crc32_combine 39 | # define crc32_combine64 z_crc32_combine64 40 | # define deflate z_deflate 41 | # define deflateBound z_deflateBound 42 | # define deflateCopy z_deflateCopy 43 | # define deflateEnd z_deflateEnd 44 | # define deflateInit2_ z_deflateInit2_ 45 | # define deflateInit_ z_deflateInit_ 46 | # define deflateParams z_deflateParams 47 | # define deflatePending z_deflatePending 48 | # define deflatePrime z_deflatePrime 49 | # define deflateReset z_deflateReset 50 | # define deflateResetKeep z_deflateResetKeep 51 | # define deflateSetDictionary z_deflateSetDictionary 52 | # define deflateSetHeader z_deflateSetHeader 53 | # define deflateTune z_deflateTune 54 | # define deflate_copyright z_deflate_copyright 55 | # define get_crc_table z_get_crc_table 56 | # ifndef Z_SOLO 57 | # define gz_error z_gz_error 58 | # define gz_intmax z_gz_intmax 59 | # define gz_strwinerror z_gz_strwinerror 60 | # define gzbuffer z_gzbuffer 61 | # define gzclearerr z_gzclearerr 62 | # define gzclose z_gzclose 63 | # define gzclose_r z_gzclose_r 64 | # define gzclose_w z_gzclose_w 65 | # define gzdirect z_gzdirect 66 | # define gzdopen z_gzdopen 67 | # define gzeof z_gzeof 68 | # define gzerror z_gzerror 69 | # define gzflush z_gzflush 70 | # define gzgetc z_gzgetc 71 | # define gzgetc_ z_gzgetc_ 72 | # define gzgets z_gzgets 73 | # define gzoffset z_gzoffset 74 | # define gzoffset64 z_gzoffset64 75 | # define gzopen z_gzopen 76 | # define gzopen64 z_gzopen64 77 | # ifdef _WIN32 78 | # define gzopen_w z_gzopen_w 79 | # endif 80 | # define gzprintf z_gzprintf 81 | # define gzvprintf z_gzvprintf 82 | # define gzputc z_gzputc 83 | # define gzputs z_gzputs 84 | # define gzread z_gzread 85 | # define gzrewind z_gzrewind 86 | # define gzseek z_gzseek 87 | # define gzseek64 z_gzseek64 88 | # define gzsetparams z_gzsetparams 89 | # define gztell z_gztell 90 | # define gztell64 z_gztell64 91 | # define gzungetc z_gzungetc 92 | # define gzwrite z_gzwrite 93 | # endif 94 | # define inflate z_inflate 95 | # define inflateBack z_inflateBack 96 | # define inflateBackEnd z_inflateBackEnd 97 | # define inflateBackInit_ z_inflateBackInit_ 98 | # define inflateCopy z_inflateCopy 99 | # define inflateEnd z_inflateEnd 100 | # define inflateGetHeader z_inflateGetHeader 101 | # define inflateInit2_ z_inflateInit2_ 102 | # define inflateInit_ z_inflateInit_ 103 | # define inflateMark z_inflateMark 104 | # define inflatePrime z_inflatePrime 105 | # define inflateReset z_inflateReset 106 | # define inflateReset2 z_inflateReset2 107 | # define inflateSetDictionary z_inflateSetDictionary 108 | # define inflateGetDictionary z_inflateGetDictionary 109 | # define inflateSync z_inflateSync 110 | # define inflateSyncPoint z_inflateSyncPoint 111 | # define inflateUndermine z_inflateUndermine 112 | # define inflateResetKeep z_inflateResetKeep 113 | # define inflate_copyright z_inflate_copyright 114 | # define inflate_fast z_inflate_fast 115 | # define inflate_table z_inflate_table 116 | # ifndef Z_SOLO 117 | # define uncompress z_uncompress 118 | # endif 119 | # define zError z_zError 120 | # ifndef Z_SOLO 121 | # define zcalloc z_zcalloc 122 | # define zcfree z_zcfree 123 | # endif 124 | # define zlibCompileFlags z_zlibCompileFlags 125 | # define zlibVersion z_zlibVersion 126 | 127 | /* all zlib typedefs in zlib.h and zconf.h */ 128 | # define Byte z_Byte 129 | # define Bytef z_Bytef 130 | # define alloc_func z_alloc_func 131 | # define charf z_charf 132 | # define free_func z_free_func 133 | # ifndef Z_SOLO 134 | # define gzFile z_gzFile 135 | # endif 136 | # define gz_header z_gz_header 137 | # define gz_headerp z_gz_headerp 138 | # define in_func z_in_func 139 | # define intf z_intf 140 | # define out_func z_out_func 141 | # define uInt z_uInt 142 | # define uIntf z_uIntf 143 | # define uLong z_uLong 144 | # define uLongf z_uLongf 145 | # define voidp z_voidp 146 | # define voidpc z_voidpc 147 | # define voidpf z_voidpf 148 | 149 | /* all zlib structs in zlib.h and zconf.h */ 150 | # define gz_header_s z_gz_header_s 151 | # define internal_state z_internal_state 152 | 153 | #endif 154 | 155 | #if defined(__MSDOS__) && !defined(MSDOS) 156 | # define MSDOS 157 | #endif 158 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 159 | # define OS2 160 | #endif 161 | #if defined(_WINDOWS) && !defined(WINDOWS) 162 | # define WINDOWS 163 | #endif 164 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 165 | # ifndef WIN32 166 | # define WIN32 167 | # endif 168 | #endif 169 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 170 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 171 | # ifndef SYS16BIT 172 | # define SYS16BIT 173 | # endif 174 | # endif 175 | #endif 176 | 177 | /* 178 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 179 | * than 64k bytes at a time (needed on systems with 16-bit int). 180 | */ 181 | #ifdef SYS16BIT 182 | # define MAXSEG_64K 183 | #endif 184 | #ifdef MSDOS 185 | # define UNALIGNED_OK 186 | #endif 187 | 188 | #ifdef __STDC_VERSION__ 189 | # ifndef STDC 190 | # define STDC 191 | # endif 192 | # if __STDC_VERSION__ >= 199901L 193 | # ifndef STDC99 194 | # define STDC99 195 | # endif 196 | # endif 197 | #endif 198 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 199 | # define STDC 200 | #endif 201 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 202 | # define STDC 203 | #endif 204 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 205 | # define STDC 206 | #endif 207 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 208 | # define STDC 209 | #endif 210 | 211 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 212 | # define STDC 213 | #endif 214 | 215 | #ifndef STDC 216 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 217 | # define const /* note: need a more gentle solution here */ 218 | # endif 219 | #endif 220 | 221 | #if defined(ZLIB_CONST) && !defined(z_const) 222 | # define z_const const 223 | #else 224 | # define z_const 225 | #endif 226 | 227 | /* Some Mac compilers merge all .h files incorrectly: */ 228 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 229 | # define NO_DUMMY_DECL 230 | #endif 231 | 232 | /* Maximum value for memLevel in deflateInit2 */ 233 | #ifndef MAX_MEM_LEVEL 234 | # ifdef MAXSEG_64K 235 | # define MAX_MEM_LEVEL 8 236 | # else 237 | # define MAX_MEM_LEVEL 9 238 | # endif 239 | #endif 240 | 241 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 242 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 243 | * created by gzip. (Files created by minigzip can still be extracted by 244 | * gzip.) 245 | */ 246 | #ifndef MAX_WBITS 247 | # define MAX_WBITS 15 /* 32K LZ77 window */ 248 | #endif 249 | 250 | /* The memory requirements for deflate are (in bytes): 251 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 252 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 253 | plus a few kilobytes for small objects. For example, if you want to reduce 254 | the default memory requirements from 256K to 128K, compile with 255 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 256 | Of course this will generally degrade compression (there's no free lunch). 257 | 258 | The memory requirements for inflate are (in bytes) 1 << windowBits 259 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 260 | for small objects. 261 | */ 262 | 263 | /* Type declarations */ 264 | 265 | #ifndef OF /* function prototypes */ 266 | # ifdef STDC 267 | # define OF(args) args 268 | # else 269 | # define OF(args) () 270 | # endif 271 | #endif 272 | 273 | #ifndef Z_ARG /* function prototypes for stdarg */ 274 | # if defined(STDC) || defined(Z_HAVE_STDARG_H) 275 | # define Z_ARG(args) args 276 | # else 277 | # define Z_ARG(args) () 278 | # endif 279 | #endif 280 | 281 | /* The following definitions for FAR are needed only for MSDOS mixed 282 | * model programming (small or medium model with some far allocations). 283 | * This was tested only with MSC; for other MSDOS compilers you may have 284 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 285 | * just define FAR to be empty. 286 | */ 287 | #ifdef SYS16BIT 288 | # if defined(M_I86SM) || defined(M_I86MM) 289 | /* MSC small or medium model */ 290 | # define SMALL_MEDIUM 291 | # ifdef _MSC_VER 292 | # define FAR _far 293 | # else 294 | # define FAR far 295 | # endif 296 | # endif 297 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 298 | /* Turbo C small or medium model */ 299 | # define SMALL_MEDIUM 300 | # ifdef __BORLANDC__ 301 | # define FAR _far 302 | # else 303 | # define FAR far 304 | # endif 305 | # endif 306 | #endif 307 | 308 | #if defined(WINDOWS) || defined(WIN32) 309 | /* If building or using zlib as a DLL, define ZLIB_DLL. 310 | * This is not mandatory, but it offers a little performance increase. 311 | */ 312 | # ifdef ZLIB_DLL 313 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 314 | # ifdef ZLIB_INTERNAL 315 | # define ZEXTERN extern __declspec(dllexport) 316 | # else 317 | # define ZEXTERN extern __declspec(dllimport) 318 | # endif 319 | # endif 320 | # endif /* ZLIB_DLL */ 321 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 322 | * define ZLIB_WINAPI. 323 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 324 | */ 325 | # ifdef ZLIB_WINAPI 326 | # ifdef FAR 327 | # undef FAR 328 | # endif 329 | # include 330 | /* No need for _export, use ZLIB.DEF instead. */ 331 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 332 | # define ZEXPORT WINAPI 333 | # ifdef WIN32 334 | # define ZEXPORTVA WINAPIV 335 | # else 336 | # define ZEXPORTVA FAR CDECL 337 | # endif 338 | # endif 339 | #endif 340 | 341 | #if defined (__BEOS__) 342 | # ifdef ZLIB_DLL 343 | # ifdef ZLIB_INTERNAL 344 | # define ZEXPORT __declspec(dllexport) 345 | # define ZEXPORTVA __declspec(dllexport) 346 | # else 347 | # define ZEXPORT __declspec(dllimport) 348 | # define ZEXPORTVA __declspec(dllimport) 349 | # endif 350 | # endif 351 | #endif 352 | 353 | #ifndef ZEXTERN 354 | # define ZEXTERN extern 355 | #endif 356 | #ifndef ZEXPORT 357 | # define ZEXPORT 358 | #endif 359 | #ifndef ZEXPORTVA 360 | # define ZEXPORTVA 361 | #endif 362 | 363 | #ifndef FAR 364 | # define FAR 365 | #endif 366 | 367 | #if !defined(__MACTYPES__) 368 | typedef unsigned char Byte; /* 8 bits */ 369 | #endif 370 | typedef unsigned int uInt; /* 16 bits or more */ 371 | typedef unsigned long uLong; /* 32 bits or more */ 372 | 373 | #ifdef SMALL_MEDIUM 374 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 375 | # define Bytef Byte FAR 376 | #else 377 | typedef Byte FAR Bytef; 378 | #endif 379 | typedef char FAR charf; 380 | typedef int FAR intf; 381 | typedef uInt FAR uIntf; 382 | typedef uLong FAR uLongf; 383 | 384 | #ifdef STDC 385 | typedef void const *voidpc; 386 | typedef void FAR *voidpf; 387 | typedef void *voidp; 388 | #else 389 | typedef Byte const *voidpc; 390 | typedef Byte FAR *voidpf; 391 | typedef Byte *voidp; 392 | #endif 393 | 394 | #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) 395 | # include 396 | # if (UINT_MAX == 0xffffffffUL) 397 | # define Z_U4 unsigned 398 | # elif (ULONG_MAX == 0xffffffffUL) 399 | # define Z_U4 unsigned long 400 | # elif (USHRT_MAX == 0xffffffffUL) 401 | # define Z_U4 unsigned short 402 | # endif 403 | #endif 404 | 405 | #ifdef Z_U4 406 | typedef Z_U4 z_crc_t; 407 | #else 408 | typedef unsigned long z_crc_t; 409 | #endif 410 | 411 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 412 | # define Z_HAVE_UNISTD_H 413 | #endif 414 | 415 | #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ 416 | # define Z_HAVE_STDARG_H 417 | #endif 418 | 419 | #ifdef STDC 420 | # ifndef Z_SOLO 421 | # include /* for off_t */ 422 | # endif 423 | #endif 424 | 425 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) 426 | # ifndef Z_SOLO 427 | # include /* for va_list */ 428 | # endif 429 | #endif 430 | 431 | #ifdef _WIN32 432 | # ifndef Z_SOLO 433 | # include /* for wchar_t */ 434 | # endif 435 | #endif 436 | 437 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 438 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 439 | * though the former does not conform to the LFS document), but considering 440 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 441 | * equivalently requesting no 64-bit operations 442 | */ 443 | #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 444 | # undef _LARGEFILE64_SOURCE 445 | #endif 446 | 447 | #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) 448 | # define Z_HAVE_UNISTD_H 449 | #endif 450 | #ifndef Z_SOLO 451 | # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 452 | # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ 453 | # ifdef VMS 454 | # include /* for off_t */ 455 | # endif 456 | # ifndef z_off_t 457 | # define z_off_t off_t 458 | # endif 459 | # endif 460 | #endif 461 | 462 | #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 463 | # define Z_LFS64 464 | #endif 465 | 466 | #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) 467 | # define Z_LARGE64 468 | #endif 469 | 470 | #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) 471 | # define Z_WANT64 472 | #endif 473 | 474 | #if !defined(SEEK_SET) && !defined(Z_SOLO) 475 | # define SEEK_SET 0 /* Seek from beginning of file. */ 476 | # define SEEK_CUR 1 /* Seek from current position. */ 477 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 478 | #endif 479 | 480 | #ifndef z_off_t 481 | # define z_off_t long 482 | #endif 483 | 484 | #if !defined(_WIN32) && defined(Z_LARGE64) 485 | # define z_off64_t off64_t 486 | #else 487 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) 488 | # define z_off64_t __int64 489 | # else 490 | # define z_off64_t z_off_t 491 | # endif 492 | #endif 493 | 494 | /* MVS linker does not support external names larger than 8 bytes */ 495 | #if defined(__MVS__) 496 | #pragma map(deflateInit_,"DEIN") 497 | #pragma map(deflateInit2_,"DEIN2") 498 | #pragma map(deflateEnd,"DEEND") 499 | #pragma map(deflateBound,"DEBND") 500 | #pragma map(inflateInit_,"ININ") 501 | #pragma map(inflateInit2_,"ININ2") 502 | #pragma map(inflateEnd,"INEND") 503 | #pragma map(inflateSync,"INSY") 504 | #pragma map(inflateSetDictionary,"INSEDI") 505 | #pragma map(compressBound,"CMBND") 506 | #pragma map(inflate_table,"INTABL") 507 | #pragma map(inflate_fast,"INFA") 508 | #pragma map(inflate_copyright,"INCOPY") 509 | #endif 510 | 511 | #endif /* ZCONF_H */ 512 | -------------------------------------------------------------------------------- /SharedMemory_v6.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | Description: 3 | Storage structure for storing and updating shared memory 4 | 5 | Copyright (c) MWL. All rights reserved. 6 | *************************************************************************************************/ 7 | 8 | #ifndef _SHARED_MEMORY_HPP_ 9 | #define _SHARED_MEMORY_HPP_ 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // NOTES: 13 | // 14 | // -The shared memory variables will be updated once per graphics frame. 15 | // 16 | // -Each variable comes with a UNIT, RANGE, and UNSET description where applicable. 17 | // UNITS - Is the numeric form which a variable is stored in (e.g. KPH, Celsius) 18 | // RANGE - Is the min-max ranges for a variable 19 | // UNSET - Is the initialised/default/invalid value, depending on the variables usage 20 | // 21 | // -Constant/unchanging values are included in the data, such as 'maxRPM', 'fuelCapacity' - this is done to allow percentage calculations. 22 | // 23 | // -Also included are 12 unique enumerated types, to be used against the mentioned flag/state variables 24 | // 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | // *** Types *** 29 | 30 | // Header version number to test against 31 | enum 32 | { 33 | SHARED_MEMORY_VERSION = 6 34 | }; 35 | 36 | // Maximum allowed length of string 37 | enum 38 | { 39 | STRING_LENGTH_MAX = 64 40 | }; 41 | 42 | // Maximum number of general participant information allowed to be stored in memory-mapped file 43 | enum 44 | { 45 | STORED_PARTICIPANTS_MAX = 64 46 | }; 47 | 48 | // Tyres 49 | enum 50 | { 51 | TYRE_FRONT_LEFT = 0, 52 | TYRE_FRONT_RIGHT, 53 | TYRE_REAR_LEFT, 54 | TYRE_REAR_RIGHT, 55 | //-------------- 56 | TYRE_MAX 57 | }; 58 | 59 | // Vector 60 | enum 61 | { 62 | VEC_X = 0, 63 | VEC_Y, 64 | VEC_Z, 65 | //------------- 66 | VEC_MAX 67 | }; 68 | 69 | // (Type#1) GameState (to be used with 'mGameState') 70 | enum 71 | { 72 | GAME_EXITED = 0, 73 | GAME_FRONT_END, 74 | GAME_INGAME_PLAYING, 75 | GAME_INGAME_PAUSED, 76 | GAME_INGAME_RESTARTING, 77 | GAME_INGAME_REPLAY, 78 | GAME_FRONT_END_REPLAY, 79 | //------------- 80 | GAME_MAX 81 | }; 82 | 83 | // (Type#2) Session state (to be used with 'mSessionState') 84 | enum 85 | { 86 | SESSION_INVALID = 0, 87 | SESSION_PRACTICE, 88 | SESSION_TEST, 89 | SESSION_QUALIFY, 90 | SESSION_FORMATION_LAP, 91 | SESSION_RACE, 92 | SESSION_TIME_ATTACK, 93 | //------------- 94 | SESSION_MAX 95 | }; 96 | 97 | // (Type#3) RaceState (to be used with 'mRaceState') 98 | enum 99 | { 100 | RACESTATE_INVALID, 101 | RACESTATE_NOT_STARTED, 102 | RACESTATE_RACING, 103 | RACESTATE_FINISHED, 104 | RACESTATE_DISQUALIFIED, 105 | RACESTATE_RETIRED, 106 | RACESTATE_DNF, 107 | //------------- 108 | RACESTATE_MAX 109 | }; 110 | 111 | // (Type#4) Current Sector (to be used with 'mCurrentSector') 112 | enum 113 | { 114 | SECTOR_INVALID = 0, 115 | SECTOR_START, 116 | SECTOR_SECTOR1, 117 | SECTOR_SECTOR2, 118 | SECTOR_FINISH, 119 | SECTOR_STOP, 120 | //------------- 121 | SECTOR_MAX 122 | }; 123 | 124 | // (Type#5) Flag Colours (to be used with 'mHighestFlagColour') 125 | enum 126 | { 127 | FLAG_COLOUR_NONE = 0, // Not used for actual flags, only for some query functions 128 | FLAG_COLOUR_GREEN, // End of danger zone, or race started 129 | FLAG_COLOUR_BLUE, // Faster car wants to overtake the participant 130 | FLAG_COLOUR_WHITE, // Approaching a slow car 131 | FLAG_COLOUR_YELLOW, // Danger on the racing surface itself 132 | FLAG_COLOUR_DOUBLE_YELLOW, // Danger that wholly or partly blocks the racing surface 133 | FLAG_COLOUR_BLACK, // Participant disqualified 134 | FLAG_COLOUR_CHEQUERED, // Chequered flag 135 | //------------- 136 | FLAG_COLOUR_MAX 137 | }; 138 | 139 | // (Type#6) Flag Reason (to be used with 'mHighestFlagReason') 140 | enum 141 | { 142 | FLAG_REASON_NONE = 0, 143 | FLAG_REASON_SOLO_CRASH, 144 | FLAG_REASON_VEHICLE_CRASH, 145 | FLAG_REASON_VEHICLE_OBSTRUCTION, 146 | //------------- 147 | FLAG_REASON_MAX 148 | }; 149 | 150 | // (Type#7) Pit Mode (to be used with 'mPitMode') 151 | enum 152 | { 153 | PIT_MODE_NONE = 0, 154 | PIT_MODE_DRIVING_INTO_PITS, 155 | PIT_MODE_IN_PIT, 156 | PIT_MODE_DRIVING_OUT_OF_PITS, 157 | PIT_MODE_IN_GARAGE, 158 | //------------- 159 | PIT_MODE_MAX 160 | }; 161 | 162 | // (Type#8) Pit Stop Schedule (to be used with 'mPitSchedule') 163 | enum 164 | { 165 | PIT_SCHEDULE_NONE = 0, // Nothing scheduled 166 | PIT_SCHEDULE_STANDARD, // Used for standard pit sequence 167 | PIT_SCHEDULE_DRIVE_THROUGH, // Used for drive-through penalty 168 | PIT_SCHEDULE_STOP_GO, // Used for stop-go penalty 169 | //------------- 170 | PIT_SCHEDULE_MAX 171 | }; 172 | 173 | // (Type#9) Car Flags (to be used with 'mCarFlags') 174 | enum 175 | { 176 | CAR_HEADLIGHT = (1<<0), 177 | CAR_ENGINE_ACTIVE = (1<<1), 178 | CAR_ENGINE_WARNING = (1<<2), 179 | CAR_SPEED_LIMITER = (1<<3), 180 | CAR_ABS = (1<<4), 181 | CAR_HANDBRAKE = (1<<5), 182 | }; 183 | 184 | // (Type#10) Tyre Flags (to be used with 'mTyreFlags') 185 | enum 186 | { 187 | TYRE_ATTACHED = (1<<0), 188 | TYRE_INFLATED = (1<<1), 189 | TYRE_IS_ON_GROUND = (1<<2), 190 | }; 191 | 192 | // (Type#11) Terrain Materials (to be used with 'mTerrain') 193 | enum 194 | { 195 | TERRAIN_ROAD = 0, 196 | TERRAIN_LOW_GRIP_ROAD, 197 | TERRAIN_BUMPY_ROAD1, 198 | TERRAIN_BUMPY_ROAD2, 199 | TERRAIN_BUMPY_ROAD3, 200 | TERRAIN_MARBLES, 201 | TERRAIN_GRASSY_BERMS, 202 | TERRAIN_GRASS, 203 | TERRAIN_GRAVEL, 204 | TERRAIN_BUMPY_GRAVEL, 205 | TERRAIN_RUMBLE_STRIPS, 206 | TERRAIN_DRAINS, 207 | TERRAIN_TYREWALLS, 208 | TERRAIN_CEMENTWALLS, 209 | TERRAIN_GUARDRAILS, 210 | TERRAIN_SAND, 211 | TERRAIN_BUMPY_SAND, 212 | TERRAIN_DIRT, 213 | TERRAIN_BUMPY_DIRT, 214 | TERRAIN_DIRT_ROAD, 215 | TERRAIN_BUMPY_DIRT_ROAD, 216 | TERRAIN_PAVEMENT, 217 | TERRAIN_DIRT_BANK, 218 | TERRAIN_WOOD, 219 | TERRAIN_DRY_VERGE, 220 | TERRAIN_EXIT_RUMBLE_STRIPS, 221 | TERRAIN_GRASSCRETE, 222 | TERRAIN_LONG_GRASS, 223 | TERRAIN_SLOPE_GRASS, 224 | TERRAIN_COBBLES, 225 | TERRAIN_SAND_ROAD, 226 | TERRAIN_BAKED_CLAY, 227 | TERRAIN_ASTROTURF, 228 | TERRAIN_SNOWHALF, 229 | TERRAIN_SNOWFULL, 230 | TERRAIN_DAMAGED_ROAD1, 231 | TERRAIN_TRAIN_TRACK_ROAD, 232 | TERRAIN_BUMPYCOBBLES, 233 | TERRAIN_ARIES_ONLY, 234 | TERRAIN_ORION_ONLY, 235 | TERRAIN_B1RUMBLES, 236 | TERRAIN_B2RUMBLES, 237 | TERRAIN_ROUGH_SAND_MEDIUM, 238 | TERRAIN_ROUGH_SAND_HEAVY, 239 | 240 | //------------- 241 | TERRAIN_MAX 242 | }; 243 | 244 | // (Type#12) Crash Damage State (to be used with 'mCrashState') 245 | enum 246 | { 247 | CRASH_DAMAGE_NONE = 0, 248 | CRASH_DAMAGE_OFFTRACK, 249 | CRASH_DAMAGE_LARGE_PROP, 250 | CRASH_DAMAGE_SPINNING, 251 | CRASH_DAMAGE_ROLLING, 252 | //------------- 253 | CRASH_MAX 254 | }; 255 | 256 | // (Type#13) ParticipantInfo struct (to be used with 'mParticipantInfo') 257 | typedef struct 258 | { 259 | bool mIsActive; 260 | char mName[STRING_LENGTH_MAX]; // [ string ] 261 | float mWorldPosition[VEC_MAX]; // [ UNITS = World Space X Y Z ] 262 | float mCurrentLapDistance; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 263 | unsigned int mRacePosition; // [ RANGE = 1->... ] [ UNSET = 0 ] 264 | unsigned int mLapsCompleted; // [ RANGE = 0->... ] [ UNSET = 0 ] 265 | unsigned int mCurrentLap; // [ RANGE = 0->... ] [ UNSET = 0 ] 266 | unsigned int mCurrentSector; // [ enum (Type#4) Current Sector ] 267 | } ParticipantInfo; 268 | 269 | 270 | // *** Shared Memory *** 271 | 272 | typedef struct 273 | { 274 | // Version Number 275 | unsigned int mVersion; // [ RANGE = 0->... ] 276 | unsigned int mBuildVersionNumber; // [ RANGE = 0->... ] [ UNSET = 0 ] 277 | 278 | // Game States 279 | unsigned int mGameState; // [ enum (Type#1) Game state ] 280 | unsigned int mSessionState; // [ enum (Type#2) Session state ] 281 | unsigned int mRaceState; // [ enum (Type#3) Race State ] 282 | 283 | // Participant Info 284 | int mViewedParticipantIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 285 | int mNumParticipants; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 286 | ParticipantInfo mParticipantInfo[STORED_PARTICIPANTS_MAX]; // [ struct (Type#13) ParticipantInfo struct ] 287 | 288 | // Unfiltered Input 289 | float mUnfilteredThrottle; // [ RANGE = 0.0f->1.0f ] 290 | float mUnfilteredBrake; // [ RANGE = 0.0f->1.0f ] 291 | float mUnfilteredSteering; // [ RANGE = -1.0f->1.0f ] 292 | float mUnfilteredClutch; // [ RANGE = 0.0f->1.0f ] 293 | 294 | // Vehicle information 295 | char mCarName[STRING_LENGTH_MAX]; // [ string ] 296 | char mCarClassName[STRING_LENGTH_MAX]; // [ string ] 297 | 298 | // Event information 299 | unsigned int mLapsInEvent; // [ RANGE = 0->... ] [ UNSET = 0 ] 300 | char mTrackLocation[STRING_LENGTH_MAX]; // [ string ] 301 | char mTrackVariation[STRING_LENGTH_MAX]; // [ string ] 302 | float mTrackLength; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 303 | 304 | // New in PCARS2 305 | float unknown; 306 | 307 | // Timings 308 | bool mLapInvalidated; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 309 | float mBestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 310 | float mLastLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 311 | float mCurrentTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 312 | float mSplitTimeAhead; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 313 | float mSplitTimeBehind; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 314 | float mSplitTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 315 | float mEventTimeRemaining; // [ UNITS = milli-seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 316 | float mPersonalFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 317 | float mWorldFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 318 | float mCurrentSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 319 | float mCurrentSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 320 | float mCurrentSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 321 | float mFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 322 | float mFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 323 | float mFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 324 | float mPersonalFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 325 | float mPersonalFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 326 | float mPersonalFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 327 | float mWorldFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 328 | float mWorldFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 329 | float mWorldFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 330 | 331 | // Flags 332 | unsigned int mHighestFlagColour; // [ enum (Type#5) Flag Colour ] 333 | unsigned int mHighestFlagReason; // [ enum (Type#6) Flag Reason ] 334 | 335 | // Pit Info 336 | unsigned int mPitMode; // [ enum (Type#7) Pit Mode ] 337 | unsigned int mPitSchedule; // [ enum (Type#8) Pit Stop Schedule ] 338 | 339 | // Car State 340 | unsigned int mCarFlags; // [ enum (Type#9) Car Flags ] 341 | float mOilTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 342 | float mOilPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 343 | float mWaterTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 344 | float mWaterPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 345 | float mFuelPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 346 | float mFuelLevel; // [ RANGE = 0.0f->1.0f ] 347 | float mFuelCapacity; // [ UNITS = Liters ] [ RANGE = 0.0f->1.0f ] [ UNSET = 0.0f ] 348 | float mSpeed; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 349 | float mRpm; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 350 | float mMaxRPM; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 351 | float mBrake; // [ RANGE = 0.0f->1.0f ] 352 | float mThrottle; // [ RANGE = 0.0f->1.0f ] 353 | float mClutch; // [ RANGE = 0.0f->1.0f ] 354 | float mSteering; // [ RANGE = -1.0f->1.0f ] 355 | int mGear; // [ RANGE = -1 (Reverse) 0 (Neutral) 1 (Gear 1) 2 (Gear 2) etc... ] [ UNSET = 0 (Neutral) ] 356 | int mNumGears; // [ RANGE = 0->... ] [ UNSET = -1 ] 357 | float mOdometerKM; // [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 358 | bool mAntiLockActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 359 | int mLastOpponentCollisionIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 360 | float mLastOpponentCollisionMagnitude; // [ RANGE = 0.0f->... ] 361 | bool mBoostActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 362 | float mBoostAmount; // [ RANGE = 0.0f->100.0f ] 363 | 364 | // Motion & Device Related 365 | float mOrientation[VEC_MAX]; // [ UNITS = Euler Angles ] 366 | float mLocalVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 367 | float mWorldVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 368 | float mAngularVelocity[VEC_MAX]; // [ UNITS = Radians per-second ] 369 | float mLocalAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 370 | float mWorldAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 371 | float mExtentsCentre[VEC_MAX]; // [ UNITS = Local Space X Y Z ] 372 | 373 | // Wheels / Tyres 374 | unsigned int mTyreFlags[TYRE_MAX]; // [ enum (Type#10) Tyre Flags ] 375 | unsigned int mTerrain[TYRE_MAX]; // [ enum (Type#11) Terrain Materials ] 376 | float mTyreY[TYRE_MAX]; // [ UNITS = Local Space Y ] 377 | float mTyreRPS[TYRE_MAX]; // [ UNITS = Revolutions per second ] 378 | float mTyreSlipSpeed[TYRE_MAX]; // [ UNITS = Metres per-second ] 379 | float mTyreTemp[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 380 | float mTyreGrip[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 381 | float mTyreHeightAboveGround[TYRE_MAX]; // [ UNITS = Local Space Y ] 382 | float mTyreLateralStiffness[TYRE_MAX]; // [ UNITS = Lateral stiffness coefficient used in tyre deformation ] 383 | float mTyreWear[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 384 | float mBrakeDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 385 | float mSuspensionDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 386 | float mBrakeTempCelsius[TYRE_MAX]; // [ UNITS = Celsius ] 387 | float mTyreTreadTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 388 | float mTyreLayerTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 389 | float mTyreCarcassTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 390 | float mTyreRimTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 391 | float mTyreInternalAirTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 392 | 393 | // Car Damage 394 | unsigned int mCrashState; // [ enum (Type#12) Crash Damage State ] 395 | float mAeroDamage; // [ RANGE = 0.0f->1.0f ] 396 | float mEngineDamage; // [ RANGE = 0.0f->1.0f ] 397 | 398 | // Weather 399 | float mAmbientTemperature; // [ UNITS = Celsius ] [ UNSET = 25.0f ] 400 | float mTrackTemperature; // [ UNITS = Celsius ] [ UNSET = 30.0f ] 401 | float mRainDensity; // [ UNITS = How much rain will fall ] [ RANGE = 0.0f->1.0f ] 402 | float mWindSpeed; // [ RANGE = 0.0f->100.0f ] [ UNSET = 2.0f ] 403 | float mWindDirectionX; // [ UNITS = Normalised Vector X ] 404 | float mWindDirectionY; // [ UNITS = Normalised Vector Y ] 405 | float mCloudBrightness; // [ RANGE = 0.0f->... ] 406 | } SharedMemory; 407 | 408 | 409 | #endif // _SHARED_MEMORY_HPP_ 410 | -------------------------------------------------------------------------------- /SharedMemory_v9.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | Description: 3 | Storage structure for storing and updating shared memory 4 | 5 | Copyright (c) MWL. All rights reserved. 6 | *************************************************************************************************/ 7 | 8 | #ifndef _SHARED_MEMORY_HPP_ 9 | #define _SHARED_MEMORY_HPP_ 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // NOTES: 13 | // 14 | // -The shared memory variables will be updated once per graphics frame. 15 | // 16 | // -Each variable comes with a UNIT, RANGE, and UNSET description where applicable. 17 | // UNITS - Is the numeric form which a variable is stored in (e.g. KPH, Celsius) 18 | // RANGE - Is the min-max ranges for a variable 19 | // UNSET - Is the initialised/default/invalid value, depending on the variables usage 20 | // 21 | // -Constant/unchanging values are included in the data, such as 'maxRPM', 'fuelCapacity' - this is done to allow percentage calculations. 22 | // 23 | // -Also included are 12 unique enumerated types, to be used against the mentioned flag/state variables 24 | // 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | // *** Types *** 29 | 30 | // Header version number to test against 31 | enum 32 | { 33 | SHARED_MEMORY_VERSION = 9 34 | }; 35 | 36 | // Maximum allowed length of string 37 | enum 38 | { 39 | STRING_LENGTH_MAX = 64 40 | }; 41 | 42 | // Maximum number of general participant information allowed to be stored in memory-mapped file 43 | enum 44 | { 45 | STORED_PARTICIPANTS_MAX = 64 46 | }; 47 | 48 | // Maximum length of a tyre compound name 49 | enum 50 | { 51 | TYRE_COMPOUND_NAME_LENGTH_MAX = 40 52 | }; 53 | 54 | // Tyres 55 | enum 56 | { 57 | TYRE_FRONT_LEFT = 0, 58 | TYRE_FRONT_RIGHT, 59 | TYRE_REAR_LEFT, 60 | TYRE_REAR_RIGHT, 61 | //-------------- 62 | TYRE_MAX 63 | }; 64 | 65 | // Vector 66 | enum 67 | { 68 | VEC_X = 0, 69 | VEC_Y, 70 | VEC_Z, 71 | //------------- 72 | VEC_MAX 73 | }; 74 | 75 | // (Type#1) GameState (to be used with 'mGameState') 76 | enum 77 | { 78 | GAME_EXITED = 0, 79 | GAME_FRONT_END, 80 | GAME_INGAME_PLAYING, 81 | GAME_INGAME_PAUSED, 82 | GAME_INGAME_INMENU_TIME_TICKING, 83 | GAME_INGAME_RESTARTING, 84 | GAME_INGAME_REPLAY, 85 | GAME_FRONT_END_REPLAY, 86 | //------------- 87 | GAME_MAX 88 | }; 89 | 90 | // (Type#2) Session state (to be used with 'mSessionState') 91 | enum 92 | { 93 | SESSION_INVALID = 0, 94 | SESSION_PRACTICE, 95 | SESSION_TEST, 96 | SESSION_QUALIFY, 97 | SESSION_FORMATION_LAP, 98 | SESSION_RACE, 99 | SESSION_TIME_ATTACK, 100 | //------------- 101 | SESSION_MAX 102 | }; 103 | 104 | // (Type#3) RaceState (to be used with 'mRaceState' and 'mRaceStates') 105 | enum 106 | { 107 | RACESTATE_INVALID, 108 | RACESTATE_NOT_STARTED, 109 | RACESTATE_RACING, 110 | RACESTATE_FINISHED, 111 | RACESTATE_DISQUALIFIED, 112 | RACESTATE_RETIRED, 113 | RACESTATE_DNF, 114 | //------------- 115 | RACESTATE_MAX 116 | }; 117 | 118 | // (Type#5) Flag Colours (to be used with 'mHighestFlagColour') 119 | enum 120 | { 121 | FLAG_COLOUR_NONE = 0, // Not used for actual flags, only for some query functions 122 | FLAG_COLOUR_GREEN, // End of danger zone, or race started 123 | FLAG_COLOUR_BLUE, // Faster car wants to overtake the participant 124 | FLAG_COLOUR_WHITE_SLOW_CAR, // Slow car in area 125 | FLAG_COLOUR_WHITE_FINAL_LAP, // Final Lap 126 | FLAG_COLOUR_RED, // Huge collisions where one or more cars become wrecked and block the track 127 | FLAG_COLOUR_YELLOW, // Danger on the racing surface itself 128 | FLAG_COLOUR_DOUBLE_YELLOW, // Danger that wholly or partly blocks the racing surface 129 | FLAG_COLOUR_BLACK_AND_WHITE, // Unsportsmanlike conduct 130 | FLAG_COLOUR_BLACK_ORANGE_CIRCLE, // Mechanical Failure 131 | FLAG_COLOUR_BLACK, // Participant disqualified 132 | FLAG_COLOUR_CHEQUERED, // Chequered flag 133 | //------------- 134 | FLAG_COLOUR_MAX 135 | }; 136 | 137 | // (Type#6) Flag Reason (to be used with 'mHighestFlagReason') 138 | enum 139 | { 140 | FLAG_REASON_NONE = 0, 141 | FLAG_REASON_SOLO_CRASH, 142 | FLAG_REASON_VEHICLE_CRASH, 143 | FLAG_REASON_VEHICLE_OBSTRUCTION, 144 | //------------- 145 | FLAG_REASON_MAX 146 | }; 147 | 148 | // (Type#7) Pit Mode (to be used with 'mPitMode') 149 | enum 150 | { 151 | PIT_MODE_NONE = 0, 152 | PIT_MODE_DRIVING_INTO_PITS, 153 | PIT_MODE_IN_PIT, 154 | PIT_MODE_DRIVING_OUT_OF_PITS, 155 | PIT_MODE_IN_GARAGE, 156 | PIT_MODE_DRIVING_OUT_OF_GARAGE, 157 | //------------- 158 | PIT_MODE_MAX 159 | }; 160 | 161 | // (Type#8) Pit Stop Schedule (to be used with 'mPitSchedule') 162 | enum 163 | { 164 | PIT_SCHEDULE_NONE = 0, // Nothing scheduled 165 | PIT_SCHEDULE_PLAYER_REQUESTED, // Used for standard pit sequence - requested by player 166 | PIT_SCHEDULE_ENGINEER_REQUESTED, // Used for standard pit sequence - requested by engineer 167 | PIT_SCHEDULE_DAMAGE_REQUESTED, // Used for standard pit sequence - requested by engineer for damage 168 | PIT_SCHEDULE_MANDATORY, // Used for standard pit sequence - requested by engineer from career enforced lap number 169 | PIT_SCHEDULE_DRIVE_THROUGH, // Used for drive-through penalty 170 | PIT_SCHEDULE_STOP_GO, // Used for stop-go penalty 171 | PIT_SCHEDULE_PITSPOT_OCCUPIED, // Used for drive-through when pitspot is occupied 172 | //------------- 173 | PIT_SCHEDULE_MAX 174 | }; 175 | 176 | // (Type#9) Car Flags (to be used with 'mCarFlags') 177 | enum CarFlags 178 | { 179 | CAR_HEADLIGHT = (1<<0), 180 | CAR_ENGINE_ACTIVE = (1<<1), 181 | CAR_ENGINE_WARNING = (1<<2), 182 | CAR_SPEED_LIMITER = (1<<3), 183 | CAR_ABS = (1<<4), 184 | CAR_HANDBRAKE = (1<<5), 185 | }; 186 | 187 | // (Type#10) Tyre Flags (to be used with 'mTyreFlags') 188 | enum 189 | { 190 | TYRE_ATTACHED = (1<<0), 191 | TYRE_INFLATED = (1<<1), 192 | TYRE_IS_ON_GROUND = (1<<2), 193 | }; 194 | 195 | // (Type#11) Terrain Materials (to be used with 'mTerrain') 196 | enum 197 | { 198 | TERRAIN_ROAD = 0, 199 | TERRAIN_LOW_GRIP_ROAD, 200 | TERRAIN_BUMPY_ROAD1, 201 | TERRAIN_BUMPY_ROAD2, 202 | TERRAIN_BUMPY_ROAD3, 203 | TERRAIN_MARBLES, 204 | TERRAIN_GRASSY_BERMS, 205 | TERRAIN_GRASS, 206 | TERRAIN_GRAVEL, 207 | TERRAIN_BUMPY_GRAVEL, 208 | TERRAIN_RUMBLE_STRIPS, 209 | TERRAIN_DRAINS, 210 | TERRAIN_TYREWALLS, 211 | TERRAIN_CEMENTWALLS, 212 | TERRAIN_GUARDRAILS, 213 | TERRAIN_SAND, 214 | TERRAIN_BUMPY_SAND, 215 | TERRAIN_DIRT, 216 | TERRAIN_BUMPY_DIRT, 217 | TERRAIN_DIRT_ROAD, 218 | TERRAIN_BUMPY_DIRT_ROAD, 219 | TERRAIN_PAVEMENT, 220 | TERRAIN_DIRT_BANK, 221 | TERRAIN_WOOD, 222 | TERRAIN_DRY_VERGE, 223 | TERRAIN_EXIT_RUMBLE_STRIPS, 224 | TERRAIN_GRASSCRETE, 225 | TERRAIN_LONG_GRASS, 226 | TERRAIN_SLOPE_GRASS, 227 | TERRAIN_COBBLES, 228 | TERRAIN_SAND_ROAD, 229 | TERRAIN_BAKED_CLAY, 230 | TERRAIN_ASTROTURF, 231 | TERRAIN_SNOWHALF, 232 | TERRAIN_SNOWFULL, 233 | TERRAIN_DAMAGED_ROAD1, 234 | TERRAIN_TRAIN_TRACK_ROAD, 235 | TERRAIN_BUMPYCOBBLES, 236 | TERRAIN_ARIES_ONLY, 237 | TERRAIN_ORION_ONLY, 238 | TERRAIN_B1RUMBLES, 239 | TERRAIN_B2RUMBLES, 240 | TERRAIN_ROUGH_SAND_MEDIUM, 241 | TERRAIN_ROUGH_SAND_HEAVY, 242 | TERRAIN_SNOWWALLS, 243 | TERRAIN_ICE_ROAD, 244 | TERRAIN_RUNOFF_ROAD, 245 | TERRAIN_ILLEGAL_STRIP, 246 | TERRAIN_PAINT_CONCRETE, 247 | TERRAIN_PAINT_CONCRETE_ILLEGAL, 248 | TERRAIN_RALLY_TARMAC, 249 | 250 | //------------- 251 | TERRAIN_MAX 252 | }; 253 | 254 | // (Type#12) Crash Damage State (to be used with 'mCrashState') 255 | enum 256 | { 257 | CRASH_DAMAGE_NONE = 0, 258 | CRASH_DAMAGE_OFFTRACK, 259 | CRASH_DAMAGE_LARGE_PROP, 260 | CRASH_DAMAGE_SPINNING, 261 | CRASH_DAMAGE_ROLLING, 262 | //------------- 263 | CRASH_MAX 264 | }; 265 | 266 | // (Type#13) ParticipantInfo struct (to be used with 'mParticipantInfo') 267 | typedef struct 268 | { 269 | bool mIsActive; 270 | char mName[STRING_LENGTH_MAX]; // [ string ] 271 | float mWorldPosition[VEC_MAX]; // [ UNITS = World Space X Y Z ] 272 | float mCurrentLapDistance; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 273 | unsigned int mRacePosition; // [ RANGE = 1->... ] [ UNSET = 0 ] 274 | unsigned int mLapsCompleted; // [ RANGE = 0->... ] [ UNSET = 0 ] 275 | unsigned int mCurrentLap; // [ RANGE = 0->... ] [ UNSET = 0 ] 276 | int mCurrentSector; // [ RANGE = 0->... ] [ UNSET = -1 ] 277 | } ParticipantInfo; 278 | 279 | 280 | // *** Shared Memory *** 281 | 282 | typedef struct 283 | { 284 | // Version Number 285 | unsigned int mVersion; // [ RANGE = 0->... ] 286 | unsigned int mBuildVersionNumber; // [ RANGE = 0->... ] [ UNSET = 0 ] 287 | 288 | // Game States 289 | unsigned int mGameState; // [ enum (Type#1) Game state ] 290 | unsigned int mSessionState; // [ enum (Type#2) Session state ] 291 | unsigned int mRaceState; // [ enum (Type#3) Race State ] 292 | 293 | // Participant Info 294 | int mViewedParticipantIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 295 | int mNumParticipants; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 296 | ParticipantInfo mParticipantInfo[STORED_PARTICIPANTS_MAX]; // [ struct (Type#13) ParticipantInfo struct ] 297 | 298 | // Unfiltered Input 299 | float mUnfilteredThrottle; // [ RANGE = 0.0f->1.0f ] 300 | float mUnfilteredBrake; // [ RANGE = 0.0f->1.0f ] 301 | float mUnfilteredSteering; // [ RANGE = -1.0f->1.0f ] 302 | float mUnfilteredClutch; // [ RANGE = 0.0f->1.0f ] 303 | 304 | // Vehicle information 305 | char mCarName[STRING_LENGTH_MAX]; // [ string ] 306 | char mCarClassName[STRING_LENGTH_MAX]; // [ string ] 307 | 308 | // Event information 309 | unsigned int mLapsInEvent; // [ RANGE = 0->... ] [ UNSET = 0 ] 310 | char mTrackLocation[STRING_LENGTH_MAX]; // [ string ] - untranslated shortened English name 311 | char mTrackVariation[STRING_LENGTH_MAX]; // [ string ]- untranslated shortened English variation description 312 | float mTrackLength; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 313 | 314 | // Timings 315 | int mNumSectors; // [ RANGE = 0->... ] [ UNSET = -1 ] 316 | bool mLapInvalidated; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 317 | float mBestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 318 | float mLastLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 319 | float mCurrentTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 320 | float mSplitTimeAhead; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 321 | float mSplitTimeBehind; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 322 | float mSplitTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 323 | float mEventTimeRemaining; // [ UNITS = milli-seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 324 | float mPersonalFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 325 | float mWorldFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 326 | float mCurrentSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 327 | float mCurrentSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 328 | float mCurrentSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 329 | float mFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 330 | float mFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 331 | float mFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 332 | float mPersonalFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 333 | float mPersonalFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 334 | float mPersonalFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 335 | float mWorldFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 336 | float mWorldFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 337 | float mWorldFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 338 | 339 | // Flags 340 | unsigned int mHighestFlagColour; // [ enum (Type#5) Flag Colour ] 341 | unsigned int mHighestFlagReason; // [ enum (Type#6) Flag Reason ] 342 | 343 | // Pit Info 344 | unsigned int mPitMode; // [ enum (Type#7) Pit Mode ] 345 | unsigned int mPitSchedule; // [ enum (Type#8) Pit Stop Schedule ] 346 | 347 | // Car State 348 | unsigned int mCarFlags; // [ enum (Type#9) Car Flags ] 349 | float mOilTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 350 | float mOilPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 351 | float mWaterTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 352 | float mWaterPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 353 | float mFuelPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 354 | float mFuelLevel; // [ RANGE = 0.0f->1.0f ] 355 | float mFuelCapacity; // [ UNITS = Liters ] [ RANGE = 0.0f->1.0f ] [ UNSET = 0.0f ] 356 | float mSpeed; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 357 | float mRpm; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 358 | float mMaxRPM; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 359 | float mBrake; // [ RANGE = 0.0f->1.0f ] 360 | float mThrottle; // [ RANGE = 0.0f->1.0f ] 361 | float mClutch; // [ RANGE = 0.0f->1.0f ] 362 | float mSteering; // [ RANGE = -1.0f->1.0f ] 363 | int mGear; // [ RANGE = -1 (Reverse) 0 (Neutral) 1 (Gear 1) 2 (Gear 2) etc... ] [ UNSET = 0 (Neutral) ] 364 | int mNumGears; // [ RANGE = 0->... ] [ UNSET = -1 ] 365 | float mOdometerKM; // [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 366 | bool mAntiLockActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 367 | int mLastOpponentCollisionIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 368 | float mLastOpponentCollisionMagnitude; // [ RANGE = 0.0f->... ] 369 | bool mBoostActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 370 | float mBoostAmount; // [ RANGE = 0.0f->100.0f ] 371 | 372 | // Motion & Device Related 373 | float mOrientation[VEC_MAX]; // [ UNITS = Euler Angles ] 374 | float mLocalVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 375 | float mWorldVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 376 | float mAngularVelocity[VEC_MAX]; // [ UNITS = Radians per-second ] 377 | float mLocalAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 378 | float mWorldAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 379 | float mExtentsCentre[VEC_MAX]; // [ UNITS = Local Space X Y Z ] 380 | 381 | // Wheels / Tyres 382 | unsigned int mTyreFlags[TYRE_MAX]; // [ enum (Type#10) Tyre Flags ] 383 | unsigned int mTerrain[TYRE_MAX]; // [ enum (Type#11) Terrain Materials ] 384 | float mTyreY[TYRE_MAX]; // [ UNITS = Local Space Y ] 385 | float mTyreRPS[TYRE_MAX]; // [ UNITS = Revolutions per second ] 386 | float mTyreSlipSpeed[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 387 | float mTyreTemp[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 388 | float mTyreGrip[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 389 | float mTyreHeightAboveGround[TYRE_MAX]; // [ UNITS = Local Space Y ] 390 | float mTyreLateralStiffness[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 391 | float mTyreWear[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 392 | float mBrakeDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 393 | float mSuspensionDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 394 | float mBrakeTempCelsius[TYRE_MAX]; // [ UNITS = Celsius ] 395 | float mTyreTreadTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 396 | float mTyreLayerTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 397 | float mTyreCarcassTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 398 | float mTyreRimTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 399 | float mTyreInternalAirTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 400 | 401 | // Car Damage 402 | unsigned int mCrashState; // [ enum (Type#12) Crash Damage State ] 403 | float mAeroDamage; // [ RANGE = 0.0f->1.0f ] 404 | float mEngineDamage; // [ RANGE = 0.0f->1.0f ] 405 | 406 | // Weather 407 | float mAmbientTemperature; // [ UNITS = Celsius ] [ UNSET = 25.0f ] 408 | float mTrackTemperature; // [ UNITS = Celsius ] [ UNSET = 30.0f ] 409 | float mRainDensity; // [ UNITS = How much rain will fall ] [ RANGE = 0.0f->1.0f ] 410 | float mWindSpeed; // [ RANGE = 0.0f->100.0f ] [ UNSET = 2.0f ] 411 | float mWindDirectionX; // [ UNITS = Normalised Vector X ] 412 | float mWindDirectionY; // [ UNITS = Normalised Vector Y ] 413 | float mCloudBrightness; // [ RANGE = 0.0f->... ] 414 | 415 | //PCars2 additions start, version 8 416 | // Sequence Number to help slightly with data integrity reads 417 | volatile unsigned int mSequenceNumber; // 0 at the start, incremented at start and end of writing, so odd when Shared Memory is being filled, even when the memory is not being touched 418 | 419 | //Additional car variables 420 | float mWheelLocalPositionY[TYRE_MAX]; // [ UNITS = Local Space Y ] 421 | float mSuspensionTravel[TYRE_MAX]; // [ UNITS = meters ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 422 | float mSuspensionVelocity[TYRE_MAX]; // [ UNITS = Rate of change of pushrod deflection ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 423 | float mAirPressure[TYRE_MAX]; // [ UNITS = PSI ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 424 | float mEngineSpeed; // [ UNITS = Rad/s ] [UNSET = 0.f ] 425 | float mEngineTorque; // [ UNITS = Newton Meters] [UNSET = 0.f ] [ RANGE = 0.0f->... ] 426 | float mWings[2]; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 427 | float mHandBrake; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 428 | 429 | // additional race variables 430 | float mCurrentSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 431 | float mCurrentSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 432 | float mCurrentSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 433 | float mFastestSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 434 | float mFastestSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 435 | float mFastestSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 436 | float mFastestLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 437 | float mLastLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 438 | bool mLapsInvalidated[STORED_PARTICIPANTS_MAX]; // [ UNITS = boolean for all participants ] [ RANGE = false->true ] [ UNSET = false ] 439 | unsigned int mRaceStates[STORED_PARTICIPANTS_MAX]; // [ enum (Type#3) Race State ] 440 | unsigned int mPitModes[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 441 | float mOrientations[STORED_PARTICIPANTS_MAX][VEC_MAX]; // [ UNITS = Euler Angles ] 442 | float mSpeeds[STORED_PARTICIPANTS_MAX]; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 443 | char mCarNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 444 | char mCarClassNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 445 | 446 | // additional race variables 447 | int mEnforcedPitStopLap; // [ UNITS = in which lap there will be a mandatory pitstop] [ RANGE = 0.0f->... ] [ UNSET = -1 ] 448 | char mTranslatedTrackLocation[STRING_LENGTH_MAX]; // [ string ] 449 | char mTranslatedTrackVariation[STRING_LENGTH_MAX]; // [ string ] 450 | float mBrakeBias; // [ RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 451 | float mTurboBoostPressure; // RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 452 | char mTyreCompound[TYRE_MAX][TYRE_COMPOUND_NAME_LENGTH_MAX];// [ strings ] 453 | unsigned int mPitSchedules[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 454 | unsigned int mHighestFlagColours[STORED_PARTICIPANTS_MAX]; // [ enum (Type#5) Flag Colour ] 455 | unsigned int mHighestFlagReasons[STORED_PARTICIPANTS_MAX]; // [ enum (Type#6) Flag Reason ] 456 | unsigned int mNationalities[STORED_PARTICIPANTS_MAX]; // [ nationality table , SP AND UNSET = 0 ] See nationalities.txt file for details 457 | float mSnowDensity; // [ UNITS = How much snow will fall ] [ RANGE = 0.0f->1.0f ], this will be non zero only in Snow season, in other seasons whatever is falling from the sky is reported as rain 458 | 459 | 460 | } SharedMemory; 461 | 462 | 463 | #endif // _SHARED_MEMORY_HPP_ 464 | 465 | -------------------------------------------------------------------------------- /SharedMemory_v10.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | Description: 3 | Storage structure for storing and updating shared memory 4 | 5 | Copyright (c) MWL. All rights reserved. 6 | *************************************************************************************************/ 7 | 8 | #ifndef _SHARED_MEMORY_HPP_ 9 | #define _SHARED_MEMORY_HPP_ 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // NOTES: 13 | // 14 | // -The shared memory variables will be updated once per graphics frame. 15 | // 16 | // -Each variable comes with a UNIT, RANGE, and UNSET description where applicable. 17 | // UNITS - Is the numeric form which a variable is stored in (e.g. KPH, Celsius) 18 | // RANGE - Is the min-max ranges for a variable 19 | // UNSET - Is the initialised/default/invalid value, depending on the variables usage 20 | // 21 | // -Constant/unchanging values are included in the data, such as 'maxRPM', 'fuelCapacity' - this is done to allow percentage calculations. 22 | // 23 | // -Also included are 12 unique enumerated types, to be used against the mentioned flag/state variables 24 | // 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | // *** Types *** 29 | 30 | // Header version number to test against 31 | enum 32 | { 33 | SHARED_MEMORY_VERSION = 10 34 | }; 35 | 36 | // Maximum allowed length of string 37 | enum 38 | { 39 | STRING_LENGTH_MAX = 64 40 | }; 41 | 42 | // Maximum number of general participant information allowed to be stored in memory-mapped file 43 | enum 44 | { 45 | STORED_PARTICIPANTS_MAX = 64 46 | }; 47 | 48 | // Maximum length of a tyre compound name 49 | enum 50 | { 51 | TYRE_COMPOUND_NAME_LENGTH_MAX = 40 52 | }; 53 | 54 | // Tyres 55 | enum 56 | { 57 | TYRE_FRONT_LEFT = 0, 58 | TYRE_FRONT_RIGHT, 59 | TYRE_REAR_LEFT, 60 | TYRE_REAR_RIGHT, 61 | //-------------- 62 | TYRE_MAX 63 | }; 64 | 65 | // Vector 66 | enum 67 | { 68 | VEC_X = 0, 69 | VEC_Y, 70 | VEC_Z, 71 | //------------- 72 | VEC_MAX 73 | }; 74 | 75 | // (Type#1) GameState (to be used with 'mGameState') 76 | enum 77 | { 78 | GAME_EXITED = 0, 79 | GAME_FRONT_END, 80 | GAME_INGAME_PLAYING, 81 | GAME_INGAME_PAUSED, 82 | GAME_INGAME_INMENU_TIME_TICKING, 83 | GAME_INGAME_RESTARTING, 84 | GAME_INGAME_REPLAY, 85 | GAME_FRONT_END_REPLAY, 86 | //------------- 87 | GAME_MAX 88 | }; 89 | 90 | // (Type#2) Session state (to be used with 'mSessionState') 91 | enum 92 | { 93 | SESSION_INVALID = 0, 94 | SESSION_PRACTICE, 95 | SESSION_TEST, 96 | SESSION_QUALIFY, 97 | SESSION_FORMATION_LAP, 98 | SESSION_RACE, 99 | SESSION_TIME_ATTACK, 100 | //------------- 101 | SESSION_MAX 102 | }; 103 | 104 | // (Type#3) RaceState (to be used with 'mRaceState' and 'mRaceStates') 105 | enum 106 | { 107 | RACESTATE_INVALID, 108 | RACESTATE_NOT_STARTED, 109 | RACESTATE_RACING, 110 | RACESTATE_FINISHED, 111 | RACESTATE_DISQUALIFIED, 112 | RACESTATE_RETIRED, 113 | RACESTATE_DNF, 114 | //------------- 115 | RACESTATE_MAX 116 | }; 117 | 118 | // (Type#5) Flag Colours (to be used with 'mHighestFlagColour') 119 | enum 120 | { 121 | FLAG_COLOUR_NONE = 0, // Not used for actual flags, only for some query functions 122 | FLAG_COLOUR_GREEN, // End of danger zone, or race started 123 | FLAG_COLOUR_BLUE, // Faster car wants to overtake the participant 124 | FLAG_COLOUR_WHITE_SLOW_CAR, // Slow car in area 125 | FLAG_COLOUR_WHITE_FINAL_LAP, // Final Lap 126 | FLAG_COLOUR_RED, // Huge collisions where one or more cars become wrecked and block the track 127 | FLAG_COLOUR_YELLOW, // Danger on the racing surface itself 128 | FLAG_COLOUR_DOUBLE_YELLOW, // Danger that wholly or partly blocks the racing surface 129 | FLAG_COLOUR_BLACK_AND_WHITE, // Unsportsmanlike conduct 130 | FLAG_COLOUR_BLACK_ORANGE_CIRCLE, // Mechanical Failure 131 | FLAG_COLOUR_BLACK, // Participant disqualified 132 | FLAG_COLOUR_CHEQUERED, // Chequered flag 133 | //------------- 134 | FLAG_COLOUR_MAX 135 | }; 136 | 137 | // (Type#6) Flag Reason (to be used with 'mHighestFlagReason') 138 | enum 139 | { 140 | FLAG_REASON_NONE = 0, 141 | FLAG_REASON_SOLO_CRASH, 142 | FLAG_REASON_VEHICLE_CRASH, 143 | FLAG_REASON_VEHICLE_OBSTRUCTION, 144 | //------------- 145 | FLAG_REASON_MAX 146 | }; 147 | 148 | // (Type#7) Pit Mode (to be used with 'mPitMode') 149 | enum 150 | { 151 | PIT_MODE_NONE = 0, 152 | PIT_MODE_DRIVING_INTO_PITS, 153 | PIT_MODE_IN_PIT, 154 | PIT_MODE_DRIVING_OUT_OF_PITS, 155 | PIT_MODE_IN_GARAGE, 156 | PIT_MODE_DRIVING_OUT_OF_GARAGE, 157 | //------------- 158 | PIT_MODE_MAX 159 | }; 160 | 161 | // (Type#8) Pit Stop Schedule (to be used with 'mPitSchedule') 162 | enum 163 | { 164 | PIT_SCHEDULE_NONE = 0, // Nothing scheduled 165 | PIT_SCHEDULE_PLAYER_REQUESTED, // Used for standard pit sequence - requested by player 166 | PIT_SCHEDULE_ENGINEER_REQUESTED, // Used for standard pit sequence - requested by engineer 167 | PIT_SCHEDULE_DAMAGE_REQUESTED, // Used for standard pit sequence - requested by engineer for damage 168 | PIT_SCHEDULE_MANDATORY, // Used for standard pit sequence - requested by engineer from career enforced lap number 169 | PIT_SCHEDULE_DRIVE_THROUGH, // Used for drive-through penalty 170 | PIT_SCHEDULE_STOP_GO, // Used for stop-go penalty 171 | PIT_SCHEDULE_PITSPOT_OCCUPIED, // Used for drive-through when pitspot is occupied 172 | //------------- 173 | PIT_SCHEDULE_MAX 174 | }; 175 | 176 | // (Type#9) Car Flags (to be used with 'mCarFlags') 177 | enum CarFlags 178 | { 179 | CAR_HEADLIGHT = (1 << 0), 180 | CAR_ENGINE_ACTIVE = (1 << 1), 181 | CAR_ENGINE_WARNING = (1 << 2), 182 | CAR_SPEED_LIMITER = (1 << 3), 183 | CAR_ABS = (1 << 4), 184 | CAR_HANDBRAKE = (1 << 5), 185 | CAR_TCS = (1 << 6), 186 | CAR_SCS = (1 << 7), 187 | }; 188 | 189 | // (Type#10) Tyre Flags (to be used with 'mTyreFlags') 190 | enum 191 | { 192 | TYRE_ATTACHED = (1 << 0), 193 | TYRE_INFLATED = (1 << 1), 194 | TYRE_IS_ON_GROUND = (1 << 2), 195 | }; 196 | 197 | // (Type#11) Terrain Materials (to be used with 'mTerrain') 198 | enum 199 | { 200 | TERRAIN_ROAD = 0, 201 | TERRAIN_LOW_GRIP_ROAD, 202 | TERRAIN_BUMPY_ROAD1, 203 | TERRAIN_BUMPY_ROAD2, 204 | TERRAIN_BUMPY_ROAD3, 205 | TERRAIN_MARBLES, 206 | TERRAIN_GRASSY_BERMS, 207 | TERRAIN_GRASS, 208 | TERRAIN_GRAVEL, 209 | TERRAIN_BUMPY_GRAVEL, 210 | TERRAIN_RUMBLE_STRIPS, 211 | TERRAIN_DRAINS, 212 | TERRAIN_TYREWALLS, 213 | TERRAIN_CEMENTWALLS, 214 | TERRAIN_GUARDRAILS, 215 | TERRAIN_SAND, 216 | TERRAIN_BUMPY_SAND, 217 | TERRAIN_DIRT, 218 | TERRAIN_BUMPY_DIRT, 219 | TERRAIN_DIRT_ROAD, 220 | TERRAIN_BUMPY_DIRT_ROAD, 221 | TERRAIN_PAVEMENT, 222 | TERRAIN_DIRT_BANK, 223 | TERRAIN_WOOD, 224 | TERRAIN_DRY_VERGE, 225 | TERRAIN_EXIT_RUMBLE_STRIPS, 226 | TERRAIN_GRASSCRETE, 227 | TERRAIN_LONG_GRASS, 228 | TERRAIN_SLOPE_GRASS, 229 | TERRAIN_COBBLES, 230 | TERRAIN_SAND_ROAD, 231 | TERRAIN_BAKED_CLAY, 232 | TERRAIN_ASTROTURF, 233 | TERRAIN_SNOWHALF, 234 | TERRAIN_SNOWFULL, 235 | TERRAIN_DAMAGED_ROAD1, 236 | TERRAIN_TRAIN_TRACK_ROAD, 237 | TERRAIN_BUMPYCOBBLES, 238 | TERRAIN_ARIES_ONLY, 239 | TERRAIN_ORION_ONLY, 240 | TERRAIN_B1RUMBLES, 241 | TERRAIN_B2RUMBLES, 242 | TERRAIN_ROUGH_SAND_MEDIUM, 243 | TERRAIN_ROUGH_SAND_HEAVY, 244 | TERRAIN_SNOWWALLS, 245 | TERRAIN_ICE_ROAD, 246 | TERRAIN_RUNOFF_ROAD, 247 | TERRAIN_ILLEGAL_STRIP, 248 | TERRAIN_PAINT_CONCRETE, 249 | TERRAIN_PAINT_CONCRETE_ILLEGAL, 250 | TERRAIN_RALLY_TARMAC, 251 | 252 | //------------- 253 | TERRAIN_MAX 254 | }; 255 | 256 | // (Type#12) Crash Damage State (to be used with 'mCrashState') 257 | enum 258 | { 259 | CRASH_DAMAGE_NONE = 0, 260 | CRASH_DAMAGE_OFFTRACK, 261 | CRASH_DAMAGE_LARGE_PROP, 262 | CRASH_DAMAGE_SPINNING, 263 | CRASH_DAMAGE_ROLLING, 264 | //------------- 265 | CRASH_MAX 266 | }; 267 | 268 | // (Type#13) ParticipantInfo struct (to be used with 'mParticipantInfo') 269 | typedef struct 270 | { 271 | bool mIsActive; 272 | char mName[STRING_LENGTH_MAX]; // [ string ] 273 | float mWorldPosition[VEC_MAX]; // [ UNITS = World Space X Y Z ] 274 | float mCurrentLapDistance; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 275 | unsigned int mRacePosition; // [ RANGE = 1->... ] [ UNSET = 0 ] 276 | unsigned int mLapsCompleted; // [ RANGE = 0->... ] [ UNSET = 0 ] 277 | unsigned int mCurrentLap; // [ RANGE = 0->... ] [ UNSET = 0 ] 278 | int mCurrentSector; // [ RANGE = 0->... ] [ UNSET = -1 ] 279 | } ParticipantInfo; 280 | 281 | // (Type#14) DrsState Flags (to be used with 'mDrsState') 282 | enum DrsState 283 | { 284 | DRS_INSTALLED = (0 << 1), // Vehicle has DRS capability 285 | DRS_ZONE_RULES = (0 << 2), // 1 if DRS uses F1 style rules 286 | DRS_AVAILABLE_NEXT = (0 << 3), // detection zone was triggered (only applies to f1 style rules) 287 | DRS_AVAILABLE_NOW = (0 << 4), // detection zone was triggered and we are now in the zone (only applies to f1 style rules) 288 | DRS_ACTIVE = (0 << 5), // Wing is in activated state 289 | }; 290 | 291 | // *** Shared Memory *** 292 | 293 | typedef struct 294 | { 295 | // Version Number 296 | unsigned int mVersion; // [ RANGE = 0->... ] 297 | unsigned int mBuildVersionNumber; // [ RANGE = 0->... ] [ UNSET = 0 ] 298 | 299 | // Game States 300 | unsigned int mGameState; // [ enum (Type#1) Game state ] 301 | unsigned int mSessionState; // [ enum (Type#2) Session state ] 302 | unsigned int mRaceState; // [ enum (Type#3) Race State ] 303 | 304 | // Participant Info 305 | int mViewedParticipantIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 306 | int mNumParticipants; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 307 | ParticipantInfo mParticipantInfo[STORED_PARTICIPANTS_MAX]; // [ struct (Type#13) ParticipantInfo struct ] 308 | 309 | // Unfiltered Input 310 | float mUnfilteredThrottle; // [ RANGE = 0.0f->1.0f ] 311 | float mUnfilteredBrake; // [ RANGE = 0.0f->1.0f ] 312 | float mUnfilteredSteering; // [ RANGE = -1.0f->1.0f ] 313 | float mUnfilteredClutch; // [ RANGE = 0.0f->1.0f ] 314 | 315 | // Vehicle information 316 | char mCarName[STRING_LENGTH_MAX]; // [ string ] 317 | char mCarClassName[STRING_LENGTH_MAX]; // [ string ] 318 | 319 | // Event information 320 | unsigned int mLapsInEvent; // [ RANGE = 0->... ] [ UNSET = 0 ] 321 | char mTrackLocation[STRING_LENGTH_MAX]; // [ string ] - untranslated shortened English name 322 | char mTrackVariation[STRING_LENGTH_MAX]; // [ string ]- untranslated shortened English variation description 323 | float mTrackLength; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 324 | 325 | // Timings 326 | int mNumSectors; // [ RANGE = 0->... ] [ UNSET = -1 ] 327 | bool mLapInvalidated; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 328 | float mBestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 329 | float mLastLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 330 | float mCurrentTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 331 | float mSplitTimeAhead; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 332 | float mSplitTimeBehind; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 333 | float mSplitTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 334 | float mEventTimeRemaining; // [ UNITS = milli-seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 335 | float mPersonalFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 336 | float mWorldFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 337 | float mCurrentSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 338 | float mCurrentSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 339 | float mCurrentSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 340 | float mFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 341 | float mFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 342 | float mFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 343 | float mPersonalFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 344 | float mPersonalFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 345 | float mPersonalFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 346 | float mWorldFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 347 | float mWorldFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 348 | float mWorldFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 349 | 350 | // Flags 351 | unsigned int mHighestFlagColour; // [ enum (Type#5) Flag Colour ] 352 | unsigned int mHighestFlagReason; // [ enum (Type#6) Flag Reason ] 353 | 354 | // Pit Info 355 | unsigned int mPitMode; // [ enum (Type#7) Pit Mode ] 356 | unsigned int mPitSchedule; // [ enum (Type#8) Pit Stop Schedule ] 357 | 358 | // Car State 359 | unsigned int mCarFlags; // [ enum (Type#9) Car Flags ] 360 | float mOilTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 361 | float mOilPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 362 | float mWaterTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 363 | float mWaterPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 364 | float mFuelPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 365 | float mFuelLevel; // [ RANGE = 0.0f->1.0f ] 366 | float mFuelCapacity; // [ UNITS = Liters ] [ RANGE = 0.0f->1.0f ] [ UNSET = 0.0f ] 367 | float mSpeed; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 368 | float mRpm; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 369 | float mMaxRPM; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 370 | float mBrake; // [ RANGE = 0.0f->1.0f ] 371 | float mThrottle; // [ RANGE = 0.0f->1.0f ] 372 | float mClutch; // [ RANGE = 0.0f->1.0f ] 373 | float mSteering; // [ RANGE = -1.0f->1.0f ] 374 | int mGear; // [ RANGE = -1 (Reverse) 0 (Neutral) 1 (Gear 1) 2 (Gear 2) etc... ] [ UNSET = 0 (Neutral) ] 375 | int mNumGears; // [ RANGE = 0->... ] [ UNSET = -1 ] 376 | float mOdometerKM; // [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 377 | bool mAntiLockActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 378 | int mLastOpponentCollisionIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 379 | float mLastOpponentCollisionMagnitude; // [ RANGE = 0.0f->... ] 380 | bool mBoostActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 381 | float mBoostAmount; // [ RANGE = 0.0f->100.0f ] 382 | 383 | // Motion & Device Related 384 | float mOrientation[VEC_MAX]; // [ UNITS = Euler Angles ] 385 | float mLocalVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 386 | float mWorldVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 387 | float mAngularVelocity[VEC_MAX]; // [ UNITS = Radians per-second ] 388 | float mLocalAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 389 | float mWorldAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 390 | float mExtentsCentre[VEC_MAX]; // [ UNITS = Local Space X Y Z ] 391 | 392 | // Wheels / Tyres 393 | unsigned int mTyreFlags[TYRE_MAX]; // [ enum (Type#10) Tyre Flags ] 394 | unsigned int mTerrain[TYRE_MAX]; // [ enum (Type#11) Terrain Materials ] 395 | float mTyreY[TYRE_MAX]; // [ UNITS = Local Space Y ] 396 | float mTyreRPS[TYRE_MAX]; // [ UNITS = Revolutions per second ] 397 | float mTyreSlipSpeed[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 398 | float mTyreTemp[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 399 | float mTyreGrip[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 400 | float mTyreHeightAboveGround[TYRE_MAX]; // [ UNITS = Local Space Y ] 401 | float mTyreLateralStiffness[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 402 | float mTyreWear[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 403 | float mBrakeDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 404 | float mSuspensionDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 405 | float mBrakeTempCelsius[TYRE_MAX]; // [ UNITS = Celsius ] 406 | float mTyreTreadTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 407 | float mTyreLayerTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 408 | float mTyreCarcassTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 409 | float mTyreRimTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 410 | float mTyreInternalAirTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 411 | 412 | // Car Damage 413 | unsigned int mCrashState; // [ enum (Type#12) Crash Damage State ] 414 | float mAeroDamage; // [ RANGE = 0.0f->1.0f ] 415 | float mEngineDamage; // [ RANGE = 0.0f->1.0f ] 416 | 417 | // Weather 418 | float mAmbientTemperature; // [ UNITS = Celsius ] [ UNSET = 25.0f ] 419 | float mTrackTemperature; // [ UNITS = Celsius ] [ UNSET = 30.0f ] 420 | float mRainDensity; // [ UNITS = How much rain will fall ] [ RANGE = 0.0f->1.0f ] 421 | float mWindSpeed; // [ RANGE = 0.0f->100.0f ] [ UNSET = 2.0f ] 422 | float mWindDirectionX; // [ UNITS = Normalised Vector X ] 423 | float mWindDirectionY; // [ UNITS = Normalised Vector Y ] 424 | float mCloudBrightness; // [ RANGE = 0.0f->... ] 425 | 426 | //PCars2 additions start, version 8 427 | // Sequence Number to help slightly with data integrity reads 428 | volatile unsigned int mSequenceNumber; // 0 at the start, incremented at start and end of writing, so odd when Shared Memory is being filled, even when the memory is not being touched 429 | 430 | //Additional car variables 431 | float mWheelLocalPositionY[TYRE_MAX]; // [ UNITS = Local Space Y ] 432 | float mSuspensionTravel[TYRE_MAX]; // [ UNITS = meters ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 433 | float mSuspensionVelocity[TYRE_MAX]; // [ UNITS = Rate of change of pushrod deflection ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 434 | float mAirPressure[TYRE_MAX]; // [ UNITS = PSI ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 435 | float mEngineSpeed; // [ UNITS = Rad/s ] [UNSET = 0.f ] 436 | float mEngineTorque; // [ UNITS = Newton Meters] [UNSET = 0.f ] [ RANGE = 0.0f->... ] 437 | float mWings[2]; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 438 | float mHandBrake; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 439 | 440 | // additional race variables 441 | float mCurrentSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 442 | float mCurrentSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 443 | float mCurrentSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 444 | float mFastestSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 445 | float mFastestSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 446 | float mFastestSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 447 | float mFastestLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 448 | float mLastLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 449 | bool mLapsInvalidated[STORED_PARTICIPANTS_MAX]; // [ UNITS = boolean for all participants ] [ RANGE = false->true ] [ UNSET = false ] 450 | unsigned int mRaceStates[STORED_PARTICIPANTS_MAX]; // [ enum (Type#3) Race State ] 451 | unsigned int mPitModes[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 452 | float mOrientations[STORED_PARTICIPANTS_MAX][VEC_MAX]; // [ UNITS = Euler Angles ] 453 | float mSpeeds[STORED_PARTICIPANTS_MAX]; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 454 | char mCarNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 455 | char mCarClassNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 456 | 457 | // additional race variables 458 | int mEnforcedPitStopLap; // [ UNITS = in which lap there will be a mandatory pitstop] [ RANGE = 0.0f->... ] [ UNSET = -1 ] 459 | char mTranslatedTrackLocation[STRING_LENGTH_MAX]; // [ string ] 460 | char mTranslatedTrackVariation[STRING_LENGTH_MAX]; // [ string ] 461 | float mBrakeBias; // [ RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 462 | float mTurboBoostPressure; // RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 463 | char mTyreCompound[TYRE_MAX][TYRE_COMPOUND_NAME_LENGTH_MAX];// [ strings ] 464 | unsigned int mPitSchedules[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 465 | unsigned int mHighestFlagColours[STORED_PARTICIPANTS_MAX]; // [ enum (Type#5) Flag Colour ] 466 | unsigned int mHighestFlagReasons[STORED_PARTICIPANTS_MAX]; // [ enum (Type#6) Flag Reason ] 467 | unsigned int mNationalities[STORED_PARTICIPANTS_MAX]; // [ nationality table , SP AND UNSET = 0 ] 468 | float mSnowDensity; // [ UNITS = How much snow will fall ] [ RANGE = 0.0f->1.0f ], this is non zero only in Winter and Snow seasons 469 | 470 | // AMS2 Additions (v10...) 471 | 472 | // Session info 473 | float mSessionDuration; // [ UNITS = minutes ] [ UNSET = 0.0f ] The scheduled session Length (unset means laps race. See mLapsInEvent) 474 | int mSessionAdditionalLaps; // The number of additional complete laps lead lap drivers must complete to finish a timed race after the session duration has elapsed. 475 | 476 | // Tyres 477 | float mTyreTempLeft[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 478 | float mTyreTempCenter[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 479 | float mTyreTempRight[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 480 | 481 | // DRS 482 | unsigned int mDrsState; // [ enum (Type#14) DrsState ] 483 | 484 | // Suspension 485 | float mRideHeight[TYRE_MAX]; // [ UNITS = cm ] 486 | 487 | // Input 488 | unsigned int mJoyPad0; // button mask 489 | unsigned int mDPad; // button mask 490 | 491 | } SharedMemory; 492 | 493 | 494 | #endif // _SHARED_MEMORY_HPP_ 495 | -------------------------------------------------------------------------------- /SharedMemory_v11.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | Description: 3 | Storage structure for storing and updating shared memory 4 | 5 | Copyright (c) MWL. All rights reserved. 6 | *************************************************************************************************/ 7 | 8 | #ifndef _SHARED_MEMORY_HPP_ 9 | #define _SHARED_MEMORY_HPP_ 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // NOTES: 13 | // 14 | // -The shared memory variables will be updated once per graphics frame. 15 | // 16 | // -Each variable comes with a UNIT, RANGE, and UNSET description where applicable. 17 | // UNITS - Is the numeric form which a variable is stored in (e.g. KPH, Celsius) 18 | // RANGE - Is the min-max ranges for a variable 19 | // UNSET - Is the initialised/default/invalid value, depending on the variables usage 20 | // 21 | // -Constant/unchanging values are included in the data, such as 'maxRPM', 'fuelCapacity' - this is done to allow percentage calculations. 22 | // 23 | // -Also included are 12 unique enumerated types, to be used against the mentioned flag/state variables 24 | // 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | // *** Types *** 29 | 30 | // Header version number to test against 31 | enum 32 | { 33 | SHARED_MEMORY_VERSION = 11 34 | }; 35 | 36 | // Maximum allowed length of string 37 | enum 38 | { 39 | STRING_LENGTH_MAX = 64 40 | }; 41 | 42 | // Maximum number of general participant information allowed to be stored in memory-mapped file 43 | enum 44 | { 45 | STORED_PARTICIPANTS_MAX = 64 46 | }; 47 | 48 | // Maximum length of a tyre compound name 49 | enum 50 | { 51 | TYRE_COMPOUND_NAME_LENGTH_MAX = 40 52 | }; 53 | 54 | // Tyres 55 | enum 56 | { 57 | TYRE_FRONT_LEFT = 0, 58 | TYRE_FRONT_RIGHT, 59 | TYRE_REAR_LEFT, 60 | TYRE_REAR_RIGHT, 61 | //-------------- 62 | TYRE_MAX 63 | }; 64 | 65 | // Vector 66 | enum 67 | { 68 | VEC_X = 0, 69 | VEC_Y, 70 | VEC_Z, 71 | //------------- 72 | VEC_MAX 73 | }; 74 | 75 | // (Type#1) GameState (to be used with 'mGameState') 76 | enum 77 | { 78 | GAME_EXITED = 0, 79 | GAME_FRONT_END, 80 | GAME_INGAME_PLAYING, 81 | GAME_INGAME_PAUSED, 82 | GAME_INGAME_INMENU_TIME_TICKING, 83 | GAME_INGAME_RESTARTING, 84 | GAME_INGAME_REPLAY, 85 | GAME_FRONT_END_REPLAY, 86 | //------------- 87 | GAME_MAX 88 | }; 89 | 90 | // (Type#2) Session state (to be used with 'mSessionState') 91 | enum 92 | { 93 | SESSION_INVALID = 0, 94 | SESSION_PRACTICE, 95 | SESSION_TEST, 96 | SESSION_QUALIFY, 97 | SESSION_FORMATION_LAP, 98 | SESSION_RACE, 99 | SESSION_TIME_ATTACK, 100 | //------------- 101 | SESSION_MAX 102 | }; 103 | 104 | // (Type#3) RaceState (to be used with 'mRaceState' and 'mRaceStates') 105 | enum 106 | { 107 | RACESTATE_INVALID, 108 | RACESTATE_NOT_STARTED, 109 | RACESTATE_RACING, 110 | RACESTATE_FINISHED, 111 | RACESTATE_DISQUALIFIED, 112 | RACESTATE_RETIRED, 113 | RACESTATE_DNF, 114 | //------------- 115 | RACESTATE_MAX 116 | }; 117 | 118 | // (Type#5) Flag Colours (to be used with 'mHighestFlagColour') 119 | enum 120 | { 121 | FLAG_COLOUR_NONE = 0, // Not used for actual flags, only for some query functions 122 | FLAG_COLOUR_GREEN, // End of danger zone, or race started 123 | FLAG_COLOUR_BLUE, // Faster car wants to overtake the participant 124 | FLAG_COLOUR_WHITE_SLOW_CAR, // Slow car in area 125 | FLAG_COLOUR_WHITE_FINAL_LAP, // Final Lap 126 | FLAG_COLOUR_RED, // Huge collisions where one or more cars become wrecked and block the track 127 | FLAG_COLOUR_YELLOW, // Danger on the racing surface itself 128 | FLAG_COLOUR_DOUBLE_YELLOW, // Danger that wholly or partly blocks the racing surface 129 | FLAG_COLOUR_BLACK_AND_WHITE, // Unsportsmanlike conduct 130 | FLAG_COLOUR_BLACK_ORANGE_CIRCLE, // Mechanical Failure 131 | FLAG_COLOUR_BLACK, // Participant disqualified 132 | FLAG_COLOUR_CHEQUERED, // Chequered flag 133 | //------------- 134 | FLAG_COLOUR_MAX 135 | }; 136 | 137 | // (Type#6) Flag Reason (to be used with 'mHighestFlagReason') 138 | enum 139 | { 140 | FLAG_REASON_NONE = 0, 141 | FLAG_REASON_SOLO_CRASH, 142 | FLAG_REASON_VEHICLE_CRASH, 143 | FLAG_REASON_VEHICLE_OBSTRUCTION, 144 | //------------- 145 | FLAG_REASON_MAX 146 | }; 147 | 148 | // (Type#7) Pit Mode (to be used with 'mPitMode') 149 | enum 150 | { 151 | PIT_MODE_NONE = 0, 152 | PIT_MODE_DRIVING_INTO_PITS, 153 | PIT_MODE_IN_PIT, 154 | PIT_MODE_DRIVING_OUT_OF_PITS, 155 | PIT_MODE_IN_GARAGE, 156 | PIT_MODE_DRIVING_OUT_OF_GARAGE, 157 | //------------- 158 | PIT_MODE_MAX 159 | }; 160 | 161 | // (Type#8) Pit Stop Schedule (to be used with 'mPitSchedule') 162 | enum 163 | { 164 | PIT_SCHEDULE_NONE = 0, // Nothing scheduled 165 | PIT_SCHEDULE_PLAYER_REQUESTED, // Used for standard pit sequence - requested by player 166 | PIT_SCHEDULE_ENGINEER_REQUESTED, // Used for standard pit sequence - requested by engineer 167 | PIT_SCHEDULE_DAMAGE_REQUESTED, // Used for standard pit sequence - requested by engineer for damage 168 | PIT_SCHEDULE_MANDATORY, // Used for standard pit sequence - requested by engineer from career enforced lap number 169 | PIT_SCHEDULE_DRIVE_THROUGH, // Used for drive-through penalty 170 | PIT_SCHEDULE_STOP_GO, // Used for stop-go penalty 171 | PIT_SCHEDULE_PITSPOT_OCCUPIED, // Used for drive-through when pitspot is occupied 172 | //------------- 173 | PIT_SCHEDULE_MAX 174 | }; 175 | 176 | // (Type#9) Car Flags (to be used with 'mCarFlags') 177 | enum CarFlags 178 | { 179 | CAR_HEADLIGHT = (1<<0), 180 | CAR_ENGINE_ACTIVE = (1<<1), 181 | CAR_ENGINE_WARNING = (1<<2), 182 | CAR_SPEED_LIMITER = (1<<3), 183 | CAR_ABS = (1<<4), 184 | CAR_HANDBRAKE = (1<<5), 185 | CAR_TCS = (1<<6), 186 | CAR_SCS = (1<<7), 187 | }; 188 | 189 | // (Type#10) Tyre Flags (to be used with 'mTyreFlags') 190 | enum 191 | { 192 | TYRE_ATTACHED = (1<<0), 193 | TYRE_INFLATED = (1<<1), 194 | TYRE_IS_ON_GROUND = (1<<2), 195 | }; 196 | 197 | // (Type#11) Terrain Materials (to be used with 'mTerrain') 198 | enum 199 | { 200 | TERRAIN_ROAD = 0, 201 | TERRAIN_LOW_GRIP_ROAD, 202 | TERRAIN_BUMPY_ROAD1, 203 | TERRAIN_BUMPY_ROAD2, 204 | TERRAIN_BUMPY_ROAD3, 205 | TERRAIN_MARBLES, 206 | TERRAIN_GRASSY_BERMS, 207 | TERRAIN_GRASS, 208 | TERRAIN_GRAVEL, 209 | TERRAIN_BUMPY_GRAVEL, 210 | TERRAIN_RUMBLE_STRIPS, 211 | TERRAIN_DRAINS, 212 | TERRAIN_TYREWALLS, 213 | TERRAIN_CEMENTWALLS, 214 | TERRAIN_GUARDRAILS, 215 | TERRAIN_SAND, 216 | TERRAIN_BUMPY_SAND, 217 | TERRAIN_DIRT, 218 | TERRAIN_BUMPY_DIRT, 219 | TERRAIN_DIRT_ROAD, 220 | TERRAIN_BUMPY_DIRT_ROAD, 221 | TERRAIN_PAVEMENT, 222 | TERRAIN_DIRT_BANK, 223 | TERRAIN_WOOD, 224 | TERRAIN_DRY_VERGE, 225 | TERRAIN_EXIT_RUMBLE_STRIPS, 226 | TERRAIN_GRASSCRETE, 227 | TERRAIN_LONG_GRASS, 228 | TERRAIN_SLOPE_GRASS, 229 | TERRAIN_COBBLES, 230 | TERRAIN_SAND_ROAD, 231 | TERRAIN_BAKED_CLAY, 232 | TERRAIN_ASTROTURF, 233 | TERRAIN_SNOWHALF, 234 | TERRAIN_SNOWFULL, 235 | TERRAIN_DAMAGED_ROAD1, 236 | TERRAIN_TRAIN_TRACK_ROAD, 237 | TERRAIN_BUMPYCOBBLES, 238 | TERRAIN_ARIES_ONLY, 239 | TERRAIN_ORION_ONLY, 240 | TERRAIN_B1RUMBLES, 241 | TERRAIN_B2RUMBLES, 242 | TERRAIN_ROUGH_SAND_MEDIUM, 243 | TERRAIN_ROUGH_SAND_HEAVY, 244 | TERRAIN_SNOWWALLS, 245 | TERRAIN_ICE_ROAD, 246 | TERRAIN_RUNOFF_ROAD, 247 | TERRAIN_ILLEGAL_STRIP, 248 | TERRAIN_PAINT_CONCRETE, 249 | TERRAIN_PAINT_CONCRETE_ILLEGAL, 250 | TERRAIN_RALLY_TARMAC, 251 | 252 | //------------- 253 | TERRAIN_MAX 254 | }; 255 | 256 | // (Type#12) Crash Damage State (to be used with 'mCrashState') 257 | enum 258 | { 259 | CRASH_DAMAGE_NONE = 0, 260 | CRASH_DAMAGE_OFFTRACK, 261 | CRASH_DAMAGE_LARGE_PROP, 262 | CRASH_DAMAGE_SPINNING, 263 | CRASH_DAMAGE_ROLLING, 264 | //------------- 265 | CRASH_MAX 266 | }; 267 | 268 | // (Type#13) ParticipantInfo struct (to be used with 'mParticipantInfo') 269 | typedef struct 270 | { 271 | bool mIsActive; 272 | char mName[STRING_LENGTH_MAX]; // [ string ] 273 | float mWorldPosition[VEC_MAX]; // [ UNITS = World Space X Y Z ] 274 | float mCurrentLapDistance; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 275 | unsigned int mRacePosition; // [ RANGE = 1->... ] [ UNSET = 0 ] 276 | unsigned int mLapsCompleted; // [ RANGE = 0->... ] [ UNSET = 0 ] 277 | unsigned int mCurrentLap; // [ RANGE = 0->... ] [ UNSET = 0 ] 278 | int mCurrentSector; // [ RANGE = 0->... ] [ UNSET = -1 ] 279 | } ParticipantInfo; 280 | 281 | // (Type#14) DrsState Flags (to be used with 'mDrsState') 282 | enum DrsState 283 | { 284 | DRS_INSTALLED = (1<<0), // Vehicle has DRS capability 285 | DRS_ZONE_RULES = (1<<1), // 1 if DRS uses F1 style rules 286 | DRS_AVAILABLE_NEXT = (1<<2), // detection zone was triggered (only applies to f1 style rules) 287 | DRS_AVAILABLE_NOW = (1<<3), // detection zone was triggered and we are now in the zone (only applies to f1 style rules) 288 | DRS_ACTIVE = (1<<4), // Wing is in activated state 289 | }; 290 | 291 | // *** Shared Memory *** 292 | 293 | typedef struct 294 | { 295 | // Version Number 296 | unsigned int mVersion; // [ RANGE = 0->... ] 297 | unsigned int mBuildVersionNumber; // [ RANGE = 0->... ] [ UNSET = 0 ] 298 | 299 | // Game States 300 | unsigned int mGameState; // [ enum (Type#1) Game state ] 301 | unsigned int mSessionState; // [ enum (Type#2) Session state ] 302 | unsigned int mRaceState; // [ enum (Type#3) Race State ] 303 | 304 | // Participant Info 305 | int mViewedParticipantIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 306 | int mNumParticipants; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 307 | ParticipantInfo mParticipantInfo[STORED_PARTICIPANTS_MAX]; // [ struct (Type#13) ParticipantInfo struct ] 308 | 309 | // Unfiltered Input 310 | float mUnfilteredThrottle; // [ RANGE = 0.0f->1.0f ] 311 | float mUnfilteredBrake; // [ RANGE = 0.0f->1.0f ] 312 | float mUnfilteredSteering; // [ RANGE = -1.0f->1.0f ] 313 | float mUnfilteredClutch; // [ RANGE = 0.0f->1.0f ] 314 | 315 | // Vehicle information 316 | char mCarName[STRING_LENGTH_MAX]; // [ string ] 317 | char mCarClassName[STRING_LENGTH_MAX]; // [ string ] 318 | 319 | // Event information 320 | unsigned int mLapsInEvent; // [ RANGE = 0->... ] [ UNSET = 0 ] 321 | char mTrackLocation[STRING_LENGTH_MAX]; // [ string ] - untranslated shortened English name 322 | char mTrackVariation[STRING_LENGTH_MAX]; // [ string ]- untranslated shortened English variation description 323 | float mTrackLength; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 324 | 325 | // Timings 326 | int mNumSectors; // [ RANGE = 0->... ] [ UNSET = -1 ] 327 | bool mLapInvalidated; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 328 | float mBestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 329 | float mLastLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 330 | float mCurrentTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 331 | float mSplitTimeAhead; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 332 | float mSplitTimeBehind; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 333 | float mSplitTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 334 | float mEventTimeRemaining; // [ UNITS = milli-seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 335 | float mPersonalFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 336 | float mWorldFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 337 | float mCurrentSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 338 | float mCurrentSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 339 | float mCurrentSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 340 | float mFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 341 | float mFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 342 | float mFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 343 | float mPersonalFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 344 | float mPersonalFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 345 | float mPersonalFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 346 | float mWorldFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 347 | float mWorldFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 348 | float mWorldFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 349 | 350 | // Flags 351 | unsigned int mHighestFlagColour; // [ enum (Type#5) Flag Colour ] 352 | unsigned int mHighestFlagReason; // [ enum (Type#6) Flag Reason ] 353 | 354 | // Pit Info 355 | unsigned int mPitMode; // [ enum (Type#7) Pit Mode ] 356 | unsigned int mPitSchedule; // [ enum (Type#8) Pit Stop Schedule ] 357 | 358 | // Car State 359 | unsigned int mCarFlags; // [ enum (Type#9) Car Flags ] 360 | float mOilTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 361 | float mOilPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 362 | float mWaterTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 363 | float mWaterPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 364 | float mFuelPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 365 | float mFuelLevel; // [ RANGE = 0.0f->1.0f ] 366 | float mFuelCapacity; // [ UNITS = Liters ] [ RANGE = 0.0f->1.0f ] [ UNSET = 0.0f ] 367 | float mSpeed; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 368 | float mRpm; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 369 | float mMaxRPM; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 370 | float mBrake; // [ RANGE = 0.0f->1.0f ] 371 | float mThrottle; // [ RANGE = 0.0f->1.0f ] 372 | float mClutch; // [ RANGE = 0.0f->1.0f ] 373 | float mSteering; // [ RANGE = -1.0f->1.0f ] 374 | int mGear; // [ RANGE = -1 (Reverse) 0 (Neutral) 1 (Gear 1) 2 (Gear 2) etc... ] [ UNSET = 0 (Neutral) ] 375 | int mNumGears; // [ RANGE = 0->... ] [ UNSET = -1 ] 376 | float mOdometerKM; // [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 377 | bool mAntiLockActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 378 | int mLastOpponentCollisionIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 379 | float mLastOpponentCollisionMagnitude; // [ RANGE = 0.0f->... ] 380 | bool mBoostActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 381 | float mBoostAmount; // [ RANGE = 0.0f->100.0f ] 382 | 383 | // Motion & Device Related 384 | float mOrientation[VEC_MAX]; // [ UNITS = Euler Angles ] 385 | float mLocalVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 386 | float mWorldVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 387 | float mAngularVelocity[VEC_MAX]; // [ UNITS = Radians per-second ] 388 | float mLocalAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 389 | float mWorldAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 390 | float mExtentsCentre[VEC_MAX]; // [ UNITS = Local Space X Y Z ] 391 | 392 | // Wheels / Tyres 393 | unsigned int mTyreFlags[TYRE_MAX]; // [ enum (Type#10) Tyre Flags ] 394 | unsigned int mTerrain[TYRE_MAX]; // [ enum (Type#11) Terrain Materials ] 395 | float mTyreY[TYRE_MAX]; // [ UNITS = Local Space Y ] 396 | float mTyreRPS[TYRE_MAX]; // [ UNITS = Revolutions per second ] 397 | float mTyreSlipSpeed[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 398 | float mTyreTemp[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 399 | float mTyreGrip[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 400 | float mTyreHeightAboveGround[TYRE_MAX]; // [ UNITS = Local Space Y ] 401 | float mTyreLateralStiffness[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 402 | float mTyreWear[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 403 | float mBrakeDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 404 | float mSuspensionDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 405 | float mBrakeTempCelsius[TYRE_MAX]; // [ UNITS = Celsius ] 406 | float mTyreTreadTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 407 | float mTyreLayerTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 408 | float mTyreCarcassTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 409 | float mTyreRimTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 410 | float mTyreInternalAirTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 411 | 412 | // Car Damage 413 | unsigned int mCrashState; // [ enum (Type#12) Crash Damage State ] 414 | float mAeroDamage; // [ RANGE = 0.0f->1.0f ] 415 | float mEngineDamage; // [ RANGE = 0.0f->1.0f ] 416 | 417 | // Weather 418 | float mAmbientTemperature; // [ UNITS = Celsius ] [ UNSET = 25.0f ] 419 | float mTrackTemperature; // [ UNITS = Celsius ] [ UNSET = 30.0f ] 420 | float mRainDensity; // [ UNITS = How much rain will fall ] [ RANGE = 0.0f->1.0f ] 421 | float mWindSpeed; // [ RANGE = 0.0f->100.0f ] [ UNSET = 2.0f ] 422 | float mWindDirectionX; // [ UNITS = Normalised Vector X ] 423 | float mWindDirectionY; // [ UNITS = Normalised Vector Y ] 424 | float mCloudBrightness; // [ RANGE = 0.0f->... ] 425 | 426 | //PCars2 additions start, version 8 427 | // Sequence Number to help slightly with data integrity reads 428 | volatile unsigned int mSequenceNumber; // 0 at the start, incremented at start and end of writing, so odd when Shared Memory is being filled, even when the memory is not being touched 429 | 430 | //Additional car variables 431 | float mWheelLocalPositionY[TYRE_MAX]; // [ UNITS = Local Space Y ] 432 | float mSuspensionTravel[TYRE_MAX]; // [ UNITS = meters ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 433 | float mSuspensionVelocity[TYRE_MAX]; // [ UNITS = Rate of change of pushrod deflection ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 434 | float mAirPressure[TYRE_MAX]; // [ UNITS = PSI ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 435 | float mEngineSpeed; // [ UNITS = Rad/s ] [UNSET = 0.f ] 436 | float mEngineTorque; // [ UNITS = Newton Meters] [UNSET = 0.f ] [ RANGE = 0.0f->... ] 437 | float mWings[2]; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 438 | float mHandBrake; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 439 | 440 | // additional race variables 441 | float mCurrentSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 442 | float mCurrentSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 443 | float mCurrentSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 444 | float mFastestSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 445 | float mFastestSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 446 | float mFastestSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 447 | float mFastestLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 448 | float mLastLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 449 | bool mLapsInvalidated[STORED_PARTICIPANTS_MAX]; // [ UNITS = boolean for all participants ] [ RANGE = false->true ] [ UNSET = false ] 450 | unsigned int mRaceStates[STORED_PARTICIPANTS_MAX]; // [ enum (Type#3) Race State ] 451 | unsigned int mPitModes[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 452 | float mOrientations[STORED_PARTICIPANTS_MAX][VEC_MAX]; // [ UNITS = Euler Angles ] 453 | float mSpeeds[STORED_PARTICIPANTS_MAX]; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 454 | char mCarNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 455 | char mCarClassNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 456 | 457 | // additional race variables 458 | int mEnforcedPitStopLap; // [ UNITS = in which lap there will be a mandatory pitstop] [ RANGE = 0.0f->... ] [ UNSET = -1 ] 459 | char mTranslatedTrackLocation[STRING_LENGTH_MAX]; // [ string ] 460 | char mTranslatedTrackVariation[STRING_LENGTH_MAX]; // [ string ] 461 | float mBrakeBias; // [ RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 462 | float mTurboBoostPressure; // RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 463 | char mTyreCompound[TYRE_MAX][TYRE_COMPOUND_NAME_LENGTH_MAX];// [ strings ] 464 | unsigned int mPitSchedules[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 465 | unsigned int mHighestFlagColours[STORED_PARTICIPANTS_MAX]; // [ enum (Type#5) Flag Colour ] 466 | unsigned int mHighestFlagReasons[STORED_PARTICIPANTS_MAX]; // [ enum (Type#6) Flag Reason ] 467 | unsigned int mNationalities[STORED_PARTICIPANTS_MAX]; // [ nationality table , SP AND UNSET = 0 ] 468 | float mSnowDensity; // [ UNITS = How much snow will fall ] [ RANGE = 0.0f->1.0f ], this is non zero only in Winter and Snow seasons 469 | 470 | // AMS2 Additions (v10...) 471 | 472 | // Session info 473 | float mSessionDuration; // [ UNITS = minutes ] [ UNSET = 0.0f ] The scheduled session Length (unset means laps race. See mLapsInEvent) 474 | int mSessionAdditionalLaps; // The number of additional complete laps lead lap drivers must complete to finish a timed race after the session duration has elapsed. 475 | 476 | // Tyres 477 | float mTyreTempLeft[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 478 | float mTyreTempCenter[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 479 | float mTyreTempRight[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 480 | 481 | // DRS 482 | unsigned int mDrsState; // [ enum (Type#14) DrsState ] 483 | 484 | // Suspension 485 | float mRideHeight[TYRE_MAX]; // [ UNITS = cm ] 486 | 487 | // Input 488 | unsigned int mJoyPad0; // button mask 489 | unsigned int mDPad; // button mask 490 | 491 | int mAntiLockSetting; // [ UNSET = -1 ] Current ABS garage setting. Valid under player control only. 492 | int mTractionControlSetting; // [ UNSET = -1 ] Current TCS garage setting. Valid under player control only. 493 | 494 | } SharedMemory; 495 | 496 | 497 | #endif // _SHARED_MEMORY_HPP_ 498 | -------------------------------------------------------------------------------- /SharedMemory_v12.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | Description: 3 | Storage structure for storing and updating shared memory 4 | 5 | Copyright (c) MWL. All rights reserved. 6 | *************************************************************************************************/ 7 | 8 | #ifndef _SHARED_MEMORY_HPP_ 9 | #define _SHARED_MEMORY_HPP_ 10 | 11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // NOTES: 13 | // 14 | // -The shared memory variables will be updated once per graphics frame. 15 | // 16 | // -Each variable comes with a UNIT, RANGE, and UNSET description where applicable. 17 | // UNITS - Is the numeric form which a variable is stored in (e.g. KPH, Celsius) 18 | // RANGE - Is the min-max ranges for a variable 19 | // UNSET - Is the initialised/default/invalid value, depending on the variables usage 20 | // 21 | // -Constant/unchanging values are included in the data, such as 'maxRPM', 'fuelCapacity' - this is done to allow percentage calculations. 22 | // 23 | // -Also included are 12 unique enumerated types, to be used against the mentioned flag/state variables 24 | // 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | 28 | // *** Types *** 29 | 30 | // Header version number to test against 31 | enum 32 | { 33 | SHARED_MEMORY_VERSION = 12 34 | }; 35 | 36 | // Maximum allowed length of string 37 | enum 38 | { 39 | STRING_LENGTH_MAX = 64 40 | }; 41 | 42 | // Maximum number of general participant information allowed to be stored in memory-mapped file 43 | enum 44 | { 45 | STORED_PARTICIPANTS_MAX = 64 46 | }; 47 | 48 | // Maximum length of a tyre compound name 49 | enum 50 | { 51 | TYRE_COMPOUND_NAME_LENGTH_MAX = 40 52 | }; 53 | 54 | // Tyres 55 | enum 56 | { 57 | TYRE_FRONT_LEFT = 0, 58 | TYRE_FRONT_RIGHT, 59 | TYRE_REAR_LEFT, 60 | TYRE_REAR_RIGHT, 61 | //-------------- 62 | TYRE_MAX 63 | }; 64 | 65 | // Vector 66 | enum 67 | { 68 | VEC_X = 0, 69 | VEC_Y, 70 | VEC_Z, 71 | //------------- 72 | VEC_MAX 73 | }; 74 | 75 | // (Type#1) GameState (to be used with 'mGameState') 76 | enum 77 | { 78 | GAME_EXITED = 0, 79 | GAME_FRONT_END, 80 | GAME_INGAME_PLAYING, 81 | GAME_INGAME_PAUSED, 82 | GAME_INGAME_INMENU_TIME_TICKING, 83 | GAME_INGAME_RESTARTING, 84 | GAME_INGAME_REPLAY, 85 | GAME_FRONT_END_REPLAY, 86 | //------------- 87 | GAME_MAX 88 | }; 89 | 90 | // (Type#2) Session state (to be used with 'mSessionState') 91 | enum 92 | { 93 | SESSION_INVALID = 0, 94 | SESSION_PRACTICE, 95 | SESSION_TEST, 96 | SESSION_QUALIFY, 97 | SESSION_FORMATION_LAP, 98 | SESSION_RACE, 99 | SESSION_TIME_ATTACK, 100 | //------------- 101 | SESSION_MAX 102 | }; 103 | 104 | // (Type#3) RaceState (to be used with 'mRaceState' and 'mRaceStates') 105 | enum 106 | { 107 | RACESTATE_INVALID, 108 | RACESTATE_NOT_STARTED, 109 | RACESTATE_RACING, 110 | RACESTATE_FINISHED, 111 | RACESTATE_DISQUALIFIED, 112 | RACESTATE_RETIRED, 113 | RACESTATE_DNF, 114 | //------------- 115 | RACESTATE_MAX 116 | }; 117 | 118 | // (Type#5) Flag Colours (to be used with 'mHighestFlagColour') 119 | enum 120 | { 121 | FLAG_COLOUR_NONE = 0, // Not used for actual flags, only for some query functions 122 | FLAG_COLOUR_GREEN, // End of danger zone, or race started 123 | FLAG_COLOUR_BLUE, // Faster car wants to overtake the participant 124 | FLAG_COLOUR_WHITE_SLOW_CAR, // Slow car in area 125 | FLAG_COLOUR_WHITE_FINAL_LAP, // Final Lap 126 | FLAG_COLOUR_RED, // Huge collisions where one or more cars become wrecked and block the track 127 | FLAG_COLOUR_YELLOW, // Danger on the racing surface itself 128 | FLAG_COLOUR_DOUBLE_YELLOW, // Danger that wholly or partly blocks the racing surface 129 | FLAG_COLOUR_BLACK_AND_WHITE, // Unsportsmanlike conduct 130 | FLAG_COLOUR_BLACK_ORANGE_CIRCLE, // Mechanical Failure 131 | FLAG_COLOUR_BLACK, // Participant disqualified 132 | FLAG_COLOUR_CHEQUERED, // Chequered flag 133 | //------------- 134 | FLAG_COLOUR_MAX 135 | }; 136 | 137 | // (Type#6) Flag Reason (to be used with 'mHighestFlagReason') 138 | enum 139 | { 140 | FLAG_REASON_NONE = 0, 141 | FLAG_REASON_SOLO_CRASH, 142 | FLAG_REASON_VEHICLE_CRASH, 143 | FLAG_REASON_VEHICLE_OBSTRUCTION, 144 | //------------- 145 | FLAG_REASON_MAX 146 | }; 147 | 148 | // (Type#7) Pit Mode (to be used with 'mPitMode') 149 | enum 150 | { 151 | PIT_MODE_NONE = 0, 152 | PIT_MODE_DRIVING_INTO_PITS, 153 | PIT_MODE_IN_PIT, 154 | PIT_MODE_DRIVING_OUT_OF_PITS, 155 | PIT_MODE_IN_GARAGE, 156 | PIT_MODE_DRIVING_OUT_OF_GARAGE, 157 | //------------- 158 | PIT_MODE_MAX 159 | }; 160 | 161 | // (Type#8) Pit Stop Schedule (to be used with 'mPitSchedule') 162 | enum 163 | { 164 | PIT_SCHEDULE_NONE = 0, // Nothing scheduled 165 | PIT_SCHEDULE_PLAYER_REQUESTED, // Used for standard pit sequence - requested by player 166 | PIT_SCHEDULE_ENGINEER_REQUESTED, // Used for standard pit sequence - requested by engineer 167 | PIT_SCHEDULE_DAMAGE_REQUESTED, // Used for standard pit sequence - requested by engineer for damage 168 | PIT_SCHEDULE_MANDATORY, // Used for standard pit sequence - requested by engineer from career enforced lap number 169 | PIT_SCHEDULE_DRIVE_THROUGH, // Used for drive-through penalty 170 | PIT_SCHEDULE_STOP_GO, // Used for stop-go penalty 171 | PIT_SCHEDULE_PITSPOT_OCCUPIED, // Used for drive-through when pitspot is occupied 172 | //------------- 173 | PIT_SCHEDULE_MAX 174 | }; 175 | 176 | // (Type#9) Car Flags (to be used with 'mCarFlags') 177 | enum CarFlags 178 | { 179 | CAR_HEADLIGHT = (1<<0), 180 | CAR_ENGINE_ACTIVE = (1<<1), 181 | CAR_ENGINE_WARNING = (1<<2), 182 | CAR_SPEED_LIMITER = (1<<3), 183 | CAR_ABS = (1<<4), 184 | CAR_HANDBRAKE = (1<<5), 185 | CAR_TCS = (1<<6), 186 | CAR_SCS = (1<<7), 187 | }; 188 | 189 | // (Type#10) Tyre Flags (to be used with 'mTyreFlags') 190 | enum 191 | { 192 | TYRE_ATTACHED = (1<<0), 193 | TYRE_INFLATED = (1<<1), 194 | TYRE_IS_ON_GROUND = (1<<2), 195 | }; 196 | 197 | // (Type#11) Terrain Materials (to be used with 'mTerrain') 198 | enum 199 | { 200 | TERRAIN_ROAD = 0, 201 | TERRAIN_LOW_GRIP_ROAD, 202 | TERRAIN_BUMPY_ROAD1, 203 | TERRAIN_BUMPY_ROAD2, 204 | TERRAIN_BUMPY_ROAD3, 205 | TERRAIN_MARBLES, 206 | TERRAIN_GRASSY_BERMS, 207 | TERRAIN_GRASS, 208 | TERRAIN_GRAVEL, 209 | TERRAIN_BUMPY_GRAVEL, 210 | TERRAIN_RUMBLE_STRIPS, 211 | TERRAIN_DRAINS, 212 | TERRAIN_TYREWALLS, 213 | TERRAIN_CEMENTWALLS, 214 | TERRAIN_GUARDRAILS, 215 | TERRAIN_SAND, 216 | TERRAIN_BUMPY_SAND, 217 | TERRAIN_DIRT, 218 | TERRAIN_BUMPY_DIRT, 219 | TERRAIN_DIRT_ROAD, 220 | TERRAIN_BUMPY_DIRT_ROAD, 221 | TERRAIN_PAVEMENT, 222 | TERRAIN_DIRT_BANK, 223 | TERRAIN_WOOD, 224 | TERRAIN_DRY_VERGE, 225 | TERRAIN_EXIT_RUMBLE_STRIPS, 226 | TERRAIN_GRASSCRETE, 227 | TERRAIN_LONG_GRASS, 228 | TERRAIN_SLOPE_GRASS, 229 | TERRAIN_COBBLES, 230 | TERRAIN_SAND_ROAD, 231 | TERRAIN_BAKED_CLAY, 232 | TERRAIN_ASTROTURF, 233 | TERRAIN_SNOWHALF, 234 | TERRAIN_SNOWFULL, 235 | TERRAIN_DAMAGED_ROAD1, 236 | TERRAIN_TRAIN_TRACK_ROAD, 237 | TERRAIN_BUMPYCOBBLES, 238 | TERRAIN_ARIES_ONLY, 239 | TERRAIN_ORION_ONLY, 240 | TERRAIN_B1RUMBLES, 241 | TERRAIN_B2RUMBLES, 242 | TERRAIN_ROUGH_SAND_MEDIUM, 243 | TERRAIN_ROUGH_SAND_HEAVY, 244 | TERRAIN_SNOWWALLS, 245 | TERRAIN_ICE_ROAD, 246 | TERRAIN_RUNOFF_ROAD, 247 | TERRAIN_ILLEGAL_STRIP, 248 | TERRAIN_PAINT_CONCRETE, 249 | TERRAIN_PAINT_CONCRETE_ILLEGAL, 250 | TERRAIN_RALLY_TARMAC, 251 | 252 | //------------- 253 | TERRAIN_MAX 254 | }; 255 | 256 | // (Type#12) Crash Damage State (to be used with 'mCrashState') 257 | enum 258 | { 259 | CRASH_DAMAGE_NONE = 0, 260 | CRASH_DAMAGE_OFFTRACK, 261 | CRASH_DAMAGE_LARGE_PROP, 262 | CRASH_DAMAGE_SPINNING, 263 | CRASH_DAMAGE_ROLLING, 264 | //------------- 265 | CRASH_MAX 266 | }; 267 | 268 | // (Type#13) ParticipantInfo struct (to be used with 'mParticipantInfo') 269 | typedef struct 270 | { 271 | bool mIsActive; 272 | char mName[STRING_LENGTH_MAX]; // [ string ] 273 | float mWorldPosition[VEC_MAX]; // [ UNITS = World Space X Y Z ] 274 | float mCurrentLapDistance; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 275 | unsigned int mRacePosition; // [ RANGE = 1->... ] [ UNSET = 0 ] 276 | unsigned int mLapsCompleted; // [ RANGE = 0->... ] [ UNSET = 0 ] 277 | unsigned int mCurrentLap; // [ RANGE = 0->... ] [ UNSET = 0 ] 278 | int mCurrentSector; // [ RANGE = 0->... ] [ UNSET = -1 ] 279 | } ParticipantInfo; 280 | 281 | // (Type#14) DrsState Flags (to be used with 'mDrsState') 282 | enum DrsState 283 | { 284 | DRS_INSTALLED = (1<<0), // Vehicle has DRS capability 285 | DRS_ZONE_RULES = (1<<1), // 1 if DRS uses F1 style rules 286 | DRS_AVAILABLE_NEXT = (1<<2), // detection zone was triggered (only applies to f1 style rules) 287 | DRS_AVAILABLE_NOW = (1<<3), // detection zone was triggered and we are now in the zone (only applies to f1 style rules) 288 | DRS_ACTIVE = (1<<4), // Wing is in activated state 289 | }; 290 | 291 | // (Type#15) ErsDeploymentMode (to be used with 'mErsDeploymentMode') 292 | enum ErsDeploymentMode 293 | { 294 | ERS_DEPLOYMENT_MODE_NONE = 0, // The vehicle does not support deployment modes 295 | ERS_DEPLOYMENT_MODE_OFF, // Regen only, no deployment 296 | ERS_DEPLOYMENT_MODE_BUILD, // Heavy emphasis towards regen 297 | ERS_DEPLOYMENT_MODE_BALANCED, // Deployment map automatically adjusted to try and maintain target SoC 298 | ERS_DEPLOYMENT_MODE_ATTACK, // More aggressive deployment, no target SoC 299 | ERS_DEPLOYMENT_MODE_QUAL, // Maximum deployment, no target Soc 300 | }; 301 | 302 | // *** Shared Memory *** 303 | 304 | typedef struct 305 | { 306 | // Version Number 307 | unsigned int mVersion; // [ RANGE = 0->... ] 308 | unsigned int mBuildVersionNumber; // [ RANGE = 0->... ] [ UNSET = 0 ] 309 | 310 | // Game States 311 | unsigned int mGameState; // [ enum (Type#1) Game state ] 312 | unsigned int mSessionState; // [ enum (Type#2) Session state ] 313 | unsigned int mRaceState; // [ enum (Type#3) Race State ] 314 | 315 | // Participant Info 316 | int mViewedParticipantIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 317 | int mNumParticipants; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 318 | ParticipantInfo mParticipantInfo[STORED_PARTICIPANTS_MAX]; // [ struct (Type#13) ParticipantInfo struct ] 319 | 320 | // Unfiltered Input 321 | float mUnfilteredThrottle; // [ RANGE = 0.0f->1.0f ] 322 | float mUnfilteredBrake; // [ RANGE = 0.0f->1.0f ] 323 | float mUnfilteredSteering; // [ RANGE = -1.0f->1.0f ] 324 | float mUnfilteredClutch; // [ RANGE = 0.0f->1.0f ] 325 | 326 | // Vehicle information 327 | char mCarName[STRING_LENGTH_MAX]; // [ string ] 328 | char mCarClassName[STRING_LENGTH_MAX]; // [ string ] 329 | 330 | // Event information 331 | unsigned int mLapsInEvent; // [ RANGE = 0->... ] [ UNSET = 0 ] 332 | char mTrackLocation[STRING_LENGTH_MAX]; // [ string ] - untranslated shortened English name 333 | char mTrackVariation[STRING_LENGTH_MAX]; // [ string ]- untranslated shortened English variation description 334 | float mTrackLength; // [ UNITS = Metres ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 335 | 336 | // Timings 337 | int mNumSectors; // [ RANGE = 0->... ] [ UNSET = -1 ] 338 | bool mLapInvalidated; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 339 | float mBestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 340 | float mLastLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 341 | float mCurrentTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 342 | float mSplitTimeAhead; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 343 | float mSplitTimeBehind; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 344 | float mSplitTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 345 | float mEventTimeRemaining; // [ UNITS = milli-seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 346 | float mPersonalFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 347 | float mWorldFastestLapTime; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 348 | float mCurrentSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 349 | float mCurrentSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 350 | float mCurrentSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 351 | float mFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 352 | float mFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 353 | float mFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 354 | float mPersonalFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 355 | float mPersonalFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 356 | float mPersonalFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 357 | float mWorldFastestSector1Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 358 | float mWorldFastestSector2Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 359 | float mWorldFastestSector3Time; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 360 | 361 | // Flags 362 | unsigned int mHighestFlagColour; // [ enum (Type#5) Flag Colour ] 363 | unsigned int mHighestFlagReason; // [ enum (Type#6) Flag Reason ] 364 | 365 | // Pit Info 366 | unsigned int mPitMode; // [ enum (Type#7) Pit Mode ] 367 | unsigned int mPitSchedule; // [ enum (Type#8) Pit Stop Schedule ] 368 | 369 | // Car State 370 | unsigned int mCarFlags; // [ enum (Type#9) Car Flags ] 371 | float mOilTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 372 | float mOilPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 373 | float mWaterTempCelsius; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 374 | float mWaterPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 375 | float mFuelPressureKPa; // [ UNITS = Kilopascal ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 376 | float mFuelLevel; // [ RANGE = 0.0f->1.0f ] 377 | float mFuelCapacity; // [ UNITS = Liters ] [ RANGE = 0.0f->1.0f ] [ UNSET = 0.0f ] 378 | float mSpeed; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 379 | float mRpm; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 380 | float mMaxRPM; // [ UNITS = Revolutions per minute ] [ RANGE = 0.0f->... ] [ UNSET = 0.0f ] 381 | float mBrake; // [ RANGE = 0.0f->1.0f ] 382 | float mThrottle; // [ RANGE = 0.0f->1.0f ] 383 | float mClutch; // [ RANGE = 0.0f->1.0f ] 384 | float mSteering; // [ RANGE = -1.0f->1.0f ] 385 | int mGear; // [ RANGE = -1 (Reverse) 0 (Neutral) 1 (Gear 1) 2 (Gear 2) etc... ] [ UNSET = 0 (Neutral) ] 386 | int mNumGears; // [ RANGE = 0->... ] [ UNSET = -1 ] 387 | float mOdometerKM; // [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 388 | bool mAntiLockActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 389 | int mLastOpponentCollisionIndex; // [ RANGE = 0->STORED_PARTICIPANTS_MAX ] [ UNSET = -1 ] 390 | float mLastOpponentCollisionMagnitude; // [ RANGE = 0.0f->... ] 391 | bool mBoostActive; // [ UNITS = boolean ] [ RANGE = false->true ] [ UNSET = false ] 392 | float mBoostAmount; // [ RANGE = 0.0f->100.0f ] 393 | 394 | // Motion & Device Related 395 | float mOrientation[VEC_MAX]; // [ UNITS = Euler Angles ] 396 | float mLocalVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 397 | float mWorldVelocity[VEC_MAX]; // [ UNITS = Metres per-second ] 398 | float mAngularVelocity[VEC_MAX]; // [ UNITS = Radians per-second ] 399 | float mLocalAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 400 | float mWorldAcceleration[VEC_MAX]; // [ UNITS = Metres per-second ] 401 | float mExtentsCentre[VEC_MAX]; // [ UNITS = Local Space X Y Z ] 402 | 403 | // Wheels / Tyres 404 | unsigned int mTyreFlags[TYRE_MAX]; // [ enum (Type#10) Tyre Flags ] 405 | unsigned int mTerrain[TYRE_MAX]; // [ enum (Type#11) Terrain Materials ] 406 | float mTyreY[TYRE_MAX]; // [ UNITS = Local Space Y ] 407 | float mTyreRPS[TYRE_MAX]; // [ UNITS = Revolutions per second ] 408 | float mTyreSlipSpeed[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 409 | float mTyreTemp[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 410 | float mTyreGrip[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 411 | float mTyreHeightAboveGround[TYRE_MAX]; // [ UNITS = Local Space Y ] 412 | float mTyreLateralStiffness[TYRE_MAX]; // OBSOLETE, kept for backward compatibility only 413 | float mTyreWear[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 414 | float mBrakeDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 415 | float mSuspensionDamage[TYRE_MAX]; // [ RANGE = 0.0f->1.0f ] 416 | float mBrakeTempCelsius[TYRE_MAX]; // [ UNITS = Celsius ] 417 | float mTyreTreadTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 418 | float mTyreLayerTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 419 | float mTyreCarcassTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 420 | float mTyreRimTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 421 | float mTyreInternalAirTemp[TYRE_MAX]; // [ UNITS = Kelvin ] 422 | 423 | // Car Damage 424 | unsigned int mCrashState; // [ enum (Type#12) Crash Damage State ] 425 | float mAeroDamage; // [ RANGE = 0.0f->1.0f ] 426 | float mEngineDamage; // [ RANGE = 0.0f->1.0f ] 427 | 428 | // Weather 429 | float mAmbientTemperature; // [ UNITS = Celsius ] [ UNSET = 25.0f ] 430 | float mTrackTemperature; // [ UNITS = Celsius ] [ UNSET = 30.0f ] 431 | float mRainDensity; // [ UNITS = How much rain will fall ] [ RANGE = 0.0f->1.0f ] 432 | float mWindSpeed; // [ RANGE = 0.0f->100.0f ] [ UNSET = 2.0f ] 433 | float mWindDirectionX; // [ UNITS = Normalised Vector X ] 434 | float mWindDirectionY; // [ UNITS = Normalised Vector Y ] 435 | float mCloudBrightness; // [ RANGE = 0.0f->... ] 436 | 437 | //PCars2 additions start, version 8 438 | // Sequence Number to help slightly with data integrity reads 439 | volatile unsigned int mSequenceNumber; // 0 at the start, incremented at start and end of writing, so odd when Shared Memory is being filled, even when the memory is not being touched 440 | 441 | //Additional car variables 442 | float mWheelLocalPositionY[TYRE_MAX]; // [ UNITS = Local Space Y ] 443 | float mSuspensionTravel[TYRE_MAX]; // [ UNITS = meters ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 444 | float mSuspensionVelocity[TYRE_MAX]; // [ UNITS = Rate of change of pushrod deflection ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 445 | float mAirPressure[TYRE_MAX]; // [ UNITS = PSI ] [ RANGE 0.f =>... ] [ UNSET = 0.0f ] 446 | float mEngineSpeed; // [ UNITS = Rad/s ] [UNSET = 0.f ] 447 | float mEngineTorque; // [ UNITS = Newton Meters] [UNSET = 0.f ] [ RANGE = 0.0f->... ] 448 | float mWings[2]; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 449 | float mHandBrake; // [ RANGE = 0.0f->1.0f ] [UNSET = 0.f ] 450 | 451 | // additional race variables 452 | float mCurrentSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 453 | float mCurrentSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 454 | float mCurrentSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 455 | float mFastestSector1Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 456 | float mFastestSector2Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 457 | float mFastestSector3Times[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 458 | float mFastestLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 459 | float mLastLapTimes[STORED_PARTICIPANTS_MAX]; // [ UNITS = seconds ] [ RANGE = 0.0f->... ] [ UNSET = -1.0f ] 460 | bool mLapsInvalidated[STORED_PARTICIPANTS_MAX]; // [ UNITS = boolean for all participants ] [ RANGE = false->true ] [ UNSET = false ] 461 | unsigned int mRaceStates[STORED_PARTICIPANTS_MAX]; // [ enum (Type#3) Race State ] 462 | unsigned int mPitModes[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 463 | float mOrientations[STORED_PARTICIPANTS_MAX][VEC_MAX]; // [ UNITS = Euler Angles ] 464 | float mSpeeds[STORED_PARTICIPANTS_MAX]; // [ UNITS = Metres per-second ] [ RANGE = 0.0f->... ] 465 | char mCarNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 466 | char mCarClassNames[STORED_PARTICIPANTS_MAX][STRING_LENGTH_MAX]; // [ string ] 467 | 468 | // additional race variables 469 | int mEnforcedPitStopLap; // [ UNITS = in which lap there will be a mandatory pitstop] [ RANGE = 0.0f->... ] [ UNSET = -1 ] 470 | char mTranslatedTrackLocation[STRING_LENGTH_MAX]; // [ string ] 471 | char mTranslatedTrackVariation[STRING_LENGTH_MAX]; // [ string ] 472 | float mBrakeBias; // [ RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 473 | float mTurboBoostPressure; // RANGE = 0.0f->1.0f... ] [ UNSET = -1.0f ] 474 | char mTyreCompound[TYRE_MAX][TYRE_COMPOUND_NAME_LENGTH_MAX];// [ strings ] 475 | unsigned int mPitSchedules[STORED_PARTICIPANTS_MAX]; // [ enum (Type#7) Pit Mode ] 476 | unsigned int mHighestFlagColours[STORED_PARTICIPANTS_MAX]; // [ enum (Type#5) Flag Colour ] 477 | unsigned int mHighestFlagReasons[STORED_PARTICIPANTS_MAX]; // [ enum (Type#6) Flag Reason ] 478 | unsigned int mNationalities[STORED_PARTICIPANTS_MAX]; // [ nationality table , SP AND UNSET = 0 ] 479 | float mSnowDensity; // [ UNITS = How much snow will fall ] [ RANGE = 0.0f->1.0f ], this is non zero only in Winter and Snow seasons 480 | 481 | // AMS2 Additions (v10...) 482 | 483 | // Session info 484 | float mSessionDuration; // [ UNITS = minutes ] [ UNSET = 0.0f ] The scheduled session Length (unset means laps race. See mLapsInEvent) 485 | int mSessionAdditionalLaps; // The number of additional complete laps lead lap drivers must complete to finish a timed race after the session duration has elapsed. 486 | 487 | // Tyres 488 | float mTyreTempLeft[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 489 | float mTyreTempCenter[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 490 | float mTyreTempRight[TYRE_MAX]; // [ UNITS = Celsius ] [ UNSET = 0.0f ] 491 | 492 | // DRS 493 | unsigned int mDrsState; // [ enum (Type#14) DrsState ] 494 | 495 | // Suspension 496 | float mRideHeight[TYRE_MAX]; // [ UNITS = cm ] 497 | 498 | // Input 499 | unsigned int mJoyPad0; // button mask 500 | unsigned int mDPad; // button mask 501 | 502 | int mAntiLockSetting; // [ UNSET = -1 ] Current ABS garage setting. Valid under player control only. 503 | int mTractionControlSetting; // [ UNSET = -1 ] Current ABS garage setting. Valid under player control only. 504 | 505 | // ERS 506 | int mErsDeploymentMode; // [ enum (Type#15) ErsDeploymentMode ] 507 | bool mErsAutoModeEnabled; // true if the deployment mode was selected by auto system. Valid only when mErsDeploymentMode > ERS_DEPLOYMENT_MODE_NONE 508 | 509 | // Clutch State & Damage 510 | float mClutchTemp; // [ UNITS = Kelvin ] [ UNSET = -273.16 ] 511 | float mClutchWear; // [ RANGE = 0.0f->1.0f... ] 512 | bool mClutchOverheated; // true if clutch performance is degraded due to overheating 513 | bool mClutchSlipping; // true if clutch is slipping (can be induced by overheating or wear) 514 | 515 | 516 | 517 | } SharedMemory; 518 | 519 | 520 | #endif // _SHARED_MEMORY_HPP_ 521 | --------------------------------------------------------------------------------