Skip to content

Commit 27856dd

Browse files
committed
Fixes
1 parent 1086014 commit 27856dd

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.1.4
2+
- Attempt to fix a crash
3+
14
# 1.1.3
25
- Fix an oopsie
36

mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.3.1",
2+
"geode": "4.4.0",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",
@@ -8,7 +8,7 @@
88
},
99
"id": "alphalaneous.alphas_geode_utils",
1010
"name": "Alpha's Geode Utils",
11-
"version": "v1.1.3",
11+
"version": "v1.1.4",
1212
"developer": "Alphalaneous",
1313
"description": "Miscellaneous utilities for Geode Modding",
1414
"api": {

src/hooks/CCObject.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,35 @@
99
using namespace geode::prelude;
1010
using namespace AlphaUtils;
1111

12-
static std::vector<Ref<ObjectData>> s_objectArena;
13-
static std::queue<uint32_t> s_freeArenaSlots;
12+
std::vector<Ref<ObjectData>>& getObjectArena() {
13+
static auto* arena = new std::vector<Ref<ObjectData>>();
14+
return *arena;
15+
}
16+
17+
std::queue<uint32_t>& getFreeSlots() {
18+
static auto* slots = new std::queue<uint32_t>();
19+
return *slots;
20+
}
1421

1522
uint32_t allocateObjectData(ObjectData* data) {
16-
if (!s_freeArenaSlots.empty()) {
17-
uint32_t id = s_freeArenaSlots.front(); s_freeArenaSlots.pop();
18-
s_objectArena[id] = data;
23+
auto& arena = getObjectArena();
24+
auto& slots = getFreeSlots();
25+
if (!slots.empty()) {
26+
uint32_t id = slots.front(); slots.pop();
27+
arena[id] = data;
1928
return id;
2029
} else {
21-
s_objectArena.push_back(data);
22-
return static_cast<uint32_t>(s_objectArena.size() - 1);
30+
arena.push_back(data);
31+
return static_cast<uint32_t>(arena.size() - 1);
2332
}
2433
}
2534

2635
void releaseObjectData(uint32_t id) {
27-
if (id < s_objectArena.size() && s_objectArena[id]) {
28-
s_objectArena[id] = nullptr;
29-
s_freeArenaSlots.push(id);
36+
auto& arena = getObjectArena();
37+
auto& slots = getFreeSlots();
38+
if (id < arena.size() && arena[id]) {
39+
arena[id] = nullptr;
40+
slots.push(id);
3041
}
3142
}
3243

@@ -53,8 +64,9 @@ void FieldCCObject::tryCreateData() {
5364

5465
ObjectData* FieldCCObject::getObjectData() {
5566
tryCreateData();
56-
if (m_nLuaID < s_objectArena.size()) {
57-
return s_objectArena[m_nLuaID];
67+
auto& arena = getObjectArena();
68+
if (m_nLuaID < arena.size()) {
69+
return arena[m_nLuaID];
5870
}
5971
return nullptr;
6072
}

0 commit comments

Comments
 (0)