|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
#include <solanaceae/util/config_model.hpp>
|
|
|
|
|
#include <solanaceae/util/utils.hpp>
|
|
|
|
|
|
|
|
|
|
#include <solanaceae/contact/contact_store_i.hpp>
|
|
|
|
|
|
|
|
|
|
#include <solanaceae/message3/components.hpp>
|
|
|
|
|
#include <solanaceae/contact/components.hpp>
|
|
|
|
|
|
|
|
|
@ -16,8 +18,9 @@ void Factorio::sendToLinked(const std::string& message) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
|
|
|
|
|
_cr(cr),
|
|
|
|
|
Factorio::Factorio(ConfigModelI& conf, ContactStore4I& cs, RegistryMessageModelI& rmm, FactorioLogParser& flp) :
|
|
|
|
|
_conf(conf),
|
|
|
|
|
_cs(cs),
|
|
|
|
|
_rmm(rmm),
|
|
|
|
|
_rmm_sr(_rmm.newSubRef(this)),
|
|
|
|
|
_flp(flp),
|
|
|
|
@ -30,19 +33,12 @@ Factorio::Factorio(ConfigModelI& conf, Contact3Registry& cr, RegistryMessageMode
|
|
|
|
|
const auto id_vec = hex2bin(contact_id);
|
|
|
|
|
|
|
|
|
|
// search
|
|
|
|
|
Contact3Handle h;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ContactHandle4 h = _cs.getOneContactByID(ByteSpan{id_vec});
|
|
|
|
|
if (!static_cast<bool>(h)) {
|
|
|
|
|
// 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);
|
|
|
|
|
_cs.throwEventConstruct(h);
|
|
|
|
|
std::cout << "Factorio: contact not found, created thin contact from ID. (" << contact_id << ")\n";
|
|
|
|
|
}
|
|
|
|
|
_linked_contacts.push_back(h);
|
|
|
|
@ -72,6 +68,10 @@ bool Factorio::onEvent(const Message::Events::MessageConstruct& e) {
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::Join& e) {
|
|
|
|
|
std::cout << "Factorio: event join " << e.player_name << "\n";
|
|
|
|
|
|
|
|
|
|
if (!_conf.get_bool("Factorio", "forward", "join").value_or(true)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string message{e.player_name};
|
|
|
|
|
message += " joined";
|
|
|
|
|
|
|
|
|
@ -83,6 +83,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Join& e) {
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::Leave& e) {
|
|
|
|
|
std::cout << "Factorio: event leave " << e.player_name << " " << e.reason << "\n";
|
|
|
|
|
|
|
|
|
|
if (!_conf.get_bool("Factorio", "forward", "leave").value_or(true)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string message{e.player_name};
|
|
|
|
|
message += " left";
|
|
|
|
|
|
|
|
|
@ -94,6 +98,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Leave& e) {
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::Chat& e) {
|
|
|
|
|
std::cout << "Factorio: event chat " << e.player_name << ": " << e.message << "\n";
|
|
|
|
|
|
|
|
|
|
if (!_conf.get_bool("Factorio", "forward", "chat").value_or(true)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ignore pings
|
|
|
|
|
constexpr std::string_view ping_prefix{"[gps="};
|
|
|
|
|
if (e.message.size() > ping_prefix.size() && e.message.substr(0, ping_prefix.size()) == ping_prefix) {
|
|
|
|
@ -113,6 +121,10 @@ bool Factorio::onEvent(const FactorioLog::Events::Chat& e) {
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::Died& e) {
|
|
|
|
|
std::cout << "Factorio: event died " << e.player_name << ": " << e.reason << "\n";
|
|
|
|
|
|
|
|
|
|
if (!_conf.get_bool("Factorio", "forward", "died").value_or(true)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string message{e.player_name};
|
|
|
|
|
message += " died from ";
|
|
|
|
|
message += e.reason;
|
|
|
|
@ -124,17 +136,31 @@ bool Factorio::onEvent(const FactorioLog::Events::Died& e) {
|
|
|
|
|
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::Evolution& e) {
|
|
|
|
|
std::cout << "Factorio: event evolution " << e.evo << "\n";
|
|
|
|
|
|
|
|
|
|
//if (!_conf.get_bool("Factorio", "forward", "evolution").value_or(true)) {
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::ResearchStarted& e) {
|
|
|
|
|
std::cout << "Factorio: event research started " << e.name << "\n";
|
|
|
|
|
|
|
|
|
|
//if (!_conf.get_bool("Factorio", "forward", "research_started").value_or(true)) {
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::ResearchFinished& e) {
|
|
|
|
|
std::cout << "Factorio: event research finished " << e.name << "\n";
|
|
|
|
|
|
|
|
|
|
if (!_conf.get_bool("Factorio", "forward", "research_finished").value_or(true)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string message{"Research "};
|
|
|
|
|
message += e.name;
|
|
|
|
|
message += " finished!";
|
|
|
|
@ -146,6 +172,11 @@ bool Factorio::onEvent(const FactorioLog::Events::ResearchFinished& e) {
|
|
|
|
|
|
|
|
|
|
bool Factorio::onEvent(const FactorioLog::Events::ResearchCancelled& e) {
|
|
|
|
|
std::cout << "Factorio: event research cancelled " << e.name << "\n";
|
|
|
|
|
|
|
|
|
|
//if (!_conf.get_bool("Factorio", "forward", "research_cancelled").value_or(true)) {
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|