void patchHelper(const wxString& cmd, const wxString& param) { // Error Handling Note: I just throw simple wxStrings here, and then catch them below and // format them into more detailed cmd+data+error printouts. If we want to add user-friendly // (translated) messages for display in a popup window then we'll have to upgrade the // exception a little bit. // print the actual patch lines only in verbose mode (even in devel) if (DevConWriterEnabled) DevCon.WriteLn(cmd + L" " + param); try { if (isCheat && cheatnumber >= MAX_CHEAT) throw wxString( L"Maximum number of cheats reached" ); if(!isCheat && patchnumber >= MAX_PATCH) throw wxString( L"Maximum number of patches reached" ); IniPatch& iPatch = isCheat ? Cheat[cheatnumber] : Patch[patchnumber]; PatchPieces pieces(param); iPatch.enabled = 0; iPatch.placetopatch = StrToU32(pieces.PlaceToPatch(), 10); iPatch.cpu = (patch_cpu_type)PatchTableExecute(pieces.CpuType(), cpuCore); iPatch.addr = StrToU32(pieces.MemAddr(), 16); iPatch.type = (patch_data_type)PatchTableExecute(pieces.OperandSize(), dataType); iPatch.data = StrToU64(pieces.WriteValue(), 16); if (iPatch.cpu == 0) throw wxsFormat(L"Unrecognized CPU Target: '%s'", WX_STR(pieces.CpuType())); if (iPatch.type == 0) throw wxsFormat(L"Unrecognized Operand Size: '%s'", WX_STR(pieces.OperandSize())); iPatch.enabled = 1; // omg success!! if (isCheat) cheatnumber++; else patchnumber++; } catch( wxString& exmsg ) { Console.Error(L"(Patch) Error Parsing: %s=%s", WX_STR(cmd), WX_STR(param)); Console.Indent().Error( exmsg ); } }
// This routine is for executing the commands of the ini file. void inifile_command(bool isCheat, const wxString& cmd) { ParsedAssignmentString set( cmd ); // Is this really what we want to be doing here? Seems like just leaving it empty/blank // would make more sense... --air if (set.rvalue.IsEmpty()) set.rvalue = set.lvalue; /*int code = */PatchTableExecute(set, isCheat ? commands_cheat : commands_patch); }