Index: binaries/data/mods/public/simulation/components/BuildRestrictions.js
===================================================================
--- binaries/data/mods/public/simulation/components/BuildRestrictions.js
+++ binaries/data/mods/public/simulation/components/BuildRestrictions.js
@@ -133,16 +133,7 @@
if (!cmpObstruction)
return result; // Fail
-
- if (this.template.Category == "Wall")
- {
- // for walls, only test the center point
- var ret = cmpObstruction.CheckFoundation(passClassName, true);
- }
- else
- {
- var ret = cmpObstruction.CheckFoundation(passClassName, false);
- }
+ var ret = cmpObstruction.CheckFoundation(passClassName);
if (ret != "success")
{
Index: binaries/data/mods/public/simulation/templates/other/bridge_hele.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/other/bridge_hele.xml
+++ binaries/data/mods/public/simulation/templates/other/bridge_hele.xml
@@ -19,6 +19,7 @@
+
Index: binaries/data/mods/public/simulation/templates/other/bridge_wooden.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/other/bridge_wooden.xml
+++ binaries/data/mods/public/simulation/templates/other/bridge_wooden.xml
@@ -19,6 +19,7 @@
+
Index: binaries/data/mods/public/simulation/templates/other/palisades_rocks_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/other/palisades_rocks_tower.xml
+++ binaries/data/mods/public/simulation/templates/other/palisades_rocks_tower.xml
@@ -33,7 +33,7 @@
0
-
+
Index: binaries/data/mods/public/simulation/templates/template_structure.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure.xml
+++ binaries/data/mods/public/simulation/templates/template_structure.xml
@@ -71,6 +71,7 @@
structure
+
true
true
true
Index: binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml
+++ binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml
@@ -33,7 +33,7 @@
15
-
+
Index: binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml
+++ binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml
@@ -62,7 +62,7 @@
15
-
+
Index: source/ps/Hotkey.cpp
===================================================================
--- source/ps/Hotkey.cpp
+++ source/ps/Hotkey.cpp
@@ -79,8 +79,12 @@
mapping = SDL_GetKeyFromName(it->c_str());
if (!mapping)
{
- LOGWARNING("Hotkey mapping used invalid key '%s'", hotkey.c_str());
- continue;
+ mapping = SDL_GetKeyFromName(it->c_str());
+ if (!mapping)
+ {
+ LOGWARNING("Hotkey mapping used invalid key '%s'", hotkey.c_str());
+ continue;
+ }
}
SKey key = { (SDL_Keycode)mapping, false };
Index: source/simulation2/components/CCmpObstruction.cpp
===================================================================
--- source/simulation2/components/CCmpObstruction.cpp
+++ source/simulation2/components/CCmpObstruction.cpp
@@ -119,6 +119,11 @@
"1.5"
""
""
+ ""
+ ""
+ ""
+ ""
+ ""
""
""
""
@@ -213,6 +218,7 @@
m_Type = STATIC;
m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed();
m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed();
+ m_Clearance = paramNode.GetChild("Static").GetChild("@clearance").ToFixed();
ENSURE(m_Size0 > minObstruction);
ENSURE(m_Size1 > minObstruction);
}
@@ -241,6 +247,9 @@
}
m_Size0 = fixed::FromInt(2).Multiply(std::max(max.X, -min.X));
m_Size1 = fixed::FromInt(2).Multiply(std::max(max.Y, -min.Y));
+
+ // TODO perhaps support clearance per obstruction
+ m_Clearance = entity_pos_t::Zero();
}
m_Active = paramNode.GetChild("Active").ToBool();
@@ -557,9 +566,9 @@
ICmpObstructionManager::FLAG_BLOCK_FOUNDATION);
if (m_Type == UNIT)
- return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass, onlyCenterPoint);
+ return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass);
else
- return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint);
+ return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, m_Clearance * 2);
}
virtual bool CheckDuplicateFoundation() const
Index: source/simulation2/components/CCmpPathfinder.cpp
===================================================================
--- source/simulation2/components/CCmpPathfinder.cpp
+++ source/simulation2/components/CCmpPathfinder.cpp
@@ -802,7 +802,7 @@
}
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter,
- entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const
+ entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass) const
{
// Check unit obstruction
CmpPtr cmpObstructionManager(GetSystemEntity());
@@ -830,20 +830,20 @@
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w,
entity_pos_t h, entity_id_t id, pass_class_t passClass) const
{
- return CCmpPathfinder::CheckBuildingPlacement(filter, x, z, a, w, h, id, passClass, false);
+ return CCmpPathfinder::CheckBuildingPlacement(filter, x, z, a, w, h, id, passClass, entity_pos_t::Zero());
}
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement(const IObstructionTestFilter& filter,
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w,
- entity_pos_t h, entity_id_t id, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const
+ entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance) const
{
// Check unit obstruction
CmpPtr cmpObstructionManager(GetSystemEntity());
if (!cmpObstructionManager)
return ICmpObstruction::FOUNDATION_CHECK_FAIL_ERROR;
- if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w, h, NULL))
+ if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w + clearance, h + clearance, NULL))
return ICmpObstruction::FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION;
// Test against terrain:
Index: source/simulation2/components/CCmpPathfinder_Common.h
===================================================================
--- source/simulation2/components/CCmpPathfinder_Common.h
+++ source/simulation2/components/CCmpPathfinder_Common.h
@@ -281,11 +281,11 @@
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) const;
- virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint) const;
+ virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass) const;
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) const;
- virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const;
+ virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance) const;
virtual void FinishAsyncRequests();
Index: source/simulation2/components/ICmpObstruction.h
===================================================================
--- source/simulation2/components/ICmpObstruction.h
+++ source/simulation2/components/ICmpObstruction.h
@@ -68,13 +68,12 @@
* value describing the type of failure.
*/
virtual EFoundationCheck CheckFoundation(const std::string& className) const = 0;
- virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const = 0;
/**
* CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck.
* @return "success" if check passes, else a string describing the type of failure.
*/
- virtual std::string CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const;
+ virtual std::string CheckFoundation_wrapper(const std::string& className) const;
/**
* Test whether this entity is colliding with any obstructions that share its
Index: source/simulation2/components/ICmpObstruction.cpp
===================================================================
--- source/simulation2/components/ICmpObstruction.cpp
+++ source/simulation2/components/ICmpObstruction.cpp
@@ -23,9 +23,9 @@
#include "simulation2/system/SimContext.h"
-std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const
+std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className) const
{
- EFoundationCheck check = CheckFoundation(className, onlyCenterPoint);
+ EFoundationCheck check = CheckFoundation(className);
switch (check)
{
@@ -47,7 +47,7 @@
BEGIN_INTERFACE_WRAPPER(Obstruction)
DEFINE_INTERFACE_METHOD_CONST_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius)
-DEFINE_INTERFACE_METHOD_CONST_2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool)
+DEFINE_INTERFACE_METHOD_CONST_1("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string)
DEFINE_INTERFACE_METHOD_CONST_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation)
DEFINE_INTERFACE_METHOD_CONST_0("GetUnitCollisions", std::vector, ICmpObstruction, GetUnitCollisions)
DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool)
Index: source/simulation2/components/ICmpPathfinder.h
===================================================================
--- source/simulation2/components/ICmpPathfinder.h
+++ source/simulation2/components/ICmpPathfinder.h
@@ -134,11 +134,10 @@
/**
* Check whether a unit placed here is valid and doesn't hit any obstructions
* or impassable terrain.
- * When onlyCenterPoint = true, only check the center tile of the unit
* @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else
* a value describing the type of failure.
*/
- virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint = false) const = 0;
+ virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass) const = 0;
/**
* Check whether a building placed here is valid and doesn't hit any obstructions
@@ -151,11 +150,10 @@
/**
* Check whether a building placed here is valid and doesn't hit any obstructions
* or impassable terrain.
- * when onlyCenterPoint = true, only check the center tile of the building
* @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else
* a value describing the type of failure.
*/
- virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const = 0;
+ virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance) const = 0;
/**