forked from mirror/openmw-tes3mp
Use lowerCamelCase in tes3mp server script function names, part 2
This commit is contained in:
parent
0e2b589cdb
commit
80d16fe1fd
14 changed files with 137 additions and 139 deletions
|
@ -36,12 +36,12 @@ Networking::Networking(RakNet::RakPeerInterface *peer)
|
||||||
running = true;
|
running = true;
|
||||||
exitCode = 0;
|
exitCode = 0;
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnServerInit")>();
|
Script::Call<Script::CallbackIdentity("onServerInit")>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Networking::~Networking()
|
Networking::~Networking()
|
||||||
{
|
{
|
||||||
Script::Call<Script::CallbackIdentity("OnServerExit")>(false);
|
Script::Call<Script::CallbackIdentity("onServerExit")>(false);
|
||||||
|
|
||||||
sThis = 0;
|
sThis = 0;
|
||||||
delete playerController;
|
delete playerController;
|
||||||
|
@ -86,7 +86,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d",
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d",
|
||||||
player->getId());
|
player->getId());
|
||||||
//KickPlayer(player->guid);
|
//kickPlayer(player->guid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
player->setLoadState(Player::LOADED);
|
player->setLoadState(Player::LOADED);
|
||||||
|
|
||||||
static constexpr unsigned int ident = Script::CallbackIdentity("OnPlayerConnect");
|
static constexpr unsigned int ident = Script::CallbackIdentity("onPlayerConnect");
|
||||||
Script::CallBackReturn<ident> result = true;
|
Script::CallBackReturn<ident> result = true;
|
||||||
Script::Call<ident>(result, Players::getPlayer(packet->guid)->getId());
|
Script::Call<ident>(result, Players::getPlayer(packet->guid)->getId());
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
player->GetCell()->getDescription().c_str());
|
player->GetCell()->getDescription().c_str());
|
||||||
|
|
||||||
myPacket->Send(player, true); //send to other clients
|
myPacket->Send(player, true); //send to other clients
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeCell")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeCell")>(player->getId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeAttributes")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeAttributes")>(player->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -191,7 +191,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeSkills")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeSkills")>(player->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -204,7 +204,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeLevel")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeLevel")>(player->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -216,7 +216,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeEquipment")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeEquipment")>(player->getId());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
DEBUG_PRINTF("ID_GAME_INVENTORY\n");
|
DEBUG_PRINTF("ID_GAME_INVENTORY\n");
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeInventory")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerChangeInventory")>(player->getId());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
player->CreatureStats()->mDead = true;
|
player->CreatureStats()->mDead = true;
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerDeath")>(player->getId(), reason, killer->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerDeath")>(player->getId(), reason, killer->getId());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -303,13 +303,12 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
case ID_GAME_RESURRECT:
|
case ID_GAME_RESURRECT:
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("ID_GAME_RESURRECT\n");
|
DEBUG_PRINTF("ID_GAME_RESURRECT\n");
|
||||||
//packetResurrect.Read(player);
|
|
||||||
player->CreatureStats()->mDead = false;
|
player->CreatureStats()->mDead = false;
|
||||||
myPacket->Send(player, true);
|
myPacket->Send(player, true);
|
||||||
playerController->GetPacket(ID_GAME_POS)->RequestData(player->guid);
|
playerController->GetPacket(ID_GAME_POS)->RequestData(player->guid);
|
||||||
playerController->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
|
playerController->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerResurrect")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerResurrect")>(player->getId());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -326,8 +325,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("ID_CHAT_MESSAGE\n");
|
DEBUG_PRINTF("ID_CHAT_MESSAGE\n");
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
|
Script::CallBackReturn<Script::CallbackIdentity("onPlayerSendMessage")> result = true;
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player->getId(), player->ChatMessage()->c_str());
|
Script::Call<Script::CallbackIdentity("onPlayerSendMessage")>(result, player->getId(), player->ChatMessage()->c_str());
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
@ -345,7 +344,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
|
|
||||||
if (player->CharGenStage()->current == player->CharGenStage()->end && player->CharGenStage()->current != 0)
|
if (player->CharGenStage()->current == player->CharGenStage()->end && player->CharGenStage()->current != 0)
|
||||||
{
|
{
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerEndCharGen")>(player->getId());
|
||||||
cout << "RACE: " << player->Npc()->mRace << endl;
|
cout << "RACE: " << player->Npc()->mRace << endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -356,7 +355,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n");
|
DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n");
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
|
|
||||||
Script::Call<Script::CallbackIdentity("OnGUIAction")>(player->getId(), (int)player->guiMessageBox.id,
|
Script::Call<Script::CallbackIdentity("onGuiAction")>(player->getId(), (int)player->guiMessageBox.id,
|
||||||
player->guiMessageBox.data.c_str());
|
player->guiMessageBox.data.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -741,7 +740,7 @@ void Networking::disconnectPlayer(RakNet::RakNetGUID guid)
|
||||||
Player *player = Players::getPlayer(guid);
|
Player *player = Players::getPlayer(guid);
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(player->getId());
|
Script::Call<Script::CallbackIdentity("onPlayerDisconnect")>(player->getId());
|
||||||
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
|
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
|
||||||
Players::deletePlayer(guid);
|
Players::deletePlayer(guid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static void MakePublic(Args &&... args)
|
static void makePublic(Args &&... args)
|
||||||
{ new Public(std::forward<Args>(args)...); }
|
{ new Public(std::forward<Args>(args)...); }
|
||||||
|
|
||||||
static boost::any Call(const std::string &name, const std::vector<boost::any> &args);
|
static boost::any Call(const std::string &name, const std::vector<boost::any> &args);
|
||||||
|
|
|
@ -78,7 +78,7 @@ int TimerAPI::pointer = 0;
|
||||||
std::unordered_map<int, Timer* > TimerAPI::timers;
|
std::unordered_map<int, Timer* > TimerAPI::timers;
|
||||||
|
|
||||||
#if defined(ENABLE_PAWN)
|
#if defined(ENABLE_PAWN)
|
||||||
int TimerAPI::CreateTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const string& def, std::vector<boost::any> args)
|
int TimerAPI::createTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const string& def, std::vector<boost::any> args)
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ int TimerAPI::CreateTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, cons
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_LUA)
|
#if defined(ENABLE_LUA)
|
||||||
int TimerAPI::CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args)
|
int TimerAPI::createTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args)
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ int TimerAPI::CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int TimerAPI::CreateTimer(ScriptFunc callback, long msec, const std::string &def, std::vector<boost::any> args)
|
int TimerAPI::createTimer(ScriptFunc callback, long msec, const std::string &def, std::vector<boost::any> args)
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ int TimerAPI::CreateTimer(ScriptFunc callback, long msec, const std::string &def
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerAPI::FreeTimer(int timerid)
|
void TimerAPI::freeTimer(int timerid)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -165,7 +165,7 @@ void TimerAPI::FreeTimer(int timerid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerAPI::ResetTimer(int timerid, long msec)
|
void TimerAPI::resetTimer(int timerid, long msec)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ void TimerAPI::ResetTimer(int timerid, long msec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerAPI::StartTimer(int timerid)
|
void TimerAPI::startTimer(int timerid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ void TimerAPI::StartTimer(int timerid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerAPI::StopTimer(int timerid)
|
void TimerAPI::stopTimer(int timerid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ void TimerAPI::StopTimer(int timerid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimerAPI::IsEndTimer(int timerid)
|
bool TimerAPI::isEndTimer(int timerid)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
try
|
try
|
||||||
|
|
|
@ -46,17 +46,17 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if defined(ENABLE_PAWN)
|
#if defined(ENABLE_PAWN)
|
||||||
static int CreateTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const std::string& def, std::vector<boost::any> args);
|
static int createTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const std::string& def, std::vector<boost::any> args);
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_LUA)
|
#if defined(ENABLE_LUA)
|
||||||
static int CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args);
|
static int createTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args);
|
||||||
#endif
|
#endif
|
||||||
static int CreateTimer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args);
|
static int createTimer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args);
|
||||||
static void FreeTimer(int timerid);
|
static void freeTimer(int timerid);
|
||||||
static void ResetTimer(int timerid, long msec);
|
static void resetTimer(int timerid, long msec);
|
||||||
static void StartTimer(int timerid);
|
static void startTimer(int timerid);
|
||||||
static void StopTimer(int timerid);
|
static void stopTimer(int timerid);
|
||||||
static bool IsEndTimer(int timerid);
|
static bool isEndTimer(int timerid);
|
||||||
|
|
||||||
static void Terminate();
|
static void Terminate();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <apps/openmw-mp/Networking.hpp>
|
#include <apps/openmw-mp/Networking.hpp>
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept
|
void ScriptFunctions::sendMessage(unsigned short pid, const char *message, bool broadcast) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
|
@ -20,12 +20,12 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
|
||||||
mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::CleanChat(unsigned short pid)
|
void ScriptFunctions::cleanChat(unsigned short pid)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::CleanChat()
|
void ScriptFunctions::cleanChat()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,39 +11,39 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
|
int ScriptFunctions::createTimer(ScriptFunc callback, int msec) noexcept
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept
|
int ScriptFunctions::createTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::StartTimer(int timerId) noexcept
|
void ScriptFunctions::startTimer(int timerId) noexcept
|
||||||
{
|
{
|
||||||
TimerAPI::StartTimer(timerId);
|
TimerAPI::startTimer(timerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::StopTimer(int timerId) noexcept
|
void ScriptFunctions::stopTimer(int timerId) noexcept
|
||||||
{
|
{
|
||||||
TimerAPI::StopTimer(timerId);
|
TimerAPI::stopTimer(timerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::RestartTimer(int timerId, int msec) noexcept
|
void ScriptFunctions::restartTimer(int timerId, int msec) noexcept
|
||||||
{
|
{
|
||||||
TimerAPI::ResetTimer(timerId, msec);
|
TimerAPI::resetTimer(timerId, msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::FreeTimer(int timerId) noexcept
|
void ScriptFunctions::freeTimer(int timerId) noexcept
|
||||||
{
|
{
|
||||||
TimerAPI::FreeTimer(timerId);
|
TimerAPI::freeTimer(timerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptFunctions::IsTimerElapsed(int timerId) noexcept
|
bool ScriptFunctions::isTimerElapsed(int timerId) noexcept
|
||||||
{
|
{
|
||||||
return TimerAPI::IsEndTimer(timerId);
|
return TimerAPI::isEndTimer(timerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,10 @@ struct F_
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<> struct F_<0> { static constexpr LuaFuctionData F{"CreateTimer", LangLua::CreateTimer}; };
|
template<> struct F_<0> { static constexpr LuaFuctionData F{"createTimer", LangLua::createTimer}; };
|
||||||
template<> struct F_<1> { static constexpr LuaFuctionData F{"CreateTimerEx", LangLua::CreateTimerEx}; };
|
template<> struct F_<1> { static constexpr LuaFuctionData F{"createTimerEx", LangLua::createTimerEx}; };
|
||||||
template<> struct F_<2> { static constexpr LuaFuctionData F{"MakePublic", LangLua::MakePublic}; };
|
template<> struct F_<2> { static constexpr LuaFuctionData F{"makePublic", LangLua::makePublic}; };
|
||||||
template<> struct F_<3> { static constexpr LuaFuctionData F{"CallPublic", LangLua::CallPublic}; };
|
template<> struct F_<3> { static constexpr LuaFuctionData F{"callPublic", LangLua::callPublic}; };
|
||||||
|
|
||||||
template<size_t... Indices>
|
template<size_t... Indices>
|
||||||
inline LuaFuctionData *LangLua::functions(indices<Indices...>)
|
inline LuaFuctionData *LangLua::functions(indices<Indices...>)
|
||||||
|
@ -135,7 +135,7 @@ boost::any LangLua::Call(const char *name, const char *argl, int buf, ...)
|
||||||
va_start(vargs, buf);
|
va_start(vargs, buf);
|
||||||
std::vector<boost::any> args;
|
std::vector<boost::any> args;
|
||||||
|
|
||||||
ScriptFunctions::GetArguments(args, vargs, argl);
|
ScriptFunctions::getArguments(args, vargs, argl);
|
||||||
|
|
||||||
return Call(name, argl, args);
|
return Call(name, argl, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,11 @@ public:
|
||||||
LangLua();
|
LangLua();
|
||||||
LangLua(lua_State *lua);
|
LangLua(lua_State *lua);
|
||||||
~LangLua();
|
~LangLua();
|
||||||
static int MakePublic(lua_State *lua) noexcept;
|
static int makePublic(lua_State *lua) noexcept;
|
||||||
static int CallPublic(lua_State *lua);
|
static int callPublic(lua_State *lua);
|
||||||
|
|
||||||
static int CreateTimer(lua_State *lua) noexcept;
|
static int createTimer(lua_State *lua) noexcept;
|
||||||
static int CreateTimerEx(lua_State *lua);
|
static int createTimerEx(lua_State *lua);
|
||||||
|
|
||||||
virtual void LoadProgram(const char *filename) override;
|
virtual void LoadProgram(const char *filename) override;
|
||||||
virtual int FreeProgram() override;
|
virtual int FreeProgram() override;
|
||||||
|
|
|
@ -64,19 +64,19 @@ inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin,
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::MakePublic(lua_State *lua) noexcept
|
int LangLua::makePublic(lua_State *lua) noexcept
|
||||||
{
|
{
|
||||||
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
||||||
const char * name = luabridge::Stack<const char*>::get(lua, 2);
|
const char * name = luabridge::Stack<const char*>::get(lua, 2);
|
||||||
char ret_type = luabridge::Stack<char>::get(lua, 3);
|
char ret_type = luabridge::Stack<char>::get(lua, 3);
|
||||||
const char * def = luabridge::Stack<const char*>::get(lua, 4);
|
const char * def = luabridge::Stack<const char*>::get(lua, 4);
|
||||||
|
|
||||||
Public::MakePublic(callback, lua, name, ret_type, def);
|
Public::makePublic(callback, lua, name, ret_type, def);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::CallPublic(lua_State *lua)
|
int LangLua::callPublic(lua_State *lua)
|
||||||
{
|
{
|
||||||
const char * name = luabridge::Stack<const char*>::get(lua, 1);
|
const char * name = luabridge::Stack<const char*>::get(lua, 1);
|
||||||
|
|
||||||
|
@ -104,18 +104,18 @@ int LangLua::CallPublic(lua_State *lua)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::CreateTimer(lua_State *lua) noexcept
|
int LangLua::createTimer(lua_State *lua) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
const char * callback= luabridge::Stack<const char*>::get(lua, 1);
|
const char * callback= luabridge::Stack<const char*>::get(lua, 1);
|
||||||
int msec = luabridge::Stack<int>::get(lua, 2);
|
int msec = luabridge::Stack<int>::get(lua, 2);
|
||||||
|
|
||||||
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, "", vector<boost::any>());
|
int id = mwmp::TimerAPI::createTimerLua(lua, callback, msec, "", vector<boost::any>());
|
||||||
luabridge::push(lua, id);
|
luabridge::push(lua, id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::CreateTimerEx(lua_State *lua)
|
int LangLua::createTimerEx(lua_State *lua)
|
||||||
{
|
{
|
||||||
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
||||||
int msec = luabridge::Stack<int>::get(lua, 2);
|
int msec = luabridge::Stack<int>::get(lua, 2);
|
||||||
|
@ -176,7 +176,7 @@ int LangLua::CreateTimerEx(lua_State *lua)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, types, args);
|
int id = mwmp::TimerAPI::createTimerLua(lua, callback, msec, types, args);
|
||||||
luabridge::push(lua, id);
|
luabridge::push(lua, id);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
|
@ -172,10 +172,10 @@ static typename enable_if<ScriptFunctions::functions[I].func.ret != 'v' && Scrip
|
||||||
}
|
}
|
||||||
|
|
||||||
template<unsigned int I> struct F_ { static constexpr AMX_NATIVE_INFO F{ScriptFunctions::functions[I].name, wrapper<I>}; };
|
template<unsigned int I> struct F_ { static constexpr AMX_NATIVE_INFO F{ScriptFunctions::functions[I].name, wrapper<I>}; };
|
||||||
template<> struct F_<0> { static constexpr AMX_NATIVE_INFO F{"CreateTimer", LangPAWN::CreateTimer}; };
|
template<> struct F_<0> { static constexpr AMX_NATIVE_INFO F{"createTimer", LangPAWN::createTimer}; };
|
||||||
template<> struct F_<1> { static constexpr AMX_NATIVE_INFO F{"CreateTimerEx", LangPAWN::CreateTimerEx}; };
|
template<> struct F_<1> { static constexpr AMX_NATIVE_INFO F{"createTimerEx", LangPAWN::createTimerEx}; };
|
||||||
template<> struct F_<2> { static constexpr AMX_NATIVE_INFO F{"MakePublic", LangPAWN::MakePublic}; };
|
template<> struct F_<2> { static constexpr AMX_NATIVE_INFO F{"makePublic", LangPAWN::makePublic}; };
|
||||||
template<> struct F_<3> { static constexpr AMX_NATIVE_INFO F{"CallPublic", LangPAWN::CallPublic}; };
|
template<> struct F_<3> { static constexpr AMX_NATIVE_INFO F{"callPublic", LangPAWN::callPublic}; };
|
||||||
|
|
||||||
void LangPAWN::LoadProgram(const char *filename)
|
void LangPAWN::LoadProgram(const char *filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,10 +30,10 @@ public:
|
||||||
LangPAWN();
|
LangPAWN();
|
||||||
LangPAWN(AMX *amx);
|
LangPAWN(AMX *amx);
|
||||||
~LangPAWN();
|
~LangPAWN();
|
||||||
static cell MakePublic(AMX *amx, const cell *params) noexcept;
|
static cell makePublic(AMX *amx, const cell *params) noexcept;
|
||||||
static cell CallPublic(AMX *amx, const cell *params) noexcept;
|
static cell callPublic(AMX *amx, const cell *params) noexcept;
|
||||||
static cell CreateTimer(AMX *amx, const cell *params) noexcept;
|
static cell createTimer(AMX *amx, const cell *params) noexcept;
|
||||||
static cell CreateTimerEx(AMX *amx, const cell *params) noexcept;
|
static cell createTimerEx(AMX *amx, const cell *params) noexcept;
|
||||||
|
|
||||||
virtual void LoadProgram(const char *filename) override;
|
virtual void LoadProgram(const char *filename) override;
|
||||||
virtual int FreeProgram() override;
|
virtual int FreeProgram() override;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
cell LangPAWN::MakePublic(AMX *amx, const cell *params) noexcept
|
cell LangPAWN::makePublic(AMX *amx, const cell *params) noexcept
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
cell* source;
|
cell* source;
|
||||||
|
@ -39,12 +39,12 @@ cell LangPAWN::MakePublic(AMX *amx, const cell *params) noexcept
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Public::MakePublic(&real[0], amx, &name[0], ret_type, &def[0]);
|
Public::makePublic(&real[0], amx, &name[0], ret_type, &def[0]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell LangPAWN::CallPublic(AMX *amx, const cell *params) noexcept
|
cell LangPAWN::callPublic(AMX *amx, const cell *params) noexcept
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
cell* source;
|
cell* source;
|
||||||
|
@ -143,12 +143,12 @@ cell LangPAWN::CallPublic(AMX *amx, const cell *params) noexcept
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell LangPAWN::CreateTimer(AMX *amx, const cell *params) noexcept
|
cell LangPAWN::createTimer(AMX *amx, const cell *params) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cell LangPAWN::CreateTimerEx(AMX *amx, const cell *params) noexcept
|
cell LangPAWN::createTimerEx(AMX *amx, const cell *params) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ constexpr ScriptCallbackData ScriptFunctions::callbacks[];
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void ScriptFunctions::GetArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def)
|
void ScriptFunctions::getArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def)
|
||||||
{
|
{
|
||||||
params.reserve(def.length());
|
params.reserve(def.length());
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ void ScriptFunctions::GetArguments(std::vector<boost::any> ¶ms, va_list args
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
|
void ScriptFunctions::makePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
|
||||||
{
|
{
|
||||||
Public::MakePublic(_public, name, ret_type, def);
|
Public::makePublic(_public, name, ret_type, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::any ScriptFunctions::CallPublic(const char *name, ...) noexcept
|
boost::any ScriptFunctions::callPublic(const char *name, ...) noexcept
|
||||||
{
|
{
|
||||||
vector<boost::any> params;
|
vector<boost::any> params;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ boost::any ScriptFunctions::CallPublic(const char *name, ...) noexcept
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, name);
|
va_start(args, name);
|
||||||
GetArguments(params, args, def);
|
getArguments(params, args, def);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
return Public::Call(name, params);
|
return Public::Call(name, params);
|
||||||
|
@ -109,30 +109,30 @@ boost::any ScriptFunctions::CallPublic(const char *name, ...) noexcept
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::StopServer(int code) noexcept
|
void ScriptFunctions::stopServer(int code) noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::getPtr()->stopServer(code);
|
mwmp::Networking::getPtr()->stopServer(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::Kick(unsigned short pid) noexcept
|
void ScriptFunctions::kick(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
mwmp::Networking::getPtr()->kickPlayer(player->guid);
|
mwmp::Networking::getPtr()->kickPlayer(player->guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ScriptFunctions::GetServerVersion() noexcept
|
const char *ScriptFunctions::getServerVersion() noexcept
|
||||||
{
|
{
|
||||||
return TES3MP_VERSION;
|
return TES3MP_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ScriptFunctions::GetProtocolVersion() noexcept
|
const char *ScriptFunctions::getProtocolVersion() noexcept
|
||||||
{
|
{
|
||||||
static string version = to_string(TES3MP_PROTO_VERSION);
|
static string version = to_string(TES3MP_PROTO_VERSION);
|
||||||
return version.c_str();
|
return version.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptFunctions::GetAvgPing(unsigned short pid) noexcept
|
int ScriptFunctions::getAvgPing(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,-1);
|
GET_PLAYER(pid, player,-1);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
pl = Players::getPlayer(pid); \
|
pl = Players::getPlayer(pid); \
|
||||||
if (player == 0) {\
|
if (player == 0) {\
|
||||||
fprintf(stderr, "%s: Player with pid \'%d\' not found\n", __PRETTY_FUNCTION__, pid);\
|
fprintf(stderr, "%s: Player with pid \'%d\' not found\n", __PRETTY_FUNCTION__, pid);\
|
||||||
/*ScriptFunctions::StopServer(1);*/ \
|
/*ScriptFunctions::stopServer(1);*/ \
|
||||||
return retvalue;\
|
return retvalue;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,16 +31,16 @@ class ScriptFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void GetArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def);
|
static void getArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def);
|
||||||
|
|
||||||
static void StopServer(int code) noexcept;
|
static void stopServer(int code) noexcept;
|
||||||
|
|
||||||
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
|
static void makePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
|
||||||
static boost::any CallPublic(const char *name, ...) noexcept;
|
static boost::any callPublic(const char *name, ...) noexcept;
|
||||||
|
|
||||||
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
|
static void sendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
|
||||||
static void CleanChat(unsigned short pid);
|
static void cleanChat(unsigned short pid);
|
||||||
static void CleanChat();
|
static void cleanChat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create timer
|
* \brief Create timer
|
||||||
|
@ -48,41 +48,40 @@ public:
|
||||||
* \param msec
|
* \param msec
|
||||||
* \return return timer id
|
* \return return timer id
|
||||||
*/
|
*/
|
||||||
static int CreateTimer(ScriptFunc callback, int msec) noexcept;
|
static int createTimer(ScriptFunc callback, int msec) noexcept;
|
||||||
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept;
|
static int createTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept;
|
||||||
|
|
||||||
static void StartTimer(int timerId) noexcept;
|
static void startTimer(int timerId) noexcept;
|
||||||
static void StopTimer(int timerId) noexcept;
|
static void stopTimer(int timerId) noexcept;
|
||||||
static void RestartTimer(int timerId, int msec) noexcept;
|
static void restartTimer(int timerId, int msec) noexcept;
|
||||||
static void FreeTimer(int timerId) noexcept;
|
static void freeTimer(int timerId) noexcept;
|
||||||
static bool IsTimerElapsed(int timerId) noexcept;
|
static bool isTimerElapsed(int timerId) noexcept;
|
||||||
|
|
||||||
static void Kick(unsigned short pid) noexcept;
|
static void kick(unsigned short pid) noexcept;
|
||||||
static const char *GetServerVersion() noexcept;
|
static const char *getServerVersion() noexcept;
|
||||||
static const char *GetProtocolVersion() noexcept;
|
static const char *getProtocolVersion() noexcept;
|
||||||
static int GetAvgPing(unsigned short pid) noexcept;
|
static int getAvgPing(unsigned short pid) noexcept;
|
||||||
|
|
||||||
static constexpr ScriptFunctionData functions[]{
|
static constexpr ScriptFunctionData functions[]{
|
||||||
{"CreateTimer", ScriptFunctions::CreateTimer},
|
{"createTimer", ScriptFunctions::createTimer},
|
||||||
{"CreateTimerEx", reinterpret_cast<Function<void>>(ScriptFunctions::CreateTimerEx)},
|
{"createTimerEx", reinterpret_cast<Function<void>>(ScriptFunctions::createTimerEx)},
|
||||||
{"MakePublic", ScriptFunctions::MakePublic},
|
{"makePublic", ScriptFunctions::makePublic},
|
||||||
{"CallPublic", reinterpret_cast<Function<void>>(ScriptFunctions::CallPublic)},
|
{"callPublic", reinterpret_cast<Function<void>>(ScriptFunctions::callPublic)},
|
||||||
|
|
||||||
|
|
||||||
{"StartTimer", ScriptFunctions::StartTimer},
|
{"startTimer", ScriptFunctions::startTimer},
|
||||||
{"StopTimer", ScriptFunctions::StopTimer},
|
{"stopTimer", ScriptFunctions::stopTimer},
|
||||||
{"RestartTimer", ScriptFunctions::RestartTimer},
|
{"restartTimer", ScriptFunctions::restartTimer},
|
||||||
{"FreeTimer", ScriptFunctions::FreeTimer},
|
{"freeTimer", ScriptFunctions::freeTimer},
|
||||||
{"IsTimerElapsed", ScriptFunctions::IsTimerElapsed},
|
{"isTimerElapsed", ScriptFunctions::isTimerElapsed},
|
||||||
|
|
||||||
{"StopServer", ScriptFunctions::StopServer},
|
{"stopServer", ScriptFunctions::stopServer},
|
||||||
|
|
||||||
// {"Cast", ScriptFunctions::Cast},
|
{"sendMessage", ScriptFunctions::sendMessage},
|
||||||
{"SendMessage", ScriptFunctions::SendMessage},
|
{"kick", ScriptFunctions::kick},
|
||||||
{"Kick", ScriptFunctions::Kick},
|
{"getServerVersion", ScriptFunctions::getServerVersion},
|
||||||
{"GetServerVersion", ScriptFunctions::GetServerVersion},
|
{"getProtocolVersion", ScriptFunctions::getProtocolVersion},
|
||||||
{"GetProtocolVersion", ScriptFunctions::GetProtocolVersion},
|
{"getAvgPing", ScriptFunctions::getAvgPing},
|
||||||
{"GetAvgPing", ScriptFunctions::GetAvgPing},
|
|
||||||
|
|
||||||
TRANSLOCATIONFUNCTIONS,
|
TRANSLOCATIONFUNCTIONS,
|
||||||
STATSFUNCTIONS,
|
STATSFUNCTIONS,
|
||||||
|
@ -96,21 +95,21 @@ public:
|
||||||
|
|
||||||
static constexpr ScriptCallbackData callbacks[]{
|
static constexpr ScriptCallbackData callbacks[]{
|
||||||
{"Main", Function<int, int, int>()},
|
{"Main", Function<int, int, int>()},
|
||||||
{"OnServerInit", Function<void>()},
|
{"onServerInit", Function<void>()},
|
||||||
{"OnServerExit", Function<void, bool>()},
|
{"onServerExit", Function<void, bool>()},
|
||||||
{"OnPlayerConnect", Function<bool, unsigned short>()},
|
{"onPlayerConnect", Function<bool, unsigned short>()},
|
||||||
{"OnPlayerDisconnect", Function<void, unsigned short>()},
|
{"onPlayerDisconnect", Function<void, unsigned short>()},
|
||||||
{"OnPlayerDeath", Function<void, unsigned short, short, unsigned short>()},
|
{"onPlayerDeath", Function<void, unsigned short, short, unsigned short>()},
|
||||||
{"OnPlayerResurrect", Function<void, unsigned short>()},
|
{"onPlayerResurrect", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeCell", Function<void, unsigned short>()},
|
{"onPlayerChangeCell", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeAttributes", Function<void, unsigned short>()},
|
{"onPlayerChangeAttributes", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeSkills", Function<void, unsigned short>()},
|
{"onPlayerChangeSkills", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeLevel", Function<void, unsigned short>()},
|
{"onPlayerChangeLevel", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeEquipment", Function<void, unsigned short>()},
|
{"onPlayerChangeEquipment", Function<void, unsigned short>()},
|
||||||
{"OnPlayerChangeInventory", Function<void, unsigned short>()},
|
{"onPlayerChangeInventory", Function<void, unsigned short>()},
|
||||||
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
{"onPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
||||||
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
{"onPlayerEndCharGen", Function<void, unsigned short>()},
|
||||||
{"OnGUIAction", Function<void, unsigned short, int, const char*>()}
|
{"onGuiAction", Function<void, unsigned short, int, const char*>()}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue