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

Feature: Per-group wagon removal flag #7441

Open
wants to merge 3 commits into
base: master
from

Conversation

@PeterN
Copy link
Member

PeterN commented Mar 30, 2019

Implements #5730.

Group::replace_protection is converted to a bitmap of flags.
Savegame conversion is there just to set the flag for existing groups for compatibility.

@@ -23,7 +23,7 @@ static const SaveLoad _group_desc[] = {
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_164), // num_vehicle
SLE_VAR(Group, owner, SLE_UINT8),
SLE_VAR(Group, vehicle_type, SLE_UINT8),
SLE_VAR(Group, replace_protection, SLE_BOOL),
SLE_VAR(Group, flags, SLE_UINT8),

This comment has been minimized.

Copy link
@michicc

michicc Mar 30, 2019

Member

While I think the standard somewhere says that the numeric value of true is 1, I'm not sure relying on old savegames to only contain 0 or 1 here is wise.

As you are doing a savegame bump anyway, maybe clear all other bits for old saves?

@@ -65,6 +65,7 @@ struct GroupStatistics {

enum GroupFlags : uint8 {
GF_REPLACE_PROTECTION, ///< If set to true, the global autoreplace has no effect on the group
GF_END,

This comment has been minimized.

Copy link
@michicc

michicc Mar 30, 2019

Member

Put in a comment that CmdSetGroupFlag is currently limited to 3 bits?

This comment has been minimized.

Copy link
@PeterN

PeterN Mar 30, 2019

Author Member

Hmm, yeah, this is wrong as I used GroupFlags as the storage type but the values within the enum are used to set bits. Perhaps it should be:

enum GroupFlag { ... }
typedef uint8 GroupFlags

or something.

src/saveload/saveload.h Outdated Show resolved Hide resolved
@PeterN PeterN force-pushed the PeterN:per-group-wagon-removal branch from 481ed27 to c1f356c Apr 10, 2019
@PeterN PeterN force-pushed the PeterN:per-group-wagon-removal branch from c1f356c to 08d18c7 May 3, 2019
Copy link
Member

LordAro left a comment

Conflict needs resolving, and I'd like to see the above comments addressed as well

@@ -91,14 +91,14 @@
{
EnforcePrecondition(false, IsValidGroup(group_id));

return ScriptObject::DoCommand(0, group_id, enable ? 1 : 0, CMD_SET_GROUP_REPLACE_PROTECTION);
return ScriptObject::DoCommand(0, group_id | (GroupFlags::GF_REPLACE_PROTECTION), enable ? 1 : 0, CMD_SET_GROUP_FLAG);

This comment has been minimized.

Copy link
@LordAro

LordAro Jun 29, 2019

Member

unnecessary parens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.