summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/Src/VolumeWad.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/DiscIO/Src/VolumeWad.cpp')
-rw-r--r--Source/Core/DiscIO/Src/VolumeWad.cpp81
1 files changed, 23 insertions, 58 deletions
diff --git a/Source/Core/DiscIO/Src/VolumeWad.cpp b/Source/Core/DiscIO/Src/VolumeWad.cpp
index 2f9f0ef961..a10e5bdb42 100644
--- a/Source/Core/DiscIO/Src/VolumeWad.cpp
+++ b/Source/Core/DiscIO/Src/VolumeWad.cpp
@@ -15,6 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <algorithm>
#include <math.h>
#include "VolumeWad.h"
@@ -107,78 +108,42 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
return true;
}
-bool CVolumeWAD::GetWName(std::vector<std::wstring>& _rwNames) const
+std::vector<std::string> CVolumeWAD::GetNames() const
{
- u32 footer_size;
+ std::vector<std::string> names;
+ u32 footer_size;
if (!Read(0x1C, 4, (u8*)&footer_size))
{
- return false;
+ return names;
}
+
+ footer_size = Common::swap32(footer_size);
+
//Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
-
- // Offset to the english title
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i != 10; ++i)
{
- u16 temp[42];
- std::wstring out_temp;
+ static const u32 string_length = 42;
+ static const u32 bytes_length = string_length * sizeof(u16);
+
+ u16 temp[string_length];
- if (!Read(0x9C + (i*84) + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1
- || !temp[0])
+ if (footer_size < 0xF1 || !Read(0x9C + (i * bytes_length) + OpeningBnrOffset, bytes_length, (u8*)&temp))
{
- _rwNames.push_back(L"");
- continue;
+ names.push_back("");
}
- for (int j = 0; j < 42; ++j)
+ else
{
- u16 t = Common::swap16(temp[j]);
- if (t == 0 && j > 0)
- {
- if (out_temp.at(out_temp.size()-1) != ' ')
- out_temp.push_back(' ');
- }
- else
- out_temp.push_back(t);
- }
-
- _rwNames.push_back(out_temp);
- }
- return true;
-}
-
-std::string CVolumeWAD::GetName() const
-{
- u32 footer_size;
-
- if (!Read(0x1C, 4, (u8*)&footer_size))
- return "";
-
-
- //Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
-
- // Offset to the english title
- char temp[84];
- if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1 ||
- !Common::swap16(temp[0]))
- return "";
-
- // Remove the null bytes due to 16bit char length
- std::string out_temp;
- for (unsigned int i = 0; i < sizeof(temp); i+=2)
- {
- // Replace null chars with a single space per null section
- if (temp[i] == '\0' && i > 0)
- {
- if (out_temp.at(out_temp.size()-1) != ' ')
- out_temp.push_back(' ');
+ std::wstring out_temp;
+ out_temp.resize(string_length);
+ std::transform(temp, temp + out_temp.size(), out_temp.begin(), (u16(&)(u16))Common::swap16);
+ out_temp.erase(std::find(out_temp.begin(), out_temp.end(), 0x00), out_temp.end());
+
+ names.push_back(UTF16ToUTF8(out_temp));
}
- else
- out_temp.push_back(temp[i]);
}
- // Make it a null terminated string
- out_temp.replace(out_temp.end()-1, out_temp.end(), 1, '\0');
- return out_temp;
+ return names;
}
u64 CVolumeWAD::GetSize() const