Ticket #46069

Clean up AI defense building code

Open Date: 2022-11-16 01:38 Last Update: 2022-12-13 22:55

Reporter:
Owner:
(None)
Type:
Status:
Open
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
None
File:
None

Details

More a meta-task related to HRM923112 and #45592, maybe I have missed some more tickets. Just some code location2s seem totally unworking. In autogames, I see whole continents conquered by a handful of barbarians because tbe cities are too busy building libraries or too failed to upkeep a lame warrior. Now, one of places that I'm almost sure does not work, dai_process_defender_want in daimilitary.c:

  bool walls = city_got_defense_effect(pcity, NULL);
Since defense effects are mostly unit class related, we get FALSE here.
  int limit_cost = pcity->shield_stock + 40;
//...
&& limit_cost <= pcity->shield_stock + 40
This variable is not modified, some redundant check. Also, I have already noticed some stange treatment of UTYF_BADCITYDEFENDER across the code.

Ticket History (3/4 Histories)

2022-11-16 01:38 Updated by: ihnatus
  • New Ticket "Clean up AI defense building code" created
2022-12-10 13:59 Updated by: cazfi
Comment

Reply To ihnatus

{{{ bool walls = city_got_defense_effect(pcity, NULL); }}} Since defense effects are mostly unit class related, we get FALSE here.

Has city_got_defense_effect() changed to do the checking with "Certain"? I think the problem here used to be that it could not tell Coastal Defense apart from City Walls, and some comments still refer to that.

2022-12-13 20:26 Updated by: ihnatus
Comment

Reply To cazfi

Has city_got_defense_effect() changed to do the checking with "Certain"?

Has it ever been different? It uses, underlyingly, get_target_bonus_effects() that evaluates to RPT_CERTAIN.

2022-12-13 22:55 Updated by: cazfi
Comment

Reply To ihnatus

Reply To cazfi

Has city_got_defense_effect() changed to do the checking with "Certain"?

Has it ever been different? It uses, underlyingly, get_target_bonus_effects() that evaluates to RPT_CERTAIN.

Ok. Then there has been wrong assumptions (likely by me, but thankfully so long ago that I don't remember. :-)

Attachment File List

No attachments

Edit

Please login to add comment to this ticket » Login