Merge branch 'pre-release-0.0.3' into develop

This commit is contained in:
duncanspumpkin 2015-11-15 21:23:01 +00:00
commit 54d7b54cb3
16 changed files with 606 additions and 521 deletions

View File

@ -503,6 +503,7 @@
#define RCT2_ADDRESS_CURRENT_FONT_FLAGS 0x013CE9A2
#define RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS 0x013CE9A4
#define RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT 0x0140E9A4
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT 0x0141E9AC
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE 0x0141E9AE

View File

@ -356,7 +356,7 @@ void game_logic_update()
scenario_update();
climate_update();
map_update_tiles();
sub_6A876D();
map_update_path_wide_flags();
peep_update_all();
vehicle_update_all();
sprite_misc_update_all();

View File

@ -47,7 +47,7 @@
static int _dragX, _dragY;
static rct_windowclass _dragWindowClass;
static rct_windownumber _dragWindowNumber;
static int _dragWidgetIndex;
static int _dragWidgetIndex, _dragScrollIndex;
static int _originalWindowWidth, _originalWindowHeight;
typedef struct {
@ -180,6 +180,83 @@ static rct_mouse_data* get_mouse_input()
return &mouse_buffer[read_index];
}
/* rct2: 0x006E957F
*/
static void input_scroll_drag_begin(int x, int y, rct_window* w, rct_widget* widget, int widgetIndex) {
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_SCROLL_RIGHT;
_dragX = x;
_dragY = y;
_dragWindowClass = w->classification;
_dragWindowNumber = w->number;
_dragWidgetIndex = widgetIndex;
RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_DRAG_START, sint16) = 0;
_dragScrollIndex = window_get_scroll_data_index(w, widgetIndex);
platform_hide_cursor();
}
/* Based on (heavily changed) rct2: 0x006E9E0E & 0x006E9ED0 */
static void input_scroll_drag_continue(int x, int y, rct_window* w) {
uint8 widgetIndex = _dragWidgetIndex;
uint8 scrollIndex = _dragScrollIndex;
rct_widget* widget = &w->widgets[widgetIndex];
rct_scroll* scroll = &w->scrolls[scrollIndex];
int dx, dy;
dx = x - _dragX;
dy = y - _dragY;
if (scroll->flags & HSCROLLBAR_VISIBLE) {
sint16 size = widget->right - widget->left - 1;
if (scroll->flags & VSCROLLBAR_VISIBLE)
size -= 11;
size = max(0, scroll->h_right - size);
scroll->h_left = min(max(0, scroll->h_left + dx), size);
}
if (scroll->flags & VSCROLLBAR_VISIBLE) {
sint16 size = widget->bottom - widget->top - 1;
if (scroll->flags & HSCROLLBAR_VISIBLE)
size -= 11;
size = max(0, scroll->v_bottom - size);
scroll->v_top = min(max(0, scroll->v_top + dy), size);
}
widget_scroll_update_thumbs(w, widgetIndex);
window_invalidate_by_number(w->classification, w->number);
platform_set_cursor_position(_dragX, _dragY);
}
/* rct2: 0x006E8ACB*/
static void input_scroll_right(int x, int y, int state) {
rct_window* w = window_find_by_number(
_dragWindowClass,
_dragWindowNumber
);
if (w == NULL) {
platform_show_cursor();
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
return;
}
switch (state) {
case 0:
RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_DRAG_START, sint16) += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16);
if (x == 0 && y == 0)
return;
RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_DRAG_START, sint16) = 1000;
input_scroll_drag_continue(x, y, w);
break;
case 4:
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
platform_show_cursor();
break;
}
}
/**
*
* rct2: 0x006E8655
@ -221,7 +298,7 @@ static void game_handle_input_mouse(int x, int y, int state)
input_viewport_drag_begin(w, x, y);
}
else if (widget->type == WWT_SCROLL) {
input_scroll_drag_begin(x, y, w, widget, widgetIndex);
}
break;
}
@ -325,8 +402,8 @@ static void game_handle_input_mouse(int x, int y, int state)
input_window_resize_continue(w, x, y);
}
break;
case 9:
RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, (int)w, (int)widget, 0);
case INPUT_STATE_SCROLL_RIGHT:
input_scroll_right(x, y, state);
break;
}
}

View File

@ -188,7 +188,7 @@ void console_draw(rct_drawpixelinfo *dpi)
int lineLength = min(sizeof(lineBuffer) - (size_t)utf8_get_codepoint_length(FORMAT_GREEN), (size_t)(nextLine - ch));
lineCh = lineBuffer;
lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN);
safe_strncpy(lineCh, ch, CONSOLE_BUFFER_SIZE);
strncpy(lineCh, ch, lineLength);
lineCh[lineLength] = 0;
gfx_draw_string(dpi, lineBuffer, 255, x, y);

View File

@ -38,7 +38,6 @@
#define RCT2_FIRST_VIEWPORT (RCT2_ADDRESS(RCT2_ADDRESS_VIEWPORT_LIST, rct_viewport))
#define RCT2_LAST_VIEWPORT (RCT2_ADDRESS(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport) - 1)
#define RCT2_NEW_VIEWPORT (RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*))
//#define DEBUG_SHOW_DIRTY_BOX
@ -98,7 +97,7 @@ void viewport_init_all()
for (int i = 0; i < 9; i++) {
g_viewport_list[i].width = 0;
}
RCT2_NEW_VIEWPORT = NULL;
RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*) = NULL;
// ?
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, sint32) = 0;

View File

@ -382,6 +382,7 @@ enum {
INPUT_STATE_VIEWPORT_LEFT = 6,
INPUT_STATE_SCROLL_LEFT = 7,
INPUT_STATE_RESIZING = 8,
INPUT_STATE_SCROLL_RIGHT = 9
};
enum {

View File

@ -71,7 +71,8 @@ LanguagePack::LanguagePack(int id, const utf8 *text)
size_t stringDataBaseAddress = (size_t)_stringData;
for (size_t i = 0; i < _strings.size(); i++) {
_strings[i] = (utf8*)(stringDataBaseAddress + (size_t)_strings[i]);
if (_strings[i] != nullptr)
_strings[i] = (utf8*)(stringDataBaseAddress + (size_t)_strings[i]);
}
for (size_t i = 0; i < _objectOverrides.size(); i++) {
for (int j = 0; j < ObjectOverrideMaxStringCount; j++) {

View File

@ -1788,7 +1788,7 @@ static void ride_ratings_calculate_wooden_wild_mouse(rct_ride *ride)
ride_ratings_apply_65E1C2(&ratings, ride, 16705, 30583, 35108);
ride_ratings_apply_proximity(&ratings, ride, 17893);
ride_ratings_apply_scenery(&ratings, ride, 5577);
ride_ratings_apply_highest_drop_height_penalty(&ratings, ride, 6, 2, 2, 2);
ride_ratings_apply_highest_drop_height_penalty(&ratings, ride, 8, 2, 2, 2);
ride_ratings_apply_max_speed_penalty(&ratings, ride, 0x70000, 2, 2, 2);
ride_ratings_apply_max_negative_g_penalty(&ratings, ride, FIXED_2DP(0,10), 2, 2, 2);
ride_ratings_apply_max_lateral_g_penalty(&ratings, ride, FIXED_2DP(1,50), 2, 2, 2);

View File

@ -3523,7 +3523,7 @@ static void track_save_add_large_scenery(int x, int y, rct_map_element *mapEleme
direction = mapElement->type & 3;
sequence = mapElement->properties.scenerymultiple.type >> 10;
if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0)) {
if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, NULL)) {
return;
}
@ -3703,7 +3703,7 @@ static void track_save_remove_large_scenery(int x, int y, rct_map_element *mapEl
direction = mapElement->type & 3;
sequence = mapElement->properties.scenerymultiple.type >> 10;
if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0)) {
if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, NULL)) {
return;
}

View File

@ -575,8 +575,11 @@ static void window_ride_construction_close(rct_window *w)
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 1);
// In order to cancel the yellow arrow correctly the
// selection tool should be cancelled.
tool_cancel();
// selection tool should be cancelled. Don't do a tool cancel if
// another window has already taken control of tool.
if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) &&
w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber))
tool_cancel();
hide_gridlines();

View File

@ -187,10 +187,8 @@ void window_sign_open(rct_windownumber number)
int view_z = map_element->base_height << 3;
w->frame_no = view_z;
rct_banner* banner = &gBanners[w->number];
banner->colour = map_element->properties.scenerymultiple.colour[0] & 0x1F;
banner->text_colour = map_element->properties.scenerymultiple.colour[1] & 0x1F;
w->list_information_type = map_element->properties.scenerymultiple.colour[0] & 0x1F;
w->var_492 = map_element->properties.scenerymultiple.colour[1] & 0x1F;
w->var_48C = map_element->properties.scenerymultiple.type;
view_x += 16;
@ -272,14 +270,12 @@ static void window_sign_mouseup(rct_window *w, int widgetIndex)
/* rct2: 0x6B9784 & 0x6E6164 */
static void window_sign_mousedown(int widgetIndex, rct_window*w, rct_widget* widget)
{
rct_banner* banner = &gBanners[w->number];
switch (widgetIndex) {
case WIDX_MAIN_COLOR:
window_dropdown_show_colour(w, widget, w->colours[1] | 0x80, (uint8)banner->colour);
window_dropdown_show_colour(w, widget, w->colours[1] | 0x80, (uint8)w->list_information_type);
break;
case WIDX_TEXT_COLOR:
window_dropdown_show_colour(w, widget, w->colours[1] | 0x80, (uint8)banner->text_colour);
window_dropdown_show_colour(w, widget, w->colours[1] | 0x80, (uint8)w->var_492);
break;
}
}
@ -287,16 +283,16 @@ static void window_sign_mousedown(int widgetIndex, rct_window*w, rct_widget* wid
/* rct2: 0x6B979C */
static void window_sign_dropdown(rct_window *w, int widgetIndex, int dropdownIndex)
{
rct_banner *banner = &gBanners[w->number];
switch (widgetIndex){
case WIDX_MAIN_COLOR:
if (dropdownIndex == -1) return;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, dropdownIndex, GAME_COMMAND_SET_SIGN_STYLE, banner->text_colour, 1);
w->list_information_type = dropdownIndex;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, dropdownIndex, GAME_COMMAND_SET_SIGN_STYLE, w->var_492, 1);
break;
case WIDX_TEXT_COLOR:
if (dropdownIndex == -1) return;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, banner->colour, GAME_COMMAND_SET_SIGN_STYLE, dropdownIndex, 1);
w->var_492 = dropdownIndex;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, w->list_information_type, GAME_COMMAND_SET_SIGN_STYLE, dropdownIndex, 1);
break;
default:
return;
@ -335,10 +331,8 @@ static void window_sign_invalidate(rct_window *w)
text_colour_btn->type = WWT_COLORBTN;
}
rct_banner* banner = &gBanners[w->number];
main_colour_btn->image = (banner->colour << 19) | 0x600013C3;
text_colour_btn->image = (banner->text_colour << 19) | 0x600013C3;
main_colour_btn->image = (w->list_information_type << 19) | 0x600013C3;
text_colour_btn->image = (w->var_492 << 19) | 0x600013C3;
}
/* rct2: 0x006B9754 & 0x006E6134 */
@ -433,9 +427,9 @@ void window_sign_small_open(rct_windownumber number){
int view_z = map_element->base_height << 3;
w->frame_no = view_z;
rct_banner* banner = &gBanners[w->number];
banner->colour = map_element->properties.fence.item[1] & 0x1F;
banner->text_colour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags&0x60) >> 2);
w->list_information_type = map_element->properties.fence.item[1] & 0x1F;
w->var_492 =
((map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2));
w->var_48C = map_element->properties.fence.type;
view_x += 16;
@ -521,11 +515,13 @@ static void window_sign_small_dropdown(rct_window *w, int widgetIndex, int dropd
switch (widgetIndex){
case WIDX_MAIN_COLOR:
if (dropdownIndex == -1) return;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, dropdownIndex, GAME_COMMAND_SET_SIGN_STYLE, banner->text_colour, 0);
w->list_information_type = dropdownIndex;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, dropdownIndex, GAME_COMMAND_SET_SIGN_STYLE, w->var_492, 0);
break;
case WIDX_TEXT_COLOR:
if (dropdownIndex == -1) return;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, banner->colour, GAME_COMMAND_SET_SIGN_STYLE, dropdownIndex, 0);
w->var_492 = dropdownIndex;
game_do_command(1, GAME_COMMAND_FLAG_APPLY, w->number, w->list_information_type, GAME_COMMAND_SET_SIGN_STYLE, dropdownIndex, 0);
break;
default:
return;
@ -554,8 +550,6 @@ static void window_sign_small_invalidate(rct_window *w)
text_colour_btn->type = WWT_COLORBTN;
}
rct_banner* banner = &gBanners[w->number];
main_colour_btn->image = (banner->colour << 19) | 0x600013C3;
text_colour_btn->image = (banner->text_colour << 19) | 0x600013C3;
main_colour_btn->image = (w->list_information_type << 19) | 0x600013C3;
text_colour_btn->image = (w->var_492 << 19) | 0x600013C3;
}

View File

@ -1581,6 +1581,203 @@ bool footpath_element_is_wide(rct_map_element *mapElement)
return mapElement->type & 2;
}
/**
*
* rct2: 0x006A8B12
* clears the wide footpath flag for all footpaths
* at location
*/
static void footpath_clear_wide(int x, int y)
{
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
do {
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
continue;
mapElement->type &= ~0x2;
} while (!map_element_is_last_for_tile(mapElement++));
}
/**
*
* rct2: 0x006A8ACF
* returns footpath element if it can be made wide
* returns NULL if it can not be made wide
*/
static rct_map_element* footpath_can_be_wide(int x, int y, uint8 height)
{
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
do {
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
continue;
if (height != mapElement->base_height)
continue;
if (footpath_element_is_queue(mapElement))
continue;
if (footpath_element_is_sloped(mapElement))
continue;
return mapElement;
} while (!map_element_is_last_for_tile(mapElement++));
return NULL;
}
/**
*
* rct2: 0x006A87BB
*/
void footpath_update_path_wide_flags(int x, int y)
{
if (x < 0x20)
return;
if (y < 0x20)
return;
if (x > 0x1FDF)
return;
if (y > 0x1FDF)
return;
footpath_clear_wide(x, y);
x += 0x20;
footpath_clear_wide(x, y);
y += 0x20;
footpath_clear_wide(x, y);
x -= 0x20;
footpath_clear_wide(x, y);
y -= 0x20;
if (!(x & 0xE0))
return;
if (!(y & 0xE0))
return;
rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32);
do {
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
continue;
if (footpath_element_is_queue(mapElement))
continue;
if (footpath_element_is_sloped(mapElement))
continue;
uint8 height = mapElement->base_height;
// pathList is a list of elements, set by sub_6A8ACF adjacent to x,y
// Spanned from 0x00F3EFA8 to 0x00F3EFC7 (8 elements) in the original
rct_map_element *pathList[8];
x -= 0x20;
y -= 0x20;
pathList[0] = footpath_can_be_wide(x, y, height);
y += 0x20;
pathList[1] = footpath_can_be_wide(x, y, height);
y += 0x20;
pathList[2] = footpath_can_be_wide(x, y, height);
x += 0x20;
pathList[3] = footpath_can_be_wide(x, y, height);
x += 0x20;
pathList[4] = footpath_can_be_wide(x, y, height);
y -= 0x20;
pathList[5] = footpath_can_be_wide(x, y, height);
y -= 0x20;
pathList[6] = footpath_can_be_wide(x, y, height);
x -= 0x20;
pathList[7] = footpath_can_be_wide(x, y, height);
y += 0x20;
uint8 F3EFA5 = 0;
if (mapElement->properties.path.edges & 8) {
F3EFA5 |= 0x80;
if (pathList[7] != NULL) {
if (footpath_element_is_wide(pathList[7])) {
F3EFA5 &= ~0x80;
}
}
}
if (mapElement->properties.path.edges & 1) {
F3EFA5 |= 0x2;
if (pathList[1] != NULL) {
if (footpath_element_is_wide(pathList[1])) {
F3EFA5 &= ~0x2;
}
}
}
if (mapElement->properties.path.edges & 2) {
F3EFA5 |= 0x8;
if (pathList[3] != NULL) {
if (footpath_element_is_wide(pathList[3])) {
F3EFA5 &= ~0x8;
}
}
}
if (mapElement->properties.path.edges & 4) {
F3EFA5 |= 0x20;
if (pathList[5] != NULL) {
if (footpath_element_is_wide(pathList[5])) {
F3EFA5 &= ~0x20;
}
}
}
if ((F3EFA5 & 0x80) && (pathList[7] != NULL) && !(footpath_element_is_wide(pathList[7]))) {
if ((F3EFA5 & 2) &&
(pathList[0] != NULL) && (!footpath_element_is_wide(pathList[0])) &&
((pathList[0]->properties.path.edges & 6) == 6) && // N E
(pathList[1] != NULL) && (!footpath_element_is_wide(pathList[1]))) {
F3EFA5 |= 0x1;
}
if ((F3EFA5 & 0x20) &&
(pathList[6] != NULL) && (!footpath_element_is_wide(pathList[6])) &&
((pathList[6]->properties.path.edges & 3) == 3) && // N W
(pathList[5] != NULL) && (!footpath_element_is_wide(pathList[5]))) {
F3EFA5 |= 0x40;
}
}
if ((F3EFA5 & 0x8) && (pathList[3] != NULL) && !(pathList[3]->type & 2)) {
if ((F3EFA5 & 2) &&
(pathList[2] != NULL) && (!footpath_element_is_wide(pathList[2])) &&
((pathList[2]->properties.path.edges & 0xC) == 0xC) &&
(pathList[1] != NULL) && (!footpath_element_is_wide(pathList[1]))) {
F3EFA5 |= 0x4;
}
if ((F3EFA5 & 0x20) &&
(pathList[4] != NULL) && (!footpath_element_is_wide(pathList[4])) &&
((pathList[4]->properties.path.edges & 9) == 9) &&
(pathList[5] != NULL) && (!footpath_element_is_wide(pathList[5]))) {
F3EFA5 |= 0x10;
}
}
if ((F3EFA5 & 0x80) && (F3EFA5 & (0x40 | 0x1)))
F3EFA5 &= ~0x80;
if ((F3EFA5 & 0x2) && (F3EFA5 & (0x4 | 0x1)))
F3EFA5 &= ~0x2;
if ((F3EFA5 & 0x8) && (F3EFA5 & (0x10 | 0x4)))
F3EFA5 &= ~0x8;
if ((F3EFA5 & 0x20) && (F3EFA5 & (0x40 | 0x10)))
F3EFA5 &= ~0x20;
if (!(F3EFA5 & (0x2 | 0x8 | 0x20 | 0x80))) {
uint8 e = mapElement->properties.path.edges;
if ((e != 0xAF) && (e != 0x5F) && (e != 0xEF))
mapElement->type |= 2;
}
} while (!map_element_is_last_for_tile(mapElement++));
}
/**
*
* rct2: 0x006A76E9

View File

@ -64,6 +64,7 @@ void footpath_connect_edges(int x, int y, rct_map_element *mapElement, int flags
void sub_6A759F();
bool fence_in_the_way(int x, int y, int z0, int z1, int direction);
void footpath_chain_ride_queue(int rideIndex, int entranceIndex, int x, int y, rct_map_element *mapElement, int direction);
void footpath_update_path_wide_flags(int x, int y);
void footpath_bridge_get_info_from_pos(int screenX, int screenY, int *x, int *y, int *direction, rct_map_element **mapElement);

File diff suppressed because it is too large Load Diff

View File

@ -293,7 +293,7 @@ rct_map_element *map_get_small_scenery_element_at(int x, int y, int z, int type)
int map_element_height(int x, int y);
void sub_68B089();
int map_coord_is_connected(int x, int y, int z, uint8 faceDirection);
void sub_6A876D();
void map_update_path_wide_flags();
int map_is_location_owned(int x, int y, int z);
int map_is_location_in_park(int x, int y);
bool map_is_location_owned_or_has_rights(int x, int y);
@ -387,7 +387,7 @@ void map_clear_all_elements();
rct_map_element *map_get_large_scenery_segment(int x, int y, int z, int direction, int sequence);
bool map_large_scenery_get_origin(
int x, int y, int z, int direction, int sequence,
int *outX, int *outY, int *outZ
int *outX, int *outY, int *outZ, rct_map_element** outElement
);
rct_map_element *map_get_track_element_at(int x, int y, int z);

View File

@ -68,7 +68,7 @@ typedef struct {
sint16 x_offset;
sint16 y_offset;
sint16 z_offset;
uint8 var_6;
uint8 z_clearance;
uint16 var_7;
} rct_large_scenery_tile;