From 79eabe5ed2806162fd3d85a369fe2dee3bcfbf62 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 17 Sep 2024 21:55:53 -0700 Subject: [PATCH] add check_size_vec_t --- src/PSOProtocol.hh | 6 ++++++ src/SaveFileFormats.hh | 1 + 2 files changed, 7 insertions(+) diff --git a/src/PSOProtocol.hh b/src/PSOProtocol.hh index e2a85f7c..e95670e1 100644 --- a/src/PSOProtocol.hh +++ b/src/PSOProtocol.hh @@ -120,6 +120,12 @@ T& check_size_t(void* data, size_t size) { return check_size_generic(data, size, sizeof(T), sizeof(T)); } +template +T* check_size_vec_t(std::string& data, size_t count) { + size_t expected_size = count * sizeof(T); + return &check_size_generic(data.data(), data.size(), expected_size, expected_size); +} + void check_size_v(size_t size, size_t min_size, size_t max_size = 0); std::string prepend_command_header( diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index a45547c5..9713dd62 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -14,6 +14,7 @@ #include "Episode3/DataIndexes.hh" #include "ItemNameIndex.hh" #include "PSOEncryption.hh" +#include "PSOProtocol.hh" #include "PlayerSubordinates.hh" #include "Text.hh"