mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Merge branch 'main' into Log-Line-Cleaning
This commit is contained in:
commit
ff8d68f45c
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@ -7,6 +7,7 @@ body:
|
|||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
id: checks
|
id: checks
|
||||||
attributes:
|
attributes:
|
||||||
|
label: "Make sure you've done the following:"
|
||||||
options:
|
options:
|
||||||
- label: >
|
- label: >
|
||||||
I have checked that this issue has not already been reported.
|
I have checked that this issue has not already been reported.
|
||||||
|
@ -5,7 +5,9 @@ labels: ["docs", "triage"]
|
|||||||
|
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
|
id: checks
|
||||||
attributes:
|
attributes:
|
||||||
|
label: "Make sure you've done the following:"
|
||||||
options:
|
options:
|
||||||
- label: >
|
- label: >
|
||||||
I have checked that this issue has not already been reported.
|
I have checked that this issue has not already been reported.
|
||||||
|
@ -7,6 +7,7 @@ body:
|
|||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
id: checks
|
id: checks
|
||||||
attributes:
|
attributes:
|
||||||
|
label: "Make sure you've done the following:"
|
||||||
options:
|
options:
|
||||||
- label: >
|
- label: >
|
||||||
I have read the [installation guide](https://github.com/DarkflameUniverse/DarkflameServer/blob/main/README.md).
|
I have read the [installation guide](https://github.com/DarkflameUniverse/DarkflameServer/blob/main/README.md).
|
||||||
|
@ -7,6 +7,7 @@ body:
|
|||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
id: checks
|
id: checks
|
||||||
attributes:
|
attributes:
|
||||||
|
label: "Make sure you've done the following:"
|
||||||
options:
|
options:
|
||||||
- label: >
|
- label: >
|
||||||
I have checked that this issue has not already been reported.
|
I have checked that this issue has not already been reported.
|
||||||
|
33
.github/workflows/build.yml
vendored
Normal file
33
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Cmake CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: cmake
|
||||||
|
uses: lukka/run-cmake@v10
|
||||||
|
with:
|
||||||
|
configurePreset: 'default'
|
||||||
|
buildPreset: 'default'
|
||||||
|
- name: artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: linux-build
|
||||||
|
path: |
|
||||||
|
build
|
||||||
|
!build/CMakeCache.txt
|
||||||
|
!build/build.ninja
|
||||||
|
!build/_deps
|
||||||
|
!build/cmake_install.cmake
|
||||||
|
!build/*.a
|
@ -123,6 +123,9 @@ make_directory(${CMAKE_BINARY_DIR}/res)
|
|||||||
# Create a /locale directory
|
# Create a /locale directory
|
||||||
make_directory(${CMAKE_BINARY_DIR}/locale)
|
make_directory(${CMAKE_BINARY_DIR}/locale)
|
||||||
|
|
||||||
|
# Create a /logs directory
|
||||||
|
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||||
|
|
||||||
# Copy ini files on first build
|
# Copy ini files on first build
|
||||||
if (NOT EXISTS ${PROJECT_BINARY_DIR}/authconfig.ini)
|
if (NOT EXISTS ${PROJECT_BINARY_DIR}/authconfig.ini)
|
||||||
configure_file(
|
configure_file(
|
||||||
|
26
CMakePresets.json
Normal file
26
CMakePresets.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 12,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"displayName": "Default Configure Settings",
|
||||||
|
"description": "Sets build and install directories",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"generator": "Unix Makefiles"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"configurePreset": "default",
|
||||||
|
"displayName": "Default Build",
|
||||||
|
"description": "Default Build",
|
||||||
|
"jobs": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -289,10 +289,10 @@ Here is a summary of the commands available in-game. All commands are prefixed b
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
instance-info
|
instanceinfo
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
/instance-info
|
/instanceinfo
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Displays in the chat the current zone, clone, and instance id.
|
Displays in the chat the current zone, clone, and instance id.
|
||||||
|
@ -45,6 +45,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("authconfig.ini");
|
dConfig config("authconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
std::string mysql_host = config.GetValue("mysql_host");
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
@ -152,11 +153,13 @@ int main(int argc, char** argv) {
|
|||||||
dLogger * SetupLogger() {
|
dLogger * SetupLogger() {
|
||||||
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
|
@ -351,6 +351,13 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (team->memberIDs.size() > 3) {
|
||||||
|
// no more teams greater than 4
|
||||||
|
|
||||||
|
Game::logger->Log("ChatPacketHandler", "Someone tried to invite a 5th player to a team");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SendTeamInvite(other, player);
|
SendTeamInvite(other, player);
|
||||||
|
|
||||||
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s\n", playerID, invitedPlayer.c_str());
|
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s\n", playerID, invitedPlayer.c_str());
|
||||||
|
@ -48,6 +48,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("chatconfig.ini");
|
dConfig config("chatconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
std::string mysql_host = config.GetValue("mysql_host");
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
@ -156,14 +157,16 @@ int main(int argc, char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dLogger* SetupLogger() {
|
dLogger * SetupLogger() {
|
||||||
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
dLogger::dLogger(const std::string& outpath, bool logToConsole) {
|
dLogger::dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements) {
|
||||||
m_logToConsole = logToConsole;
|
m_logToConsole = logToConsole;
|
||||||
|
m_logDebugStatements = logDebugStatements;
|
||||||
m_outpath = outpath;
|
m_outpath = outpath;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -24,39 +25,25 @@ dLogger::~dLogger() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::LogBasic(const std::string & message) {
|
void dLogger::vLog(const char* format, va_list args) {
|
||||||
LogBasic(message.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void dLogger::LogBasic(const char * format, ...) {
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm time;
|
struct tm time;
|
||||||
localtime_s(&time, &t);
|
localtime_s(&time, &t);
|
||||||
|
|
||||||
char timeStr[70];
|
char timeStr[70];
|
||||||
|
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
||||||
|
|
||||||
char message[2048];
|
char message[2048];
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf_s(message, format, args);
|
vsprintf_s(message, format, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) std::cout << "[" << "time machine broke" << "] " << message;
|
if (m_logToConsole) std::cout << "[" << timeStr << "] " << message;
|
||||||
mFile << "[" << "time" << "] " << message;
|
mFile << "[" << timeStr << "] " << message;
|
||||||
#else
|
#else
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm * time = localtime(&t);
|
struct tm * time = localtime(&t);
|
||||||
char timeStr[70];
|
char timeStr[70];
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
||||||
|
|
||||||
char message[2048];
|
char message[2048];
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf(message, format, args);
|
vsprintf(message, format, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) {
|
if (m_logToConsole) {
|
||||||
fputs("[", stdout);
|
fputs("[", stdout);
|
||||||
@ -76,62 +63,42 @@ void dLogger::LogBasic(const char * format, ...) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::Log(const char * className, const char * format, ...) {
|
void dLogger::LogBasic(const char * format, ...) {
|
||||||
#ifdef _WIN32
|
|
||||||
time_t t = time(NULL);
|
|
||||||
struct tm time;
|
|
||||||
localtime_s(&time, &t);
|
|
||||||
|
|
||||||
char timeStr[70];
|
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
|
||||||
|
|
||||||
char message[2048];
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsprintf_s(message, format, args);
|
vLog(format, args);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_logToConsole) std::cout << "[" << timeStr << "] [" << className << "]: " << message;
|
void dLogger::LogBasic(const std::string & message) {
|
||||||
mFile << "[" << timeStr << "] [" << className << "]: " << message;
|
LogBasic(message.c_str());
|
||||||
#else
|
}
|
||||||
time_t t = time(NULL);
|
|
||||||
struct tm * time = localtime(&t);
|
void dLogger::Log(const char * className, const char * format, ...) {
|
||||||
char timeStr[70];
|
va_list args;
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||||
|
va_start(args, format);
|
||||||
char message[2048];
|
vLog(log.c_str(), args);
|
||||||
va_list args;
|
va_end(args);
|
||||||
va_start(args, format);
|
|
||||||
vsprintf(message, format, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) {
|
|
||||||
fputs("[", stdout);
|
|
||||||
fputs(timeStr, stdout);
|
|
||||||
fputs("] ", stdout);
|
|
||||||
fputs("[", stdout);
|
|
||||||
fputs(className, stdout);
|
|
||||||
fputs("]: ", stdout);
|
|
||||||
fputs(message, stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp != NULL) {
|
|
||||||
fputs("[", fp);
|
|
||||||
fputs(timeStr, fp);
|
|
||||||
fputs("] ", fp);
|
|
||||||
fputs("[", fp);
|
|
||||||
fputs(className, fp);
|
|
||||||
fputs("]: ", fp);
|
|
||||||
fputs(message, fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::Log(const std::string & className, const std::string & message) {
|
void dLogger::Log(const std::string & className, const std::string & message) {
|
||||||
Log(className.c_str(), message.c_str());
|
Log(className.c_str(), message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dLogger::LogDebug(const char * className, const char * format, ...) {
|
||||||
|
if (!m_logDebugStatements) return;
|
||||||
|
va_list args;
|
||||||
|
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||||
|
va_start(args, format);
|
||||||
|
vLog(log.c_str(), args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dLogger::LogDebug(const std::string & className, const std::string & message) {
|
||||||
|
LogDebug(className.c_str(), message.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void dLogger::Flush() {
|
void dLogger::Flush() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
mFile.flush();
|
mFile.flush();
|
||||||
|
@ -7,21 +7,26 @@
|
|||||||
|
|
||||||
class dLogger {
|
class dLogger {
|
||||||
public:
|
public:
|
||||||
dLogger(const std::string& outpath, bool logToConsole);
|
dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements);
|
||||||
~dLogger();
|
~dLogger();
|
||||||
|
|
||||||
void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; }
|
void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; }
|
||||||
|
void SetLogDebugStatements(bool logDebugStatements) { m_logDebugStatements = logDebugStatements; }
|
||||||
|
void vLog(const char* format, va_list args);
|
||||||
|
|
||||||
void LogBasic(const std::string& message);
|
void LogBasic(const std::string& message);
|
||||||
void LogBasic(const char* format, ...);
|
void LogBasic(const char* format, ...);
|
||||||
void Log(const char* className, const char* format, ...);
|
void Log(const char* className, const char* format, ...);
|
||||||
void Log(const std::string& className, const std::string& message);
|
void Log(const std::string& className, const std::string& message);
|
||||||
|
void LogDebug(const std::string& className, const std::string& message);
|
||||||
|
void LogDebug(const char* className, const char* format, ...);
|
||||||
|
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
const bool GetIsLoggingToConsole() const { return m_logToConsole; }
|
const bool GetIsLoggingToConsole() const { return m_logToConsole; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_logDebugStatements;
|
||||||
bool m_logToConsole;
|
bool m_logToConsole;
|
||||||
std::string m_outpath;
|
std::string m_outpath;
|
||||||
std::ofstream mFile;
|
std::ofstream mFile;
|
||||||
|
@ -57,6 +57,6 @@ std::vector<CDLootMatrix> CDLootMatrixTable::Query(std::function<bool(CDLootMatr
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
std::vector<CDLootMatrix> CDLootMatrixTable::GetEntries(void) const {
|
const std::vector<CDLootMatrix>& CDLootMatrixTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The entries
|
\return The entries
|
||||||
*/
|
*/
|
||||||
std::vector<CDLootMatrix> GetEntries(void) const;
|
const std::vector<CDLootMatrix>& GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,6 +54,6 @@ std::vector<CDLootTable> CDLootTableTable::Query(std::function<bool(CDLootTable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
std::vector<CDLootTable> CDLootTableTable::GetEntries(void) const {
|
const std::vector<CDLootTable>& CDLootTableTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The entries
|
\return The entries
|
||||||
*/
|
*/
|
||||||
std::vector<CDLootTable> GetEntries(void) const;
|
const std::vector<CDLootTable>& GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,6 @@ std::vector<CDRarityTable> CDRarityTableTable::Query(std::function<bool(CDRarity
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Gets all the entries in the table
|
//! Gets all the entries in the table
|
||||||
std::vector<CDRarityTable> CDRarityTableTable::GetEntries(void) const {
|
const std::vector<CDRarityTable>& CDRarityTableTable::GetEntries(void) const {
|
||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
\return The entries
|
\return The entries
|
||||||
*/
|
*/
|
||||||
std::vector<CDRarityTable> GetEntries(void) const;
|
const std::vector<CDRarityTable>& GetEntries(void) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
includeFaction = 1;
|
includeFaction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto validTarget : context->GetValidTargets(m_ignoreFaction , includeFaction))
|
for (auto validTarget : context->GetValidTargets(m_ignoreFaction , includeFaction, m_TargetSelf == 1))
|
||||||
{
|
{
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
||||||
|
|
||||||
@ -155,4 +155,6 @@ void AreaOfEffectBehavior::Load()
|
|||||||
this->m_ignoreFaction = GetInt("ignore_faction");
|
this->m_ignoreFaction = GetInt("ignore_faction");
|
||||||
|
|
||||||
this->m_includeFaction = GetInt("include_faction");
|
this->m_includeFaction = GetInt("include_faction");
|
||||||
|
|
||||||
|
this->m_TargetSelf = GetInt("target_self");
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ public:
|
|||||||
int32_t m_ignoreFaction;
|
int32_t m_ignoreFaction;
|
||||||
|
|
||||||
int32_t m_includeFaction;
|
int32_t m_includeFaction;
|
||||||
|
|
||||||
|
int32_t m_TargetSelf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
|
@ -149,7 +149,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
behavior->Sync(this, bitStream, branch);
|
behavior->Sync(this, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ void BehaviorContext::Reset()
|
|||||||
this->scheduledUpdates.clear();
|
this->scheduledUpdates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction) const
|
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf) const
|
||||||
{
|
{
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
||||||
|
|
||||||
@ -353,21 +353,20 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && !entity->HasComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS) && targets.empty()))
|
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && targets.empty()))
|
||||||
{
|
{
|
||||||
DestroyableComponent* destroyableComponent;
|
DestroyableComponent* destroyableComponent;
|
||||||
if (!entity->TryGetComponent(COMPONENT_TYPE_DESTROYABLE, destroyableComponent))
|
if (!entity->TryGetComponent(COMPONENT_TYPE_DESTROYABLE, destroyableComponent))
|
||||||
{
|
{
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
|
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
|
||||||
|
|
||||||
for (auto* candidate : entities)
|
for (auto* candidate : entities)
|
||||||
{
|
{
|
||||||
const auto id = candidate->GetObjectID();
|
const auto id = candidate->GetObjectID();
|
||||||
|
|
||||||
if (destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction))
|
if ((id != entity->GetObjectID() || targetSelf) && destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction))
|
||||||
{
|
{
|
||||||
targets.push_back(id);
|
targets.push_back(id);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ struct BehaviorContext
|
|||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
std::vector<LWOOBJID> GetValidTargets(int32_t ignoreFaction = 0, int32_t includeFaction = 0) const;
|
std::vector<LWOOBJID> GetValidTargets(int32_t ignoreFaction = 0, int32_t includeFaction = 0, const bool targetSelf = false) const;
|
||||||
|
|
||||||
explicit BehaviorContext(LWOOBJID originator, bool calculation = false);
|
explicit BehaviorContext(LWOOBJID originator, bool calculation = false);
|
||||||
|
|
||||||
|
@ -1,44 +1,81 @@
|
|||||||
#include "ForceMovementBehavior.h"
|
#include "ForceMovementBehavior.h"
|
||||||
|
|
||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
|
#include "ControllablePhysicsComponent.h"
|
||||||
|
#include "EntityManager.h"
|
||||||
|
|
||||||
void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||||
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY)
|
return;
|
||||||
{
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
bitStream->Read(handle);
|
||||||
bitStream->Read(handle);
|
context->RegisterSyncBehavior(handle, this, branch);
|
||||||
|
|
||||||
context->RegisterSyncBehavior(handle, this, branch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||||
{
|
{
|
||||||
uint32_t next;
|
uint32_t next;
|
||||||
|
bitStream->Read(next);
|
||||||
|
|
||||||
bitStream->Read(next);
|
LWOOBJID target;
|
||||||
|
bitStream->Read(target);
|
||||||
|
|
||||||
LWOOBJID target;
|
branch.target = target;
|
||||||
|
auto* behavior = CreateBehavior(next);
|
||||||
|
behavior->Handle(context, bitStream, branch);
|
||||||
|
}
|
||||||
|
|
||||||
bitStream->Read(target);
|
void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
|
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto* behavior = CreateBehavior(next);
|
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
|
||||||
|
if (casterEntity != nullptr) {
|
||||||
|
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (controllablePhysicsComponent != nullptr) {
|
||||||
|
|
||||||
branch.target = target;
|
if (m_Forward == 1) {
|
||||||
|
controllablePhysicsComponent->SetVelocity(controllablePhysicsComponent->GetRotation().GetForwardVector() * 25);
|
||||||
|
}
|
||||||
|
|
||||||
behavior->Handle(context, bitStream, branch);
|
EntityManager::Instance()->SerializeEntity(casterEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto skillHandle = context->GetUniqueSkillId();
|
||||||
|
bitStream->Write(skillHandle);
|
||||||
|
|
||||||
|
context->SyncCalculation(skillHandle, this->m_Duration, this, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForceMovementBehavior::Load()
|
void ForceMovementBehavior::Load()
|
||||||
{
|
{
|
||||||
this->m_hitAction = GetAction("hit_action");
|
this->m_hitAction = GetAction("hit_action");
|
||||||
|
this->m_hitEnemyAction = GetAction("hit_action_enemy");
|
||||||
this->m_hitEnemyAction = GetAction("hit_action_enemy");
|
this->m_hitFactionAction = GetAction("hit_action_faction");
|
||||||
|
this->m_Duration = GetFloat("duration");
|
||||||
this->m_hitFactionAction = GetAction("hit_action_faction");
|
this->m_Forward = GetFloat("forward");
|
||||||
|
this->m_Left = GetFloat("left");
|
||||||
|
this->m_Yaw = GetFloat("yaw");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
|
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
|
||||||
|
if (casterEntity != nullptr) {
|
||||||
|
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
if (controllablePhysicsComponent != nullptr) {
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetPosition(controllablePhysicsComponent->GetPosition() + controllablePhysicsComponent->GetVelocity() * m_Duration);
|
||||||
|
controllablePhysicsComponent->SetVelocity({});
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(casterEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_hitAction->Calculate(context, bitStream, branch);
|
||||||
|
this->m_hitEnemyAction->Calculate(context, bitStream, branch);
|
||||||
|
this->m_hitEnemyAction->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,11 @@ public:
|
|||||||
Behavior* m_hitEnemyAction;
|
Behavior* m_hitEnemyAction;
|
||||||
|
|
||||||
Behavior* m_hitFactionAction;
|
Behavior* m_hitFactionAction;
|
||||||
|
|
||||||
|
float_t m_Duration;
|
||||||
|
float_t m_Forward;
|
||||||
|
float_t m_Left;
|
||||||
|
float_t m_Yaw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
@ -18,8 +23,12 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Calculate(BehaviorContext *context, RakNet::BitStream *bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void SyncCalculation(BehaviorContext *context, RakNet::BitStream *bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
void Load() override;
|
void Load() override;
|
||||||
|
@ -129,6 +129,9 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
|
|||||||
BaseCombatAIComponent::~BaseCombatAIComponent() {
|
BaseCombatAIComponent::~BaseCombatAIComponent() {
|
||||||
if (m_dpEntity)
|
if (m_dpEntity)
|
||||||
dpWorld::Instance().RemoveEntity(m_dpEntity);
|
dpWorld::Instance().RemoveEntity(m_dpEntity);
|
||||||
|
|
||||||
|
if (m_dpEntityEnemy)
|
||||||
|
dpWorld::Instance().RemoveEntity(m_dpEntityEnemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseCombatAIComponent::Update(const float deltaTime) {
|
void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||||
|
@ -769,26 +769,33 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
if (team != nullptr && m_Parent->GetComponent<BaseCombatAIComponent>() != nullptr)
|
if (team != nullptr && m_Parent->GetComponent<BaseCombatAIComponent>() != nullptr)
|
||||||
{
|
{
|
||||||
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
||||||
|
auto* scriptedActivityComponent = m_Parent->GetComponent<ScriptedActivityComponent>();
|
||||||
|
uint32_t teamSize = team->members.size();
|
||||||
|
uint32_t lootMatrixId = GetLootMatrixID();
|
||||||
|
|
||||||
if (team->lootOption == 0) // Round robin
|
if (scriptedActivityComponent) {
|
||||||
{
|
lootMatrixId = scriptedActivityComponent->GetLootMatrixForTeamSize(teamSize);
|
||||||
specificOwner = TeamManager::Instance()->GetNextLootOwner(team);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto memberId : team->members)
|
if (team->lootOption == 0) { // Round robin
|
||||||
{
|
specificOwner = TeamManager::Instance()->GetNextLootOwner(team);
|
||||||
if (specificOwner != LWOOBJID_EMPTY && memberId != specificOwner) continue;
|
|
||||||
|
|
||||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
||||||
|
|
||||||
if (member == nullptr) continue;
|
if (member) LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (const auto memberId : team->members) { // Free for all
|
||||||
|
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||||
|
|
||||||
Loot::DropLoot(member, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
if (member == nullptr) continue;
|
||||||
|
|
||||||
|
LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else { // drop loot for non team user
|
||||||
{
|
LootGenerator::Instance().DropLoot(owner, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||||
Loot::DropLoot(owner, m_Parent, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,7 +822,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
|
|
||||||
coinsTotal -= coinsToLoose;
|
coinsTotal -= coinsToLoose;
|
||||||
|
|
||||||
Loot::DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose);
|
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose);
|
||||||
}
|
}
|
||||||
|
|
||||||
character->SetCoins(coinsTotal);
|
character->SetCoins(coinsTotal);
|
||||||
|
@ -317,7 +317,9 @@ void RacingControlComponent::OnRequestDie(Entity *player) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
racingPlayer.smashedTimes++;
|
if (!racingPlayer.noSmashOnReload) {
|
||||||
|
racingPlayer.smashedTimes++;
|
||||||
|
}
|
||||||
|
|
||||||
// Reset player to last checkpoint
|
// Reset player to last checkpoint
|
||||||
GameMessages::SendRacingSetPlayerResetInfo(
|
GameMessages::SendRacingSetPlayerResetInfo(
|
||||||
@ -390,7 +392,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity *player,
|
|||||||
// Calculate the score, different loot depending on player count
|
// Calculate the score, different loot depending on player count
|
||||||
const auto score = m_LoadedPlayers * 10 + data->finished;
|
const auto score = m_LoadedPlayers * 10 + data->finished;
|
||||||
|
|
||||||
Loot::GiveActivityLoot(player, m_Parent, m_ActivityID, score);
|
LootGenerator::Instance().GiveActivityLoot(player, m_Parent, m_ActivityID, score);
|
||||||
|
|
||||||
// Giving rewards
|
// Giving rewards
|
||||||
GameMessages::SendNotifyRacingClient(
|
GameMessages::SendNotifyRacingClient(
|
||||||
|
@ -452,7 +452,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
|||||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ACTIVITY, m_ActivityId);
|
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ACTIVITY, m_ActivityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::DropActivityLoot(builder, m_Parent, m_ActivityId, 1);
|
LootGenerator::Instance().DropActivityLoot(builder, m_Parent, m_ActivityId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Builder = LWOOBJID_EMPTY;
|
m_Builder = LWOOBJID_EMPTY;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent)
|
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent)
|
||||||
{
|
{
|
||||||
@ -43,6 +44,31 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
|
if (destroyableComponent) {
|
||||||
|
// check for LMIs and set the loot LMIs
|
||||||
|
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
||||||
|
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) {return (entry.LootMatrixIndex == destroyableComponent->GetLootMatrixID()); });
|
||||||
|
|
||||||
|
uint32_t startingLMI = 0;
|
||||||
|
|
||||||
|
if (activityRewards.size() > 0) {
|
||||||
|
startingLMI = activityRewards[0].LootMatrixIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startingLMI > 0) {
|
||||||
|
// now time for bodge :)
|
||||||
|
|
||||||
|
std::vector<CDActivityRewards> objectTemplateActivities = activityRewardsTable->Query([=](CDActivityRewards entry) {return (activityRewards[0].objectTemplate == entry.objectTemplate); });
|
||||||
|
for (const auto& item : objectTemplateActivities) {
|
||||||
|
if (item.activityRating > 0 && item.activityRating < 5) {
|
||||||
|
m_ActivityLootMatrices.insert({ item.activityRating, item.LootMatrixIndex });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptedActivityComponent::~ScriptedActivityComponent()
|
ScriptedActivityComponent::~ScriptedActivityComponent()
|
||||||
@ -524,7 +550,7 @@ void ActivityInstance::RewardParticipant(Entity* participant) {
|
|||||||
maxCoins = currencyTable[0].maxvalue;
|
maxCoins = currencyTable[0].maxvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::DropLoot(participant, m_Parent, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
LootGenerator::Instance().DropLoot(participant, m_Parent, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +328,13 @@ public:
|
|||||||
* @param mapID the map ID to set
|
* @param mapID the map ID to set
|
||||||
*/
|
*/
|
||||||
void SetInstanceMapID(uint32_t mapID) { m_ActivityInfo.instanceMapID = mapID; };
|
void SetInstanceMapID(uint32_t mapID) { m_ActivityInfo.instanceMapID = mapID; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the LMI that this activity points to for a team size
|
||||||
|
* @param teamSize the team size to get the LMI for
|
||||||
|
* @return the LMI that this activity points to for a team size
|
||||||
|
*/
|
||||||
|
uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; }
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -349,6 +356,11 @@ private:
|
|||||||
* All the activity score for the players in this activity
|
* All the activity score for the players in this activity
|
||||||
*/
|
*/
|
||||||
std::vector<ActivityPlayer*> m_ActivityPlayers;
|
std::vector<ActivityPlayer*> m_ActivityPlayers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LMIs for team sizes
|
||||||
|
*/
|
||||||
|
std::unordered_map<uint32_t, uint32_t> m_ActivityLootMatrices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPTEDACTIVITYCOMPONENT_H
|
#endif // SCRIPTEDACTIVITYCOMPONENT_H
|
||||||
|
@ -333,14 +333,14 @@ bool Item::UseNonEquip()
|
|||||||
{
|
{
|
||||||
std::unordered_map<LOT, int32_t> result {};
|
std::unordered_map<LOT, int32_t> result {};
|
||||||
|
|
||||||
Loot::CalculateLootMatrix(pack.LootMatrixIndex, entityParent, result);
|
result = LootGenerator::Instance().RollLootMatrix(entityParent, pack.LootMatrixIndex);
|
||||||
|
|
||||||
if (!inventory->GetComponent()->HasSpaceForLoot(result))
|
if (!inventory->GetComponent()->HasSpaceForLoot(result))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::GiveLoot(inventory->GetComponent()->GetParent(), result);
|
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||||
|
@ -1,384 +1,389 @@
|
|||||||
#include "Loot.h"
|
|
||||||
#include "GameMessages.h"
|
|
||||||
|
|
||||||
#include "CDClientManager.h"
|
|
||||||
#include "CDLootMatrixTable.h"
|
|
||||||
#include "CDLootTableTable.h"
|
|
||||||
|
|
||||||
#include "SimplePhysicsComponent.h"
|
|
||||||
#include "ControllablePhysicsComponent.h"
|
|
||||||
#include "DestroyableComponent.h"
|
|
||||||
#include "MissionComponent.h"
|
|
||||||
#include "CharacterComponent.h"
|
|
||||||
#include "TeamManager.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
std::vector<CDLootTable> Loot::GetLootOfRarity(const std::vector<CDLootTable> &lootTable, uint32_t rarity) {
|
#include "Loot.h"
|
||||||
std::vector<CDLootTable> refinedLoot;
|
|
||||||
for (auto loot : lootTable) {
|
|
||||||
CDItemComponent item = Inventory::FindItemComponent(loot.itemid);
|
|
||||||
if (item.rarity == rarity) {
|
|
||||||
refinedLoot.push_back(loot);
|
|
||||||
}
|
|
||||||
else if (item.rarity == 0) {
|
|
||||||
refinedLoot.push_back(loot); // powerups
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return refinedLoot;
|
#include "CDComponentsRegistryTable.h"
|
||||||
|
#include "CDItemComponentTable.h"
|
||||||
|
#include "CDLootMatrixTable.h"
|
||||||
|
#include "CDLootTableTable.h"
|
||||||
|
#include "CDRarityTableTable.h"
|
||||||
|
#include "Character.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
#include "GeneralUtils.h"
|
||||||
|
#include "InventoryComponent.h"
|
||||||
|
#include "MissionComponent.h"
|
||||||
|
|
||||||
|
LootGenerator::LootGenerator() {
|
||||||
|
CDLootTableTable* lootTableTable = CDClientManager::Instance()->GetTable<CDLootTableTable>("LootTable");
|
||||||
|
CDComponentsRegistryTable* componentsRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||||
|
CDItemComponentTable* itemComponentTable = CDClientManager::Instance()->GetTable<CDItemComponentTable>("ItemComponent");
|
||||||
|
CDLootMatrixTable* lootMatrixTable = CDClientManager::Instance()->GetTable<CDLootMatrixTable>("LootMatrix");
|
||||||
|
CDRarityTableTable* rarityTableTable = CDClientManager::Instance()->GetTable<CDRarityTableTable>("RarityTable");
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// Cache Item Rarities
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
std::vector<uint32_t> uniqueItems;
|
||||||
|
|
||||||
|
for (const CDLootTable& loot : lootTableTable->GetEntries()) {
|
||||||
|
uniqueItems.push_back(loot.itemid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out duplicates
|
||||||
|
std::sort(uniqueItems.begin(), uniqueItems.end());
|
||||||
|
uniqueItems.erase(std::unique(uniqueItems.begin(), uniqueItems.end()), uniqueItems.end());
|
||||||
|
|
||||||
|
for (const uint32_t itemID : uniqueItems) {
|
||||||
|
uint32_t itemComponentID = componentsRegistryTable->GetByIDAndType(itemID, COMPONENT_TYPE_ITEM);
|
||||||
|
const CDItemComponent& item = itemComponentTable->GetItemComponentByID(itemComponentID);
|
||||||
|
|
||||||
|
m_ItemRarities.insert({itemID, item.rarity});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// Cache Rarity Tables
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
std::vector<uint32_t> uniqueRarityIndices;
|
||||||
|
|
||||||
|
for (const CDRarityTable& rarity : rarityTableTable->GetEntries()) {
|
||||||
|
uniqueRarityIndices.push_back(rarity.RarityTableIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out duplicates
|
||||||
|
std::sort(uniqueRarityIndices.begin(), uniqueRarityIndices.end());
|
||||||
|
uniqueRarityIndices.erase(std::unique(uniqueRarityIndices.begin(), uniqueRarityIndices.end()), uniqueRarityIndices.end());
|
||||||
|
|
||||||
|
for (const uint32_t index : uniqueRarityIndices) {
|
||||||
|
std::vector<CDRarityTable> table = rarityTableTable->Query([index](const CDRarityTable& entry) { return entry.RarityTableIndex == index; });
|
||||||
|
|
||||||
|
RarityTable rarityTable;
|
||||||
|
|
||||||
|
for (const CDRarityTable& entry : table) {
|
||||||
|
RarityTableEntry rarity{entry.rarity, entry.randmax};
|
||||||
|
rarityTable.push_back(rarity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort in descending order based on randMax
|
||||||
|
std::sort(rarityTable.begin(), rarityTable.end(), [](const RarityTableEntry& x, const RarityTableEntry& y) { return x.randMax > y.randMax; });
|
||||||
|
|
||||||
|
m_RarityTables.insert({index, rarityTable});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// Cache Loot Matrices
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
std::vector<uint32_t> uniqueMatrixIndices;
|
||||||
|
|
||||||
|
for (const CDLootMatrix& matrix : lootMatrixTable->GetEntries()) {
|
||||||
|
uniqueMatrixIndices.push_back(matrix.LootMatrixIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out duplicates
|
||||||
|
std::sort(uniqueMatrixIndices.begin(), uniqueMatrixIndices.end());
|
||||||
|
uniqueMatrixIndices.erase(std::unique(uniqueMatrixIndices.begin(), uniqueMatrixIndices.end()), uniqueMatrixIndices.end());
|
||||||
|
|
||||||
|
for (const uint32_t index : uniqueMatrixIndices) {
|
||||||
|
std::vector<CDLootMatrix> matrix = lootMatrixTable->Query([index](const CDLootMatrix& entry) { return entry.LootMatrixIndex == index; });
|
||||||
|
|
||||||
|
LootMatrix lootMatrix;
|
||||||
|
|
||||||
|
for (const CDLootMatrix& entry : matrix) {
|
||||||
|
LootMatrixEntry matrixEntry{entry.LootTableIndex, entry.RarityTableIndex, entry.percent, entry.minToDrop, entry.maxToDrop};
|
||||||
|
lootMatrix.push_back(matrixEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_LootMatrices.insert({index, lootMatrix});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================
|
||||||
|
// Cache Loot Tables
|
||||||
|
// ==============================
|
||||||
|
|
||||||
|
std::vector<uint32_t> uniqueTableIndices;
|
||||||
|
|
||||||
|
for (const CDLootTable& entry : lootTableTable->GetEntries()) {
|
||||||
|
uniqueTableIndices.push_back(entry.LootTableIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out duplicates
|
||||||
|
std::sort(uniqueTableIndices.begin(), uniqueTableIndices.end());
|
||||||
|
uniqueTableIndices.erase(std::unique(uniqueTableIndices.begin(), uniqueTableIndices.end()), uniqueTableIndices.end());
|
||||||
|
|
||||||
|
for (const uint32_t index : uniqueTableIndices) {
|
||||||
|
std::vector<CDLootTable> entries = lootTableTable->Query([index](const CDLootTable& entry) { return entry.LootTableIndex == index; });
|
||||||
|
|
||||||
|
LootTable lootTable;
|
||||||
|
|
||||||
|
for (const CDLootTable& entry : entries) {
|
||||||
|
LootTableEntry tableEntry{(LOT)entry.itemid, entry.MissionDrop};
|
||||||
|
lootTable.push_back(tableEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort by item rarity descending
|
||||||
|
std::sort(lootTable.begin(), lootTable.end(), [&](const LootTableEntry& x, const LootTableEntry& y) {
|
||||||
|
return m_ItemRarities[x.itemID] > m_ItemRarities[y.itemID];
|
||||||
|
});
|
||||||
|
|
||||||
|
m_LootTables.insert({index, lootTable});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::GiveLoot(Entity* user, uint32_t lootMatrixID) {
|
std::unordered_map<LOT, int32_t> LootGenerator::RollLootMatrix(Entity* player, uint32_t matrixIndex) {
|
||||||
user = user->GetOwner(); // If the owner is overwritten, we collect that here
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
std::unordered_map<LOT, int32_t> result {};
|
std::unordered_map<LOT, int32_t> drops;
|
||||||
|
|
||||||
CalculateLootMatrix(lootMatrixID, user, result);
|
if (missionComponent == nullptr) {
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
|
|
||||||
GiveLoot(user, result);
|
const LootMatrix& matrix = m_LootMatrices[matrixIndex];
|
||||||
|
|
||||||
|
for (const LootMatrixEntry& entry : matrix) {
|
||||||
|
if (GeneralUtils::GenerateRandomNumber<float>(0, 1) < entry.percent) {
|
||||||
|
const LootTable& lootTable = m_LootTables[entry.lootTableIndex];
|
||||||
|
const RarityTable& rarityTable = m_RarityTables[entry.rarityTableIndex];
|
||||||
|
|
||||||
|
uint32_t dropCount = GeneralUtils::GenerateRandomNumber<uint32_t>(entry.minDrop, entry.maxDrop);
|
||||||
|
for (uint32_t i = 0; i < dropCount; ++i) {
|
||||||
|
uint32_t maxRarity = 1;
|
||||||
|
|
||||||
|
float rarityRoll = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
||||||
|
|
||||||
|
for (const RarityTableEntry& rarity : rarityTable) {
|
||||||
|
if (rarity.randMax >= rarityRoll) {
|
||||||
|
maxRarity = rarity.rarity;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rarityFound = false;
|
||||||
|
std::vector<LootTableEntry> possibleDrops;
|
||||||
|
|
||||||
|
for (const LootTableEntry& loot : lootTable) {
|
||||||
|
uint32_t rarity = m_ItemRarities[loot.itemID];
|
||||||
|
|
||||||
|
if (rarity == maxRarity) {
|
||||||
|
possibleDrops.push_back(loot);
|
||||||
|
rarityFound = true;
|
||||||
|
} else if (rarity < maxRarity && !rarityFound) {
|
||||||
|
possibleDrops.push_back(loot);
|
||||||
|
maxRarity = rarity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (possibleDrops.size() > 0) {
|
||||||
|
LootTableEntry drop = possibleDrops[GeneralUtils::GenerateRandomNumber<uint32_t>(0, possibleDrops.size() - 1)];
|
||||||
|
|
||||||
|
// filter out uneeded mission items
|
||||||
|
if (drop.isMissionDrop && !missionComponent->RequiresItem(drop.itemID))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// convert faction token proxy
|
||||||
|
if (drop.itemID == 13763) {
|
||||||
|
if (missionComponent->GetMissionState(545) == MissionState::MISSION_STATE_COMPLETE)
|
||||||
|
drop.itemID = 8318; // "Assembly Token"
|
||||||
|
else if (missionComponent->GetMissionState(556) == MissionState::MISSION_STATE_COMPLETE)
|
||||||
|
drop.itemID = 8321; // "Venture League Token"
|
||||||
|
else if (missionComponent->GetMissionState(567) == MissionState::MISSION_STATE_COMPLETE)
|
||||||
|
drop.itemID = 8319; // "Sentinels Token"
|
||||||
|
else if (missionComponent->GetMissionState(578) == MissionState::MISSION_STATE_COMPLETE)
|
||||||
|
drop.itemID = 8320; // "Paradox Token"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drop.itemID == 13763) {
|
||||||
|
continue;
|
||||||
|
} // check if we aren't in faction
|
||||||
|
|
||||||
|
if (drops.find(drop.itemID) == drops.end()) {
|
||||||
|
drops.insert({drop.itemID, 1});
|
||||||
|
} else {
|
||||||
|
++drops[drop.itemID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::DropLoot(Entity* user, Entity* killedObject, uint32_t lootMatrixID, uint32_t minCoins, uint32_t maxCoins) {
|
std::unordered_map<LOT, int32_t> LootGenerator::RollLootMatrix(uint32_t matrixIndex) {
|
||||||
user = user->GetOwner(); // If the owner is overwritten, we collect that here
|
std::unordered_map<LOT, int32_t> drops;
|
||||||
|
|
||||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
const LootMatrix& matrix = m_LootMatrices[matrixIndex];
|
||||||
|
|
||||||
if (inventoryComponent == nullptr) {
|
for (const LootMatrixEntry& entry : matrix) {
|
||||||
return;
|
if (GeneralUtils::GenerateRandomNumber<float>(0, 1) < entry.percent) {
|
||||||
}
|
const LootTable& lootTable = m_LootTables[entry.lootTableIndex];
|
||||||
|
const RarityTable& rarityTable = m_RarityTables[entry.rarityTableIndex];
|
||||||
|
|
||||||
std::unordered_map<LOT, int32_t> result {};
|
uint32_t dropCount = GeneralUtils::GenerateRandomNumber<uint32_t>(entry.minDrop, entry.maxDrop);
|
||||||
|
for (uint32_t i = 0; i < dropCount; ++i) {
|
||||||
|
uint32_t maxRarity = 1;
|
||||||
|
|
||||||
CalculateLootMatrix(lootMatrixID, user, result);
|
float rarityRoll = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
||||||
|
|
||||||
DropLoot(user, killedObject, result, minCoins, maxCoins);
|
for (const RarityTableEntry& rarity : rarityTable) {
|
||||||
|
if (rarity.randMax >= rarityRoll) {
|
||||||
|
maxRarity = rarity.rarity;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rarityFound = false;
|
||||||
|
std::vector<LootTableEntry> possibleDrops;
|
||||||
|
|
||||||
|
for (const LootTableEntry& loot : lootTable) {
|
||||||
|
uint32_t rarity = m_ItemRarities[loot.itemID];
|
||||||
|
|
||||||
|
if (rarity == maxRarity) {
|
||||||
|
possibleDrops.push_back(loot);
|
||||||
|
rarityFound = true;
|
||||||
|
} else if (rarity < maxRarity && !rarityFound) {
|
||||||
|
possibleDrops.push_back(loot);
|
||||||
|
maxRarity = rarity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (possibleDrops.size() > 0) {
|
||||||
|
const LootTableEntry& drop = possibleDrops[GeneralUtils::GenerateRandomNumber<uint32_t>(0, possibleDrops.size() - 1)];
|
||||||
|
|
||||||
|
if (drops.find(drop.itemID) == drops.end()) {
|
||||||
|
drops.insert({drop.itemID, 1});
|
||||||
|
} else {
|
||||||
|
++drops[drop.itemID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::GiveLoot(Entity* user, std::unordered_map<LOT, int32_t>& result) {
|
void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex) {
|
||||||
user = user->GetOwner(); // If the owner is overwritten, we collect that here
|
player = player->GetOwner(); // If the owner is overwritten, we collect that here
|
||||||
|
|
||||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
std::unordered_map<LOT, int32_t> result = RollLootMatrix(player, matrixIndex);
|
||||||
|
|
||||||
if (inventoryComponent == nullptr) {
|
GiveLoot(player, result);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& pair : result) {
|
|
||||||
inventoryComponent->AddItem(pair.first, pair.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::DropLoot(Entity* user, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins) {
|
void LootGenerator::GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result) {
|
||||||
user = user->GetOwner(); // If the owner is overwritten, we collect that here
|
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||||
|
|
||||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||||
|
|
||||||
if (inventoryComponent == nullptr) {
|
if (!inventoryComponent)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const auto spawnPosition = killedObject->GetPosition();
|
for (const auto& pair : result) {
|
||||||
|
inventoryComponent->AddItem(pair.first, pair.second);
|
||||||
const auto source = killedObject->GetObjectID();
|
}
|
||||||
|
|
||||||
for (const auto& pair : result) {
|
|
||||||
for (int i = 0; i < pair.second; ++i) {
|
|
||||||
GameMessages::SendDropClientLoot(user, source, pair.first, 0, spawnPosition, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
|
||||||
|
|
||||||
GameMessages::SendDropClientLoot(user, source, LOT_NULL, coins, spawnPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::DropActivityLoot(Entity* user, Entity* source, uint32_t activityID, int32_t rating)
|
void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating) {
|
||||||
{
|
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
||||||
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([activityID](CDActivityRewards entry) { return (entry.objectTemplate == activityID); });
|
||||||
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) { return (entry.objectTemplate == activityID); });
|
|
||||||
|
|
||||||
const CDActivityRewards* selectedReward = nullptr;
|
const CDActivityRewards* selectedReward = nullptr;
|
||||||
for (const auto& activityReward : activityRewards)
|
for (const auto& activityReward : activityRewards) {
|
||||||
{
|
if (activityReward.activityRating <= rating && (selectedReward == nullptr || activityReward.activityRating > selectedReward->activityRating)) {
|
||||||
if (activityReward.activityRating <= rating && (selectedReward == nullptr || activityReward.activityRating > selectedReward->activityRating))
|
selectedReward = &activityReward;
|
||||||
{
|
}
|
||||||
selectedReward = &activityReward;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedReward == nullptr)
|
if (!selectedReward)
|
||||||
{
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t minCoins = 0;
|
uint32_t minCoins = 0;
|
||||||
uint32_t maxCoins = 0;
|
uint32_t maxCoins = 0;
|
||||||
|
|
||||||
CDCurrencyTableTable* currencyTableTable = CDClientManager::Instance()->GetTable<CDCurrencyTableTable>("CurrencyTable");
|
CDCurrencyTableTable* currencyTableTable = CDClientManager::Instance()->GetTable<CDCurrencyTableTable>("CurrencyTable");
|
||||||
std::vector<CDCurrencyTable> currencyTable = currencyTableTable->Query([=](CDCurrencyTable entry) { return (entry.currencyIndex == selectedReward->CurrencyIndex && entry.npcminlevel == 1); });
|
std::vector<CDCurrencyTable> currencyTable = currencyTableTable->Query([selectedReward](CDCurrencyTable entry) { return (entry.currencyIndex == selectedReward->CurrencyIndex && entry.npcminlevel == 1); });
|
||||||
|
|
||||||
if (currencyTable.size() > 0) {
|
if (currencyTable.size() > 0) {
|
||||||
minCoins = currencyTable[0].minvalue;
|
minCoins = currencyTable[0].minvalue;
|
||||||
maxCoins = currencyTable[0].maxvalue;
|
maxCoins = currencyTable[0].maxvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::DropLoot(user, source, selectedReward->LootMatrixIndex, minCoins, maxCoins);
|
GiveLoot(player, selectedReward->LootMatrixIndex);
|
||||||
|
|
||||||
|
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||||
|
|
||||||
|
auto* character = player->GetCharacter();
|
||||||
|
|
||||||
|
character->SetCoins(character->GetCoins() + coins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::GiveActivityLoot(Entity* user, Entity* source, uint32_t activityID, int32_t rating)
|
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||||
{
|
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||||
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
|
||||||
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) { return (entry.objectTemplate == activityID); });
|
|
||||||
|
|
||||||
const CDActivityRewards* selectedReward = nullptr;
|
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||||
for (const auto& activityReward : activityRewards)
|
|
||||||
{
|
|
||||||
if (activityReward.activityRating <= rating && (selectedReward == nullptr || activityReward.activityRating > selectedReward->activityRating))
|
|
||||||
{
|
|
||||||
selectedReward = &activityReward;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedReward == nullptr)
|
if (!inventoryComponent)
|
||||||
{
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t minCoins = 0;
|
std::unordered_map<LOT, int32_t> result = RollLootMatrix(player, matrixIndex);
|
||||||
uint32_t maxCoins = 0;
|
|
||||||
|
|
||||||
CDCurrencyTableTable* currencyTableTable = CDClientManager::Instance()->GetTable<CDCurrencyTableTable>("CurrencyTable");
|
DropLoot(player, killedObject, result, minCoins, maxCoins);
|
||||||
std::vector<CDCurrencyTable> currencyTable = currencyTableTable->Query([=](CDCurrencyTable entry) { return (entry.currencyIndex == selectedReward->CurrencyIndex && entry.npcminlevel == 1); });
|
|
||||||
|
|
||||||
if (currencyTable.size() > 0) {
|
|
||||||
minCoins = currencyTable[0].minvalue;
|
|
||||||
maxCoins = currencyTable[0].maxvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Loot::GiveLoot(user, selectedReward->LootMatrixIndex);
|
|
||||||
|
|
||||||
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
|
||||||
|
|
||||||
auto* charactert = user->GetCharacter();
|
|
||||||
|
|
||||||
charactert->SetCoins(charactert->GetCoins() + coins);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::CalculateLootMatrix(uint32_t lootMatrixID, Entity* user, std::unordered_map<LOT, int32_t>& result)
|
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins) {
|
||||||
{
|
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||||
user = user->GetOwner();
|
|
||||||
|
|
||||||
auto* missionComponent = user->GetComponent<MissionComponent>();
|
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||||
|
|
||||||
// Get our loot for this LOT's lootMatrixID:
|
if (!inventoryComponent)
|
||||||
CDLootMatrixTable* lootMatrixTable = CDClientManager::Instance()->GetTable<CDLootMatrixTable>("LootMatrix");
|
return;
|
||||||
CDLootTableTable* lootTableTable = CDClientManager::Instance()->GetTable<CDLootTableTable>("LootTable");
|
|
||||||
CDRarityTableTable* rarityTableTable = CDClientManager::Instance()->GetTable<CDRarityTableTable>("RarityTable");
|
|
||||||
|
|
||||||
std::vector<CDLootMatrix> lootMatrix = lootMatrixTable->Query([lootMatrixID](CDLootMatrix entry) { return (entry.LootMatrixIndex == lootMatrixID); });
|
const auto spawnPosition = killedObject->GetPosition();
|
||||||
|
|
||||||
// Now, loop through each entry
|
const auto source = killedObject->GetObjectID();
|
||||||
for (uint32_t i = 0; i < lootMatrix.size(); ++i) {
|
|
||||||
// Now, determine whether or not we should drop this
|
|
||||||
float chanceToDrop = 1.0 - lootMatrix[i].percent;
|
|
||||||
float shouldDrop = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
|
||||||
|
|
||||||
const auto rarityTableIndex = lootMatrix[i].RarityTableIndex;
|
for (const auto& pair : result) {
|
||||||
|
for (int i = 0; i < pair.second; ++i) {
|
||||||
|
GameMessages::SendDropClientLoot(player, source, pair.first, 0, spawnPosition, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<CDRarityTable> rarityTable = rarityTableTable->Query([rarityTableIndex](CDRarityTable entry) { return (entry.RarityTableIndex == rarityTableIndex); });
|
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||||
|
|
||||||
std::sort(rarityTable.begin(), rarityTable.end());
|
|
||||||
|
|
||||||
if (shouldDrop < chanceToDrop) {
|
GameMessages::SendDropClientLoot(player, source, LOT_NULL, coins, spawnPosition);
|
||||||
// We are not able to drop this item, so continue
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we reached here, we are able to drop the item
|
|
||||||
uint32_t minToDrop = lootMatrix[i].minToDrop;
|
|
||||||
uint32_t maxToDrop = lootMatrix[i].maxToDrop;
|
|
||||||
|
|
||||||
// Now determine the number we will drop of items from this table
|
|
||||||
uint32_t numToDrop = GeneralUtils::GenerateRandomNumber<uint32_t>(minToDrop, maxToDrop);
|
|
||||||
|
|
||||||
// Now, query the loot matrix index
|
|
||||||
const auto lootTableIndex = lootMatrix[i].LootTableIndex;
|
|
||||||
|
|
||||||
std::vector<CDLootTable> lootTable = lootTableTable->Query([lootTableIndex](CDLootTable entry) { return (entry.LootTableIndex == lootTableIndex); });
|
|
||||||
|
|
||||||
// Now randomize these entries
|
|
||||||
if (lootTable.size() > 1) {
|
|
||||||
std::shuffle(std::begin(lootTable), std::end(lootTable), Game::randomEngine);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t addedItems = 0;
|
|
||||||
|
|
||||||
if (lootTable.empty()) continue;
|
|
||||||
|
|
||||||
while (addedItems < numToDrop) {
|
|
||||||
addedItems++;
|
|
||||||
|
|
||||||
float rarityRoll = GeneralUtils::GenerateRandomNumber<float>(0, 1);
|
|
||||||
|
|
||||||
// im sorry
|
|
||||||
uint32_t highestRarity = 1; // LOOT_COMMON
|
|
||||||
float highestRandMax = 0.0f;
|
|
||||||
for (const auto& rarity : rarityTable) {
|
|
||||||
if (rarityRoll > rarity.randmax && rarity.randmax > highestRandMax) {
|
|
||||||
highestRandMax = rarity.randmax;
|
|
||||||
highestRarity = rarity.rarity + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<CDLootTable> refinedLoot;
|
|
||||||
|
|
||||||
if (lootTable.size() == 1)
|
|
||||||
{
|
|
||||||
refinedLoot = lootTable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
refinedLoot = GetLootOfRarity(lootTable, highestRarity);
|
|
||||||
|
|
||||||
bool continueLoop = false;
|
|
||||||
while (refinedLoot.empty())
|
|
||||||
{
|
|
||||||
if (highestRarity == 1)
|
|
||||||
{
|
|
||||||
continueLoop = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
highestRarity -= 1;
|
|
||||||
|
|
||||||
refinedLoot = GetLootOfRarity(lootTable, highestRarity);
|
|
||||||
|
|
||||||
if (!refinedLoot.empty())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (continueLoop) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int randomTable = GeneralUtils::GenerateRandomNumber<int>(0, refinedLoot.size() - 1);
|
|
||||||
|
|
||||||
const auto& selectedTable = refinedLoot[randomTable];
|
|
||||||
|
|
||||||
uint32_t itemLOT = selectedTable.itemid;
|
|
||||||
bool isMissionItem = selectedTable.MissionDrop;
|
|
||||||
|
|
||||||
if (isMissionItem && missionComponent != nullptr)
|
|
||||||
{
|
|
||||||
// TODO: this executes a query in a hot path, might be worth refactoring away
|
|
||||||
if (!missionComponent->RequiresItem(itemLOT))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lootTable.size() > numToDrop)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < lootTable.size(); i++)
|
|
||||||
{
|
|
||||||
if (lootTable[i].id == selectedTable.id)
|
|
||||||
{
|
|
||||||
lootTable.erase(lootTable.begin() + i);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& it = result.find(itemLOT);
|
|
||||||
if (it != result.end()) {
|
|
||||||
it->second++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result.emplace(itemLOT, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tokenCount = 0;
|
|
||||||
|
|
||||||
const auto& tokens = result.find(13763);
|
|
||||||
|
|
||||||
if (tokens != result.end()) {
|
|
||||||
tokenCount = tokens->second;
|
|
||||||
|
|
||||||
result.erase(tokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tokenCount == 0 || user == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missionComponent == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOT tokenId = -1;
|
|
||||||
|
|
||||||
if (missionComponent->GetMissionState(545) == MissionState::MISSION_STATE_COMPLETE) // "Join Assembly!"
|
|
||||||
{
|
|
||||||
tokenId = 8318; // "Assembly Token"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missionComponent->GetMissionState(556) == MissionState::MISSION_STATE_COMPLETE) // "Join Venture League!"
|
|
||||||
{
|
|
||||||
tokenId = 8321; // "Venture League Token"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missionComponent->GetMissionState(567) == MissionState::MISSION_STATE_COMPLETE) // "Join The Sentinels!"
|
|
||||||
{
|
|
||||||
tokenId = 8319; // "Sentinels Token"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missionComponent->GetMissionState(578) == MissionState::MISSION_STATE_COMPLETE) // "Join Paradox!"
|
|
||||||
{
|
|
||||||
tokenId = 8320; // "Paradox Token"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tokenId != -1)
|
|
||||||
{
|
|
||||||
result.emplace(tokenId, tokenCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::DropItem(Entity* user, Entity* sourceObject, LOT item, int32_t currency, int32_t count, bool useTeam, bool freeForAll)
|
void LootGenerator::DropActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating) {
|
||||||
{
|
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance()->GetTable<CDActivityRewardsTable>("ActivityRewards");
|
||||||
if (sourceObject == nullptr)
|
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([activityID](CDActivityRewards entry) { return (entry.objectTemplate == activityID); });
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto sourceID = sourceObject->GetObjectID();
|
const CDActivityRewards* selectedReward = nullptr;
|
||||||
const auto sourcePosition = sourceObject->GetPosition();
|
for (const auto& activityReward : activityRewards) {
|
||||||
|
if (activityReward.activityRating <= rating && (selectedReward == nullptr || activityReward.activityRating > selectedReward->activityRating)) {
|
||||||
|
selectedReward = &activityReward;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If useTeam, drop the item once for each team member.
|
if (selectedReward == nullptr) {
|
||||||
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (team != nullptr && useTeam)
|
uint32_t minCoins = 0;
|
||||||
{
|
uint32_t maxCoins = 0;
|
||||||
for (const auto& memberID : team->members)
|
|
||||||
{
|
|
||||||
// Get the team member from its ID.
|
|
||||||
auto* member = EntityManager::Instance()->GetEntity(memberID);
|
|
||||||
|
|
||||||
if (member == nullptr)
|
CDCurrencyTableTable* currencyTableTable = CDClientManager::Instance()->GetTable<CDCurrencyTableTable>("CurrencyTable");
|
||||||
{
|
std::vector<CDCurrencyTable> currencyTable = currencyTableTable->Query([selectedReward](CDCurrencyTable entry) { return (entry.currencyIndex == selectedReward->CurrencyIndex && entry.npcminlevel == 1); });
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the item.
|
if (currencyTable.size() > 0) {
|
||||||
GameMessages::SendDropClientLoot(member, sourceID, item, currency, sourcePosition, count);
|
minCoins = currencyTable[0].minvalue;
|
||||||
}
|
maxCoins = currencyTable[0].maxvalue;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
DropLoot(player, source, selectedReward->LootMatrixIndex, minCoins, maxCoins);
|
||||||
}
|
|
||||||
|
|
||||||
GameMessages::SendDropClientLoot(user, sourceID, item, currency, sourcePosition, count);
|
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,62 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
|
#include <unordered_map>
|
||||||
|
#include "Singleton.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "CDClientManager.h"
|
|
||||||
class Entity;
|
class Entity;
|
||||||
|
|
||||||
|
struct RarityTableEntry {
|
||||||
|
uint32_t rarity;
|
||||||
|
float randMax;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<RarityTableEntry> RarityTable;
|
||||||
|
|
||||||
|
struct LootMatrixEntry {
|
||||||
|
uint32_t lootTableIndex;
|
||||||
|
uint32_t rarityTableIndex;
|
||||||
|
float percent;
|
||||||
|
uint32_t minDrop;
|
||||||
|
uint32_t maxDrop;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<LootMatrixEntry> LootMatrix;
|
||||||
|
|
||||||
|
struct LootTableEntry {
|
||||||
|
LOT itemID;
|
||||||
|
bool isMissionDrop;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<LootTableEntry> LootTable;
|
||||||
|
|
||||||
|
// used for glue code with Entity and Player classes
|
||||||
namespace Loot {
|
namespace Loot {
|
||||||
struct Info {
|
struct Info {
|
||||||
LWOOBJID id;
|
LWOOBJID id;
|
||||||
LOT lot;
|
LOT lot;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<CDLootTable> GetLootOfRarity(const std::vector<CDLootTable> &lootTable, uint32_t rarity);
|
|
||||||
|
|
||||||
void DropActivityLoot(Entity* user, Entity* source, uint32_t activityID, int32_t rating = 0);
|
class LootGenerator : public Singleton<LootGenerator> {
|
||||||
|
public:
|
||||||
|
LootGenerator();
|
||||||
|
|
||||||
void GiveActivityLoot(Entity* user, Entity* source, uint32_t activityID, int32_t rating = 0);
|
std::unordered_map<LOT, int32_t> RollLootMatrix(Entity* player, uint32_t matrixIndex);
|
||||||
|
std::unordered_map<LOT, int32_t> RollLootMatrix(uint32_t matrixIndex);
|
||||||
|
void GiveLoot(Entity* player, uint32_t matrixIndex);
|
||||||
|
void GiveLoot(Entity* player, std::unordered_map<LOT, int32_t>& result);
|
||||||
|
void GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0);
|
||||||
|
void DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins);
|
||||||
|
void DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins);
|
||||||
|
void DropActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0);
|
||||||
|
|
||||||
void CalculateLootMatrix(uint32_t lootMatrixID, Entity* user, std::unordered_map<LOT, int32_t>& result);
|
private:
|
||||||
|
std::unordered_map<uint32_t, uint8_t> m_ItemRarities;
|
||||||
void GiveLoot(Entity* user, uint32_t lootMatrixID);
|
std::unordered_map<uint32_t, RarityTable> m_RarityTables;
|
||||||
|
std::unordered_map<uint32_t, LootMatrix> m_LootMatrices;
|
||||||
void DropLoot(Entity* user, Entity* killedObject, uint32_t lootMatrixID, uint32_t minCoins, uint32_t maxCoins);
|
std::unordered_map<uint32_t, LootTable> m_LootTables;
|
||||||
|
};
|
||||||
void GiveLoot(Entity* user, std::unordered_map<LOT, int32_t>& result);
|
|
||||||
|
|
||||||
void DropLoot(Entity* user, Entity* killedObject, std::unordered_map<LOT, int32_t>& result, uint32_t minCoins, uint32_t maxCoins);
|
|
||||||
|
|
||||||
void DropItem(Entity* user, Entity* sourceObject, LOT item, int32_t currency, int32_t count, bool useTeam = false, bool freeForAll = false);
|
|
||||||
};
|
|
||||||
|
@ -407,7 +407,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
stmt->execute();
|
stmt->execute();
|
||||||
delete stmt;
|
delete stmt;
|
||||||
|
|
||||||
if (chatCommand == "setMinifig" && args.size() == 2 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_FORUM_MODERATOR) { // could break characters so only allow if GM > 0
|
if (chatCommand == "setminifig" && args.size() == 2 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_FORUM_MODERATOR) { // could break characters so only allow if GM > 0
|
||||||
int32_t minifigItemId;
|
int32_t minifigItemId;
|
||||||
if (!GeneralUtils::TryParse(args[1], minifigItemId)) {
|
if (!GeneralUtils::TryParse(args[1], minifigItemId)) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
|
||||||
@ -434,7 +434,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
charComp->m_Character->SetMouth(minifigItemId);
|
charComp->m_Character->SetMouth(minifigItemId);
|
||||||
} else if (lowerName == "righthand") {
|
} else if (lowerName == "righthand") {
|
||||||
charComp->m_Character->SetRightHand(minifigItemId);
|
charComp->m_Character->SetRightHand(minifigItemId);
|
||||||
} else if (lowerName == "shirt") {
|
} else if (lowerName == "shirtcolor") {
|
||||||
charComp->m_Character->SetShirtColor(minifigItemId);
|
charComp->m_Character->SetShirtColor(minifigItemId);
|
||||||
} else if (lowerName == "hands") {
|
} else if (lowerName == "hands") {
|
||||||
charComp->m_Character->SetLeftHand(minifigItemId);
|
charComp->m_Character->SetLeftHand(minifigItemId);
|
||||||
@ -1691,6 +1691,43 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatCommand == "rollloot" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && args.size() >= 3) {
|
||||||
|
uint32_t lootMatrixIndex = 0;
|
||||||
|
uint32_t targetLot = 0;
|
||||||
|
uint32_t loops = 1;
|
||||||
|
|
||||||
|
if (!GeneralUtils::TryParse(args[0], lootMatrixIndex)) return;
|
||||||
|
if (!GeneralUtils::TryParse(args[1], targetLot)) return;
|
||||||
|
if (!GeneralUtils::TryParse(args[2], loops)) return;
|
||||||
|
|
||||||
|
uint64_t totalRuns = 0;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < loops; i++) {
|
||||||
|
while (true) {
|
||||||
|
auto lootRoll = LootGenerator::Instance().RollLootMatrix(lootMatrixIndex);
|
||||||
|
totalRuns += 1;
|
||||||
|
bool doBreak = false;
|
||||||
|
for (const auto& kv : lootRoll) {
|
||||||
|
if ((uint32_t)kv.first == targetLot) {
|
||||||
|
doBreak = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (doBreak) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::u16string message = u"Ran loot drops looking for "
|
||||||
|
+ GeneralUtils::to_u16string(targetLot)
|
||||||
|
+ u", "
|
||||||
|
+ GeneralUtils::to_u16string(loops)
|
||||||
|
+ u" times. It ran "
|
||||||
|
+ GeneralUtils::to_u16string(totalRuns)
|
||||||
|
+ u" times. Averaging out at "
|
||||||
|
+ GeneralUtils::to_u16string((float) totalRuns / loops);
|
||||||
|
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, message);
|
||||||
|
}
|
||||||
|
|
||||||
if (chatCommand == "inspect" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1)
|
if (chatCommand == "inspect" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1)
|
||||||
{
|
{
|
||||||
Entity* closest = nullptr;
|
Entity* closest = nullptr;
|
||||||
|
@ -43,7 +43,8 @@ Instance * InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, L
|
|||||||
maxPlayers = GetHardCap(mapID);
|
maxPlayers = GetHardCap(mapID);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = new Instance(mExternalIP, ++m_LastPort, mapID, ++m_LastInstanceID, cloneID, softCap, maxPlayers);
|
uint32_t port = GetFreePort();
|
||||||
|
instance = new Instance(mExternalIP, port, mapID, ++m_LastInstanceID, cloneID, softCap, maxPlayers);
|
||||||
|
|
||||||
//Start the actual process:
|
//Start the actual process:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -59,7 +60,7 @@ Instance * InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, L
|
|||||||
|
|
||||||
cmd.append(std::to_string(mapID));
|
cmd.append(std::to_string(mapID));
|
||||||
cmd.append(" -port ");
|
cmd.append(" -port ");
|
||||||
cmd.append(std::to_string(m_LastPort));
|
cmd.append(std::to_string(port));
|
||||||
cmd.append(" -instance ");
|
cmd.append(" -instance ");
|
||||||
cmd.append(std::to_string(m_LastInstanceID));
|
cmd.append(std::to_string(m_LastInstanceID));
|
||||||
cmd.append(" -maxclients ");
|
cmd.append(" -maxclients ");
|
||||||
@ -74,8 +75,6 @@ Instance * InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, L
|
|||||||
|
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
|
|
||||||
m_LastPort++; //Increment it again because the next port is for World<->Server comm.
|
|
||||||
m_LastPort++; //Increment it again because the next port is for World<->Chat comm.
|
|
||||||
m_Instances.push_back(instance);
|
m_Instances.push_back(instance);
|
||||||
|
|
||||||
if (instance) {
|
if (instance) {
|
||||||
@ -97,6 +96,25 @@ bool InstanceManager::IsPortInUse(uint32_t port) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t InstanceManager::GetFreePort() {
|
||||||
|
uint32_t port = m_LastPort;
|
||||||
|
std::vector<uint32_t> usedPorts;
|
||||||
|
for (Instance* i : m_Instances) {
|
||||||
|
usedPorts.push_back(i->GetPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(usedPorts.begin(), usedPorts.end());
|
||||||
|
|
||||||
|
int portIdx = 0;
|
||||||
|
while (portIdx < usedPorts.size() && port == usedPorts[portIdx]) {
|
||||||
|
//increment by 3 since each instance uses 3 ports (instance, world-server, world-chat)
|
||||||
|
port += 3;
|
||||||
|
portIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceManager::AddPlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID) {
|
void InstanceManager::AddPlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID) {
|
||||||
Instance* inst = FindInstance(mapID, instanceID);
|
Instance* inst = FindInstance(mapID, instanceID);
|
||||||
if (inst) {
|
if (inst) {
|
||||||
@ -291,7 +309,8 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon
|
|||||||
|
|
||||||
int maxPlayers = 999;
|
int maxPlayers = 999;
|
||||||
|
|
||||||
instance = new Instance(mExternalIP, ++m_LastPort, mapID, ++m_LastInstanceID, cloneID, maxPlayers, maxPlayers, true, password);
|
uint32_t port = GetFreePort();
|
||||||
|
instance = new Instance(mExternalIP, port, mapID, ++m_LastInstanceID, cloneID, maxPlayers, maxPlayers, true, password);
|
||||||
|
|
||||||
//Start the actual process:
|
//Start the actual process:
|
||||||
std::string cmd = "start ./WorldServer.exe -zone ";
|
std::string cmd = "start ./WorldServer.exe -zone ";
|
||||||
@ -302,7 +321,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon
|
|||||||
|
|
||||||
cmd.append(std::to_string(mapID));
|
cmd.append(std::to_string(mapID));
|
||||||
cmd.append(" -port ");
|
cmd.append(" -port ");
|
||||||
cmd.append(std::to_string(m_LastPort));
|
cmd.append(std::to_string(port));
|
||||||
cmd.append(" -instance ");
|
cmd.append(" -instance ");
|
||||||
cmd.append(std::to_string(m_LastInstanceID));
|
cmd.append(std::to_string(m_LastInstanceID));
|
||||||
cmd.append(" -maxclients ");
|
cmd.append(" -maxclients ");
|
||||||
@ -317,8 +336,6 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon
|
|||||||
|
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
|
|
||||||
m_LastPort++; //Increment it again because the next port is for World<->Server comm.
|
|
||||||
m_LastPort++; //Increment it again because the next port is for World<->Chat comm.
|
|
||||||
m_Instances.push_back(instance);
|
m_Instances.push_back(instance);
|
||||||
|
|
||||||
if (instance) return instance;
|
if (instance) return instance;
|
||||||
|
@ -102,6 +102,7 @@ public:
|
|||||||
|
|
||||||
Instance* GetInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneID); //Creates an instance if none found
|
Instance* GetInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneID); //Creates an instance if none found
|
||||||
bool IsPortInUse(uint32_t port);
|
bool IsPortInUse(uint32_t port);
|
||||||
|
uint32_t GetFreePort();
|
||||||
|
|
||||||
void AddPlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID);
|
void AddPlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID);
|
||||||
void RemovePlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID);
|
void RemovePlayer(SystemAddress systemAddr, LWOMAPID mapID, LWOINSTANCEID instanceID);
|
||||||
|
@ -47,9 +47,12 @@ namespace Game {
|
|||||||
bool shutdownSequenceStarted = false;
|
bool shutdownSequenceStarted = false;
|
||||||
void ShutdownSequence();
|
void ShutdownSequence();
|
||||||
dLogger* SetupLogger();
|
dLogger* SetupLogger();
|
||||||
|
void StartAuthServer();
|
||||||
|
void StartChatServer();
|
||||||
void HandlePacket(Packet* packet);
|
void HandlePacket(Packet* packet);
|
||||||
std::map<uint32_t, std::string> activeSessions;
|
std::map<uint32_t, std::string> activeSessions;
|
||||||
bool shouldShutdown = false;
|
bool shouldShutdown = false;
|
||||||
|
SystemAddress chatServerMasterPeerSysAddr;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
Diagnostics::SetProcessName("Master");
|
Diagnostics::SetProcessName("Master");
|
||||||
@ -72,6 +75,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("masterconfig.ini");
|
dConfig config("masterconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
|
|
||||||
//Connect to CDClient
|
//Connect to CDClient
|
||||||
try {
|
try {
|
||||||
@ -181,35 +185,12 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
//Depending on the config, start up servers:
|
//Depending on the config, start up servers:
|
||||||
if (config.GetValue("prestart_servers") != "" && config.GetValue("prestart_servers") == "1") {
|
if (config.GetValue("prestart_servers") != "" && config.GetValue("prestart_servers") == "1") {
|
||||||
#ifdef __APPLE__
|
StartChatServer();
|
||||||
//macOS doesn't need sudo to run on ports < 1024
|
|
||||||
system("./ChatServer&");
|
|
||||||
#elif _WIN32
|
|
||||||
system("start ./ChatServer.exe");
|
|
||||||
#else
|
|
||||||
if (std::atoi(Game::config->GetValue("use_sudo_chat").c_str())) {
|
|
||||||
system("sudo ./ChatServer&");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
system("./ChatServer&");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Game::im->GetInstance(0, false, 0)->SetIsReady(true);
|
Game::im->GetInstance(0, false, 0)->SetIsReady(true);
|
||||||
Game::im->GetInstance(1000, false, 0)->SetIsReady(true);
|
Game::im->GetInstance(1000, false, 0)->SetIsReady(true);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
StartAuthServer();
|
||||||
system("./AuthServer&");
|
|
||||||
#elif _WIN32
|
|
||||||
system("start ./AuthServer.exe");
|
|
||||||
#else
|
|
||||||
if (std::atoi(Game::config->GetValue("use_sudo_auth").c_str())) {
|
|
||||||
system("sudo ./AuthServer&");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
system("./AuthServer&");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto t = std::chrono::high_resolution_clock::now();
|
auto t = std::chrono::high_resolution_clock::now();
|
||||||
@ -320,11 +301,13 @@ dLogger* SetupLogger() {
|
|||||||
std::string logPath =
|
std::string logPath =
|
||||||
"./logs/MasterServer_" + std::to_string(time(nullptr)) + ".log";
|
"./logs/MasterServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
@ -338,6 +321,10 @@ void HandlePacket(Packet* packet) {
|
|||||||
if (instance) {
|
if (instance) {
|
||||||
Game::im->RemoveInstance(instance); //Delete the old
|
Game::im->RemoveInstance(instance); //Delete the old
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (packet->systemAddress == chatServerMasterPeerSysAddr && !shouldShutdown) {
|
||||||
|
StartChatServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->data[0] == ID_CONNECTION_LOST) {
|
if (packet->data[0] == ID_CONNECTION_LOST) {
|
||||||
@ -350,6 +337,10 @@ void HandlePacket(Packet* packet) {
|
|||||||
Game::im->RemoveInstance(instance); //Delete the old
|
Game::im->RemoveInstance(instance); //Delete the old
|
||||||
//Game::im->GetInstance(zoneID.GetMapID(), false, 0); //Create the new
|
//Game::im->GetInstance(zoneID.GetMapID(), false, 0); //Create the new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (packet->systemAddress == chatServerMasterPeerSysAddr && !shouldShutdown) {
|
||||||
|
StartChatServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->data[1] == MASTER) {
|
if (packet->data[1] == MASTER) {
|
||||||
@ -438,6 +429,14 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theirServerType == ServerType::Chat) {
|
||||||
|
SystemAddress copy;
|
||||||
|
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
||||||
|
copy.port = packet->systemAddress.port;
|
||||||
|
|
||||||
|
chatServerMasterPeerSysAddr = copy;
|
||||||
|
}
|
||||||
|
|
||||||
Game::logger->Log("MasterServer", "Received server info, instance: %i port: %i\n", theirInstanceID, theirPort);
|
Game::logger->Log("MasterServer", "Received server info, instance: %i port: %i\n", theirInstanceID, theirPort);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -657,6 +656,37 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StartChatServer() {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
//macOS doesn't need sudo to run on ports < 1024
|
||||||
|
system("./ChatServer&");
|
||||||
|
#elif _WIN32
|
||||||
|
system("start ./ChatServer.exe");
|
||||||
|
#else
|
||||||
|
if (std::atoi(Game::config->GetValue("use_sudo_chat").c_str())) {
|
||||||
|
system("sudo ./ChatServer&");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
system("./ChatServer&");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartAuthServer() {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
system("./AuthServer&");
|
||||||
|
#elif _WIN32
|
||||||
|
system("start ./AuthServer.exe");
|
||||||
|
#else
|
||||||
|
if (std::atoi(Game::config->GetValue("use_sudo_auth").c_str())) {
|
||||||
|
system("sudo ./AuthServer&");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
system("./AuthServer&");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void ShutdownSequence() {
|
void ShutdownSequence() {
|
||||||
if (shutdownSequenceStarted) {
|
if (shutdownSequenceStarted) {
|
||||||
return;
|
return;
|
||||||
|
@ -70,7 +70,7 @@ void ActivityManager::StopActivity(Entity *self, const LWOOBJID playerID, const
|
|||||||
SetActivityValue(self, playerID, 1, value1);
|
SetActivityValue(self, playerID, 1, value1);
|
||||||
SetActivityValue(self, playerID, 2, value2);
|
SetActivityValue(self, playerID, 2, value2);
|
||||||
|
|
||||||
Loot::GiveActivityLoot(player, self, gameID, CalculateActivityRating(self, playerID));
|
LootGenerator::Instance().GiveActivityLoot(player, self, gameID, CalculateActivityRating(self, playerID));
|
||||||
|
|
||||||
// Save the new score to the leaderboard and show the leaderboard to the player
|
// Save the new score to the leaderboard and show the leaderboard to the player
|
||||||
LeaderboardManager::SaveScore(playerID, gameID, score, value1);
|
LeaderboardManager::SaveScore(playerID, gameID, score, value1);
|
||||||
|
@ -8,7 +8,7 @@ void AgPicnicBlanket::OnUse(Entity *self, Entity *user) {
|
|||||||
self->SetVar<bool>(u"active", true);
|
self->SetVar<bool>(u"active", true);
|
||||||
|
|
||||||
auto lootTable = std::unordered_map<LOT, int32_t> {{935, 3}};
|
auto lootTable = std::unordered_map<LOT, int32_t> {{935, 3}};
|
||||||
Loot::DropLoot(user, self, lootTable, 0, 0);
|
LootGenerator::Instance().DropLoot(user, self, lootTable, 0, 0);
|
||||||
|
|
||||||
self->AddCallbackTimer(5.0f, [self]() {
|
self->AddCallbackTimer(5.0f, [self]() {
|
||||||
self->SetVar<bool>(u"active", false);
|
self->SetVar<bool>(u"active", false);
|
||||||
|
@ -25,7 +25,7 @@ void BaseInteractDropLootServer::BaseUse(Entity* self, Entity* user)
|
|||||||
|
|
||||||
self->SetNetworkVar(u"bInUse", true);
|
self->SetNetworkVar(u"bInUse", true);
|
||||||
|
|
||||||
Loot::DropLoot(user, self, lootMatrix, 0, 0);
|
LootGenerator::Instance().DropLoot(user, self, lootMatrix, 0, 0);
|
||||||
|
|
||||||
self->AddCallbackTimer(cooldownTime, [this, self] () {
|
self->AddCallbackTimer(cooldownTime, [this, self] () {
|
||||||
self->SetNetworkVar(u"bInUse", false);
|
self->SetNetworkVar(u"bInUse", false);
|
||||||
|
@ -91,7 +91,7 @@ void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawne
|
|||||||
|
|
||||||
if (spawnerName == "Named_Enemies")
|
if (spawnerName == "Named_Enemies")
|
||||||
{
|
{
|
||||||
//spawner->Reset();
|
spawner->SoftReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
spawner->Activate();
|
spawner->Activate();
|
||||||
@ -173,12 +173,12 @@ void BaseRandomServer::NamedEnemyDeath(Entity* self, Spawner* spawner)
|
|||||||
|
|
||||||
void BaseRandomServer::SpawnersUp(Entity* self)
|
void BaseRandomServer::SpawnersUp(Entity* self)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseRandomServer::SpawnersDown(Entity* self)
|
void BaseRandomServer::SpawnersDown(Entity* self)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseRandomServer::BaseOnTimerDone(Entity* self, const std::string& timerName)
|
void BaseRandomServer::BaseOnTimerDone(Entity* self, const std::string& timerName)
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
void SpawnersUp(Entity* self);
|
void SpawnersUp(Entity* self);
|
||||||
void SpawnersDown(Entity* self);
|
void SpawnersDown(Entity* self);
|
||||||
void BaseOnTimerDone(Entity* self, const std::string& timerName);
|
void BaseOnTimerDone(Entity* self, const std::string& timerName);
|
||||||
|
|
||||||
void NotifySpawnerOfDeath(Entity* self, Spawner* spawner);
|
void NotifySpawnerOfDeath(Entity* self, Spawner* spawner);
|
||||||
void NamedEnemyDeath(Entity* self, Spawner* spawner);
|
void NamedEnemyDeath(Entity* self, Spawner* spawner);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ BootyDigServer::OnFireEventServerSide(Entity *self, Entity *sender, std::string
|
|||||||
if (renderComponent != nullptr)
|
if (renderComponent != nullptr)
|
||||||
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
|
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
|
||||||
|
|
||||||
Loot::DropLoot(player, self, 231, 75, 75);
|
LootGenerator::Instance().DropLoot(player, self, 231, 75, 75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args == "ChestDead") {
|
} else if (args == "ChestDead") {
|
||||||
|
19
dScripts/BuccaneerValiantShip.cpp
Normal file
19
dScripts/BuccaneerValiantShip.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "BuccaneerValiantShip.h"
|
||||||
|
#include "SkillComponent.h"
|
||||||
|
#include "dLogger.h"
|
||||||
|
|
||||||
|
void BuccaneerValiantShip::OnStartup(Entity* self) {
|
||||||
|
self->AddCallbackTimer(1.0F, [self]() {
|
||||||
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||||
|
auto* owner = self->GetOwner();
|
||||||
|
|
||||||
|
if (skillComponent != nullptr && owner != nullptr) {
|
||||||
|
skillComponent->CalculateBehavior(982, 20577, LWOOBJID_EMPTY, true, false, owner->GetObjectID());
|
||||||
|
|
||||||
|
// Kill self if missed
|
||||||
|
self->AddCallbackTimer(1.1F, [self]() {
|
||||||
|
self->Kill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
6
dScripts/BuccaneerValiantShip.h
Normal file
6
dScripts/BuccaneerValiantShip.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
|
||||||
|
class BuccaneerValiantShip : public CppScripts::Script {
|
||||||
|
void OnStartup(Entity *self) override;
|
||||||
|
};
|
@ -261,6 +261,8 @@
|
|||||||
#include "PersonalFortress.h"
|
#include "PersonalFortress.h"
|
||||||
#include "PropertyDevice.h"
|
#include "PropertyDevice.h"
|
||||||
#include "ImaginationBackpackHealServer.h"
|
#include "ImaginationBackpackHealServer.h"
|
||||||
|
#include "LegoDieRoll.h"
|
||||||
|
#include "BuccaneerValiantShip.h"
|
||||||
|
|
||||||
// Survival scripts
|
// Survival scripts
|
||||||
#include "AgSurvivalStromling.h"
|
#include "AgSurvivalStromling.h"
|
||||||
@ -774,6 +776,10 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = new PropertyDevice();
|
script = new PropertyDevice();
|
||||||
else if (scriptName == "scripts\\02_server\\Map\\General\\L_IMAG_BACKPACK_HEALS_SERVER.lua")
|
else if (scriptName == "scripts\\02_server\\Map\\General\\L_IMAG_BACKPACK_HEALS_SERVER.lua")
|
||||||
script = new ImaginationBackpackHealServer();
|
script = new ImaginationBackpackHealServer();
|
||||||
|
else if (scriptName == "scripts\\ai\\GENERAL\\L_LEGO_DIE_ROLL.lua")
|
||||||
|
script = new LegoDieRoll();
|
||||||
|
else if (scriptName == "scripts\\EquipmentScripts\\BuccaneerValiantShip.lua")
|
||||||
|
script = new BuccaneerValiantShip();
|
||||||
|
|
||||||
//Ignore these scripts:
|
//Ignore these scripts:
|
||||||
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
||||||
@ -782,7 +788,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = invalidToReturn;
|
script = invalidToReturn;
|
||||||
else if (script == invalidToReturn) {
|
else if (script == invalidToReturn) {
|
||||||
if (scriptName.length() > 0)
|
if (scriptName.length() > 0)
|
||||||
Game::logger->Log("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
||||||
|
// information not really needed for sys admins but is for developers
|
||||||
|
|
||||||
script = invalidToReturn;
|
script = invalidToReturn;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "MissionState.h"
|
#include "MissionState.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
#include "Loot.h"
|
||||||
|
|
||||||
class User;
|
class User;
|
||||||
class Entity;
|
class Entity;
|
||||||
|
@ -10,7 +10,7 @@ void GrowingFlower::OnSkillEventFired(Entity *self, Entity *target, const std::s
|
|||||||
const auto mission1 = self->GetVar<int32_t>(u"missionID");
|
const auto mission1 = self->GetVar<int32_t>(u"missionID");
|
||||||
const auto mission2 = self->GetVar<int32_t>(u"missionID2");
|
const auto mission2 = self->GetVar<int32_t>(u"missionID2");
|
||||||
|
|
||||||
Loot::DropActivityLoot(target, self, self->GetLOT(), 0);
|
LootGenerator::Instance().DropActivityLoot(target, self, self->GetLOT(), 0);
|
||||||
|
|
||||||
auto* missionComponent = target->GetComponent<MissionComponent>();
|
auto* missionComponent = target->GetComponent<MissionComponent>();
|
||||||
if (missionComponent != nullptr) {
|
if (missionComponent != nullptr) {
|
||||||
|
55
dScripts/LegoDieRoll.cpp
Normal file
55
dScripts/LegoDieRoll.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "LegoDieRoll.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "dLogger.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
|
||||||
|
void LegoDieRoll::OnStartup(Entity* self) {
|
||||||
|
self->AddTimer("DoneRolling", 10.0f);
|
||||||
|
self->AddTimer("ThrowDice", LegoDieRoll::animTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) {
|
||||||
|
if (timerName == "DoneRolling") {
|
||||||
|
self->Smash(self->GetObjectID(), SILENT);
|
||||||
|
}
|
||||||
|
else if (timerName == "ThrowDice") {
|
||||||
|
int dieRoll = GeneralUtils::GenerateRandomNumber<int>(1, 6);
|
||||||
|
|
||||||
|
switch (dieRoll)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-1");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-2");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-3");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-4");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-5");
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
GameMessages::SendPlayAnimation(self, u"roll-die-6");
|
||||||
|
// tracking the It's Truly Random Achievement
|
||||||
|
auto* owner = self->GetOwner();
|
||||||
|
auto* missionComponent = owner->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
|
if (missionComponent != nullptr) {
|
||||||
|
const auto rollMissionState = missionComponent->GetMissionState(756);
|
||||||
|
if (rollMissionState == MissionState::MISSION_STATE_ACTIVE) {
|
||||||
|
missionComponent->ForceProgress(756, 1103, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Game::logger->LogDebug("LegoDieRoll", "Invalid animation: roll-die-%i\n", dieRoll);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
dScripts/LegoDieRoll.h
Normal file
11
dScripts/LegoDieRoll.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
|
||||||
|
class LegoDieRoll : public CppScripts::Script {
|
||||||
|
public:
|
||||||
|
void OnStartup(Entity* self);
|
||||||
|
void OnTimerDone(Entity* self, std::string timerName);
|
||||||
|
private:
|
||||||
|
constexpr static const float animTime = 2.0f;
|
||||||
|
};
|
||||||
|
|
@ -18,14 +18,24 @@ void MinigameTreasureChestServer::OnUse(Entity *self, Entity *user) {
|
|||||||
UpdatePlayer(self, user->GetObjectID());
|
UpdatePlayer(self, user->GetObjectID());
|
||||||
|
|
||||||
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
||||||
|
uint32_t activityRating = 0;
|
||||||
if (team != nullptr) {
|
if (team != nullptr) {
|
||||||
for (const auto& teamMemberID : team->members) {
|
for (const auto& teamMemberID : team->members) {
|
||||||
auto* teamMember = EntityManager::Instance()->GetEntity(teamMemberID);
|
auto* teamMember = EntityManager::Instance()->GetEntity(teamMemberID);
|
||||||
if (teamMember != nullptr)
|
if (teamMember != nullptr) {
|
||||||
Loot::DropActivityLoot(teamMember, self, sac->GetActivityID(), CalculateActivityRating(self, teamMemberID));
|
activityRating = CalculateActivityRating(self, teamMemberID);
|
||||||
|
|
||||||
|
if (self->GetLOT() == frakjawChestId) activityRating = team->members.size();
|
||||||
|
|
||||||
|
LootGenerator::Instance().DropActivityLoot(teamMember, self, sac->GetActivityID(), activityRating);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Loot::DropActivityLoot(user, self, sac->GetActivityID(), CalculateActivityRating(self, user->GetObjectID()));
|
activityRating = CalculateActivityRating(self, user->GetObjectID());
|
||||||
|
|
||||||
|
if (self->GetLOT() == frakjawChestId) activityRating = 1;
|
||||||
|
|
||||||
|
LootGenerator::Instance().DropActivityLoot(user, self, sac->GetActivityID(), activityRating);
|
||||||
}
|
}
|
||||||
|
|
||||||
sac->PlayerRemove(user->GetObjectID());
|
sac->PlayerRemove(user->GetObjectID());
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
#include "ActivityManager.h"
|
#include "ActivityManager.h"
|
||||||
|
|
||||||
class MinigameTreasureChestServer : public ActivityManager {
|
class MinigameTreasureChestServer : public ActivityManager {
|
||||||
|
public:
|
||||||
void OnStartup(Entity* self) override;
|
void OnStartup(Entity* self) override;
|
||||||
void OnUse(Entity* self, Entity* user) override;
|
void OnUse(Entity* self, Entity* user) override;
|
||||||
uint32_t CalculateActivityRating(Entity *self, LWOOBJID playerID) override;
|
uint32_t CalculateActivityRating(Entity *self, LWOOBJID playerID) override;
|
||||||
|
private:
|
||||||
|
const uint32_t frakjawChestId = 16486;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,6 @@ void NjDragonEmblemChestServer::OnUse(Entity *self, Entity *user) {
|
|||||||
|
|
||||||
auto* destroyable = self->GetComponent<DestroyableComponent>();
|
auto* destroyable = self->GetComponent<DestroyableComponent>();
|
||||||
if (destroyable != nullptr) {
|
if (destroyable != nullptr) {
|
||||||
Loot::DropLoot(user, self, destroyable->GetLootMatrixID(), 0, 0);
|
LootGenerator::Instance().DropLoot(user, self, destroyable->GetLootMatrixID(), 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ void SGCannon::SpawnNewModel(Entity *self) {
|
|||||||
|
|
||||||
if (lootMatrix != 0) {
|
if (lootMatrix != 0) {
|
||||||
std::unordered_map<LOT, int32_t> toDrop = {};
|
std::unordered_map<LOT, int32_t> toDrop = {};
|
||||||
Loot::CalculateLootMatrix(lootMatrix, player, toDrop);
|
toDrop = LootGenerator::Instance().RollLootMatrix(player, lootMatrix);
|
||||||
|
|
||||||
for (auto drop : toDrop) {
|
for (auto drop : toDrop) {
|
||||||
rewardModel->OnFireEventServerSide(self, ModelToBuildEvent, drop.first);
|
rewardModel->OnFireEventServerSide(self, ModelToBuildEvent, drop.first);
|
||||||
@ -581,7 +581,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
|
LootGenerator::Instance().GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
|
||||||
|
|
||||||
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable),
|
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable),
|
||||||
self->GetVar<uint32_t>(MaxStreakVariable), percentage);
|
self->GetVar<uint32_t>(MaxStreakVariable), percentage);
|
||||||
|
@ -24,7 +24,7 @@ void ScriptedPowerupSpawner::OnTimerDone(Entity *self, std::string message) {
|
|||||||
renderComponent->PlayEffect(0, u"cast", "N_cast");
|
renderComponent->PlayEffect(0, u"cast", "N_cast");
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::DropItem(owner, self, itemLOT, 0, 1, true, true);
|
LootGenerator::Instance().DropLoot(owner, self, itemLOT, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment the current cycle
|
// Increment the current cycle
|
||||||
|
@ -39,12 +39,12 @@ void TreasureChestDragonServer::OnUse(Entity* self, Entity* user)
|
|||||||
|
|
||||||
if (memberObject == nullptr) continue;
|
if (memberObject == nullptr) continue;
|
||||||
|
|
||||||
Loot::DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
|
LootGenerator::Instance().DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Loot::DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
|
LootGenerator::Instance().DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->Smash(self->GetObjectID());
|
self->Smash(self->GetObjectID());
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
|
|
||||||
void VeMissionConsole::OnUse(Entity *self, Entity *user) {
|
void VeMissionConsole::OnUse(Entity *self, Entity *user) {
|
||||||
Loot::DropActivityLoot(user, self, 12551);
|
LootGenerator::Instance().DropActivityLoot(user, self, 12551);
|
||||||
|
|
||||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
||||||
if (inventoryComponent != nullptr) {
|
if (inventoryComponent != nullptr) {
|
||||||
|
@ -24,7 +24,7 @@ void WishingWellServer::OnUse(Entity* self, Entity* user)
|
|||||||
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), audio);
|
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::DropActivityLoot(
|
LootGenerator::Instance().DropActivityLoot(
|
||||||
user,
|
user,
|
||||||
self,
|
self,
|
||||||
static_cast<uint32_t>(scriptedActivity->GetActivityID()),
|
static_cast<uint32_t>(scriptedActivity->GetActivityID()),
|
||||||
|
@ -73,6 +73,7 @@ namespace Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool chatDisabled = false;
|
bool chatDisabled = false;
|
||||||
|
bool chatConnected = false;
|
||||||
bool worldShutdownSequenceStarted = false;
|
bool worldShutdownSequenceStarted = false;
|
||||||
bool worldShutdownSequenceComplete = false;
|
bool worldShutdownSequenceComplete = false;
|
||||||
void WorldShutdownSequence();
|
void WorldShutdownSequence();
|
||||||
@ -89,6 +90,7 @@ struct tempSessionInfo {
|
|||||||
std::map<std::string, tempSessionInfo> m_PendingUsers;
|
std::map<std::string, tempSessionInfo> m_PendingUsers;
|
||||||
int instanceID = 0;
|
int instanceID = 0;
|
||||||
int g_CloneID = 0;
|
int g_CloneID = 0;
|
||||||
|
std::string databaseChecksum = "";
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
Diagnostics::SetProcessName("World");
|
Diagnostics::SetProcessName("World");
|
||||||
@ -136,6 +138,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("worldconfig.ini");
|
dConfig config("worldconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
if (config.GetValue("disable_chat") == "1") chatDisabled = true;
|
if (config.GetValue("disable_chat") == "1") chatDisabled = true;
|
||||||
|
|
||||||
// Connect to CDClient
|
// Connect to CDClient
|
||||||
@ -185,6 +188,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
ObjectIDManager::Instance()->Initialize();
|
ObjectIDManager::Instance()->Initialize();
|
||||||
UserManager::Instance()->Initialize();
|
UserManager::Instance()->Initialize();
|
||||||
|
LootGenerator::Instance();
|
||||||
Game::chatFilter = new dChatFilter("./res/chatplus_en_us", bool(std::stoi(config.GetValue("dont_generate_dcf"))));
|
Game::chatFilter = new dChatFilter("./res/chatplus_en_us", bool(std::stoi(config.GetValue("dont_generate_dcf"))));
|
||||||
|
|
||||||
Game::server = new dServer(masterIP, ourPort, instanceID, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::World, zoneID);
|
Game::server = new dServer(masterIP, ourPort, instanceID, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::World, zoneID);
|
||||||
@ -209,6 +213,7 @@ int main(int argc, char** argv) {
|
|||||||
Packet* packet = nullptr;
|
Packet* packet = nullptr;
|
||||||
int framesSinceLastFlush = 0;
|
int framesSinceLastFlush = 0;
|
||||||
int framesSinceMasterDisconnect = 0;
|
int framesSinceMasterDisconnect = 0;
|
||||||
|
int framesSinceChatDisconnect = 0;
|
||||||
int framesSinceLastUsersSave = 0;
|
int framesSinceLastUsersSave = 0;
|
||||||
int framesSinceLastSQLPing = 0;
|
int framesSinceLastSQLPing = 0;
|
||||||
int framesSinceLastUser = 0;
|
int framesSinceLastUser = 0;
|
||||||
@ -234,6 +239,47 @@ int main(int argc, char** argv) {
|
|||||||
Game::physicsWorld = &dpWorld::Instance(); //just in case some old code references it
|
Game::physicsWorld = &dpWorld::Instance(); //just in case some old code references it
|
||||||
dZoneManager::Instance()->Initialize(LWOZONEID(zoneID, instanceID, cloneID));
|
dZoneManager::Instance()->Initialize(LWOZONEID(zoneID, instanceID, cloneID));
|
||||||
g_CloneID = cloneID;
|
g_CloneID = cloneID;
|
||||||
|
|
||||||
|
// pre calculate the FDB checksum
|
||||||
|
if (Game::config->GetValue("check_fdb") == "1") {
|
||||||
|
std::ifstream fileStream;
|
||||||
|
|
||||||
|
static const std::vector<std::string> aliases = {
|
||||||
|
"res/CDServers.fdb",
|
||||||
|
"res/cdserver.fdb",
|
||||||
|
"res/CDClient.fdb",
|
||||||
|
"res/cdclient.fdb",
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& file : aliases) {
|
||||||
|
fileStream.open(file, std::ios::binary | std::ios::in);
|
||||||
|
if (fileStream.is_open()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int bufferSize = 1024;
|
||||||
|
MD5* md5 = new MD5();
|
||||||
|
|
||||||
|
char fileStreamBuffer[1024] = {};
|
||||||
|
|
||||||
|
while (!fileStream.eof()) {
|
||||||
|
memset(fileStreamBuffer, 0, bufferSize);
|
||||||
|
fileStream.read(fileStreamBuffer, bufferSize);
|
||||||
|
md5->update(fileStreamBuffer, fileStream.gcount());
|
||||||
|
}
|
||||||
|
|
||||||
|
fileStream.close();
|
||||||
|
|
||||||
|
const char* nullTerminateBuffer = "\0";
|
||||||
|
md5->update(nullTerminateBuffer, 1); // null terminate the data
|
||||||
|
md5->finalize();
|
||||||
|
databaseChecksum = md5->hexdigest();
|
||||||
|
|
||||||
|
delete md5;
|
||||||
|
|
||||||
|
Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s\n", databaseChecksum.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -275,6 +321,19 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
else framesSinceMasterDisconnect = 0;
|
else framesSinceMasterDisconnect = 0;
|
||||||
|
|
||||||
|
// Check if we're still connected to chat:
|
||||||
|
if (!chatConnected) {
|
||||||
|
framesSinceChatDisconnect++;
|
||||||
|
|
||||||
|
// Attempt to reconnect every 30 seconds.
|
||||||
|
if (framesSinceChatDisconnect >= 2000) {
|
||||||
|
framesSinceChatDisconnect = 0;
|
||||||
|
|
||||||
|
Game::chatServer->Connect(masterIP.c_str(), chatPort, "3.25 ND1", 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else framesSinceChatDisconnect = 0;
|
||||||
|
|
||||||
//In world we'd update our other systems here.
|
//In world we'd update our other systems here.
|
||||||
|
|
||||||
if (zoneID != 0 && deltaTime > 0.0f) {
|
if (zoneID != 0 && deltaTime > 0.0f) {
|
||||||
@ -503,21 +562,27 @@ int main(int argc, char** argv) {
|
|||||||
dLogger * SetupLogger(int zoneID, int instanceID) {
|
dLogger * SetupLogger(int zoneID, int instanceID) {
|
||||||
std::string logPath = "./logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacketChat(Packet* packet) {
|
void HandlePacketChat(Packet* packet) {
|
||||||
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
||||||
Game::logger->Log("WorldServer", "Lost our connection to chat, zone(%i), instance(%i)\n", Game::server->GetZoneID(), Game::server->GetInstanceID());
|
Game::logger->Log("WorldServer", "Lost our connection to chat, zone(%i), instance(%i)\n", Game::server->GetZoneID(), Game::server->GetInstanceID());
|
||||||
|
|
||||||
|
chatConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
|
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
|
||||||
Game::logger->Log("WorldServer", "Established connection to chat, zone(%i), instance (%i)\n",Game::server -> GetZoneID(), Game::server -> GetInstanceID());
|
Game::logger->Log("WorldServer", "Established connection to chat, zone(%i), instance (%i)\n",Game::server -> GetZoneID(), Game::server -> GetInstanceID());
|
||||||
Game::chatSysAddr = packet->systemAddress;
|
Game::chatSysAddr = packet->systemAddress;
|
||||||
|
|
||||||
|
chatConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->data[0] == ID_USER_PACKET_ENUM) {
|
if (packet->data[0] == ID_USER_PACKET_ENUM) {
|
||||||
@ -838,7 +903,33 @@ void HandlePacket(Packet* packet) {
|
|||||||
case MSG_WORLD_CLIENT_VALIDATION: {
|
case MSG_WORLD_CLIENT_VALIDATION: {
|
||||||
std::string username = PacketUtils::ReadString(0x08, packet, true);
|
std::string username = PacketUtils::ReadString(0x08, packet, true);
|
||||||
std::string sessionKey = PacketUtils::ReadString(74, packet, true);
|
std::string sessionKey = PacketUtils::ReadString(74, packet, true);
|
||||||
|
std::string clientDatabaseChecksum = PacketUtils::ReadString(packet->length - 33, packet, false);
|
||||||
|
|
||||||
|
// sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird
|
||||||
|
clientDatabaseChecksum = clientDatabaseChecksum.substr(0, 32);
|
||||||
|
|
||||||
|
// If the check is turned on, validate the client's database checksum.
|
||||||
|
if (Game::config->GetValue("check_fdb") == "1" && !databaseChecksum.empty()) {
|
||||||
|
uint32_t gmLevel = 0;
|
||||||
|
auto* stmt = Database::CreatePreppedStmt("SELECT gm_level FROM accounts WHERE name=? LIMIT 1;");
|
||||||
|
stmt->setString(1, username.c_str());
|
||||||
|
|
||||||
|
auto* res = stmt->executeQuery();
|
||||||
|
while (res->next()) {
|
||||||
|
gmLevel = res->getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete stmt;
|
||||||
|
delete res;
|
||||||
|
|
||||||
|
// Developers may skip this check
|
||||||
|
if (gmLevel < 8 && clientDatabaseChecksum != databaseChecksum) {
|
||||||
|
Game::logger->Log("WorldServer", "Client's database checksum does not match the server's, aborting connection.\n");
|
||||||
|
Game::server->Disconnect(packet->systemAddress, SERVER_DISCON_KICK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Request the session info from Master:
|
//Request the session info from Master:
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_SESSION_KEY);
|
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_SESSION_KEY);
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
#include "CDFeatureGatingTable.h"
|
||||||
|
#include "CDClientManager.h"
|
||||||
|
|
||||||
Level::Level(Zone* parentZone, const std::string& filepath) {
|
Level::Level(Zone* parentZone, const std::string& filepath) {
|
||||||
m_ParentZone = parentZone;
|
m_ParentZone = parentZone;
|
||||||
|
@ -19,6 +19,9 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should ignore playkeys
|
# 0 or 1, should ignore playkeys
|
||||||
# If 1 everyone with an account will be able to login, regardless of if they have a key or not
|
# If 1 everyone with an account will be able to login, regardless of if they have a key or not
|
||||||
dont_use_keys=0
|
dont_use_keys=0
|
||||||
|
@ -19,5 +19,8 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should not compile chat hash map to file
|
# 0 or 1, should not compile chat hash map to file
|
||||||
dont_generate_dcf=0
|
dont_generate_dcf=0
|
||||||
|
@ -32,5 +32,8 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should autostart auth, chat, and char servers
|
# 0 or 1, should autostart auth, chat, and char servers
|
||||||
prestart_servers=1
|
prestart_servers=1
|
||||||
|
@ -20,6 +20,9 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should not compile chat hash map to file
|
# 0 or 1, should not compile chat hash map to file
|
||||||
dont_generate_dcf=0
|
dont_generate_dcf=0
|
||||||
|
|
||||||
@ -47,3 +50,6 @@ solo_racing=0
|
|||||||
|
|
||||||
# Disables the anti-speedhack system. If you get kicked randomly you might want to disable this, as it might just be lag
|
# Disables the anti-speedhack system. If you get kicked randomly you might want to disable this, as it might just be lag
|
||||||
disable_anti_speedhack=0
|
disable_anti_speedhack=0
|
||||||
|
|
||||||
|
# 0 or 1, check server fdb (res/CDServer.fdb) against clients
|
||||||
|
check_fdb=0
|
Loading…
Reference in New Issue
Block a user