From ceb79290aed2698c836cab0fd76f21d42bcc1d62 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 31 Mar 2021 03:00:51 +0200 Subject: [PATCH] arg:: made added_commands a pointer, to prevent possible initialization order errors --- commandline.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commandline.cpp b/commandline.cpp index 04438311..e3c9bc3e 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -375,13 +375,14 @@ EX purehookset hooks_config; EX hookset hooks_args; -EX map> added_commands; +EX map> *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> (); + if(added_commands->count(s)) throw hr_exception("arg::add conflict"); + (*added_commands)[s] = {at, r}; return 1; }