-
Notifications
You must be signed in to change notification settings - Fork 5
/
OverFlowFix.gsc
252 lines (214 loc) · 5.55 KB
/
OverFlowFix.gsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
// DoktorSAS Codes
SetDvarIfNotInizialized(dvar, value){
if(!IsInizialized(dvar))
setDvar(dvar, value);
}
IsInizialized(dvar){
result = getDvar(dvar);
return result != undefined || result != "";
}
GetColor( color ){
switch(tolower(color)){
case "red":
return (0.960, 0.180, 0.180);
break;
case "black":
return (0, 0, 0);
break;
case "purple":
return (1, 0.282, 1);
break;
case "pink":
return (1, 0.623, 0.811);
break;
case "green":
return (0, 0.69, 0.15);
break;
case "blue":
return (0, 0, 1);
break;
case "lightblue":
case "light blue":
return (0.152, 0329, 0.929);
break;
case "lightgreen":
case "light green":
return (0.09, 1, 0.09);
break;
case "orange":
return (1, 0662, 0.035);
break;
case "yellow":
return (0.968, 0.992, 0.043);
break;
case "brown":
return (0.501, 0.250, 0);
break;
case "cyan":
return (0, 1, 1);
break;
case "white":
return (0, 1, 1);
break;
}
}
// CMT Frosty Codes
initOverFlowFix()
{
// tables
self.stringTable = [];
self.stringTableEntryCount = 0;
self.textTable = [];
self.textTableEntryCount = 0;
if(isDefined(level.anchorText) == false)
{
level.anchorText = createServerFontString("default",1.5);
level.anchorText setText("anchor");
level.anchorText.alpha = 0;
level.stringCount = 0;
level thread monitorOverflow();
}
}
// strings cache serverside -- all string entries are shared by every player
monitorOverflow()
{
level endon("disconnect");
for(;;)
{
if(level.stringCount >= 60)
{
level.anchorText clearAllTextAfterHudElem();
level.stringCount = 0;
foreach(player in level.players)
{
player purgeTextTable();
player purgeStringTable();
player recreateText();
}
}
wait 0.05;
}
}
setSafeText(player, text)
{
stringId = player getStringId(text);
// if the string doesn't exist add it and get its id
if(stringId == -1)
{
player addStringTableEntry(text);
stringId = player getStringId(text);
}
// update the entry for this text element
player editTextTableEntry(self.textTableIndex, stringId);
self setText(text);
}
recreateText()
{
foreach(entry in self.textTable)
entry.element setSafeText(self, lookUpStringById(entry.stringId));
}
addStringTableEntry(string)
{
// create new entry
entry = spawnStruct();
entry.id = self.stringTableEntryCount;
entry.string = string;
self.stringTable[self.stringTable.size] = entry; // add new entry
self.stringTableEntryCount++;
level.stringCount++;
}
lookUpStringById(id)
{
string = "";
foreach(entry in self.stringTable)
{
if(entry.id == id)
{
string = entry.string;
break;
}
}
return string;
}
getStringId(string)
{
id = -1;
foreach(entry in self.stringTable)
{
if(entry.string == string)
{
id = entry.id;
break;
}
}
return id;
}
getStringTableEntry(id)
{
stringTableEntry = -1;
foreach(entry in self.stringTable)
{
if(entry.id == id)
{
stringTableEntry = entry;
break;
}
}
return stringTableEntry;
}
purgeStringTable()
{
stringTable = [];
// store all used strings
foreach(entry in self.textTable)
stringTable[stringTable.size] = getStringTableEntry(entry.stringId);
self.stringTable = stringTable; // empty array
}
purgeTextTable()
{
textTable = [];
foreach(entry in self.textTable)
{
if(entry.id != -1)
textTable[textTable.size] = entry;
}
self.textTable = textTable;
}
addTextTableEntry(element, stringId)
{
entry = spawnStruct();
entry.id = self.textTableEntryCount;
entry.element = element;
entry.stringId = stringId;
element.textTableIndex = entry.id;
self.textTable[self.textTable.size] = entry;
self.textTableEntryCount++;
}
editTextTableEntry(id, stringId)
{
foreach(entry in self.textTable)
{
if(entry.id == id)
{
entry.stringId = stringId;
break;
}
}
}
deleteTextTableEntry(id)
{
foreach(entry in self.textTable)
{
if(entry.id == id)
{
entry.id = -1;
entry.stringId = -1;
}
}
}
clear(player)
{
if(self.type == "text")
player deleteTextTableEntry(self.textTableIndex);
self destroy();
}