MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / cheat_getID

Function cheat_getID

TheForceEngine/TFE_DarkForces/cheats.cpp:77–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 }
76
77 CheatID cheat_getID()
78 {
79 if (!s_cheatCharIndex)
80 {
81 return CHEAT_NONE;
82 }
83
84 s32 maxMatchIndex = 0;
85 const size_t cheatCount = TFE_ARRAYSIZE(c_cheatStrings);
86 for (size_t cheatIndex = 0; cheatIndex < cheatCount; cheatIndex++)
87 {
88 const char* srcCheatStr = c_cheatStrings[cheatIndex];
89 for (s32 c = 0; c <= s_cheatCharIndex; c++)
90 {
91 if (srcCheatStr[c])
92 {
93 if (srcCheatStr[c] != s_cheatString[c])
94 {
95 break;
96 }
97 }
98 else if (s_cheatString[c])
99 {
100 break;
101 }
102
103 // If the strings match to the end, clear out the data and return the cheat ID.
104 maxMatchIndex = max(maxMatchIndex, c + 1);
105 if (!srcCheatStr[c + 1])
106 {
107 cheat_clearData();
108 return CheatID(cheatIndex + 1);
109 }
110 }
111 }
112
113 // If we match don't match up to this point, then clear out the data.
114 if (maxMatchIndex != s_cheatCharIndex)
115 {
116 cheat_clearData();
117 }
118 return CHEAT_NONE;
119 }
120
121 const char* cheat_getStringFromID(CheatID id)
122 {

Callers 1

handleBufferedInputFunction · 0.85

Calls 3

maxFunction · 0.85
cheat_clearDataFunction · 0.85
CheatIDEnum · 0.85

Tested by

no test coverage detected