Rpg_Core : Tilemap code bug

Hi people,


I was converting the tilemap class to typescript and I noticed....that the Original JS code (V.1.2) 


they actually have a syntax errors.


let's me show the error :

Spoiler
Y5S9Bsd.png



IOEmfHx.png



So this line is a actual bug as you can see via my editor.


getAutotileKind(tileId) % 16 >= 8;


so in BOTH JS and typescript way this code wouldn't just not work at all.


thanks for further answer


EDIT : No I didn't edit the JS file.


EDIT : 


way of fixing is simply by changing this line : 


Tilemap.isWallSideTile = function(tileId) {
return (this.isTileA3(tileId) || this.isTileA4(tileId)) &&
getAutotileKind(tileId) % 16 >= 8;
};


to this : 

Code:
Tilemap.isWallSideTile = function(tileId) {
    return (this.isTileA3(tileId) || this.isTileA4(tileId)) &&
            this.getAutotileKind(tileId) % 16 >= 8;
};
I'm more interested in where this particular method would be called.


It may even be unused.
I'm more interested in where this particular method would be called.


It may even be unused.

it's a public static method who would probably used in Game_Map for know if the tile is actually a sideWall.


I guess it's could be useful when collision occur with events.


Most Tilemap Static methods are boolean value for return if tiles is a Either water tiles etc 


it's change their behavior on own they are build.
Yeah, it's used in Tilemap.  I just went through all of this when writing my plugin.  It's used when determining what pattern to draw from the autotile.
Yeah, it's used in Tilemap.  I just went through all of this when writing my plugin.  It's used when determining what pattern to draw from the autotile.

yeah now I just wonder HOW it's not threw a bug when it's have a syntax error lol
this. could be implied?  I don't know JS well enough to know that.


There ARE some functions there that don't get called by anything, but I'm pretty sure that one does - unless there are two with very similar names and it's the other one that's called.
I'm fairly certain that instance variables do not need the "this" qualifier because in an object it's kind of implied that we have access to "this" and all its variables. 


As a comparison, technically every global variable is stored on the window object, but we don't need to explicitly say "window." on everything, that'd be tedious. 


In other languages, such as C++,  "this" is not required, it can be used for proper scoping or for clarification. 
I'm fairly certain that instance variables do not need the "this" qualifier because in an object it's kind of implied that we have access to "this" and all its variables. 


As a comparison, technically every global variable is stored on the window object, but we don't need to explicitly say "window." on everything, that'd be tedious. 


In other languages, such as C++,  "this" is not required, it can be used for proper scoping or for clarification. 



I can ensure this is needed Javascript is not like C like language 


here it's used in the scope of the static 


so "this" or "Tilemap" is required for get the proper scope. this not a global scoped instance so yes it's a bug


even my editor throw me a error.
I'm fairly certain that instance variables do not need the "this" qualifier because in an object it's kind of implied that we have access to "this" and all its variables. 


As a comparison, technically every global variable is stored on the window object, but we don't need to explicitly say "window." on everything, that'd be tedious. 


In other languages, such as C++,  "this" is not required, it can be used for proper scoping or for clarification. 



It would be tedious. That's why if "this" is not specified, javascript would assume you're trying to access the function defined on window, and NOT some local method defined in "this" object, whether it's a static method or not.


JS scoping causes a lot of headaches for the most part.


My issue with this particular method is I haven't been able to actually call it.


A bunch of methods call it it, but I can't find a situation to throw the error.

Code:
Tilemap.isWallSideTile = function(tileId) {
    return (this.isTileA3(tileId) || this.isTileA4(tileId)) &&
            getAutotileKind(tileId) % 16 >= 8;
};

Tilemap.isWallTile = function(tileId) {
    return this.isWallTopTile(tileId) || this.isWallSideTile(tileId);
};

Tilemap.isFloorTypeAutotile = function(tileId) {
    return (this.isTileA1(tileId) && !this.isWaterfallTile(tileId)) ||
            this.isTileA2(tileId) || this.isWallTopTile(tileId);
};

Tilemap.isWallTypeAutotile = function(tileId) {
    return this.isRoofTile(tileId) || this.isWallSideTile(tileId);
};
It would be tedious. That's why if "this" is not specified, javascript would assume you're trying to access the function defined on window, and NOT some local method defined in "this" object, whether it's a static method or not.


JS scoping causes a lot of headaches for the most part.


My issue with this particular method is I haven't been able to actually call it.


A bunch of methods call it it, but I can't find a situation to throw the error.



Tilemap.isWallSideTile = function(tileId) {
return (this.isTileA3(tileId) || this.isTileA4(tileId)) &&
getAutotileKind(tileId) % 16 >= 8;
};

Tilemap.isWallTile = function(tileId) {
return this.isWallTopTile(tileId) || this.isWallSideTile(tileId);
};

Tilemap.isFloorTypeAutotile = function(tileId) {
return (this.isTileA1(tileId) && !this.isWaterfallTile(tileId)) ||
this.isTileA2(tileId) || this.isWallTopTile(tileId);
};

Tilemap.isWallTypeAutotile = function(tileId) {
return this.isRoofTile(tileId) || this.isWallSideTile(tileId);
};

eh me neither honestly but this got fixed in 1.3
Be very careful about your use of this in JavaScript.


It meaning differs based on context and is rather confusingly defined.


Worse, it behaves differently in some situations depending on whether you are running in strict mode or non-strict mode.


Reading through the definition I get the feeling that the this keyword is just waiting to screw you over.


*hugs*


 - Zeriab

Original thread: https://forums.rpgmakerweb.com/threads/rpg_core-tilemap-code-bug.66592/