[BTS] and [BTS] Larger City Radius and Open Borders Tech Trading

because people are too afraid to use a real OS ;):rolleyes:

Pfft. Well, Linux-Windows bits aside, I found the cause of the problem. Unfortunately, I do not have a solution (aside from disabling a feature).

Edit: Turns out it was wrong. It's CvCity.cpp causing the headaches, in line 4302:

iHappiness += std::max(0, GC.getCultureLevelInfo(getCultureLevel()).getCultureHappiness());

Compare this to CvGameTextMgr.cpp line 8706:

iHappy = GC.getCultureLevelInfo(city.getCultureLevel()).getCultureHappiness();

which works just fine. Gonna try tweaking a few more things.

Edit: Did some tweaking. For whatever reason, I cannot get this working. When I replace the nonworking line above with:

iHappiness += std::max(0, getCultureLevel());

I get an error in compiling stating that std::max() requires 3 arguments, which makes no sense.
 
Finally fixed it! It seems, during city initialization, the city's culture level is set to -1, then it tries and checks the city's happiness, and was passing -1 to the getculturelevelinfo function, which didn't turn out pretty on all computers. Anyway, by changing the "default" culture of a city during resetting phase to 0, everything works perfectly. I'll be posting a new version up in a few minutes.
 
hey mylon, great to know you have a new stabkle bversion,

though, i must say, over 600 people played my mod, with no crash,

also i my self ran over 1500+ turns in aiauto play without a crash. so i wasnt aware of any problem.

say,
did you tagged all your changes?

and could you plz direct me to the files you changed in 1.1 so i wont have to go through all of them?

thanks alot for any help, and for this perfect modcomp,
its one of the best on the site in my opinion.

thanks for everything.
 
The crash was specific to the culture/happiness bonuses I was using to give cities from culture. If you were using an older version that did not have these features, you were immune to the crash. But if you were using a more recent version, the file I changed specifically was CvCity.cpp, wrapping the happiness and health functions around a conditional statement to make sure the culture level was not, "NO_CULTURE". Oh, and in CvInfos I changed the default culture level from 0 to 1, just for kicks. Next I should probably fix that weird quirk about how the warrior and settler start so far apart from one another.

As with any edit, WinMerge is your friend.
 
ok.. the new update works!.. thanks Mylon... there was something in the update you did that fixed the radius 1 problem I had. I haven't tried to merge and compile yet but I'll let you guys know soon. thanks keldath again for the offer and thanks Mylon for the great mod and update.. :)

fingers crossed!.. :)
 
great, it starts for me now with vista

do you think it would be possible to fix the display glitch mentioned in post 71?

thanks for your time and effort
 
great, it starts for me now with vista

do you think it would be possible to fix the display glitch mentioned in post 71?

thanks for your time and effort

Thanks for pointing that out. I'll take a look.
 
great, it starts for me now with vista

do you think it would be possible to fix the display glitch mentioned in post 71?

thanks for your time and effort

I fixed that problem too. I'm still not entirely sure what the issue was, but if anyone would like to explain it to me, here's the code I changed from setBuildingHelp() of CvGameTextMgr.cpp. All I did was comment out a few lines:
Code:
		int aiCommerces[NUM_COMMERCE_TYPES];
		for (int iI = 0; iI < NUM_COMMERCE_TYPES; ++iI)
		{
//			if (NULL == pCity)
//			{
				aiCommerces[iI] = kBuilding.getCommerceChange(iI);
				aiCommerces[iI] += kBuilding.getObsoleteSafeCommerceChange(iI);
/*			}
			else
			{
				aiCommerces[iI] = pCity->getBuildingCommerceByBuilding((CommerceTypes)iI, eBuilding);
			}*/
		}

I'll put up version 1.11. If anyone wants to test to see how this affects certain buildings (like, say, really old libraries that have doubled their culture rate), please let me know.
 
hey, it's me again

it works fine now when building cities, but upon capturing a (barbaric) city it crashes again (i'd assume similar cause)

wine: Unhandled page fault on read access to 0x000000b9 at address 0x20e0240 (thread 001f), starting debugger...
Unhandled exception: page fault on read access to 0x000000b9 in 32-bit code (0x020e0240).
[...]
Backtrace:
=>1 0x020e0240 ?getCityRadius@CvCultureLevelInfo@@QBEHXZ() in cvgamecoredll (0x00000012)
2 0x00000000 (0x00000000)
0x020e0240 ?getCityRadius@CvCultureLevelInfo@@QBEHXZ in cvgamecoredll: movl 0x78(%ecx),%eax
[...blah stuff...]
 
yeah, i figured that 1.11 is totally unrelated, that's why i didn't try

i have a feeling you should guard your array bounds a little better :)

PS: what do you think about exporting the city radius arrays from CvGlobals.cpp into XML, to allow for easier changing and adding of different radiuses?
 
Okay, uploaded 1.12 with a fix to the problem. I have no idea why the default culture level, when a city is founded, is -1 (yet quickly is changed to 0 later in initialization). I preserved this behavior and merely changed my segments of code to account for this quirk, though it might be better if the getCultureLevelInfo function returned the proper defaults if given a non-existing culture level.

To be fair, I'm not too comfortable with XML (or even the XML-reading c++ code) to import arrays from XML. If I was really dedicated, I could try replacing the array entirely with a more dynamic method (and put variables to control this method that could be changed in XML), but the array is used in a lot of places I cannot say I fully understand.
 
nice, i'll try it, but if this -1 stuff is not properly guarded against, i'm afraid the problem will reappear at other places.

for the arrays, i'd also settle for python, it's better to specify arrays anyway. i just think that bit would be preferable to modify without the need for a compiler
 
timestamps? im not sure what you mean,

acctually, as i told you before, i commented every line you added in the sdk, in v 1.0,

ever since, to track your version changes...
all i do is just compare the versions itself, thus fining the new version changes easly each time you update :)

thanks for the tip though.

say another thingy,

are you good at any speed tweaks?

though i added all your culture additions,
im not sure what number of culture to give each speed...i think i come up with somthing,
but not quite good though.

:)
 
Top Bottom