2014-07-09 19:05:07 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "NetMessage.h"
|
|
|
|
#include "Console.h"
|
2014-07-10 20:24:28 -04:00
|
|
|
#include "ROMLoader.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "../Utilities/FolderUtilities.h"
|
|
|
|
|
|
|
|
class GameInformationMessage : public NetMessage
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual uint32_t GetMessageLength()
|
|
|
|
{
|
2014-07-09 21:48:54 -04:00
|
|
|
return sizeof(ROMFilename) + sizeof(CRC32Hash) + sizeof(ControllerPort) + sizeof(Paused);
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ProtectedSend(Socket &socket)
|
|
|
|
{
|
|
|
|
socket.BufferedSend((char*)&ROMFilename, sizeof(ROMFilename));
|
|
|
|
socket.BufferedSend((char*)&CRC32Hash, sizeof(CRC32Hash));
|
|
|
|
socket.BufferedSend((char*)&ControllerPort, sizeof(ControllerPort));
|
2014-07-09 21:48:54 -04:00
|
|
|
socket.BufferedSend((char*)&Paused, sizeof(Paused));
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
wchar_t ROMFilename[255];
|
|
|
|
uint32_t CRC32Hash;
|
|
|
|
uint8_t ControllerPort;
|
2014-07-09 21:48:54 -04:00
|
|
|
bool Paused;
|
2014-07-09 19:05:07 -04:00
|
|
|
|
|
|
|
GameInformationMessage(char *readBuffer) : NetMessage(MessageType::GameInformation)
|
|
|
|
{
|
|
|
|
memcpy((char*)ROMFilename, readBuffer, sizeof(ROMFilename));
|
|
|
|
memcpy((char*)&CRC32Hash, readBuffer + sizeof(ROMFilename), sizeof(CRC32Hash));
|
|
|
|
ControllerPort = readBuffer[sizeof(ROMFilename) + sizeof(CRC32Hash)];
|
2014-07-09 21:48:54 -04:00
|
|
|
Paused = readBuffer[sizeof(ROMFilename) + sizeof(CRC32Hash) + sizeof(ControllerPort)] == 1;
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
|
|
|
|
2014-07-09 21:48:54 -04:00
|
|
|
GameInformationMessage(wstring filepath, uint8_t port, bool paused) : NetMessage(MessageType::GameInformation)
|
2014-07-09 19:05:07 -04:00
|
|
|
{
|
|
|
|
memset(ROMFilename, 0, sizeof(ROMFilename));
|
|
|
|
wcscpy_s(ROMFilename, FolderUtilities::GetFilename(filepath, true).c_str());
|
2014-07-10 20:24:28 -04:00
|
|
|
CRC32Hash = ROMLoader::GetCRC32(filepath);
|
2014-07-09 19:05:07 -04:00
|
|
|
ControllerPort = port;
|
2014-07-09 21:48:54 -04:00
|
|
|
Paused = paused;
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AttemptLoadGame()
|
|
|
|
{
|
|
|
|
wstring filename = ROMFilename;
|
|
|
|
if(filename.size() > 0) {
|
|
|
|
if(Console::AttemptLoadROM(filename, CRC32Hash)) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Console::DisplayMessage(L"Could not find matching game ROM.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|