Skip to content

Commit

Permalink
Assign battleanims to correct DrawableList
Browse files Browse the repository at this point in the history
Prevents lifetime issues with multipler battleanims
  • Loading branch information
Desdaemon committed Oct 30, 2024
1 parent 2c625ea commit e6d5d47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/battle_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "spriteset_map.h"

BattleAnimation::BattleAnimation(const lcf::rpg::Animation& anim, bool only_sound, int cutoff, bool synced, bool multiplayer) :
Sprite(multiplayer ? Drawable::Flags::Shared : Drawable::Flags::Default), animation(anim), only_sound(only_sound), synced(synced), multiplayer(multiplayer)
animation(anim), only_sound(only_sound), synced(synced), multiplayer(multiplayer)
{
num_frames = GetRealFrames() * 2;
if (cutoff >= 0 && cutoff < num_frames) {
Expand Down
5 changes: 5 additions & 0 deletions src/multiplayer/game_multiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,12 @@ void Game_Multiplayer::InitConnection() {
if (players.find(p.id) == players.end()) return;
const lcf::rpg::Animation* anim = lcf::ReaderUtil::GetElement(lcf::Data::animations, p.anim_id);
if (anim) {
auto scene_map = Scene::Find(Scene::SceneType::Map);
if (!scene_map) return;
auto old_list = &DrawableMgr::GetLocalList();
DrawableMgr::SetLocalList(&scene_map->GetDrawableList());
players[p.id].battle_animation.reset(new BattleAnimationMap(*anim, *players[p.id].ch, false, true, true));
DrawableMgr::SetLocalList(old_list);
} else {
players[p.id].battle_animation.reset();
}
Expand Down

0 comments on commit e6d5d47

Please sign in to comment.