-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
2,661 additions
and
1,138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* common.h | ||
* StatusSpec project | ||
* | ||
* Copyright (c) 2014 thesupremecommander | ||
* BSD 2-Clause License | ||
* http://opensource.org/licenses/BSD-2-Clause | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "stdafx.h" | ||
|
||
#include <cstdint> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "Color.h" | ||
#include "convar.h" | ||
#include "steam/steamclientpublic.h" | ||
|
||
#include "gamedata.h" | ||
|
||
typedef struct Replacement { | ||
std::string group; | ||
std::string replacement; | ||
} Replacement; | ||
|
||
typedef struct ColorConCommand_s { | ||
Color color; | ||
ConCommand *command; | ||
} ColorConCommand_t; | ||
|
||
inline bool DataCompare(const BYTE* pData, const BYTE* bSig, const char* szMask) { | ||
for (; *szMask; ++szMask, ++pData, ++bSig) | ||
{ | ||
if (*szMask == 'x' && *pData != *bSig) | ||
return false; | ||
} | ||
|
||
return (*szMask) == NULL; | ||
} | ||
|
||
inline DWORD FindPattern(DWORD dwAddress, DWORD dwSize, BYTE* pbSig, const char* szMask) { | ||
for (DWORD i = NULL; i < dwSize; i++) | ||
{ | ||
if (DataCompare((BYTE*)(dwAddress + i), pbSig, szMask)) | ||
return (DWORD)(dwAddress + i); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
inline DWORD SignatureScan(const char *moduleName, const char *signature, const char *mask) { | ||
#if defined _WIN32 | ||
MODULEINFO clientModInfo; | ||
const HMODULE clientModule = GetHandleOfModule(moduleName); | ||
GetModuleInformation(GetCurrentProcess(), clientModule, &clientModInfo, sizeof(MODULEINFO)); | ||
|
||
return FindPattern((DWORD)clientModule, clientModInfo.SizeOfImage, (PBYTE)signature, mask); | ||
#endif | ||
} | ||
|
||
inline void FindAndReplaceInString(std::string &str, const std::string &find, const std::string &replace) { | ||
if (find.empty()) | ||
return; | ||
|
||
size_t start_pos = 0; | ||
|
||
while ((start_pos = str.find(find, start_pos)) != std::string::npos) { | ||
str.replace(start_pos, find.length(), replace); | ||
start_pos += replace.length(); | ||
} | ||
} | ||
|
||
inline float ChangeScale(float currentValue, float currentMin, float currentMax, float newMin, float newMax) { | ||
float deltaScaler = ((newMax - newMin) / (currentMax - currentMin)); | ||
float newDelta = ((currentValue - currentMin) * deltaScaler); | ||
float newValue = newMin + newDelta; | ||
|
||
return newValue; | ||
} | ||
|
||
inline int ColorRangeRestrict(int color) { | ||
if (color < 0) return 0; | ||
else if (color > 255) return 255; | ||
else return color; | ||
} | ||
|
||
inline bool IsInteger(const std::string &s) { | ||
if (s.empty() || !isdigit(s[0])) return false; | ||
|
||
char *p; | ||
strtoull(s.c_str(), &p, 10); | ||
|
||
return (*p == 0); | ||
} | ||
|
||
inline CSteamID ConvertTextToSteamID(std::string textID) { | ||
if (IsInteger(textID)) { | ||
uint64_t steamID = strtoull(textID.c_str(), nullptr, 10); | ||
|
||
return CSteamID(steamID); | ||
} | ||
|
||
return CSteamID(); | ||
} | ||
|
||
inline std::string ConvertTreeToString(std::vector<std::string> tree) { | ||
std::stringstream ss; | ||
std::string string; | ||
|
||
for (auto iterator = tree.begin(); iterator != tree.end(); ++iterator) { | ||
ss << ">"; | ||
ss << *iterator; | ||
} | ||
|
||
ss >> string; | ||
|
||
return string; | ||
} | ||
|
||
#define PLUGIN_VERSION "0.23.0" | ||
#define PRINT_TAG() ConColorMsg(Color(0, 153, 153, 255), "[StatusSpec] ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.