mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-02-05 10:10:36 +03:00
Cstrike: Do some cleanup for the sake of consistency and readability
This commit is contained in:
parent
864e0b88eb
commit
84c320d539
File diff suppressed because it is too large
Load Diff
@ -14,16 +14,9 @@
|
|||||||
#include "amxxmodule.h"
|
#include "amxxmodule.h"
|
||||||
#include "MemoryUtils.h"
|
#include "MemoryUtils.h"
|
||||||
|
|
||||||
bool UTIL_IsPlayer(AMX* amx, edict_t* pPlayer)
|
bool UTIL_IsPlayer(edict_t *pPlayer)
|
||||||
{
|
{
|
||||||
bool player = false;
|
return strcmp(STRING(pPlayer->v.classname), "player") == 0;
|
||||||
|
|
||||||
if (strcmp(STRING(pPlayer->v.classname), "player") == 0)
|
|
||||||
{
|
|
||||||
player = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
|
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
|
||||||
@ -32,73 +25,6 @@ void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
|
|||||||
WRITE_BYTE(HUD_PRINTCENTER); // 1 = console, 2 = console, 3 = chat, 4 = center, 5 = radio
|
WRITE_BYTE(HUD_PRINTCENTER); // 1 = console, 2 = console, 3 = chat, 4 = center, 5 = radio
|
||||||
WRITE_STRING(message);
|
WRITE_STRING(message);
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
/*
|
|
||||||
The byte above seems to use these:
|
|
||||||
#define HUD_PRINTNOTIFY 1
|
|
||||||
#define HUD_PRINTCONSOLE 2
|
|
||||||
#define HUD_PRINTTALK 3
|
|
||||||
#define HUD_PRINTCENTER 4
|
|
||||||
#define HUD_PRINTRADIO 5
|
|
||||||
However both 1 and 2 seems to go to console with Steam CS.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void *UTIL_FindAddressFromEntry(const char *entry, bool isHidden, const char *library)
|
|
||||||
{
|
|
||||||
void *addressInBase = NULL;
|
|
||||||
void *finalAddress;
|
|
||||||
|
|
||||||
if (strcmp(library, "mod") == 0)
|
|
||||||
{
|
|
||||||
addressInBase = (void *)MDLL_Spawn;
|
|
||||||
}
|
|
||||||
else if (strcmp(library, "engine") == 0)
|
|
||||||
{
|
|
||||||
addressInBase = (void *)gpGlobals;
|
|
||||||
}
|
|
||||||
|
|
||||||
finalAddress = NULL;
|
|
||||||
|
|
||||||
if (*entry != '\\')
|
|
||||||
{
|
|
||||||
#if defined(WIN32)
|
|
||||||
|
|
||||||
MEMORY_BASIC_INFORMATION mem;
|
|
||||||
|
|
||||||
if (VirtualQuery(addressInBase, &mem, sizeof(mem)))
|
|
||||||
{
|
|
||||||
finalAddress = g_MemUtils.ResolveSymbol(mem.AllocationBase, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
|
||||||
|
|
||||||
Dl_info info;
|
|
||||||
|
|
||||||
if (dladdr(addressInBase, &info) != 0)
|
|
||||||
{
|
|
||||||
void *handle = dlopen(info.dli_fname, RTLD_NOW);
|
|
||||||
if (handle)
|
|
||||||
{
|
|
||||||
if (isHidden)
|
|
||||||
{
|
|
||||||
finalAddress = g_MemUtils.ResolveSymbol(handle, entry);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
finalAddress = dlsym(handle, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
dlclose(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
finalAddress = g_MemUtils.DecodeAndFindPattern(addressInBase, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalAddress != NULL ? finalAddress : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UTIL_CheckForPublic(const char *publicname)
|
bool UTIL_CheckForPublic(const char *publicname)
|
||||||
@ -110,7 +36,7 @@ bool UTIL_CheckForPublic(const char *publicname)
|
|||||||
|
|
||||||
strncpy(blah, publicname, sizeof(blah)- 1);
|
strncpy(blah, publicname, sizeof(blah)- 1);
|
||||||
|
|
||||||
while ((amx = MF_GetScriptAmx(i++)) != NULL)
|
while ((amx = MF_GetScriptAmx(i++)))
|
||||||
{
|
{
|
||||||
if (MF_AmxFindPublic(amx, blah, &iFunctionIndex) == AMX_ERR_NONE)
|
if (MF_AmxFindPublic(amx, blah, &iFunctionIndex) == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <IGameConfigs.h>
|
#include <IGameConfigs.h>
|
||||||
|
|
||||||
bool UTIL_IsPlayer(AMX* amx, edict_t* pPlayer);
|
bool UTIL_IsPlayer(edict_t *pPlayer);
|
||||||
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
|
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
|
||||||
void *UTIL_FindAddressFromEntry(const char *entry, bool isHidden = false, const char *library = "mod");
|
void *UTIL_FindAddressFromEntry(const char *entry, bool isHidden = false, const char *library = "mod");
|
||||||
bool UTIL_CheckForPublic(const char *publicname);
|
bool UTIL_CheckForPublic(const char *publicname);
|
||||||
@ -193,4 +193,35 @@ class EHANDLE
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CUnifiedSignals
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
void Update(void)
|
||||||
|
{
|
||||||
|
m_flState = m_flSignal;
|
||||||
|
m_flSignal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal(int flags)
|
||||||
|
{
|
||||||
|
m_flSignal |= flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetSignal(void)
|
||||||
|
{
|
||||||
|
return m_flSignal;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetState(void)
|
||||||
|
{
|
||||||
|
return m_flState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int m_flSignal;
|
||||||
|
int m_flState;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CSTRIKE_UTILS_H
|
#endif // CSTRIKE_UTILS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user