Skip to content

Commit 117e40d

Browse files
committed
use sr
1 parent 050c7f3 commit 117e40d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/factorio.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ void Factorio::sendToLinked(const std::string& message) {
1919
Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
2020
_cr(cr),
2121
_rmm(rmm),
22-
_flp(flp)
22+
_rmm_sr(_rmm.newSubRef(this)),
23+
_flp(flp),
24+
_flp_sr(_flp.newSubRef(this))
2325
{
2426
// config
2527
for (const auto&& [contact_id, enabled] : conf.entries_bool("Factorio", "link_to_contact")) {
@@ -46,16 +48,18 @@ Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageMode
4648
_linked_contacts.push_back(h);
4749
}
4850

49-
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
50-
51-
_flp.subscribe(this, FactorioLogParser_Event::join);
52-
_flp.subscribe(this, FactorioLogParser_Event::leave);
53-
_flp.subscribe(this, FactorioLogParser_Event::chat);
54-
_flp.subscribe(this, FactorioLogParser_Event::died);
55-
_flp.subscribe(this, FactorioLogParser_Event::evolution);
56-
_flp.subscribe(this, FactorioLogParser_Event::research_started);
57-
_flp.subscribe(this, FactorioLogParser_Event::research_finished);
58-
_flp.subscribe(this, FactorioLogParser_Event::research_cancelled);
51+
_rmm_sr.subscribe(RegistryMessageModel_Event::message_construct);
52+
53+
_flp_sr
54+
.subscribe(FactorioLogParser_Event::join)
55+
.subscribe(FactorioLogParser_Event::leave)
56+
.subscribe(FactorioLogParser_Event::chat)
57+
.subscribe(FactorioLogParser_Event::died)
58+
.subscribe(FactorioLogParser_Event::evolution)
59+
.subscribe(FactorioLogParser_Event::research_started)
60+
.subscribe(FactorioLogParser_Event::research_finished)
61+
.subscribe(FactorioLogParser_Event::research_cancelled)
62+
;
5963
}
6064

6165
Factorio::~Factorio(void) {

src/factorio.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ struct ConfigModelI;
1212
class Factorio : public RegistryMessageModelEventI, public FactorioLogParserEventI {
1313
Contact3Registry& _cr;
1414
RegistryMessageModelI& _rmm;
15+
RegistryMessageModelI::SubscriptionReference _rmm_sr;
1516
FactorioLogParser& _flp;
17+
FactorioLogParser::SubscriptionReference _flp_sr;
1618

1719
std::vector<Contact3Handle> _linked_contacts;
1820

0 commit comments

Comments
 (0)