diff --git a/binaries/data/mods/public/gui/session_new/selection.js b/binaries/data/mods/public/gui/session_new/selection.js index 9036d12cbb..c494947d58 100644 --- a/binaries/data/mods/public/gui/session_new/selection.js +++ b/binaries/data/mods/public/gui/session_new/selection.js @@ -17,8 +17,10 @@ function _setMotionOverlay(ents, enabled) function EntitySelection() { // Private properties: - this.selected = {}; // { id: 1, id: 1, ... } for each selected entity ID 'id' - this.highlighted = {}; // { id: 1, ... } for mouseover-highlighted entity IDs + this.selected = {}; // { id:id, id:id, ... } for each selected entity ID 'id' + this.highlighted = {}; // { id:id, ... } for mouseover-highlighted entity IDs + // (in these, the key is a string and the value is an int; we want to use the + // int form wherever possible since it's more efficient to send to the simulation code) this.motionDebugOverlay = false; // Public properties: @@ -37,7 +39,7 @@ EntitySelection.prototype.toggle = function(ent) { _setHighlight([ent], g_ActiveSelectionColour); _setMotionOverlay([ent], this.motionDebugOverlay); - this.selected[ent] = 1; + this.selected[ent] = ent; } this.dirty = true; }; @@ -50,7 +52,7 @@ EntitySelection.prototype.addList = function(ents) if (!this.selected[ent]) { added.push(ent); - this.selected[ent] = 1; + this.selected[ent] = ent; } } _setHighlight(added, g_ActiveSelectionColour); @@ -69,8 +71,8 @@ EntitySelection.prototype.reset = function() EntitySelection.prototype.toList = function() { var ents = []; - for (var ent in this.selected) - ents.push(+ent); // convert from string to number and push + for each (var ent in this.selected) + ents.push(ent); return ents; }; @@ -80,7 +82,7 @@ EntitySelection.prototype.setHighlightList = function(ents) var added = []; // Remove highlighting for the old units (excluding ones that are actively selected too) - for (var ent in this.highlighted) + for each (var ent in this.highlighted) if (!this.selected[ent]) removed.push(ent); @@ -98,7 +100,7 @@ EntitySelection.prototype.setHighlightList = function(ents) // Store the new list this.highlighted = {}; for each (var ent in ents) - this.highlighted[ent] = 1; + this.highlighted[ent] = ent; }; EntitySelection.prototype.SetMotionDebugOverlay = function(enabled) diff --git a/binaries/data/mods/public/simulation/components/Health.js b/binaries/data/mods/public/simulation/components/Health.js index 4c034883cf..4a6d919491 100644 --- a/binaries/data/mods/public/simulation/components/Health.js +++ b/binaries/data/mods/public/simulation/components/Health.js @@ -116,7 +116,7 @@ Health.prototype.CreateCorpse = function() // Make it fall over var cmpCorpseVisual = Engine.QueryInterface(corpse, IID_Visual); - cmpCorpseVisual.SelectAnimation("death", true); + cmpCorpseVisual.SelectAnimation("death", true, 1.0, ""); }; diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 990c70344d..2ecb698933 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -311,7 +311,7 @@ UnitAI.prototype.SelectAnimation = function(name, once, speed, sound) if (!cmpVisual) return; - var soundgroup = ""; + var soundgroup; if (sound) { var cmpSound = Engine.QueryInterface(this.entity, IID_Sound); @@ -319,6 +319,14 @@ UnitAI.prototype.SelectAnimation = function(name, once, speed, sound) soundgroup = cmpSound.GetSoundGroup(sound); } + // Set default values if unspecified + if (typeof once == "undefined") + once = false; + if (typeof speed == "undefined") + speed = 1.0; + if (typeof soundgroup == "undefined") + soundgroup = ""; + cmpVisual.SelectAnimation(name, once, speed, soundgroup); }; diff --git a/source/ps/CLogger.cpp b/source/ps/CLogger.cpp index 742062dfbc..a1f109a1cc 100644 --- a/source/ps/CLogger.cpp +++ b/source/ps/CLogger.cpp @@ -145,6 +145,8 @@ void CLogger::WriteError(const wchar_t* message) void CLogger::WriteWarning(const wchar_t* message) { ++m_NumberOfWarnings; + if (m_UseDebugPrintf) + debug_printf(L"WARNING: %ls\n", message); if (g_Console) g_Console->InsertMessage(L"WARNING: %ls", message); *m_InterestingLog << L"
WARNING: "<< message << L"
\n"; diff --git a/source/scriptinterface/ScriptConversions.cpp b/source/scriptinterface/ScriptConversions.cpp index d99891a289..6bc3706517 100644 --- a/source/scriptinterface/ScriptConversions.cpp +++ b/source/scriptinterface/ScriptConversions.cpp @@ -20,14 +20,19 @@ #include "ScriptInterface.h" #include "ps/utf16string.h" +#include "ps/CLogger.h" #include "js/jsapi.h" -#define FAIL(msg) do { JS_ReportError(cx, msg); return false; } while (false) +#define FAIL(msg) STMT(JS_ReportError(cx, msg); return false) + +// Implicit type conversions often hide bugs, so warn about them +#define WARN_IF_NOT(c) STMT(if (!(c)) { JS_ReportWarning(cx, "Script value conversion check failed: %s", #c); }) template<> bool ScriptInterface::FromJSVal