1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Refactored water and entrance paint functions

This commit is contained in:
Duncan Frost
2015-03-01 21:06:51 +00:00
parent 3ad1655379
commit 013be11aed
9 changed files with 138 additions and 38 deletions

View File

@@ -200,6 +200,7 @@
<ClInclude Include="..\src\windows\tooltip.h" />
<ClInclude Include="..\src\world\banner.h" />
<ClInclude Include="..\src\world\climate.h" />
<ClInclude Include="..\src\world\entrance.h" />
<ClInclude Include="..\src\world\footpath.h" />
<ClInclude Include="..\src\world\map.h" />
<ClInclude Include="..\src\world\mapgen.h" />
@@ -207,6 +208,7 @@
<ClInclude Include="..\src\world\park.h" />
<ClInclude Include="..\src\world\scenery.h" />
<ClInclude Include="..\src\world\sprite.h" />
<ClInclude Include="..\src\world\water.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libs\libs.vcxproj">

View File

@@ -342,7 +342,6 @@
<ClCompile Include="..\src\windows\text_input.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\windows\map_tooltip.c">
<Filter>Source\Windows</Filter>
</ClCompile>
@@ -368,7 +367,7 @@
<ClCompile Include="..\src\interface\viewport_interaction.c">
<Filter>Source\Interface</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\world\footpath.c">
<Filter>Source\World</Filter>
</ClCompile>
@@ -622,5 +621,11 @@
<ClInclude Include="..\src\ride\track_data.h">
<Filter>Source\Ride</Filter>
</ClInclude>
<ClInclude Include="..\src\world\entrance.h">
<Filter>Source\World</Filter>
</ClInclude>
<ClInclude Include="..\src\world\water.h">
<Filter>Source\World</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -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];

View File

@@ -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;

View File

@@ -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];

View File

@@ -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;
}

View File

@@ -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())

33
src/world/entrance.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#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

34
src/world/water.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#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