add more compile-time diagnostics, implement fixes for them

Before, a lot of common errors went unnoticed, due to insufficient
compiler diagnostics. This commit fixes this by adding a lot of new
diagnostics, and fixing the issues found by this.
This commit is contained in:
Lion Kortlepel
2022-09-26 12:02:05 +02:00
parent 501fddadc6
commit 24c98eb2b2
15 changed files with 141 additions and 85 deletions

View File

@@ -22,10 +22,10 @@ static std::optional<std::pair<int, int>> GetPidVid(const std::string& str) {
if (pid.find_first_not_of("0123456789") == std::string::npos && vid.find_first_not_of("0123456789") == std::string::npos) {
try {
int PID = stoi(pid);
int VID = stoi(vid);
return {{ PID, VID }};
} catch(const std::exception&) {
int PID = stoi(pid);
int VID = stoi(vid);
return { { PID, VID } };
} catch (const std::exception&) {
return std::nullopt;
}
}
@@ -75,7 +75,6 @@ TEST_CASE("GetPidVid") {
}
}
TServer::TServer(const std::vector<std::string_view>& Arguments) {
beammp_info("BeamMP Server v" + Application::ServerVersionString());
Application::SetSubsystemStatus("Server", Application::Status::Starting);
@@ -256,7 +255,7 @@ void TServer::ParseVehicle(TClient& c, const std::string& Pckt, TNetwork& Networ
std::string Packet = Pckt;
char Code = Packet.at(1);
int PID = -1;
int VID = -1, Pos;
int VID = -1;
std::string Data = Packet.substr(3), pid, vid;
switch (Code) { // Spawned Destroyed Switched/Moved NotFound Reset
case 's':