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

Merge remote-tracking branch 'upstream/master'

Conflicts:
	src/rct2.h
	src/window_game_bottom_toolbar.c
This commit is contained in:
Matthias Lanzinger
2014-05-01 22:30:44 +02:00
19 changed files with 8208 additions and 54 deletions

6260
lodepng/lodepng.c Normal file

File diff suppressed because it is too large Load Diff

1716
lodepng/lodepng.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -51,6 +51,7 @@
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\lodepng\lodepng.c" />
<ClCompile Include="..\src\audio.c" />
<ClCompile Include="..\src\climate.c" />
<ClCompile Include="..\src\config.c" />
@@ -129,13 +130,13 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)..\sdl\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\lodepng;$(SolutionDir)..\sdl\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\sdl\lib\x86;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\obj\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)..\sdl\include;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\lodepng;$(SolutionDir)..\sdl\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\sdl\lib\x86;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\obj\$(Configuration)\</IntDir>

View File

@@ -254,6 +254,9 @@
<ClCompile Include="..\src\window_about.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\lodepng\lodepng.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@@ -121,7 +121,7 @@
#define RCT2_ADDRESS_G1_ELEMENTS 0x009EBD28
#define RCT2_ADDRESS_CURRENT_MONTH_YEAR 0x00F663A8
#define RCT2_ADDRESS_CURRENT_DAY 0x00F663AA
#define RCT2_ADDRESS_CURRENT_MONTH_TICKS 0x00F663AA
#define RCT2_ADDRESS_MAP_ELEMENTS 0x00F663B8

View File

@@ -22,7 +22,7 @@
#include "date.h"
#include "rct2.h"
// rtc2: 0x00993988
// rct2: 0x00993988
const sint16 days_in_month[MONTH_COUNT] = { 31, 30, 31, 30, 31, 31, 30, 31 };
@@ -48,6 +48,6 @@ int date_get_total_months(int month, int year)
void date_reset()
{
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) = MONTH_MARCH;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, sint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32) = 0;
}

View File

@@ -174,7 +174,8 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
{
int i;
rct_ride *ride;
rct_sprite *sprite, *sprite_2;
rct_peep *peep;
rct_car *car;
switch (type) {
case NEWS_ITEM_RIDE:
@@ -195,37 +196,41 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
*z = edx;
}
break;
case NEWS_ITEM_PEEP_1:
sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
*x = sprite->unknown.x;
*y = sprite->unknown.y;
*z = sprite->unknown.z;
if (*x != SPRITE_LOCATION_NULL)
case NEWS_ITEM_PEEP_ON_RIDE:
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
*x = peep->x;
*y = peep->y;
*z = peep->z;
if (*((uint16*)x) != SPRITE_LOCATION_NULL)
break;
if (sprite->peep.state != 3 && sprite->peep.state != 7) {
if (peep->state != 3 && peep->state != 7) {
*x = SPRITE_LOCATION_NULL;
break;
}
ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[sprite->peep.current_ride]);
if (ride->var_1D0 & 1) {
// Find which ride peep is on
ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]);
// Check if there are trains on the track (first bit of var_1D0)
if (!(ride->var_1D0 & 1)) {
*x = SPRITE_LOCATION_NULL;
break;
}
sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->var_086[sprite->peep.var_6A]]);
for (i = 0; i < sprite->peep.var_6B; i++)
sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[*((uint16*)&sprite_2->pad_00[0x3E])]);
*x = sprite_2->unknown.x;
*y = sprite_2->unknown.y;
*z = sprite_2->unknown.z;
// Find the first car of the train peep is on
car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]);
// Find the actual car peep is on
for (i = 0; i < peep->current_car; i++)
car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]);
*x = car->x;
*y = car->y;
*z = car->z;
break;
case NEWS_ITEM_PEEP_2:
sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
*x = sprite->unknown.x;
*y = sprite->unknown.y;
*z = sprite->unknown.z;
case NEWS_ITEM_PEEP:
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
*x = peep->x;
*y = peep->y;
*z = peep->z;
break;
case NEWS_ITEM_BLANK:
{

View File

@@ -26,8 +26,8 @@
enum {
NEWS_ITEM_NULL,
NEWS_ITEM_RIDE,
NEWS_ITEM_PEEP_1,
NEWS_ITEM_PEEP_2,
NEWS_ITEM_PEEP_ON_RIDE,
NEWS_ITEM_PEEP,
NEWS_ITEM_MONEY,
NEWS_ITEM_BLANK,
NEWS_ITEM_SCENERY,

View File

@@ -19,10 +19,12 @@
*****************************************************************************/
#include "addresses.h"
#include "map.h"
#include "park.h"
#include "peep.h"
#include "ride.h"
#include "sprite.h"
#include "window.h"
int park_is_open()
{
@@ -38,6 +40,36 @@ void park_init()
RCT2_CALLPROC_EBPSAFE(0x00667132);
}
/**
*
* rct2: 0x0066A348
*/
int park_calculate_size()
{
int tiles, x, y;
rct_map_element *mapElement;
tiles = 0;
for (y = 0; y < 256; y++) {
for (x = 0; x < 256; x++) {
mapElement = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[y * 256 + x];
while (mapElement->type & MAP_ELEMENT_TYPE_MASK) {
mapElement++;
}
if (mapElement->properties.surface.ownership & 0x30)
tiles++;
}
}
if (tiles != RCT2_GLOBAL(0x013580EA, sint16)) {
RCT2_GLOBAL(0x013580EA, sint16) = tiles;
window_invalidate_by_id(WC_PARK_INFORMATION, 0);
}
return tiles;
}
/**
*
* rct2: 0x00669EAA

View File

@@ -53,6 +53,7 @@ enum {
int park_is_open();
void park_init();
int park_calculate_size();
int calculate_park_rating();
int calculate_park_value();

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* Copyright (c) 2014 Ted John, Peter Hill
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of OpenRCT2.
@@ -62,7 +62,10 @@ typedef struct {
uint8 pad_09;
sint16 var_0A;
uint16 var_0C;
uint8 var_0E[0x14];
sint16 x; // 0x0E
sint16 y; // 0x10
sint16 z; // 0x12
uint8 pad_14[0x0E];
uint16 name_string_idx; // 0x22
uint16 next_x; // 0x24
uint16 next_y; // 0x26
@@ -77,11 +80,15 @@ typedef struct {
uint8 var_31;
uint8 pad_32[0x08];
uint8 happiness; // 0x3A
uint8 pad_03B[0x2D];
uint8 var_03B;
uint8 nausea; // 0x3C
uint8 pad_03D[0x2B];
uint8 current_ride; // 0x68
uint8 var_6A;
uint8 var_6B;
uint8 pad_6C[0x30];
uint8 pad_6a; // 0x6A Part of current_ride?
uint8 current_train; // 0x6B
uint8 current_car; // 0x6C
uint8 current_seat; // 0x6d
uint8 pad_6C[0x2e];
uint32 id; // 0x9C
uint8 pad_A0[0x10];
rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0

View File

@@ -122,9 +122,10 @@ enum {
enum {
GAME_FLAGS_PARK_OPEN = (1 << 0),
GAME_FLAGS_BELOW_TREE_HEIGHT_ONLY = (1 << 5),
GAME_FLAGS_BELOW_TREE_HEIGHT_ONLY = (1 << 5),
GAME_FLAGS_NO_MONEY = (1 << 11),
GAME_FLAGS_PARK_FREE_ENTRY = (1 << 13)
GAME_FLAGS_PARK_FREE_ENTRY = (1 << 13),
GAME_FLAGS_18 = (1 << 18)
};
void rct2_endupdate();

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* Copyright (c) 2014 Ted John, Peter Hill
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of OpenRCT2.
@@ -38,7 +38,7 @@ typedef struct {
uint8 pad_052[0x18];
uint16 var_06A[4]; // probably entrance map coordinates
uint8 pad_072[0x14];
uint16 var_086[1];
uint16 train_car_map[1]; // 0x86 Points to the first car in the train
uint8 pad_088[0x68];
sint16 excitement; // 0x0F0
sint16 intensity; // 0x0F2

View File

@@ -22,6 +22,7 @@
#include <windows.h>
#include "addresses.h"
#include "date.h"
#include "game.h"
#include "map.h"
#include "news_item.h"
@@ -464,5 +465,54 @@ void scenario_load_and_play(rct_scenario_basic *scenario)
strcpy(0x0135924A, s6Info->details);
strcpy(0x0135920A, s6Info->name);
RCT2_CALLPROC_EBPSAFE(0x00678461);
// RCT2_CALLPROC_EBPSAFE(0x00678461);
if (RCT2_GLOBAL(0x009ADAE4, sint32) != -1) {
char *ebp = RCT2_GLOBAL(0x009ADAE4, char*);
format_string(0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0);
RCT2_GLOBAL(0x0141E9AE, uint16) = STR_CANT_RENAME_PARK;
RCT2_CALLPROC_X(0x006677F2, 1, 1, 0, *((int*)(0x0141ED68 + 0)), 33, *((int*)(0x0141ED68 + 8)), *((int*)(0x0141ED68 + 4)));
RCT2_CALLPROC_X(0x006677F2, 2, 1, 0, *((int*)(0x0141ED68 + 12)), 33, *((int*)(0x0141ED68 + 20)), *((int*)(0x0141ED68 + 16)));
RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, *((int*)(0x0141ED68 + 24)), 33, *((int*)(0x0141ED68 + 32)), *((int*)(0x0141ED68 + 28)));
format_string(0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0);
strcpy_s(0x0135920A, 32, 0x0141ED68);
format_string(0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0);
strcpy_s(RCT2_ADDRESS_SCENARIO_DETAILS, 256, 0x0141ED68);
}
strcpy(0x009ABB37, 0x009AB5DA);
format_string(0x009ABB37 + strlen(0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), 0x0013573D8);
strcat(0x009ABB37, ".SV6");
memset(0x001357848, 0, 56);
RCT2_GLOBAL(0x0135832C, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0;
RCT2_GLOBAL(0x01358334, uint32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000;
RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0;
RCT2_GLOBAL(0x013587D8, uint16) = 63;
RCT2_CALLPROC_EBPSAFE(0x0069E869);
RCT2_CALLPROC_EBPSAFE(0x0066729F);
RCT2_CALLPROC_EBPSAFE(0x006B7A38);
date_reset();
RCT2_CALLPROC_EBPSAFE(0x00674576);
park_calculate_size();
RCT2_CALLPROC_EBPSAFE(0x006C1955);
RCT2_GLOBAL(0x01358840, uint8) = 0;
memset(0x001358102, 0, 20);
RCT2_GLOBAL(0x00135882E, uint16) = 0;
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) & GAME_FLAGS_NO_MONEY) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) |= GAME_FLAGS_PARK_OPEN;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = 0;
}
RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) |= GAME_FLAGS_18;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, uint16) = 0;
RCT2_GLOBAL(0x009DEA5C, uint16) = 62000;
}

View File

@@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <lodepng.h>
#include <stdio.h>
#include <windows.h>
#include "addresses.h"
#include "gfx.h"
@@ -26,6 +28,16 @@
#include "strings.h"
#include "window_error.h"
enum {
SCREENSHOT_FORMAT_BMP,
SCREENSHOT_FORMAT_PNG
};
int gScreenshotFormat = SCREENSHOT_FORMAT_BMP;
static int screenshot_dump_bmp();
static int screenshot_dump_png();
/**
*
* rct2: 0x006E3AEC
@@ -50,17 +62,14 @@ void screenshot_check()
}
}
static int screenshot_get_next_path(char *path)
static int screenshot_get_next_path(char *path, char *extension)
{
char *placeHolder;
strcpy(path, RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char));
placeHolder = path + strlen(path);
int i;
for (i = 1; i < 1000; i++) {
RCT2_GLOBAL(0x013CE952, uint16) = i;
format_string(placeHolder, STR_SCR_BMP, 0x013CE952);
// Glue together path and filename
sprintf(path, "%sSCR%d%s", RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), i, extension);
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
return i;
@@ -69,6 +78,18 @@ static int screenshot_get_next_path(char *path)
return -1;
}
int screenshot_dump()
{
switch (gScreenshotFormat) {
case SCREENSHOT_FORMAT_BMP:
return screenshot_dump_bmp();
case SCREENSHOT_FORMAT_PNG:
return screenshot_dump_png();
default:
return -1;
}
}
// Bitmap header structs, for cross platform purposes
typedef struct {
uint16 bfType;
@@ -96,7 +117,7 @@ typedef struct {
*
* rct2: 0x00683D20
*/
int screenshot_dump()
int screenshot_dump_bmp()
{
BitmapFileHeader header;
BitmapInfoHeader info;
@@ -107,7 +128,7 @@ int screenshot_dump()
DWORD bytesWritten;
// Get a free screenshot path
if ((index = screenshot_get_next_path(path)) == -1)
if ((index = screenshot_get_next_path(path, ".bmp")) == -1)
return -1;
// Open file for writing
@@ -188,5 +209,48 @@ int screenshot_dump()
CloseHandle(hFile);
free(buffer);
return index;
}
int screenshot_dump_png()
{
int i, index, width, height, stride;
char path[MAX_PATH] = "";
unsigned char r, g, b, a = 255;
unsigned char* png;
size_t pngSize;
LodePNGState state;
// Get a free screenshot path
if ((index = screenshot_get_next_path(path, ".png")) == -1)
return -1;
lodepng_state_init(&state);
state.info_raw.colortype = LCT_PALETTE;
// Get image size
width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
stride = (width + 3) & 0xFFFFFFFC;
for (i = 0; i < 246; i++) {
b = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0];
g = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1];
r = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2];
lodepng_palette_add(&state.info_raw, r, g, b, a);
}
rct_drawpixelinfo *dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
unsigned int error = lodepng_encode(&png, &pngSize, dpi->bits, stride, dpi->height, &state);
if (!error) lodepng_save_file(png, pngSize, path);
if (error) fprintf(stderr, "error: %u: %s\n", error, lodepng_error_text(error));
free(png);
return index;
}

View File

@@ -21,6 +21,8 @@
#ifndef _SCREENSHOT_H_
#define _SCREENSHOT_H_
extern int gScreenshotFormat;
void screenshot_check();
int screenshot_dump();

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* Copyright (c) 2014 Ted John, Peter Hill
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of OpenRCT2.
@@ -46,6 +46,16 @@ typedef struct {
sint32 var_24;
} rct_litter;
typedef struct {
uint8 sprite_idetifier; // 0x00
uint8 pad_01[0x0D];
sint16 x; // 0x0E
sint16 y; // 0x10
sint16 z; // 0x12
uint8 pad_14[0x2a];
uint16 next_car; // 0x3E
} rct_car;
/**
* Sprite structure.
* size: 0x0100
@@ -55,6 +65,7 @@ typedef union {
rct_unk_sprite unknown;
rct_peep peep;
rct_litter litter;
rct_car car;
} rct_sprite;
#endif

View File

@@ -186,7 +186,7 @@ static void window_game_bottom_toolbar_mouseup()
news_item_get_subject_location(newsItem->type, subject, &x, &y, &z);
if (x == SPRITE_LOCATION_NULL)
if ((uint16)x == SPRITE_LOCATION_NULL)
break;
if ((mainWindow = window_get_main()) != NULL)
@@ -222,7 +222,8 @@ static void window_game_bottom_toolbar_tooltip()
break;
case WIDX_DATE:
month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7;
day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, sint16) * days_in_month[month]) >> 16) & 0xFF;
day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) * days_in_month[month]) >> 16) & 0xFF;
*((short*)0x013CE952) = STR_DATE_DAY_1 + day;
*((short*)0x013CE954) = STR_MONTH_MARCH + month;
widgetIndex = 0;
@@ -534,8 +535,8 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
case NEWS_ITEM_RIDE:
gfx_draw_sprite(dpi, SPR_RIDE, x, y);
break;
case NEWS_ITEM_PEEP_1:
case NEWS_ITEM_PEEP_2:
case NEWS_ITEM_PEEP_ON_RIDE:
case NEWS_ITEM_PEEP:
if (newsItem->flags & 1)
break;

View File

@@ -2029,7 +2029,7 @@ static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history
int i, x, y, yearOver32, currentMonth, currentDay;
currentMonth = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16));
currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, uint16);
currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16);
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
x = baseX;
y = baseY;