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

Reach a conclusion on SetBlight desync #105

Open
Luashine opened this issue Sep 19, 2023 · 2 comments
Open

Reach a conclusion on SetBlight desync #105

Luashine opened this issue Sep 19, 2023 · 2 comments

Comments

@Luashine
Copy link
Collaborator

Making an issue to track it formally.

https://www.hiveworkshop.com/threads/setblight-desync-issues.350885/

I haven't seen anyone post about this but thanks to the guys working on W3CE it's been revealed that the SetBlight native has a major problem: it will remove blight (regardless of the value of the addBlight argument) for any player that is holding down the shift key. This can easily cause a desync.

Link to conversation

The solution is to use the other natives, which aren't affected by the shift key:
JASS:

native SetBlightRect takes player whichPlayer, rect r, boolean addBlight returns nothing
native SetBlightPoint takes player whichPlayer, real x, real y, boolean addBlight returns nothing
native SetBlightLoc takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing

Abilities that create blight, such as the Sacrificial Skull and Undead building creation, also don't suffer from the issue.

@Luashine
Copy link
Collaborator Author

The SetBlight comment was mistaken, the discussion evolved into why the SHIFT check is there. I tested SetBlight in 1.27 and 1.36. Instead SetTerrainType(0, 0, FourCC('NOTH'), 0,5,1) is affected by the SHIFT key.

SetTerrainType(0, 0, FourCC('Ldrt'), 0,5,1) sets Lordaeron Dirt

SetTerrainType(0, 0, FourCC('NOTH'), 0,5,1) acts as a hackish API to add fog overlay like at map border. THIS ONE IS AFFECTED BY SHIFT! Shift not pressed = fog set. Shift pressed = fog removed. Code: "NOTH" aka "HTON" aka 1213484878. The actual terrain type is NOT changed, only this flag/shadow added.

SetTerrainType(0, 0, FourCC('NOTR'), 0,5,1) from the discussion is misleading, using any invalid ID just sets the terrain ID to 0, no texture, pitch black.

string.pack(">I4", GetTerrainType(0,0)) - shows readable rawcode for terrain at 0,0. Literal int 0 ID would be translated to a \0 string and not shown.

I don't see a way how to revert NOTH at least through this native. But SetBlight is safe.

Water's message is correct but was too short for me to understand what's going on.

Test map: for SetBlight only https://github.com/Luashine/wc3-test-maps/tree/master/SetBlight-depends-on-shift-key

TODO: Add this to documentation about Terrain type. Due to visibility of the above thread, SetBlight will need to refute the desync allegation in a note.

@Luashine
Copy link
Collaborator Author

Luashine commented Mar 10, 2024

PS: to document the Blight API itself, read good research about its applicability and area contraints here https://xgm.guru/p/wc3/blightapi

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

No branches or pull requests

1 participant