Bug adding modded building ( Memory overwritten towngen2.cpp line 324)[solved]

Discussions about modding and share your mods with other players in this forum.
Post Reply
Pietro
Mod Contributor
Mod Contributor
Posts: 59
Joined: Thu Sep 15, 2016 2:50 am

Bug adding modded building ( Memory overwritten towngen2.cpp line 324)[solved]

Post by Pietro »

Hello !

I have encountered several other errors while investigating a previous 'bug' in this topic : https://capitalism2.com/forum/viewtopic.php?f=39&t=8660 But it's mostly when using wrong image format, or wrong image size, and most of them i was able to correct, and i'm starting to get familiar with the error messages.

However this one like the other one I can't understand why they are happening. I made different topic because it's different 'bug' but sounding similar. It look like this :
reproerror.jpg
reproerror.jpg (883.83 KiB) Viewed 1188 times

This one is easy to reproduce you need to change only 1 file from the regular mod_kit : building.dbf
reproerror.jpg
reproerror.jpg (163.48 KiB) Viewed 1188 times
I know what you are thinking, obviously with something this ridiculous it will create errors. BUT the error happens only with the line 19, if you only copy 18 line it is ok. 19=>error message.

I attempted this test after many tests on my images. Each of my custom building works when used individually but everytime i try to add several of them it seem like it reaches a limit and then it start to throw error. So i decided to test with the images from the mod_kit in an attempt to rule out the possibility that my custom sprites are responsible.

Why 17 custom identical buiding is ok but not 18 ?

maybe this is related as both error occur during the loading of a game, and relate to the towngen2.cpp file. Maybe this can hint that something is wrong with my setup. I have read (again) the whole modding forum that is related to buildings but couldn't find anything :( Therefore I am in hope that mister David could help me, or indicate me other thing i could do to possibly resolve my problem or tests what could cause it.

For this one no need to download additionnal files to possibly let me know if the resulst i encountered are not reproductible. One would need to edit the building.dbf.
Last edited by Pietro on Fri Jan 14, 2022 4:38 am, edited 1 time in total.
User avatar
David
Community and Marketing Manager at Enlight
Posts: 9356
Joined: Sat Jul 03, 2010 1:42 pm
Has thanked: 17 times
Been thanked: 48 times

Re: Bug adding modded building ( Memory overwritten towngen2.cpp line 324)

Post by David »

I've forwarded your files to the programmer and he will look into it and provide you with a solution soon.
Pietro
Mod Contributor
Mod Contributor
Posts: 59
Joined: Thu Sep 15, 2016 2:50 am

Re: Bug adding modded building ( Memory overwritten towngen2.cpp line 324)

Post by Pietro »

After some further testing I came up with an hypothesis :

18 buildings plus the existing 6 is making 24 buildings. Which happens to be 3 column of building in the construction menu.

Now if you add 20HQ 17RD 6FARM 10FACTORY 10APARTMEN 10COMMERCI and 14MANSION in the building.dbf with all added building copies of the mod_kit's Apart4, then it seems to load and play properly.

To get those number i tried to never exceed 3 column of buildings in the construction menu. And no bug occured.

I tried many different things, and following this rule of not exceeding 3 column, or 2 or 1 in certain category seemed like it worked fine.

Before i had realized that :

If you try to add 120 factory, you have another error message at game launch. when it's way too many. but i couldn't find information on the maximum theoric limit. I consider i just discovered it :).

If you try 50 or so, you have a 3rd different error, only when AI try to build one. not related to towngen2.cpp.

So my first hypothesis is that there is a limit in the number of building you can add in certain category. Namely those that the city can build itself, if too many it would crash at the city generation step of the game initialization or when an AI firm tries to build one.

maybe i'm wrong but i figure i could let those informations there in case it help tracking the bug, or working-around it :)
User avatar
David
Community and Marketing Manager at Enlight
Posts: 9356
Joined: Sat Jul 03, 2010 1:42 pm
Has thanked: 17 times
Been thanked: 48 times

Re: Bug adding modded building ( Memory overwritten towngen2.cpp line 324)

Post by David »

The bug has been fixed. Please download the latest patch v7.1.16 from https://www.capitalism2.com/forum/viewt ... f=7&t=8514

The new buildings that you have added to the game look very nice. Do you have any plan to release your mod to the community?
Pietro
Mod Contributor
Mod Contributor
Posts: 59
Joined: Thu Sep 15, 2016 2:50 am

Re: Bug adding modded building ( Memory overwritten towngen2.cpp line 324)

Post by Pietro »

Good to hear ! I will be trying the update today.

I'm better at planning than at following the plan but yes i have some plans to make the mod and files available.

I'm not quite sure where it is appropriate to host the source file for the mod. ( it is around 300Mo but it will increase)

I have made an account in the moddb.com and will try to publish a very early playable version once the little editing details like banners and description is made possibly in the next 3 days or sonner if i can.

For now all buildings have same stats and products are roughly balanced it's just functionning and i add a little every day.
Post Reply