Files
TeslaRel410/restoration/source410/BT/BTPLAYER.CPP
T
CydandClaude Fable 5 c43e6d873a 4.10 reconstruction: real BTPlayer ctor (binary-accurate experience-level flags)
Boot ladder advances past player creation. BTPlayer ctor/dtor/Make/
TestInstance/GetExperienceLevel reconstructed from BT411's Ghidra-recovered
body (@004c0bc8) backdated to 1995 idiom; the reserved[38] placeholder in
BTPLAYER.HPP replaced with the real BT-own members.

Key fidelity call: the game-mode flags are derived from
btMission->ExperienceLevel() (the egg's per-pilot experience key) with the
binary-accurate switch rows from the [T1] disassembly -- NOT from the scenario
role's returnFromDeath, which BT411's port uses as a [T3] stand-in. Mapping and
residual naming/[T4] uncertainty documented in BTPLAYER.NOTES.md.

Live boot now runs: banner -> resources -> app ctor -> network single-user ->
egg -> mission -> SetPlayerData -> BTRegistry::MakePlayer -> BTPlayer ctor
(resolves team, seeds experience flags) -> halts at the base
Player::DropZoneReplyMessageHandler stub (BTPlayer's own message-handler table
is the next brick -- DefaultData still reuses Player::MessageHandlers).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 20:18:37 -05:00

222 lines
5.9 KiB
C++

//===========================================================================//
// File: btplayer.cpp //
// Project: BattleTech //
// Contents: Implementation details for the BT player //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <bt.hpp>
#pragma hdrstop
#if !defined(BTPLAYER_HPP)
# include <btplayer.hpp>
#endif
#if !defined(BTTEAM_HPP)
# include <btteam.hpp>
#endif
#if !defined(BTMSSN_HPP)
# include <btmssn.hpp>
#endif
#if !defined(NTTMGR_HPP)
# include <nttmgr.hpp>
#endif
#if !defined(APP_HPP)
# include <app.hpp>
#endif
//
//#############################################################################
// Shared data support
//#############################################################################
//
Derivation
BTPlayer::ClassDerivations(
Player::ClassDerivations,
"BTPlayer"
);
BTPlayer::SharedData
BTPlayer::DefaultData(
BTPlayer::ClassDerivations,
Player::MessageHandlers,
Player::AttributeIndex,
1,
(Entity::MakeHandler)BTPlayer::Make
);
//
//#############################################################################
// Constructor
//
// Copies the team name out of the creation message, resolves the owning
// BTTeam, caches the mission, and derives the game-mode display / heat-model
// flags from the mission's experience level and advanced-damage flag.
//#############################################################################
//
BTPlayer::BTPlayer(
MakeMessage *creation_message,
SharedData &shared_data
):
Player(creation_message, shared_data)
{
consoleAttached = False;
suppressConsole = False;
currentScore = 0;
deathPending = False;
//
// Remember our team name from the creation message.
//
strcpy(teamName, creation_message->teamName);
//
// Resolve the BTTeam entity that owns this team name.
//
teamEntity = NULL;
EntityGroup *teams = application->GetEntityManager()->FindGroup("Teams");
if (teams)
{
ChainIteratorOf<Node*> iterator(teams->groupMembers);
BTTeam *team;
while ((team = (BTTeam *)iterator.ReadAndNext()) != NULL)
{
if (strcmp(team->teamName, teamName) == 0)
{
teamEntity = team;
break;
}
}
}
freeForAll = True;
//
// Cache the mission (experience level / advanced-damage source).
//
BTMission *bt_mission =
Cast_Object(BTMission *, application->GetCurrentMission());
btMission = bt_mission;
if (GetInstance() == ReplicantInstance)
{
//
// Replicant: driven by console-update messages.
//
SetPerformance(&BTPlayer::PlayerSimulation);
}
else
{
//
// Master: derive the game-mode flags from the mission experience
// level (novice / standard / veteran / expert) and advanced-damage
// technician flag. See BTPLAYER.NOTES.md for the flag mapping.
//
Check(bt_mission);
switch (bt_mission->ExperienceLevel())
{
case BTMission::NoviceMode:
showDamageReceived = 0;
showKills = 0;
roleReturnDelay2 = 0;
showScore = 0;
break;
case BTMission::StandardMode:
showDamageReceived = 1;
showKills = 0;
roleReturnDelay2 = 1;
showScore = 1;
break;
case BTMission::VeteranMode:
showDamageReceived = 1;
showKills = 1;
roleReturnDelay2 = 1;
showScore = 1;
break;
case BTMission::ExpertMode:
showDamageReceived = 1;
showKills = 1;
roleReturnDelay2 = 0;
showScore = 1;
break;
}
showDamageInflicted = bt_mission->AdvancedDamageOn();
roleReturnDelay = bt_mission->AdvancedDamageOn();
roleClassIndex = bt_mission->ExperienceLevel();
}
killCount = 0;
padScore = 0;
objectiveMech = NULL;
lastPerformance = lastConsoleUpdate = lastUpdate;
Check_Fpu();
}
//
//#############################################################################
//#############################################################################
//
BTPlayer::~BTPlayer()
{
Check(this);
Check_Fpu();
}
//
//#############################################################################
// Make
//#############################################################################
//
BTPlayer*
BTPlayer::Make(MakeMessage *creation_message)
{
return new BTPlayer(creation_message);
}
//
//#############################################################################
//#############################################################################
//
Logical
BTPlayer::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// GetExperienceLevel
//#############################################################################
//
Enumeration
BTPlayer::GetExperienceLevel()
{
Check(this);
Check(btMission);
return Cast_Object(BTMission *, btMission)->ExperienceLevel();
}
//
//#############################################################################
// PlayerSimulation -- console-update performance (not yet reconstructed).
// The constructor installs this as the replicant Performance; its body is
// exercised only on a networked console-driven run.
//#############################################################################
//
void
BTPlayer::PlayerSimulation(Scalar)
{
Fail("BTPlayer::PlayerSimulation -- btplayer.cpp not yet reconstructed");
}