Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable the pioneer to build a "road" to the selected point. #427

Closed
MrZorG33 opened this issue Mar 27, 2021 · 19 comments
Closed

enable the pioneer to build a "road" to the selected point. #427

MrZorG33 opened this issue Mar 27, 2021 · 19 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@MrZorG33
Copy link
Collaborator

hotkey, for example, Ctrl + R.
in the early stages of the game, this will be in demand.
now he can only build a "plastered road".

@devolution79 devolution79 added the good first issue Good for newcomers label Apr 5, 2021
@devolution79
Copy link
Member

Adding the "good first issue" label since this is fairly easy to do and may serve as an intro to WTP modding.

@Ramstormp
Copy link
Contributor

@ErikSandbraaten I have spent tons of hours thrown into the deep end of clinking lists and headless nodes trying to resolve this issue; but all I have come up with is the simple changes that causes a pioneer to build the 'route to' as a basic road only, and never any of the other road types. Any clues on where I might not be looking?

@devolution79
Copy link
Member

devolution79 commented Jan 16, 2022

@Ramstormp

Trying to remember what I had in mind, it's been a while...

Here's one possible way to do it: add a new mission (e.g. MISSION_ROUTE_TO_ROAD) and a new property which indicates the road to build to CIV4MissionInfos.
Then ensure that CvSelectionGroup::getBestBuildRoute (through the CvSelectionGroup::groupRoadTo callchain) gets passed this route somehow (otherwise it defaults to the best route which is the plastered road).
Repeat for the intermediate road type.

@raystuttgart
Copy link
Collaborator

@ErikSandbraaten , @Ramstormp
If you guys need a command button or anything like that, let me know.
I can create it then. It takes just a few minutes.

@raystuttgart
Copy link
Collaborator

@Ramstormp
If you have already succeeded that the Pioneer builds a normal Road to a certain poin, maybe you could commit / share that already. 👍

Then we others could take a look and suggest improvements.
Or if you have run out of ideas maybe @ErikSandbraaten could finalize it to build the Plastered Road.

You do not necessarily need to do it all alone if you run out of ideas.

@Ramstormp
Copy link
Contributor

@ErikSandbraaten, @raystuttgart, The Westward Ho mod has a 3-way 'road to' system which I started copying over, but ran out of motivation to finish at the time. I am not completely sure the implementation there is the nicest one though - some of it looked a little clumsy, but at least it works.. I think. So after I had copied it over I was hoping to polish it once I completely understood how it ought be done.

The graphics also needs to be different, since it was build trail/road/railroad to images in Westward Ho. So we would need one for country road and one for plastered country road.

@raystuttgart
Copy link
Collaborator

Graphics are no problem, I can always easily create new better buttons.
Take your time though and polish it, if you are still working on it. 👍

@devolution79
Copy link
Member

While debugging I stumbled upon a more generic way to accomplish this. Rather than cluttering the UI with additional buttons we could add actions to the right click menu.

@MrZorG33
Copy link
Collaborator Author

do you propose to "hang" the construction of three types of roads on one button (when you press the button, three more buttons will appear)? Or use right click?

jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit that referenced this issue Apr 14, 2023
jo-oe added a commit that referenced this issue Apr 14, 2023
… point (#427) [1] - still crashes!"

This reverts commit 0bc491f.
jo-oe added a commit that referenced this issue Apr 14, 2023
jo-oe added a commit that referenced this issue Apr 14, 2023
…427) [2 - use files made by Schmiddie, still crashing]
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit that referenced this issue Apr 14, 2023
…427) [3 - revert special char changes in CvGameTextMgr.cpp]
@jo-oe
Copy link
Contributor

jo-oe commented Apr 14, 2023

I am stuck with a crash I cannot locate due to lack of a working debugging environment. If someone wants to have a look at what I did, it is in the "route_to" branch. Otherwise I think I'm giving up on this.

jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [3 - revert special char changes in CvGameTextMgr.cpp]"

This reverts commit 5b93de7.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [2 - use files made by Schmiddie, still crashing]"

This reverts commit b55d16e.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [3 - revert special char changes in CvGameTextMgr.cpp]"

This reverts commit 5b93de7.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [2 - use files made by Schmiddie, still crashing]"

This reverts commit b55d16e.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [3 - revert special char changes in CvGameTextMgr.cpp]"

This reverts commit 5b93de7.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [2 - use files made by Schmiddie, still crashing]"

This reverts commit b55d16e.
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
jo-oe added a commit that referenced this issue Apr 14, 2023
* Implement: enable the pioneer to build a road to the selected point (#427) [1] - still crashes!

* Revert "Implement: enable the pioneer to build a road to the selected point (#427) [1] - still crashes!"

This reverts commit 0bc491f.

* Implement: enable the pioneer to build a road to the selected point (#427) [1] - still crashes!

* Implement: enable the pioneer to build a road to the selected point (#427) [2 - use files made by Schmiddie, still crashing]

* Implement: enable the pioneer to build a road to the selected point (#427) [3 - revert special char changes in CvGameTextMgr.cpp]

* Implement: enable the pioneer to build a road to the selected point (#427) [4]

* Implement: enable the pioneer to build a road to the selected point (#427) [5]

* Implement: enable the pioneer to build a road to the selected point (#427) [6]

* Implement: enable the pioneer to build a road to the selected point (#427) [7]
@jo-oe
Copy link
Contributor

jo-oe commented Apr 14, 2023

Done :)

@jo-oe jo-oe closed this as completed Apr 14, 2023
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
…col-mod#427) (We-the-People-civ4col-mod#820)

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [1] - still crashes!

* Revert "Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [1] - still crashes!"

This reverts commit 0bc491f.

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [1] - still crashes!

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [2 - use files made by Schmiddie, still crashing]

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [3 - revert special char changes in CvGameTextMgr.cpp]

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [4]

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [5]

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [6]

* Implement: enable the pioneer to build a road to the selected point (We-the-People-civ4col-mod#427) [7]
jo-oe added a commit to jo-oe/Civ4ColWTP that referenced this issue Apr 14, 2023
… point (We-the-People-civ4col-mod#427) [2 - use files made by Schmiddie, still crashing]"

This reverts commit b55d16e.
@MrZorG33
Copy link
Collaborator Author

jo-oe wrote in #823:
_"I tried to implement this feature last week, but unfortunately the pioneers will incorrectly still build the highest level of road.
I suppose there is a finish check returning the wrong value if there is still a route type to be built.
I'd suggest debugging the code from a breakpoint in the CvSelectionGroup::startMission() function.

(Unfortunately I'm unable to do this myself as I cannot debug Windows applications on my system.)"_

can someone help him complete this task?

@devolution79
Copy link
Member

devolution79 commented Apr 17, 2023

@MrZorG33 We could add a context menu like (probably triggered by a right-click):
image

Which would allow the player to select the road type

@devolution79
Copy link
Member

Even better if we can trigger it after pressing the button I suppose :P

@jo-oe
Copy link
Contributor

jo-oe commented Apr 17, 2023

Ok, I did actually (and unexpectedly) find a bit of time today for looking into this again:
Unfortunately the game was a victim of the devious marketing skills of the pioneers.
Each time they had finished building a simple road, the game would check if they could still build simple road on the same plot before telling them to go to the next.
The pioneers would then say, "no, we cannot build a simple road here, because it is already there" - " But, look, we could build this plastered road which looks nicer, for only 9,99 gold, special offer for you". And the game fell for the bargain and told them, ok, build a plastered road before you go on.

Stupid pioneers did not give the game that information though when they were asked "are you finished" on the last plot. That is why the last plot always had the simple road.

It was not easy to find this, and to find the game logic telling the game about the different road types and them depending on the simple road. It was actually hardcoded in CvPlot::canBuild ... and probably not exactly doing what was intended, as the three levels were not each based on the lower but 0->1, then 1->2 or 1->3.
Unfortunately, I was not able to change that without causing Python errors I don't understand at all.

Well, now it mostly works, only the pioneers will not build the road on the target plot anymore. Maybe they are disappointed that their marketing offers are rejected and stop fulfilling the contract. Evil capitalists!

tl,dr: I'm still working on it. Give me a little more time. But I don't know when I will find this time, as I'm going on night shift again now ...

@jo-oe
Copy link
Contributor

jo-oe commented Apr 17, 2023

It should be working now. Sometimes pioneers are probably victims of the routing problems in "new movement system" if that is enabled. Country road (level 2) is not as reliably built as the level 1 and level 3 (sometimes missing on the last plot)
But I think that is good enough for now.
I'd also like to improve that check in CvPlot::canBuild to what it was probably meant to do (0->1, then, 1->2, then 2->3), but I have no idea why I'm getting python errors as a result ...) - but that is a different issue

@MrZorG33
Copy link
Collaborator Author

it works)
but for a simple road does not show the number of moves to build.
image

for other types of roads, there is a calculation. and although the calculation is not correct, but there is)
image

image

but it's already better than nothing. thank you all guys)

@jo-oe
Copy link
Contributor

jo-oe commented Apr 18, 2023

I have no idea about the displaying of required turns, which is wrong anyways as those are the turns required for moving, not for building the road.
But that apparently happens in the exe (I also tried to find out about this when working on a bug in NMS), so that's hard to impossible to change.

Anyways, I have now spent around 10 hours of work on this feature @MrZorG33 asked me to implement. I think it works sufficiently well to be used. I even managed to sort the buttons. And now I have no further motivation at all to work on it, neither on the optical aspects nor on the question of a menu.
If there is nobody else to put their energy in this, I suggest closing this issue again now.

@raystuttgart
Copy link
Collaborator

raystuttgart commented Aug 30, 2023

I also adjusted it a bit now.
(Fixed inconsistent XML referencing.)

It is definitely possible to build now, Roads, Country Roads and Plastered Roads to a plot.
No idea how the number of turns could be displayed ... but that is not that important in my opinion.

Still I think it is done.

raystuttgart added a commit that referenced this issue Aug 30, 2023
…ds" as "PLASTERED_ROADS".

(Will at some point also correct referencing of "Plastered Roads" as "Railroads".)
@MrZorG33 MrZorG33 unpinned this issue Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants