Establishing Connections

Well something is going wrong, because that message you are getting is about a debug build. Make certain you have Final_Release selected as your target, and if you do, then something very odd is going on. Have you compiled the unmodified source successfully before?
 
No, I got the same debug error. I was amazed when I started trying to compile this stuff and I was getting germane errors instead of just that one. I'm going to try to set up codeblocks again and see if I did something wrong. Could Vista be the problem? I'm calling the workspace "Spaceport" though the target is Final_Release. There's a Final_Release folder in the folder with my copy of the dll source, with many of the compiled files. Should I delete it and rebuild?
 
Yeah, do a clean rebuild after you set things up from scratch again. You can name the main folder (holding your source) anything you want, and within that will be a Final_Release folder once you start trying to compile which holds lots of chunks of the final product.
 
I uninstalled, downloaded and reinstalled codeblocks. I built a copy of the regular source for the dll and then did the same for the one I had altered. I've got the Final_Release folder, with lots of chunks like you say. When the build finished I had a bunch of object files in Final_Release. I was scared because the message gave the path where the new dll had replaced the old one and it looked like it might be my regular game dll, but had "..." so I couldn't tell. I tested and my mod, with the new tag, works fine, though the airports don't work, even though I have not added any new dll for it. I thought when you added tags to the schema without them being in the dll you got big problems. Regular BtS also works fine, so my fears must be unfounded. I just don't know what to do now. These object files are not what mod comps have.

Then I went back and "cleaned" both projects and tried to rebuild them and they didn't make it all the way.
 
Adding to the schema & XML won't cause errors if done without DLL support, it just won't change anything in the game.

By default, your final DLL should be placed in the Final_Release folder. Don't remember how to make codeblocks target anywhere else, so can't tell you how to try and find it unfortunately.
 
I just finished doing another build, after going back over all the settings from Kael's thread, including the added stuff for BtS. All the files get compiled I guess, a slow process, and then I got 6 pages of errors during linking.

Looking in the city header I find that I duplicated a function. Checkings to see if taking that out fixes it.

That fixed it. Next I'll test it out in my mod.

It works!

Funny, it works in my mod but not in a little modlet I made with just the dll and the buildings xml and schema. I guess I won't be able to share this because I have no idea why.
 
Tholish, I really like this ability, and actually would like to include it. Could you upload your source code, and comment all the code you edited?

Standard convention on commenting code would be like so:
//Start -Name of added function
code fu
//End -Name of function

So for your source, where you add in this function, include
Code:
//Start -Tholish City Connection
Code fu
//End -Tholish City Connection
In all the spots where you add/change code to the SDK.
Here's an example from ACO, some code that'll make it into ACO 0.5 whenever it comes out:
Code:
                [B]/** phungus Shift Detail start **/[/B]
                int iDetail = tmpDetail;
				bool bShift; bShift = gDLL->shiftKey(); if (bShift) { iDetail = 3; }
				bool bctrl; bctrl = gDLL->ctrlKey(); if (bctrl)
				{
					CvUnit* swap = pAttacker;
					pAttacker = pDefender;
					pDefender = swap;
				}
		[B]/** phungus Shift Detail end **/[/B]

Those comments make it easy for others to go in, use the search function, find the code changes, and cut and paste them to their source code so that merging in the modcomp is nice and easy.
 
OK, here's the minimod with the source code of the changed files in a separate folder. The minimod works now. I just forgot to put the changed xml files in a Buildings subfolder, they were right under XML. Once I fixed it, it works.

However, I tested it with an advanced future start. I had two resources in my area: oil and uranium. I put my capitol on the uranium and my other city on the oil and gave both airports. The capitol had both oil and uranium and the other city had only uranium.

I had two functiions in the wrong order, so I fixed that, compiled, and tested again. This time I had 3 bonuses in three cities: 25 aluminum in my capitol, one city with one of each, and one city with only one of one, but for trade with another civ I had exactly the right stuff because they were connected to my capitol by road. Then I tried to go to the next turn and got a CTD.
 

Attachments

I hope this thread isn't quite dead yet. We are working on a Dune mod, and one major problem we have is with trade routes. Civs are separated by deep desert, and it does not make much sense to build roads to connect the trade network. Something like airports, or possibly spaceports, makes a lot of sense.

If I understand correctly, the minimod compiles, but causes CTD in limited testing. Did anybody take this a little further? Or, is there a similar capability working in some other mod?
 
I could have sworn he had this working. I have source for it, it may be the same source above, but it didn't CTD when I tried it. :dunno: Anyway let me know if this works or not. I was eventually planning on incorporating it into the Legends of Revolution mod. Try compiling a degug dll, and see if it throws any asserts. If you do find something wrong, and fix it, please up load the debugged source :)
 
The two zips are the same. The only thing I can see about testing is in this thread, where the previous author said he got an immediate CTD. Maybe you and he discussed about other testing which worked by PM.

I will wrap a vanilla environment around your zip, and try it out in the next day or so. I hope it does not require me to build a debug dll (but thank you for your encouragement to learn building the sdk.)
 
Well, I did a limited test, and it is definitely not working correctly. I built a tiny mod which is vanilla except for this dll, its buildingschema, and a buildingsinfo with a low cost airport with tech_prereq THE_WHEEL. I started a vanilla game from scratch, and I built two cities, one near corn and one near rice. Each city showed its own resource connected.

Then when both cities built an airport, they magically showed both resources connected, and the health values showed the resource was being used correctly. This is great.

But ... then I used WB to look at the other civs. Tokugawa had cows and wheat connected to his capital. So I dropped an airport into his city with WB and went to the next turn. My cities got unhealthy! Both the corn and the rice had vanished from the connected resource list in both my cities. That's right, corn had been directly connected to one city even without the airport, and this connection vanished along with its health bonus. This is wrong; some data is getting munged. I did not have a CTD but it is clear that anything could happen once the data gets wrong this way.

Anybody interested in pushing this minimod to completion by investigating this problem? I have uploaded the minimod and the save-games at this link.

I would love it if the connection had a "range" integer parameter instead of a boolean. But for Dune, a boolean is OK; we can make a starport, which represents interplanetary range connections. As long as it supports resource trading between two civs with airports, we can definitely use it. The point is to avoid a trading network of roads between the civs. I assume that if the AI finds it is connected to civs "magically" then it will not bother trying to build long distance roads.
 
Could you post the code snippets of the mod (and what files and sections of the source they are in)? I'll look through and do it if you don't get to this in a few hours, but would help to have a look at them.
 
I meant in the source. This code:

I'm going to forgo the CvInfos code, as it is obviously loading the tag.

From CvCity.h:

Code:
public:
	CvCity();
	virtual ~CvCity();
...
//salaminizers airtrade mod
[B]	void setCityConnected(bool bCityConnected);
	bool isCityConnected() const;[/B]
//salaminizers airtrade mod.
Code:
protected:
...
//salaminizers air trade mod
	[B]bool m_bCityConnected;[/B]
//salaminizers air trade mod
};


From CvCity.cpp:

Code:
CvCity::CvCity()
{
...
//salaminizers air trade mod
[B]	m_bCityConnected = NULL;[/B]
//salaminizers air trade mod
}
Code:
void CvCity::init(int iID, PlayerTypes eOwner, int iX, int iY, bool bBumpUnits, bool bUpdatePlotGroups)
{
...
//salaminizers air trade mod
[B]	setCityConnected(false);[/B]
//salaminizers air trade mod
}
Code:
void CvCity::reset(int iID, PlayerTypes eOwner, int iX, int iY, bool bConstructorCall)
{
...
//salaminizers air trade mod
[B]	m_bCityConnected = false;[/B]
//salaminizers air trade mod
}
Code:
void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bObsolete)
{
	UnitTypes eGreatPeopleUnit;
	int iI, iJ;

	if (!(GET_TEAM(getTeam()).isObsoleteBuilding(eBuilding)) || bObsolete)
	{
...
//salaminizers air trade mod
[B]		if (GC.getBuildingInfo(eBuilding).isCityConnected())
		{
			setCityConnected(true);
			GC.getGameINLINE().updatePlotGroups();
			updateTradeRoutes();
		}[/B]
//salaminizers air trade mod
Code:
//salaminizers air trade mod
[B]bool CvCity::isCityConnected() const
{
	return m_bCityConnected;
}

void CvCity::setCityConnected(bool bCityConnected)
{
	m_bCityConnected = bCityConnected;
}[/B]
//salaminizers air trade mod
//tholish wonders if having these in the opposite order from the recipe is a problem

From CvPlot.cpp
Code:
//salaminizers air trade mod
[B]if (isCity(true,eTeam)) if (getPlotCity()->isCityConnected()) { return true; }


	return isBonusNetwork(eTeam);
}[/B]
//salaminizers air trade mod
Code:
bool CvPlot::isTradeNetworkConnected(const CvPlot* pPlot, TeamTypes eTeam) const
{
...
//salaminizers air trade mod
[B]		if (isCity(true,eTeam)) 
			if (getPlotCity()->isCityConnected()) 
			{ return true; } 
		if (pPlot->isCity(true,eTeam)) 
			if (pPlot->getPlotCity()->isCityConnected()) 
			{ return true; }[/B]
//salaminizers air trade mod
//This isn't indented properly, but being C++, this wol't make a difference
Code:
void CvPlot::updatePlotGroup(PlayerTypes ePlayer, bool bRecalculate)
{
...
//salaminizers air trade mod
[B]			if (isCity())
		if (getPlotCity()->isCityConnected())

    {
        PlayerTypes ePlayer = getOwner();
        TeamTypes team = GET_PLAYER(ePlayer).getTeam();
        CvCity* pLoopCity;
        int iI;
        int iLoop;
        for (iI = 0; iI < MAX_PLAYERS; iI++)
        {
            if (GET_PLAYER((PlayerTypes)iI).isAlive())
            {
                for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
                {
                    pAdjacentPlotGroup = pLoopCity->plot()->getPlotGroup(ePlayer);
                    if ((pAdjacentPlotGroup != NULL) && (pAdjacentPlotGroup != pPlotGroup))
                    {
						if ((pLoopCity->isCityConnected()) &&  (pLoopCity->isVisible(team, false)))
                        {
                            if (pPlotGroup == NULL)
                            {
                                pAdjacentPlotGroup->addPlot(this);
                                pPlotGroup = pAdjacentPlotGroup;
                                FAssertMsg(getPlotGroup(ePlayer) == pPlotGroup, "ePlayer's plot group is expected to equal pPlotGroup");
                            }
                            else
                            {
                                FAssertMsg(getPlotGroup(ePlayer) == pPlotGroup, "ePlayer's plot group is expected to equal pPlotGroup");
                                GC.getMapINLINE().combinePlotGroups(ePlayer, pPlotGroup, pAdjacentPlotGroup);
                                pPlotGroup = getPlotGroup(ePlayer);
                                FAssertMsg(pPlotGroup != NULL, "PlotGroup is not assigned a valid value");
                            }
                        }
                    }
                }
            }
        }
		if (pPlotGroup == NULL)
		{
			GET_PLAYER(ePlayer).initPlotGroup(this);
		}
    }[/B]
//salaminizers air trade mod
//Once again, not indented properly
 
Now we can look at the code for any errors. Unfortunately I didn't work on this, so I'm a bit lost as to what I'm looking at...

Just on the outset, this doesn't look syntactically correct:
Code:
			if (isCity())
		if (getPlotCity()->isCityConnected())
 
Bedtime here, more in 20 hours or so.

In my run I did a save game and then reload. I am no expert. But when you define a new m_ field, doesn't that also require changing the read and write functions? Is it possible one is changed and one isn't? Then after the load, a lot of data could be munged.

Perhaps you did not see funny results in your testing because you did not save and load. If you have a chance, could you try saving and loading, or review the code for that and see if it looks suspicious?
 
You're definatly right the m_bNewVariable variables need to be added to the ReadStreams and WriteStreams. This will definatly destroy saved games (you simply wol't ever be able to load a game you save). I don't think that's the cause of the errors though...
 
Back
Top Bottom