Skip to content

Commit 7518a85

Browse files
committed
Check SDK version for ROM in argv/launcharg
1 parent 5dfcb9d commit 7518a85

File tree

6 files changed

+62
-8
lines changed

6 files changed

+62
-8
lines changed

romsel_dsimenutheme/arm9/source/fileBrowse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ string browseForFile(const vector<string> extensionList, const char* username)
11101110
&& (isDirectory[cursorPosition] == false) && (bnrRomType[cursorPosition] == 0) && (isHomebrew[cursorPosition] == false)
11111111
&& !titleboxXmoveleft && !titleboxXmoveright && showSTARTborder)
11121112
{
1113-
perGameSettings(dirContents[scrn].at(cursorPosition+pagenum*40).name, username);
1113+
perGameSettings(dirContents[scrn].at(cursorPosition+pagenum*40).name);
11141114
}
11151115

11161116
}

romsel_dsimenutheme/arm9/source/perGameSettings.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void savePerGameSettings (std::string filename) {
108108
pergameini.SaveIniFile( pergamefilepath );
109109
}
110110

111-
void perGameSettings (std::string filename, const char* username) {
111+
void perGameSettings (std::string filename) {
112112
int pressed = 0;
113113

114114
clearText();
@@ -119,7 +119,34 @@ void perGameSettings (std::string filename, const char* username) {
119119

120120
loadPerGameSettings(filename);
121121

122-
FILE *f_nds_file = fopen(filename.c_str(), "rb");
122+
std::string filenameForInfo = filename;
123+
if((filenameForInfo.substr(filenameForInfo.find_last_of(".") + 1) == "argv")
124+
|| (filenameForInfo.substr(filenameForInfo.find_last_of(".") + 1) == "launcharg"))
125+
{
126+
std::vector<char*> argarray;
127+
128+
FILE *argfile = fopen(filenameForInfo.c_str(),"rb");
129+
char str[PATH_MAX], *pstr;
130+
const char seps[]= "\n\r\t ";
131+
132+
while( fgets(str, PATH_MAX, argfile) ) {
133+
// Find comment and end string there
134+
if( (pstr = strchr(str, '#')) )
135+
*pstr= '\0';
136+
137+
// Tokenize arguments
138+
pstr= strtok(str, seps);
139+
140+
while( pstr != NULL ) {
141+
argarray.push_back(strdup(pstr));
142+
pstr= strtok(NULL, seps);
143+
}
144+
}
145+
fclose(argfile);
146+
filenameForInfo = argarray.at(0);
147+
}
148+
149+
FILE *f_nds_file = fopen(filenameForInfo.c_str(), "rb");
123150

124151
u32 SDKVersion = 0;
125152
char game_TID[5];

romsel_dsimenutheme/arm9/source/perGameSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern char fileCounter[8];
1313

1414
void loadPerGameSettings(std::string filename);
1515
void savePerGameSettings(std::string filename);
16-
void perGameSettings(std::string filename, const char* username);
16+
void perGameSettings(std::string filename);
1717

1818

1919

romsel_r4theme/arm9/source/fileBrowse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ string browseForFile(const vector<string> extensionList, const char* username)
560560
if ((pressed & KEY_SELECT) && (isDirectory == false) && (bnrRomType == 0) && (isHomebrew == false))
561561
{
562562
cursorPosition = fileOffset;
563-
perGameSettings(dirContents.at(fileOffset).name, username);
563+
perGameSettings(dirContents.at(fileOffset).name);
564564
}
565565

566566
}

romsel_r4theme/arm9/source/perGameSettings.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,41 @@ void savePerGameSettings (std::string filename) {
108108
pergameini.SaveIniFile( pergamefilepath );
109109
}
110110

111-
void perGameSettings (std::string filename, const char* username) {
111+
void perGameSettings (std::string filename) {
112112
int pressed = 0;
113113

114114
clearText();
115115

116116
loadPerGameSettings(filename);
117117

118-
FILE *f_nds_file = fopen(filename.c_str(), "rb");
118+
std::string filenameForInfo = filename;
119+
if((filenameForInfo.substr(filenameForInfo.find_last_of(".") + 1) == "argv")
120+
|| (filenameForInfo.substr(filenameForInfo.find_last_of(".") + 1) == "launcharg"))
121+
{
122+
std::vector<char*> argarray;
123+
124+
FILE *argfile = fopen(filenameForInfo.c_str(),"rb");
125+
char str[PATH_MAX], *pstr;
126+
const char seps[]= "\n\r\t ";
127+
128+
while( fgets(str, PATH_MAX, argfile) ) {
129+
// Find comment and end string there
130+
if( (pstr = strchr(str, '#')) )
131+
*pstr= '\0';
132+
133+
// Tokenize arguments
134+
pstr= strtok(str, seps);
135+
136+
while( pstr != NULL ) {
137+
argarray.push_back(strdup(pstr));
138+
pstr= strtok(NULL, seps);
139+
}
140+
}
141+
fclose(argfile);
142+
filenameForInfo = argarray.at(0);
143+
}
144+
145+
FILE *f_nds_file = fopen(filenameForInfo.c_str(), "rb");
119146

120147
u32 SDKVersion = 0;
121148
char game_TID[5];

romsel_r4theme/arm9/source/perGameSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern int perGameSettings_asyncPrefetch;
1111

1212
void loadPerGameSettings(std::string filename);
1313
void savePerGameSettings(std::string filename);
14-
void perGameSettings(std::string filename, const char* username);
14+
void perGameSettings(std::string filename);
1515

1616

1717

0 commit comments

Comments
 (0)