aboutsummaryrefslogtreecommitdiff
path: root/src/packet_distribution.cpp
diff options
context:
space:
mode:
authorRosemary Witchaven <32779090+in1tiate@users.noreply.github.com>2022-03-29 09:37:02 -0500
committerGitHub <noreply@github.com>2022-03-29 17:37:02 +0300
commit68d0b838cf5abf01c4956a9f079fa76fef340a2e (patch)
tree46f51c1cce650270d273f4013a0f480ce0e391d8 /src/packet_distribution.cpp
parent18412cc9303b1c11c8e35818d57b39aee72a5ec2 (diff)
Add two ways of controlling judge buttons that aren't hardcoded nonsense (networked and local) (#537)
* add both network and local ways to show judge buttons on pos other than jud * hide judge buttons when pos_removing to a non-judge position * alter packet header * Only use pos jud hardcoding if no design.ini if design.ini does not define judges= then we fall back to pos jud garbage * Fix judge buttons being disabled if default_side pos is judge (logic poopy) Fix positions.isEmpty() returning False cuz a split of an empty string returns the list with an empty string by default * Expand JD packet to be able to send -1, 0 and 1. If -1 is received, fall back on client-sided judge button behavior. If 0 or 1 is received, treat it as "absolute override" and adhere to that packet. * alter check for empty qstringlist to support old qt versions * heehoo * trigger client side behavior when jd -1 is sent * less confusing variable names * remove useless code, trim some fat Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> * use an enum dammit! & warn on malformed auth * use an enum dammit! pt. 2 * appease clang, rewrite ugly judge controls function * please squash this its so bad Co-authored-by: Crystalwarrior <Varsash@Gmail.com> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Diffstat (limited to 'src/packet_distribution.cpp')
-rw-r--r--src/packet_distribution.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp
index 0fe25dc5..8ac1b280 100644
--- a/src/packet_distribution.cpp
+++ b/src/packet_distribution.cpp
@@ -606,10 +606,31 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
else if (header == "AUTH") {
if (!courtroom_constructed || !auth_packet_enabled || f_contents.size() < 1)
goto end;
- int authenticated = f_contents.at(0).toInt();
+ bool ok;
+ int authenticated = f_contents.at(0).toInt(&ok);
+ if (!ok) {
+ qWarning() << "Malformed AUTH packet! Contents:" << f_contents.at(0);
+ }
w_courtroom->on_authentication_state_received(authenticated);
}
+ else if (header == "JD") {
+ if (!courtroom_constructed || f_contents.empty()) {
+ goto end;
+ }
+ bool ok;
+ Courtroom::JudgeState state = static_cast<Courtroom::JudgeState>(f_contents.at(0).toInt(&ok));
+ if (!ok) {
+ goto end; // ignore malformed packet
+ }
+ w_courtroom->set_judge_state(state);
+ if (w_courtroom->get_judge_state() != Courtroom::POS_DEPENDENT) { // If we receive JD -1, it means the server asks us to fall back to client-side judge buttons behavior
+ w_courtroom->show_judge_controls(w_courtroom->get_judge_state() == Courtroom::SHOW_CONTROLS);
+ }
+ else {
+ w_courtroom->set_judge_buttons(); // client-side judge behavior
+ }
+ }
//AssetURL Packet
else if (header == "ASS") {