From 31628a70c87260bc5636e990207e5b7e4e6d9729 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Sep 2020 10:45:45 +0200 Subject: [PATCH] - added some 'overrides' and block 'forcelookup' for script access to textures. --- src/common/scripting/core/types.h | 36 ++++++++++---------- src/common/scripting/interface/vmnatives.cpp | 3 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/common/scripting/core/types.h b/src/common/scripting/core/types.h index eae6891ee..0d6c6546e 100644 --- a/src/common/scripting/core/types.h +++ b/src/common/scripting/core/types.h @@ -270,10 +270,10 @@ public: void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; - virtual void SetValue(void *addr, int val); - virtual void SetValue(void *addr, double val); - virtual int GetValueInt(void *addr) const; - virtual double GetValueFloat(void *addr) const; + virtual void SetValue(void *addr, int val) override; + virtual void SetValue(void *addr, double val) override; + virtual int GetValueInt(void *addr) const override; + virtual double GetValueFloat(void *addr) const override; virtual bool isNumeric() override { return IntCompatible; } bool Unsigned; @@ -300,10 +300,10 @@ public: void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; - virtual void SetValue(void *addr, int val); - virtual void SetValue(void *addr, double val); - virtual int GetValueInt(void *addr) const; - virtual double GetValueFloat(void *addr) const; + virtual void SetValue(void *addr, int val) override; + virtual void SetValue(void *addr, double val) override; + virtual int GetValueInt(void *addr) const override; + virtual double GetValueFloat(void *addr) const override; virtual bool isNumeric() override { return true; } protected: void SetOps(); @@ -411,8 +411,8 @@ public: reader = r; } - virtual bool IsMatch(intptr_t id1, intptr_t id2) const; - virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; + bool IsMatch(intptr_t id1, intptr_t id2) const override; + void GetTypeIDs(intptr_t &id1, intptr_t &id2) const override; void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; @@ -455,8 +455,8 @@ public: bool ReadValue(FSerializer &ar, const char *key, void *addr) const override; void SetPointer(void *base, unsigned offset, TArray *special = NULL) override; - virtual bool IsMatch(intptr_t id1, intptr_t id2) const; - virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; + bool IsMatch(intptr_t id1, intptr_t id2) const override; + void GetTypeIDs(intptr_t &id1, intptr_t &id2) const override; }; // Compound types ----------------------------------------------------------- @@ -479,8 +479,8 @@ public: unsigned int ElementCount; unsigned int ElementSize; - virtual bool IsMatch(intptr_t id1, intptr_t id2) const; - virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; + bool IsMatch(intptr_t id1, intptr_t id2) const override; + void GetTypeIDs(intptr_t &id1, intptr_t &id2) const override; void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; @@ -507,8 +507,8 @@ public: PType *ElementType; PStruct *BackingType; - virtual bool IsMatch(intptr_t id1, intptr_t id2) const; - virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; + bool IsMatch(intptr_t id1, intptr_t id2) const override; + void GetTypeIDs(intptr_t &id1, intptr_t &id2) const override; void WriteValue(FSerializer &ar, const char *key, const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key, void *addr) const override; @@ -540,8 +540,8 @@ public: VMFunction *mConstructor = nullptr; VMFunction *mDestructor = nullptr; - virtual PField *AddField(FName name, PType *type, uint32_t flags=0); - virtual PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0); + PField *AddField(FName name, PType *type, uint32_t flags=0) override; + PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0) override; void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index b62e22993..74cba2701 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -78,7 +78,8 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) static int CheckForTexture(const FString& name, int type, int flags) { - return TexMan.CheckForTexture(name, static_cast(type), flags).GetIndex(); + // ForceLookup is intentionally blocked here, this flag is for internal use only. + return TexMan.CheckForTexture(name, static_cast(type), (flags & ~FTextureManager::TEXMAN_ForceLookup)).GetIndex(); } DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture)