Conversation
…ot shown if worker on district bug
…h_City_can_build_improvement to simplify; Push water tile check logic into repl calls to original functions
…replacing districts with improvements
…c for AI building central rail hubs
…, buildable_by_civ_cultures
…districts; Have leader_can_build_district take civ_id as an arg instead of basing off tile owner, allowing bridges, etc on non-owner tiles
|
I have not looked into those other items yet because I wanted to understand the code first. I'll get to them soon. |
…if city is on tile for tile naming
…s, in reduce_city_population_due_to_lost_neighborhood, remove_dependent_buildings_for_district, patch_Unit_attack_tile
…ted after successful lookup
…ze_improvement_loops is false
|
Ok, as always I'm floored by your sleuthing skills and attention to detail. I think I've addressed everything.
instafluff0@34a6560 - I set the right-click to also check and make sure the tile doesn't have a city on it. Note that I intentionally didn't put that check in It's hilarious, after all these years I had no idea one could Shift+right click to set production. Thanks for catching that.
instafluff0@010d032 - nice find, some day I'll learn how to properly write a while loop.
instafluff0@6d2a764 - D'oh, yes.
instafluff0@85dee1e - I recall I missed this last time with neighborhood messages as well, sorry. Should be good now.
instafluff0@f239d2a - Good call. Incidentally this was the fix for "Clicking move units of the same type causes them to 'build' a natural wonder" bug, though I'm guessing you figured that out already.
instafluff0@ce7dfb0 - Good catch! |
|
Looks good except one thing. In I've finally finished reading through injected_code.c! What an epic it's become, 36000 lines. I have more notes but I've already shared the important things. I'll go over them once more to decide what of the rest is worth bothering you with. |
Got it, I'll take a closer look and fix that. I think I missed the larger implications here.
Whoa! Nice! And thank you for reviewing. I agree it is becoming quite epic. And that sounds good, I'm happy to clean/fix up whatever is needed. |
7bb1943 - Ok, |
…CX canvas size, as vanilla does
|
Perfect. I noticed a couple more things since my earlier post:
Also I looked into those issues you raised originally:
|
…s debugging return early statements in patch_Unit_ai_move_air_defense_unit and patch_Unit_ai_move_air_transport
…x for workers on water waking up each turn
…its over maritime districts, as units themselves just need the pillage ability
|
Awesome, thank you very much for the reviews above. Some of these things I can't believe I missed or forgot about.
b960724 - Ah, I had meant to rework this and add a general check for district obsolescence, after initially thinking to explicitly check Great Wall, then lost track. Implemented now.
same commit as above - I had been testing and comparing AI movements compared to vanilla code and forgotten to take out the early returns, removed now.
7b6cf93 - THANK YOU! This is so strange, I could swear that I tried patching that exact call multiple times before, but for whatever reason I couldn't get it to work. Taking a fresh look now and doing so did the trick. Wow, that is incredibly satisfying.
1704b9f - This was the only issue that I wasn't able to fully resolve, and workers on coastal tile go-to states still seem to awaken. You're right, I was aware of non-NULL transport causing the unit to go into fortified state, but hadn't thought to restore those variables as well. Since (line ~27,372) if (is->coast_walk_restore_goto_path) {
this->Body.path_len = is->coast_walk_prev_path_len;
this->Body.path_dest_x = is->coast_walk_prev_path_dest_x;
this->Body.path_dest_y = is->coast_walk_prev_path_dest_y;
}Unfortunately I'm not seeing any change. Workers still wake up on water tiles while following a multi-turn route. I'm still investigating, but if you see something obviously off let me know.
Same as previous commit + 3afa3e2 - Perfect, thank you. I implemented a repl call with I made the injected state variable names a bit more general in case we ever need to reuse them. If I'm overcomplicating this or you want me to rename those, just let me know.
7699f0f - Crap, yes you are right. It didn't even occur to me that naval units simply wouldn't have that ability. I will add a note in Districts documentation about this to give people a heads up, but right, it doesn't make sense to force this in C3X code itself given that it can be done via editors.
Alright, in that case I'll leave as-is.
|
… clearing lights files; Fix central rail background colors
…s think units cant cross those tiles but technically can; Update Great Wall light annotations


Hey @maxpetul,
I hope things are going well. I've been hard at work on the new additions to districts. As seems to be my MO these days, I set out with a very specific set of goals and a relatively narrow scope. That lasted about ... 2 weeks. As I reworked things and added new features, those in turn inspired me to add more ... and more. I also have gotten a lot of feedback from modders and so on on CivFanatics and did my best to add straightforward features that weren't much of a lift, or seemed worth it.
Anyway, the PR has become quite big (again), for which I can only apologize for asking you to do yet another huge code review. Thank you very much, as always.
After this gets merged and any outstanding bugs get worked out, I plan to go quiet for a while and take a break. At this point I have no intended major additions I want to do to districts - this PR is kind of the kitchen sink. After this I think districts will actually be very mature, in terms of features and robustness. So I can't make any promises, but at this point the only remaining dev I intend to do is adding a seasonal cycle, which will mostly be art anyway.
Changelog
Here's a reasonably exhaustive list of changelog items:
scenario.districts.txt)Current issues need advice on
I'm making the PR now as (1) I don't anticipate any other major changes to the codebase unless you request it, and (2) I've basically hit a wall on a few items I don't know how to resolve and need your help. Most of these are related to unit movement, which I think you understand much better than I do.
Those are:
patch_Unit_can_move_to_adjacent_tileandpatch_Unit_move_to_adjacent_tile.patch_Unit_can_perform_commandandpatch_Leader_can_do_worker_job, but those seemed to have no effect and I think for naval units they perhaps aren't checked at all? Not completely sure. As a workaround, I patchedpatch_Main_GUI_set_up_unit_command_buttonsand put the check there, BUT the code I got working to actually enable the button is ugly and took a lot of poking around the source to understand the offsets and get the right images. I hate it but couldn't figure out a better way. This works but I would love suggestions for a better way to do it.patch_Leader_get_attitude_toward. The relation penalty in the config is calledper_extraterritorial_colony_relation_penalty. I couldn't figure out how to actually loop over colonies directly though, so as a workaround loop over every tile on the map. In the source code I was able to find and addp_coloniesto civ_prog_objects.csv, but don't quite understand how to loop over it. This is probably really dumb but I could not quite figure out why this works for p_cities and not p_colonies.buildable_by_civschecks civ names by strings. I really wanted to do this by just figuring out the civ_id and indexing that on start/load, but as configs are loaded before civs are decided, I couldn't do my typical approach. If you're ok with this I am too, but just wanted to point that out.I think the code is relatively clean, and I worked hard to incorporate your feedback from the first districts PR and keep everything tight. Overall I think it is solid. As you review the code though, you will probably come across
align_variant_and_pixel_offsets_with_coastlineand a few other functions which handle rendering maritime district stuff. I'll just say I hated putting specific if/else statements there to try to handle pixel offsets for specific terrain tile sheets and sprites, but it really looked bad without it and I couldn't find any cleaner way. In terms of how far beach/coast/land is on the coastal terrain art, it really is wacky and all over the place. Without handling that, ports and so on often appear way out in the water and look stupid. Anyway long-story-short: I know the code there is ugly and am very open to feedback. But the game looks much better because of it.Remaining stuff to do
Like I said the code is basically done, besides refinement based on feedback and thie issues I need help on above.
I'm planning to refactor and add a(this is done)buildable_on_overlaysproperty for districts that is distinct frombuildable_on, and should be done with that in a day or two.There is still some art to finish as well. ZergMazter is doing the art for Central Rail Hub and Municipal District, and probably needs a couple more weeks. I'm working on the light annotations for the new districts as well. So let's wait to actually merge this in until after those are done, but I saw no need to wait for that in order to start code reviews.
Phew! Sorry for the super long explanation. Thank you for your help. I'm very heartened by how many people have reached out and said how happy they are with the new stuff we're adding. A number of people have told me details about custom districts and scenarios they are working on, which makes it all worth it.