This property can be deleted:
And so can these two methods:
|
beginEditing: function() { |
|
this.oldData = ig.copy(this.data); |
|
}, |
|
|
|
getOldTile: function( x, y ) { |
|
var tx = Math.floor( x / this.tilesize ); |
|
var ty = Math.floor( y / this.tilesize ); |
|
if( |
|
(tx >= 0 && tx < this.width) && |
|
(ty >= 0 && ty < this.height) |
|
) { |
|
return this.oldData[ty][tx]; |
|
} |
|
else { |
|
return 0; |
|
} |
|
}, |
And then patch weltmeister.js as follows:
diff --git a/lib/weltmeister/weltmeister.js b/lib/weltmeister/weltmeister.js
index 8c9bae9..7fd9d1c 100644
--- a/lib/weltmeister/weltmeister.js
+++ b/lib/weltmeister/weltmeister.js
@@ -717,14 +717,6 @@ wm.Weltmeister = ig.Class.extend({
}
else {
this.undo.beginMapDraw();
- this.activeLayer.beginEditing();
- if(
- this.activeLayer.linkWithCollision &&
- this.collisionLayer &&
- this.collisionLayer != this.activeLayer
- ) {
- this.collisionLayer.beginEditing();
- }
this.setTileOnCurrentLayer();
}
}
@@ -831,10 +823,12 @@ wm.Weltmeister = ig.Class.extend({
var mapy = y + by * this.activeLayer.tilesize;
var newTile = brushRow[bx];
- var oldTile = this.activeLayer.getOldTile( mapx, mapy );
-
- this.activeLayer.setTile( mapx, mapy, newTile );
- this.undo.pushMapDraw( this.activeLayer, mapx, mapy, oldTile, newTile );
+ var oldTile = this.activeLayer.getTile( mapx, mapy );
+
+ if( newTile !== oldTile ) {
+ this.activeLayer.setTile( mapx, mapy, newTile );
+ this.undo.pushMapDraw( this.activeLayer, mapx, mapy, oldTile, newTile );
+ }
if(
@@ -845,8 +839,10 @@ wm.Weltmeister = ig.Class.extend({
var collisionLayerTile = newTile > 0 ? this.collisionSolid : 0;
var oldCollisionTile = this.collisionLayer.getOldTile(mapx, mapy);
- this.collisionLayer.setTile( mapx, mapy, collisionLayerTile );
- this.undo.pushMapDraw( this.collisionLayer, mapx, mapy, oldCollisionTile, collisionLayerTile );
+ if( collisionLayerTile !== oldCollisionTile ) {
+ this.collisionLayer.setTile( mapx, mapy, collisionLayerTile );
+ this.undo.pushMapDraw( this.collisionLayer, mapx, mapy, oldCollisionTile, collisionLayerTile );
+ }
}
}
}
There is no need to keep a reference to oldData because the old data already gets passed into the undo and redo objects. Additionally, there is no need to make 10's of undo objects per single tile edit, which currently happens. The added if( newTile !== oldTile ) check ensures we only have one undo object per edit, which is necessary before we can delete the oldData array.
This property can be deleted:
Impact/lib/weltmeister/edit-map.js
Line 18 in 98037a5
And so can these two methods:
Impact/lib/weltmeister/edit-map.js
Lines 81 to 97 in 98037a5
And then patch weltmeister.js as follows:
There is no need to keep a reference to
oldDatabecause the old data already gets passed into theundoandredoobjects. Additionally, there is no need to make 10's ofundoobjects per single tile edit, which currently happens. The addedif( newTile !== oldTile )check ensures we only have oneundoobject per edit, which is necessary before we can delete theoldDataarray.