Merge remote-tracking branch 'upstream/master'

Conflicts:
	src/config.c
This commit is contained in:
Jørn Lomax
2014-05-12 17:31:25 +02:00
62 changed files with 2093 additions and 583 deletions

View File

@@ -74,7 +74,6 @@
<ClCompile Include="..\src\sawyercoding.c" />
<ClCompile Include="..\src\scenario.c" />
<ClCompile Include="..\src\screenshot.c" />
<ClCompile Include="..\src\settings.c" />
<ClCompile Include="..\src\strings.c" />
<ClCompile Include="..\src\title.c" />
<ClCompile Include="..\src\track.c" />
@@ -84,6 +83,7 @@
<ClCompile Include="..\src\widget.c" />
<ClCompile Include="..\src\window.c" />
<ClCompile Include="..\src\window_about.c" />
<ClCompile Include="..\src\window_banner.c" />
<ClCompile Include="..\src\window_cheats.c" />
<ClCompile Include="..\src\window_clear_scenery.c" />
<ClCompile Include="..\src\window_error.c" />
@@ -93,9 +93,13 @@
<ClCompile Include="..\src\window_land.c" />
<ClCompile Include="..\src\window_news.c" />
<ClCompile Include="..\src\window_park.c" />
<ClCompile Include="..\src\window_finances.c" />
<ClCompile Include="..\src\window_footpath.c" />
<ClCompile Include="..\src\window_new_ride.c" />
<ClCompile Include="..\src\window_options.c" />
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_staff.c" />
<ClCompile Include="..\src\window_title_exit.c" />
<ClCompile Include="..\src\window_title_logo.c" />
<ClCompile Include="..\src\window_main.c" />
@@ -155,6 +159,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -167,13 +172,15 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<SDLCheck>
</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<TreatSpecificWarningsAsErrors>4013</TreatSpecificWarningsAsErrors>
<OmitFramePointers>
</OmitFramePointers>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@@ -269,9 +269,6 @@
<ClCompile Include="..\src\window_save_prompt.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\settings.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\window_news.c">
<Filter>Windows</Filter>
</ClCompile>
@@ -281,6 +278,21 @@
<ClCompile Include="..\src\finance.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\window_finances.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_staff.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_banner.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_new_ride.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_options.c">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@@ -120,6 +120,9 @@
#define RCT2_ADDRESS_WINDOW_DPI 0x009DEA74
#define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88
#define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
#define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C
@@ -154,8 +157,11 @@
#define RCT2_ADDRESS_OBJECTIVE_YEAR 0x013580F9
#define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC
#define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100
#define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C
#define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330
#define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C
#define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C
#define RCT2_ADDRESS_PARK_VALUE_HISTORY 0x01358540
#define RCT2_ADDRESS_COMPLETED_COMPANY_VALUE 0x01358740
#define RCT2_ADDRESS_TOTAL_ADMISSIONS 0x01358744
#define RCT2_ADDRESS_INCOME_FROM_ADMISSIONS 0x01358748
@@ -165,6 +171,11 @@
#define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A
#define RCT2_ADDRESS_EXPENDITURE_TABLE 0x01357848
#define RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL 0x013573FF
#define RCT2_ADDRESS_HANDYMAN_COLOUR 0x01357BCD
#define RCT2_ADDRESS_MECHANIC_COLOUR 0x01357BCE
#define RCT2_ADDRESS_SECURITY_COLOUR 0x01357BCF
#define RCT2_ADDRESS_CURRENT_INTEREST_RATE 0x0135934A
#define RCT2_ADDRESS_MAP_SIZE 0x01358834
@@ -209,8 +220,6 @@
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID 0x0141E9AE
#define RCT2_ADDRESS_CURRENT_ROTATION 0x0141E9E0
#define RCT2_ADDRESS_SCENARIO_NAME 0x0141F5B8
#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738
#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C
@@ -229,6 +238,8 @@
#define RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB 0x00F4390A
#define RCT2_ADDRESS_WINDOW_MAP_SELECTED_TAB 0x014209E4
#define RCT2_ADDRESS_OS_TIME_MINUTE 0x01424654
#define RCT2_ADDRESS_OS_TIME_HOUR 0x01424656
#define RCT2_ADDRESS_OS_TIME_DAY 0x01424304

View File

@@ -25,6 +25,9 @@
#include "addresses.h"
#include "config.h"
#include "rct2.h"
#include <tchar.h>
#include "osinterface.h"
// Current keyboard shortcuts
uint16 gShortcutKeys[SHORTCUT_COUNT];
@@ -142,10 +145,10 @@ void config_save()
HANDLE hFile;
DWORD bytesWritten;
hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
WriteFile(hFile, &MagicNumber, 4, &bytesWritten, NULL);
WriteFile(hFile, 0x009AAC5C, 2155, &bytesWritten, NULL);
WriteFile(hFile, (LPCVOID)0x009AAC5C, 2155, &bytesWritten, NULL);
CloseHandle(hFile);
}
}
@@ -154,6 +157,7 @@ void config_save()
general_configuration_t gGeneral_config;
static char *config_show_directory_browser();
static void config_parse_settings(FILE *fp);
static int config_get_line(FILE *fp, char *setting, char *value);
static int config_parse_setting(FILE *fp, char *setting);
@@ -178,7 +182,7 @@ void config_init()
DWORD dwAttrib = GetFileAttributes(path);
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
if (!CreateDirectory(path, NULL)) {
config_error("Could not create config file (do you have write acces to you documents folder?)");
config_error("Could not create config file (do you have write access to your documents folder?)");
}
}
strcat(path, "\\config.ini");
@@ -236,9 +240,11 @@ static void config_create_default(char *path)
{
FILE* fp;
if (!config_find_rct2_path(gGeneral_config.game_path)) {
MessageBox(NULL, "Unable to find RCT2 installation directory. Please correct in config.ini.", "OpenRCT2", MB_OK);
strcpy(gGeneral_config.game_path, "C:\\");
if (!config_find_rct2_path(gConfig.game_path)) {
osinterface_show_messagebox("Unable to find RCT2 installation directory. Please select the directory where you installed RCT2!");
char *res = osinterface_open_directory_browser("Please select your RCT2 directory");
strcpy(gConfig.game_path, res);
}
fp = fopen(path, "w");
@@ -253,13 +259,14 @@ static void config_create_default(char *path)
fclose(fp);
}
/**
* Parse settings and set the game veriables
* @param fp file pointer to the settings file
*/
static void config_parse_settings(FILE *fp)
{
int c = NULL, pos = 0;
int pos = 0;
char *setting;
char *value;
char *section;
@@ -428,36 +435,36 @@ static int config_parse_setting(FILE *fp, char *setting){
* @param value a pointer to where to store the value
* @return < 0 if EOF is reached
*/
static int config_parse_value(FILE *fp, char *value){
static int config_parse_value(FILE *fp, char *value)
{
long start, end;
int size, c, pos = 0;
start = ftell(fp);
c = fgetc(fp);
while (isspace(c)){
while (isspace(c)) {
start = ftell(fp);
c = fgetc(fp);
}
while (c != EOF && c != '\n'){
while (c != EOF && c != '\n') {
c = fgetc(fp);
}
end = ftell(fp);
size = end - start;
if (size > MAX_CONFIG_LENGTH){
if (size > MAX_CONFIG_LENGTH)
config_error("One of your settings is too long");
}
fseek(fp, start, SEEK_SET);
c = fgetc(fp);
while (c != EOF && c != '\n'){
while (c != EOF && c != '\n') {
value[pos] = (char)c;
c = fgetc(fp);
pos++;
}
value[pos] = '\0';
return;
return 0;
}
/**
@@ -540,8 +547,10 @@ static int config_parse_currency(char* currency){
* @param msg Message to print in message box
*/
static void config_error(char *msg){
MessageBox(NULL, msg, "OpenRCT2", MB_OK);
exit(-1);
osinterface_show_messagebox(msg);
//TODO:SHUT DOWN EVERYTHING!
}

View File

@@ -58,11 +58,11 @@ void editor_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN;
window_staff_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
window_ride_list_init_vars();
window_new_ride_init_vars();
RCT2_GLOBAL(0x0141F571, uint8) = 4;
viewport_init_all();
news_item_init_queue();
@@ -107,10 +107,10 @@ void trackdesigner_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN;
window_staff_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
window_ride_list_init_vars();
window_new_ride_init_vars();
viewport_init_all();
news_item_init_queue();
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
@@ -145,10 +145,10 @@ void trackmanager_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) = WINDOW_STAFF_LIST_TAB_HANDYMEN;
window_staff_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
window_ride_list_init_vars();
window_new_ride_init_vars();
viewport_init_all();
news_item_init_queue();
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create

View File

@@ -23,6 +23,7 @@
#include "sprite.h"
#include "park.h"
#include "peep.h"
#include "ride.h"
#include "window.h"
// monthly cost
@@ -102,6 +103,35 @@ void finance_pay_interest()
finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST);
}
/**
*
* rct2: 0x006AC885
*/
void finance_pay_ride_upkeep()
{
rct_ride* ride;
for (int i = 0; i < MAX_RIDES; i++) {
ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]);
if (ride->type == RIDE_TYPE_NULL)
continue;
if (!(ride->var_1D0 & 0x1000)) {
ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
ride->var_196 = 25855; // durability?
}
if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) {
sint16 upkeep = ride->upkeep_cost;
if (upkeep != -1) {
ride->var_158 -= upkeep;
ride->var_14D |= 2;
finance_payment(upkeep, RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP);
}
}
}
}
/**
*
* rct2: 0x0069DEFB

View File

@@ -23,9 +23,12 @@
#include "rct2.h"
#define CURRENCY(whole, fraction) ((whole) * 10 + ((fraction) / 10))
typedef int rct_expenditure_type;
enum {
RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP = 1,
RCT_EXPENDITURE_TYPE_WAGES = 10,
RCT_EXPENDITURE_TYPE_RESEARCH = 12,
RCT_EXPENDITURE_TYPE_INTEREST = 13
@@ -36,6 +39,7 @@ void finance_payment(int amount, rct_expenditure_type type);
void finance_pay_wages();
void finance_pay_research();
void finance_pay_interest();
void finance_pay_ride_upkeep();
void finance_init();
#endif

File diff suppressed because it is too large Load Diff

147
src/gfx.c
View File

@@ -98,8 +98,53 @@ void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour)
gfx_fill_rect(dpi, x, y, x, y, colour);
}
/*
* Draws a horizontal line of specified colour to a buffer.
* rct2: 0x68474C
*/
void gfx_draw_line_on_buffer(rct_drawpixelinfo *dpi, char colour, int y, int x, int no_pixels)
{
y -= dpi->y;
//Check to make sure point is in the y range
if (y < 0)return;
if (y >= dpi->height)return;
//Check to make sure we are drawing at least a pixel
if (!no_pixels) return;
no_pixels++;
x -= dpi->x;
//If x coord outside range leave
if (x < 0){
//Unless the number of pixels is enough to be in range
no_pixels += x;
if (no_pixels <= 0)return;
//Resets starting point to 0 as we don't draw outside the range
x = 0;
}
//Ensure that the end point of the line is within range
if (x + no_pixels - dpi->width > 0){
//If the end point has any pixels outside range
//cut them off. If there are now no pixels return.
no_pixels -= x + no_pixels - dpi->width;
if (no_pixels <= 0)return;
}
char* bits_pointer;
//Get the buffer we are drawing to and move to the first coordinate.
bits_pointer = dpi->bits + y*(dpi->pitch + dpi->width) + x;
//Draw the line to the specified colour
for (; no_pixels > 0; --no_pixels, ++bits_pointer){
*((uint8*)bits_pointer) = colour;
}
}
/**
*
* Draws a line on dpi if within dpi boundaries
* rct2: 0x00684466
* dpi (edi)
* x1 (ax)
@@ -110,7 +155,78 @@ void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour)
*/
void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour)
{
RCT2_CALLPROC_X(0x00684466, x1, y1, x2, y2, 0, dpi, colour);
// Check to make sure the line is within the drawing area
if ((x1 < dpi->x) && (x2 < dpi->x)){
return;
}
if ((y1 < dpi->y) && (y2 < dpi->y)){
return;
}
if ((x1 >(dpi->x + dpi->width)) && (x2 >(dpi->x + dpi->width))){
return;
}
if ((y1 > (dpi->y + dpi->height)) && (y2 > (dpi->y + dpi->height))){
return;
}
//Bresenhams algorithm
//If vertical plot points upwards
int steep = abs(y2 - y1) > abs(x2 - x1);
if (steep){
int temp_y2 = y2;
int temp_x2 = x2;
y2 = x1;
x2 = y1;
y1 = temp_x2;
x1 = temp_y2;
}
//If line is right to left swap direction
if (x1 > x2){
int temp_y2 = y2;
int temp_x2 = x2;
y2 = y1;
x2 = x1;
y1 = temp_y2;
x1 = temp_x2;
}
int delta_x = x2 - x1;
int delta_y = abs(y2 - y1);
int error = delta_x / 2;
int y_step;
int y = y1;
//Direction of step
if (y1 < y2)y_step = 1;
else y_step = -1;
for (int x = x1, x_start = x1, no_pixels = 1; x < x2; ++x,++no_pixels){
//Vertical lines are drawn 1 pixel at a time
if (steep)gfx_draw_line_on_buffer(dpi, colour, x, y, 1);
error -= delta_y;
if (error < 0){
//Non vertical lines are drawn with as many pixels in a horizontal line as possible
if (!steep)gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels);
//Reset non vertical line vars
x_start = x + 1;
no_pixels = 1;
y += y_step;
error += delta_x;
}
//Catch the case of the last line
if (x + 1 == x2 && !steep){
gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels);
}
}
return;
}
/**
@@ -125,7 +241,7 @@ void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int c
*/
void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bottom, int colour)
{
RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, dpi, colour);
RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, (int)dpi, colour);
}
/**
@@ -141,7 +257,7 @@ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bot
*/
void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short _si)
{
RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, dpi, colour);
RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, (int)dpi, colour);
}
/**
@@ -153,7 +269,7 @@ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short ri
*/
void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y)
{
RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0);
RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, 0);
}
/**
@@ -196,7 +312,7 @@ void gfx_transpose_palette(int pal, unsigned char product)
*/
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args)
{
RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, args, dpi, 0);
RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, (int)args, (int)dpi, 0);
}
/**
@@ -253,7 +369,6 @@ void gfx_set_dirty_blocks(int left, int top, int right, int bottom)
void gfx_draw_all_dirty_blocks()
{
int x, y, xx, yy, columns, rows;
short left, top, right, bottom;
uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8);
for (x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32); x++) {
@@ -346,7 +461,7 @@ int gfx_get_string_width(char *buffer)
{
int eax, ebx, ecx, edx, esi, edi, ebp;
esi = buffer;
esi = (int)buffer;
RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
return ecx & 0xFFFF;
@@ -366,7 +481,7 @@ int gfx_get_string_width(char *buffer)
*/
void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y, int width)
{
RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, args, dpi, width);
RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, (int)args, (int)dpi, width);
//char* buffer;
@@ -391,7 +506,7 @@ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args
*/
void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width)
{
RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, args, dpi, width);
RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, (int)args, (int)dpi, width);
//char* buffer;
//short text_width;
@@ -452,8 +567,8 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i
ebx = format;
ecx = x;
edx = y;
esi = args;
edi = dpi;
esi = (int)args;
edi = (int)dpi;
ebp = width;
RCT2_CALLFUNC_X(0x006C1E53, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
@@ -479,8 +594,8 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *format, int x, in
ebx = colour;
ecx = x;
edx = y;
esi = format;
edi = dpi;
esi = (int)format;
edi = (int)dpi;
ebp = width;
RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
@@ -523,8 +638,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *format, int colour, int x, in
ebx = 0;
ecx = x;
edx = y;
esi = format;
edi = dpi;
esi = (int)format;
edi = (int)dpi;
ebp = 0;
RCT2_CALLFUNC_X(0x00682702, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);

View File

@@ -146,7 +146,6 @@ void map_update_tile_pointers()
*/
int map_element_height(int x, int y)
{
int i;
rct_map_element *mapElement;
// Off the map
@@ -298,13 +297,13 @@ void sub_68B089()
i++;
if (i >= MAX_TILE_MAP_ELEMENT_POINTERS)
i = 0;
} while (TILE_MAP_ELEMENT_POINTER(i) == 0xFFFFFFFF);
} while (TILE_MAP_ELEMENT_POINTER(i) == TILE_UNDEFINED_MAP_ELEMENT);
RCT2_GLOBAL(0x0010E63B8, uint32) = i;
mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i);
do {
mapElement--;
if (mapElement < RCT2_ADDRESS_MAP_ELEMENTS)
if (mapElement < (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS)
break;
} while (mapElement->base_height == 255);
mapElement++;

View File

@@ -180,7 +180,7 @@ enum {
#define MAX_MAP_ELEMENTS 196608
#define MAX_TILE_MAP_ELEMENT_POINTERS (256 * 256)
#define TILE_UNDEFINED_MAP_ELEMENT -1
#define TILE_UNDEFINED_MAP_ELEMENT (rct_map_element*)-1
void map_init();
void map_update_tile_pointers();

View File

@@ -191,7 +191,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
*z = map_element_height(*x, *y);
break;
case NEWS_ITEM_PEEP_ON_RIDE:
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep;
*x = peep->x;
*y = peep->y;
*z = peep->z;
@@ -212,16 +212,16 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int *
}
// 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]]);
car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]).car;
// 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]);
car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]).car;
*x = car->x;
*y = car->y;
*z = car->z;
break;
case NEWS_ITEM_PEEP:
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]);
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep;
*x = peep->x;
*y = peep->y;
*z = peep->z;
@@ -252,7 +252,7 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
// find first open slot
while (newsItem->type != NEWS_ITEM_NULL) {
if (newsItem + sizeof(newsItem) >= 0x13CB1CC)
if (newsItem + sizeof(newsItem) >= (rct_news_item*)0x13CB1CC)
news_item_close_current();
else
newsItem++;
@@ -263,12 +263,12 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
newsItem->flags = 0;
newsItem->assoc = assoc;
newsItem->ticks = 0;
newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16;
newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
newsItem->day = (days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16;
format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible?
format_string((char*)0x0141EF68, string_id, (void*)0x013CE952); // overflows possible?
newsItem->colour = ((char*)0x0141EF68)[0];
strncpy(newsItem->text, 0x0141EF68, 255);
strncpy(newsItem->text, (char*)0x0141EF68, 255);
newsItem->text[254] = 0;
// blatant disregard for what happens on the last element.
@@ -276,3 +276,71 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
newsItem++;
newsItem->type = 0;
}
/**
* Opens the window/tab for the subject of the news item
*
* rct2: 0x0066EBE6
*
**/
void news_item_open_subject(int type, int subject) {
int eax;
rct_peep* peep;
rct_window* window;
switch (type) {
case NEWS_ITEM_RIDE:
RCT2_CALLPROC_X(0x006ACC28, subject, 0, 0, 0, 0, 0, 0);
break;
case NEWS_ITEM_PEEP_ON_RIDE:
case NEWS_ITEM_PEEP:
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep;
RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0);
break;
case NEWS_ITEM_MONEY:
// Open finances window
RCT2_CALLPROC_EBPSAFE(0x0069DDF1);
break;
case NEWS_ITEM_RESEARCH:
if (subject >= 0x10000) {
// Open ride list window
RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
eax = (subject & 0xFF00) >> 8;
eax += (subject & 0xFF) << 8;
// Switch to right tab and scroll to ride location
RCT2_CALLPROC_X(0x006B3EBA, eax, 0, subject, 0, 0, 0, 0);
break;
}
// Check if window is already open
window = window_bring_to_front_by_id(WC_SCENERY, 0);
if (window == NULL) {
window = window_find_by_id(WC_TOP_TOOLBAR, 0);
if (window != NULL) {
window_invalidate(window);
if (tool_set(window, 9, 0)){
RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0);
}
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
// Open scenery window
RCT2_CALLPROC_EBPSAFE(0x006E0FEF);
}
}
// Switch to new scenery tab
RCT2_CALLPROC_X(0x006E1172, (subject & 0xFFFF), 0, subject, 0, 0, 0, 0);
break;
case NEWS_ITEM_PEEPS:
// Open guest list to right tab
RCT2_CALLPROC_X(0x006993BA, 3, subject, 0, 0, 0, 0, 0);
break;
case NEWS_ITEM_AWARD:
window_park_awards_open();
break;
case NEWS_ITEM_GRAPH:
window_park_rating_open();
break;
}
}

View File

@@ -33,7 +33,7 @@ enum {
NEWS_ITEM_PEEP,
NEWS_ITEM_MONEY,
NEWS_ITEM_BLANK,
NEWS_ITEM_SCENERY,
NEWS_ITEM_RESEARCH,
NEWS_ITEM_PEEPS,
NEWS_ITEM_AWARD,
NEWS_ITEM_GRAPH
@@ -48,8 +48,7 @@ typedef struct {
uint8 flags; // 0x01
uint32 assoc; // 0x02
uint16 ticks; // 0x06
uint8 month; // 0x08
uint8 pad_09; // 0x09
uint16 month_year; // 0x08
uint8 day; // 0x0A
uint8 pad_0B; // 0x0B
uint8 colour; // 0x0C
@@ -61,5 +60,6 @@ void news_item_update_current();
void news_item_close_current();
void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z);
void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc);
void news_item_open_subject(int type, int subject);
#endif

View File

@@ -34,7 +34,7 @@ void object_load_list()
*
* rct2: 0x006AA0C6
*/
void object_read_and_load_entries(HFILE hFile)
void object_read_and_load_entries(HANDLE hFile)
{
RCT2_CALLPROC_EBPSAFE(0x006AA0C6);

View File

@@ -35,7 +35,7 @@ typedef struct {
} rct_object_entry;
void object_load_list();
void object_read_and_load_entries(HFILE hFile);
void object_read_and_load_entries(HANDLE hFile);
int object_load_packed();
#endif

View File

@@ -19,6 +19,8 @@
*****************************************************************************/
#include <stdio.h>
#include <shlobj.h>
#include <tchar.h>
#include <windows.h>
#include <SDL.h>
#include <SDL_syswm.h>
@@ -31,8 +33,8 @@
typedef void(*update_palette_func)(char*, int, int);
openrct2_cursor gCursorState;
unsigned char* gKeysState;
unsigned char* gKeysPressed;
const unsigned char *gKeysState;
unsigned char *gKeysPressed;
unsigned int gLastKeyPressed;
static void osinterface_create_window();
@@ -323,12 +325,12 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
openFileName.lpstrTitle = title;
// Copy filter name
strcpy(0x01423800, filterName);
strcpy((char*)0x01423800, filterName);
// Copy filter pattern
strcpy(0x01423800 + strlen(filterName) + 1, filterPattern);
strcpy((char*)0x01423800 + strlen(filterName) + 1, filterPattern);
*((char*)(0x01423800 + strlen(filterName) + 1 + strlen(filterPattern) + 1)) = 0;
openFileName.lpstrFilter = 0x01423800;
openFileName.lpstrFilter = (char*)0x01423800;
//
tmp = RCT2_GLOBAL(0x009E2C74, uint32);
@@ -348,4 +350,49 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
RCT2_GLOBAL(0x009E2C74, uint32) = tmp;
return result;
}
}
void osinterface_show_messagebox(char* message){
MessageBox(NULL, message, "OpenRCT2", MB_OK);
}
char* osinterface_open_directory_browser(char *title) {
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
LPMALLOC lpMalloc;
// Initialize COM
if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) {
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
CoUninitialize();
return 0;
}
// Get a pointer to the shell memory allocator
if (SHGetMalloc(&lpMalloc) != S_OK) {
MessageBox(NULL, _T("Error opening browse window"), _T("ERROR"), MB_OK);
CoUninitialize();
return 0;
}
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T(title);
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
char *outPath = "C:\\";
if (pidl = SHBrowseForFolder(&bi)) {
// Copy the path directory to the buffer
if (SHGetPathFromIDList(pidl, pszBuffer)) {
// Store pszBuffer (and the path) in the outPath
outPath = strcat("", pszBuffer);
}
}
CoUninitialize();
return outPath;
}

View File

@@ -37,8 +37,8 @@ typedef struct {
} openrct2_cursor;
extern openrct2_cursor gCursorState;
extern unsigned char* gKeysState;
extern unsigned char* gKeysPressed;
extern const unsigned char *gKeysState;
extern unsigned char *gKeysPressed;
extern unsigned int gLastKeyPressed;
void osinterface_init();
@@ -47,5 +47,7 @@ void osinterface_draw();
void osinterface_free();
int osinterface_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName);
void osinterface_show_messagebox(char* message);
char* osinterface_open_directory_browser(char *title);
#endif

View File

@@ -19,11 +19,14 @@
*****************************************************************************/
#include "addresses.h"
#include "finance.h"
#include "map.h"
#include "park.h"
#include "peep.h"
#include "ride.h"
#include "scenario.h"
#include "sprite.h"
#include "strings.h"
#include "window.h"
int park_is_open()
@@ -37,7 +40,84 @@ int park_is_open()
*/
void park_init()
{
RCT2_CALLPROC_EBPSAFE(0x00667132);
int i;
RCT2_GLOBAL(0x013CA740, uint8) = 0;
RCT2_GLOBAL(0x013573D4, uint16) = 777;
RCT2_GLOBAL(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8) = 28;
RCT2_GLOBAL(RCT2_ADDRESS_MECHANIC_COLOUR, uint8) = 28;
RCT2_GLOBAL(RCT2_ADDRESS_SECURITY_COLOUR, uint8) = 28;
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0;
RCT2_GLOBAL(0x01357BC8, uint16) = 0;
RCT2_GLOBAL(0x01357846, uint16) = 0;
RCT2_GLOBAL(0x013573FE, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = 0;
RCT2_GLOBAL(0x013580EC, uint16) = 0;
RCT2_GLOBAL(0x013580EE, uint16) = 0;
RCT2_GLOBAL(0x01357CF4, sint32) = -1;
for (i = 0; i < 20; i++)
RCT2_ADDRESS(0x01358102, uint8)[i] = 0;
RCT2_GLOBAL(0x01358844, uint32) = 0xFFFFFFFF;
RCT2_GLOBAL(0x01358849, uint32) = 0xFFFFFFFE;
RCT2_GLOBAL(0x0135884E, uint32) = 0xFFFFFFFD;
finance_init();
for (i = 0; i < 2; i++)
RCT2_ADDRESS(0x01357404, uint32)[i] = 0;
for (i = 0; i < 56; i++)
RCT2_ADDRESS(0x01357BD0, sint32)[i] = -1;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = CURRENCY(10, 00);
RCT2_GLOBAL(0x013573F2, sint16) = -1;
RCT2_GLOBAL(0x013573F8, sint16) = -1;
RCT2_GLOBAL(0x01357CF2, uint16) = 127;
RCT2_GLOBAL(0x013573FF, uint8) = 2;
RCT2_GLOBAL(0x013580F4, uint16) = 500;
RCT2_GLOBAL(0x013580E9, uint8) = 128;
RCT2_GLOBAL(0x013580F6, uint8) = 200;
RCT2_GLOBAL(0x013580F7, uint8) = 200;
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) = 1;
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8) = 4;
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16) = 1000;
RCT2_GLOBAL(0x01358770, uint16) = 900;
RCT2_GLOBAL(0x01358772, uint16) = 400;
RCT2_GLOBAL(0x01358774, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
park_reset_awards_and_history();
rct_s6_info *info = (rct_s6_info*)0x0141F570;
info->name[0] = '\0';
format_string(info->details, STR_NO_DETAILS_YET, NULL);
}
/**
*
* rct2: 0x0066729F
*/
void park_reset_awards_and_history()
{
int i;
// Reset park rating and guests in park history
for (i = 0; i < 32; i++) {
RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8)[i] = 255;
RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8)[i] = 255;
}
// Reset finance history
for (i = 0; i < 128; i++) {
RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, uint32)[i] = 0x80000000;
RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, uint32)[i] = 0x80000000;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, uint32)[i] = 0x80000000;
}
// Reset awards
for (i = 0; i < 4; i++)
RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i].time = 0;
}
/**

View File

@@ -59,7 +59,8 @@ enum {
PARK_FLAGS_FORBID_HIGH_CONSTRUCTION = (1 << 5), // below tree height
PARK_FLAGS_PREF_LESS_INTENSE_RIDES = (1 << 6),
PARK_FLAGS_FORBID_MARKETING_CAMPAIGN = (1 << 7),
PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 11),
PARK_FLAGS_PREF_MORE_INTENSE_RIDES = (1 << 8),
PARK_FLAGS_11 = (1 << 11),
PARK_FLAGS_DIFFICULT_GUEST_GENERATION = (1 << 12),
PARK_FLAGS_PARK_FREE_ENTRY = (1 << 13),
PARK_FLAGS_DIFFICULT_PARK_RATING = (1 << 14),
@@ -69,6 +70,7 @@ enum {
int park_is_open();
void park_init();
void park_reset_awards_and_history();
int park_calculate_size();
int calculate_park_rating();

View File

@@ -63,11 +63,11 @@ void peep_update_all()
sprite_index = peep->next;
if ((i & 0x7F) != (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x7F)) {
RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0);
RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0);
} else {
RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, peep, 0, 0);
RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, (int)peep, 0, 0);
if (peep->var_08 == 4)
RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0);
RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0);
}
i++;

Some files were not shown because too many files have changed in this diff Show More