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

Commit

Permalink
Basic framework for pop compositions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed Apr 8, 2011
1 parent 913d8c2 commit 04d996b
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 38 deletions.
2 changes: 2 additions & 0 deletions cpp_version/EU3toV2Converter/EU3toV2Converter.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
<ClCompile Include="Supplementary.cpp" />
<ClCompile Include="tempFuncs.cpp" />
<ClCompile Include="V2Country.cpp" />
<ClCompile Include="V2Pop.cpp" />
<ClCompile Include="V2Province.cpp" />
<ClCompile Include="V2State.cpp" />
<ClCompile Include="V2World.cpp" />
Expand All @@ -221,6 +222,7 @@
<ClInclude Include="stdafx.h" />
<ClInclude Include="tempFuncs.h" />
<ClInclude Include="V2Country.h" />
<ClInclude Include="V2Pop.h" />
<ClInclude Include="V2Province.h" />
<ClInclude Include="V2State.h" />
<ClInclude Include="V2World.h" />
Expand Down
6 changes: 6 additions & 0 deletions cpp_version/EU3toV2Converter/EU3toV2Converter.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<ClCompile Include="RulesetHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="V2Pop.cpp">
<Filter>V2 World</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Mapper.h">
Expand Down Expand Up @@ -140,6 +143,9 @@
<ClInclude Include="RulesetHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="V2Pop.h">
<Filter>V2 World</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
Expand Down
164 changes: 163 additions & 1 deletion cpp_version/EU3toV2Converter/V2Province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,165 @@ string V2Province::getOwner()
}


void V2Province::createPops(EU3Province* oldProvince)
{
int farmers = 0;
int labourers = 0;
int craftsmen = 0;
int slaves = 0;
int soldiers = 0;
int artisans = 0;
int clergymen = 0;
int clerks = 0;
int bureaucrats = 0;
int officers = 0;
int capitalists = 0;
int aristocrats = 0;

if ( (rgoType == "\"cattle\"") || (rgoType == "\"coffee\"") || (rgoType == "\"cotton\"") || (rgoType == "\"dye\"") || (rgoType == "\"fish\"") || (rgoType == "\"fruit\"") || (rgoType == "\"grain\"") || (rgoType == "\"opium\"") || (rgoType == "\"silk\"") || (rgoType == "\"tea\"") || (rgoType == "\"tobacco\"") || (rgoType == "\"wool\"") )
{
farmers += 90;
}
else
{
labourers += 90;
craftsmen += 5;
}

//If Nation has Slavery ALLOWED, add 5 SLAVES.
soldiers += 2;
//If province has a MANUFACTORY add 2 CRAFTSMEN
//If province has a MANUFACTORY add 1 clerk.
if(0)
{
craftsmen += 2;
clerks += 1;
}
artisans += 5;
clergymen += 1;
officers += 1;
//If province is the CAPITAL or NATIONAL FOCUS add 1 BUREAUCRAT
//If province is CENTER OF TRADE then add 1 CLERK
//If government is NOT republic, add 2 ARISTOCRATS.
//If government is NOT absolute monarchy, add 2 CAPITALISTS.
//If province is capital or was national focus, add 1 ARISTOCRATS.
//If province was a COT, add 1 CAPITALISTS.
aristocrats += 1;

int total = farmers + labourers + slaves + soldiers + craftsmen + artisans + clergymen + clerks + bureaucrats + officers + capitalists + aristocrats;

if (farmers > 0)
{
V2Pop farmersPop;
farmersPop.setType("farmers");
farmersPop.setSize(oldPopulation * farmers / total);
farmersPop.setCulture(culture);
farmersPop.setReligion("animist");
pops.push_back(farmersPop);
}
if (labourers > 0)
{
V2Pop labourersPop;
labourersPop.setType("labourers");
labourersPop.setSize(oldPopulation * labourers / total);
labourersPop.setCulture(culture);
labourersPop.setReligion("animist");
pops.push_back(labourersPop);
}
if (slaves > 0)
{
V2Pop slavesPop;
slavesPop.setType("slaves");
slavesPop.setSize(oldPopulation * slaves / total);
slavesPop.setCulture(culture);
slavesPop.setReligion("animist");
pops.push_back(slavesPop);
}
if (soldiers > 0)
{
V2Pop soldiersPop;
soldiersPop.setType("soldiers");
soldiersPop.setSize(oldPopulation * soldiers / total);
soldiersPop.setCulture(culture);
soldiersPop.setReligion("animist");
pops.push_back(soldiersPop);
}
if (craftsmen > 0)
{
V2Pop craftsmenPop;
craftsmenPop.setType("craftsmen");
craftsmenPop.setSize(oldPopulation * craftsmen / total);
craftsmenPop.setCulture(culture);
craftsmenPop.setReligion("animist");
pops.push_back(craftsmenPop);
}
if (artisans > 0)
{
V2Pop artisansPop;
artisansPop.setType("artisans");
artisansPop.setSize(oldPopulation * artisans / total);
artisansPop.setCulture(culture);
artisansPop.setReligion("animist");
pops.push_back(artisansPop);
}
if (clergymen > 0)
{
V2Pop clergymenPop;
clergymenPop.setType("clergymen");
clergymenPop.setSize(oldPopulation * clergymen / total);
clergymenPop.setCulture(culture);
clergymenPop.setReligion("animist");
pops.push_back(clergymenPop);
}
if (clerks > 0)
{
V2Pop clerksPop;
clerksPop.setType("clerks");
clerksPop.setSize(oldPopulation * clerks / total);
clerksPop.setCulture(culture);
clerksPop.setReligion("animist");
pops.push_back(clerksPop);
}
if (bureaucrats > 0)
{
V2Pop bureaucratsPop;
bureaucratsPop.setType("bureaucrats");
bureaucratsPop.setSize(oldPopulation * bureaucrats / total);
bureaucratsPop.setCulture(culture);
bureaucratsPop.setReligion("animist");
pops.push_back(bureaucratsPop);
}
if (officers > 0)
{
V2Pop officersPop;
officersPop.setType("officers");
officersPop.setSize(oldPopulation * officers / total);
officersPop.setCulture(culture);
officersPop.setReligion("animist");
pops.push_back(officersPop);
}
if (capitalists > 0)
{
V2Pop capitalistsPop;
capitalistsPop.setType("capitalists");
capitalistsPop.setSize(oldPopulation * capitalists / total);
capitalistsPop.setCulture(culture);
capitalistsPop.setReligion("animist");
pops.push_back(capitalistsPop);
}
if (aristocrats > 0)
{
V2Pop aristocratsPop;
aristocratsPop.setType("aristocrats");
aristocratsPop.setSize(oldPopulation * aristocrats / total);
aristocratsPop.setCulture(culture);
aristocratsPop.setReligion("animist");
pops.push_back(aristocratsPop);
}
}



void V2Province::output(FILE* output)
{
fprintf(output, "%d=\n", num);
Expand All @@ -95,7 +254,10 @@ void V2Province::output(FILE* output)
fprintf(output, " garrison=100.000\n");
if (land)
{
outputPopStuff(output, oldPopulation, rgoType, culture);
for (unsigned int i = 0; i < pops.size(); i++)
{
pops[i].output(output);
}
fprintf(output, " rgo=\n");
fprintf(output, " {\n");
fprintf(output, " goods_type=%s\n", rgoType.c_str());
Expand Down
15 changes: 9 additions & 6 deletions cpp_version/EU3toV2Converter/V2Province.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <string>
#include "Parsers/Object.h"
#include "tempFuncs.h"
#include "V2Pop.h"
#include "EU3Province.h"
using namespace std;

class V2Province {
Expand All @@ -16,6 +18,7 @@ class V2Province {
void setColonial(bool);
void setCulture(string);
bool isColonial();
void createPops(EU3Province* oldProvince);
void output(FILE*);
private:
bool land;
Expand All @@ -24,12 +27,12 @@ class V2Province {
string owner;
//controller
//cores
bool colonial;
int oldPopulation;
//pops
string culture;
string rgoType;
int lifeRating;
bool colonial;
int oldPopulation;
vector<V2Pop> pops;
string culture;
string rgoType;
int lifeRating;
};


Expand Down
2 changes: 2 additions & 0 deletions cpp_version/EU3toV2Converter/V2World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ void V2World::convertProvinces(EU3World sourceWorld, provinceMapping provMap, co
log("Error: Could not set culture for province %d\n", destNum);
provinces[i].setCulture("");
}

provinces[i].createPops(oldProvince);
}
}
}
Expand Down
30 changes: 0 additions & 30 deletions cpp_version/EU3toV2Converter/tempFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,6 @@ void outputHeader(FILE* output)
}


void outputPopStuff(FILE* output, int population, string rgoType, string culture)
{
fprintf(output, " aristocrats=\n");
fprintf(output, " {\n");
fprintf(output, " id=%d\n", popId++);
fprintf(output, " size=%d\n", population/3);
fprintf(output, " %s=animist\n", culture.c_str());
fprintf(output, " }\n");
fprintf(output, " artisans=\n");
fprintf(output, " {\n");
fprintf(output, " id=%d\n", popId++);
fprintf(output, " size=%d\n", population/3);
fprintf(output, " %s=animist\n", culture.c_str());
fprintf(output, " }\n");
if ( (rgoType == "\"cattle\"") || (rgoType == "\"coffee\"") || (rgoType == "\"cotton\"") || (rgoType == "\"dye\"") || (rgoType == "\"fish\"") || (rgoType == "\"fruit\"") || (rgoType == "\"grain\"") || (rgoType == "\"opium\"") || (rgoType == "\"silk\"") || (rgoType == "\"tea\"") || (rgoType == "\"tobacco\"") || (rgoType == "\"wool\"") )
{
fprintf(output, " farmers=\n");
}
else
{
fprintf(output, " labourers=\n");
}
fprintf(output, " {\n");
fprintf(output, " id=%d\n", popId++);
fprintf(output, " size=%d\n", population/3);
fprintf(output, " %s=animist\n", culture.c_str());
fprintf(output, " }\n");
}


void outputCountryHeader(FILE* output)
{
fprintf(output, " wage_reform=no_minimum_wage\n");
Expand Down
1 change: 0 additions & 1 deletion cpp_version/EU3toV2Converter/tempFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ using namespace std;


void outputHeader(FILE*);
void outputPopStuff(FILE*, int, string, string);
void outputCountryHeader(FILE*);
void outputCountryHeader2(FILE*);
void outputCountryMiddle(FILE*);
Expand Down

0 comments on commit 04d996b

Please sign in to comment.