MCPcopy Create free account
hub / github.com/TASEmulators/fceux / FCEU_LoadGameCheats

Function FCEU_LoadGameCheats

src/cheat.cpp:188–286  ·  view source on GitHub ↗

The "override_existing" parameter is used only in cheat dialog import. Since the default behaviour will reset numsubcheats to 0 everytime, In game loading, this is absolutely right, but when importing in cheat window, resetting numsubcheats to 0 will override existed cheat items to make them invalid. */

Source from the content-addressed store, hash-verified

186 invalid.
187*/
188void FCEU_LoadGameCheats(FILE *override, int override_existing)
189{
190 FILE *fp;
191 unsigned int addr;
192 unsigned int val;
193 unsigned int status;
194 unsigned int type;
195 unsigned int compare;
196 int x;
197
198 char linebuf[2048] = { 0 };
199 char namebuf[128] = { 0 };
200 int tc = 0;
201 char *fn;
202
203 if (override_existing)
204 {
205 numsubcheats = 0;
206 if (cheatMap)
207 FCEUI_RefreshCheatMap();
208 }
209
210 if(override)
211 fp = override;
212 else
213 {
214 fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT, 0, 0).c_str());
215 fp = FCEUD_UTF8fopen(fn, "rb");
216 free(fn);
217 if (!fp) {
218 return;
219 }
220 }
221
222 while(fgets(linebuf, 2048, fp) != nullptr)
223 {
224 char *tbuf = linebuf;
225 int doc = 0;
226
227 addr = val = compare = status = type = 0;
228
229 if(tbuf[0] == 'S')
230 {
231 tbuf++;
232 type = 1;
233 }
234 else
235 type = 0;
236
237 if(tbuf[0] == 'C')
238 {
239 tbuf++;
240 doc = 1;
241 }
242
243 if(tbuf[0] == ':')
244 {
245 tbuf++;

Callers 8

FCEUI_NetplayStopFunction · 0.85
FCEUI_NetplayStartFunction · 0.85
NetplayUpdateFunction · 0.85
FCEUI_LoadGameVirtualFunction · 0.85
AppWndProcFunction · 0.85
CheatConsoleCallBFunction · 0.85
openCheatFileMethod · 0.85
openCheatFileFunction · 0.85

Calls 6

FCEUI_RefreshCheatMapFunction · 0.85
FCEU_MakeFNameFunction · 0.85
AddCheatEntryFunction · 0.85
RebuildSubCheatsFunction · 0.85
FCEU_DispMessageFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70

Tested by

no test coverage detected