(by Codex) Fix seller transfer review and fresh-arrival contract flags

This commit is contained in:
Codex committed 2026-11-01 17:57:55 +01:00
1 parent d57b6b5a96
commit 8baf80564a
19 files changed
+461 -28

No files matched your search

+7
View File
@@ -538,6 +538,13 @@ TransferActionResult list_manager_player(GameState& g, int manager, int squad_ro
out.status = TransferActionStatus::invalid_player;
return out;
}
bool free_entry = false;
for (size_t entry = 0; entry < 40; ++entry) {
const int listed = g.squad_slots.at(0xb70 + entry) & 0xfff;
if (listed == player) { out.status = TransferActionStatus::pending; out.player = player; out.list_entry = int(entry); return out; }
free_entry = free_entry || listed == 0xfff;
}
if (!free_entry) { out.status = TransferActionStatus::blocked_by_board; return out; }
if (!list_transfer_player(g, slot, rand, report)) {
out.status = report.unsupported ? TransferActionStatus::invalid_request : TransferActionStatus::blocked_by_board;
return out;
+7
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "game/transfer_allocator.hpp"
// OpenBMH deviates from the original: supports designated set-piece records and the supported transfer-editor rules.
// Actions a human manager can take at his desk that change the game state and draw random
// numbers (BMH.exe V2.24 + supported rule profile patch). The screens themselves belong to the UI; these
@@ -272,6 +273,12 @@ struct TransferOfferEditorSubmitResult {
TransferOfferEditorSubmitResult submit_transfer_offer_editor_source(GameState&,
const TransferOfferEditorState&,WatcomRandom&,const HumanBuyerSaleHooks&,MinuteReport&);
// OpenBMH deviates from the original: a seller may accept an existing bid before expiry.
// The caller stages state/RNG; cancellation is handled before invoking this action.
TransferActionResult accept_manager_transfer_offer(GameState&, int manager, int list_entry,
int expected_player, int bid_index, WatcomRandom&, MinuteReport&,
TransferAllocatorContext = TransferAllocatorContext::unsupported);
// Submit a manager bid on an existing list entry. A full-value fee and salary meeting
// the demand complete an immediate agreement; lower viable offers persist for weekly review.
TransferActionResult submit_transfer_bid(GameState& g, const TransferBidRequest& request, WatcomRandom& rand);
+3
View File
@@ -74,6 +74,9 @@ void new_board_entry(GameState& g, int manager, int index, int slot, WatcomRando
uint8_t* e = &g.tactics.at(size_t(manager) * kBoard + size_t(index) * kBoardSlot);
std::memset(e + 7, 0, 3);
std::memset(e + 0x19, 0, 0x24);
// OpenBMH deviates from the original: a new arrival must not inherit the
// previous occupant's retirement/refusal/month-processing flags.
e[0xb] = 0;
e[10] = 2;
for (int k = 0; k < 4; k++) e[2 + k] = index < 2 ? 1 : uint8_t(rand.range(2, 0x27));
e[0x3f] = 0xff;
+43
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/weekly.hpp"
#include "game/desk_actions.hpp"
#include "game/pending_offer.hpp"
#include "game/human_buyer_sale.hpp"
#include "game/transfer_bid.hpp"
@@ -1637,6 +1638,7 @@ static TransferOfferListView project_transfer_offer_list_impl(const GameState& g
view.player = player;
view.seller = g.memory.u16(list + 8) & 0x7fff;
view.seller_manager = g.manager_of(view.seller);
offer_bases(g.memory, list, -1, view.asking_fee, view.asking_monthly_salary);
for (int bid = 0; bid < 4; ++bid) view.offers[size_t(bid)].bid_index = bid;
if (view.seller_manager >= 0 && g.memory.has(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager)))
view.seller_loan_count = g.memory.u8(::bmh::layout::DeskActions_Unsupported_RuntimeField + uint32_t(view.seller_manager));
@@ -2621,6 +2623,47 @@ PendingOfferResult process_national_nomination_pending_after_desk(GameState& g,
return process_natural_pending_offers_after_desk(g,request,game,rand,hooks,report);
}
TransferActionResult accept_manager_transfer_offer(GameState& g, int manager, int entry,
int expected_player, int bid, WatcomRandom& rand, MinuteReport& report, TransferAllocatorContext allocator) {
TransferActionResult result;
const auto view = project_transfer_offer_list(g, entry);
if (!view.valid || manager < 0 || view.seller_manager != manager ||
view.player != expected_player || bid < 0 || bid >= 4) return result;
const auto& offer = view.offers[size_t(bid)];
if (!offer.present) return result;
if (!offer.affordable) { result.status = TransferActionStatus::insufficient_funds; return result; }
if (!offer.has_squad_room) { result.status = TransferActionStatus::no_squad_room; return result; }
if (!offer.passes_foreign_limit || !offer.loan_permitted) {
result.status = TransferActionStatus::blocked_by_board; return result;
}
if (!offer.transaction_supported) { result.status = TransferActionStatus::unsupported; return result; }
const uint32_t list = kTransferList + uint32_t(entry) * kListEntry;
auto staged = g;
auto staged_rand = rand;
const uint32_t salary_at = list + 0x0c + uint32_t(bid) * 4;
const auto salary = staged.memory.u32(salary_at);
staged.memory.set32(salary_at, (salary * 10u) >> 3);
uint32_t fee_pct = 0, salary_pct = 0;
const bool rated = evaluate_bid(staged, list, bid, fee_pct, salary_pct, staged_rand, report);
staged.memory.set32(salary_at, salary);
if (!rated || report.unsupported) { result.status = TransferActionStatus::unsupported; return result; }
if (!salary_pct) { result.status = TransferActionStatus::rejected; return result; }
if (!accept_transfer_bid_immediately(staged, entry, bid, staged_rand, report,
allocator) || report.unsupported) {
result.status = TransferActionStatus::unsupported; return result;
}
const auto buyer_range = squad_range(offer.buyer);
const bool moved = std::any_of(staged.squad_slots.begin() + buyer_range.first,
staged.squad_slots.begin() + buyer_range.first + buyer_range.count,
[&](uint16_t slot) { return (slot & 0xfff) == expected_player; });
if (!moved) { result.status = TransferActionStatus::unsupported; return result; }
g = std::move(staged); rand = staged_rand;
result.status = TransferActionStatus::accepted;
result.player = expected_player; result.list_entry = entry;
result.fee = int32_t(offer.fee); result.annual_salary = int32_t(offer.monthly_salary);
return result;
}
bool accept_transfer_bid_immediately(GameState& g, int entry, int bid, WatcomRandom& rand,
MinuteReport& report, TransferAllocatorContext allocator) {
if (entry < 0 || entry >= 40 || bid < 0 || bid >= 4) return false;