o switch to v46

This commit is contained in:
David Voswinkel
2009-05-12 22:17:42 +02:00
parent 7a878eab39
commit 8e877d38d4
217 changed files with 1440 additions and 31284 deletions

View File

@@ -1,4 +1,7 @@
#include <../base.hpp>
#include <../base.hpp>
#define CHEAT_CPP
namespace SNES {
Cheat cheat;
@@ -178,9 +181,7 @@ void Cheat::disable(unsigned i) {
//...
//===============================
bool Cheat::load(const char *fn) {
string data;
if(!data.readfile(fn)) return false;
void Cheat::load(string data) {
data.replace("\r\n", "\n");
data.qreplace(" ", "");
@@ -193,21 +194,16 @@ bool Cheat::load(const char *fn) {
trim(part[0], "\"");
add(part[1] == "enabled", /* code = */ part[2], /* desc = */ part[0]);
}
return true;
}
bool Cheat::save(const char *fn) const {
file fp;
if(!fp.open(fn, file::mode_write)) return false;
for(unsigned i = 0; i < code.size(); i++) {
fp.print(string()
<< "\"" << code[i].desc << "\", "
<< (code[i].enabled ? "enabled, " : "disabled, ")
<< code[i].code << "\r\n");
}
fp.close();
return true;
string Cheat::save() const {
string data;
for(unsigned i = 0; i < code.size(); i++) {
data << "\"" << code[i].desc << "\", "
<< (code[i].enabled ? "enabled, " : "disabled, ")
<< code[i].code << "\r\n";
}
return data;
}
void Cheat::clear() {
@@ -390,3 +386,6 @@ string& Cheat::decode_description(string &desc) const {
desc.replace("\\n", "\n");
return desc;
}
};

View File

@@ -38,8 +38,8 @@ public:
void enable(unsigned i);
void disable(unsigned i);
bool load(const char *fn);
bool save(const char *fn) const;
void load(string data);
string save() const;
void clear();
Cheat();