Skip to content
This repository was archived by the owner on Sep 24, 2023. It is now read-only.

Commit bf73fa2

Browse files
committed
Fix double-insert of last entity block
Release handle reference in currentEntityMap once it's been pushed so it doesn't get re-added once all the keys have been finished parsing.
1 parent 2f5a34e commit bf73fa2

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

scripting/level_keyvalues.sp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#pragma newdecls required
1717

18-
#define PLUGIN_VERSION "0.1.1"
18+
#define PLUGIN_VERSION "0.1.2"
1919
public Plugin myinfo = {
2020
name = "Level KeyValues",
2121
author = "nosoop",
@@ -99,8 +99,6 @@ static ArrayList ParseEntityList(const char mapEntities[2097152]) {
9999

100100
ArrayList mapEntityList = new ArrayList();
101101

102-
int nKeys;
103-
104102
char key[256], value[256];
105103

106104
StringMultiMap currentEntityMap;
@@ -111,19 +109,18 @@ static ArrayList ParseEntityList(const char mapEntities[2097152]) {
111109
switch(lineBuffer[0]) {
112110
case '{': {
113111
currentEntityMap = new StringMultiMap();
114-
nKeys++;
115112
}
116113
case '}': {
117114
if (ForwardOnEntityKeysParsed(currentEntityMap) != Plugin_Stop) {
118115
mapEntityList.Push(currentEntityMap);
116+
currentEntityMap = null; // don't hold a reference that might be pushed later
119117
} else {
120118
delete currentEntityMap;
121119
}
122120

123121
// next open bracket starts on same line
124122
if (lineBuffer[1] == '{') {
125123
currentEntityMap = new StringMultiMap();
126-
nKeys++;
127124
}
128125
}
129126
default: {

0 commit comments

Comments
 (0)