SDK Help Needed

vincentz

Programmer
Joined
Feb 4, 2009
Messages
3,614
Location
Denmark
I'm trying to get TheLopez modcomp Building Resource Converter to work, so that the consumed resource is being consumed and the newly created resource can be tradeable, but I have very little understanding of C++ and of the coredll.
I have really big plans for it/with it, so I'm really hoping to make it work.

Any help would be greatly appreciated.

Thanks

Vincentz

ps. look at the last post in the modthread for a detailed explanation of the problem.
 
Here's my attempt at this. I made some modifications to CvCity.cpp and they seem to (at least partially) work, but you'd have to test it as I'm sure it has bugs.
Attached are the compiled DLL and my modified CvCity.cpp (changes are marked with 'Asaf').
 

Attachments

Here's my attempt at this. I made some modifications to CvCity.cpp and they seem to (at least partially) work, but you'd have to test it as I'm sure it has bugs.
Attached are the compiled DLL and my modified CvCity.cpp (changes are marked with 'Asaf').

To be honest I had really high hopes that you would take a look at it.
And you did.
And it seems to be working 100%!

:goodjob::goodjob::goodjob::goodjob::goodjob:

Thank you. This is the first dll/sdk/core modification for my mod, but with all the goods/weapons I have, I needed a way to not spam them, nor make them national wonders. This is the perfect solution, and I'm a very very very happy modder right now :lol:
 
I'm glad it works :D

I'm not sure, but there might be problems if you chain a few cities (city 1 generates resource B from resource A, and city 2 which is connected to it generates resource C from resource B).

If you happen to come across a problem of this kind, let me know and attach the full scenario/saved game.
 
Would it be possible to f.ex. make the conversion limited.
Right now it takes 1 oil and makes 3 fuel, but if there are 2 oil it automatically converts it all into 6 fuel instead of 3 fuel and 1 oil.
It would somehow work better if I needed 6 fuel I had to build 2 refineries.

I think the A to B to C works pretty ok.
I set up a rubber plant (rubber or oil to synth rubber), oil refinery (oil to fuel) and iron works (iron to steel) in different cities.
I was then able to build the auto industry which required synth rubber, fuel and steel to produce Automobiles.
 
Would it be possible to f.ex. make the conversion limited.
Right now it takes 1 oil and makes 3 fuel, but if there are 2 oil it automatically converts it all into 6 fuel instead of 3 fuel and 1 oil.
It would somehow work better if I needed 6 fuel I had to build 2 refineries.

So do you want it to always be limited to 1 produced - as in the exact number which appears in the XML and not multiples? Or do you want to add an XML value for this?

And basically the code supports multiple instances of the same buildings (e.g. 2 refineries in a city), but I guess that would require some changes, probably Python interface, to work.
 
So do you want it to always be limited to 1 produced - as in the exact number which appears in the XML and not multiples? Or do you want to add an XML value for this?

And basically the code supports multiple instances of the same buildings (e.g. 2 refineries in a city), but I guess that would require some changes, probably Python interface, to work.

the exact number which appears in the XML would be perfect if possible.
I.E. : I have 5 iron and want to produce iron weapons.
I build 1 Weaponsmith and it uses 1 iron (or more defined in the xml) to produce 1 iron weapons (or more defined in the xml). I then have 4 iron left, and if I want to produce more ironweapons I have to build another Weaponsmith in another city.

I'm planning to expand it so Power Plants produce energi, and energi is consumed by various industries. (but thats a different story ;))
 
Oh, if it's only one of each building in each city - it shouldn't be a problem. I'll try adding the limit today or tomorrow.

BTW, did I mention already that this whole industry chain of resources is very very cool? :yeah:
 
Thanks :D

I really appreciate the help, as I have very limited understanding of C++, and while looking at it I can somehow understand it the same way I can look at a painting and see the way it was painted, but giving me a brush in my hand would only destoy the canvas. :think:
 
Try this (I didn't have the time to run it even once, but the only change was to cap the amount produced at 1 times the amount in the XML, so I hope it's fine).
 

Attachments

Try this (I didn't have the time to run it even once, but the only change was to cap the amount produced at 1 times the amount in the XML, so I hope it's fine).

I wish I could do what you are doing. R.e.s.p.e.c.t.

attachment.php
(1 iron is converted into 3 ironweapons)

:goodjob:

Thanks :D
 
I wish I could do what you are doing. R.e.s.p.e.c.t.
Programming is an acquired skill and anyone can learn it. No disrespect to Asaf, obviously. Once I get the time and piece of mind I'll learn to do what he does also.
 
Try this (I didn't have the time to run it even once, but the only change was to cap the amount produced at 1 times the amount in the XML, so I hope it's fine).

There are a few problems with the modcomp, and I have unfortunatey no idea how to debug or fix them, so I'm really hoping you can take a look at it again :D

1. The produced resource don't obsolete. Even if both the building and the resource obsoletes it is still there
2. When loading a loadgame it resets and the resource is not converted.

I'll upload the newest version of my mod together with a "scenario" asap.

@ Baldur
Drawing and playing music are skills too, and can be learned by anyone. Yet someone has more talent than others ;)
 
I started working on this, and, well, it's complicated.
The bug happens when I run it in the debugger as well (which is good news) - before I press Enter the iron and sulfur are converted to 3 firearms, but after that, in the beginning of the next turn, I have iron and sulfur instead of the firearms.

I can see the calculations done correctly for the city, but then something happens (a culture change of a tile) which causes a recalculation of the plot group (the group of plots connected by trade routes and therefore share resources), and this in turn causes everything to be recalculated over and over again. Somewhere along these lines something breaks.

I've tried debugging it last night but it was just too confusing for the late hour. I'll try again, but it might be a better idea to rewrite some of the code and make it simpler, and prevent the entire thing from being recalculated over and over again.

TheLopez's code was only a local conversion, so the recalculating was simpler (it was not triggered every time for every city).

I'll try to come up with a better design for this. I'll keep you posted.
 
Here's the updated version.
I intend to make a mod component out of it (once I add a few things) - 'Enhanced Resource Converter', since I rewrote most of TheLopez code and it behaves differently in many ways.

Now the calculations are done in the plot group level instead of the city level, since that's actually the influence in the game. It saves a lot of re-calculations (in addition to the fact that it should work correctly now ;) ).

I attached all the relevant C++ source files - both the ones I changed and the ones TheLopez did.

I still want to add some AI changes - so the AI can appreciate the resources and buildings according to their potential conversions. After I do that - I'll release it as a mod comp.
Not sure when I'll get around to it though, so I wanted you to have a working version.

I hope it works fine. I made some testing, but you should keep testing it and let me know if you find any problems.

I added backward compatibility for saved games to the previous version I sent you so you can test it on the saved game you gave me. After you save with it, however, it cannot be loaded by the old version.

Let me know how it goes.
 

Attachments

Back
Top Bottom