Use the common 3.7 environment model and source-language contract tabs (by Codex)
This commit is contained in:
1 parent
249bdca1a8
commit
048f617395
11 files changed
+72
-17
No files matched your search
+10
-12
@@ -33,18 +33,16 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
// OpenBMH deviates from the original: the common Diamond 3.7 monthly
|
||||
// environment model applies to every supported source-data edition.
|
||||
// Numeric steps are data; an edition's original instructions are not run.
|
||||
auto steps=kEnvironmentStep;
|
||||
for(size_t i=0;i<steps.size();++i) {
|
||||
const auto at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if(!exe.contains(at)||exe.u8(at)==0){supported_environment=false;return;}
|
||||
steps[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;
|
||||
kEnvironmentStep=steps;supported_environment=true;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
@@ -57,7 +55,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");
|
||||
if (!supported_environment) throw FormatError("environment: monthly budget steps are missing or invalid");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
// Install validated numeric steps for the common Diamond 3.7 monthly model.
|
||||
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 };
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
// Canonical monthly environment model; source editions supply compatible data.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "launch/fltd.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
@@ -129,6 +130,12 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
for (uint32_t i = 0; i < 11 * 11; ++i)
|
||||
put(::bmh::layout::OriginalPointerPixels + i,
|
||||
en(::bmh::layout::EnglishOriginalPointerPixels + i));
|
||||
// Copy the actual English six-budget geometry, numeric steps and suffixes
|
||||
// for the common monthly environment model.
|
||||
for(const auto [to,from,count]:{std::array<uint32_t,3>{layout::Environment_FormatError_RuntimeField,0x6d230,6},
|
||||
{layout::Environment_FormatError_RuntimeField2,0x6d238,6},{layout::EnvironmentYouthColors,0x6d240,3},
|
||||
{layout::EnvironmentBudgetSteps,0x6d244,6},{layout::EnvironmentYouthPositionSuffix,0x6d24a,5},
|
||||
{layout::EnvironmentCostSuffix,0x6d24f,2}})for(uint32_t i=0;i<count;++i)put(to+i,en(from+i));
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
|
||||
const fs::path marker = prepared / ".openbmh-english";
|
||||
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
|
||||
// by another version is built again
|
||||
constexpr const char* kTranslation = "english translation 16"; // 16: overwrite question pointer (15: original pitch affinity tables and pointer bitmap)
|
||||
constexpr const char* kTranslation = "english translation 17"; // 17: English monthly environment tables (16: overwrite question)
|
||||
std::string built;
|
||||
{
|
||||
std::ifstream in(marker);
|
||||
|
||||
@@ -396,7 +396,7 @@ Image ContractsScreen::render() const {
|
||||
}
|
||||
const auto selected = std::find_if(state_.players.begin(), state_.players.end(),
|
||||
[&](const auto& p) { return p.row == state_.selected_row; });
|
||||
static constexpr std::array<std::string_view, 4> tabs{"DATEN-A", "DATEN-B", "GEHALT", "TEAM-PRÄMIEN"};
|
||||
const std::array<std::string,4> tabs{original_to_utf8(texts_[117]),original_to_utf8(texts_[118]),original_to_utf8(texts_[119]),original_to_utf8(texts_[120])};
|
||||
for (int i = 0; i < (state_.mode_three?4:3); ++i) {
|
||||
const int x = i * 60 + 2, w = i == 3 ? 71 : 51;
|
||||
if(i!=tab_) {fill(out,x+2,225,w,2,0x40);fill(out,x+w,217,2,10,0x40);}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/contracts.hpp"
|
||||
#include "ui/source_notice_test_helpers.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/textd.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -23,6 +26,20 @@ int main(int argc, char** argv) {
|
||||
state.club_name = "UNIT FOOTBALL CLUB";
|
||||
state.players.push_back({0, 150, "TORWART", 25, 0, 8, 180000});
|
||||
state.players.push_back({1, 151, "STÜRMER", 21, 3, 14, 90000});
|
||||
{
|
||||
auto language_state=state;language_state.mode_three=true;
|
||||
ContractsScreen language(argv[1],language_state);const auto frame=language.render();
|
||||
const auto data=std::filesystem::path(argv[1]);const auto exe=bmh::load_le(asset_path(data,"BMH.exe"));
|
||||
const auto texts=bmh::load_textd(asset_path(data,"TEXTD.BLK"));SpriteFont source_font(data);
|
||||
for(int tab=0;tab<4;++tab) {
|
||||
const auto caption=original_to_utf8(texts[size_t(117+tab)]);const int width=tab==3?71:51;
|
||||
const int x=tab*60+2+(tab==2?2:0),y=215+(tab==2?2:0);
|
||||
bmh::Image expected(320,240,0xfd);
|
||||
source_font.draw(expected,x+width/2-source_font.text_width(caption)/2,y+7,caption,exe.u8(bmh::layout::Advertising_Button_RuntimeField+(tab==2)));
|
||||
size_t ink=0;for(size_t pixel=0;pixel<expected.pixels.size();++pixel)if(expected.pixels[pixel]!=0xfd){check(frame.pixels[pixel]==expected.pixels[pixel],"contract tab does not render its authoritative source-language caption");++ink;}
|
||||
check(ink>10,"source-language contract tab oracle contains no glyphs");
|
||||
}
|
||||
}
|
||||
auto blocked_state = state;
|
||||
blocked_state.players[0].offer_blocked = true;
|
||||
ContractsScreen blocked(argv[1], blocked_state);
|
||||
|
||||
@@ -157,6 +157,8 @@ EnvironmentScreen::EnvironmentScreen(const std::filesystem::path& data, Environm
|
||||
background_.height != 240 || tiles_.width != 306 || tiles_.height != 111 ||
|
||||
panel_.width <= 0 || texts_.strings.size() != TEXT_COUNT)
|
||||
throw FormatError("environment: unsupported owner or Original assets");
|
||||
for(int item=0;item<kEnvironmentItems;++item){const int x=exe_.u8(layout::Environment_FormatError_RuntimeField+item),y=exe_.u8(layout::Environment_FormatError_RuntimeField2+item);
|
||||
if(x<9||x+0x36>=320||y<10||y+0x31+(item<3?6:0)>=240)throw FormatError("environment: tile geometry outside Original screen");}
|
||||
}
|
||||
|
||||
void EnvironmentScreen::text(Image& out, int x, int baseline, std::string_view value,
|
||||
|
||||
Reference in new issue
Block a user