aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2021-01-12 12:02:07 +0300
committerCrystalwarrior <varsash@gmail.com>2021-01-12 12:02:07 +0300
commit07993a621b046985ee39ddef1427d8b4cc6042b1 (patch)
treec5fb202b31d065518bee00e2edb12f129ec45618
parentf96bd6cc3cb03a22d10ffdaa66d8b794faa3bf18 (diff)
Better place to check invalid ID's
-rw-r--r--src/courtroom.cpp12
-rw-r--r--src/packet_distribution.cpp4
2 files changed, 6 insertions, 10 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 4ed47355..0c36215f 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -5336,7 +5336,7 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud,
void Courtroom::start_clock(int id)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->start();
}
@@ -5344,7 +5344,7 @@ void Courtroom::start_clock(int id)
void Courtroom::start_clock(int id, qint64 msecs)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->start(static_cast<int>(msecs));
}
@@ -5352,7 +5352,7 @@ void Courtroom::start_clock(int id, qint64 msecs)
void Courtroom::set_clock(int id, qint64 msecs)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->set(static_cast<int>(msecs), true);
}
@@ -5360,7 +5360,7 @@ void Courtroom::set_clock(int id, qint64 msecs)
void Courtroom::pause_clock(int id)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->pause();
}
@@ -5368,7 +5368,7 @@ void Courtroom::pause_clock(int id)
void Courtroom::stop_clock(int id)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->stop();
}
@@ -5376,7 +5376,7 @@ void Courtroom::stop_clock(int id)
void Courtroom::set_clock_visibility(int id, bool visible)
{
- if (id < max_clocks && ui_clock[id] != nullptr)
+ if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
{
ui_clock[id]->setVisible(visible);
}
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp
index 4aae789e..6865987c 100644
--- a/src/packet_distribution.cpp
+++ b/src/packet_distribution.cpp
@@ -583,10 +583,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
// Timer ID is reserved as argument 0
int id = f_contents.at(0).toInt();
- // ID is invalid
- if (id < 0 || id >= w_courtroom->max_clocks)
- goto end;
-
// Type 0 = start/resume/sync timer at time
// Type 1 = pause timer at time
// Type 2 = show timer