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

FlxTilemap.loadMap doesn't respect trailing whitespace in CSV files #1550

Closed
rrohrer opened this issue Jun 30, 2015 · 1 comment
Closed

FlxTilemap.loadMap doesn't respect trailing whitespace in CSV files #1550

rrohrer opened this issue Jun 30, 2015 · 1 comment

Comments

@rrohrer
Copy link

rrohrer commented Jun 30, 2015

I'm calling loadmap as such:

foo.loadMap(Assets.getText("assets/foo.txt"), "assets/my_image.png", x, y, FlxTilemap.OFF);

with a foo.txt that looks like:

0,0,0,0,0
1,0,0,0,0
0,0,0,0,0
0,0,0,0,0
1,1,1,1,1
~this is a newline character~

having a newline character at the end of the file (to make it a valid text file), which is allowed by the CSV format causes this call to silently fail.

On OSX under the neko and native target I'm getting back:

trace(foo.widthInTiles); // this prints 0

Looking into how FlxTilemap is implemented if the last line is a newline, it fails the whole call (silently).

To fix this, you need to call loadMap as such:

foo.loadMap(StringTools.rtrim(Assets.getText("assets/foo.txt")), "assets/my_image.png", x, y, FlxTilemap.OFF);

It seems like it would make more sense to have that call to StringTools.rtrim in loadMap, or at the very least throw an exception saying that whitespace isn't allowed at the end of the CSVs.

@Gama11 Gama11 added the Bug label Jun 30, 2015
@Gama11
Copy link
Member

Gama11 commented Jun 30, 2015

This works fine on the dev branch, CSV parsing in general is a bit more robust there as there have been some fixes. I might release a 3.3.9 patch soon though, might as well include a fix for this.

A unit test for this would also be nice.

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