Fix acceptmessages, added exp hooks to luamods

This commit is contained in:
KimLS
2017-06-10 15:12:31 -07:00
parent c83810be36
commit 31d8336b4b
17 changed files with 530 additions and 20 deletions
+17
View File
@@ -25,6 +25,23 @@ void EQ::Net::ConsoleServer::RegisterLogin(ConsoleServerLoginCallback fn)
m_login = fn;
}
EQ::Net::ConsoleServerConnection *EQ::Net::ConsoleServer::FindByAccountName(const std::string &acct_name) {
for (auto &iter : m_connections) {
if (iter.second->UserName().compare(acct_name) == 0) {
return iter.second.get();
}
}
return nullptr;
}
void EQ::Net::ConsoleServer::SendChannelMessage(const ServerChannelMessage_Struct* scm, std::function<void(void)> onTell) {
for (auto &iter : m_connections) {
iter.second->SendChannelMessage(scm, onTell);
}
}
void EQ::Net::ConsoleServer::ConnectionDisconnected(ConsoleServerConnection *c)
{
auto iter = m_connections.find(c->GetUUID());
+2 -1
View File
@@ -25,7 +25,8 @@ namespace EQ
void RegisterCall(const std::string& command, int status_required, const std::string& help_definition, ConsoleServerCallback fn);
void RegisterLogin(ConsoleServerLoginCallback fn);
ConsoleServerConnection *FindByAccountName(const std::string &acct_name);
void SendChannelMessage(const ServerChannelMessage_Struct* scm, std::function<void(void)> onTell);
private:
void ConnectionDisconnected(ConsoleServerConnection *c);
void ProcessCommand(ConsoleServerConnection *c, const std::string& cmd);
+49
View File
@@ -2,6 +2,8 @@
#include "../common/util/uuid.h"
#include "../common/net/packet.h"
#include "../common/eqemu_logsys.h"
#include "../common/servertalk.h"
#include "../common/rulesys.h"
EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent, std::shared_ptr<TCPConnection> connection)
{
@@ -107,6 +109,53 @@ void EQ::Net::ConsoleServerConnection::QueueMessage(const std::string &msg)
}
}
bool EQ::Net::ConsoleServerConnection::SendChannelMessage(const ServerChannelMessage_Struct* scm, std::function<void(void)> onTell) {
if (!m_accept_messages) {
return false;
}
switch (scm->chan_num) {
if (RuleB(Chat, ServerWideAuction)) {
case 4: {
QueueMessage(fmt::format("{0} auctions, '{1}'", scm->from, scm->message));
break;
}
}
if (RuleB(Chat, ServerWideOOC)) {
case 5: {
QueueMessage(fmt::format("{0} says ooc, '{1}'", scm->from, scm->message));
break;
}
}
case 6: {
QueueMessage(fmt::format("{0} BROADCASTS, '{1}'", scm->from, scm->message));
break;
}
case 7: {
QueueMessage(fmt::format("[{0}] tells you, '{1}'", scm->from, scm->message));
if (onTell) {
onTell();
}
break;
}
case 11: {
QueueMessage(fmt::format("{0} GMSAYS, '{1}'", scm->from, scm->message));
break;
}
default: {
return false;
}
}
return true;
}
void EQ::Net::ConsoleServerConnection::OnRead(TCPConnection *c, const unsigned char *data, size_t sz)
{
for (size_t i = 0; i < sz; ++i) {
+3
View File
@@ -4,6 +4,8 @@
#include <memory>
#include <map>
struct ServerChannelMessage_Struct;
namespace EQ
{
namespace Net
@@ -42,6 +44,7 @@ namespace EQ
bool AcceptMessages() const { return m_accept_messages; }
void SetAcceptMessages(bool v) { m_accept_messages = v; }
void QueueMessage(const std::string &msg);
bool SendChannelMessage(const ServerChannelMessage_Struct* scm, std::function<void(void)> onTell);
private:
void OnRead(TCPConnection* c, const unsigned char* data, size_t sz);
void OnDisconnect(TCPConnection* c);