From d174999cf959df5b6a20489a90667cd4a6902015 Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Wed, 14 Jun 2017 11:45:48 +0200 Subject: [PATCH] temp fix for saving too many --- src/game-lib-a-component-a.js | 7 +++---- src/game-lib-d3-image.js | 6 +++++- src/game-lib-d3-material.js | 8 +++++++- src/game-lib-d3-mesh-0.js | 8 +++++++- src/game-lib-d3-texture.js | 10 ++++++++-- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index ff9fca3..ec69a3d 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -28,7 +28,7 @@ GameLib.Component = function( this.built = false; - this.saved = false; + this.canSave = true; this.loaded = false; @@ -277,11 +277,11 @@ GameLib.Component.prototype.clone = function() { GameLib.Component.prototype.save = function() { - if (this.saved) { + if (!this.canSave) { return; } - this.saved = true; + this.canSave = false; var apiObject = this.toApiObject(true); @@ -294,5 +294,4 @@ GameLib.Component.prototype.save = function() { apiObject ); - this.saved = false; }; \ No newline at end of file diff --git a/src/game-lib-d3-image.js b/src/game-lib-d3-image.js index b40f394..b3ad4f8 100644 --- a/src/game-lib-d3-image.js +++ b/src/game-lib-d3-image.js @@ -155,7 +155,11 @@ GameLib.D3.Image.prototype.updateInstance = function() { * * @returns {GameLib.D3.API.Image} */ -GameLib.D3.Image.prototype.toApiObject = function() { +GameLib.D3.Image.prototype.toApiObject = function(save) { + + if (GameLib.Utils.UndefinedOrNull(save)) { + save = false; + } var apiImage = new GameLib.D3.API.Image( this.id, diff --git a/src/game-lib-d3-material.js b/src/game-lib-d3-material.js index 7bdfec2..febdf9d 100644 --- a/src/game-lib-d3-material.js +++ b/src/game-lib-d3-material.js @@ -917,6 +917,10 @@ GameLib.D3.Material.prototype.updateInstance = function() { */ GameLib.D3.Material.prototype.toApiObject = function(save) { + if (GameLib.Utils.UndefinedOrNull(save)) { + save = false; + } + var apiAlphaMap = null; if (this.alphaMap) { if (save) { @@ -1011,7 +1015,7 @@ GameLib.D3.Material.prototype.toApiObject = function(save) { apiSpecularMap = this.specularMap.id; } - return new GameLib.D3.API.Material( + var apiMaterial = new GameLib.D3.API.Material( this.id, this.materialType, this.name, @@ -1082,6 +1086,8 @@ GameLib.D3.Material.prototype.toApiObject = function(save) { apiSpecularMap, GameLib.Utils.IdOrNull(this.parentEntity) ); + + return apiMaterial; }; /** diff --git a/src/game-lib-d3-mesh-0.js b/src/game-lib-d3-mesh-0.js index 99a9233..94eee0f 100644 --- a/src/game-lib-d3-mesh-0.js +++ b/src/game-lib-d3-mesh-0.js @@ -474,6 +474,10 @@ GameLib.D3.Mesh.prototype.updateInstance = function() { */ GameLib.D3.Mesh.prototype.toApiObject = function(save) { + if (GameLib.Utils.UndefinedOrNull(save)) { + save = false; + } + var apiSkeleton = null; if (this.skeleton) { if (save) { @@ -494,7 +498,7 @@ GameLib.D3.Mesh.prototype.toApiObject = function(save) { ) } - return new GameLib.D3.API.Mesh( + var apiMesh = new GameLib.D3.API.Mesh( this.id, this.meshType, this.name, @@ -522,6 +526,8 @@ GameLib.D3.Mesh.prototype.toApiObject = function(save) { GameLib.Utils.IdOrNull(this.parentEntity), this.renderOrder ); + + return apiMesh; }; /** diff --git a/src/game-lib-d3-texture.js b/src/game-lib-d3-texture.js index 13beac7..da62732 100644 --- a/src/game-lib-d3-texture.js +++ b/src/game-lib-d3-texture.js @@ -344,6 +344,10 @@ GameLib.D3.Texture.prototype.updateInstance = function() { */ GameLib.D3.Texture.prototype.toApiObject = function(save) { + if (GameLib.Utils.UndefinedOrNull(save)) { + save = false; + } + var apiImage = null; if (this.image) { if (save) { @@ -352,7 +356,7 @@ GameLib.D3.Texture.prototype.toApiObject = function(save) { apiImage = this.image.id } - return new GameLib.D3.API.Texture( + var apiTexture = new GameLib.D3.API.Texture( this.id, this.typeId, this.name, @@ -375,7 +379,9 @@ GameLib.D3.Texture.prototype.toApiObject = function(save) { this.premultiplyAlpha, this.encoding, GameLib.Utils.IdOrNull(this.parentEntity) - ) + ); + + return apiTexture; };