mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 03:29:19 +02:00
partially fix static sounds
This commit is contained in:
@@ -1449,7 +1449,7 @@ event_manager::InitEvents() {
|
|||||||
}
|
}
|
||||||
case tp_Sound: {
|
case tp_Sound: {
|
||||||
// odtworzenie dźwięku
|
// odtworzenie dźwięku
|
||||||
auto *sound = sound_man->create_sound(event->asNodeName);
|
auto *sound = simulation::Sounds.find( event->asNodeName );
|
||||||
if( sound != nullptr )
|
if( sound != nullptr )
|
||||||
event->Params[ 9 ].tsTextSound = sound;
|
event->Params[ 9 ].tsTextSound = sound;
|
||||||
else
|
else
|
||||||
|
|||||||
7
Names.h
7
Names.h
@@ -23,9 +23,8 @@ public:
|
|||||||
// methods
|
// methods
|
||||||
// adds provided item to the collection. returns: true if there's no duplicate with the same name, false otherwise
|
// adds provided item to the collection. returns: true if there's no duplicate with the same name, false otherwise
|
||||||
bool
|
bool
|
||||||
insert( Type_ *Item ) {
|
insert( Type_ *Item, std::string itemname ) {
|
||||||
m_items.emplace_back( Item );
|
m_items.emplace_back( Item );
|
||||||
auto const itemname = Item->name();
|
|
||||||
if( ( true == itemname.empty() ) || ( itemname == "none" ) ) {
|
if( ( true == itemname.empty() ) || ( itemname == "none" ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -38,6 +37,10 @@ public:
|
|||||||
// cell with this name already exists; update mapping to point to the new one, for backward compatibility
|
// cell with this name already exists; update mapping to point to the new one, for backward compatibility
|
||||||
mapping.first->second = itemhandle;
|
mapping.first->second = itemhandle;
|
||||||
return false; }
|
return false; }
|
||||||
|
bool insert (Type_ *Item)
|
||||||
|
{
|
||||||
|
return insert(Item, Item->name());
|
||||||
|
}
|
||||||
// locates item with specified name. returns pointer to the item, or nullptr
|
// locates item with specified name. returns pointer to the item, or nullptr
|
||||||
Type_ *
|
Type_ *
|
||||||
find( std::string const &Name ) {
|
find( std::string const &Name ) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ powergridsource_table Powergrid;
|
|||||||
instance_table Instances;
|
instance_table Instances;
|
||||||
vehicle_table Vehicles;
|
vehicle_table Vehicles;
|
||||||
light_array Lights;
|
light_array Lights;
|
||||||
|
sound_table Sounds;
|
||||||
lua Lua;
|
lua Lua;
|
||||||
|
|
||||||
scene::basic_region *Region { nullptr };
|
scene::basic_region *Region { nullptr };
|
||||||
@@ -465,9 +466,11 @@ state_manager::deserialize_node( cParser &Input, scene::scratch_data &Scratchpad
|
|||||||
simulation::Region->insert_launcher( eventlauncher, Scratchpad );
|
simulation::Region->insert_launcher( eventlauncher, Scratchpad );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( nodedata.type == "sound" ) {
|
else if( nodedata.type == "sound" )
|
||||||
|
{
|
||||||
auto *sound { deserialize_sound( Input, Scratchpad, nodedata ) };
|
auto *sound { deserialize_sound( Input, Scratchpad, nodedata ) };
|
||||||
|
if( false == simulation::Sounds.insert( sound, nodedata.name ) )
|
||||||
|
ErrorLog( "Bad scenario: sound node with duplicate name \"" + nodedata.name + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
|
||||||
simulation::Region->insert_sound( sound, Scratchpad );
|
simulation::Region->insert_sound( sound, Scratchpad );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ private:
|
|||||||
glm::dvec3 transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad );
|
glm::dvec3 transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class sound_table : public basic_table<sound>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
extern state_manager State;
|
extern state_manager State;
|
||||||
extern event_manager Events;
|
extern event_manager Events;
|
||||||
extern memory_table Memory;
|
extern memory_table Memory;
|
||||||
@@ -83,6 +87,7 @@ extern powergridsource_table Powergrid;
|
|||||||
extern instance_table Instances;
|
extern instance_table Instances;
|
||||||
extern vehicle_table Vehicles;
|
extern vehicle_table Vehicles;
|
||||||
extern light_array Lights;
|
extern light_array Lights;
|
||||||
|
extern sound_table Sounds;
|
||||||
extern lua Lua;
|
extern lua Lua;
|
||||||
|
|
||||||
extern scene::basic_region *Region;
|
extern scene::basic_region *Region;
|
||||||
|
|||||||
Reference in New Issue
Block a user