diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 42d6c41bc6..5878ea1c89 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -153,7 +153,7 @@ function updateBuildingPlacementPreview() if (placementSupport.wallSet && placementSupport.position) { // Fetch an updated list of snapping candidate entities - placementSupport.wallSnapEntities = Engine.PickSimilarFriendlyEntities( + placementSupport.wallSnapEntities = Engine.PickSimilarPlayerEntities( placementSupport.wallSet.templates.tower, placementSupport.wallSnapEntitiesIncludeOffscreen, true, // require exact template match @@ -535,7 +535,7 @@ function handleInputBeforeGui(ev, hoveredObject) case "mousemotion": var rect = updateBandbox(bandbox, ev, false); - var ents = Engine.PickFriendlyEntitiesInRect(rect[0], rect[1], rect[2], rect[3], Engine.GetPlayerID()); + var ents = Engine.PickPlayerEntitiesInRect(rect[0], rect[1], rect[2], rect[3], Engine.GetPlayerID()); var preferredEntities = getPreferredEntities(ents); g_Selection.setHighlightList(preferredEntities); @@ -547,7 +547,7 @@ function handleInputBeforeGui(ev, hoveredObject) var rect = updateBandbox(bandbox, ev, true); // Get list of entities limited to preferred entities - var ents = getPreferredEntities(Engine.PickFriendlyEntitiesInRect(rect[0], rect[1], rect[2], rect[3], Engine.GetPlayerID())); + var ents = getPreferredEntities(Engine.PickPlayerEntitiesInRect(rect[0], rect[1], rect[2], rect[3], Engine.GetPlayerID())); // Remove the bandbox hover highlighting g_Selection.setHighlightList([]); @@ -1029,7 +1029,7 @@ function handleInputAfterGui(ev) } // TODO: Should we handle "control all units" here as well? - ents = Engine.PickSimilarFriendlyEntities(templateToMatch, showOffscreen, matchRank, false); + ents = Engine.PickSimilarPlayerEntities(templateToMatch, showOffscreen, matchRank, false); } else { diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index d60aa548f4..881e971076 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -837,7 +837,7 @@ function recalculateStatusBarDisplay() { let entities; if (g_ShowAllStatusBars) - entities = Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID()); + entities = Engine.PickPlayerEntitiesOnScreen(Engine.GetPlayerID()); else { let selected = g_Selection.toList(); diff --git a/source/gui/scripting/ScriptFunctions.cpp b/source/gui/scripting/ScriptFunctions.cpp index 956bf31a30..80d1ccf342 100644 --- a/source/gui/scripting/ScriptFunctions.cpp +++ b/source/gui/scripting/ScriptFunctions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2016 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -154,17 +154,17 @@ entity_id_t PickEntityAtPoint(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), in return EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x, y, g_Game->GetPlayerID(), false); } -std::vector PickFriendlyEntitiesInRect(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int x0, int y0, int x1, int y1, int player) +std::vector PickPlayerEntitiesInRect(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int x0, int y0, int x1, int y1, int player) { return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x0, y0, x1, y1, player, false); } -std::vector PickFriendlyEntitiesOnScreen(ScriptInterface::CxPrivate* pCxPrivate, int player) +std::vector PickPlayerEntitiesOnScreen(ScriptInterface::CxPrivate* pCxPrivate, int player) { - return PickFriendlyEntitiesInRect(pCxPrivate, 0, 0, g_xres, g_yres, player); + return PickPlayerEntitiesInRect(pCxPrivate, 0, 0, g_xres, g_yres, player); } -std::vector PickSimilarFriendlyEntities(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::string templateName, bool includeOffScreen, bool matchRank, bool allowFoundations) +std::vector PickSimilarPlayerEntities(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::string templateName, bool includeOffScreen, bool matchRank, bool allowFoundations) { return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, g_Game->GetPlayerID(), includeOffScreen, matchRank, false, allowFoundations); } @@ -965,9 +965,9 @@ void GuiScriptingInit(ScriptInterface& scriptInterface) // Entity picking scriptInterface.RegisterFunction("PickEntityAtPoint"); - scriptInterface.RegisterFunction, int, int, int, int, int, &PickFriendlyEntitiesInRect>("PickFriendlyEntitiesInRect"); - scriptInterface.RegisterFunction, int, &PickFriendlyEntitiesOnScreen>("PickFriendlyEntitiesOnScreen"); - scriptInterface.RegisterFunction, std::string, bool, bool, bool, &PickSimilarFriendlyEntities>("PickSimilarFriendlyEntities"); + scriptInterface.RegisterFunction, int, int, int, int, int, &PickPlayerEntitiesInRect>("PickPlayerEntitiesInRect"); + scriptInterface.RegisterFunction, int, &PickPlayerEntitiesOnScreen>("PickPlayerEntitiesOnScreen"); + scriptInterface.RegisterFunction, std::string, bool, bool, bool, &PickSimilarPlayerEntities>("PickSimilarPlayerEntities"); scriptInterface.RegisterFunction("GetTerrainAtScreenPoint"); // Network / game setup functions diff --git a/source/simulation2/components/ICmpRangeManager.h b/source/simulation2/components/ICmpRangeManager.h index b728226ea1..35e063282c 100644 --- a/source/simulation2/components/ICmpRangeManager.h +++ b/source/simulation2/components/ICmpRangeManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2016 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -185,7 +185,7 @@ public: virtual std::vector ResetActiveQuery(tag_t tag) = 0; /** - * Returns list of all entities for specific player. + * Returns a list of all entities for a specific player. * (This is on this interface because it shares a lot of the implementation. * Maybe it should be extended to be more like ExecuteQuery without * the range parameter.) diff --git a/source/simulation2/helpers/Selection.cpp b/source/simulation2/helpers/Selection.cpp index 856d9eed1e..69e83894ba 100644 --- a/source/simulation2/helpers/Selection.cpp +++ b/source/simulation2/helpers/Selection.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2016 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -88,7 +88,8 @@ entity_id_t EntitySelection::PickEntityAtPoint(CSimulation2& simulation, const C } /** - * Used by EntitySelection::PickEntitiesInRect. + * Returns true if the given entity is visible to the given player and visible in the given screen area. + * If the entity is a decorative, the function will only return true if allowEditorSelectables. */ static bool CheckEntityVisibleAndInRect(CEntityHandle handle, CmpPtr cmpRangeManager, const CCamera& camera, int sx0, int sy0, int sx1, int sy1, player_id_t owner, bool allowEditorSelectables) {