Bridges & Tunnels (Again!)

Patar

Chieftain
Joined
Jun 7, 2008
Messages
21
Location
Illinois, USA
I've been reading some of the old idea threads about having bridges over short spans of ocean, and tunnels through mountains. I was wondering, for bridges, could I somehow use the new "fort" game mechanics in reverse to create bridges over 1 or two water tile? If someone were willing to help me with the art, I'd be willing to try and make a mod.
 
You can start with dummy art (you mentioned fort - it really does not matter at first) once you achieved some progress and there is reason for optimism that this will actually work out i would be willing to make suspension bridge model for it.
 
Now that forts can act as a canal through water, do you think that we could use that idea/game mechanic as an easy way to make land units go over water?
 
I am not sure. Even if you manage to put a fort on water (your workers can't go there... Maybe with Workboat) It still remains to be seen if land unis will be able to enter such a installation and if some sideeffects occur. One side effect that you can cout on is - ships will be destoyed without a fight, if they stay on the plot with the bridge, while a land unit enters it - it's what happens in forts.

You might need some python or even sdk coding to really resolve those issues.
 
if you do make a bridge, can i suggest there be a movement penalty for land units who go through?
 
I am not sure. Even if you manage to put a fort on water (your workers can't go there... Maybe with Workboat) It still remains to be seen if land unis will be able to enter such a installation and if some sideeffects occur.
They can't. It's easy to make a "water fort", if you will, but it doesn't do what you want. The trouble is naval units and land units are coded quite differently. This would definitely require SDK modding.
 
Does anyone have a suggestion on the best way of implementing this??? As an improvement, a terrain type, or "DOMAIN_*"???
 
Does anyone have a suggestion on the best way of implementing this??? As an improvement, a terrain type, or "DOMAIN_*"???
From a purely gameplay perspective (i.e. not taking into account how difficult it would be to code (mostly because I'm not sure how difficult it would be)) definitely improvement. You can already use carefully placed forts to create areas that both land and navel units can go (in worldbuilder) so making it a terrain type wouldn't improve on that at all.
 
I have been weeding through the BTS SDK, and I think that forts are too "comingled" with cities to easily adapt them to bridges. I'm gonna have to program this almost from scratch.
 
I played with this a bit back in warlords and getting units to move a cross the bridge isn't that hard to get working.

As for art, look through the art folder and search for the word bridge, you will find the art for the little bridges they put across rivers when you get engineering tech. If you mess with the scale in the xml entry for your new bridge improvement, that art works out well for testing purposes.
 
Alright, I have been messing around with the SDK and following Kael's case study, but it appears that whenever this statement (in bold) is evaluated, the program crashes instantly.:eek:

Here's my code, maybe an SDK guru can help! :)
Code:
case DOMAIN_LAND:

		if (pPlot->isWater() && !canMoveAllTerrain() && [B]!(GC.getImprovementInfo(pPlot->getImprovementType()).isSeaBridge())[/B])
		{
			if (!pPlot->isCity() || 0 == GC.getDefineINT("LAND_UNITS_CAN_ATTACK_WATER_CITIES"))
			{
				if (bIgnoreLoad || !isHuman() || plot()->isWater() || !canLoad(pPlot))
				{
				   /* if (fptrb) {
                        char logtime[9];
                        _strtime(logtime);
                        fprintf(fptrb,"[%s]line 2389\n", logtime);
                        fclose(fptrb);
                    }*/
					return false;
				}
			}
		}
		break;

I added a <bSeaBridge> tag in the XML per Kael's other case study.
 
I'm not sure. I just started messing around with C++ and haven't done any SDK modding yet, so I can't really help you there. What I may suggest, is to start with a tunnel first, instead of a bridge. Because you are dealing with land units and only land units, it might be a little easier.

As for getting a worker onto a mountain, you can try to copy the Submarine's "Can enter impassible terrain" function, and add it into a worker.
 
It would help if you posted your isSeaBridge function.

One "isSeaBridge" function as ordered (it's quite simple really :))

Code:
// From CvInfos.cpp:

bool CvImprovementInfo::isSeaBridge() const
{
	return m_bSeaBridge;
}

EDIT: My mom, the professional C++ programmer of the house, suggested that probably there is a null pointer. Only problem is, I am using Codeblocks and can't debug.

PS. My mom doesn't want to get involved with my summer vacation projects.
 
Onionsoilder: Just a thought... Would it be easier to implement a tunnel as a route (or does it really, really need to be in the SDK?)
 
Onionsoilder: Just a thought... Would it be easier to implement a tunnel as a route (or does it really, really need to be in the SDK?)

I'm not sure... You could try it I guess. As for that codeblock... I think the problem is you have not declared the variable "m_bSeaBridge". I don't see you passing in any variable by reference, and you didn't declare it in the function either.

Unless I'm missing something obvious and you did declare it somewhere, that might be your problem.
 
Well, the problem is narrowed down by a few things. Since your saying the game is crashing, then I'm assuming that you didn't get any errors or warnings when you compiled the dll...?

Did you declare a default value for m_bSeaBridge?

Did you add the parts to read your new value from the xml? Would look somthing like..
(Not acual code, just an example)
Code:
pXMl->read(m_bSeaBridge)
.. and ..
pXMl->write(m_bSeaBridge)

In your CvImprovementInfo.xml, what values are you passing to your bSeaBridge entry? it needs to be 1 or 0, not True or False.

And lastly, if none of that is the problem, let me see the changes you made in the CvTerrainSchemea.xml file.
 
Onionsoidler: Here is where I have defined the variable...
Code:
CvImprovementInfo::CvImprovementInfo() :
...
m_iHappiness(0),
m_iPillageGold(0),
m_iImprovementPillage(NO_IMPROVEMENT),
m_iImprovementUpgrade(NO_IMPROVEMENT),
m_bActsAsCity(true),
[B]m_bSeaBridge(true),[/B]
m_bHillsMakesValid(false),
m_bFreshWaterMakesValid(false),
m_bRiverSideMakesValid(false),
m_bNoFreshWater(false),
m_bRequiresFlatlands(false),
m_bRequiresRiverSide(false),
m_bRequiresIrrigation(false),
m_bCarriesIrrigation(false),
m_bRequiresFeature(false),
...
{
}

Jeckel: Here is where I read in from the XML:

CivInfos.cpp: line 11750
Code:
void CvImprovementInfo::read(FDataStreamBase* stream)
{
	CvInfoBase::read(stream);

	uint uiFlag=0;
	stream->Read(&uiFlag);		// flag for expansion

	stream->Read(&m_iAdvancedStartCost);
	stream->Read(&m_iAdvancedStartCostIncrease);

	stream->Read(&m_iTilesPerGoody);
	stream->Read(&m_iGoodyUniqueRange);
	stream->Read(&m_iFeatureGrowthProbability);
	stream->Read(&m_iUpgradeTime);
	stream->Read(&m_iAirBombDefense);
	stream->Read(&m_iDefenseModifier);
	stream->Read(&m_iHappiness);
	stream->Read(&m_iPillageGold);
	stream->Read(&m_iImprovementPillage);
	stream->Read(&m_iImprovementUpgrade);

	stream->Read(&m_bActsAsCity);
	[B]stream->Read(&m_bSeaBridge);[/B]
	stream->Read(&m_bHillsMakesValid);
	stream->Read(&m_bFreshWaterMakesValid);
	stream->Read(&m_bRiverSideMakesValid);
	stream->Read(&m_bNoFreshWater);
	stream->Read(&m_bRequiresFlatlands);
        ...

CvInfos.cpp: line 11863
Code:
void CvImprovementInfo::write(FDataStreamBase* stream)
{
	CvInfoBase::write(stream);

	uint uiFlag=0;
	stream->Write(uiFlag);		// flag for expansion

	stream->Write(m_iAdvancedStartCost);
	stream->Write(m_iAdvancedStartCostIncrease);

	stream->Write(m_iTilesPerGoody);
	stream->Write(m_iGoodyUniqueRange);
	stream->Write(m_iFeatureGrowthProbability);
	stream->Write(m_iUpgradeTime);
	stream->Write(m_iAirBombDefense);
	stream->Write(m_iDefenseModifier);
	stream->Write(m_iHappiness);
	stream->Write(m_iPillageGold);
	stream->Write(m_iImprovementPillage);
	stream->Write(m_iImprovementUpgrade);

	stream->Write(m_bActsAsCity);
	[B]stream->Write(m_bSeaBridge);[/B]
	stream->Write(m_bHillsMakesValid);
	stream->Write(m_bFreshWaterMakesValid);
	stream->Write(m_bRiverSideMakesValid);
	stream->Write(m_bNoFreshWater);
	stream->Write(m_bRequiresFlatlands);
        ...

CvInfos.cpp: CvImprovementInfo::read(CvXMLLoadUtility* pXML)
Code:
        ...
	pXML->GetChildXmlValByName(&m_iAdvancedStartCost, "iAdvancedStartCost");
	pXML->GetChildXmlValByName(&m_iAdvancedStartCostIncrease, "iAdvancedStartCostIncrease");
	pXML->GetChildXmlValByName(&m_bActsAsCity, "bActsAsCity");
	pXML->GetChildXmlValByName(&m_bSeaBridge, "bSeaBridge");
	pXML->GetChildXmlValByName(&m_bHillsMakesValid, "bHillsMakesValid");
	pXML->GetChildXmlValByName(&m_bFreshWaterMakesValid, "bFreshWaterMakesValid");
	pXML->GetChildXmlValByName(&m_bRiverSideMakesValid, "bRiverSideMakesValid");
	pXML->GetChildXmlValByName(&m_bNoFreshWater, "bNoFreshWater");
	pXML->GetChildXmlValByName(&m_bRequiresFlatlands, "bRequiresFlatlands");
        ...

As well, here are my ImprovementInfos.xml and associated schema... I changed the name of the schema in both files to not interfere with other files.
View attachment SeaBridgeXMLFiles.zip
 
Well all the stuff you posted looks ok. Just to point it out, pXML->blah is reading from the xml file. stream->Read and stream->Write are writing and reading from the save game.

I looked at your attached xml files and they look alright. You don't really need to change the name of the terrain schema. But if you did, remember to change it in all the xml files in the Terrain folder, as they all use the same schemea file.

Beyond that, I must say I'm out of ideas.
 
Problem Solved!!! :goodjob::goodjob::goodjob::goodjob::goodjob:

It turns out that getImprovementInfos croaks when NO_IMPROVEMENT is passed in. I'll have some screen shots of my scouts walking on fishing boats (but the fishing boats have to be adjacent to land so that a bridge can only be two spaces long!)


Now to get the AI to use them...:crazyeye:

Unfortunately (or not...) it does not appear that you can cross someone else's bridge...even if you have an open borders agreement...more debugging :wallbash:
 
Back
Top Bottom