Thalassicus / cep-bnw

Civ V Communitas Expansion Pack
32 stars 22 forks source link

MAXIMUM_BUY_PLOT_DISTANCE #170

Closed skodkim closed 10 years ago

skodkim commented 10 years ago

Hi

I just had a discussion with Whoward69 concerning a bug that involved his dll. With the dll on it seems cities can work and buy tiles up to four tiles away. The problem involves the parameter MAXIMUM_BUY_PLOT_DISTANCE, which CEG updates to 4 (from 3) in CEP\Cities\CEC_Data.xml

A test shows that:

So the conclusion is that it is the updated value of MAXIMUM_BUY_PLOT_DISTANCE that causes the issue and that Whowards dll opens up expanded distances

I did a search of the CEP and found out that the variable is used in CAT\Tools\ClassMethods\MT_City.lua but I can't really see what it does.

Is there any reason we change this value? If we need this update can we do anything to secure compatibility (I reckon that it was not intended to be able to work 4 tiles from the city)?

Skodkim

stackpoint commented 10 years ago

MAXIMUM_BUY_PLOT_DISTANCE is used in MT_City.lua to determine which plot has the best value for purchase (GetBestPlotPurchaseCity). It was also used in GEM to expand the border radius for the tiles you can purchase using custom code in CityView.lua that hasn't been activated in CEP yet.

skodkim commented 10 years ago

But as the test showed you can't buy (our work) more than tiles away with the normal dll anyway. Wouldn't that mean that there's no need to make the update?

\skodkim

On 30. jan. 2014 19.44.48 CET, stackpointer notifications@github.com wrote:

MAXIMUM_BUY_PLOT_DISTANCE is used in MT_City.lua to determine which plot has the best value for purchase (GetBestPlotPurchaseCity). It was also used in GEM to expand the border radius for the tiles you can purchase using custom code in CityView.lua that hasn't been activated in CEP yet.


Reply to this email directly or view it on GitHub: https://github.com/Thalassicus/cep-bnw/issues/170#issuecomment-33719005

Sendt fra min Android telefon med K-9 Mail. Undskyld hvis jeg er lidt kortfattet.

stackpoint commented 10 years ago

It's because the code in CityView.lua hasn't been activated in CEP yet. I presume that the plan is to eventually reintroduce the code to do so.

skodkim commented 10 years ago

Wouldn't it be possible to do math in cityview.lua so that you select an increment to MAXIMUM_PLOT_BUY_DISTANCE in stead of updating the variable itself? Or make a new variable - its not as though CEP is trying to use the dll anyway since MAXIMUM_PLOT_BUY_DISTANCE doesnt work with the standard dll.

\Skodkim

stackpoint commented 10 years ago

That sounds plausible. I can't say exactly how Thal's code works though.

Thalassicus commented 10 years ago

I want to be able to buy plots up to 4 tiles away, so the behavior when combined with whoward's mod is intended. He probably did it in a much simpler way than I had to do through hacky methods in the cityview interface.

stackpoint commented 10 years ago

Whoward's mod also allows you to work tiles up to MAXIMUM_PLOT_BUY_DISTANCE tiles away in addition to buying those tiles.

skodkim commented 10 years ago

Yes, that why I was suggesting that we leave MAXIMUM_PLOT_BUY_DISTANCE at three but in stead let the player buy tiles (MAXIMUM_PLOT_BUY_DISTANCE+1) tiles away in the lua file.

\Skodkim

stackpoint commented 10 years ago

Depending on how CityView.lua is coded, just making a new variable like MAXIMUM_PLOT_BUY_DISTANCE_CEP or MAXIMUM_PLOT_BUY_ADDITIONAL would work.

skodkim commented 10 years ago

So would it be ok if I changed MAXIMUM_PLOT_BUY_DISTANCE to 3 and made a new field in the Cep table (still learning the "rules" here and don't wan't do offend anyone)?

Would it be possible to test the changes (if the code is currently disabled)

\Skodkim

stackpoint commented 10 years ago

Please note it's MAXIMUM_BUY_PLOT_DISTANCE vs MAXIMUM_PLOT_BUY_DISTANCE.

Your best bet would be just insert a new MAXIMUM_BUY_PLOT_ADDITIONAL and add the math to it in MT_City.lua.

The code in City_GetBestPlotPurchaseCity() is active and the code change for that should be pretty simple.

skodkim commented 10 years ago

I just commited my changes here: https://github.com/Thalassicus/cep-bnw/commit/05e3db1197655b13ca6a2575b589cde03b5183d5

I have not made any changes in Cat\Interface\Cities\CityView - Copy.lua and D:\Dokumenter\GitHub\cep-bnw\Cin\Cin\Interface\Cities\CityView - Copy.lua as these seem not to be used at the moment.

MAXIMUM_BUY_PLOT_ADDITIONAL is added to the table CEP in Cat\Tools\Cat_Misc.sql. The sql seemed like a reasonable place to do create the variable and the cep table as like a reasonable place to place it.

I've only test this by trying to buy tiles far away with and without whowards dll mod as I didn't know what else to do. It solves the "four tile radius bug" and doesn't seem to create any bugs, e.g. nothing in logs.

I would appreciate it if anyone could have a look at the commit (especially MT_City.lua as I know the other stuff works) and see if it looks reasonable!

\Skodkim

stackpoint commented 10 years ago

Looks good to me.