Merge pull request #3292 from JosJuice/state-str
State: Don't use memcpy and memcmp with strings
This commit is contained in:
commit
3e2ac3df43
|
@ -185,7 +185,7 @@ void Init()
|
||||||
ReadHeader();
|
ReadHeader();
|
||||||
std::thread md5thread(CheckMD5);
|
std::thread md5thread(CheckMD5);
|
||||||
md5thread.detach();
|
md5thread.detach();
|
||||||
if (strncmp((char *)tmpHeader.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6))
|
if (strncmp(tmpHeader.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6))
|
||||||
{
|
{
|
||||||
PanicAlertT("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, SConfig::GetInstance().GetUniqueID().c_str());
|
PanicAlertT("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, SConfig::GetInstance().GetUniqueID().c_str());
|
||||||
EndPlayInput(false);
|
EndPlayInput(false);
|
||||||
|
@ -1205,7 +1205,7 @@ void SaveRecording(const std::string& filename)
|
||||||
memset(&header, 0, sizeof(DTMHeader));
|
memset(&header, 0, sizeof(DTMHeader));
|
||||||
|
|
||||||
header.filetype[0] = 'D'; header.filetype[1] = 'T'; header.filetype[2] = 'M'; header.filetype[3] = 0x1A;
|
header.filetype[0] = 'D'; header.filetype[1] = 'T'; header.filetype[2] = 'M'; header.filetype[3] = 0x1A;
|
||||||
strncpy((char *)header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6);
|
strncpy(header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6);
|
||||||
header.bWii = SConfig::GetInstance().bWii;
|
header.bWii = SConfig::GetInstance().bWii;
|
||||||
header.numControllers = s_numPads & (SConfig::GetInstance().bWii ? 0xFF : 0x0F);
|
header.numControllers = s_numPads & (SConfig::GetInstance().bWii ? 0xFF : 0x0F);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct DTMHeader
|
||||||
{
|
{
|
||||||
u8 filetype[4]; // Unique Identifier (always "DTM"0x1A)
|
u8 filetype[4]; // Unique Identifier (always "DTM"0x1A)
|
||||||
|
|
||||||
u8 gameID[6]; // The Game ID
|
char gameID[6]; // The Game ID
|
||||||
bool bWii; // Wii game
|
bool bWii; // Wii game
|
||||||
|
|
||||||
u8 numControllers; // The number of connected controllers (1-4)
|
u8 numControllers; // The number of connected controllers (1-4)
|
||||||
|
|
|
@ -343,7 +343,7 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args)
|
||||||
|
|
||||||
// Setting up the header
|
// Setting up the header
|
||||||
StateHeader header;
|
StateHeader header;
|
||||||
memcpy(header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6);
|
strncpy(header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6);
|
||||||
header.size = g_use_compression ? (u32)buffer_size : 0;
|
header.size = g_use_compression ? (u32)buffer_size : 0;
|
||||||
header.time = Common::Timer::GetDoubleTime();
|
header.time = Common::Timer::GetDoubleTime();
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_
|
||||||
StateHeader header;
|
StateHeader header;
|
||||||
f.ReadArray(&header, 1);
|
f.ReadArray(&header, 1);
|
||||||
|
|
||||||
if (memcmp(SConfig::GetInstance().GetUniqueID().c_str(), header.gameID, 6))
|
if (strncmp(SConfig::GetInstance().GetUniqueID().c_str(), header.gameID, 6))
|
||||||
{
|
{
|
||||||
Core::DisplayMessage(StringFromFormat("State belongs to a different game (ID %.*s)",
|
Core::DisplayMessage(StringFromFormat("State belongs to a different game (ID %.*s)",
|
||||||
6, header.gameID), 2000);
|
6, header.gameID), 2000);
|
||||||
|
|
|
@ -20,7 +20,7 @@ static const u32 NUM_STATES = 10;
|
||||||
|
|
||||||
struct StateHeader
|
struct StateHeader
|
||||||
{
|
{
|
||||||
u8 gameID[6];
|
char gameID[6];
|
||||||
u32 size;
|
u32 size;
|
||||||
double time;
|
double time;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue