Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Get EU4 mod information from save.
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed May 8, 2014
1 parent e75560b commit 6e96c74
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 41 deletions.
3 changes: 0 additions & 3 deletions EU4toV2/Data_Files/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ configuration =
# HOD Heart of Darkness (3.x)
V2gametype = "HOD"

# EU4 Mod: An EU4 mod to use for conversion
EU4Mod = ""

# CK2Converted: Whether or not the mod was converted from CK2. Possible values:
# yes
# no
Expand Down
Binary file modified EU4toV2/EU4_Saves/Alea_Iacta_Est_Proper_FirstIteration.zip
Binary file not shown.
Binary file modified EU4toV2/EU4_Saves/Observer_110.zip
Binary file not shown.
Binary file modified EU4toV2/EU4_Saves/Sirk_Russia.zip
Binary file not shown.
1 change: 0 additions & 1 deletion EU4toV2/Source/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Configuration::Configuration()
V2Path = obj[0]->getLeaf("V2directory");
V2DocumentsPath = obj[0]->getLeaf("V2Documentsdirectory");
V2Gametype = obj[0]->getLeaf("V2gametype");
EU4Mod = obj[0]->getLeaf("EU4Mod");
CK2Converted = (obj[0]->getLeaf("CK2Converted") == "yes");
resetProvinces = obj[0]->getLeaf("resetProvinces");
MaxLiteracy = atof(obj[0]->getLeaf("max_literacy").c_str());
Expand Down
6 changes: 0 additions & 6 deletions EU4toV2/Source/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class Configuration // Singleton
return getInstance()->V2Gametype;
}

static string getEU4Mod()
{
return getInstance()->EU4Mod;
}

static bool getCK2Converted()
{
return getInstance()->CK2Converted;
Expand Down Expand Up @@ -105,7 +100,6 @@ class Configuration // Singleton
string V2Path;
string V2DocumentsPath;
string V2Gametype;
string EU4Mod;
bool CK2Converted;
string resetProvinces;
double MaxLiteracy;
Expand Down
65 changes: 34 additions & 31 deletions EU4toV2/Source/EU4toV2Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,7 @@ int main(int argc, char * argv[]) //changed from TCHAR, no use when everything e
else
{
log("\tCK2 export direcotry is %s\n", CK2ExportLoc.c_str());
}

// Get EU4 Mod
log("Get EU4 Mod\n");
string fullModPath;
string modName = Configuration::getEU4Mod();
if (modName != "")
{
if (Configuration::getCK2Converted())
{
fullModPath = CK2ExportLoc + "\\" + modName;
}
else
{
fullModPath = EU4ModLoc + "\\" + modName;
}
if (fullModPath.empty() || (_stat(fullModPath.c_str(), &st) != 0))
{
log("%s could not be found at the specified directory. A valid path and mod must be specified.\n", modName.c_str());
printf("%s could not be found at the specified directory. A valid path and mod must be specified.\n", modName.c_str());
return (-2);
}
else
{
log("EU4 Mod is at %s\n", fullModPath.c_str());
}
}
}

//Get Input EU4 save
string inputFilename("input.eu4");
Expand Down Expand Up @@ -171,6 +145,36 @@ int main(int argc, char * argv[]) //changed from TCHAR, no use when everything e
printf("\tExtracting data.\n");
EU4World sourceWorld(obj);

// Get EU4 Mod
log("Get EU4 Mod\n");
string fullModPath = "";
vector<Object*> modObj = obj->getValue("mod_enabled");
if (modObj.size() > 0)
{
string modName = modObj[0]->getLeaf();
if (modName != "")
{
if (Configuration::getCK2Converted())
{
fullModPath = CK2ExportLoc + "\\" + modName;
}
else
{
fullModPath = EU4ModLoc + "\\" + modName;
}
if (fullModPath.empty() || (_stat(fullModPath.c_str(), &st) != 0))
{
log("%s could not be found in the specified mod directory. A valid mod directory must be specified.\n", modName.c_str());
printf("%s could not be found in the specified mod directory. A valid mod directory must be specified.\n", modName.c_str());
return (-2);
}
else
{
log("EU4 Mod is at %s\n", fullModPath.c_str());
}
}
}


// Resolve unit types
/*log("Resolving unit types.\n");
Expand Down Expand Up @@ -338,9 +342,8 @@ int main(int argc, char * argv[]) //changed from TCHAR, no use when everything e
adjacencyMapping adjacencyMap = initAdjacencyMap();

// Generate continent mapping
string EU4Mod = Configuration::getEU4Mod();
continentMapping continentMap;
if (EU4Mod != "")
if (fullModPath != "")
{
string continentFile = fullModPath + "\\map\\continent.txt";
if ((_stat(continentFile.c_str(), &st) == 0))
Expand Down Expand Up @@ -437,7 +440,7 @@ int main(int argc, char * argv[]) //changed from TCHAR, no use when everything e
return 1;
}
initUnionCultures(obj, unionCultures);
if (EU4Mod != "")
if (fullModPath != "")
{
struct _finddata_t fileData;
intptr_t fileListing = NULL;
Expand Down Expand Up @@ -491,7 +494,7 @@ int main(int argc, char * argv[]) //changed from TCHAR, no use when everything e
return 1;
}
EU4Religion::parseReligions(obj);
if (EU4Mod != "")
if (fullModPath != "")
{
struct _finddata_t fileData;
intptr_t fileListing = NULL;
Expand Down

0 comments on commit 6e96c74

Please sign in to comment.