Files
DarkflameServer/tests/dGameTests/GameSpellingsTests.cpp
Aaron Kimbrell a956e615f8 fix(scripts): the mast swing reads its lead-in as the game names it
The Gnarled Forest masts give the cinematic lead-in as LeadIn, an integer
(LeadIn=1:1). The mast script read LeanIn as a float, so the swing cinematic
always played with no lead-in. It now reads LeadIn and takes the integer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 07:08:36 -06:00

49 lines
1.5 KiB
C++

#include <gtest/gtest.h>
#include "GameDependencies.h"
#include "Entity.h"
#include "EffectsMessages.h"
#include "dGameMessagesTests/GameMessageTestUtils.h"
#include "02_server/Map/GF/MastTeleport.h"
// Names the server reads from the shipped game data, spelt as the game spells them.
using namespace GameMessageTestUtils;
class GameSpellingsTest : public GameDependenciesTest {
protected:
std::vector<std::unique_ptr<Entity>> entities;
void SetUp() override { SetUpDependencies(); }
void TearDown() override {
for (const auto& entity : entities) Game::entityManager->_removeEntity(entity->GetObjectID());
entities.clear();
TearDownDependencies();
}
Entity* Add(const LWOOBJID id, const LOT lot) {
info.lot = lot;
auto* const entity = entities.emplace_back(std::make_unique<Entity>(id, info)).get();
Game::entityManager->_addEntity(entity);
return entity;
}
};
// The Gnarled Forest masts' config: Cinematic=0:MastSwing_01 and LeadIn=1:1 (an integer)
TEST_F(GameSpellingsTest, TheMastSwingCinematicTakesTheMastsLeadIn) {
auto* const mast = Add(0x1000, 6714);
auto* const player = Add(0x1001, 1);
mast->SetVar<std::u16string>(u"Cinematic", u"MastSwing_01");
mast->SetVar<int32_t>(u"LeadIn", 1);
mast->SetVar<LWOOBJID>(u"userID", player->GetObjectID());
MastTeleport script;
const auto packets = Capture([&] { script.OnTimerDone(mast, "Start"); });
const auto sent = SentGameMessages<GameMessages::PlayCinematic>(packets);
ASSERT_EQ(sent.size(), 1u);
EXPECT_EQ(sent[0].pathName, u"MastSwing_01");
EXPECT_FLOAT_EQ(sent[0].leadIn, 1.0f);
}