Don't bother trying to standardize event name if there isn't one

This commit is contained in:
Celtic Minstrel 2018-03-24 12:40:42 -04:00
parent 89e0d7e2ae
commit f7cc1842bb

View file

@ -118,22 +118,24 @@ void event_handlers::add_event_handler(const config& cfg, bool is_menu_item)
// name field. Will be moved into the handler. // name field. Will be moved into the handler.
config event_cfg = cfg; config event_cfg = cfg;
// Split the name field... if(!name.empty()) {
std::vector<std::string> standardized_names = utils::split(name); // Split the name field...
std::vector<std::string> standardized_names = utils::split(name);
// ...and standardize each one individually. This ensures they're all valid for by-name lookup. // ...and standardize each one individually. This ensures they're all valid for by-name lookup.
for(std::string& single_name : standardized_names) { for(std::string& single_name : standardized_names) {
if(!utils::might_contain_variables(single_name)) { if(!utils::might_contain_variables(single_name)) {
single_name = standardize_name(single_name); single_name = standardize_name(single_name);
}
} }
assert(!standardized_names.empty());
// Write the new name back to the config.
name = utils::join(standardized_names);
event_cfg["name"] = name;
} }
assert(!standardized_names.empty());
// Write the new name back to the config.
name = utils::join(standardized_names);
event_cfg["name"] = name;
// Create a new handler. // Create a new handler.
// Do note active_ holds the main shared_ptr, and the other three containers // Do note active_ holds the main shared_ptr, and the other three containers
// construct weak_ptrs from the shared one. // construct weak_ptrs from the shared one.