231 |
|
|
232 |
|
|
233 |
|
if ( strcmp(levels[i].c_str(), "0") ){ |
234 |
< |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + "_Final/AKEV/AKEV*.oni").c_str()); |
234 |
> |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + |
235 |
> |
"_Final/AKEV/AKEV*.oni").c_str()); |
236 |
|
remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); |
237 |
|
} |
238 |
|
|
246 |
|
for (int i = 0; i < 15; i++) |
247 |
|
{ |
248 |
|
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
249 |
< |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); |
249 |
> |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + |
250 |
> |
levels[i] + "_Final.oni"); |
251 |
|
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
252 |
|
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
253 |
|
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
308 |
|
/* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file). |
309 |
|
Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never |
310 |
|
run Oni before :-p */ |
311 |
< |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants the folder that *contains* the GDF) |
311 |
> |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
312 |
|
//bad Iritscen, bad! fixed buffers can cause crashes. |
313 |
|
/*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
314 |
|
strcat(prefsCommand, fullAEpath.c_str()); |
376 |
|
} |
377 |
|
|
378 |
|
ModPackage fileToModPackage(fstream &file, string modName) |
379 |
< |
{ |
378 |
< |
/* |
379 |
< |
This converts a file to a ModPackage struct. |
380 |
< |
|
381 |
< |
A few notes... |
382 |
< |
"iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok. |
383 |
< |
I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much |
384 |
< |
slower than reading a variable. |
385 |
< |
*/ |
386 |
< |
|
379 |
> |
{ |
380 |
|
ModPackage package; |
381 |
|
string line; |
382 |
|
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
568 |
|
|
569 |
|
|
570 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
571 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
571 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
572 |
> |
dir_itr->path().filename() + " "); |
573 |
|
|
574 |
|
system(importCommand.c_str()); |
575 |
|
j++; |
625 |
|
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
626 |
|
|
627 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
628 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
628 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
629 |
> |
dir_itr->path().filename() + " "); |
630 |
|
system(importCommand.c_str()); |
631 |
|
j++; |
632 |
|
} |
703 |
|
|
704 |
|
void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) |
705 |
|
{ |
706 |
< |
ofstream BSLlog("BSL2.log", ios::app ); |
706 |
> |
ofstream BSLlog("BSL.log", ios::app ); |
707 |
|
|
708 |
|
try { |
709 |
|
for ( directory_iterator dir_itr( copypath ), end_itr; |
811 |
|
| Installer to be replaced (when the new Installer | |
812 |
|
| launches, this function will be called again but will | |
813 |
|
| return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | |
814 |
+ |
| UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | |
815 |
|
\* UPDATE_CONT_UPD -- Currently unused */ |
816 |
|
int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
817 |
|
{ |
926 |
|
} |
927 |
|
newUpdateLog << "Installer was updated to:\n"; |
928 |
|
newUpdateLog << newUpdateLine.c_str(); |
929 |
< |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp::OnInit() |
929 |
> |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() |
930 |
|
doneReadingFile = true; |
931 |
|
newUpdateLog.close(); |
932 |
|
newUpdateLog.clear(); |
965 |
|
return UPDATE_SIMP_AVAIL; |
966 |
|
} |
967 |
|
} |
968 |
< |
try { |
973 |
< |
directory_iterator end; |
974 |
< |
if(exists("../updates")){ |
975 |
< |
for ( directory_iterator install_iter( "../updates" ); |
976 |
< |
install_iter != end; |
977 |
< |
++install_iter ) |
968 |
> |
try |
969 |
|
{ |
970 |
< |
|
971 |
< |
ModPackage installedPackage, updatePackage; |
972 |
< |
if ( is_directory( install_iter->path() ) && exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) { |
973 |
< |
fstream file; |
983 |
< |
file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
984 |
< |
if (!file.fail()) |
985 |
< |
{ |
986 |
< |
ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); |
987 |
< |
} |
988 |
< |
else |
989 |
< |
{ |
990 |
< |
file.close(); |
991 |
< |
continue; |
992 |
< |
} |
993 |
< |
if(!exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")); |
994 |
< |
file.close(); |
995 |
< |
file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
996 |
< |
if (!file.fail()) |
997 |
< |
{ |
998 |
< |
ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); |
999 |
< |
} |
1000 |
< |
else |
970 |
> |
directory_iterator end; |
971 |
> |
if (exists("../updates")) |
972 |
> |
{ |
973 |
> |
for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) |
974 |
|
{ |
975 |
< |
file.close(); |
976 |
< |
return UPDATE_THIRD_PARTY; |
977 |
< |
} |
978 |
< |
file.close(); |
979 |
< |
if(updatePackage.modStringVersion > installedPackage.modStringVersion) { |
980 |
< |
return UPDATE_THIRD_PARTY; |
975 |
> |
ModPackage installedPackage, updatePackage; |
976 |
> |
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
977 |
> |
{ |
978 |
> |
fstream file; |
979 |
> |
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
980 |
> |
if (!file.fail()) |
981 |
> |
ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); |
982 |
> |
else |
983 |
> |
{ |
984 |
> |
file.close(); |
985 |
> |
continue; |
986 |
> |
} |
987 |
> |
if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")) |
988 |
> |
{ |
989 |
> |
file.close(); |
990 |
> |
file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
991 |
> |
if (!file.fail()) |
992 |
> |
ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); |
993 |
> |
file.close(); |
994 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
995 |
> |
{ |
996 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
997 |
> |
return UPDATE_PKG_AVAIL; |
998 |
> |
} |
999 |
> |
} |
1000 |
> |
else |
1001 |
> |
{ |
1002 |
> |
file.close(); |
1003 |
> |
return UPDATE_PKG_AVAIL; |
1004 |
> |
} |
1005 |
> |
} |
1006 |
|
} |
1009 |
– |
|
1007 |
|
} |
1011 |
– |
} |
1012 |
– |
|
1013 |
– |
} |
1008 |
|
} |
1009 |
|
catch (exception & ex) { |
1010 |
|
// setStatusArea("Warning, handled exception: " + (string)ex.what()); |
1011 |
|
} |
1018 |
– |
|
1012 |
|
|
1013 |
|
return UPDATE_NO_UPD_AVAIL; |
1014 |
|
} |
1235 |
|
|
1236 |
|
string popenCommand = "../updates/" + strEUFN + "/install/"; |
1237 |
|
#ifdef WIN32 |
1245 |
– |
// TODO: Fill in Windows equivalent of code below :-3 |
1238 |
|
popenCommand = "replace_installer.bat"; |
1239 |
|
#else |
1240 |
|
// We can't just use '~' to mean "the home directory" because we need to check the path in C... |
1264 |
|
#endif |
1265 |
|
return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running |
1266 |
|
} |
1275 |
– |
//strPathToEUFNPackages |
1276 |
– |
|
1277 |
– |
void CrawlPackages(string pathToUpdate, string strPathToPackages) { |
1278 |
– |
try{ |
1279 |
– |
directory_iterator end; |
1280 |
– |
for ( directory_iterator update_iter( pathToUpdate ); |
1281 |
– |
update_iter != end; |
1282 |
– |
++update_iter ) |
1283 |
– |
{ |
1284 |
– |
|
1285 |
– |
ModPackage installedPackage, updatePackage; |
1286 |
– |
string updateStr = update_iter->path().string() + "/Mod_Info.cfg"; |
1287 |
– |
if ( !boost::iequals(update_iter->path().filename(),"Edition") |
1288 |
– |
&& !boost::iequals(update_iter->path().filename(),"Edition-patch") |
1289 |
– |
&& is_directory( update_iter->path() ) |
1290 |
– |
&& exists( update_iter->path().string() + "/Mod_Info.cfg" ) ) |
1291 |
– |
{ |
1292 |
– |
bool update = 0; |
1293 |
– |
fstream file; |
1294 |
– |
file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str()); |
1295 |
– |
if (!file.fail()) |
1296 |
– |
{ |
1297 |
– |
updatePackage = fileToModPackage(file, update_iter->path().filename()); |
1298 |
– |
} |
1299 |
– |
else |
1300 |
– |
{ |
1301 |
– |
file.close(); |
1302 |
– |
continue; |
1303 |
– |
} |
1304 |
– |
if(!exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg")); |
1305 |
– |
file.close(); |
1306 |
– |
file.clear(); |
1307 |
– |
file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
1308 |
– |
if (!file.fail()) |
1309 |
– |
{ |
1310 |
– |
installedPackage = fileToModPackage(file, update_iter->path().filename()); |
1311 |
– |
file.close(); |
1312 |
– |
if(updatePackage.modStringVersion > installedPackage.modStringVersion) { |
1313 |
– |
remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); |
1314 |
– |
update = 1; |
1315 |
– |
} |
1316 |
– |
} |
1317 |
– |
else |
1318 |
– |
{ |
1319 |
– |
file.close(); |
1320 |
– |
update = 1; |
1321 |
– |
} |
1322 |
– |
file.close(); |
1323 |
– |
|
1324 |
– |
if(update) { |
1325 |
– |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
1326 |
– |
|
1327 |
– |
} |
1328 |
– |
} |
1329 |
– |
} |
1330 |
– |
} |
1331 |
– |
catch (exception & ex) { |
1332 |
– |
// ex.what(); |
1333 |
– |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
1334 |
– |
} |
1335 |
– |
} |
1336 |
– |
|
1337 |
– |
|
1338 |
– |
bool ProcessThirdPartyUpdates() { |
1339 |
– |
CrawlPackages( "../updates", "./packages"); |
1340 |
– |
return true; |
1341 |
– |
// globalPackages = getPackages(); |
1342 |
– |
// refreshMods(globalInstalledMods); |
1343 |
– |
} |
1344 |
– |
|
1267 |
|
|
1268 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
1269 |
|
{ |
1290 |
|
bool needNewTrashDir = false; |
1291 |
|
bool readingVerAndDate = false; |
1292 |
|
|
1371 |
– |
// TODO: Fill in Windows equivalent of code below |
1293 |
|
#ifdef WIN32 |
1294 |
< |
string strTrashDir = "Trash\\"; |
1294 |
> |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
1295 |
|
#else |
1296 |
|
FILE *fUserName = NULL; |
1297 |
|
char chrUserName[32]; |
1428 |
|
} |
1429 |
|
} |
1430 |
|
|
1431 |
< |
CrawlPackages( strPathToEUFNPackages, strPathToPackages); |
1431 |
> |
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
1432 |
|
|
1433 |
|
// Next, we get a list of which files and folders in the update's Globalize folder to move over; all files not starting with '.' will be moved... |
1434 |
|
// ...and folders which do not exist in the current AE will be created there |
1490 |
|
return true; |
1491 |
|
} |
1492 |
|
|
1493 |
+ |
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
1494 |
+ |
{ |
1495 |
+ |
ptime startTime(second_clock::local_time()); |
1496 |
+ |
#ifdef WIN32 |
1497 |
+ |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
1498 |
+ |
#else |
1499 |
+ |
FILE *fUserName = NULL; |
1500 |
+ |
char chrUserName[32]; |
1501 |
+ |
fUserName = popen("whoami", "r"); |
1502 |
+ |
fgets(chrUserName, sizeof(chrUserName), fUserName); |
1503 |
+ |
pclose(fUserName); |
1504 |
+ |
string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh |
1505 |
+ |
int endOfName = strUserName.find("\n", 0); |
1506 |
+ |
string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; |
1507 |
+ |
bool needNewTrashDir = true; |
1508 |
+ |
tm tmStartTime = to_tm(startTime); |
1509 |
+ |
#endif |
1510 |
+ |
|
1511 |
+ |
try |
1512 |
+ |
{ |
1513 |
+ |
directory_iterator end; |
1514 |
+ |
for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) |
1515 |
+ |
{ |
1516 |
+ |
ModPackage installedPackage, updatePackage; |
1517 |
+ |
string updtPath = update_iter->path().string(); |
1518 |
+ |
string updtFolder = update_iter->path().filename(); |
1519 |
+ |
string updtModInfo = updtPath + "/Mod_Info.cfg"; |
1520 |
+ |
string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; |
1521 |
+ |
if (!boost::iequals(updtFolder, "Edition") |
1522 |
+ |
&& !boost::iequals(updtFolder, "Edition-patch") |
1523 |
+ |
&& is_directory(update_iter->path()) |
1524 |
+ |
&& exists(updtModInfo)) |
1525 |
+ |
{ |
1526 |
+ |
fstream file; |
1527 |
+ |
file.open((updtModInfo).c_str()); |
1528 |
+ |
if (!file.fail()) |
1529 |
+ |
updatePackage = fileToModPackage(file, updtFolder); |
1530 |
+ |
else |
1531 |
+ |
{ |
1532 |
+ |
file.close(); |
1533 |
+ |
continue; |
1534 |
+ |
} |
1535 |
+ |
if (exists(instModInfo)) |
1536 |
+ |
{ |
1537 |
+ |
file.close(); |
1538 |
+ |
file.clear(); |
1539 |
+ |
file.open(instModInfo.c_str()); |
1540 |
+ |
if (!file.fail()) |
1541 |
+ |
{ |
1542 |
+ |
installedPackage = fileToModPackage(file, updtFolder); |
1543 |
+ |
file.close(); |
1544 |
+ |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
1545 |
+ |
{ |
1546 |
+ |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
1547 |
+ |
{ |
1548 |
+ |
#ifdef WIN32 |
1549 |
+ |
remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); |
1550 |
+ |
#else |
1551 |
+ |
if (needNewTrashDir) |
1552 |
+ |
{ |
1553 |
+ |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
1554 |
+ |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
1555 |
+ |
create_directory(strTrashDir); |
1556 |
+ |
needNewTrashDir = false; |
1557 |
+ |
} |
1558 |
+ |
rename((path)(strPathToPackages + "/" + installedPackage.modStringName), (path)(strTrashDir + installedPackage.modStringName)); |
1559 |
+ |
#endif |
1560 |
+ |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
1561 |
+ |
} |
1562 |
+ |
} |
1563 |
+ |
} |
1564 |
+ |
else |
1565 |
+ |
file.close(); |
1566 |
+ |
} |
1567 |
+ |
file.close(); |
1568 |
+ |
file.clear(); |
1569 |
+ |
} |
1570 |
+ |
} |
1571 |
+ |
} |
1572 |
+ |
catch (exception & ex) |
1573 |
+ |
{ |
1574 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
1575 |
+ |
} |
1576 |
+ |
} |
1577 |
+ |
|
1578 |
|
/* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \ |
1579 |
|
| update's Globalize folder and changes its path, originally relative to the Installer, to be | |
1580 |
|
| relative to the structure of the Globalize folder; this makes it easier to have the Installer | |