Author: mir3x Date: Sun Sep 14 20:16:14 2014 New Revision: 26420 URL: http://svn.gna.org/viewcvs/freeciv?rev=26420&view=rev Log: replace fake html tags like <(X)> or <X> to [(X)] or [X]
See patch #5222 Modified: branches/S2_5/client/gui-qt/chatline.cpp Modified: branches/S2_5/client/gui-qt/chatline.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/chatline.cpp?rev=26420&r1=26419&r2=26420&view=diff ============================================================================== --- branches/S2_5/client/gui-qt/chatline.cpp (original) +++ branches/S2_5/client/gui-qt/chatline.cpp Sun Sep 14 20:16:14 2014 @@ -30,7 +30,7 @@ static bool gui_qt_allied_chat_only = false; static bool is_plain_public_message(const char *s); - +static QString replace_html(QString str); /*************************************************************************** Constructor for chatwdg ***************************************************************************/ @@ -373,6 +373,47 @@ } /************************************************************************** + Replace HTML tags first or it will be cut + Replace <player> + Replace <(player)> +**************************************************************************/ +static QString replace_html(QString str) +{ + QString s, s2; + conn_list_iterate(game.all_connections, pconn){ + s = pconn->username; + s = "<(" + s + ")>"; + if (str.contains(s)) { + s2 = "([" + QString(pconn->username) + ")]"; + str = str.replace(s, s2); + break; + } + s = pconn->username; + s = "<" + s + ">"; + if (str.contains(s)) { + s2 = "[" + QString(pconn->username) + "]"; + str = str.replace(s, s2); + } + } conn_list_iterate_end; + players_iterate(pplayer) { + s = pplayer->name; + s = "(<" + s + ">)"; + if (str.contains(s)) { + s2 = "([" + QString(pplayer->name) + ")]"; + str = str.replace(s, s2); + break; + } + s = pplayer->name; + s = "<" + s + ">"; + if (str.contains(s)) { + s2 = "[" + QString(pplayer->name) + "]"; + str = str.replace(s, s2); + } + } players_iterate_end; + return str; +} + +/************************************************************************** Helper function to determine if a given client input line is intended as a "plain" public message. **************************************************************************/ @@ -413,24 +454,11 @@ int conn_id) { QString str; - QString s, s2; str = QString::fromUtf8(astring); gui()->set_status_bar(str); gui()->update_completer(); - /* Replace HTML tags first or it will be cut - Replace <player> - */ - players_iterate(pplayer) { - s = pplayer->name; - s = "<" + s + ">"; - if (str.contains(s)) { - s2 = "[" + QString(pplayer->name) + "]"; - str = str.replace(s, s2); - } - - } players_iterate_end; - + str = replace_html(str); str = apply_tags(str, tags); gui()->append_output_window(str); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits