Hydromancerx
C2C Modder
Updates
- Reduced the cost of the Seed Camp building.
- Tweaked JPL building.
- Reduced the cost of the Seed Camp building.
- Tweaked JPL building.
Update
- Some new trade goods - fine wines. Three new trade goods each provided by a World Wonder which can't be built in the same city as the other great wine producing wonders.
So they are "wonder resources"?
Also in the building code I am kind of confused. It says that X Winery requires 3 X Winerys. If its a wonder how can you build 3 let alone have it require itself?
=== modified file 'Sources/CvCity.cpp'
--- Sources/CvCity.cpp 2012-11-26 04:53:38 +0000
+++ Sources/CvCity.cpp 2012-12-06 05:34:18 +0000
@@ -1590,10 +1590,18 @@
if (abEspionageVisibility[iI])
{
pPlot->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, false);
}
}
+
+ if (bCapital) {
+ for (iI = 0; iI < MAX_TEAMS; iI++) {
+ if (GET_TEAM(GET_PLAYER(eOwner).getTeam()).isHasEmbassy((TeamTypes)iI)) {
+ pPlot->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, false);
+ }
+ }
+ }
GET_PLAYER(eOwner).setMaintenanceDirty(true);
GC.getMapINLINE().updateWorkingCity();
=== modified file 'Sources/CvPlayer.cpp'
--- Sources/CvPlayer.cpp 2012-11-26 04:53:38 +0000
+++ Sources/CvPlayer.cpp 2012-12-06 06:04:21 +0000
@@ -14910,10 +14910,25 @@
}
else
{
m_iCapitalCityID = FFreeList::INVALID_INDEX;
}
+
+ if (pOldCapitalCity != NULL) {
+ for (int iI = 0; iI < MAX_TEAMS; iI++) {
+ if (GET_TEAM(getTeam()).isHasEmbassy((TeamTypes)iI)) {
+ pOldCapitalCity->plot()->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, bUpdatePlotGroups);
+ }
+ }
+ }
+ if (pNewCapitalCity != NULL) {
+ for (int iI = 0; iI < MAX_TEAMS; iI++) {
+ if (GET_TEAM(getTeam()).isHasEmbassy((TeamTypes)iI)) {
+ pNewCapitalCity->plot()->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), true, NULL, bUpdatePlotGroups);
+ }
+ }
+ }
if (bUpdatePlotGroups)
{
if (pOldCapitalCity != NULL)
{
=== modified file 'Sources/CvPlot.cpp'
--- Sources/CvPlot.cpp 2012-11-16 02:54:35 +0000
+++ Sources/CvPlot.cpp 2012-12-06 05:21:17 +0000
@@ -2393,15 +2393,17 @@
/* Afforess Start 02/03/10 */
/* */
/* Embassy Allows Players to See Capitals */
/************************************************************************************************/
//Removed 3/7/10 due to bugs
- /*if (pCity->isCapital())
+ //Reinserted 12/5/12
+ if (pCity->isCapital())
{
+ TeamTypes pTeam = pCity->getTeam();
for (iI = 0; iI < MAX_CIV_TEAMS; ++iI)
{
- if (GET_TEAM(pCity->getTeam()).isHasEmbassy((TeamTypes)iI))
+ if (GET_TEAM(pTeam).isHasEmbassy((TeamTypes)iI))
{
changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), bIncrement, NULL, bUpdatePlotGroups);
}
}
}
=== modified file 'Sources/CvTeam.cpp'
--- Sources/CvTeam.cpp 2012-11-16 02:54:35 +0000
+++ Sources/CvTeam.cpp 2012-12-06 05:58:28 +0000
@@ -9015,25 +9015,30 @@
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < MAX_TEAMS, "eIndex is expected to be within maximum bounds (invalid Index)");
if (isHasEmbassy(eIndex) != bNewValue)
{
//Removed due to bugs
- /* CvCity* pCapital;
- for (int iI = 0; iI < MAX_PLAYERS; iI++)
- {
- if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
- {
+ //Fixed and reintroduced
+ CvCity* pCapital;
+ for (int iI = 0; iI < MAX_PLAYERS; ++iI) {
+ if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID()) {
pCapital = GET_PLAYER((PlayerTypes)iI).getCapitalCity();
- if (pCapital != NULL)
- {
+ if (pCapital != NULL) {
pCapital->plot()->updateSight(false, true);
- m_abEmbassy[eIndex] = bNewValue;
- pCapital->plot()->updateSight(true, true);
}
}
- }*/
+ }
m_abEmbassy[eIndex] = bNewValue;
+ for (int iI = 0; iI < MAX_PLAYERS; ++iI) {
+ if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID()) {
+ pCapital = GET_PLAYER((PlayerTypes)iI).getCapitalCity();
+ if (pCapital != NULL) {
+ pCapital->plot()->updateSight(true, true);
+ }
+ }
+ }
+ //m_abEmbassy[eIndex] = bNewValue;
}
}
int CvTeam::getEmbassyTradingCount() const
{
Here's a patch to make embassies grant visibility of capitals.
I noticed that contrary to the game text, it doesn't appear that embassies actually give you and the other player the ability to see each others' capitals. Looking in the code I saw that the feature had been commented and disabled because it was buggy. That seemed odd to me -- after all, the espionage system offers the exact same functionality, bug-free -- so I took a look at the code for it.
The bug was easy to spot after spending a little time figuring out how the visibility code fit together. (I'm talking about visibility as in whether we can see what's currently happening in a plot or not, not about whether the plot has ever been "revealed" or is still incognito, or whether we can pull up a city screen.) The visibility system works by keeping a 'reference count' for each team of how many things can see into a given plot. An idiom used when making a visibility-affecting change to an object is to 1) decrement the visibility counts due to the object's existence, 2) make the change, and 3) increment the visibility counts due to the object. Whoever implemented this code in the first place (correctly) copied this idiom... But then they put a loop around the whole thing, as teams can have multiple players. Naturally, this doesn't work. It also seems like they didn't really understand the visibility system, as they neglected some other changes needed when e.g. capitals move.
Code:=== modified file 'Sources/CvCity.cpp' --- Sources/CvCity.cpp 2012-11-26 04:53:38 +0000 +++ Sources/CvCity.cpp 2012-12-06 05:34:18 +0000 @@ -1590,10 +1590,18 @@ if (abEspionageVisibility[iI]) { pPlot->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, false); } } + + if (bCapital) { + for (iI = 0; iI < MAX_TEAMS; iI++) { + if (GET_TEAM(GET_PLAYER(eOwner).getTeam()).isHasEmbassy((TeamTypes)iI)) { + pPlot->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, false); + } + } + } GET_PLAYER(eOwner).setMaintenanceDirty(true); GC.getMapINLINE().updateWorkingCity(); === modified file 'Sources/CvPlayer.cpp' --- Sources/CvPlayer.cpp 2012-11-26 04:53:38 +0000 +++ Sources/CvPlayer.cpp 2012-12-06 06:04:21 +0000 @@ -14910,10 +14910,25 @@ } else { m_iCapitalCityID = FFreeList::INVALID_INDEX; } + + if (pOldCapitalCity != NULL) { + for (int iI = 0; iI < MAX_TEAMS; iI++) { + if (GET_TEAM(getTeam()).isHasEmbassy((TeamTypes)iI)) { + pOldCapitalCity->plot()->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), false, NULL, bUpdatePlotGroups); + } + } + } + if (pNewCapitalCity != NULL) { + for (int iI = 0; iI < MAX_TEAMS; iI++) { + if (GET_TEAM(getTeam()).isHasEmbassy((TeamTypes)iI)) { + pNewCapitalCity->plot()->changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), true, NULL, bUpdatePlotGroups); + } + } + } if (bUpdatePlotGroups) { if (pOldCapitalCity != NULL) { === modified file 'Sources/CvPlot.cpp' --- Sources/CvPlot.cpp 2012-11-16 02:54:35 +0000 +++ Sources/CvPlot.cpp 2012-12-06 05:21:17 +0000 @@ -2393,15 +2393,17 @@ /* Afforess Start 02/03/10 */ /* */ /* Embassy Allows Players to See Capitals */ /************************************************************************************************/ //Removed 3/7/10 due to bugs - /*if (pCity->isCapital()) + //Reinserted 12/5/12 + if (pCity->isCapital()) { + TeamTypes pTeam = pCity->getTeam(); for (iI = 0; iI < MAX_CIV_TEAMS; ++iI) { - if (GET_TEAM(pCity->getTeam()).isHasEmbassy((TeamTypes)iI)) + if (GET_TEAM(pTeam).isHasEmbassy((TeamTypes)iI)) { changeAdjacentSight((TeamTypes)iI, GC.getDefineINT("PLOT_VISIBILITY_RANGE"), bIncrement, NULL, bUpdatePlotGroups); } } } === modified file 'Sources/CvTeam.cpp' --- Sources/CvTeam.cpp 2012-11-16 02:54:35 +0000 +++ Sources/CvTeam.cpp 2012-12-06 05:58:28 +0000 @@ -9015,25 +9015,30 @@ FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)"); FAssertMsg(eIndex < MAX_TEAMS, "eIndex is expected to be within maximum bounds (invalid Index)"); if (isHasEmbassy(eIndex) != bNewValue) { //Removed due to bugs - /* CvCity* pCapital; - for (int iI = 0; iI < MAX_PLAYERS; iI++) - { - if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID()) - { + //Fixed and reintroduced + CvCity* pCapital; + for (int iI = 0; iI < MAX_PLAYERS; ++iI) { + if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID()) { pCapital = GET_PLAYER((PlayerTypes)iI).getCapitalCity(); - if (pCapital != NULL) - { + if (pCapital != NULL) { pCapital->plot()->updateSight(false, true); - m_abEmbassy[eIndex] = bNewValue; - pCapital->plot()->updateSight(true, true); } } - }*/ + } m_abEmbassy[eIndex] = bNewValue; + for (int iI = 0; iI < MAX_PLAYERS; ++iI) { + if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID()) { + pCapital = GET_PLAYER((PlayerTypes)iI).getCapitalCity(); + if (pCapital != NULL) { + pCapital->plot()->updateSight(true, true); + } + } + } + //m_abEmbassy[eIndex] = bNewValue; } } int CvTeam::getEmbassyTradingCount() const {
This works correctly so far on my system.