Prepare Classic 1.0 edition rules and Diamond 3.7 foreign crests (by Codex)
This commit is contained in:
1 parent
c293a35f56
commit
8ee062ea46
46 files changed
+296
-147
No files matched your search
+18
-1
@@ -20,11 +20,28 @@ constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeFie
|
||||
|
||||
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
|
||||
// (the clubs per league are kLeagueSizes, schedule.hpp)
|
||||
constexpr int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
|
||||
int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
|
||||
{85, 95}, {90, 95}, {75, 95}, {80, 95}};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::pair<int,int> career_strength_range(int league) {
|
||||
if (league<0 || league>=9) throw FormatError("career: invalid league range");
|
||||
return {kLeagueStrength[league][0],kLeagueStrength[league][1]};
|
||||
}
|
||||
|
||||
void install_career_rules(const LeImage& exe) {
|
||||
int next[9][2]{};
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
for (int bound = 0; bound < 2; ++bound)
|
||||
next[league][bound] = exe.u8(layout::LeagueStrengthRanges + uint32_t(league * 2 + bound));
|
||||
if (next[league][0] > next[league][1] || next[league][1] > 99)
|
||||
throw FormatError("career: unsupported original league strength range");
|
||||
}
|
||||
for (int league = 0; league < 9; ++league)
|
||||
for (int bound = 0; bound < 2; ++bound) kLeagueStrength[league][bound] = next[league][bound];
|
||||
}
|
||||
|
||||
void generate_player(GameState& g, int id, int level_flags, GameRandom& game, WatcomRandom& rand) {
|
||||
Player& p = g.players.at(size_t(id));
|
||||
const bool keep_age = (level_flags & 0x1000) != 0, exact = (level_flags & 0x2000) != 0;
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Install the nine strength ranges from the loaded edition, never a shared replacement.
|
||||
void install_career_rules(const LeImage&);
|
||||
std::pair<int,int> career_strength_range(int league);
|
||||
|
||||
// OpenBMH deviates from the original: uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
// GeneratePlayer with the supported rule profile patch GeneratePlayer2: new values for player `id` around
|
||||
// `level` (low 12 bits of `level_flags`; 0x1000 = leave the age at 0, 0x2000 = exactly
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
#include "game/environment.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
|
||||
|
||||
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||
uint32_t spending_at(int manager, int item) {
|
||||
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||
@@ -29,6 +32,21 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
}
|
||||
void install_environment_rules(const LeImage& exe) {
|
||||
for (size_t i=0;i<kEnvironmentStep.size();++i) {
|
||||
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
|
||||
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
uint64_t fingerprint = 14695981039346656037ull;
|
||||
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
|
||||
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
|
||||
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
|
||||
}
|
||||
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
|
||||
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
const auto value = g.memory.u32(spending_at(manager, item));
|
||||
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
|
||||
@@ -39,6 +57,7 @@ bool environment_academy_active(const GameState& g, int manager) {
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
@@ -56,6 +75,7 @@ EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
}
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (message) message->clear();
|
||||
if (!supported_environment) return EnvironmentResult::invalid;
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
|
||||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "game/random.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
std::array<int, kEnvironmentItems> level{};
|
||||
|
||||
Reference in new issue
Block a user