mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 09:58:05 +00:00
doesnt compile
This commit is contained in:
@@ -11,7 +11,6 @@ set(DSCRIPTS_SOURCES
|
||||
"Darkitect.cpp"
|
||||
"NPCAddRemoveItem.cpp"
|
||||
"NtFactionSpyServer.cpp"
|
||||
"ScriptComponent.cpp"
|
||||
"ScriptedPowerupSpawner.cpp"
|
||||
"SpawnPetBaseServer.cpp")
|
||||
|
||||
|
@@ -312,7 +312,7 @@
|
||||
#include "WildNinjaSensei.h"
|
||||
#include "WildNinjaBricks.h"
|
||||
|
||||
InvalidScript* CppScripts::invalidToReturn = new InvalidScript();
|
||||
std::unique_ptr<InvalidScript> CppScripts::invalidScript = std::make_unique<InvalidScript>();
|
||||
std::map<std::string, CppScripts::Script*> CppScripts::m_Scripts;
|
||||
|
||||
CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
||||
@@ -324,7 +324,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
return script;
|
||||
}
|
||||
|
||||
script = invalidToReturn;
|
||||
script = invalidScript.get();
|
||||
|
||||
//VE / AG:
|
||||
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
|
||||
@@ -926,7 +926,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
|
||||
// handle invalid script reporting if the path is greater than zero and it's not an ignored script
|
||||
// information not really needed for sys admins but is for developers
|
||||
else if (script == invalidToReturn) {
|
||||
else if (script == invalidScript.get()) {
|
||||
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
||||
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
||||
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
||||
@@ -938,22 +938,3 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
m_Scripts[scriptName] = script;
|
||||
return script;
|
||||
}
|
||||
|
||||
std::vector<CppScripts::Script*> CppScripts::GetEntityScripts(Entity* entity) {
|
||||
std::vector<CppScripts::Script*> scripts;
|
||||
auto comps = entity->GetScriptComponents();
|
||||
for (auto& scriptComp : comps) {
|
||||
if (scriptComp != nullptr) {
|
||||
scripts.push_back(scriptComp->GetScript());
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
|
||||
CppScripts::Script::Script() {
|
||||
|
||||
}
|
||||
|
||||
CppScripts::Script::~Script() {
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,7 +15,7 @@ enum class eRebuildState : uint32_t;
|
||||
|
||||
namespace CppScripts {
|
||||
|
||||
extern InvalidScript* invalidToReturn;
|
||||
extern std::unique_ptr<InvalidScript> invalidScript;
|
||||
extern std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||
/**
|
||||
* Base class for all scripts. Includes virtual methods to be overridden to handle LUA equivelent events.
|
||||
@@ -33,8 +34,7 @@ namespace CppScripts {
|
||||
*/
|
||||
class Script {
|
||||
public:
|
||||
Script();
|
||||
~Script();
|
||||
virtual ~Script() = default;
|
||||
|
||||
/**
|
||||
* Invoked one frame after the script is loaded.
|
||||
@@ -365,5 +365,4 @@ namespace CppScripts {
|
||||
};
|
||||
|
||||
Script* GetScript(Entity* parent, const std::string& scriptName);
|
||||
std::vector<Script*> GetEntityScripts(Entity* entity);
|
||||
};
|
||||
|
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Darkflame Universe
|
||||
* Copyright 2018
|
||||
*/
|
||||
|
||||
#include "Entity.h"
|
||||
#include "ScriptComponent.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDScriptComponentTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
ScriptComponent::ScriptComponent(Entity* parent, const std::string& scriptName) : Component(parent) {
|
||||
SetScript(scriptName);
|
||||
}
|
||||
|
||||
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
if (bIsInitialUpdate) {
|
||||
const auto& networkSettings = m_ParentEntity->GetNetworkSettings();
|
||||
auto hasNetworkSettings = !networkSettings.empty();
|
||||
outBitStream->Write(hasNetworkSettings);
|
||||
|
||||
if (hasNetworkSettings) {
|
||||
|
||||
// First write the most inner LDF data
|
||||
RakNet::BitStream ldfData;
|
||||
ldfData.Write<uint8_t>(0);
|
||||
ldfData.Write<uint32_t>(networkSettings.size());
|
||||
|
||||
for (auto* networkSetting : networkSettings) {
|
||||
networkSetting->WriteToPacket(&ldfData);
|
||||
}
|
||||
|
||||
// Finally write everything to the stream
|
||||
outBitStream->Write<uint32_t>(ldfData.GetNumberOfBytesUsed());
|
||||
outBitStream->Write(ldfData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CppScripts::Script* ScriptComponent::GetScript() {
|
||||
return m_Script;
|
||||
}
|
||||
|
||||
void ScriptComponent::SetScript(const std::string& scriptName) {
|
||||
m_Script = CppScripts::GetScript(m_ParentEntity, scriptName);
|
||||
}
|
||||
|
||||
const std::string ScriptComponent::GetScriptName(Entity* parentEntity, const uint32_t componentId) {
|
||||
if (!parentEntity || componentId == 0) return "";
|
||||
// LDF key script overrides script component Id
|
||||
const auto customScriptServer = parentEntity->GetVarAsString(u"custom_script_server");
|
||||
if (!customScriptServer.empty()) return customScriptServer;
|
||||
|
||||
auto* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(componentId);
|
||||
return scriptCompData.script_name;
|
||||
}
|
||||
|
||||
const std::string ScriptComponent::GetZoneScriptName(const uint32_t componentId) {
|
||||
auto* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const auto zoneID = dZoneManager::Instance()->GetZoneID();
|
||||
const auto* zoneData = zoneTable->Query(zoneID.GetMapID());
|
||||
|
||||
if (!zoneData) return "";
|
||||
|
||||
int zoneScriptID = zoneData->scriptID;
|
||||
if (zoneScriptID == -1) return "";
|
||||
auto* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||
const auto& zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
|
||||
return zoneScriptData.script_name;
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Darkflame Universe
|
||||
* Copyright 2018
|
||||
*/
|
||||
|
||||
#ifndef SCRIPTCOMPONENT_H
|
||||
#define SCRIPTCOMPONENT_H
|
||||
|
||||
#include "CppScripts.h"
|
||||
#include "Component.h"
|
||||
#include <string>
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
class Entity;
|
||||
|
||||
/**
|
||||
* Handles the loading and execution of server side scripts on entities, scripts were originally written in Lua,
|
||||
* here they're written in C++
|
||||
*/
|
||||
class ScriptComponent : public Component {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
||||
|
||||
ScriptComponent(Entity* parent, const std::string& scriptName);
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
|
||||
/**
|
||||
* Returns the script that's attached to this entity
|
||||
* @return the script that's attached to this entity
|
||||
*/
|
||||
CppScripts::Script* GetScript();
|
||||
|
||||
/**
|
||||
* Sets the script using a path by looking through dScripts for a script that matches
|
||||
* @param scriptName the name of the script to find
|
||||
*/
|
||||
void SetScript(const std::string& scriptName);
|
||||
|
||||
// Get the script attached to the provided component id.
|
||||
// LDF key custom_script_server overrides component id script.
|
||||
static const std::string GetScriptName(Entity* parentEntity, const uint32_t componentId = 0);
|
||||
|
||||
static const std::string GetZoneScriptName(const uint32_t componentId);
|
||||
private:
|
||||
|
||||
/**
|
||||
* The script attached to this entity
|
||||
*/
|
||||
CppScripts::Script* m_Script;
|
||||
};
|
||||
|
||||
#endif // SCRIPTCOMPONENT_H
|
Reference in New Issue
Block a user