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

wzapi::addBeacon: Center beacon blip #4168

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

aco4
Copy link
Contributor

@aco4 aco4 commented Jan 7, 2025

wzapi function addBeacon(x, y, playerFilter[, message]) spawns a beacon, but it's not in the middle of a tile. It's placed on the North-West (top left) corner.

Why it happens

wzapi.cpp:

bool wzapi::addBeacon(WZAPI_PARAMS(int _x, int _y, int playerFilter, optional<std::string> _message))
{
	SCRIPT_ASSERT(false, context, _x >= 0, "Beacon x value %d is less than zero", _x);
	SCRIPT_ASSERT(false, context, _y >= 0, "Beacon y value %d is less than zero", _y);
	SCRIPT_ASSERT(false, context, _x <= mapWidth, "Beacon x value %d is greater than mapWidth %d", _x, (int)mapWidth);
	SCRIPT_ASSERT(false, context, _y <= mapHeight, "Beacon y value %d is greater than mapHeight %d", _y, (int)mapHeight);

	int x = world_coord(_x);
	int y = world_coord(_y);
        ...

Needs to be

	int x = world_coord(_x) + 64;
	int y = world_coord(_y) + 64;

Each tile = 128 "world units".


I'm not sure this works; I didn't test it. Additionally, I'm not sure if there's an appropriate constant I should be using instead. Review would be appreciated.

@past-due past-due changed the title Center beacon blip wzapi::addBeacon: Center beacon blip Jan 29, 2025
@past-due
Copy link
Member

(TILE_UNITS / 2) would be the appropriate constant (I've pushed this) - just waiting for the okay from @KJeff01

@KJeff01 KJeff01 added this to the 4.6.0-beta1 milestone Jan 30, 2025
@KJeff01 KJeff01 merged commit 2f7bfd3 into Warzone2100:master Jan 30, 2025
37 checks passed
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.

3 participants