diff --git a/cpp/game_main.cpp b/cpp/game_main.cpp index fbeb94439a..159be22187 100644 --- a/cpp/game_main.cpp +++ b/cpp/game_main.cpp @@ -167,6 +167,11 @@ GameMain::GameMain(Engine *engine) foundation_size.ne, foundation_size.se ); + log::msg(" sound_creation0: %5d, sound_creation1: %5d, sound_dying: %5d", + building.sound_creation0, + building.sound_creation1, + building.sound_dying + ); TestBuilding *newbuilding = new TestBuilding{ this->assetmanager.get_texture(tex_fname), @@ -386,18 +391,17 @@ bool GameMain::on_input(SDL_Event *e) { if (obj != nullptr) { obj->remove(); this->placed_buildings.erase(obj); + this->available_sounds[obj->sound_id_destruction].play(); delete obj; - // TODO: play destruction sound - //int rand = util::random_range(0, obj->destruction_snd_count + 1); - //sounds[rand].play() } else { TestBuilding *newbuilding = this->available_buildings[this->editor_current_building]; int coloring = util::random_range(1, 8 + 1); TerrainObject *newobj = new TerrainObject( newbuilding->texture, newbuilding->foundation_size, - coloring + coloring, + newbuilding->sound_id_destruction ); // try to place the obj, it knows best whether it will fit. diff --git a/cpp/terrain_object.cpp b/cpp/terrain_object.cpp index a637a98062..a22a885c0d 100644 --- a/cpp/terrain_object.cpp +++ b/cpp/terrain_object.cpp @@ -17,11 +17,13 @@ namespace openage { TerrainObject::TerrainObject(Texture *tex, coord::tile_delta foundation_size, - unsigned player) { - this->placed = false; - this->texture = tex; - this->size = foundation_size; - this->player = player; + unsigned player, int sound_id_destruction) { + + this->placed = false; + this->texture = tex; + this->size = foundation_size; + this->player = player; + this->sound_id_destruction = sound_id_destruction; this->occupied_chunk_count = 0; } diff --git a/cpp/terrain_object.h b/cpp/terrain_object.h index 8c8e51acc5..993c85d5d6 100644 --- a/cpp/terrain_object.h +++ b/cpp/terrain_object.h @@ -29,13 +29,15 @@ terrain object class represents one immobile object on the map (building, trees, */ class TerrainObject { public: - TerrainObject(Texture *tex, coord::tile_delta foundation_size, unsigned player); + TerrainObject(Texture *tex, coord::tile_delta foundation_size, unsigned player, int sound_id_destruction); ~TerrainObject(); coord::tile start_pos; coord::phys3 draw_pos; coord::tile end_pos; + int sound_id_destruction; + /** * tests whether this terrain object will fit at the given position. *