Files
Dreierpack-Manager/src/formats/native_save_version.hpp
T
ClaudeandClaude Sonnet 5.5 287b5a9251 Add header comments to the source files
Every source file in ui, app, game, formats, cli, audio and launch that had none
now starts with a short English comment: what it implements, what state it owns
and how it relates to its neighbours (request/acknowledge flow, pairs of files,
random generator use). Comment lines only; the full build and the runnable
tests are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 09:15:23 +01:00

26 lines
1.4 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// Accepted savegame version markers for the native (original-layout) save format. The FBM
// container (fbm.hpp) carries a version string; V2.24 and V3.7 share the same block order,
// while expanded careers use their own marker (O1.1) and layout. require_native_savegame()
// throws FormatError on a bad checksum or an unsupported marker; callers still validate the
// full state layout afterwards (savestate.hpp). Header-only.
#pragma once
#include "formats/fbm.hpp"
#include <string_view>
namespace bmh {
// Verified German V2.24 state layout: the supplied Diamond 3.7 changes its
// container label, while retaining the same block order and database counts.
// Expanded careers have their own layout and must not accept these markers.
inline bool supported_native_save_version(std::string_view version, bool expanded = false) {
return expanded ? version == "O1.1" : version == "V2.24" || version == "V3.7";
}
inline void require_native_savegame(const Savegame& save, bool expanded = false) {
if (!save.checksum_ok) throw FormatError("savegame: FBM checksum mismatch");
if (!supported_native_save_version(save.version, expanded))
throw FormatError("savegame: unsupported FBM version " + save.version);
// Callers still parse the complete state using the installed edition's
// exact DbCounts; a recognized marker never bypasses layout validation.
}
}