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

Data Layer String Meaning? [Question] #108

Open
diaosuyidsy opened this issue Dec 20, 2019 · 2 comments
Open

Data Layer String Meaning? [Question] #108

diaosuyidsy opened this issue Dec 20, 2019 · 2 comments

Comments

@diaosuyidsy
Copy link

Sorry to leave this question here but what does the data in Data Layer mean? I am trying to write my owner parser. When empty it shows AAAAAAA. When filled with first selected tiles it shows AgICAgAA.

@Epono
Copy link
Contributor

Epono commented Dec 21, 2019

Hi.

*Disclaimer: It's been a while since I used it, so I might not be 100% correct. *

It depends on the layer type. For what I remember:

  • If it's a tile or ground layer, it's a Base64 encoded 1D array (with a size of width*height) of tile IDs.
    If you're using Haxe, there is an helper function, you can retrieve it like this :
var tilesArray:Array<Int> = tileLayer.data.data.decode();
  • If it's an object layer, it's a Base64 encoded 1D array of 3-uples (one object is represented by 3 consecutive values, respectively x, y and ID).
    Again, there is an helper function in Haxe :
var objectsArray:Array<Int> = objectsLayer.data.data.decode()

See this function for a more complete example.

If you enabled compression (LZ4), you'll have to decompress it first.

You can read more at castledb.org under The Data Model > Column Types and Map Editor >Tile Layers > Objects Mode.

You can also take a look at this library I started a while ago to streamline the use of CDB data for HaxeFlixel (a simple 2D framework for Haxe).

@diaosuyidsy
Copy link
Author

@Epono Thank you for the explanation, it was very clear! For the Tile Layer, was it encrypted further somehow? Because when I put the encoded string into an online decoder or use the c# decoding method it yields null characters. For instance, when Tile ID is 0000, encoded string shows AAAAAA==, but on the online encoder it shows MDAwMA==

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

2 participants