aboutsummaryrefslogtreecommitdiff
path: root/source/nds/gcheat.c
diff options
context:
space:
mode:
authorNebuleon Fumika2012-12-23 20:51:14 -0500
committerNebuleon Fumika2012-12-23 20:51:14 -0500
commitbb39cc82364ea00324a054ba0970bdc07ecfdeec (patch)
treeb221c90bf1c23195f08b69de6dd8cdb3f1b9df75 /source/nds/gcheat.c
parenta194b850037c03f5fb3ac1ecc9f7a99f73b84104 (diff)
downloadsnes9x2005-bb39cc82364ea00324a054ba0970bdc07ecfdeec.tar.gz
snes9x2005-bb39cc82364ea00324a054ba0970bdc07ecfdeec.tar.bz2
snes9x2005-bb39cc82364ea00324a054ba0970bdc07ecfdeec.zip
Correctly handle multi-part codes, for all cheat types (GG, PAR, GF).
They are currently loaded as multiple codes, however.
Diffstat (limited to 'source/nds/gcheat.c')
-rw-r--r--source/nds/gcheat.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/nds/gcheat.c b/source/nds/gcheat.c
index 648bfda..e3d0e8d 100644
--- a/source/nds/gcheat.c
+++ b/source/nds/gcheat.c
@@ -72,8 +72,8 @@ int NDSSFCLoadCheatFile(const char* filename)
fclose(fp);
return -2;
}
+ *ptr = '\0'; // End the codes there
*ptr++; // Past the comma
- *(ptr - 1) = '\0'; // End the codes there
uint32 i = 0;
description = ptr; // Skip starting " in description
@@ -86,19 +86,21 @@ int NDSSFCLoadCheatFile(const char* filename)
}
*ptr = '\0';
- uint32 n = 0, c;
+ uint32 c;
// n is the number of cheat codes. Beware of MAX_CHEATS_T.
// List of cheat codes having the same description.
ptr = codes_ptr;
while (*ptr && !(*ptr == ',' || *ptr == '"')) {
- if (n >= MAX_CHEATS_T) {
+ if (Cheat.num_cheats >= MAX_CHEATS_T) {
fclose(fp);
return 0;
}
i = 0;
- while (*ptr && *ptr != '+' && i < sizeof(code) - 1)
+ while (*ptr && !(*ptr == '+' || *ptr == ',' || *ptr == '"') && i < sizeof(code) - 1)
code[i++] = *ptr++;
+ if (*ptr)
+ ptr++; // Go past the + , or "
code[i] = '\0';
if (!S9xGameGenieToRaw (code, &address, &byte)) {
S9xAddCheat (FALSE, TRUE, address, byte);
@@ -112,7 +114,7 @@ int NDSSFCLoadCheatFile(const char* filename)
{
for (c = 0; c < num_bytes; c++) {
S9xAddCheat (FALSE, TRUE, address + c, bytes[c]);
- strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, 22);
+ strncpy (Cheat.c[Cheat.num_cheats - 1].name, description, MAX_SFCCHEAT_NAME);
}
}
else {