Skip to content

Commit 36864d3

Browse files
committed
Force old cache update + remove wideTitles
1 parent c772494 commit 36864d3

File tree

7 files changed

+31
-41
lines changed

7 files changed

+31
-41
lines changed

inc/data.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ namespace data
2828
std::string getProdCode() { return prodCode; }
2929
std::u16string getTitle() { return title; }
3030
std::u16string getTitleSafe() { return titleSafe; }
31-
std::u32string getTitleWide() { return wideTitle; }
3231

3332
void drawInfo(unsigned x, unsigned y);
3433

@@ -37,7 +36,6 @@ namespace data
3736
uint32_t high, low, unique, extdata;
3837
std::string prodCode;
3938
std::u16string title, titleSafe;
40-
std::u32string wideTitle;
4139
FS_MediaType m;
4240
};
4341

inc/gfx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace gfx
1616

1717
void drawText(const std::string& str, const int& x, const int& y, const uint32_t& clr);
1818
void drawU16Text(const std::u16string& str, const int& x, const int& y, const uint32_t& clr);
19-
void drawU32Text(const std::u32string& str, const int& x, const int& y, const uint32_t& clr);
2019
size_t getTextWidth(const std::string& str);
2120
}
2221

inc/util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ namespace util
1616
};
1717

1818
std::string toUtf8(const std::u16string& conv);
19-
std::string toUtf8(const std::u32string& conv);
2019
std::u16string toUtf16(const std::string& conv);
21-
std::u32string toUtf32(const std::u16string& conv);
2220
std::u16string createPath(data::titleData& dat, const uint32_t& mode);
2321
std::string getString(const std::string& hint, bool def);
2422
int getInt(const std::string& hint, const int& init, const int& max);

src/data.cpp

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ namespace data
9393
if(smdh == NULL)
9494
return false;
9595

96-
title = (char16_t *)smdh->applicationTitles[1].shortDescription;
96+
title.assign((char16_t *)(smdh->applicationTitles[1].shortDescription));
9797
titleSafe.assign(safeTitle(title));
98-
wideTitle = util::toUtf32(title);
9998

10099
char tmp[16];
101100
AM_GetTitleProductCode(m, id, tmp);
@@ -118,7 +117,6 @@ namespace data
118117

119118
title.assign(_title);
120119
titleSafe.assign(safeTitle(title));
121-
wideTitle.assign(util::toUtf32(title));
122120
prodCode.assign(code);
123121

124122
return true;
@@ -252,6 +250,19 @@ namespace data
252250
std::fstream cache("/JKSV/titles", std::ios::in | std::ios::binary);
253251
if(cache.is_open())
254252
{
253+
uint8_t cacheRev = 0;
254+
cache.seekg(2, cache.beg);
255+
cacheRev = cache.get();
256+
cache.seekg(0, cache.beg);
257+
258+
if(cacheRev < 2)
259+
{
260+
cache.close();
261+
std::remove("/JKSV/titles");
262+
loadTitles();
263+
return;
264+
}
265+
255266
uint16_t count = 0;
256267
cache.read((char *)&count, sizeof(uint16_t));
257268

@@ -301,6 +312,7 @@ namespace data
301312
titles.push_back(newTitle);
302313
}
303314
}
315+
else
304316

305317
prog.update(i);
306318

@@ -320,7 +332,7 @@ namespace data
320332
{
321333
uint16_t countOut = titles.size();
322334
cache.write((char *)&countOut, sizeof(uint16_t));
323-
cache.put(0x00);
335+
cache.put(0x02);
324336

325337
for(unsigned i = 0; i < titles.size(); i++)
326338
{
@@ -354,6 +366,18 @@ namespace data
354366
std::fstream cache("/JKSV/nand", std::ios::in | std::ios::binary);
355367
if(cache.is_open())
356368
{
369+
uint8_t cacheRev = 0;
370+
cache.seekg(2, cache.beg);
371+
cacheRev = cache.get();
372+
cache.seekg(0, cache.beg);
373+
if(cacheRev < 2)
374+
{
375+
cache.close();
376+
std::remove("/JKSV/nand");
377+
loadNand();
378+
return;
379+
}
380+
357381
uint16_t count;
358382
cache.read((char *)&count, sizeof(uint16_t));
359383

@@ -411,7 +435,7 @@ namespace data
411435
uint16_t countOut = nand.size();
412436
cache.open("/JKSV/nand", std::ios::out | std::ios::binary);
413437
cache.write((char *)&countOut, sizeof(uint16_t));
414-
cache.put(0x00);
438+
cache.put(0x02);
415439
for(unsigned i = 0; i < nand.size(); i++)
416440
{
417441
char16_t titleOut[0x40];

src/gfx.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,6 @@ namespace gfx
7979
C2D_TextBufDelete(tmpBuf);
8080
}
8181

82-
void drawU32Text(const std::u32string& str, const int& x, const int& y, const uint32_t& clr)
83-
{
84-
C2D_Text tmpTxt;
85-
C2D_TextBuf tmpBuf = C2D_TextBufNew(1024);
86-
87-
std::string tmp = util::toUtf8(str);
88-
89-
C2D_TextParse(&tmpTxt, tmpBuf, tmp.c_str());
90-
C2D_TextOptimize(&tmpTxt);
91-
C2D_DrawText(&tmpTxt, C2D_WithColor, (float)x, (float) y, 0.5f, 0.5f, 0.5f, clr);
92-
C2D_TextBufDelete(tmpBuf);
93-
}
94-
9582
size_t getTextWidth(const std::string& str)
9683
{
9784
float ret = 0;

src/ui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ namespace ui
260260

261261
gfx::frameBegin();
262262
gfx::frameStartTop();
263-
drawTopBar(util::toUtf8(data::curData.getTitleWide()));
263+
drawTopBar(util::toUtf8(data::curData.getTitle()));
264264
backupMenu.draw(40, 82, C2D_Color32(0xFF, 0xFF, 0xFF, 0xFF), 320);
265265
gfx::frameStartBot();
266266
gfx::frameEnd();
@@ -335,7 +335,7 @@ namespace ui
335335

336336
gfx::frameBegin();
337337
gfx::frameStartTop();
338-
drawTopBar(util::toUtf8(data::curData.getTitleWide()));
338+
drawTopBar(util::toUtf8(data::curData.getTitle()));
339339
nandBackupMenu.draw(40, 88, C2D_Color32(0xFF, 0xFF, 0xFF, 0xFF), 320);
340340
gfx::frameStartBot();
341341
gfx::frameEnd();

src/util.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ namespace util
1919
return std::string((char *)tmp);
2020
}
2121

22-
std::string toUtf8(const std::u32string& conv)
23-
{
24-
uint8_t tmp[1024];
25-
std::memset(tmp, 0, 1024);
26-
utf32_to_utf8(tmp, (uint32_t *)conv.data(), 1024);
27-
return std::string((char *)tmp);
28-
}
29-
3022
std::u16string toUtf16(const std::string& conv)
3123
{
3224
char16_t tmp[1024];
@@ -35,14 +27,6 @@ namespace util
3527
return std::u16string(tmp);
3628
}
3729

38-
std::u32string toUtf32(const std::u16string& conv)
39-
{
40-
uint32_t tmp[1024];
41-
std::memset(tmp, 0, 1024 * 4);
42-
utf16_to_utf32(tmp, (uint16_t *)conv.data(), 1024);
43-
return std::u32string((char32_t *)tmp);
44-
}
45-
4630
std::u16string createPath(data::titleData& dat, const uint32_t& mode)
4731
{
4832
std::u16string ret;

0 commit comments

Comments
 (0)