mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
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();
|
||||
std::thread md5thread(CheckMD5);
|
||||
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());
|
||||
EndPlayInput(false);
|
||||
@ -1205,7 +1205,7 @@ void SaveRecording(const std::string& filename)
|
||||
memset(&header, 0, sizeof(DTMHeader));
|
||||
|
||||
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.numControllers = s_numPads & (SConfig::GetInstance().bWii ? 0xFF : 0x0F);
|
||||
|
||||
|
@ -63,7 +63,7 @@ struct DTMHeader
|
||||
{
|
||||
u8 filetype[4]; // Unique Identifier (always "DTM"0x1A)
|
||||
|
||||
u8 gameID[6]; // The Game ID
|
||||
char gameID[6]; // The Game ID
|
||||
bool bWii; // Wii game
|
||||
|
||||
u8 numControllers; // The number of connected controllers (1-4)
|
||||
|
@ -343,7 +343,7 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args)
|
||||
|
||||
// Setting up the 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.time = Common::Timer::GetDoubleTime();
|
||||
|
||||
@ -474,7 +474,7 @@ static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_
|
||||
StateHeader header;
|
||||
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)",
|
||||
6, header.gameID), 2000);
|
||||
|
@ -20,7 +20,7 @@ static const u32 NUM_STATES = 10;
|
||||
|
||||
struct StateHeader
|
||||
{
|
||||
u8 gameID[6];
|
||||
char gameID[6];
|
||||
u32 size;
|
||||
double time;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user