Skip to content

Commit d1d6aed

Browse files
adriansmaresarthurdead
authored andcommitted
Remove removed containers
Co-authored-by: arthurdead <arthur.kinder@gmail.com>
1 parent 2802d38 commit d1d6aed

4 files changed

Lines changed: 22 additions & 24 deletions

File tree

AMBuildScript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class ExtensionConfig(object):
126126
'-fvisibility=hidden',
127127
]
128128
cxx.cxxflags += [
129-
'-std=c++11',
129+
'-std=c++14',
130130
'-fno-exceptions',
131131
'-fno-threadsafe-statics',
132132
'-Wno-non-virtual-dtor',

types/mempatch.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ HandleType_t g_MemoryPatchType = 0;
1313
void ByteVectorRead(ByteVector &vec, uint8_t* mem, size_t count) {
1414
vec.clear();
1515
for (size_t i = 0; i < count; i++) {
16-
vec.append(mem[i]);
16+
vec.push_back(mem[i]);
1717
}
1818
}
1919

2020
void ByteVectorWrite(ByteVector &vec, uint8_t* mem) {
21-
for (size_t i = 0; i < vec.length(); i++) {
21+
for (size_t i = 0; i < vec.size(); i++) {
2222
mem[i] = vec[i];
2323
}
2424
}
@@ -27,38 +27,38 @@ class MemoryPatch {
2727
public:
2828
MemoryPatch(uintptr_t pAddress, const MemPatchGameConfig::MemoryPatchInfo& info) {
2929
for (auto bit : info.vecPatch) {
30-
this->vecPatch.append(bit);
30+
this->vecPatch.push_back(bit);
3131
}
3232
for (auto bit : info.vecVerify) {
33-
this->vecVerify.append(bit);
33+
this->vecVerify.push_back(bit);
3434
}
3535
for (auto bit : info.vecPreserve) {
36-
this->vecPreserve.append(bit);
36+
this->vecPreserve.push_back(bit);
3737
}
3838

3939
// ignore offset if address is bad
4040
this->pAddress = pAddress ? pAddress + (info.offset) : 0;
4141
}
4242

4343
bool Enable() {
44-
if (vecRestore.length() > 0) {
44+
if (vecRestore.size() > 0) {
4545
// already patched, disregard
4646
return false;
4747
}
4848

4949
if (!this->Verify()) {
5050
return false;
5151
}
52-
ByteVectorRead(vecRestore, (uint8_t*) pAddress, vecPatch.length());
52+
ByteVectorRead(vecRestore, (uint8_t*) pAddress, vecPatch.size());
5353

54-
SourceHook::SetMemAccess((void*) this->pAddress, vecPatch.length() * sizeof(uint8_t),
54+
SourceHook::SetMemAccess((void*) this->pAddress, vecPatch.size() * sizeof(uint8_t),
5555
SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC);
5656
ByteVectorWrite(vecPatch, (uint8_t*) pAddress);
5757

5858
//
59-
for (size_t i = 0; i < vecPatch.length(); i++) {
59+
for (size_t i = 0; i < vecPatch.size(); i++) {
6060
uint8_t preserveBits = 0;
61-
if (i < vecPreserve.length()) {
61+
if (i < vecPreserve.size()) {
6262
preserveBits = vecPreserve[i];
6363
}
6464
*((uint8_t*) pAddress + i) = (vecPatch[i] & ~preserveBits) | (vecRestore[i] & preserveBits);
@@ -68,7 +68,7 @@ class MemoryPatch {
6868
}
6969

7070
void Disable() {
71-
if (vecRestore.length() == 0) {
71+
if (vecRestore.size() == 0) {
7272
// no memory to restore, fug
7373
return;
7474
}
@@ -82,7 +82,7 @@ class MemoryPatch {
8282
}
8383

8484
auto addr = (uint8_t*) pAddress;
85-
for (size_t i = 0; i < this->vecVerify.length(); i++) {
85+
for (size_t i = 0; i < this->vecVerify.size(); i++) {
8686
if (vecVerify[i] != '*' && vecVerify[i] != addr[i]) {
8787
return false;
8888
}
@@ -129,8 +129,8 @@ cell_t sm_MemoryPatchLoadFromConfig(IPluginContext *pContext, const cell_t *para
129129
}
130130

131131
void* addr;
132-
if (!pConfig->GetMemSig(info.signature.chars(), &addr)) {
133-
return pContext->ThrowNativeError("Failed to locate signature for '%s' (mempatch '%s')", info.signature.chars(), name);
132+
if (!pConfig->GetMemSig(info.signature.c_str(), &addr)) {
133+
return pContext->ThrowNativeError("Failed to locate signature for '%s' (mempatch '%s')", info.signature.c_str(), name);
134134
}
135135

136136
MemoryPatch *pMemoryPatch = new MemoryPatch((uintptr_t) addr, info);

userconf/mempatches.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ unsigned int g_IgnoreLevel;
1010
// The parent section type of a platform specific "windows" or "linux" section.
1111
MemPatchGameConfig::ParseState g_PlatformOnlyState;
1212

13-
ke::AString g_CurrentSection;
13+
std::string g_CurrentSection;
1414
MemPatchGameConfig::MemoryPatchInfo *g_CurrentPatchInfo;
1515

1616
/**
@@ -25,7 +25,7 @@ ByteVector ByteVectorFromString(const char* s) {
2525
char* p = strtok(s1, "\\x ");
2626
while (p) {
2727
uint8_t byte = strtol(p, nullptr, 16);
28-
payload.append(byte);
28+
payload.push_back(byte);
2929
p = strtok(nullptr, "\\x ");
3030
}
3131
free(s1);
@@ -72,7 +72,7 @@ SMCResult MemPatchGameConfig::ReadSMC_NewSection(const SMCStates *states, const
7272
// Handle platform specific sections first.
7373
if (IsTargetPlatformSection(name)) {
7474
if (g_IgnoreLevel > 0) {
75-
smutils->LogError(myself, "Unreachable platform specific section in \"%s\" Function: line: %i col: %i", g_CurrentPatchInfo->signature.chars(), states->line, states->col);
75+
smutils->LogError(myself, "Unreachable platform specific section in \"%s\" Function: line: %i col: %i", g_CurrentPatchInfo->signature.c_str(), states->line, states->col);
7676
return SMCResult_HaltFail;
7777
}
7878

@@ -85,7 +85,7 @@ SMCResult MemPatchGameConfig::ReadSMC_NewSection(const SMCStates *states, const
8585
return SMCResult_Continue;
8686
} else if (IsNonTargetPlatformSection(name)) {
8787
if (g_PlatformOnlyState != PState_None) {
88-
smutils->LogError(myself, "Unreachable platform specific section in \"%s\" Function: line: %i col: %i", g_CurrentPatchInfo->signature.chars(), states->line, states->col);
88+
smutils->LogError(myself, "Unreachable platform specific section in \"%s\" Function: line: %i col: %i", g_CurrentPatchInfo->signature.c_str(), states->line, states->col);
8989
return SMCResult_HaltFail;
9090
}
9191
g_IgnoreLevel++;
@@ -168,7 +168,7 @@ SMCResult MemPatchGameConfig::ReadSMC_LeavingSection(const SMCStates *states) {
168168
case PState_Runtime:
169169
// pop section info
170170
g_ParseState = PState_Root;
171-
m_MemPatchInfoMap.insert(g_CurrentSection.chars(), g_CurrentPatchInfo);
171+
m_MemPatchInfoMap.insert(g_CurrentSection.c_str(), g_CurrentPatchInfo);
172172

173173
g_CurrentPatchInfo = nullptr;
174174
g_CurrentSection = "";

userconf/mempatches.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
#include "extension.h"
88

9-
#include <am-string.h>
10-
#include <am-vector.h>
119
#include <sm_stringhashmap.h>
1210

13-
using ByteVector = ke::Vector<uint8_t>;
11+
using ByteVector = std::vector<uint8_t>;
1412

1513
class MemPatchGameConfig : public ITextListener_SMC {
1614
public:
@@ -22,7 +20,7 @@ class MemPatchGameConfig : public ITextListener_SMC {
2220
public:
2321
class MemoryPatchInfo {
2422
public:
25-
ke::AString signature;
23+
std::string signature;
2624
size_t offset;
2725
ByteVector vecPatch, vecVerify, vecPreserve;
2826
};

0 commit comments

Comments
 (0)