Project

General

Profile

Actions

Bug #1618

closed

Add-to-city always adds specialists

Added by Marko Lindqvist about 1 year ago. Updated about 6 hours ago.

Status:
Closed
Priority:
Normal
Category:
Server
Target version:
Start date:
07/21/2025
Due date:
% Done:

0%

Estimated time:

Description

Even when the unit has no "specialist" defined, add-to-city creates default specialists, not field workers.


Files

1618_Main.patch (2.17 KB) 1618_Main.patch Dean Brown, 09/13/2026 04:39 AM
1618.patch (1.1 KB) 1618.patch Also good for S3_2 Dean Brown, 09/13/2026 04:39 AM
Actions #1

Updated by Alexandr Ignatiev about 1 year ago

Is it a bug at all? Possibly we don't want our carefully placed workers rearranged when we add one more citizen. Here we know where the newly added citizen is. This is the behavior that existed for ages. Maybe though we could respect the city setting "new citizens will be...".

Actions #2

Updated by Marko Lindqvist about 1 year ago

Alexandr Ignatiev wrote in #note-1:

This is the behavior that existed for ages.

Oh. I thought it was new with your recent changes. Guess I haven't been using add-to-city too much previously (now been testing foodbox behavior when city grows by different means)

Actions #3

Updated by Dean Brown 2 months ago

  • File 1618_Main.patch added
  • File 1618.patch added

See also #2080

Could call this a feature request rather than a bug. That city setting is not used when a city grows normally, nor when it gets migrated to - in those cases auto_arrange_workers() gets called. I think that's the best way to go. The current code usually leaves the city with a food deficit, and if the user doesn't click on the city and re-assign the new citizens the city will lose pop, possibly on the next turn.

Actions #4

Updated by Dean Brown 2 months ago

  • File deleted (1618.patch)
Actions #5

Updated by Dean Brown 2 months ago

  • File 1618.patch added

Could target this to 3.2.6

Actions #6

Updated by Marko Lindqvist about 2 months ago

  • Assignee deleted (Alexandr Ignatiev)
Actions #7

Updated by Marko Lindqvist 24 days ago

The patch seems wrong for main branch. When the unit does have "specialist" defined, it should be respected (what otherwise is the point of that feature?)

Actions #8

Updated by Dean Brown 22 days ago

  • File deleted (1618_Main.patch)
Actions #9

Updated by Dean Brown 22 days ago

  • File 1618_Main.patch added

Yeah that Main patch was bad - not understanding the new superspecialist feature. I'm still a bit unclear about the new

struct specialist spec_type; / affects only founding and adding to cities */

in struct unit_type. It looks to me like it is only used for superspecialists, so I think it can be ignored if is_super_specialist(act_utype->spec_type) returns FALSE. Maybe I'm wrong?

Actions #10

Updated by Dean Brown 22 days ago

  • File deleted (1618_Main.patch)
Actions #11

Updated by Dean Brown 22 days ago

  • File 1618_Main.patch added

Corrected a mistake.

Actions #12

Updated by Marko Lindqvist 22 days ago

  • Category set to Server
  • Target version set to 3.3.0
Actions #13

Updated by Marko Lindqvist 22 days ago

Dean Brown wrote in #note-9:

Yeah that Main patch was bad - not understanding the new superspecialist feature. I'm still a bit unclear about the new

struct specialist spec_type; / affects only founding and adding to cities */

in struct unit_type. It looks to me like it is only used for superspecialists, so I think it can be ignored if is_super_specialist(act_utype->spec_type) returns FALSE. Maybe I'm wrong?

As far as I know, nothing prevents one from setting regular specialists as unit spec_type, even though the feature was originally meant for superspecialists. We should do the right thing also when spec_type is set but not superspecialist.

Actions #14

Updated by Dean Brown 22 days ago

Looks to me like the spec_type gets defaulted to DEFAULT_SPECIALIST in load_ruleset_units(), and that code won't allow setting it to NULL. How would you un-set the unit spec_type? Is it possible to set it to none? I want to be able to have "add to city" not always add specialists. Maybe load_ruleset_units() should allow setting spec_type to NULL if there's no "specialist" entry for a unit, then the code in city_add_unit() could test for that.

Actions #15

Updated by Marko Lindqvist 22 days ago

Dean Brown wrote in #note-14:

Looks to me like the spec_type gets defaulted to DEFAULT_SPECIALIST in load_ruleset_units(), and that code won't allow setting it to NULL. How would you un-set the unit spec_type? Is it possible to set it to none? I want to be able to have "add to city" not always add specialists. Maybe load_ruleset_units() should allow setting spec_type to NULL if there's no "specialist" entry for a unit, then the code in city_add_unit() could test for that.

I didn't know ruleset_load() sets it even if it's not set in the ruleset. Can you open a new (future) ticket about those changes needed to make regular specialist behave correctly? I guess this one should go forward as is for now.

Actions #16

Updated by Dean Brown 22 days ago

Created #2187

Actions #17

Updated by Marko Lindqvist 20 days ago

  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
Actions #18

Updated by Marko Lindqvist 13 days ago

  • Status changed from In Review to In Progress
  • Assignee changed from Marko Lindqvist to Dean Brown

I got an autogame sanity check failure "in auto_arrange_workers() ... citizens not equal [size], repairing ...", and this patch seems likely reason. You make the new citizen nothing (neither worker nor specialist) before calling auto_arrange_workers().
When sanity checking is enabled, there's this "repairing" part, but in a release version new citizen would not be made anything by that either.
Seen on the main branch.

Actions #19

Updated by Marko Lindqvist 13 days ago

Marko Lindqvist wrote in #note-18:

I got an autogame sanity check failure "in auto_arrange_workers() ... citizens not equal [size], repairing ...", and this patch seems likely reason.

Managed to reproduce, and confirmed that it's the new call from city_add_unit()

Actions #20

Updated by Dean Brown 8 days ago

  • File deleted (1618.patch)
Actions #21

Updated by Dean Brown 8 days ago

  • File deleted (1618_Main.patch)

Updated by Dean Brown 8 days ago

Looked for that sanity check failure "in auto_arrange_workers() ... citizens not equal [size], repairing ..." and found it in S3_3 and Main.
New repaired patches.

Actions #23

Updated by Marko Lindqvist 8 days ago

  • Status changed from In Progress to In Review
  • Assignee changed from Dean Brown to Marko Lindqvist
Actions #24

Updated by Marko Lindqvist about 6 hours ago

  • Status changed from In Review to Closed
Actions

Also available in: Atom PDF