arg:: made added_commands a pointer, to prevent possible initialization order errors

This commit is contained in:
Zeno Rogue 2021-03-31 03:00:51 +02:00
parent 408a49dfe9
commit ceb79290ae
1 changed files with 7 additions and 5 deletions

View File

@ -375,13 +375,14 @@ EX purehookset hooks_config;
EX hookset<int()> hooks_args;
EX map<string, pair<int, reaction_t>> added_commands;
EX map<string, pair<int, reaction_t>> *added_commands;
EX namespace arg {
int read_added_commands() {
if(added_commands.count(args())) {
auto& ac = added_commands[args()];
if(!added_commands) return 1;
if(added_commands->count(args())) {
auto& ac = (*added_commands)[args()];
if(ac.first == 2)
PHASEFROM(2);
if(ac.first == 3)
@ -393,8 +394,9 @@ EX namespace arg {
}
EX int add_at(const string& s, int at, const reaction_t& r) {
if(added_commands.count(s)) throw hr_exception("arg::add conflict");
added_commands[s] = {at, r};
if(!added_commands) added_commands = new map<string, pair<int, reaction_t>> ();
if(added_commands->count(s)) throw hr_exception("arg::add conflict");
(*added_commands)[s] = {at, r};
return 1;
}