port to contact4
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
This commit is contained in:
parent
6aa90a1852
commit
161f605b20
@ -34,13 +34,13 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
|
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
|
||||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I);
|
||||||
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI);
|
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI);
|
||||||
|
|
||||||
// static store, could be anywhere tho
|
// static store, could be anywhere tho
|
||||||
// construct with fetched dependencies
|
// construct with fetched dependencies
|
||||||
g_flp = std::make_unique<FactorioLogParser>(*conf);
|
g_flp = std::make_unique<FactorioLogParser>(*conf);
|
||||||
g_f = std::make_unique<Factorio>(*conf, *cr, *rmm, *g_flp);
|
g_f = std::make_unique<Factorio>(*conf, *cs, *rmm, *g_flp);
|
||||||
|
|
||||||
// register types
|
// register types
|
||||||
PLUG_PROVIDE_INSTANCE(FactorioLogParser, plugin_name, g_flp.get());
|
PLUG_PROVIDE_INSTANCE(FactorioLogParser, plugin_name, g_flp.get());
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <solanaceae/util/config_model.hpp>
|
#include <solanaceae/util/config_model.hpp>
|
||||||
#include <solanaceae/util/utils.hpp>
|
#include <solanaceae/util/utils.hpp>
|
||||||
|
|
||||||
|
#include <solanaceae/contact/contact_store_i.hpp>
|
||||||
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
|
|
||||||
@ -16,9 +18,9 @@ void Factorio::sendToLinked(const std::string& message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
|
Factorio::Factorio(ConfigModelI& conf, ContactStore4I& cs, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
|
||||||
_conf(conf),
|
_conf(conf),
|
||||||
_cr(cr),
|
_cs(cs),
|
||||||
_rmm(rmm),
|
_rmm(rmm),
|
||||||
_rmm_sr(_rmm.newSubRef(this)),
|
_rmm_sr(_rmm.newSubRef(this)),
|
||||||
_flp(flp),
|
_flp(flp),
|
||||||
@ -31,19 +33,12 @@ Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageMode
|
|||||||
const auto id_vec = hex2bin(contact_id);
|
const auto id_vec = hex2bin(contact_id);
|
||||||
|
|
||||||
// search
|
// search
|
||||||
Contact3Handle h;
|
ContactHandle4 h = _cs.getOneContactByID(ByteSpan{id_vec});
|
||||||
auto view = _cr.view<Contact::Components::ID>();
|
|
||||||
for (const auto c : view) {
|
|
||||||
if (view.get<Contact::Components::ID>(c).data == id_vec) {
|
|
||||||
h = Contact3Handle{_cr, c};
|
|
||||||
std::cout << "Factorio: found contact for link.\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!static_cast<bool>(h)) {
|
if (!static_cast<bool>(h)) {
|
||||||
// not found, create thin contact with just id
|
// not found, create thin contact with just id
|
||||||
h = {_cr, _cr.create()};
|
h = _cs.contactHandle(_cs.registry().create());
|
||||||
h.emplace<Contact::Components::ID>(id_vec);
|
h.emplace<Contact::Components::ID>(id_vec);
|
||||||
|
_cs.throwEventConstruct(h);
|
||||||
std::cout << "Factorio: contact not found, created thin contact from ID. (" << contact_id << ")\n";
|
std::cout << "Factorio: contact not found, created thin contact from ID. (" << contact_id << ")\n";
|
||||||
}
|
}
|
||||||
_linked_contacts.push_back(h);
|
_linked_contacts.push_back(h);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <solanaceae/contact/fwd.hpp>
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
|
||||||
#include "./factorio_log_parser.hpp"
|
#include "./factorio_log_parser.hpp"
|
||||||
@ -11,18 +12,18 @@ struct ConfigModelI;
|
|||||||
|
|
||||||
class Factorio : public RegistryMessageModelEventI, public FactorioLogParserEventI {
|
class Factorio : public RegistryMessageModelEventI, public FactorioLogParserEventI {
|
||||||
ConfigModelI& _conf;
|
ConfigModelI& _conf;
|
||||||
Contact3Registry& _cr;
|
ContactStore4I& _cs;
|
||||||
RegistryMessageModelI& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||||
FactorioLogParser& _flp;
|
FactorioLogParser& _flp;
|
||||||
FactorioLogParser::SubscriptionReference _flp_sr;
|
FactorioLogParser::SubscriptionReference _flp_sr;
|
||||||
|
|
||||||
std::vector<Contact3Handle> _linked_contacts;
|
std::vector<ContactHandle4> _linked_contacts;
|
||||||
|
|
||||||
void sendToLinked(const std::string& message);
|
void sendToLinked(const std::string& message);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp);
|
Factorio(ConfigModelI& conf, ContactStore4I& cs, RegistryMessageModelI& rmm, FactorioLogParser& flp);
|
||||||
virtual ~Factorio(void);
|
virtual ~Factorio(void);
|
||||||
|
|
||||||
protected: // rmm
|
protected: // rmm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user