diff --git a/apps/openmw-mp/Script/Functions/Chat.cpp b/apps/openmw-mp/Script/Functions/Chat.cpp index a94e1248e..0b72a173c 100644 --- a/apps/openmw-mp/Script/Functions/Chat.cpp +++ b/apps/openmw-mp/Script/Functions/Chat.cpp @@ -1,8 +1,12 @@ +#include "Chat.hpp" + +#include +#include + #include #include -#include -void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept +void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -20,7 +24,7 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool packet->Send(true); } -void ScriptFunctions::CleanChatForPid(unsigned short pid) +void ChatFunctions::CleanChatForPid(unsigned short pid) { Player *player; GET_PLAYER(pid, player,); @@ -33,7 +37,7 @@ void ScriptFunctions::CleanChatForPid(unsigned short pid) packet->Send(false); } -void ScriptFunctions::CleanChat() +void ChatFunctions::CleanChat() { for (auto player : *Players::getPlayers()) { diff --git a/apps/openmw-mp/Script/Functions/Chat.hpp b/apps/openmw-mp/Script/Functions/Chat.hpp new file mode 100644 index 000000000..2424aa5f8 --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Chat.hpp @@ -0,0 +1,44 @@ +#ifndef OPENMW_CHATAPI_HPP +#define OPENMW_CHATAPI_HPP + +#include "../Types.hpp" + +#define CHATAPI \ + {"SendMessage", ChatFunctions::SendMessage},\ + {"CleanChatForPid", ChatFunctions::CleanChat},\ + {"CleanChat", ChatFunctions::CleanChatForPid} + +class ChatFunctions +{ +public: + + /** + * \brief Send a message to a certain player. + * + * \param pid The player ID. + * \param message The contents of the message. + * \param sendToOtherPlayers Whether this packet should be sent to players other than the + * player attached to the packet (false by default). + * \param sendToAttachedPlayer Whether the packet should be sent to the player attached + * to the packet (true by default). + * \return void + */ + static void SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept; + + /** + * \brief Remove all messages from chat for a certain player. + * + * \param pid The player ID. + * \return void + */ + static void CleanChatForPid(unsigned short pid); + + /** + * \brief Remove all messages from chat for everyone on the server. + * + * \return void + */ + static void CleanChat(); +}; + +#endif //OPENMW_CHATAPI_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 1a3780adb..e494cf7b5 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 24.01.16. -// - #ifndef SCRIPTFUNCTIONS_HPP #define SCRIPTFUNCTIONS_HPP @@ -9,6 +5,7 @@ #include