Some clean up

delete devices after reply


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1386 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee
2008-12-03 21:17:49 +00:00
parent c16732a012
commit b08352d1e4

View File

@ -250,6 +250,7 @@ void CopySettingsFile(std::string DeviceName)
void ExecuteCommand(u32 _Address) void ExecuteCommand(u32 _Address)
{ {
bool GenerateReply = false; bool GenerateReply = false;
u32 erased = 0;
ECommandType Command = static_cast<ECommandType>(Memory::Read_U32(_Address)); ECommandType Command = static_cast<ECommandType>(Memory::Read_U32(_Address));
switch (Command) switch (Command)
@ -343,7 +344,7 @@ void ExecuteCommand(u32 _Address)
// Delete the device when CLOSE is called, this does not effect // Delete the device when CLOSE is called, this does not effect
// GenerateReply() for any other purpose than the logging because // GenerateReply() for any other purpose than the logging because
// it's a true / false only function // // it's a true / false only function //
DeleteDeviceByID(DeviceID); erased = DeviceID;
GenerateReply = true; GenerateReply = true;
} }
} }
@ -412,22 +413,27 @@ void ExecuteCommand(u32 _Address)
IWII_IPC_HLE_Device* pDevice = NULL; IWII_IPC_HLE_Device* pDevice = NULL;
// Get the device from the device map // Get the device from the device map
if (DeviceID != 0) {
if (g_DeviceMap.find(DeviceID) != g_DeviceMap.end()) if (g_DeviceMap.find(DeviceID) != g_DeviceMap.end())
pDevice = g_DeviceMap[DeviceID]; pDevice = g_DeviceMap[DeviceID];
if (pDevice != NULL) if (pDevice != NULL) {
{
// Write reply, this will later be executed in Update() // Write reply, this will later be executed in Update()
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, pDevice->GetDeviceName())); g_ReplyQueue.push(std::pair<u32, std::string>(_Address, pDevice->GetDeviceName()));
} } else {
else
{
// 0 is ok, as it's used for devices that wasn't created yet
if (DeviceID != 0)
LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID); LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID);
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown")); g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown"));
} }
if (erased > 0 && erased == DeviceID)
DeleteDeviceByID(DeviceID);
} else {
// 0 is ok, as it's used for devices that weren't created yet
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown"));
} }
}
} }
// This is called continuously and WII_IPCInterface::IsReady() is controlled from WII_IPC.cpp. // This is called continuously and WII_IPCInterface::IsReady() is controlled from WII_IPC.cpp.