diff --git a/src/ObjCommon/InfoString/InfoString.cpp b/src/ObjCommon/InfoString/InfoString.cpp index 5a731e0e..14efada8 100644 --- a/src/ObjCommon/InfoString/InfoString.cpp +++ b/src/ObjCommon/InfoString/InfoString.cpp @@ -1,6 +1,7 @@ #include "InfoString.h" #include +#include #include #include @@ -170,17 +171,36 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream) std::string readPrefix; if (!infoStream.NextField(readPrefix)) + { + std::cerr << "Invalid info string: Empty\n"; return false; + } if (prefix != readPrefix) + { + std::cerr << "Invalid info string: Prefix \"" << readPrefix << "\" did not match expected prefix \"" << prefix << "\"\n"; return false; + } std::string key; while (infoStream.NextField(key)) { + if (key.empty()) + { + if (m_keys_by_insertion.empty()) + std::cerr << "Invalid info string: Got empty key at the start of the info string\n"; + else + std::cerr << "Invalid info string: Got empty key after key \"" << m_keys_by_insertion[m_keys_by_insertion.size() - 1] << "\"\n"; + + return false; + } + std::string value; if (!infoStream.NextField(value)) + { + std::cerr << "Invalid info string: Unexpected eof, no value for key \"" << key << "\"\n"; return false; + } const auto existingEntry = m_values.find(key); if (existingEntry == m_values.end()) diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp index 30701f60..6f08e0c4 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderPhysPreset.cpp @@ -126,7 +126,7 @@ bool AssetLoaderPhysPreset::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) { - std::cout << "Failed to read phys preset raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp index bd3cf859..db91158a 100644 --- a/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW4/AssetLoaders/AssetLoaderWeapon.cpp @@ -440,7 +440,7 @@ bool AssetLoaderWeapon::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << "Failed to read weapon raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp index 4054129a..7343589f 100644 --- a/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/IW5/AssetLoaders/AssetLoaderWeapon.cpp @@ -870,7 +870,7 @@ bool AssetLoaderWeapon::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << "Failed to read weapon raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp index 67166778..d707d037 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysConstraints.cpp @@ -146,7 +146,7 @@ bool AssetLoaderPhysConstraints::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS, *file.m_stream)) { - std::cout << "Failed to read phys constraints raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp index 4542953b..eac11ae8 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderPhysPreset.cpp @@ -129,7 +129,7 @@ bool AssetLoaderPhysPreset::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) { - std::cout << "Failed to read phys preset raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp index d75f23fd..1d0242b8 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderTracer.cpp @@ -112,7 +112,7 @@ bool AssetLoaderTracer::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_TRACER, *file.m_stream)) { - std::cout << "Failed to read tracer raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp index 91acd77d..43c3ff65 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderVehicle.cpp @@ -175,7 +175,7 @@ bool AssetLoaderVehicle::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_VEHICLE, *file.m_stream)) { - std::cout << "Failed to read vehicle raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp index 940d3424..dc2ab93d 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp @@ -621,7 +621,7 @@ bool AssetLoaderWeapon::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << "Failed to read weapon raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp index 9c919685..2ac312c1 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachment.cpp @@ -165,7 +165,7 @@ bool AssetLoaderWeaponAttachment::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, *file.m_stream)) { - std::cerr << "Failed to read attachment raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp index 379a97f8..601e3bd6 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeaponAttachmentUnique.cpp @@ -285,7 +285,7 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, *file.m_stream)) { - std::cerr << "Failed to read attachment unique raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; } diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp index b8421ae5..68744477 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderZBarrier.cpp @@ -126,7 +126,7 @@ bool AssetLoaderZBarrier::LoadFromRaw( InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_ZBARRIER, *file.m_stream)) { - std::cout << "Failed to read zbarrier raw file: \"" << fileName << "\"\n"; + std::cerr << "Could not parse as info string file: \"" << fileName << "\"\n"; return true; }