forked from mirror/openmw-tes3mp
Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
43340fd033 |
31 changed files with 276 additions and 429 deletions
|
@ -585,8 +585,8 @@ void Networking::InitQuery(std::string queryAddr, unsigned short queryPort)
|
||||||
|
|
||||||
void Networking::postInit()
|
void Networking::postInit()
|
||||||
{
|
{
|
||||||
Script::Call<Script::CallbackIdentity("OnRequestDataFileList")>();
|
|
||||||
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
|
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
|
||||||
|
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>();
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketPreInit::PluginContainer &Networking::getSamples()
|
PacketPreInit::PluginContainer &Networking::getSamples()
|
||||||
|
|
|
@ -537,7 +537,7 @@ void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
|
||||||
|
|
||||||
void ActorFunctions::CopyLastActorListToStore() noexcept
|
void ActorFunctions::CopyLastActorListToStore() noexcept
|
||||||
{
|
{
|
||||||
CopyReceivedActorListToStore();
|
CopyLastActorListToStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept
|
unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept
|
||||||
|
|
|
@ -1,12 +1,38 @@
|
||||||
#include "Miscellaneous.hpp"
|
#include "Miscellaneous.hpp"
|
||||||
|
|
||||||
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
|
||||||
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||||
#include <apps/openmw-mp/Networking.hpp>
|
#include <apps/openmw-mp/Networking.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static std::string tempFilename;
|
||||||
|
|
||||||
|
bool MiscellaneousFunctions::DoesFileExist(const char *filePath) noexcept
|
||||||
|
{
|
||||||
|
return boost::filesystem::exists(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
|
||||||
|
{
|
||||||
|
if (!boost::filesystem::exists(folderPath)) return "invalid";
|
||||||
|
|
||||||
|
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
||||||
|
|
||||||
|
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
|
||||||
|
{
|
||||||
|
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
|
||||||
|
{
|
||||||
|
tempFilename = itr->path().filename().string();
|
||||||
|
return tempFilename.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "invalid";
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept
|
unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept
|
||||||
{
|
{
|
||||||
return Players::getLastPlayerId();
|
return Players::getLastPlayerId();
|
||||||
|
@ -21,3 +47,13 @@ void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::getPtr()->setCurrentMpNum(mpNum);
|
mwmp::Networking::getPtr()->setCurrentMpNum(mpNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MiscellaneousFunctions::LogAppend(unsigned short level, const char *message) noexcept
|
||||||
|
{
|
||||||
|
LOG_APPEND(level, "[Script]: %s", message);
|
||||||
|
}
|
||||||
|
|
|
@ -4,15 +4,42 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define MISCELLANEOUSAPI \
|
#define MISCELLANEOUSAPI \
|
||||||
|
{"DoesFileExist", MiscellaneousFunctions::DoesFileExist},\
|
||||||
|
{"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\
|
||||||
|
\
|
||||||
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
|
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
|
||||||
\
|
\
|
||||||
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
|
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
|
||||||
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum}
|
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\
|
||||||
|
\
|
||||||
|
{"LogMessage", MiscellaneousFunctions::LogMessage},\
|
||||||
|
{"LogAppend", MiscellaneousFunctions::LogAppend}
|
||||||
|
|
||||||
class MiscellaneousFunctions
|
class MiscellaneousFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check whether a certain file exists.
|
||||||
|
*
|
||||||
|
* This will be a case sensitive check on case sensitive filesystems.
|
||||||
|
*
|
||||||
|
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
|
||||||
|
*
|
||||||
|
* \return Whether the file exists or not.
|
||||||
|
*/
|
||||||
|
static bool DoesFileExist(const char *filePath) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the first filename in a folder that has a case insensitive match with the filename
|
||||||
|
* argument.
|
||||||
|
*
|
||||||
|
* This is used to retain case insensitivity when opening data files on Linux.
|
||||||
|
*
|
||||||
|
* \return The filename that matches.
|
||||||
|
*/
|
||||||
|
static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the last player ID currently connected to the server.
|
* \brief Get the last player ID currently connected to the server.
|
||||||
*
|
*
|
||||||
|
@ -48,6 +75,30 @@ public:
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
static void SetCurrentMpNum(int mpNum) noexcept;
|
static void SetCurrentMpNum(int mpNum) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Write a log message with its own timestamp.
|
||||||
|
*
|
||||||
|
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
|
||||||
|
*
|
||||||
|
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
|
||||||
|
* 3 for LOG_ERROR, 4 for LOG_FATAL).
|
||||||
|
* \param message The message logged.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void LogMessage(unsigned short level, const char *message) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Write a log message without its own timestamp.
|
||||||
|
*
|
||||||
|
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
|
||||||
|
*
|
||||||
|
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
|
||||||
|
* 3 for LOG_ERROR, 4 for LOG_FATAL).
|
||||||
|
* \param message The message logged.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void LogAppend(unsigned short level, const char *message) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_MISCELLANEOUSAPI_HPP
|
#endif //OPENMW_MISCELLANEOUSAPI_HPP
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "Server.hpp"
|
#include "Server.hpp"
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
#include <components/openmw-mp/Version.hpp>
|
#include <components/openmw-mp/Version.hpp>
|
||||||
|
@ -10,18 +9,6 @@
|
||||||
#include <apps/openmw-mp/MasterClient.hpp>
|
#include <apps/openmw-mp/MasterClient.hpp>
|
||||||
#include <Script/Script.hpp>
|
#include <Script/Script.hpp>
|
||||||
|
|
||||||
static std::string tempFilename;
|
|
||||||
static std::chrono::high_resolution_clock::time_point startupTime = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
void ServerFunctions::LogMessage(unsigned short level, const char *message) noexcept
|
|
||||||
{
|
|
||||||
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerFunctions::LogAppend(unsigned short level, const char *message) noexcept
|
|
||||||
{
|
|
||||||
LOG_APPEND(level, "[Script]: %s", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerFunctions::StopServer(int code) noexcept
|
void ServerFunctions::StopServer(int code) noexcept
|
||||||
{
|
{
|
||||||
|
@ -48,40 +35,6 @@ void ServerFunctions::UnbanAddress(const char *ipAddress) noexcept
|
||||||
mwmp::Networking::getPtr()->unbanAddress(ipAddress);
|
mwmp::Networking::getPtr()->unbanAddress(ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerFunctions::DoesFilePathExist(const char *filePath) noexcept
|
|
||||||
{
|
|
||||||
return boost::filesystem::exists(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ServerFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
|
|
||||||
{
|
|
||||||
if (!boost::filesystem::exists(folderPath)) return "invalid";
|
|
||||||
|
|
||||||
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
|
|
||||||
|
|
||||||
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
|
|
||||||
{
|
|
||||||
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
|
|
||||||
{
|
|
||||||
tempFilename = itr->path().filename().string();
|
|
||||||
return tempFilename.c_str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* ServerFunctions::GetDataPath() noexcept
|
|
||||||
{
|
|
||||||
return Script::GetModDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int ServerFunctions::GetMillisecondsSinceServerStart() noexcept
|
|
||||||
{
|
|
||||||
std::chrono::high_resolution_clock::time_point currentTime = std::chrono::high_resolution_clock::now();
|
|
||||||
std::chrono::milliseconds milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startupTime);
|
|
||||||
return milliseconds.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ServerFunctions::GetOperatingSystemType() noexcept
|
const char *ServerFunctions::GetOperatingSystemType() noexcept
|
||||||
{
|
{
|
||||||
return Utils::getOperatingSystemType().c_str();
|
return Utils::getOperatingSystemType().c_str();
|
||||||
|
@ -184,46 +137,34 @@ void ServerFunctions::SetRuleValue(const char *key, double value) noexcept
|
||||||
mc->SetRuleValue(key, value);
|
mc->SetRuleValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerFunctions::AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept
|
void ServerFunctions::AddPluginHash(const char *pluginName, const char *hashStr) noexcept
|
||||||
{
|
{
|
||||||
auto &samples = mwmp::Networking::getPtr()->getSamples();
|
auto &samples = mwmp::Networking::getPtr()->getSamples();
|
||||||
auto it = std::find_if(samples.begin(), samples.end(), [&dataFilename](mwmp::PacketPreInit::PluginPair &item) {
|
auto it = std::find_if(samples.begin(), samples.end(), [&pluginName](mwmp::PacketPreInit::PluginPair &item) {
|
||||||
return item.first == dataFilename;
|
return item.first == pluginName;
|
||||||
});
|
});
|
||||||
if (it != samples.end())
|
if (it != samples.end())
|
||||||
it->second.push_back((unsigned) std::stoul(checksumString));
|
it->second.push_back((unsigned) std::stoul(hashStr));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mwmp::PacketPreInit::HashList checksumList;
|
mwmp::PacketPreInit::HashList hashList;
|
||||||
|
|
||||||
unsigned checksum = 0;
|
unsigned hash = 0;
|
||||||
|
|
||||||
if (strlen(checksumString) != 0)
|
if (strlen(hashStr) != 0)
|
||||||
{
|
{
|
||||||
checksum = (unsigned) std::stoul(checksumString);
|
hash = (unsigned) std::stoul(hashStr);
|
||||||
checksumList.push_back(checksum);
|
hashList.push_back(hash);
|
||||||
}
|
}
|
||||||
samples.emplace_back(dataFilename, checksumList);
|
samples.emplace_back(pluginName, hashList);
|
||||||
|
|
||||||
auto mclient = mwmp::Networking::getPtr()->getMasterClient();
|
auto mclient = mwmp::Networking::getPtr()->getMasterClient();
|
||||||
if (mclient)
|
if (mclient)
|
||||||
mclient->PushPlugin({dataFilename, checksum});
|
mclient->PushPlugin({pluginName, hash});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All methods below are deprecated versions of methods from above
|
|
||||||
|
|
||||||
bool ServerFunctions::DoesFileExist(const char *filePath) noexcept
|
|
||||||
{
|
|
||||||
return DoesFilePathExist(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* ServerFunctions::GetModDir() noexcept
|
const char* ServerFunctions::GetModDir() noexcept
|
||||||
{
|
{
|
||||||
return GetDataPath();
|
return Script::GetModDir();
|
||||||
}
|
|
||||||
|
|
||||||
void ServerFunctions::AddPluginHash(const char *pluginName, const char *checksumString) noexcept
|
|
||||||
{
|
|
||||||
AddDataFileRequirement(pluginName, checksumString);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,73 +4,38 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define SERVERAPI \
|
#define SERVERAPI \
|
||||||
{"LogMessage", ServerFunctions::LogMessage},\
|
{"StopServer", ServerFunctions::StopServer},\
|
||||||
{"LogAppend", ServerFunctions::LogAppend},\
|
|
||||||
\
|
\
|
||||||
{"StopServer", ServerFunctions::StopServer},\
|
{"Kick", ServerFunctions::Kick},\
|
||||||
|
{"BanAddress", ServerFunctions::BanAddress},\
|
||||||
|
{"UnbanAddress", ServerFunctions::UnbanAddress},\
|
||||||
\
|
\
|
||||||
{"Kick", ServerFunctions::Kick},\
|
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
|
||||||
{"BanAddress", ServerFunctions::BanAddress},\
|
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
|
||||||
{"UnbanAddress", ServerFunctions::UnbanAddress},\
|
{"GetServerVersion", ServerFunctions::GetServerVersion},\
|
||||||
|
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
|
||||||
|
{"GetAvgPing", ServerFunctions::GetAvgPing},\
|
||||||
|
{"GetIP", ServerFunctions::GetIP},\
|
||||||
|
{"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\
|
||||||
|
{"GetPort", ServerFunctions::GetPort},\
|
||||||
|
{"HasPassword", ServerFunctions::HasPassword},\
|
||||||
|
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
|
||||||
|
{"GetScriptErrorIgnoringState", ServerFunctions::GetScriptErrorIgnoringState},\
|
||||||
\
|
\
|
||||||
{"DoesFilePathExist", ServerFunctions::DoesFilePathExist},\
|
{"SetGameMode", ServerFunctions::SetGameMode},\
|
||||||
{"GetCaseInsensitiveFilename", ServerFunctions::GetCaseInsensitiveFilename},\
|
{"SetHostname", ServerFunctions::SetHostname},\
|
||||||
{"GetDataPath", ServerFunctions::GetDataPath},\
|
{"SetServerPassword", ServerFunctions::SetServerPassword},\
|
||||||
{"GetMillisecondsSinceServerStart", ServerFunctions::GetMillisecondsSinceServerStart},\
|
{"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
|
||||||
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
|
{"SetScriptErrorIgnoringState", ServerFunctions::SetScriptErrorIgnoringState},\
|
||||||
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
|
{"SetRuleString", ServerFunctions::SetRuleString},\
|
||||||
{"GetServerVersion", ServerFunctions::GetServerVersion},\
|
{"SetRuleValue", ServerFunctions::SetRuleValue},\
|
||||||
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
|
{"AddPluginHash", ServerFunctions::AddPluginHash},\
|
||||||
{"GetAvgPing", ServerFunctions::GetAvgPing},\
|
{"GetModDir", ServerFunctions::GetModDir}
|
||||||
{"GetIP", ServerFunctions::GetIP},\
|
|
||||||
{"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\
|
|
||||||
{"GetPort", ServerFunctions::GetPort},\
|
|
||||||
{"HasPassword", ServerFunctions::HasPassword},\
|
|
||||||
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
|
|
||||||
{"GetScriptErrorIgnoringState", ServerFunctions::GetScriptErrorIgnoringState},\
|
|
||||||
\
|
|
||||||
{"SetGameMode", ServerFunctions::SetGameMode},\
|
|
||||||
{"SetHostname", ServerFunctions::SetHostname},\
|
|
||||||
{"SetServerPassword", ServerFunctions::SetServerPassword},\
|
|
||||||
{"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
|
|
||||||
{"SetScriptErrorIgnoringState", ServerFunctions::SetScriptErrorIgnoringState},\
|
|
||||||
{"SetRuleString", ServerFunctions::SetRuleString},\
|
|
||||||
{"SetRuleValue", ServerFunctions::SetRuleValue},\
|
|
||||||
\
|
|
||||||
{"AddDataFileRequirement", ServerFunctions::AddDataFileRequirement},\
|
|
||||||
\
|
|
||||||
{"DoesFileExist", ServerFunctions::DoesFileExist},\
|
|
||||||
{"GetModDir", ServerFunctions::GetModDir},\
|
|
||||||
{"AddPluginHash", ServerFunctions::AddPluginHash}
|
|
||||||
|
|
||||||
class ServerFunctions
|
class ServerFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Write a log message with its own timestamp.
|
|
||||||
*
|
|
||||||
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
|
|
||||||
*
|
|
||||||
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
|
|
||||||
* 3 for LOG_ERROR, 4 for LOG_FATAL).
|
|
||||||
* \param message The message logged.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void LogMessage(unsigned short level, const char *message) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Write a log message without its own timestamp.
|
|
||||||
*
|
|
||||||
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
|
|
||||||
*
|
|
||||||
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
|
|
||||||
* 3 for LOG_ERROR, 4 for LOG_FATAL).
|
|
||||||
* \param message The message logged.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void LogAppend(unsigned short level, const char *message) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Shut down the server.
|
* \brief Shut down the server.
|
||||||
*
|
*
|
||||||
|
@ -103,41 +68,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static void UnbanAddress(const char *ipAddress) noexcept;
|
static void UnbanAddress(const char *ipAddress) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Check whether a certain file path exists.
|
|
||||||
*
|
|
||||||
* This will be a case sensitive check on case sensitive filesystems.
|
|
||||||
*
|
|
||||||
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
|
|
||||||
*
|
|
||||||
* \return Whether the file exists or not.
|
|
||||||
*/
|
|
||||||
static bool DoesFilePathExist(const char *filePath) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the first filename in a folder that has a case insensitive match with the filename
|
|
||||||
* argument.
|
|
||||||
*
|
|
||||||
* This is used to retain case insensitivity when opening data files on Linux.
|
|
||||||
*
|
|
||||||
* \return The filename that matches.
|
|
||||||
*/
|
|
||||||
static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the path of the server's data folder.
|
|
||||||
*
|
|
||||||
* \return The data path.
|
|
||||||
*/
|
|
||||||
static const char *GetDataPath() noexcept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the milliseconds elapsed since the server was started.
|
|
||||||
*
|
|
||||||
* \return The time since the server's startup in milliseconds.
|
|
||||||
*/
|
|
||||||
static unsigned int GetMillisecondsSinceServerStart() noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the type of the operating system used by the server.
|
* \brief Get the type of the operating system used by the server.
|
||||||
*
|
*
|
||||||
|
@ -189,7 +119,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* \brief Get the port used by the server.
|
* \brief Get the port used by the server.
|
||||||
*
|
*
|
||||||
* \return The port.
|
* \return Port
|
||||||
*/
|
*/
|
||||||
static unsigned short GetPort() noexcept;
|
static unsigned short GetPort() noexcept;
|
||||||
|
|
||||||
|
@ -290,24 +220,13 @@ public:
|
||||||
static void SetRuleValue(const char *key, double value) noexcept;
|
static void SetRuleValue(const char *key, double value) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add a data file and a corresponding CRC32 checksum to the data file loadout
|
* \brief Adds plugins to the internal server structure to validate players.
|
||||||
* that connecting clients need to match.
|
* @param pluginName Name with extension of the plugin or master file.
|
||||||
*
|
* @param hash Hash string
|
||||||
* It can be used multiple times to set multiple checksums for the same data file.
|
|
||||||
*
|
|
||||||
* Note: If an empty string is provided for the checksum, a checksum will not be
|
|
||||||
* required for that data file.
|
|
||||||
*
|
|
||||||
* @param dataFilename The filename of the data file.
|
|
||||||
* @param checksumString A string with the CRC32 checksum required.
|
|
||||||
*/
|
*/
|
||||||
static void AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept;
|
static void AddPluginHash(const char *pluginName, const char *hash) noexcept;
|
||||||
|
|
||||||
// All methods below are deprecated versions of methods from above
|
|
||||||
|
|
||||||
static bool DoesFileExist(const char *filePath) noexcept;
|
|
||||||
static const char *GetModDir() noexcept;
|
static const char *GetModDir() noexcept;
|
||||||
static void AddPluginHash(const char *pluginName, const char *checksumString) noexcept;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_SERVERAPI_HPP
|
#endif //OPENMW_SERVERAPI_HPP
|
||||||
|
|
|
@ -201,17 +201,6 @@ int StatsFunctions::GetAttributeModifier(unsigned short pid, unsigned short attr
|
||||||
return player->creatureStats.mAttributes[attributeId].mMod;
|
return player->creatureStats.mAttributes[attributeId].mMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
double StatsFunctions::GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
if (attributeId >= Attribute::Length)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return player->creatureStats.mAttributes[attributeId].mDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skillId) noexcept
|
int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skillId) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -234,17 +223,6 @@ int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned short skillId)
|
||||||
return player->npcStats.mSkills[skillId].mMod;
|
return player->npcStats.mSkills[skillId].mMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
double StatsFunctions::GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, 0);
|
|
||||||
|
|
||||||
if (skillId >= Skill::Length)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return player->npcStats.mSkills[skillId].mDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept
|
double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -459,20 +437,6 @@ void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsigned short a
|
||||||
player->attributeIndexChanges.push_back(attributeId);
|
player->attributeIndexChanges.push_back(attributeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsFunctions::SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
if (attributeId >= Attribute::Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player->creatureStats.mAttributes[attributeId].mDamage = value;
|
|
||||||
|
|
||||||
if (!Utils::vectorContains(player->attributeIndexChanges, attributeId))
|
|
||||||
player->attributeIndexChanges.push_back(attributeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept
|
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -501,20 +465,6 @@ void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned short skill
|
||||||
player->skillIndexChanges.push_back(skillId);
|
player->skillIndexChanges.push_back(skillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsFunctions::SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept
|
|
||||||
{
|
|
||||||
Player *player;
|
|
||||||
GET_PLAYER(pid, player, );
|
|
||||||
|
|
||||||
if (skillId >= Skill::Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player->npcStats.mSkills[skillId].mDamage = value;
|
|
||||||
|
|
||||||
if (!Utils::vectorContains(player->skillIndexChanges, skillId))
|
|
||||||
player->skillIndexChanges.push_back(skillId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept
|
void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
|
|
@ -30,11 +30,9 @@
|
||||||
\
|
\
|
||||||
{"GetAttributeBase", StatsFunctions::GetAttributeBase},\
|
{"GetAttributeBase", StatsFunctions::GetAttributeBase},\
|
||||||
{"GetAttributeModifier", StatsFunctions::GetAttributeModifier},\
|
{"GetAttributeModifier", StatsFunctions::GetAttributeModifier},\
|
||||||
{"GetAttributeDamage", StatsFunctions::GetAttributeDamage},\
|
|
||||||
\
|
\
|
||||||
{"GetSkillBase", StatsFunctions::GetSkillBase},\
|
{"GetSkillBase", StatsFunctions::GetSkillBase},\
|
||||||
{"GetSkillModifier", StatsFunctions::GetSkillModifier},\
|
{"GetSkillModifier", StatsFunctions::GetSkillModifier},\
|
||||||
{"GetSkillDamage", StatsFunctions::GetSkillDamage},\
|
|
||||||
{"GetSkillProgress", StatsFunctions::GetSkillProgress},\
|
{"GetSkillProgress", StatsFunctions::GetSkillProgress},\
|
||||||
{"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\
|
{"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\
|
||||||
\
|
\
|
||||||
|
@ -60,11 +58,9 @@
|
||||||
\
|
\
|
||||||
{"SetAttributeBase", StatsFunctions::SetAttributeBase},\
|
{"SetAttributeBase", StatsFunctions::SetAttributeBase},\
|
||||||
{"ClearAttributeModifier", StatsFunctions::ClearAttributeModifier},\
|
{"ClearAttributeModifier", StatsFunctions::ClearAttributeModifier},\
|
||||||
{"SetAttributeDamage", StatsFunctions::SetAttributeDamage},\
|
|
||||||
\
|
\
|
||||||
{"SetSkillBase", StatsFunctions::SetSkillBase},\
|
{"SetSkillBase", StatsFunctions::SetSkillBase},\
|
||||||
{"ClearSkillModifier", StatsFunctions::ClearSkillModifier},\
|
{"ClearSkillModifier", StatsFunctions::ClearSkillModifier},\
|
||||||
{"SetSkillDamage", StatsFunctions::SetSkillDamage},\
|
|
||||||
{"SetSkillProgress", StatsFunctions::SetSkillProgress},\
|
{"SetSkillProgress", StatsFunctions::SetSkillProgress},\
|
||||||
{"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\
|
{"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\
|
||||||
\
|
\
|
||||||
|
@ -271,16 +267,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static int GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
|
static int GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the amount of damage (as caused through the Damage Attribute effect)
|
|
||||||
* to a player's attribute.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param attributeId The attribute ID.
|
|
||||||
* \return The amount of damage to the attribute.
|
|
||||||
*/
|
|
||||||
static double GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the base value of a player's skill.
|
* \brief Get the base value of a player's skill.
|
||||||
*
|
*
|
||||||
|
@ -299,16 +285,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static int GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
|
static int GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the amount of damage (as caused through the Damage Skill effect)
|
|
||||||
* to a player's skill.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param skillId The skill ID.
|
|
||||||
* \return The amount of damage to the skill.
|
|
||||||
*/
|
|
||||||
static double GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the progress the player has made towards increasing a certain skill by 1.
|
* \brief Get the progress the player has made towards increasing a certain skill by 1.
|
||||||
*
|
*
|
||||||
|
@ -501,17 +477,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static void ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
|
static void ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the amount of damage (as caused through the Damage Attribute effect) to
|
|
||||||
* a player's attribute.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param attributeId The attribute ID.
|
|
||||||
* \param value The amount of damage to the player's attribute.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the base value of a player's skill.
|
* \brief Set the base value of a player's skill.
|
||||||
*
|
*
|
||||||
|
@ -536,17 +501,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static void ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
|
static void ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the amount of damage (as caused through the Damage Skill effect) to
|
|
||||||
* a player's skill.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param skillId The skill ID.
|
|
||||||
* \param value The amount of damage to the player's skill.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the progress the player has made towards increasing a certain skill by 1.
|
* \brief Set the progress the player has made towards increasing a certain skill by 1.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,7 +21,7 @@ int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *ty
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
vector<boost::any> params;
|
vector<boost::any> params;
|
||||||
Utils::getArguments(params, args, types);
|
GetArguments(params, args, types);
|
||||||
|
|
||||||
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);
|
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,6 @@ public:
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
||||||
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
|
|
||||||
|
|
||||||
if (!mwmp::Networking::getPtr()->getScriptErrorIgnoringState())
|
if (!mwmp::Networking::getPtr()->getScriptErrorIgnoringState())
|
||||||
throw;
|
throw;
|
||||||
|
|
|
@ -13,6 +13,62 @@ 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)
|
||||||
|
{
|
||||||
|
params.reserve(def.length());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (char c : def)
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'i':
|
||||||
|
params.emplace_back(va_arg(args, unsigned int));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'q':
|
||||||
|
params.emplace_back(va_arg(args, signed int));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
params.emplace_back(va_arg(args, unsigned long long));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
params.emplace_back(va_arg(args, signed long long));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
params.emplace_back(va_arg(args, double));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'p':
|
||||||
|
params.emplace_back(va_arg(args, void*));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
params.emplace_back(va_arg(args, const char*));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
params.emplace_back(va_arg(args, int));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw runtime_error("C++ call: Unknown argument identifier " + c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
va_end(args);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
@ -25,7 +81,7 @@ boost::any ScriptFunctions::CallPublic(const char *name, va_list args) noexcept
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string def = Public::GetDefinition(name);
|
string def = Public::GetDefinition(name);
|
||||||
Utils::getArguments(params, args, def);
|
GetArguments(params, args, def);
|
||||||
|
|
||||||
return Public::Call(name, params);
|
return Public::Call(name, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ScriptFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static void GetArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def);
|
||||||
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, va_list args) noexcept;
|
static boost::any CallPublic(const char *name, va_list args) noexcept;
|
||||||
|
|
||||||
|
@ -156,7 +157,6 @@ public:
|
||||||
{"OnServerInit", Callback<>()},
|
{"OnServerInit", Callback<>()},
|
||||||
{"OnServerPostInit", Callback<>()},
|
{"OnServerPostInit", Callback<>()},
|
||||||
{"OnServerExit", Callback<bool>()},
|
{"OnServerExit", Callback<bool>()},
|
||||||
{"OnServerScriptCrash", Callback<const char*>()},
|
|
||||||
{"OnPlayerConnect", Callback<unsigned short>()},
|
{"OnPlayerConnect", Callback<unsigned short>()},
|
||||||
{"OnPlayerDisconnect", Callback<unsigned short>()},
|
{"OnPlayerDisconnect", Callback<unsigned short>()},
|
||||||
{"OnPlayerDeath", Callback<unsigned short>()},
|
{"OnPlayerDeath", Callback<unsigned short>()},
|
||||||
|
@ -209,7 +209,7 @@ public:
|
||||||
{"OnWorldMap", Callback<unsigned short>()},
|
{"OnWorldMap", Callback<unsigned short>()},
|
||||||
{"OnWorldWeather", Callback<unsigned short>() },
|
{"OnWorldWeather", Callback<unsigned short>() },
|
||||||
{"OnMpNumIncrement", Callback<int>()},
|
{"OnMpNumIncrement", Callback<int>()},
|
||||||
{"OnRequestDataFileList", Callback<>()}
|
{"OnRequestPluginList", Callback<>()}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "Utils.hpp"
|
//
|
||||||
|
// Created by koncord on 04.03.17.
|
||||||
|
//
|
||||||
|
|
||||||
#include <cstdarg>
|
#include "Utils.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -50,59 +52,3 @@ ESM::Cell Utils::getCellFromDescription(std::string cellDescription)
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::getArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def)
|
|
||||||
{
|
|
||||||
params.reserve(def.length());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (char c : def)
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'i':
|
|
||||||
params.emplace_back(va_arg(args, unsigned int));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'q':
|
|
||||||
params.emplace_back(va_arg(args, signed int));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
params.emplace_back(va_arg(args, unsigned long long));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
params.emplace_back(va_arg(args, signed long long));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
params.emplace_back(va_arg(args, double));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p':
|
|
||||||
params.emplace_back(va_arg(args, void*));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
params.emplace_back(va_arg(args, const char*));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
params.emplace_back(va_arg(args, int));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw runtime_error("C++ call: Unknown argument identifier " + c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
va_end(args);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
//
|
||||||
|
// Created by koncord on 04.03.17.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef OPENMW_UTILS_HPP
|
#ifndef OPENMW_UTILS_HPP
|
||||||
#define OPENMW_UTILS_HPP
|
#define OPENMW_UTILS_HPP
|
||||||
|
|
||||||
|
@ -5,8 +9,6 @@
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
|
||||||
|
|
||||||
#include <components/esm/loadcell.hpp>
|
#include <components/esm/loadcell.hpp>
|
||||||
|
|
||||||
#include <components/openmw-mp/Utils.hpp>
|
#include <components/openmw-mp/Utils.hpp>
|
||||||
|
@ -25,8 +27,6 @@ namespace Utils
|
||||||
|
|
||||||
ESM::Cell getCellFromDescription(std::string cellDescription);
|
ESM::Cell getCellFromDescription(std::string cellDescription);
|
||||||
|
|
||||||
void getArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def);
|
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
constexpr unsigned int hash(const char(&str)[N], size_t I = N)
|
constexpr unsigned int hash(const char(&str)[N], size_t I = N)
|
||||||
{
|
{
|
||||||
|
|
|
@ -307,7 +307,6 @@ int main(int argc, char *argv[])
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
|
||||||
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
|
|
||||||
throw; //fall through
|
throw; //fall through
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
//
|
||||||
|
// Created by koncord on 31.03.17.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef OPENMW_PROCESSORPLAYERPOSITION_HPP
|
#ifndef OPENMW_PROCESSORPLAYERPOSITION_HPP
|
||||||
#define OPENMW_PROCESSORPLAYERPOSITION_HPP
|
#define OPENMW_PROCESSORPLAYERPOSITION_HPP
|
||||||
|
|
||||||
|
@ -15,7 +19,11 @@ namespace mwmp
|
||||||
|
|
||||||
void Do(PlayerPacket &packet, Player &player) override
|
void Do(PlayerPacket &packet, Player &player) override
|
||||||
{
|
{
|
||||||
player.sendToLoaded(&packet);
|
//DEBUG_PRINTF(strPacketID);
|
||||||
|
if (!player.creatureStats.mDead)
|
||||||
|
{
|
||||||
|
player.sendToLoaded(&packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ add_openmw_dir (mwmp/processors/object BaseObjectProcessor
|
||||||
ProcessorScriptGlobalFloat
|
ProcessorScriptGlobalFloat
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwmp/processors/worldstate ProcessorCellCreate ProcessorCellReset ProcessorRecordDynamic
|
add_openmw_dir (mwmp/processors/worldstate ProcessorCellCreate ProcessorCellReplace ProcessorRecordDynamic
|
||||||
ProcessorWorldCollisionOverride ProcessorWorldMap ProcessorWorldRegionAuthority ProcessorWorldTime
|
ProcessorWorldCollisionOverride ProcessorWorldMap ProcessorWorldRegionAuthority ProcessorWorldTime
|
||||||
ProcessorWorldWeather
|
ProcessorWorldWeather
|
||||||
)
|
)
|
||||||
|
|
|
@ -458,15 +458,6 @@ namespace MWGui
|
||||||
|
|
||||||
updateMagicMarkers();
|
updateMagicMarkers();
|
||||||
updateCustomMarkers();
|
updateCustomMarkers();
|
||||||
/*
|
|
||||||
Start of tes3mp addition
|
|
||||||
|
|
||||||
Update player markers when cell changes to fix their locations
|
|
||||||
*/
|
|
||||||
updatePlayerMarkers();
|
|
||||||
/*
|
|
||||||
End of tes3mp addition
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalMapBase::requestMapRender(const MWWorld::CellStore *cell)
|
void LocalMapBase::requestMapRender(const MWWorld::CellStore *cell)
|
||||||
|
|
|
@ -71,13 +71,6 @@ DedicatedPlayer::~DedicatedPlayer()
|
||||||
|
|
||||||
void DedicatedPlayer::update(float dt)
|
void DedicatedPlayer::update(float dt)
|
||||||
{
|
{
|
||||||
// Only move and set anim flags if the framerate isn't too low
|
|
||||||
if (dt < 0.1)
|
|
||||||
{
|
|
||||||
move(dt);
|
|
||||||
setAnimFlags();
|
|
||||||
}
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
|
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
|
||||||
|
|
||||||
MWMechanics::DynamicStat<float> value;
|
MWMechanics::DynamicStat<float> value;
|
||||||
|
@ -107,6 +100,13 @@ void DedicatedPlayer::update(float dt)
|
||||||
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0);
|
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0);
|
||||||
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0);
|
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0);
|
||||||
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
|
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
|
||||||
|
|
||||||
|
// Only move and set anim flags if the framerate isn't too low
|
||||||
|
if (dt < 0.1)
|
||||||
|
{
|
||||||
|
move(dt);
|
||||||
|
setAnimFlags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DedicatedPlayer::move(float dt)
|
void DedicatedPlayer::move(float dt)
|
||||||
|
|
|
@ -68,10 +68,10 @@ void LocalActor::update(bool forceUpdate)
|
||||||
|
|
||||||
void LocalActor::updateCell()
|
void LocalActor::updateCell()
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_ACTOR_CELL_CHANGE about %s %i-%i in cell %s to server",
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_ACTOR_CELL_CHANGE about %s %i-%i to server",
|
||||||
refId.c_str(), refNum, mpNum, cell.getDescription().c_str());
|
refId.c_str(), refNum, mpNum);
|
||||||
|
|
||||||
LOG_APPEND(Log::LOG_VERBOSE, "- Moved to cell %s", ptr.getCell()->getCell()->getDescription().c_str());
|
LOG_APPEND(Log::LOG_VERBOSE, "- Moved from %s to %s", cell.getDescription().c_str(), ptr.getCell()->getCell()->getDescription().c_str());
|
||||||
|
|
||||||
cell = *ptr.getCell()->getCell();
|
cell = *ptr.getCell()->getCell();
|
||||||
position = ptr.getRefData().getPosition();
|
position = ptr.getRefData().getPosition();
|
||||||
|
@ -194,8 +194,8 @@ void LocalActor::updateStatsDynamic(bool forceUpdate)
|
||||||
if (MechanicsHelper::isEmptyTarget(killer))
|
if (MechanicsHelper::isEmptyTarget(killer))
|
||||||
killer = MechanicsHelper::getTarget(ptr);
|
killer = MechanicsHelper::getTarget(ptr);
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_ACTOR_DEATH about %s %i-%i in cell %s to server",
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_ACTOR_DEATH about %s %i-%i to server",
|
||||||
refId.c_str(), refNum, mpNum, cell.getDescription().c_str());
|
refId.c_str(), refNum, mpNum);
|
||||||
|
|
||||||
mwmp::Main::get().getNetworking()->getActorList()->addDeathActor(*this);
|
mwmp::Main::get().getNetworking()->getActorList()->addDeathActor(*this);
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,6 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
|
||||||
{
|
{
|
||||||
if (ptrNpcStats.getAttribute(i).getBase() != creatureStats.mAttributes[i].mBase ||
|
if (ptrNpcStats.getAttribute(i).getBase() != creatureStats.mAttributes[i].mBase ||
|
||||||
ptrNpcStats.getAttribute(i).getModifier() != creatureStats.mAttributes[i].mMod ||
|
ptrNpcStats.getAttribute(i).getModifier() != creatureStats.mAttributes[i].mMod ||
|
||||||
ptrNpcStats.getAttribute(i).getDamage() != creatureStats.mAttributes[i].mDamage ||
|
|
||||||
ptrNpcStats.getSkillIncrease(i) != npcStats.mSkillIncrease[i] ||
|
ptrNpcStats.getSkillIncrease(i) != npcStats.mSkillIncrease[i] ||
|
||||||
forceUpdate)
|
forceUpdate)
|
||||||
{
|
{
|
||||||
|
@ -319,7 +318,6 @@ void LocalPlayer::updateSkills(bool forceUpdate)
|
||||||
// Update a skill if its base value has changed at all or its progress has changed enough
|
// Update a skill if its base value has changed at all or its progress has changed enough
|
||||||
if (ptrNpcStats.getSkill(i).getBase() != npcStats.mSkills[i].mBase ||
|
if (ptrNpcStats.getSkill(i).getBase() != npcStats.mSkills[i].mBase ||
|
||||||
ptrNpcStats.getSkill(i).getModifier() != npcStats.mSkills[i].mMod ||
|
ptrNpcStats.getSkill(i).getModifier() != npcStats.mSkills[i].mMod ||
|
||||||
ptrNpcStats.getSkill(i).getDamage() != npcStats.mSkills[i].mDamage ||
|
|
||||||
abs(ptrNpcStats.getSkill(i).getProgress() - npcStats.mSkills[i].mProgress) > 0.75 ||
|
abs(ptrNpcStats.getSkill(i).getProgress() - npcStats.mSkills[i].mProgress) > 0.75 ||
|
||||||
forceUpdate)
|
forceUpdate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
#include "WorldstateProcessor.hpp"
|
#include "WorldstateProcessor.hpp"
|
||||||
#include "worldstate/ProcessorCellCreate.hpp"
|
#include "worldstate/ProcessorCellCreate.hpp"
|
||||||
#include "worldstate/ProcessorCellReset.hpp"
|
#include "worldstate/ProcessorCellReplace.hpp"
|
||||||
#include "worldstate/ProcessorRecordDynamic.hpp"
|
#include "worldstate/ProcessorRecordDynamic.hpp"
|
||||||
#include "worldstate/ProcessorWorldCollisionOverride.hpp"
|
#include "worldstate/ProcessorWorldCollisionOverride.hpp"
|
||||||
#include "worldstate/ProcessorWorldMap.hpp"
|
#include "worldstate/ProcessorWorldMap.hpp"
|
||||||
|
@ -186,7 +186,7 @@ void ProcessorInitializer()
|
||||||
ActorProcessor::AddProcessor(new ProcessorActorTest());
|
ActorProcessor::AddProcessor(new ProcessorActorTest());
|
||||||
|
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorCellCreate());
|
WorldstateProcessor::AddProcessor(new ProcessorCellCreate());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorCellReset());
|
WorldstateProcessor::AddProcessor(new ProcessorCellReplace());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
WorldstateProcessor::AddProcessor(new ProcessorRecordDynamic());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorWorldCollisionOverride());
|
WorldstateProcessor::AddProcessor(new ProcessorWorldCollisionOverride());
|
||||||
WorldstateProcessor::AddProcessor(new ProcessorWorldMap());
|
WorldstateProcessor::AddProcessor(new ProcessorWorldMap());
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef OPENMW_PROCESSORCELLREPLACE_HPP
|
||||||
|
#define OPENMW_PROCESSORCELLREPLACE_HPP
|
||||||
|
|
||||||
|
#include "../WorldstateProcessor.hpp"
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class ProcessorCellReplace : public WorldstateProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProcessorCellReplace()
|
||||||
|
{
|
||||||
|
BPP_INIT(ID_CELL_REPLACE)
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
||||||
|
{
|
||||||
|
// Placeholder
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PROCESSORCELLREPLACE_HPP
|
|
@ -1,23 +0,0 @@
|
||||||
#ifndef OPENMW_PROCESSORCELLRESET_HPP
|
|
||||||
#define OPENMW_PROCESSORCELLRESET_HPP
|
|
||||||
|
|
||||||
#include "../WorldstateProcessor.hpp"
|
|
||||||
|
|
||||||
namespace mwmp
|
|
||||||
{
|
|
||||||
class ProcessorCellReset : public WorldstateProcessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProcessorCellReset()
|
|
||||||
{
|
|
||||||
BPP_INIT(ID_CELL_RESET)
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Do(WorldstatePacket &packet, Worldstate &worldstate)
|
|
||||||
{
|
|
||||||
// Placeholder
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //OPENMW_PROCESSORCELLRESET_HPP
|
|
|
@ -202,7 +202,7 @@ add_component_dir (openmw-mp/Packets/Object
|
||||||
add_component_dir (openmw-mp/Packets/Worldstate
|
add_component_dir (openmw-mp/Packets/Worldstate
|
||||||
WorldstatePacket
|
WorldstatePacket
|
||||||
|
|
||||||
PacketCellCreate PacketCellReset PacketRecordDynamic PacketWorldCollisionOverride PacketWorldMap
|
PacketCellCreate PacketCellReplace PacketRecordDynamic PacketWorldCollisionOverride PacketWorldMap
|
||||||
PacketWorldRegionAuthority PacketWorldTime PacketWorldWeather
|
PacketWorldRegionAuthority PacketWorldTime PacketWorldWeather
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../Packets/Worldstate/PacketCellCreate.hpp"
|
#include "../Packets/Worldstate/PacketCellCreate.hpp"
|
||||||
#include "../Packets/Worldstate/PacketCellReset.hpp"
|
#include "../Packets/Worldstate/PacketCellReplace.hpp"
|
||||||
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
||||||
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
||||||
#include "../Packets/Worldstate/PacketWorldMap.hpp"
|
#include "../Packets/Worldstate/PacketWorldMap.hpp"
|
||||||
|
@ -20,7 +20,7 @@ inline void AddPacket(mwmp::WorldstatePacketController::packets_t *packets, RakN
|
||||||
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
||||||
{
|
{
|
||||||
AddPacket<PacketCellCreate>(&packets, peer);
|
AddPacket<PacketCellCreate>(&packets, peer);
|
||||||
AddPacket<PacketCellReset>(&packets, peer);
|
AddPacket<PacketCellReplace>(&packets, peer);
|
||||||
AddPacket<PacketRecordDynamic>(&packets, peer);
|
AddPacket<PacketRecordDynamic>(&packets, peer);
|
||||||
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
||||||
AddPacket<PacketWorldMap>(&packets, peer);
|
AddPacket<PacketWorldMap>(&packets, peer);
|
||||||
|
|
|
@ -104,7 +104,7 @@ enum GameMessages
|
||||||
ID_GAME_PREINIT,
|
ID_GAME_PREINIT,
|
||||||
|
|
||||||
ID_CELL_CREATE,
|
ID_CELL_CREATE,
|
||||||
ID_CELL_RESET,
|
ID_CELL_REPLACE,
|
||||||
ID_RECORD_DYNAMIC,
|
ID_RECORD_DYNAMIC,
|
||||||
ID_WORLD_COLLISION_OVERRIDE,
|
ID_WORLD_COLLISION_OVERRIDE,
|
||||||
ID_WORLD_MAP,
|
ID_WORLD_MAP,
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "PacketCellReplace.hpp"
|
||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
PacketCellReplace::PacketCellReplace(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
|
||||||
|
{
|
||||||
|
packetID = ID_CELL_REPLACE;
|
||||||
|
orderChannel = CHANNEL_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PacketCellReplace::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
{
|
||||||
|
WorldstatePacket::Packet(bs, send);
|
||||||
|
|
||||||
|
// Placeholder
|
||||||
|
}
|
|
@ -1,18 +1,18 @@
|
||||||
#ifndef OPENMW_PACKETCELLRESET_HPP
|
#ifndef OPENMW_PACKETCELLREPLACE_HPP
|
||||||
#define OPENMW_PACKETCELLRESET_HPP
|
#define OPENMW_PACKETCELLREPLACE_HPP
|
||||||
|
|
||||||
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
#include <components/openmw-mp/Packets/Worldstate/WorldstatePacket.hpp>
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class PacketCellReset: public WorldstatePacket
|
class PacketCellReplace: public WorldstatePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketCellReset(RakNet::RakPeerInterface *peer);
|
PacketCellReplace(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_PACKETCELLRESET_HPP
|
#endif //OPENMW_PACKETCELLREPLACE_HPP
|
|
@ -1,17 +0,0 @@
|
||||||
#include "PacketCellReset.hpp"
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
||||||
|
|
||||||
using namespace mwmp;
|
|
||||||
|
|
||||||
PacketCellReset::PacketCellReset(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)
|
|
||||||
{
|
|
||||||
packetID = ID_CELL_RESET;
|
|
||||||
orderChannel = CHANNEL_SYSTEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PacketCellReset::Packet(RakNet::BitStream *bs, bool send)
|
|
||||||
{
|
|
||||||
WorldstatePacket::Packet(bs, send);
|
|
||||||
|
|
||||||
// Placeholder
|
|
||||||
}
|
|
|
@ -192,16 +192,15 @@ std::string Utils::getArchitectureType()
|
||||||
{
|
{
|
||||||
#if defined(__x86_64__) || defined(_M_X64)
|
#if defined(__x86_64__) || defined(_M_X64)
|
||||||
return "64-bit";
|
return "64-bit";
|
||||||
#elif defined(__i386__) || defined(_M_I86) || defined(_M_IX86)
|
#elif defined(__i386__) || defined(_M_I86)
|
||||||
return "32-bit";
|
return "32-bit";
|
||||||
#elif defined(__ARM_ARCH)
|
#elif defined(__ARM_ARCH)
|
||||||
std::string architectureType = "ARMv" + __ARM_ARCH;
|
return "ARMv" + __ARM_ARCH;
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
architectureType = architectureType + " 64-bit";
|
return "64-bit";
|
||||||
#else
|
#else
|
||||||
architectureType = architectureType + " 32-bit";
|
return "32-bit";
|
||||||
#endif
|
#endif
|
||||||
return architectureType;
|
|
||||||
#else
|
#else
|
||||||
return "Unknown architecture";
|
return "Unknown architecture";
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue