-
Notifications
You must be signed in to change notification settings - Fork 173
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
feat: deletion restrictions #1611
base: main
Are you sure you want to change the base?
Conversation
May not do the recursive restriction cause they aren't used in the live game
dDatabase/CDClientDatabase/CDClientTables/CDDeletionRestrictionsTable.cpp
Outdated
Show resolved
Hide resolved
dDatabase/CDClientDatabase/CDClientTables/CDDeletionRestrictionsTable.cpp
Outdated
Show resolved
Hide resolved
dDatabase/CDClientDatabase/CDClientTables/CDDeletionRestrictionsTable.cpp
Outdated
Show resolved
Hide resolved
switch(restriction.checkType) { | ||
case eDeletionRestrictionsCheckType::INCLUDE_LOTS: | ||
if (std::ranges::find(restriction.ids, item) != restriction.ids.end()) return false; | ||
else return true; | ||
case eDeletionRestrictionsCheckType::EXCLUDE_LOTS: | ||
if (std::ranges::find(restriction.ids, item) != restriction.ids.end()) return true; | ||
else return false; | ||
case eDeletionRestrictionsCheckType::ANY_OF_THESE: | ||
// TODO: Implement | ||
return true; | ||
case eDeletionRestrictionsCheckType::ALL_OF_THESE: | ||
// TODO: Implement | ||
return true; | ||
case eDeletionRestrictionsCheckType::WHILE_IN_ZONE: | ||
if (std::ranges::find(restriction.ids, Game::zoneManager->GetZoneID().GetMapID()) != restriction.ids.end()) return false; | ||
else return true; | ||
case eDeletionRestrictionsCheckType::ALWAYS_RESTRICTED: | ||
return false; | ||
case eDeletionRestrictionsCheckType::MAX: | ||
default: | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider instead a bool toReturn before the switch and a single return at the bottom of the function instead. This would also allow you to greatly simplify the logic in the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, that would make too much sense /s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of reasons for the verbose-ness of this currently is that I wanted to make sure I got the logic correct. now that I have, I will simplify it
dDatabase/CDClientDatabase/CDClientTables/CDDeletionRestrictionsTable.cpp
Outdated
Show resolved
Hide resolved
void LoadValuesFromDatabase(); | ||
const CDDeletionRestriction& GetByID(uint32_t id); | ||
|
||
static CDDeletionRestriction Default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if this could be not public, and instead use a getter which returns a const reference to a default struct so this cannot be modified accidentally, alongside removing a static variable in place for a static function and an unnamed namespace member.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell that to itemComponentTable
thank you for adding the new table! Let's try and clean it up a bit since I know our table reading in other places is quite messy and tends to spider web to other tables. Some extra feedback was left on the logic for the check as well :) |
Co-authored-by: David Markowitz <[email protected]>
Co-authored-by: David Markowitz <[email protected]>
Co-authored-by: David Markowitz <[email protected]>
WIP