• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

This is a fork of Zandronum Beta for TSPG.


Commit MetaInfo

Revision7e0a46587fd030775105391f24817f60e52d701c (tree)
Time2021-12-13 07:55:44
AuthorJoshua Surace <doomjoshuaboy@live...>
CommiterJoshua Surace

Log Message

Fixed the time load for badwords to 10 minutes instead of 2 seconds

Change Summary

Incremental Difference

diff -r b28ddce5f134 -r 7e0a46587fd0 src/tspg_badwords.cpp
--- a/src/tspg_badwords.cpp Mon Dec 06 12:29:50 2021 +1100
+++ b/src/tspg_badwords.cpp Mon Dec 13 09:55:44 2021 +1100
@@ -26,48 +26,48 @@
2626
2727 #define badwords_Print(fmt, ...) \
2828 if (tspg_badwords_debug) { \
29- Printf(fmt, ##__VA_ARGS__); \
30- }
31-
32-enum class BadWordType
33-{
34- Word,
35- Includes
36-};
37-
38-struct BadWordEntry
39-{
40- BadWordType type;
41- FString word;
42-};
29+ Printf(fmt, ##__VA_ARGS__); \
30+ }
31+
32+enum class BadWordType
33+{
34+ Word,
35+ Includes
36+};
37+
38+struct BadWordEntry
39+{
40+ BadWordType type;
41+ FString word;
42+};
4343
4444 CVAR(String, tspg_badwordsfile, "", TSPG_NOSET);
4545 CVAR(Bool, tspg_badwords_debug, false, TSPG_NOSET);
46-CUSTOM_CVAR(Int, tspg_badwordsreloadtime, 2, TSPG_NOSET)
46+CUSTOM_CVAR(Int, tspg_badwordsreloadtime, 600, TSPG_NOSET)
4747 {
4848 if (self.GetGenericRep(CVAR_Int).Int < 1)
4949 self = 1;
5050 }
5151
52-CUSTOM_CVAR(Bool, tspg_badwordsenabled, false, TSPG_NOSET)
52+CUSTOM_CVAR(Bool, tspg_badwordsenabled, false, TSPG_NOSET)
5353 {
5454 if (self)
55- BADWORDS_Init();
55+ BADWORDS_Init();
5656 else
5757 BADWORDS_Shutdown();
58-}
59-
60-static TArray<BadWordEntry> BadWords;
61-
58+}
59+
60+static TArray<BadWordEntry> BadWords;
61+
6262 static bool badwords_Load();
6363 static bool badwords_LoadFile(const char *filename, const char *includedFrom = nullptr, int includeLine = -1);
64-static void badwords_Clear();
64+static void badwords_Clear();
6565 static bool badwords_CheckStringEquals(FString text);
6666 static bool badwords_CheckStringWords(FString text);
6767 static bool badwords_CheckStringIncludes(FString text);
6868
69-static unsigned lastReload = 0;
70-
69+static unsigned lastReload = 0;
70+
7171 void BADWORDS_Init()
7272 {
7373 if (!tspg_badwordsenabled)
@@ -82,8 +82,8 @@
8282 return;
8383
8484 badwords_Clear();
85-}
86-
85+}
86+
8787 bool badwords_Load()
8888 {
8989 if (BadWords.Size() > 0)
@@ -105,8 +105,8 @@
105105 lastReload = I_MSTime();
106106
107107 return true;
108-}
109-
108+}
109+
110110 bool badwords_LoadFile(const char *filename, const char *includedFrom, int includeLine)
111111 {
112112 // check if we can read the file first
@@ -203,101 +203,101 @@
203203 buffer.AppendFormat("%c", c);
204204 }
205205
206- // Now check the words
207- for (size_t i = 0; i < BadWords.Size(); i++)
208- {
209- BadWordEntry *entry = &BadWords[i];
210-
211- if (entry->type != BadWordType::Word)
212- {
213- continue;
214- }
215-
216- if (entry->word.CompareNoCase(buffer) == 0)
206+ // Now check the words
207+ for (size_t i = 0; i < BadWords.Size(); i++)
208+ {
209+ BadWordEntry *entry = &BadWords[i];
210+
211+ if (entry->type != BadWordType::Word)
217212 {
218- badwords_Print("badwords_CheckStringEquals: Got a match for \"%s\".\n", entry->word.GetChars());
219- return true;
220- }
213+ continue;
214+ }
215+
216+ if (entry->word.CompareNoCase(buffer) == 0)
217+ {
218+ badwords_Print("badwords_CheckStringEquals: Got a match for \"%s\".\n", entry->word.GetChars());
219+ return true;
220+ }
221221 }
222222
223223 return false;
224224 }
225-
226-static bool badwords_CheckStringWords(FString text)
227-{
228- TArray<FString> words;
229- FString buffer;
230-
231- for (size_t i = 0; i < text.Len(); i++)
232- {
233- char c = text[i];
234-
235- // If we hit a space, push it to the array
236- if (c == ' ')
237- {
238- if (buffer.Len() >= 1)
239- {
240- words.Push(buffer);
241- buffer = "";
242- }
243-
244- continue;
245- }
246-
247- // Ignore it if it's not alphanumeric
248- if (!isalnum(c))
249- {
250- continue;
251- }
252-
253- // Add it to the buffer
254- buffer.AppendFormat("%c", c);
255- }
256-
257- // Push anything left over in the buffer
258- if (buffer.Len() >= 1)
259- {
260- words.Push(buffer);
261- buffer = "";
262- }
263-
264- // Now check the words
265- for (size_t i = 0; i < BadWords.Size(); i++) {
266- BadWordEntry *entry = &BadWords[i];
267-
268- if (entry->type != BadWordType::Word)
269- {
270- continue;
271- }
272-
273- for (size_t j = 0; j < words.Size(); j++)
274- {
275- FString word = words[j];
276-
277- if (entry->word.CompareNoCase(word) == 0)
225+
226+static bool badwords_CheckStringWords(FString text)
227+{
228+ TArray<FString> words;
229+ FString buffer;
230+
231+ for (size_t i = 0; i < text.Len(); i++)
232+ {
233+ char c = text[i];
234+
235+ // If we hit a space, push it to the array
236+ if (c == ' ')
237+ {
238+ if (buffer.Len() >= 1)
278239 {
279- badwords_Print("badwords_CheckStringWords: Got a match for \"%s\".\n", entry->word.GetChars());
280- return true;
281- }
282- }
283- }
284-
285- // We found nothing
286- return false;
287-}
288-
240+ words.Push(buffer);
241+ buffer = "";
242+ }
243+
244+ continue;
245+ }
246+
247+ // Ignore it if it's not alphanumeric
248+ if (!isalnum(c))
249+ {
250+ continue;
251+ }
252+
253+ // Add it to the buffer
254+ buffer.AppendFormat("%c", c);
255+ }
256+
257+ // Push anything left over in the buffer
258+ if (buffer.Len() >= 1)
259+ {
260+ words.Push(buffer);
261+ buffer = "";
262+ }
263+
264+ // Now check the words
265+ for (size_t i = 0; i < BadWords.Size(); i++) {
266+ BadWordEntry *entry = &BadWords[i];
267+
268+ if (entry->type != BadWordType::Word)
269+ {
270+ continue;
271+ }
272+
273+ for (size_t j = 0; j < words.Size(); j++)
274+ {
275+ FString word = words[j];
276+
277+ if (entry->word.CompareNoCase(word) == 0)
278+ {
279+ badwords_Print("badwords_CheckStringWords: Got a match for \"%s\".\n", entry->word.GetChars());
280+ return true;
281+ }
282+ }
283+ }
284+
285+ // We found nothing
286+ return false;
287+}
288+
289289 bool badwords_CheckStringIncludes(FString text)
290290 {
291291 FString lowerText(text);
292292 lowerText.ToLower();
293293
294- // Now check the words
295- for (size_t i = 0; i < BadWords.Size(); i++) {
296- BadWordEntry *entry = &BadWords[i];
297-
298- if (entry->type != BadWordType::Includes)
299- {
300- continue;
294+ // Now check the words
295+ for (size_t i = 0; i < BadWords.Size(); i++) {
296+ BadWordEntry *entry = &BadWords[i];
297+
298+ if (entry->type != BadWordType::Includes)
299+ {
300+ continue;
301301 }
302302
303303 FString lowerWord(entry->word);
@@ -307,7 +307,7 @@
307307 {
308308 badwords_Print("badwords_CheckStringIncludes: Got a match for \"%s\".\n", entry->word.GetChars());
309309 return true;
310- }
310+ }
311311 }
312312
313313 return false;