Files
TeslaRel410/restoration/source410/BT/BTPLAYER.CPP
T
CydandClaude Fable 5 956fc57681 4.10 reconstruction: BTPlayer message-handler table + DropZone spawn dispatch
Fixes the incorrect DefaultData reuse of Player::MessageHandlers -- BTPlayer now
has its own handler table (DropZoneReply, VehicleDead, Score, ScoreInflicted,
ScoreUpdate; the last two add BT message IDs) chained onto the base set, matching
the .data table recovered in BT411. A mission-start DropZoneReply now routes to
BTPlayer::DropZoneReplyMessageHandler (the real spawn/respawn dispatch skeleton)
instead of the base "should not be handled by base player class" Fail stub.

Boot ladder now runs the full engine + app + network + mission + player path and
reaches the spawn handshake, halting at CreatePlayerVehicle -> Mech::Make -- the
Mech subsystem frontier (Mech ctor + mech2/3/4 + subsystems + weapons), the next
major reconstruction milestone. Scoring/death handlers, PlayerSimulation, and the
mech-placement tail staged with documented Fail bodies (BTPLAYER.NOTES.md).

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

338 lines
9.0 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
#if !defined(DROPZONE_HPP)
# include <dropzone.hpp>
#endif
//
//#############################################################################
// Shared data support
//#############################################################################
//
Derivation
BTPlayer::ClassDerivations(
Player::ClassDerivations,
"BTPlayer"
);
const Receiver::HandlerEntry
BTPlayer::MessageHandlerEntries[]=
{
MESSAGE_ENTRY(BTPlayer,DropZoneReply),
MESSAGE_ENTRY(BTPlayer,VehicleDead),
MESSAGE_ENTRY(BTPlayer,Score),
MESSAGE_ENTRY(BTPlayer,ScoreInflicted),
MESSAGE_ENTRY(BTPlayer,ScoreUpdate)
};
BTPlayer::MessageHandlerSet
BTPlayer::MessageHandlers(
ELEMENTS(BTPlayer::MessageHandlerEntries),
BTPlayer::MessageHandlerEntries,
Player::MessageHandlers
);
BTPlayer::SharedData
BTPlayer::DefaultData(
BTPlayer::ClassDerivations,
BTPlayer::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();
}
//
//#############################################################################
// DropZoneReplyMessageHandler The spawn / respawn handshake: when the drop
// zone replies with our spawn location we create (or, on respawn, reset) the
// player's vehicle there and bind it to us.
//
// The mech placement / respawn-reset tail depends on the Mech subsystem
// (Mech::MechClassID / Mech::Reset), which is not yet reconstructed; the
// dispatch skeleton below halts at CreatePlayerVehicle -> Mech::Make on the
// first (fresh-drop) reply. See BTPLAYER.NOTES.md.
//#############################################################################
//
void
BTPlayer::DropZoneReplyMessageHandler(DropZone__ReplyMessage *message)
{
Check(this);
Check(message);
if (!playerVehicle)
{
CreatePlayerVehicle(message->dropZoneLocation);
InitializePlayerLink();
//
// A piloted mech runs the combat PlayerSimulation and is a scoring
// player; a camera-ship observer runs CameraShipSimulation and never
// ranks. (Vehicle-class dispatch + mech placement deferred with the
// Mech subsystem.)
//
AlwaysExecute();
deathCount = 0;
}
else if (deathCount == message->deathCount)
{
if (GetSimulationState() == MissionEndingState)
{
Check_Fpu();
return;
}
//
// Respawn: reset the existing dead mech in place (deferred with the
// Mech subsystem).
//
}
Check_Fpu();
}
//
//#############################################################################
// Vehicle creation -- pulls in the Mech subsystem (Mech::Make), not yet
// reconstructed. This is the current boot frontier.
//#############################################################################
//
void
BTPlayer::CreatePlayerVehicle(Origin)
{
Fail("BTPlayer::CreatePlayerVehicle -- btplayer.cpp not yet reconstructed");
}
void
BTPlayer::InitializePlayerLink()
{
Fail("BTPlayer::InitializePlayerLink -- btplayer.cpp not yet reconstructed");
}
//
//#############################################################################
// Scoring / death handlers -- exercised in combat, not during bring-up boot.
//#############################################################################
//
void
BTPlayer::VehicleDeadMessageHandler(VehicleDeadMessage *)
{
Fail("BTPlayer::VehicleDeadMessageHandler -- btplayer.cpp not yet reconstructed");
}
void
BTPlayer::ScoreMessageHandler(ScoreMessage *)
{
Fail("BTPlayer::ScoreMessageHandler -- btplayer.cpp not yet reconstructed");
}
void
BTPlayer::ScoreInflictedMessageHandler(ScoreMessage *)
{
Fail("BTPlayer::ScoreInflictedMessageHandler -- btplayer.cpp not yet reconstructed");
}
void
BTPlayer::ScoreUpdateMessageHandler(ScoreMessage *)
{
Fail("BTPlayer::ScoreUpdateMessageHandler -- btplayer.cpp not yet reconstructed");
}
//
//#############################################################################
// 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");
}