mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
With an atlas applied, SetTexCoord was addressing the whole sheet, so a crop showed a slice of the surrounding art rather than a part of the sprite, and GetTexCoord reported the atlas rect where a caller expected what it had asked for. Both came from one cause: SetAtlas was writing the atlas rect into the region's only set of coordinates, leaving the caller's own nowhere to live. A live client shows the two are separate state there: GetTexCoord reads the full 0..1 rect immediately after SetAtlas, with GetAtlas still reporting the atlas, so 0..1 means all of the sprite rather than all of the sheet. Keep the caller's coordinates alongside the atlas name and compose: SetTexCoord records them in sprite space and writes the mapped result for the engine to draw, GetTexCoord hands them back. Both handlers are co-hooked and pass straight through for a texture with no atlas, which is every texture in the game until an addon calls SetAtlas -- the empty-map test is the whole cost in that case. Both the 4-argument and 8-argument corner forms compose; anything else is left to the engine to reject so its own error text is what the author sees. ResetTexCoord becomes a plain restore of identity, which is what it always was conceptually -- the atlas rect now falls out of composing identity rather than being a special case. Also clear the atlas on SetTexture rather than inferring it from the texture handle. The handle comparison cannot detect a re-set to the very file the atlas names, because the engine returns the same HTEXTURE, so GetAtlas kept reporting an atlas that was no longer showing. That guard predates this change. It stays for recycled regions, which is the case it is actually good for and the reason this module needs no region constructor hook. Verified in-game against a registered quarter-rect atlas: identity is reported after SetAtlas, a crop reads back in sprite space, the engine receives the composed file-space rect from both argument forms, reset returns to the full sprite, SetTexture clears the atlas even to the same file, and a texture with no atlas behaves exactly as before.