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:
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;
}
@ -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);
}
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < clearanceHeight) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = clearanceHeight;
RCT2_GLOBAL(0x141E9DA, uint8) = 0x20;
}
paint_util_set_general_support_height(clearanceHeight, 0x20);
}
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 {
w += text->glyphs[*fitStrEnd].width;
}
} while (w < text->max_width && *fitStrEnd++);
} while (w <= text->max_width && *fitStrEnd++);
*fitStrEnd = 0;
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)
{
const char *fitStr = scenery_multiple_sign_fit_text(str, text, false);
int width = scenery_multiple_sign_text_width(fitStr, text);
int x_offset = text->offset[(direction & 1)].x;
int acc = 0;
int acc = y_offset * (direction & 1 ? -1 : 1);
if (!(text->var_C & 0x1)) {
// sign is horizontal, center text:
x_offset -= (width / 2);
if (direction & 1) {
y_offset += ((width / 2) / 2);
} else {
y_offset -= ((width / 2) / 2);
}
acc -= (width / 2);
}
for (size_t i = 0; i < strlen(fitStr); i++) {
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;
// set slightly different glyph on horizontal sign, which was rendered 1/2 pixel lower to deal with aliasing:
if (direction & 1) {
if (!(acc % 2)) {
if (!(acc & 1)) {
glyph_type += 2;
}
} else {
if (acc % 2) {
if ((acc & 1)) {
glyph_type += 2;
}
}
}
int image_id = textImage + glyph_offset + glyph_type | textColour;
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 {
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;
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) {
//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;
rct_scenery_entry *entry = get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF);
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) {
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];
image_id &= 0x7FFFF;
dword_F4387C = ebp;
@ -229,24 +230,26 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map
utf8 signString[MAX_PATH] = {0};
format_string(signString, stringId, gCommonFormatArgs);
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) {
// Draw vertical sign:
y_offset += 1;
char fitStr[32] = {0};
strncpy(fitStr, scenery_multiple_sign_fit_text(signString, text, true), sizeof(fitStr) - 1);
int height = scenery_multiple_sign_text_height(fitStr, text);
char str[2] = {0};
for (size_t i = 0; i < strlen(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));
y_offset += text->glyphs[fitStr[i]].height;
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 * 2;
}
} else {
y_offset -= (direction & 1);
if (text->var_C & 0x2) {
// Draw two-line sign:
int width = scenery_multiple_sign_text_width(signString, text);
if (width > text->max_width) {
y_offset -= (text->glyphs['A'].height / 2);
y_offset -= text->glyphs['A'].height + 1;
char *src = signString;
for (int i = 0; i < 2; i++) {
char str1[32] = {0};
@ -261,13 +264,13 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map
space = 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) {
str1[space] = 0;
src = &srcold[space + 1];
}
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 {
scenery_multiple_sign_paint_line(signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);