diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj
index a83cc21a07..3a650aa77d 100644
--- a/projects/openrct2.vcxproj
+++ b/projects/openrct2.vcxproj
@@ -200,6 +200,7 @@
+
@@ -207,6 +208,7 @@
+
diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters
index d409975888..fce4be6300 100644
--- a/projects/openrct2.vcxproj.filters
+++ b/projects/openrct2.vcxproj.filters
@@ -342,7 +342,6 @@
Source\Windows
-
Source\Windows
@@ -368,7 +367,7 @@
Source\Interface
-
+
Source\World
@@ -622,5 +621,11 @@
Source\Ride
+
+ Source\World
+
+
+ Source\World
+
\ No newline at end of file
diff --git a/src/drawing/drawing.c b/src/drawing/drawing.c
index 99b9988fd4..d1ba7ec55a 100644
--- a/src/drawing/drawing.c
+++ b/src/drawing/drawing.c
@@ -24,6 +24,7 @@
#include "../interface/window.h"
#include "../platform/platform.h"
#include "../object.h"
+#include "../world/water.h"
#include "drawing.h"
// HACK These were originally passed back through registers
@@ -152,12 +153,12 @@ void gfx_transpose_palette(int pal, unsigned char product)
/* rct2: 0x006837E3 */
void load_palette(){
- uint8* water_chunk = object_entry_groups[OBJECT_TYPE_WATER].chunks[0];
+ rct_water_type* water_type = (rct_water_type*)object_entry_groups[OBJECT_TYPE_WATER].chunks[0];
uint32 palette = 0x5FC;
- if (water_chunk != (uint8*)-1){
- palette = *((uint32*)(water_chunk + 2));
+ if ((sint32)water_type != -1){
+ palette = water_type->image_id;
}
rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
diff --git a/src/editor.c b/src/editor.c
index 5065445e99..2a083a00cc 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -159,7 +159,7 @@ void editor_convert_save_to_scenario()
format_string(s6Info->details, STR_NO_DETAILS_YET, NULL);
s6Info->name[0] = 0;
-}
+ }
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR;
s6Info->var_000 = 4;
diff --git a/src/game.c b/src/game.c
index adac305a35..a0c0feafda 100644
--- a/src/game.c
+++ b/src/game.c
@@ -51,6 +51,7 @@
#include "world/climate.h"
#include "world/park.h"
#include "world/sprite.h"
+#include "world/water.h"
int gGameSpeed = 1;
@@ -82,11 +83,14 @@ void game_create_windows()
*/
void update_palette_effects()
{
+ rct_water_type* water_type = (rct_water_type*)object_entry_groups[OBJECT_TYPE_WATER].chunks[0];
+
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 1) {
// change palette to lighter color during lightning
int palette = 1532;
- if (RCT2_GLOBAL(0x009ADAE0, sint32) != -1) {
- palette = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 2, int);
+
+ if ((sint32)water_type != -1) {
+ palette = water_type->image_id;
}
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
int xoffset = g1_element.x_offset;
@@ -104,9 +108,11 @@ void update_palette_effects()
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
// change palette back to normal after lightning
int palette = 1532;
- if (RCT2_GLOBAL(0x009ADAE0, sint32) != -1) {
- palette = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 2, int);
+
+ if ((sint32)water_type != -1) {
+ palette = water_type->image_id;
}
+
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
int xoffset = g1_element.x_offset;
xoffset = xoffset * 4;
@@ -129,8 +135,8 @@ void update_palette_effects()
uint32 j = RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, uint32);
j = (((uint16)((~j / 2) * 128) * 15) >> 16);
int p = 1533;
- if (RCT2_GLOBAL(0x009ADAE0, int) != -1) {
- p = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 0x6, int);
+ if ((sint32)water_type != -1) {
+ p = water_type->var_06;
}
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[q + p];
uint8* vs = &g1_element.offset[j * 3];
@@ -148,8 +154,8 @@ void update_palette_effects()
}
p = 1536;
- if (RCT2_GLOBAL(0x009ADAE0, int) != -1) {
- p = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 0xA, int);
+ if ((sint32)water_type != -1) {
+ p = water_type->var_0A;
}
g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[q + p];
vs = &g1_element.offset[j * 3];
diff --git a/src/object.c b/src/object.c
index 45644db5c6..7a4ea1f8a3 100644
--- a/src/object.c
+++ b/src/object.c
@@ -26,6 +26,8 @@
#include "util/sawyercoding.h"
#include "drawing/drawing.h"
#include "world/footpath.h"
+#include "world/water.h"
+#include "world/entrance.h"
#include "scenario.h"
int object_load_entry(const char *path, rct_object_entry *outEntry)
@@ -842,30 +844,40 @@ int paint_park_entrance_entry(int flags, int ebx, int ecx, int edx, rct_drawpixe
if ((flags & 0xFF) == 0){
// Object Load
- uint8_t* pStringTable = (uint8_t*)(esi + 8);
- ((rct_string_id*)esi)[0] = object_get_localised_text(&pStringTable, ecx, ebx, 0);
- int image_id = object_chunk_load_image_directory(&pStringTable);
- ((uint32_t*)(esi + 2))[0] = image_id;
- if (RCT2_GLOBAL(0x9ADAF4, uint32_t) != 0xFFFFFFFF) RCT2_GLOBAL(0x9ADAF4, uint16_t*)[0] = 0;
+ rct_entrance_type* entrance_type = (rct_entrance_type*)esi;
+ uint8* pStringTable = (uint8*)(esi + sizeof(rct_entrance_type));
+
+ entrance_type->string_idx = object_get_localised_text(&pStringTable, ecx, ebx, 0);
+
+ entrance_type->image_id = object_chunk_load_image_directory(&pStringTable);
+
+ if (RCT2_GLOBAL(0x9ADAF4, uint32) != 0xFFFFFFFF) *RCT2_GLOBAL(0x9ADAF4, uint16*) = 0;
}
else if ((flags & 0xFF) == 1){
// Object Unload
- ((rct_string_id*)esi)[0] = 0;
- ((uint32_t*)(esi + 2))[0] = 0;
+ rct_entrance_type* entrance_type = (rct_entrance_type*)esi;
+ entrance_type->string_idx = 0;
+ entrance_type->image_id = 0;
}
else if ((flags & 0xFF) == 2){
return 0;
}
else if ((flags & 0xFF) == 3){
+ int x = ecx, y = edx;
if (!((flags >> 8) & 0xFF))
{
- dpi = clip_drawpixelinfo(dpi, ecx - 56, 112, edx - 56, 112);
+ rct_entrance_type* entrance_type = (rct_entrance_type*)ebp;
+
+ dpi = clip_drawpixelinfo(dpi, x - 56, 112, y - 56, 112);
if (dpi == NULL) return flags;
- int image_id = ((uint32_t*)(ebp + 2))[0];
+
+ int image_id = entrance_type->image_id;
+
gfx_draw_sprite(dpi, image_id + 1, 24, 68, ebp);
gfx_draw_sprite(dpi, image_id, 56, 84, ebp);
gfx_draw_sprite(dpi, image_id + 2, 88, 100, ebp);
+
rct2_free(dpi);
}
}
@@ -878,15 +890,18 @@ int paint_water_entry(int flags, int ebx, int ecx, int edx, rct_drawpixelinfo* d
if ((flags & 0xFF) == 0){
// Object Load
- uint8_t* pStringTable = (uint8_t*)(esi + 0x10);
- ((rct_string_id*)esi)[0] = object_get_localised_text(&pStringTable, ecx, ebx, 0);
+ rct_water_type* water_type = (rct_water_type*)esi;
+
+ uint8_t* pStringTable = (uint8_t*)(esi + sizeof(rct_water_type));
+ water_type->string_idx = object_get_localised_text(&pStringTable, ecx, ebx, 0);
+
int image_id = object_chunk_load_image_directory(&pStringTable);
- ((uint32_t*)(esi + 2))[0] = image_id;
- image_id++;
- ((uint32_t*)(esi + 6))[0] = image_id;
- image_id += 3;
- ((uint32_t*)(esi + 0xA))[0] = image_id;
- if (RCT2_GLOBAL(0x9ADAF4, uint32_t) != 0xFFFFFFFF) RCT2_GLOBAL(0x9ADAF4, uint16_t*)[0] = 0;
+ water_type->image_id = image_id;
+ water_type->var_06 = image_id + 1;
+ water_type->var_0A = image_id + 4;
+
+ if (RCT2_GLOBAL(0x9ADAF4, uint32) != 0xFFFFFFFF) *RCT2_GLOBAL(0x9ADAF4, uint16*) = 0;
+
if (RCT2_GLOBAL(0x9ADAFD, uint8_t) == 0)
{
load_palette();
@@ -896,17 +911,18 @@ int paint_water_entry(int flags, int ebx, int ecx, int edx, rct_drawpixelinfo* d
else if ((flags & 0xFF) == 1){
// Object Unload
- ((rct_string_id*)esi)[0] = 0;
- ((uint32_t*)(esi + 2))[0] = 0;
- ((uint32_t*)(esi + 6))[0] = 0;
- ((uint32_t*)(esi + 0xA))[0] = 0;
+ rct_water_type* water_type = (rct_water_type*)esi;
+ water_type->string_idx = 0;
+ water_type->image_id = 0;
+ water_type->var_06 = 0;
+ water_type->var_0A = 0;
}
else if ((flags & 0xFF) == 2){
return 0;
}
else if ((flags & 0xFF) == 3){
- if (!((flags >> 8) & 0xFF)) gfx_draw_string_centred(dpi, 3326, ecx, edx, 0, (void*)esi);
-
+ if (!((flags >> 8) & 0xFF))
+ gfx_draw_string_centred(dpi, 3326, ecx, edx, 0, (void*)esi);
}
return flags;
}
diff --git a/src/scenario.c b/src/scenario.c
index 056a09b169..c506685500 100644
--- a/src/scenario.c
+++ b/src/scenario.c
@@ -39,6 +39,7 @@
#include "world/map.h"
#include "world/park.h"
#include "world/sprite.h"
+#include "world/water.h"
static char _scenarioPath[MAX_PATH];
static const char *_scenarioFileName;
@@ -700,7 +701,9 @@ void scenario_update()
ride_check_all_reachable();
ride_update_favourited_stat();
- if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) {
+ rct_water_type* water_type = (rct_water_type*)object_entry_groups[OBJECT_TYPE_WATER].chunks[0];
+
+ if (month <= 1 && (sint32)water_type != -1 && water_type->var_0E & 1) {
// 100 attempts at finding some water to create a few ducks at
for (int i = 0; i < 100; i++) {
if (scenario_create_ducks())
diff --git a/src/world/entrance.h b/src/world/entrance.h
new file mode 100644
index 0000000000..6705c623f0
--- /dev/null
+++ b/src/world/entrance.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+* Copyright (c) 2014 Ted John
+* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
+*
+* This file is part of OpenRCT2.
+*
+* OpenRCT2 is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*****************************************************************************/
+
+#ifndef _ENTRANCE_H_
+#define _ENTRANCE_H_
+
+#include "../common.h"
+
+typedef struct {
+ rct_string_id string_idx; // 0x00
+ uint32 image_id; // 0x02
+ uint8 var_06;
+ uint8 var_07;
+} rct_entrance_type;
+
+#endif
\ No newline at end of file
diff --git a/src/world/water.h b/src/world/water.h
new file mode 100644
index 0000000000..72018c7ddc
--- /dev/null
+++ b/src/world/water.h
@@ -0,0 +1,34 @@
+/*****************************************************************************
+* Copyright (c) 2014 Ted John
+* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
+*
+* This file is part of OpenRCT2.
+*
+* OpenRCT2 is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*****************************************************************************/
+
+#ifndef _WATER_H_
+#define _WATER_H_
+
+#include "../common.h"
+
+typedef struct {
+ rct_string_id string_idx; // 0x00
+ uint32 image_id; // 0x02
+ uint32 var_06;
+ uint32 var_0A;
+ uint16 var_0E;
+} rct_water_type;
+
+#endif
\ No newline at end of file