aboutsummaryrefslogtreecommitdiff
path: root/courtroom.cpp
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-12-17 11:08:20 +0100
committerCerapter <cerap@protonmail.com>2018-12-17 11:08:20 +0100
commit73b6e72ab90934eea7118793a1b71b9b53d508c8 (patch)
treee9d7178ee4334145388745e0d60d635c871f6fed /courtroom.cpp
parent144a5bb64b5dab98d9fa631d8bf627c650d242b1 (diff)
Fix judge buttons not appearing & crash if MS goes down during play.
The former was caused by the position dropdown simply not having code to make the judge buttons appear. Alongside that, the issue(?) where `/pos judddd` (or variations) would not put the user in the judge position, but gave them the buttons anyway. The latter was caused by a simple mistake. We deleted the Lobby (and the Courtroom) frequently, however, we never did set its (their) pointer(s) back to null -- so they pointer to trash data, and the `if (w_lobby != nullptr)` part never failed. This is also now fixed, and deletion of the Lobby or the Courtroom also brings about the nulling of their pointers.
Diffstat (limited to 'courtroom.cpp')
-rw-r--r--courtroom.cpp49
1 files changed, 32 insertions, 17 deletions
diff --git a/courtroom.cpp b/courtroom.cpp
index c187e9ce..2769f77d 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -2585,6 +2585,32 @@ void Courtroom::set_hp_bar(int p_bar, int p_state)
}
}
+void Courtroom::toggle_judge_buttons(bool is_on)
+{
+ if (is_on)
+ {
+ ui_witness_testimony->show();
+ ui_cross_examination->show();
+ ui_guilty->show();
+ ui_not_guilty->show();
+ ui_defense_minus->show();
+ ui_defense_plus->show();
+ ui_prosecution_minus->show();
+ ui_prosecution_plus->show();
+ }
+ else
+ {
+ ui_witness_testimony->hide();
+ ui_cross_examination->hide();
+ ui_guilty->hide();
+ ui_not_guilty->hide();
+ ui_defense_minus->hide();
+ ui_defense_plus->hide();
+ ui_prosecution_minus->hide();
+ ui_prosecution_plus->hide();
+ }
+}
+
void Courtroom::mod_called(QString p_ip)
{
ui_server_chatlog->append(p_ip);
@@ -2621,27 +2647,13 @@ void Courtroom::on_ooc_return_pressed()
if (ooc_message.startsWith("/pos"))
{
- if (ooc_message.startsWith("/pos jud"))
+ if (ooc_message == "/pos jud")
{
- ui_witness_testimony->show();
- ui_cross_examination->show();
- ui_guilty->show();
- ui_not_guilty->show();
- ui_defense_minus->show();
- ui_defense_plus->show();
- ui_prosecution_minus->show();
- ui_prosecution_plus->show();
+ toggle_judge_buttons(true);
}
else
{
- ui_witness_testimony->hide();
- ui_cross_examination->hide();
- ui_guilty->hide();
- ui_not_guilty->hide();
- ui_defense_minus->hide();
- ui_defense_plus->hide();
- ui_prosecution_minus->hide();
- ui_prosecution_plus->hide();
+ toggle_judge_buttons(false);
}
}
else if (ooc_message.startsWith("/login"))
@@ -2891,6 +2903,8 @@ void Courtroom::on_pos_dropdown_changed(int p_index)
if (p_index < 0 || p_index > 5)
return;
+ toggle_judge_buttons(false);
+
QString f_pos;
switch (p_index)
@@ -2906,6 +2920,7 @@ void Courtroom::on_pos_dropdown_changed(int p_index)
break;
case 3:
f_pos = "jud";
+ toggle_judge_buttons(true);
break;
case 4:
f_pos = "hld";