raystuttgart
Civ4Col Modder
WTP still has a few places that have "hardcoding" or "abuse of unrelated XML tags" in its logic.
Thus let us collect them all and try to remove them step by step ...
-----
Why bother to remove these things?
Isn't it working currently?
Well, yes it is working currently and code improvements as such do not add new features.
But it will make the mod much more stable and easier to maintain in the long run.
If a mod-modder not knowing that code should ever change XML it can easily break the intended DLL logic.
It is of course also pretty bad sytle of coding ...
But well there were times when I was a beginner as well.
My main focus was simply to get all that stuff working with little effort - not if it was "good style".
-----
This here e.g. is an example that has both.
It is one of the oldest pieces of logic I had ever written.
(It was even before RaR - it was still in RWL ("Ray's Wish List") which later became RaR to a huge degree.)
Hardcoding example: getSpecialBuildingType() == 26
Abuse of unrelated XML tags example: GC.getBuildingInfo(eBuilding).getAICitySize() == 4
-----------
@devolution:
I will take care of the example you posted.
Buildings will get this XML attribute:
RouteTypeCreatedOnCityCenterPlot
(it will be able to contain "RoutTypes" and will be optional in XML)
Thus let us collect them all and try to remove them step by step ...
-----
Why bother to remove these things?
Isn't it working currently?
Well, yes it is working currently and code improvements as such do not add new features.
But it will make the mod much more stable and easier to maintain in the long run.
If a mod-modder not knowing that code should ever change XML it can easily break the intended DLL logic.
It is of course also pretty bad sytle of coding ...
But well there were times when I was a beginner as well.
My main focus was simply to get all that stuff working with little effort - not if it was "good style".
-----
This here e.g. is an example that has both.
It is one of the oldest pieces of logic I had ever written.
(It was even before RaR - it was still in RWL ("Ray's Wish List") which later became RaR to a huge degree.)
Hardcoding example: getSpecialBuildingType() == 26
Abuse of unrelated XML tags example: GC.getBuildingInfo(eBuilding).getAICitySize() == 4
Here's another suggestion for removal of hard-coding: Add a (Free)Route attribute (or similar) to BuildingInfo:
"CvCity:: ProcessBuilding"
Code://RWL Railroads and Trainstations if (GC.getBuildingInfo(eBuilding).getSpecialBuildingType() == 26) // easiest way to identify Trainstation { //WTP fixing small bugs in City Founding an Roads CvPlot* pPlot = plot(); if (pPlot->getRouteType() < 2) { pPlot->setRouteType((RouteTypes)2); } } //RWL END Railroads and Trainstations // R&R, ray, Plastered Road if (GC.getBuildingInfo(eBuilding).getAICitySize() == 4) // easiest way to identify Townhall { //WTP fixing small bugs in City Founding an Roads CvPlot* pPlot = plot(); if (pPlot->getRouteType() < 1) { pPlot->setRouteType((RouteTypes)1); } } // R&R, ray, Plastered Road -END
-----------
@devolution:
I will take care of the example you posted.
Buildings will get this XML attribute:
RouteTypeCreatedOnCityCenterPlot
(it will be able to contain "RoutTypes" and will be optional in XML)
Last edited: