1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Fix strict aliasing violations

Compiler only guarantees proper accesses to variables when using
variable's native type or `char` (i.e. single byte type) [1].

This commit fixes violations of this rule. In most cases changing code
to a simple cast was enough, some required a bit deeper modifications.

This fixes #2596.

[1] http://blog.qt.io/blog/2011/06/10/type-punning-and-strict-aliasing/
This commit is contained in:
Michał Janiszewski
2015-12-31 09:16:44 +01:00
parent db95b3ada3
commit 8a5d066efe
18 changed files with 98 additions and 77 deletions

View File

@@ -41,7 +41,7 @@
rct_window* g_window_list = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window);
uint8 TextInputDescriptionArgs[8];
uint16 TextInputDescriptionArgs[4];
widget_identifier gCurrentTextBox = { { 255, 0 }, 0 };
char gTextBoxInput[512] = { 0 };
int gMaxTextBoxInputLength = 0;

View File

@@ -27,11 +27,13 @@
#include "../ride/ride.h"
#include "../ride/vehicle.h"
#include "../world/park.h"
#include "../management/research.h"
#include "../scenario.h"
#include "colour.h"
struct rct_window;
union rct_window_event;
extern uint8 TextInputDescriptionArgs[8];
extern uint16 TextInputDescriptionArgs[4];
extern char gTextBoxInput[512];
extern int gMaxTextBoxInputLength;
extern int gTextBoxFrameNo;
@@ -264,7 +266,13 @@ typedef struct rct_window {
uint16 frame_no; // 0x48E updated every tic for motion in windows sprites
uint16 list_information_type; // 0x490 0 for none, Used as current position of marquee in window_peep
sint16 var_492;
uint32 highlighted_item; // 0x494
union { // 0x494
uint32 highlighted_item;
uint16 ride_colour;
rct_research_item* research_item;
rct_object_entry* object_entry;
rct_scenario_basic* scenario;
};
uint8 var_498[0x14];
sint16 selected_tab; // 0x4AC
sint16 var_4AE;