Skip to content

Commit

Permalink
Scripts: Fix ambiguous base class
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Oct 9, 2023
1 parent 288991e commit dc7c834
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dScripts/02_server/Enemy/General/BaseEnemyApe.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "CppScripts.h"

class BaseEnemyApe : public CppScripts::Script {
class BaseEnemyApe : virtual public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnDie(Entity* self, Entity* killer) override;
Expand Down
2 changes: 1 addition & 1 deletion dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ActivityManager.h"
#include "ZoneAgProperty.h"

class ZoneAgSpiderQueen : ZoneAgProperty, ActivityManager {
class ZoneAgSpiderQueen : public ZoneAgProperty, ActivityManager {
public:
void OnStartup(Entity* self) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
Expand Down
2 changes: 1 addition & 1 deletion dScripts/02_server/Map/njhub/NjNPCMissionSpinjitzuServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static std::map<std::u16string, uint32_t> ElementMissions = {
{u"fire", 1962},
};

class NjNPCMissionSpinjitzuServer : public CppScripts::Script {
class NjNPCMissionSpinjitzuServer : virtual public CppScripts::Script {
public:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
private:
Expand Down
2 changes: 1 addition & 1 deletion dScripts/ActivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct ActivityTimer {
float_t runTime = 0;
};

class ActivityManager : public CppScripts::Script {
class ActivityManager : virtual public CppScripts::Script {
public:
static bool IsPlayerInActivity(Entity* self, LWOOBJID playerID);
static void UpdatePlayer(Entity* self, LWOOBJID playerID, bool remove = false);
Expand Down
2 changes: 1 addition & 1 deletion dScripts/BasePropertyServer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "CppScripts.h"

class BasePropertyServer : public CppScripts::Script {
class BasePropertyServer : virtual public CppScripts::Script {
public:

virtual void SetGameVariables(Entity* self);
Expand Down
2 changes: 1 addition & 1 deletion dScripts/BaseWavesGenericEnemy.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "CppScripts.h"

class BaseWavesGenericEnemy : public CppScripts::Script {
class BaseWavesGenericEnemy : virtual public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnDie(Entity* self, Entity* killer) override;
Expand Down
33 changes: 10 additions & 23 deletions dScripts/CppScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,22 +312,17 @@
#include "WildNinjaSensei.h"
#include "WildNinjaBricks.h"

//Big bad global bc this is a namespace and not a class:
InvalidScript* invalidToReturn = new InvalidScript();
std::map<std::string, CppScripts::Script*> m_Scripts;

// yeah sorry darwin ill fix the global later
namespace {
InvalidScript* invalidToReturn = new InvalidScript();
std::map<std::string, CppScripts::Script*> m_Scripts;
};

CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
Script* script;

if (m_Scripts.find(scriptName) != m_Scripts.end()) {
script = m_Scripts[scriptName];

return script;
return m_Scripts[scriptName];
}

script = invalidToReturn;
Script* script = invalidToReturn;

//VE / AG:
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
Expand Down Expand Up @@ -411,7 +406,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\02_server\\Map\\AG\\L__AG_MONUMENT_RACE_CANCEL.lua")
script = new AgMonumentRaceCancel();
else if (scriptName == "scripts\\02_server\\Map\\AG_Spider_Queen\\L_ZONE_AG_SPIDER_QUEEN.lua")
script = (ZoneAgProperty*)new ZoneAgSpiderQueen();
script = new ZoneAgSpiderQueen();
else if (scriptName == "scripts\\02_server\\Map\\AG_Spider_Queen\\L_SPIDER_BOSS_TREASURE_CHEST_SERVER.lua")
script = new SpiderBossTreasureChestServer();
else if (scriptName == "scripts\\02_server\\Map\\AG\\L_NPC_COWBOY_SERVER.lua")
Expand Down Expand Up @@ -475,7 +470,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\02_server\\Enemy\\Waves\\L_WAVES_BOSS_HAMMERLING_ENEMY_SERVER.lua")
script = new WaveBossHammerling();
else if (scriptName == "scripts\\02_server\\Enemy\\Waves\\L_WAVES_BOSS_APE_ENEMY_SERVER.lua")
script = (BaseEnemyApe*) new WaveBossApe();
script = new WaveBossApe();
else if (scriptName == "scripts\\02_server\\Enemy\\Waves\\L_WAVES_BOSS_DARK_SPIDERLING_ENEMY_SERVER.lua")
script = new WaveBossSpiderling();
else if (scriptName == "scripts\\02_server\\Enemy\\Waves\\L_WAVES_BOSS_HORESEMEN_ENEMY_SERVER.lua")
Expand Down Expand Up @@ -636,7 +631,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\02_server\\Map\\General\\L_PROP_PLATFORM.lua")
script = new PropertyPlatform();
else if (scriptName == "scripts\\02_server\\Map\\VE\\L_VE_BRICKSAMPLE_SERVER.lua")
return new VeBricksampleServer();
script = new VeBricksampleServer();
else if (scriptName == "scripts\\02_server\\Map\\General\\L_MAIL_BOX_SERVER.lua")
script = new MailBoxServer();
else if (scriptName == "scripts\\ai\\ACT\\L_ACT_MINE.lua")
Expand Down Expand Up @@ -771,7 +766,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_COLE_NPC.lua")
script = new NjColeNPC();
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_JAY_MISSION_ITEMS.lua")
script = (NjNPCMissionSpinjitzuServer*) new NjJayMissionItems();
script = new NjJayMissionItems();
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_NPC_MISSION_SPINJITZU_SERVER.lua")
script = new NjNPCMissionSpinjitzuServer();
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_ENEMY_SKELETON_SPAWNER.lua")
Expand Down Expand Up @@ -952,11 +947,3 @@ std::vector<CppScripts::Script*> CppScripts::GetEntityScripts(Entity* entity) {
}
return scripts;
}

CppScripts::Script::Script() {

}

CppScripts::Script::~Script() {

}
3 changes: 0 additions & 3 deletions dScripts/CppScripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ namespace CppScripts {
*/
class Script {
public:
Script();
~Script();

/**
* Invoked one frame after the script is loaded.
*
Expand Down
2 changes: 1 addition & 1 deletion dScripts/NPCAddRemoveItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct ItemSetting {
/**
* Scripts that allows for the addition and removal of sets of items by an NPC
*/
class NPCAddRemoveItem : public CppScripts::Script {
class NPCAddRemoveItem : virtual public CppScripts::Script {
protected:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
virtual std::map<uint32_t, std::vector<ItemSetting>> GetSettings();
Expand Down

0 comments on commit dc7c834

Please sign in to comment.