summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/character_system.cpp8
-rw-r--r--src/character_system.h2
-rw-r--r--src/game.cpp8
3 files changed, 14 insertions, 4 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index d4765bf..888914f 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -238,3 +238,11 @@ void CharacterSystem::stopRunningSound(Sprite& sprite) {
238 sprite.runningSfxChannel = -1; 238 sprite.runningSfxChannel = -1;
239 } 239 }
240} 240}
241
242void CharacterSystem::clearSpriteCache() {
243 for (Sprite& sprite : game_.getSprites() | game_.spriteView()) {
244 if (sprite.runningSfxChannel != -1) {
245 stopRunningSound(sprite);
246 }
247 }
248}
diff --git a/src/character_system.h b/src/character_system.h index 18b6c46..39b3958 100644 --- a/src/character_system.h +++ b/src/character_system.h
@@ -31,6 +31,8 @@ public:
31 31
32 void endCrouch(int spriteId); 32 void endCrouch(int spriteId);
33 33
34 void clearSpriteCache() override;
35
34private: 36private:
35 37
36 void stopRunning(int spriteId); 38 void stopRunning(int spriteId);
diff --git a/src/game.cpp b/src/game.cpp index 530068c..dc3a5ba 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -13,13 +13,13 @@ int Game::emplaceSprite(std::string alias) {
13} 13}
14 14
15void Game::clearSprites() { 15void Game::clearSprites() {
16 sprites_.clear();
17 spriteIds_.clear();
18 spritesByAlias_.clear();
19
20 for (std::unique_ptr<System>& system : systems_) { 16 for (std::unique_ptr<System>& system : systems_) {
21 system->clearSpriteCache(); 17 system->clearSpriteCache();
22 } 18 }
19
20 sprites_.clear();
21 spriteIds_.clear();
22 spritesByAlias_.clear();
23} 23}
24 24
25void Game::loadMap(std::string filename, std::string warpPoint) { 25void Game::loadMap(std::string filename, std::string warpPoint) {