diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-07-01 02:43:29 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-07-01 02:43:29 +0100 |
commit | 5c6a48b2ff362a70416a6a00fda7d06e0f276f2d (patch) | |
tree | 62cf542c68d91aa6f7a4e3bfa9eddca4ab352970 /src/T2DLL/T2WordDefArray.cpp | |
parent | c0c336500955a23e344651e5412c9d9d441ef4ee (diff) | |
download | t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.tar.gz t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.zip |
i am in hell
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2WordDefArray.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/T2DLL/T2WordDefArray.cpp b/src/T2DLL/T2WordDefArray.cpp index 76b3248..46f05d2 100644 --- a/src/T2DLL/T2WordDefArray.cpp +++ b/src/T2DLL/T2WordDefArray.cpp @@ -15,35 +15,35 @@ void T2WordDefArray::GetWords(unsigned int sex, unsigned int age, unsigned int f CResFile resFile; if (resFile.OpenResource(mInstance, 1, 'WoDf')) { - unsigned int numOfWordDef; - resFile >> numOfWordDef; + unsigned int numOfWordDefs; + resFile >> numOfWordDefs; - T2WordDef *wordDef = new T2WordDef[numOfWordDef]; + T2WordDef *theWordDef = new T2WordDef[numOfWordDefs]; - for (unsigned int i = 0; i < numOfWordDef; i++) - wordDef[i].Read(resFile); + for (unsigned int i = 0; i < numOfWordDefs; i++) + theWordDef[i].Read(resFile); - if (numOfWordDef > 0) { - unsigned char *seen = (unsigned char *) malloc(numOfWordDef); - memset(seen, 0, numOfWordDef); + if (numOfWordDefs > 0) { + unsigned char *seenArray = (unsigned char *) malloc(numOfWordDefs); + memset(seenArray, 0, numOfWordDefs); - unsigned int i = 0; - while ((outStr == "") && i < numOfWordDef) { - int rnd = UT2Utils::Randomize(numOfWordDef); - if (!seen[rnd]) { - seen[rnd] = true; - wordDef[rnd].GetWords(sex, age, flags, level, outStr); + unsigned int i = 0, wordInd; + while ((outStr == "") && i < numOfWordDefs) { + wordInd = UT2Utils::Randomize(numOfWordDefs); + if (!seenArray[wordInd]) { + seenArray[wordInd] = true; + theWordDef[wordInd].GetWords(sex, age, flags, level, outStr); } else { - for (i = 0; i < numOfWordDef; i++) { - if (!seen[i]) + for (i = 0; i < numOfWordDefs; i++) { + if (!seenArray[i]) break; } } } - free(seen); + free(seenArray); } - delete[] wordDef; + delete[] theWordDef; } } |