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

Build limit group #1243

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from

Conversation

Coronia
Copy link
Contributor

@Coronia Coronia commented Apr 9, 2024

Different technos can now share build limit within a group. Originally implemented by ststl. I've gotten the permission to transplant it to mainline Phobos and make further enhancement on it.

  • BuildLimitGroup.Types determines the technos that'll be used for build limit conditions of the selected techno.
  • BuildLimitGroup.Nums determines the amount of technos that would reach the build limit. If using a single integer, it'll use the sum of all technos in the group to calculate build limit. If using a list of integers with the same size of BuildLimitGroup.Types, it'll calculate build limit per techno.
  • BuildLimitGroup.ContentIfAnyMatch determines the rule of calculating build limit per techno. If set to true, build limit will be content if the amount of any techno in the group reaches its BuildLimitGroup.Nums value. If set to false, then it'll only be content if the amount of all technos in the group reached.
  • BuildLimitGroup.NotBuildableIfQueueMatch determines the moment to stop the techno's production. If set to true, its production will be stopped once the condition is content by the sum of real technos and technos in production queue. If set to false, it'll only be stopped when the condition is content by real technos.

In rulesmd.ini:

[SOMETECHNO]                                    ; TechnoType
BuildLimitGroup.Types=                          ; list of TechnoType names
BuildLimitGroup.Nums=                           ; integer, or a list of integers
BuildLimitGroup.ContentIfAnyMatch=false         ; boolean
BuildLimitGroup.NotBuildableIfQueueMatch=false  ; boolean

Copy link

github-actions bot commented Apr 9, 2024

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Starkku
Copy link
Contributor

Starkku commented Apr 10, 2024

I'll do a full code review later but I tested this in both skirmish and MP and it appeared to work fine, no crashes and no desyncs.

src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@Starkku Starkku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly fine, couple of minor code style nitpicks though.

src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/TechnoType/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Body.cpp Outdated Show resolved Hide resolved
src/Ext/House/Hooks.BuildLimit.cpp Outdated Show resolved Hide resolved
@Coronia
Copy link
Contributor Author

Coronia commented May 22, 2024

moved all hooks into Hooks.Upgrade and removed Hooks.BuildLimits, tho I didn't find out a duplicate of hook 0x50B669 yet

I've asked ststl and made sure that __fastcall can be removed here. Also fixed other code style issues

@Starkku
Copy link
Contributor

Starkku commented May 24, 2024

Why is non-upgrade related code in Hooks.Upgrade.cpp now?

@Coronia
Copy link
Contributor Author

Coronia commented May 25, 2024

According to the suggestion of MigEater I've added these additional functions:

  • BuildLimitGroup.Factor determines each of this techno instance will count as what value when calculating build limit.

    • This is only used by BuildLimitGroup. No other place will use it when counting owned objects, including BuildLimitGroup.ExtraLimit.
  • You can also add an extra value into BuildLimitGroup.Nums, determined by the amount of specific technos owned by its house.

    • BuildLimitGroup.ExtraLimit.Types determines the technos that'll be used for extra value calculation.
    • BuildLimitGroup.ExtraLimit.Nums determines the actual value of increment. Value matching the position in BuildLimitGroup.ExtraLimit.Types is used for that type. For each of these technos, it'll increase the extra value by its amount * corresponding value from the list.
    • BuildLimitGroup.ExtraLimit.MaxCount determines the maximum amount of technos being counted into the extra value calculation. Value matching the position in BuildLimitGroup.ExtraLimit.Types is used for that type. If not set or set to a value below 1, it'll be considered as no maximum count.
    • BuildLimitGroup.ExtraLimit.MaxNum determines the maximum of values in BuildLimitGroup.Nums after extra limit calculation. If not set or set to a value below 1, it'll be considered as no maximum value.

    In rulesmd.ini:

[SOMETECHNO]                                    ; TechnoType
BuildLimitGroup.Factor=1                        ; integer
BuildLimitGroup.ExtraLimit.Types=               ; list of TechnoType names
BuildLimitGroup.ExtraLimit.Nums=                ; list of integers
BuildLimitGroup.ExtraLimit.MaxCount=            ; list of integers
BuildLimitGroup.ExtraLimit.MaxNum=0             ; integer

Please test and review it when you have time, cuz I'm not 100% sure my calculation logic is correct

src/Ext/BuildingType/Hooks.Upgrade.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants