summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-01-12 22:27:19 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-04-24 17:40:11 +0200
commitdcb2571888f58aee2e5aa3512f36707a3adde472 (patch)
tree7259a829d22a76db084e07aa4d66b157e2704638 /src
parent66cd32a252ee0edab11448b560371878b2189223 (diff)
downloadopenttd-dcb2571888f58aee2e5aa3512f36707a3adde472.tar.xz
Add: Warn players that company passwords are not truly secure
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/misc_gui.cpp20
-rw-r--r--src/network/network_gui.cpp13
-rw-r--r--src/script/api/game/game_window.hpp.sq3
-rw-r--r--src/script/api/script_window.hpp3
-rw-r--r--src/textbuf_gui.h1
-rw-r--r--src/widgets/misc_widget.h12
-rw-r--r--src/widgets/network_widget.h1
8 files changed, 48 insertions, 6 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 61fa2a91b..4f648a482 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -265,6 +265,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}By enabl
STR_BUTTON_DEFAULT :{BLACK}Default
STR_BUTTON_CANCEL :{BLACK}Cancel
STR_BUTTON_OK :{BLACK}OK
+STR_WARNING_PASSWORD_SECURITY :{YELLOW}Warning: Server administrators may be{}able to read any text entered here.
# On screen keyboard window
STR_OSK_KEYBOARD_LAYOUT :`1234567890-=\qwertyuiop[]asdfghjkl;' zxcvbnm,./ .
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 4c7557c36..8a86f0c57 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -981,6 +981,23 @@ struct QueryStringWindow : public Window
resize->width = 0;
size->width = 0;
}
+
+ if (widget == WID_QS_WARNINGBOX && (this->flags & QSF_PASSWORD) == 0) {
+ /* We don't want this widget to show! */
+ fill->width = 0;
+ resize->width = 0;
+ size->width = 0;
+ }
+ if (widget == WID_QS_WARNING) {
+ *size = GetStringBoundingBox(STR_WARNING_PASSWORD_SECURITY);
+ }
+ }
+
+ virtual void DrawWidget(const Rect &r, int widget) const
+ {
+ if (widget != WID_QS_WARNING) return;
+
+ DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
}
void SetStringParameters(int widget) const override
@@ -1037,6 +1054,9 @@ static const NWidgetPart _nested_query_string_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2),
EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNINGBOX),
+ NWidget(WWT_LABEL, COLOUR_GREY, WID_QS_WARNING), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), SetFill(0, 1),
+ EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 29bc88959..42fea015c 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -2157,7 +2157,7 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
}
- ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
+ ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_PASSWORD);
}
struct NetworkCompanyPasswordWindow : public Window {
@@ -2174,6 +2174,14 @@ struct NetworkCompanyPasswordWindow : public Window {
this->SetFocusedWidget(WID_NCP_PASSWORD);
}
+ virtual void DrawWidget(const Rect &r, int widget) const
+ {
+ if (widget != WID_NCP_WARNING) return;
+
+ DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
+ STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
+ }
+
void OnOk()
{
if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
@@ -2220,6 +2228,9 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = {
EndContainer(),
EndContainer(),
EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING),
+ NWidget(WWT_LABEL, COLOUR_GREY), SetFill(0, 1), SetPadding(2, 2, 2, 2), SetDataTip(STR_WARNING_PASSWORD_SECURITY, STR_NULL),
+ EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq
index ce2b37bb5..90fd2f5ac 100644
--- a/src/script/api/game/game_window.hpp.sq
+++ b/src/script/api/game/game_window.hpp.sq
@@ -636,6 +636,8 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_WEBSITE, "WID_A_WEBSITE");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION, "WID_QS_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT, "WID_QS_TEXT");
+ SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING, "WID_QS_WARNING");
+ SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNINGBOX, "WID_QS_WARNINGBOX");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_DEFAULT, "WID_QS_DEFAULT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CANCEL, "WID_QS_CANCEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_OK, "WID_QS_OK");
@@ -780,6 +782,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_LABEL, "WID_NCP_LABEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_PASSWORD, "WID_NCP_PASSWORD");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, "WID_NCP_SAVE_AS_DEFAULT_PASSWORD");
+ SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_WARNING, "WID_NCP_WARNING");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_CANCEL, "WID_NCP_CANCEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_OK, "WID_NCP_OK");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_CAPTION, "WID_NGRFI_CAPTION");
diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp
index fa584693a..4275fba54 100644
--- a/src/script/api/script_window.hpp
+++ b/src/script/api/script_window.hpp
@@ -1598,6 +1598,8 @@ public:
enum QueryStringWidgets {
WID_QS_CAPTION = ::WID_QS_CAPTION, ///< Caption of the window.
WID_QS_TEXT = ::WID_QS_TEXT, ///< Text of the query.
+ WID_QS_WARNING = ::WID_QS_WARNING, ///< Warning label about password security
+ WID_QS_WARNINGBOX = ::WID_QS_WARNINGBOX, ///< Container for warning label
WID_QS_DEFAULT = ::WID_QS_DEFAULT, ///< Default button.
WID_QS_CANCEL = ::WID_QS_CANCEL, ///< Cancel button.
WID_QS_OK = ::WID_QS_OK, ///< OK button.
@@ -1817,6 +1819,7 @@ public:
WID_NCP_LABEL = ::WID_NCP_LABEL, ///< Label in front of the password field.
WID_NCP_PASSWORD = ::WID_NCP_PASSWORD, ///< Input field for the password.
WID_NCP_SAVE_AS_DEFAULT_PASSWORD = ::WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
+ WID_NCP_WARNING = ::WID_NCP_WARNING, ///< Warning text about password security
WID_NCP_CANCEL = ::WID_NCP_CANCEL, ///< Close the window without changing anything.
WID_NCP_OK = ::WID_NCP_OK, ///< Safe the password etc.
};
diff --git a/src/textbuf_gui.h b/src/textbuf_gui.h
index ec134c11c..e8f5159f9 100644
--- a/src/textbuf_gui.h
+++ b/src/textbuf_gui.h
@@ -22,6 +22,7 @@ enum QueryStringFlags {
QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change
QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned)
QSF_LEN_IN_CHARS = 0x04, ///< the length of the string is counted in characters
+ QSF_PASSWORD = 0x08, ///< password entry box, show warning about password security
};
DECLARE_ENUM_AS_BIT_SET(QueryStringFlags)
diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h
index a6dd081a9..9fbd9f2f1 100644
--- a/src/widgets/misc_widget.h
+++ b/src/widgets/misc_widget.h
@@ -30,11 +30,13 @@ enum AboutWidgets {
/** Widgets of the #QueryStringWindow class. */
enum QueryStringWidgets {
- WID_QS_CAPTION, ///< Caption of the window.
- WID_QS_TEXT, ///< Text of the query.
- WID_QS_DEFAULT, ///< Default button.
- WID_QS_CANCEL, ///< Cancel button.
- WID_QS_OK, ///< OK button.
+ WID_QS_CAPTION, ///< Caption of the window.
+ WID_QS_TEXT, ///< Text of the query.
+ WID_QS_WARNING, ///< Warning label about password security
+ WID_QS_WARNINGBOX, ///< Container for warning label
+ WID_QS_DEFAULT, ///< Default button.
+ WID_QS_CANCEL, ///< Cancel button.
+ WID_QS_OK, ///< OK button.
};
/** Widgets of the #QueryWindow class. */
diff --git a/src/widgets/network_widget.h b/src/widgets/network_widget.h
index f5773b8ea..4cb5cc92c 100644
--- a/src/widgets/network_widget.h
+++ b/src/widgets/network_widget.h
@@ -122,6 +122,7 @@ enum NetworkCompanyPasswordWidgets {
WID_NCP_LABEL, ///< Label in front of the password field.
WID_NCP_PASSWORD, ///< Input field for the password.
WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
+ WID_NCP_WARNING, ///< Warning text about password security
WID_NCP_CANCEL, ///< Close the window without changing anything.
WID_NCP_OK, ///< Safe the password etc.
};