summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-08-21 19:05:14 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-08-21 19:05:14 +0000
commit5f174240f1821f22b2d14b2ce2affe080ef8c72a (patch)
treebf223cbb1e5433e99c5fe587a0495673e3302d59 /src
parente38adf825ec94a2d886ba5d3880e9f564c3ba023 (diff)
Fix crash when loading cheats, plus a bit of minor cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/emu/cheat.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index 1aff6ff2497..4bc4ec7ea6a 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -411,22 +411,20 @@ void cheat_reload(running_machine *machine)
and MAME will load gamename.xml */
device_image_interface *image = NULL;
for (bool gotone = machine->m_devicelist.first(image); gotone; gotone = image->next(image))
- {
if (image->exists())
{
- char mess_cheat_filename[9];
- UINT32 crc = image->crc();
- sprintf(mess_cheat_filename, "%08X", crc);
- if (crc!=0) {
- cheatinfo->cheatlist = cheat_list_load(machine, mess_cheat_filename);
+ UINT32 crc = image->crc();
+ if (crc != 0)
+ {
+ astring filename;
+ filename.printf("%08X", crc);
+ cheatinfo->cheatlist = cheat_list_load(machine, filename);
break;
}
}
- }
+
if (cheatinfo->cheatlist == NULL)
- {
cheatinfo->cheatlist = cheat_list_load(machine, machine->basename());
- }
/* temporary: save the file back out as output.xml for comparison */
if (cheatinfo->cheatlist != NULL)
@@ -458,9 +456,7 @@ int cheat_get_global_enable(running_machine *machine)
cheat_private *cheatinfo = machine->cheat_data;
if (cheatinfo != NULL)
- {
return !cheatinfo->disabled;
- }
return 0;
}
@@ -1077,7 +1073,7 @@ static cheat_entry *cheat_list_load(running_machine *machine, const char *filena
scannode = NULL;
if (REMOVE_DUPLICATE_CHEATS)
for (scannode = cheatlist; scannode != NULL; scannode = scannode->next)
- if (scannode->description.cmp(curcheat->description) == 0)
+ if (scannode->description == curcheat->description)
{
mame_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", curcheat->description.cstr(), mame_file_full_name(cheatfile).cstr());
break;
@@ -1193,7 +1189,7 @@ static cheat_entry *cheat_entry_load(running_machine *machine, const char *filen
mame_printf_error("%s.xml(%d): empty or missing desc attribute on cheat\n", filename, cheatnode->line);
return NULL;
}
- cheat->description.cpy(description);
+ cheat->description = description;
/* create the symbol table */
cheat->symbols = symtable_alloc(NULL, machine);
@@ -1213,7 +1209,7 @@ static cheat_entry *cheat_entry_load(running_machine *machine, const char *filen
if (commentnode != NULL)
{
if (commentnode->value != NULL && commentnode->value[0] != 0)
- cheat->comment.cpy(commentnode->value);
+ cheat->comment = commentnode->value;
/* only one comment is kept */
commentnode = xml_get_sibling(commentnode->next, "comment");
@@ -1708,7 +1704,7 @@ static void script_entry_save(mame_file *cheatfile, const script_entry *entry)
astring tempstring;
/* output an action */
- if (entry->format == NULL)
+ if (entry->format.len() == 0)
{
mame_fprintf(cheatfile, "\t\t\t<action");
if (entry->condition != NULL)