Skip to content

Commit

Permalink
Dryers have lint screens for a reason
Browse files Browse the repository at this point in the history
  • Loading branch information
Techjar committed Jul 6, 2018
1 parent aa48b3f commit 26fcb3f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
7 changes: 5 additions & 2 deletions Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ int GCMemcardDirectory::LoadGCI(const std::string& file_name, bool current_game_
}

// This is only used by NetPlay but it made sense to put it here to keep the relevant code together
std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::string& directory, const std::string& game_id)
std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::string& directory,
const std::string& game_id)
{
std::vector<std::string> filenames;

Expand Down Expand Up @@ -161,7 +162,9 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
if (file_size != size + DENTRY_SIZE)
continue;

// There's technically other available block checks to prevent overfilling the virtual memory card (see above method), but since we're only loading the saves for one GameID here, we're definitely not going to run out of space.
// There's technically other available block checks to prevent overfilling the virtual memory
// card (see above method), but since we're only loading the saves for one GameID here, we're
// definitely not going to run out of space.

if (game_code == BE32(gci.m_gci_header.Gamecode))
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class GCMemcardDirectory : public MemoryCardBase
GCMemcardDirectory(GCMemcardDirectory&&) = default;
GCMemcardDirectory& operator=(GCMemcardDirectory&&) = default;

static std::vector<std::string> GetFileNamesForGameID(const std::string& directory, const std::string& game_id);
static std::vector<std::string> GetFileNamesForGameID(const std::string& directory,
const std::string& game_id);
void FlushToFile();
void FlushThread();
s32 Read(u32 src_address, s32 length, u8* dest_address) override;
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/NetPlayClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
u8 file_count;
packet >> is_slot_a >> file_count;

const std::string path = File::GetUserPath(D_GCUSER_IDX) + GC_MEMCARD_NETPLAY DIR_SEP + StringFromFormat("Card %c", is_slot_a ? 'A' : 'B');
const std::string path = File::GetUserPath(D_GCUSER_IDX) + GC_MEMCARD_NETPLAY DIR_SEP +
StringFromFormat("Card %c", is_slot_a ? 'A' : 'B');

if ((File::Exists(path) && !File::DeleteDirRecursively(path + DIR_SEP)) || !File::CreateFullPath(path + DIR_SEP))
if ((File::Exists(path) && !File::DeleteDirRecursively(path + DIR_SEP)) ||
!File::CreateFullPath(path + DIR_SEP))
{
PanicAlertT("Failed to reset NetPlay GCI folder. Verify your write permissions.");
SyncSaveDataResponse(false);
Expand Down
21 changes: 13 additions & 8 deletions Source/Core/Core/NetPlayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ bool NetPlayServer::SyncSaveData()
u8 save_count = 0;
for (size_t i = 0; i < 2; i++)
{
if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARD || SConfig::GetInstance().m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARD ||
SConfig::GetInstance().m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
{
save_count++;
}
Expand All @@ -954,7 +955,8 @@ bool NetPlayServer::SyncSaveData()
return false;
}

const std::string region = SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion()));
const std::string region =
SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion()));

for (size_t i = 0; i < 2; i++)
{
Expand Down Expand Up @@ -984,7 +986,8 @@ bool NetPlayServer::SyncSaveData()
if (!CompressFileIntoPacket(path, pac))
return false;
}
else {
else
{
// No file, so we'll say the size is 0
pac << static_cast<u32>(0) << static_cast<u32>(0);
}
Expand All @@ -994,7 +997,8 @@ bool NetPlayServer::SyncSaveData()
else if (SConfig::GetInstance().m_EXIDevice[i] ==
ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER)
{
const std::string path = File::GetUserPath(D_GCUSER_IDX) + region + DIR_SEP + StringFromFormat("Card %c", is_slot_a ? 'A' : 'B');
const std::string path = File::GetUserPath(D_GCUSER_IDX) + region + DIR_SEP +
StringFromFormat("Card %c", is_slot_a ? 'A' : 'B');

sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
Expand All @@ -1003,7 +1007,8 @@ bool NetPlayServer::SyncSaveData()

if (File::IsDirectory(path))
{
std::vector<std::string> files = GCMemcardDirectory::GetFileNamesForGameID(path + DIR_SEP, game->GetGameID());
std::vector<std::string> files =
GCMemcardDirectory::GetFileNamesForGameID(path + DIR_SEP, game->GetGameID());

pac << static_cast<u8>(files.size());

Expand Down Expand Up @@ -1043,8 +1048,8 @@ bool NetPlayServer::CompressFileIntoPacket(const std::string& file_path, sf::Pac
lzo_uint i = 0;
while (true)
{
lzo_uint32 cur_len = 0; // number of bytes to read
lzo_uint out_len = 0; // number of bytes to write
lzo_uint32 cur_len = 0; // number of bytes to read
lzo_uint out_len = 0; // number of bytes to write

if ((i + NETPLAY_LZO_IN_LEN) >= file_size)
{
Expand All @@ -1056,7 +1061,7 @@ bool NetPlayServer::CompressFileIntoPacket(const std::string& file_path, sf::Pac
}

if (cur_len <= 0)
break; // EOF
break; // EOF

if (!file.ReadBytes(in_buffer.data(), cur_len))
{
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/DolphinQt2/NetPlay/NetPlayDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,7 @@ void NetPlayDialog::GameStatusChanged(bool running)
if (!running && !m_got_stop_request)
Settings::Instance().GetNetPlayClient()->RequestStopGame();

QueueOnObject(this, [this, running] {
SetOptionsEnabled(!running);
});
QueueOnObject(this, [this, running] { SetOptionsEnabled(!running); });
}

void NetPlayDialog::SetOptionsEnabled(bool enabled)
Expand Down

0 comments on commit 26fcb3f

Please sign in to comment.