fixed anim bug

This commit is contained in:
Vladislav Khorev committed 2026-10-30 15:09:13 +06:00
1 parent 297bd7377f
commit 931236bec0
2 files changed
+50 -20

No files matched your search

+23
View File
@@ -1,5 +1,7 @@
#include "LocationGameState.h" #include "LocationGameState.h"
#include "game_server/InternalGameServer.h"
#include <cstdlib> #include <cstdlib>
#include <filesystem>
#include <iostream> #include <iostream>
namespace { namespace {
@@ -14,6 +16,10 @@ int fail(const char* message)
int main() int main()
{ {
const std::filesystem::path repositoryRoot =
std::filesystem::path(__FILE__).parent_path().parent_path().parent_path();
std::filesystem::current_path(repositoryRoot);
FRG::LocationDefinition definition; FRG::LocationDefinition definition;
definition.config.id = "test_location"; definition.config.id = "test_location";
@@ -63,5 +69,22 @@ int main()
FRG::PlayerStateMap noPlayers; FRG::PlayerStateMap noPlayers;
state.update(50, noPlayers, false); state.update(50, noPlayers, false);
FRG::CampaignConfig battleZone;
battleZone.id = "battle_zone";
battleZone.questsPath = "resources/config/quests_battle_zone.json";
FRG::InternalGameServer server;
server.startCampaign(battleZone, {}, false, true);
const auto snapshot = server.snapshot();
const auto bot = snapshot->players.find("battle_zone_test_bot");
if (bot == snapshot->players.end())
return fail("Battle Zone test bot was not created");
const auto stand = static_cast<std::size_t>(FRG::AnimationState::STAND);
const auto walk = static_cast<std::size_t>(FRG::AnimationState::WALK);
if (bot->second.state.animationFrameCounts[stand] <= 1 ||
bot->second.state.animationFrameCounts[walk] <= 1) {
return fail("Battle Zone test bot animation metadata was not loaded");
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
+27 -20
View File
@@ -11,6 +11,31 @@ namespace {
constexpr const char* kBattleZoneCampaignId = "battle_zone"; constexpr const char* kBattleZoneCampaignId = "battle_zone";
constexpr const char* kBattleZoneTestBotId = "battle_zone_test_bot"; constexpr const char* kBattleZoneTestBotId = "battle_zone_test_bot";
constexpr std::int64_t kBattleZoneTestBotIntervalMs = 5000; constexpr std::int64_t kBattleZoneTestBotIntervalMs = 5000;
void configurePlayerAnimations(
CharacterState& player, const std::string& zipFile)
{
player.creationInfo.animationPaths = {
{AnimationState::STAND,
"resources/w/gg/new2/gg_stand_idle001_small.anim"},
{AnimationState::WALK,
"resources/w/gg/new2/gg_walk001_small.anim"},
{AnimationState::STAND_TO_ACTION,
"resources/w/gg/new2/gg_stand_to_action001_small.anim"},
{AnimationState::ACTION_ATTACK,
"resources/w/gg/new2/gg_action_chop001_small.anim"},
{AnimationState::ACTION_ATTACK_2,
"resources/w/gg/new2/gg_action_stab001_small.anim"},
{AnimationState::ACTION_IDLE,
"resources/w/gg/new2/gg_action_idle002_small.anim"},
{AnimationState::ACTION_TO_STAND,
"resources/w/gg/new2/gg_action_to_stand001_small.anim"},
{AnimationState::ACTION_TO_DEATH,
"resources/w/gg/new2/gg_die001_small.anim"},
{AnimationState::DEATH_IDLE,
"resources/w/gg/new2/gg_die_idle001_small.anim"}};
loadCharacterAnimationMetadata(player, zipFile);
}
} }
InternalGameServer::InternalGameServer() = default; InternalGameServer::InternalGameServer() = default;
@@ -26,6 +51,7 @@ void InternalGameServer::ensureBattleZoneTestBot()
auto& bot = state_.players[kBattleZoneTestBotId]; auto& bot = state_.players[kBattleZoneTestBotId];
if (!bot) bot = std::make_shared<CharacterState>(); if (!bot) bot = std::make_shared<CharacterState>();
bot->configureAsPlayer(); bot->configureAsPlayer();
configurePlayerAnimations(*bot, resourceZipFile_);
bot->npcName = "Test Bot"; bot->npcName = "Test Bot";
} }
@@ -77,26 +103,7 @@ void InternalGameServer::startCampaign(
if (createLocalPlayer) { if (createLocalPlayer) {
auto player = std::make_shared<CharacterState>(); auto player = std::make_shared<CharacterState>();
player->configureAsPlayer(); player->configureAsPlayer();
player->creationInfo.animationPaths = { configurePlayerAnimations(*player, zipFile);
{AnimationState::STAND,
"resources/w/gg/new2/gg_stand_idle001_small.anim"},
{AnimationState::WALK,
"resources/w/gg/new2/gg_walk001_small.anim"},
{AnimationState::STAND_TO_ACTION,
"resources/w/gg/new2/gg_stand_to_action001_small.anim"},
{AnimationState::ACTION_ATTACK,
"resources/w/gg/new2/gg_action_chop001_small.anim"},
{AnimationState::ACTION_ATTACK_2,
"resources/w/gg/new2/gg_action_stab001_small.anim"},
{AnimationState::ACTION_IDLE,
"resources/w/gg/new2/gg_action_idle002_small.anim"},
{AnimationState::ACTION_TO_STAND,
"resources/w/gg/new2/gg_action_to_stand001_small.anim"},
{AnimationState::ACTION_TO_DEATH,
"resources/w/gg/new2/gg_die001_small.anim"},
{AnimationState::DEATH_IDLE,
"resources/w/gg/new2/gg_die_idle001_small.anim"}};
loadCharacterAnimationMetadata(*player, zipFile);
state_.players.emplace(localPlayerId_, std::move(player)); state_.players.emplace(localPlayerId_, std::move(player));
} }
battleZoneTestBotElapsedMs_ = 0; battleZoneTestBotElapsedMs_ = 0;