diff --git a/include/algorithms/CaptureAnims.h b/include/algorithms/CaptureAnims.h index 86b47c9..b5c23e9 100644 --- a/include/algorithms/CaptureAnims.h +++ b/include/algorithms/CaptureAnims.h @@ -488,6 +488,10 @@ namespace CaptureAnims { } static constexpr const char *FindStr(Type type) { - return s_Strs.at(ToValue(type)); + const s16 type_ = (s16)type; + if (0 <= type_ && type_ < s_Strs.size()) + return s_Strs[type_]; + else + return ""; } } \ No newline at end of file diff --git a/include/algorithms/CaptureTypes.h b/include/algorithms/CaptureTypes.h index b98552a..614c4e8 100644 --- a/include/algorithms/CaptureTypes.h +++ b/include/algorithms/CaptureTypes.h @@ -98,6 +98,10 @@ namespace CaptureTypes { } static constexpr const char *FindStr(Type type) { - return s_Strs.at(ToValue(type)); + const s16 type_ = (s16)type; + if (0 <= type_ && type_ < s_Strs.size()) + return s_Strs[type_]; + else + return ""; } } \ No newline at end of file diff --git a/include/algorithms/PlayerAnims.h b/include/algorithms/PlayerAnims.h index 5e2e9ad..2cd50fb 100644 --- a/include/algorithms/PlayerAnims.h +++ b/include/algorithms/PlayerAnims.h @@ -1154,6 +1154,10 @@ namespace PlayerAnims { } static constexpr const char *FindStr(Type type) { - return s_Strs.at(ToValue(type)); + const s16 type_ = (s16)type; + if (0 <= type_ && type_ < s_Strs.size()) + return s_Strs[type_]; + else + return ""; } } \ No newline at end of file diff --git a/include/algorithms/WipeTypes.h b/include/algorithms/WipeTypes.h index 5f40910..5c9bcee 100644 --- a/include/algorithms/WipeTypes.h +++ b/include/algorithms/WipeTypes.h @@ -72,6 +72,10 @@ namespace WipeTypes { } static constexpr const char *FindStr(Type type) { - return s_Strs.at(ToValue(type)); + const s16 type_ = (s16)type; + if (0 <= type_ && type_ < s_Strs.size()) + return s_Strs[type_]; + else + return ""; } } \ No newline at end of file diff --git a/source/server/Client.cpp b/source/server/Client.cpp index a6560d7..010436b 100644 --- a/source/server/Client.cpp +++ b/source/server/Client.cpp @@ -783,12 +783,16 @@ void Client::updatePlayerInfo(PlayerInf *packet) { } else { strcpy(curInfo->curAnimStr, "Wait"); } + if (strlen(curInfo->curAnimStr) == 0) + Logger::log("[ERROR] %s: actName was out of bounds: %d", __func__, packet->actName); if(packet->subActName != PlayerAnims::Type::Unknown) { strcpy(curInfo->curSubAnimStr, PlayerAnims::FindStr(packet->subActName)); } else { strcpy(curInfo->curSubAnimStr, ""); } + if (strlen(curInfo->curSubAnimStr) == 0) + Logger::log("[ERROR] %s: subActName was out of bounds: %d", __func__, packet->subActName); curInfo->curAnim = packet->actName; curInfo->curSubAnim = packet->subActName;