Merge pull request #3059 from zsilencer/bugfixes

Bugfixes
This commit is contained in:
Ted John 2016-03-01 08:25:03 +00:00
commit ce779cb4c1
9 changed files with 17 additions and 7 deletions

View File

@ -124,7 +124,7 @@ void console_update()
}
// Remove unwated characters in console input
utf8_remove_format_codes(_consoleCurrentLine);
utf8_remove_format_codes(_consoleCurrentLine, false);
}
// Flash the caret

View File

@ -118,13 +118,13 @@ const utf8 BlackLeftArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8
const utf8 BlackRightArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x96, (utf8)0xB6, (utf8)0x00 };
const utf8 CheckBoxMarkString[] = { (utf8)0xE2, (utf8)0x9C, (utf8)0x93, (utf8)0x00 };
void utf8_remove_format_codes(utf8 *text)
void utf8_remove_format_codes(utf8 *text, bool allowcolours)
{
utf8 *dstCh = text;
utf8 *ch = text;
int codepoint;
while ((codepoint = utf8_get_next(ch, (const utf8**)&ch)) != 0) {
if (!utf8_is_format_code(codepoint)) {
if (!utf8_is_format_code(codepoint) || (allowcolours && utf8_is_colour_code(codepoint))) {
dstCh = utf8_write_codepoint(dstCh, codepoint);
}
}

View File

@ -79,7 +79,7 @@ uint32 utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr);
utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint);
int utf8_insert_codepoint(utf8 *dst, uint32 codepoint);
bool utf8_is_codepoint_start(utf8 *text);
void utf8_remove_format_codes(utf8 *text);
void utf8_remove_format_codes(utf8 *text, bool allowcolours);
int utf8_get_codepoint_length(int codepoint);
int utf8_length(const utf8 *text);
wchar_t *utf8_to_widechar(const utf8 *src);

View File

@ -143,6 +143,12 @@ bool utf8_is_format_code(int codepoint)
return false;
}
bool utf8_is_colour_code(int codepoint)
{
if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) return true;
return false;
}
bool utf8_should_use_sprite_for_codepoint(int codepoint)
{
switch (codepoint) {

View File

@ -27,6 +27,7 @@
#include "string_ids.h"
bool utf8_is_format_code(int codepoint);
bool utf8_is_colour_code(int codepoint);
bool utf8_should_use_sprite_for_codepoint(int codepoint);
int font_sprite_get_codepoint_offset(int codepoint);
int utf8_get_format_code_arg_length(int codepoint);

View File

@ -209,6 +209,7 @@ void NetworkPlayer::SetName(const char* name)
{
safe_strcpy((char*)NetworkPlayer::name, name, sizeof(NetworkPlayer::name));
NetworkPlayer::name[sizeof(NetworkPlayer::name) - 1] = 0;
utf8_remove_format_codes((utf8*)NetworkPlayer::name, false);
}
void NetworkPlayer::AddMoneySpent(money32 cost)
@ -992,7 +993,9 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
}
lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE);
char* ptrtext = lineCh;
safe_strcpy(lineCh, text, 800);
utf8_remove_format_codes((utf8*)ptrtext, true);
return formatted;
}

View File

@ -440,7 +440,7 @@ static void window_multiplayer_players_scrollpaint(rct_window *w, rct_drawpixeli
if (action != -999) {
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_action_name_string_id(action);
}
gfx_draw_string_left(dpi, 1191, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, 256, y - 1);
gfx_draw_string_left_clipped(dpi, 1191, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, 256, y - 1, 100);
// Draw ping
lineCh = buffer;

View File

@ -206,7 +206,7 @@ void window_player_open(uint8 id)
int player = network_get_player_index(id);
window = window_bring_to_front_by_number(WC_PLAYER, id);
if (window == NULL) {
window = window_create_auto_pos(210, 134, &window_player_overview_events, WC_PLAYER, WF_RESIZABLE);
window = window_create_auto_pos(240, 170, &window_player_overview_events, WC_PLAYER, WF_RESIZABLE);
window->number = id;
window->page = 0;
window->viewport_focus_coordinates.y = 0;

View File

@ -118,7 +118,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t
// from crashing the game.
text_input[maxLength - 1] = '\0';
utf8_remove_format_codes(text_input);
utf8_remove_format_codes(text_input, false);
// This is the text displayed above the input box
input_text_description = description;