My first commit :)

Fixed more memory leaks when doing state load. Now all file devices(handles) are stored in state, and this will fix some crash after loading state.

Warning: Do NOT Save/Load state before game title is shown and controllable, or else you will get a corrupt state.

If you encounter "Emu WiiMote Desync" frequently, please report the condition
(PS: To recover from wiimote desync, just load a saved state)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4608 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx
2009-11-24 17:10:38 +00:00
parent 6a46befc2a
commit 29774c35e8
9 changed files with 239 additions and 75 deletions

View File

@ -74,13 +74,48 @@ public:
(*ptr) += size;
}
// Store maps to file. Very useful.
template<class T>
void Do(std::map<unsigned int, T> &x) {
void Do(std::map<unsigned int, T> &x)
{
// TODO
PanicAlert("Do(map<>) does not yet work.");
}
void Do(std::map<unsigned int, std::string> &x)
{
unsigned int number = (unsigned int)x.size();
Do(number);
switch (mode) {
case MODE_READ:
{
x.clear();
while (number > 0)
{
unsigned int first;
Do(first);
std::string second;
Do(second);
x[first] = second;
--number;
}
}
break;
case MODE_WRITE:
case MODE_MEASURE:
{
std::map<unsigned int, std::string>::iterator itr = x.begin();
while (number > 0)
{
Do(itr->first);
Do(itr->second);
--number;
++itr;
}
}
break;
}
}
// Store vectors.
template<class T>
void Do(std::vector<T> &x) {