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

Fix missing arrival when sending lords & donkeys #2594

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/src/hooks/helpers/use-resource-arrivals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useNextBlockTimestamp from "../useNextBlockTimestamp";

const DONKEY_RESOURCE_TRACKER = 452312848583266388373324160190187140051835877600158453279131187530910662656n;
const LORDS_RESOURCE_TRACKER = 7237005577332262213973186563042994240829374041602535252466099000494570602496n;
Comment on lines 9 to 10
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding documentation comments above these constants to explain what each resource tracker represents and how they're used. This would help future maintainers understand the significance of these magic numbers.

Suggested change
const DONKEY_RESOURCE_TRACKER = 452312848583266388373324160190187140051835877600158453279131187530910662656n;
const LORDS_RESOURCE_TRACKER = 7237005577332262213973186563042994240829374041602535252466099000494570602496n;
/**
* Represents a resource tracker for donkey-related resources.
* Used to track entities that are specifically carrying donkey resources.
*/
const DONKEY_RESOURCE_TRACKER = 452312848583266388373324160190187140051835877600158453279131187530910662656n;
/**
* Represents a resource tracker for LORDS tokens.
* Used to track entities that are carrying LORDS token resources.
*/
const LORDS_RESOURCE_TRACKER = 7237005577332262213973186563042994240829374041602535252466099000494570602496n;
/**
* Combined resource tracker for both LORDS tokens and donkey resources.
* This tracker is the sum of DONKEY_RESOURCE_TRACKER and LORDS_RESOURCE_TRACKER,
* used to track entities carrying both types of resources simultaneously.
*/

const LORDS_AND_DONKEY_RESOURCE_TRACKER = 7689318425915528602346510723233181380881209919202693705745230188025481265152n;

export type ArrivalInfo = {
entityId: ID;
Expand Down Expand Up @@ -69,7 +70,9 @@ const usePlayerArrivals = () => {
// Check if entity has special resource types that don't need weight check
const hasSpecialResources =
ownedResourceTracker?.resource_types === DONKEY_RESOURCE_TRACKER ||
ownedResourceTracker?.resource_types === LORDS_RESOURCE_TRACKER;
ownedResourceTracker?.resource_types === LORDS_RESOURCE_TRACKER ||
ownedResourceTracker?.resource_types === LORDS_AND_DONKEY_RESOURCE_TRACKER;


// Determine if entity meets weight requirements
const meetsWeightRequirement = hasSpecialResources || hasMinWeight(id);
Expand All @@ -82,7 +85,6 @@ const usePlayerArrivals = () => {
// Check if entity has resources
const hasResources =
meetsWeightRequirement && !!ownedResourceTracker && ownedResourceTracker.resource_types !== 0n;

// Find matching player structure at position
const playerStructurePosition = playerStructurePositions.find(
(structurePosition) => structurePosition.x === position.x && structurePosition.y === position.y,
Expand Down
Loading