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

Function FCEU_FlushGameCheats

src/cheat.cpp:312–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312void FCEU_FlushGameCheats(FILE *override, int nosave)
313{
314 if(CheatComp)
315 {
316 free(CheatComp);
317 CheatComp=0;
318 }
319 if((!savecheats || nosave) && !override) /* Always save cheats if we're being overridden. */
320 {
321 if(cheats)
322 {
323 struct CHEATF *next=cheats;
324 for(;;)
325 {
326 struct CHEATF *last=next;
327 next=next->next;
328 delete last;
329 if(!next) break;
330 }
331 cheats=cheatsl=0;
332 }
333 }
334 else
335 {
336 char *fn = 0;
337
338 if(!override)
339 fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str());
340
341 if(cheats)
342 {
343 FILE *fp;
344
345 if(override)
346 fp = override;
347 else
348 fp=FCEUD_UTF8fopen(fn,"wb");
349
350 if(fp)
351 {
352 FCEU_SaveGameCheats(fp, 1);
353 if(!override)
354 fclose(fp);
355 }
356 else
357 FCEUD_PrintError("Error saving cheats.");
358 cheats=cheatsl=0;
359 }
360 else if(!override)
361 remove(fn);
362 if(!override)
363 free(fn);
364 }
365
366 RebuildSubCheats(); /* Remove memory handlers. */
367
368}
369

Callers 5

FCEUI_NetplayStopFunction · 0.85
FCEUI_NetplayStartFunction · 0.85
NetplayUpdateFunction · 0.85
FCEU_CloseGameFunction · 0.85
SaveCheatAsFunction · 0.85

Calls 5

FCEU_MakeFNameFunction · 0.85
FCEU_SaveGameCheatsFunction · 0.85
RebuildSubCheatsFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70
FCEUD_PrintErrorFunction · 0.50

Tested by

no test coverage detected