diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 3e15fe3..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "editor.insertSpaces": false, - "files.exclude": { - "**/*.db3": true, - "**/*.o": true, - "**/*~": true, - "*/*.tgz": true, - "Makefile": true, - "nbproject": true - }, - "files.associations": { - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "array": "cpp", - "atomic": "cpp", - "strstream": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "chrono": "cpp", - "cstdint": "cpp", - "deque": "cpp", - "list": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "optional": "cpp", - "string_view": "cpp", - "fstream": "cpp", - "functional": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "memory": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "system_error": "cpp", - "thread": "cpp", - "cinttypes": "cpp", - "type_traits": "cpp", - "tuple": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "utility": "cpp", - "variant": "cpp", - "complex": "cpp", - "new": "cpp", - "algorithm": "cpp" - } -} \ No newline at end of file diff --git a/src/common/local.h b/src/common/local.h index 4a915ac..bb629dc 100644 --- a/src/common/local.h +++ b/src/common/local.h @@ -26,6 +26,9 @@ https://github.com/sago007/oastat/ #define MAX_ID 128 +/* This is a hardcoded value in the Quake 3 engine to distinguish environmental deaths from player-inflicted kills */ +#define ENTITYNUM_WORLD_1022 1022 + #include "oastatstruct.h" /* This array contains all the guid hashes of the players in a game */ diff --git a/src/db/Db2CppDb.cpp b/src/db/Db2CppDb.cpp index 133aea7..93578bb 100644 --- a/src/db/Db2CppDb.cpp +++ b/src/db/Db2CppDb.cpp @@ -400,6 +400,7 @@ void Db2CppDb::Rollback() commitlock->rollback(); commitlock = nullptr; commitlock = std::shared_ptr(new cppdb::transaction(*sql)); + playerids.clear(); //Clear player cache on rollback or we might get wrong playerids DebugMessage("Rollback"); } @@ -437,7 +438,7 @@ int Db2CppDb::getPlayerId(const std::string& guid) playerids[guid] = ret; } else { - std::cerr << "Player ID not found for GUID: " << guid << "\n"; + throw std::runtime_error("Player ID not found for GUID: " + guid); } } return ret; diff --git a/src/oss2db/Harvester2Db.cpp b/src/oss2db/Harvester2Db.cpp index 7ab3d20..8fa826f 100644 --- a/src/oss2db/Harvester2Db.cpp +++ b/src/oss2db/Harvester2Db.cpp @@ -45,13 +45,13 @@ void Harvester2Db::process(const OaStatStruct &oss) std::string player1 = ""; //Parameter 0 std::string player2 = ""; //Parameter 3 - if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) { + if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=ENTITYNUM_WORLD_1022) { player1 = clientIdMap.at(oss.parameters.at(0)); } else { player1 = "WORLD"; } - if (oss.parameters.at(3)>-1 && oss.parameters.at(3)<(int)clientIdMap.size() && oss.parameters.at(3)!=1022) { + if (oss.parameters.at(3)>-1 && oss.parameters.at(3)<(int)clientIdMap.size() && oss.parameters.at(3)!=ENTITYNUM_WORLD_1022) { player2 = clientIdMap.at(oss.parameters.at(3)); } else { player2 = "WORLD"; diff --git a/src/oss2db/kill2db.cpp b/src/oss2db/kill2db.cpp index 743c048..b36eea4 100644 --- a/src/oss2db/kill2db.cpp +++ b/src/oss2db/kill2db.cpp @@ -45,13 +45,13 @@ void Kill2Db::process(const OaStatStruct &oss) std::string target = ""; //Parameter 1 std::string killer = ""; //Parameter 0 //mod is parameter 2 - if (oss.parameters.at(1)>-1 && oss.parameters.at(1)<(int)clientIdMap.size() && oss.parameters.at(1)!=1022 ) { + if (oss.parameters.at(1)>-1 && oss.parameters.at(1)<(int)clientIdMap.size() && oss.parameters.at(1)!=ENTITYNUM_WORLD_1022 ) { target = clientIdMap.at(oss.parameters.at(1)); } else { target ="WORLD"; //Should not be possible... except maybe for NPC-creatures } - if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=1022) { + if (oss.parameters.at(0)>-1 && oss.parameters.at(0)<(int)clientIdMap.size() && oss.parameters.at(0)!=ENTITYNUM_WORLD_1022) { killer = clientIdMap.at(oss.parameters.at(0)); } else { killer ="WORLD";