1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Replaced some usages of void * with more clear CPack *

This commit is contained in:
Ivan Savenko 2024-02-12 12:53:10 +02:00
parent b796ed8626
commit 392c360f88
5 changed files with 18 additions and 18 deletions

View File

@ -59,8 +59,8 @@ template<typename T> class CApplyOnCL;
class CBaseForCLApply class CBaseForCLApply
{ {
public: public:
virtual void applyOnClAfter(CClient * cl, void * pack) const =0; virtual void applyOnClAfter(CClient * cl, CPack * pack) const =0;
virtual void applyOnClBefore(CClient * cl, void * pack) const =0; virtual void applyOnClBefore(CClient * cl, CPack * pack) const =0;
virtual ~CBaseForCLApply(){} virtual ~CBaseForCLApply(){}
template<typename U> static CBaseForCLApply * getApplier(const U * t = nullptr) template<typename U> static CBaseForCLApply * getApplier(const U * t = nullptr)
@ -72,13 +72,13 @@ public:
template<typename T> class CApplyOnCL : public CBaseForCLApply template<typename T> class CApplyOnCL : public CBaseForCLApply
{ {
public: public:
void applyOnClAfter(CClient * cl, void * pack) const override void applyOnClAfter(CClient * cl, CPack * pack) const override
{ {
T * ptr = static_cast<T *>(pack); T * ptr = static_cast<T *>(pack);
ApplyClientNetPackVisitor visitor(*cl, *cl->gameState()); ApplyClientNetPackVisitor visitor(*cl, *cl->gameState());
ptr->visit(visitor); ptr->visit(visitor);
} }
void applyOnClBefore(CClient * cl, void * pack) const override void applyOnClBefore(CClient * cl, CPack * pack) const override
{ {
T * ptr = static_cast<T *>(pack); T * ptr = static_cast<T *>(pack);
ApplyFirstClientNetPackVisitor visitor(*cl, *cl->gameState()); ApplyFirstClientNetPackVisitor visitor(*cl, *cl->gameState());
@ -89,12 +89,12 @@ public:
template<> class CApplyOnCL<CPack>: public CBaseForCLApply template<> class CApplyOnCL<CPack>: public CBaseForCLApply
{ {
public: public:
void applyOnClAfter(CClient * cl, void * pack) const override void applyOnClAfter(CClient * cl, CPack * pack) const override
{ {
logGlobal->error("Cannot apply on CL plain CPack!"); logGlobal->error("Cannot apply on CL plain CPack!");
assert(0); assert(0);
} }
void applyOnClBefore(CClient * cl, void * pack) const override void applyOnClBefore(CClient * cl, CPack * pack) const override
{ {
logGlobal->error("Cannot apply on CL plain CPack!"); logGlobal->error("Cannot apply on CL plain CPack!");
assert(0); assert(0);

View File

@ -59,7 +59,7 @@ template <typename T> class CApplyOnGS;
class CBaseForGSApply class CBaseForGSApply
{ {
public: public:
virtual void applyOnGS(CGameState *gs, void *pack) const =0; virtual void applyOnGS(CGameState *gs, CPack * pack) const =0;
virtual ~CBaseForGSApply() = default; virtual ~CBaseForGSApply() = default;
template<typename U> static CBaseForGSApply *getApplier(const U * t=nullptr) template<typename U> static CBaseForGSApply *getApplier(const U * t=nullptr)
{ {
@ -70,7 +70,7 @@ public:
template <typename T> class CApplyOnGS : public CBaseForGSApply template <typename T> class CApplyOnGS : public CBaseForGSApply
{ {
public: public:
void applyOnGS(CGameState *gs, void *pack) const override void applyOnGS(CGameState *gs, CPack * pack) const override
{ {
T *ptr = static_cast<T*>(pack); T *ptr = static_cast<T*>(pack);

View File

@ -315,7 +315,7 @@ public:
void ptrAllocated(const T *ptr, ui32 pid) void ptrAllocated(const T *ptr, ui32 pid)
{ {
if(smartPointerSerialization && pid != 0xffffffff) if(smartPointerSerialization && pid != 0xffffffff)
loadedPointers[pid] = (void*)ptr; //add loaded pointer to our lookup map; cast is to avoid errors with const T* pt loadedPointers[pid] = static_cast<void*>(ptr); //add loaded pointer to our lookup map; cast is to avoid errors with const T* pt
} }
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr) template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)

View File

@ -82,7 +82,7 @@ template <typename T> class CApplyOnGH;
class CBaseForGHApply class CBaseForGHApply
{ {
public: public:
virtual bool applyOnGH(CGameHandler * gh, CGameState * gs, void * pack) const =0; virtual bool applyOnGH(CGameHandler * gh, CGameState * gs, CPack * pack) const =0;
virtual ~CBaseForGHApply(){} virtual ~CBaseForGHApply(){}
template<typename U> static CBaseForGHApply *getApplier(const U * t=nullptr) template<typename U> static CBaseForGHApply *getApplier(const U * t=nullptr)
{ {
@ -93,7 +93,7 @@ public:
template <typename T> class CApplyOnGH : public CBaseForGHApply template <typename T> class CApplyOnGH : public CBaseForGHApply
{ {
public: public:
bool applyOnGH(CGameHandler * gh, CGameState * gs, void * pack) const override bool applyOnGH(CGameHandler * gh, CGameState * gs, CPack * pack) const override
{ {
T *ptr = static_cast<T*>(pack); T *ptr = static_cast<T*>(pack);
try try
@ -116,7 +116,7 @@ template <>
class CApplyOnGH<CPack> : public CBaseForGHApply class CApplyOnGH<CPack> : public CBaseForGHApply
{ {
public: public:
bool applyOnGH(CGameHandler * gh, CGameState * gs, void * pack) const override bool applyOnGH(CGameHandler * gh, CGameState * gs, CPack * pack) const override
{ {
logGlobal->error("Cannot apply on GH plain CPack!"); logGlobal->error("Cannot apply on GH plain CPack!");
assert(0); assert(0);

View File

@ -31,8 +31,8 @@ template<typename T> class CApplyOnServer;
class CBaseForServerApply class CBaseForServerApply
{ {
public: public:
virtual bool applyOnServerBefore(CVCMIServer * srv, void * pack) const =0; virtual bool applyOnServerBefore(CVCMIServer * srv, CPack * pack) const =0;
virtual void applyOnServerAfter(CVCMIServer * srv, void * pack) const =0; virtual void applyOnServerAfter(CVCMIServer * srv, CPack * pack) const =0;
virtual ~CBaseForServerApply() {} virtual ~CBaseForServerApply() {}
template<typename U> static CBaseForServerApply * getApplier(const U * t = nullptr) template<typename U> static CBaseForServerApply * getApplier(const U * t = nullptr)
{ {
@ -43,7 +43,7 @@ public:
template <typename T> class CApplyOnServer : public CBaseForServerApply template <typename T> class CApplyOnServer : public CBaseForServerApply
{ {
public: public:
bool applyOnServerBefore(CVCMIServer * srv, void * pack) const override bool applyOnServerBefore(CVCMIServer * srv, CPack * pack) const override
{ {
T * ptr = static_cast<T *>(pack); T * ptr = static_cast<T *>(pack);
ClientPermissionsCheckerNetPackVisitor checker(*srv); ClientPermissionsCheckerNetPackVisitor checker(*srv);
@ -59,7 +59,7 @@ public:
return false; return false;
} }
void applyOnServerAfter(CVCMIServer * srv, void * pack) const override void applyOnServerAfter(CVCMIServer * srv, CPack * pack) const override
{ {
T * ptr = static_cast<T *>(pack); T * ptr = static_cast<T *>(pack);
ApplyOnServerAfterAnnounceNetPackVisitor applier(*srv); ApplyOnServerAfterAnnounceNetPackVisitor applier(*srv);
@ -71,13 +71,13 @@ template <>
class CApplyOnServer<CPack> : public CBaseForServerApply class CApplyOnServer<CPack> : public CBaseForServerApply
{ {
public: public:
bool applyOnServerBefore(CVCMIServer * srv, void * pack) const override bool applyOnServerBefore(CVCMIServer * srv, CPack * pack) const override
{ {
logGlobal->error("Cannot apply plain CPack!"); logGlobal->error("Cannot apply plain CPack!");
assert(0); assert(0);
return false; return false;
} }
void applyOnServerAfter(CVCMIServer * srv, void * pack) const override void applyOnServerAfter(CVCMIServer * srv, CPack * pack) const override
{ {
logGlobal->error("Cannot apply plain CPack!"); logGlobal->error("Cannot apply plain CPack!");
assert(0); assert(0);