Review changes

This commit is contained in:
zsilencer 2016-05-21 20:17:56 -06:00
parent a963935c11
commit 1685d8e3f1

View file

@ -28,7 +28,7 @@
// 6B8172: // 6B8172:
void scenery_multiple_paint_supports(uint8 direction, uint16 height, rct_map_element *mapElement, uint32 dword_F4387C, rct_scenery_entry *entry) void scenery_multiple_paint_supports(uint8 direction, uint16 height, rct_map_element *mapElement, uint32 dword_F4387C, rct_scenery_entry *entry)
{ {
if (entry->large_scenery.flags & 0x20) { if (!(entry->large_scenery.flags & 0x20)) {
return; return;
} }
@ -56,10 +56,7 @@ void scenery_multiple_paint_supports(uint8 direction, uint16 height, rct_map_ele
paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0);
} }
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < clearanceHeight) { paint_util_set_general_support_height(clearanceHeight, 0x20);
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = clearanceHeight;
RCT2_GLOBAL(0x141E9DA, uint8) = 0x20;
}
} }
int scenery_multiple_sign_text_width(const char *str, rct_large_scenery_text *text) int scenery_multiple_sign_text_width(const char *str, rct_large_scenery_text *text)
@ -92,25 +89,25 @@ const char *scenery_multiple_sign_fit_text(const char *str, rct_large_scenery_te
} else { } else {
w += text->glyphs[*fitStrEnd].width; w += text->glyphs[*fitStrEnd].width;
} }
} while (w < text->max_width && *fitStrEnd++); } while (w <= text->max_width && *fitStrEnd++);
*fitStrEnd = 0; *fitStrEnd = 0;
return fitStr; return fitStr;
} }
int div_to_minus_infinity(int a, int b) {
return (a / b) - (a % b < 0);
}
void scenery_multiple_sign_paint_line(const char *str, rct_large_scenery_text *text, int textImage, int textColour, uint8 direction, int y_offset) void scenery_multiple_sign_paint_line(const char *str, rct_large_scenery_text *text, int textImage, int textColour, uint8 direction, int y_offset)
{ {
const char *fitStr = scenery_multiple_sign_fit_text(str, text, false); const char *fitStr = scenery_multiple_sign_fit_text(str, text, false);
int width = scenery_multiple_sign_text_width(fitStr, text); int width = scenery_multiple_sign_text_width(fitStr, text);
int x_offset = text->offset[(direction & 1)].x; int x_offset = text->offset[(direction & 1)].x;
int acc = 0; int acc = y_offset * (direction & 1 ? -1 : 1);
if (!(text->var_C & 0x1)) { if (!(text->var_C & 0x1)) {
// sign is horizontal, center text: // sign is horizontal, center text:
x_offset -= (width / 2); x_offset -= (width / 2);
if (direction & 1) { acc -= (width / 2);
y_offset += ((width / 2) / 2);
} else {
y_offset -= ((width / 2) / 2);
}
} }
for (size_t i = 0; i < strlen(fitStr); i++) { for (size_t i = 0; i < strlen(fitStr); i++) {
int glyph_offset = text->glyphs[fitStr[i]].image_offset; int glyph_offset = text->glyphs[fitStr[i]].image_offset;
@ -121,20 +118,24 @@ void scenery_multiple_sign_paint_line(const char *str, rct_large_scenery_text *t
glyph_offset *= 4; glyph_offset *= 4;
// set slightly different glyph on horizontal sign, which was rendered 1/2 pixel lower to deal with aliasing: // set slightly different glyph on horizontal sign, which was rendered 1/2 pixel lower to deal with aliasing:
if (direction & 1) { if (direction & 1) {
if (!(acc % 2)) { if (!(acc & 1)) {
glyph_type += 2; glyph_type += 2;
} }
} else { } else {
if (acc % 2) { if ((acc & 1)) {
glyph_type += 2; glyph_type += 2;
} }
} }
} }
int image_id = textImage + glyph_offset + glyph_type | textColour; int image_id = textImage + glyph_offset + glyph_type | textColour;
if (direction == 3) { if (direction == 3) {
paint_attach_to_previous_ps(image_id, x_offset, y_offset - (acc / 2)); paint_attach_to_previous_ps(image_id, x_offset, -div_to_minus_infinity(acc, 2));
} else { } else {
paint_attach_to_previous_attach(image_id, x_offset, y_offset + (acc / 2)); if (text->var_C & 0x1) {
paint_attach_to_previous_ps(image_id, x_offset, div_to_minus_infinity(acc, 2));
} else {
paint_attach_to_previous_attach(image_id, x_offset, div_to_minus_infinity(acc, 2));
}
} }
x_offset += text->glyphs[fitStr[i]].width; x_offset += text->glyphs[fitStr[i]].width;
acc += text->glyphs[fitStr[i]].width; acc += text->glyphs[fitStr[i]].width;
@ -147,7 +148,7 @@ void scenery_multiple_sign_paint_line(const char *str, rct_large_scenery_text *t
*/ */
void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *mapElement) { void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *mapElement) {
//RCT2_CALLPROC_X(0x6B7F0C, 0, 0, direction, height, (int)mapElement, 0, 0); return; //RCT2_CALLPROC_X(0x6B7F0C, 0, 0, direction, height, (int)mapElement, 0, 0); return;
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY;
uint32 ebp = mapElement->properties.scenerymultiple.type >> 10; uint32 ebp = mapElement->properties.scenerymultiple.type >> 10;
rct_scenery_entry *entry = get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF); rct_scenery_entry *entry = get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF);
uint32 image_id = (ebp << 2) + entry->image + 4 + direction; uint32 image_id = (ebp << 2) + entry->image + 4 + direction;
@ -165,7 +166,7 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map
} }
} }
if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST) { if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST) {
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
ebp = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour]; ebp = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour];
image_id &= 0x7FFFF; image_id &= 0x7FFFF;
dword_F4387C = ebp; dword_F4387C = ebp;
@ -229,24 +230,26 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map
utf8 signString[MAX_PATH] = {0}; utf8 signString[MAX_PATH] = {0};
format_string(signString, stringId, gCommonFormatArgs); format_string(signString, stringId, gCommonFormatArgs);
rct_large_scenery_text *text = entry->large_scenery.text; rct_large_scenery_text *text = entry->large_scenery.text;
int y_offset = text->offset[(direction & 1)].y; int y_offset = (text->offset[(direction & 1)].y * 2);
if (text->var_C & 0x1) { if (text->var_C & 0x1) {
// Draw vertical sign: // Draw vertical sign:
y_offset += 1;
char fitStr[32] = {0}; char fitStr[32] = {0};
strncpy(fitStr, scenery_multiple_sign_fit_text(signString, text, true), sizeof(fitStr) - 1); strncpy(fitStr, scenery_multiple_sign_fit_text(signString, text, true), sizeof(fitStr) - 1);
int height = scenery_multiple_sign_text_height(fitStr, text); int height = scenery_multiple_sign_text_height(fitStr, text);
char str[2] = {0}; char str[2] = {0};
for (size_t i = 0; i < strlen(fitStr); i++) { for (size_t i = 0; i < strlen(fitStr); i++) {
str[0] = fitStr[i]; str[0] = fitStr[i];
scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - (height / 2)); scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height);
y_offset += text->glyphs[fitStr[i]].height; y_offset += text->glyphs[fitStr[i]].height * 2;
} }
} else { } else {
y_offset -= (direction & 1);
if (text->var_C & 0x2) { if (text->var_C & 0x2) {
// Draw two-line sign: // Draw two-line sign:
int width = scenery_multiple_sign_text_width(signString, text); int width = scenery_multiple_sign_text_width(signString, text);
if (width > text->max_width) { if (width > text->max_width) {
y_offset -= (text->glyphs['A'].height / 2); y_offset -= text->glyphs['A'].height + 1;
char *src = signString; char *src = signString;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
char str1[32] = {0}; char str1[32] = {0};
@ -261,13 +264,13 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map
space = j; space = j;
} }
j++; j++;
} while(w < text->max_width && j < sizeof(str1) && (*dst++ = *src++)); } while(w <= text->max_width && j < sizeof(str1) && (*dst++ = *src++));
if (space != -1 && *src) { if (space != -1 && *src) {
str1[space] = 0; str1[space] = 0;
src = &srcold[space + 1]; src = &srcold[space + 1];
} }
scenery_multiple_sign_paint_line(str1, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset); scenery_multiple_sign_paint_line(str1, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);
y_offset += text->glyphs['A'].height; y_offset += (text->glyphs['A'].height + 1) * 2;
} }
} else { } else {
scenery_multiple_sign_paint_line(signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset); scenery_multiple_sign_paint_line(signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);