[colobot] 33/100: Allow selectinsect to select other objects with selectable=0
Didier Raboud
odyx at moszumanska.debian.org
Thu Jun 1 18:10:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 6a382830a95a36a2e643193729433ddba266c420
Author: krzys-h <krzys_h at interia.pl>
Date: Tue Dec 27 22:20:58 2016 +0100
Allow selectinsect to select other objects with selectable=0
---
src/level/robotmain.cpp | 38 +++++++++-----------------------------
src/level/robotmain.h | 3 ---
src/ui/controls/target.cpp | 2 +-
3 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
index 0918d33..aa8ae91 100644
--- a/src/level/robotmain.cpp
+++ b/src/level/robotmain.cpp
@@ -1851,7 +1851,8 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
if (m_movieLock || m_editLock) return false;
if (m_movie->IsExist()) return false;
- if (obj != nullptr && !IsSelectable(obj)) return false;
+ if (obj != nullptr &&
+ (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_selectInsect))) return false;
if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted && m_codeBattleSpectator)
{
@@ -1944,7 +1945,7 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
for (CObject* obj : m_objMan->GetAllObjects())
{
if (obj == exclu) continue;
- if (!IsSelectable(obj)) continue;
+ if (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_selectInsect)) continue;
ObjectType type = obj->GetType();
if (type == OBJECT_TOTO) continue;
@@ -2019,30 +2020,6 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
return nullptr;
}
-//! Indicates whether an object is selectable
-// TODO: Refactor this, calling CControllableObject::GetSelectable should always be enough
-bool CRobotMain::IsSelectable(CObject* obj)
-{
- if (obj->GetType() == OBJECT_TOTO) return true;
- if (!obj->Implements(ObjectInterfaceType::Controllable)) return false;
-
- if (!m_selectInsect)
- {
- // TODO: Some function in CControllableObject
- if ( obj->GetType() == OBJECT_MOTHER ||
- obj->GetType() == OBJECT_ANT ||
- obj->GetType() == OBJECT_SPIDER ||
- obj->GetType() == OBJECT_BEE ||
- obj->GetType() == OBJECT_WORM ||
- obj->GetType() == OBJECT_MOBILEtg )
- {
- return false;
- }
- }
-
- return dynamic_cast<CControllableObject*>(obj)->GetSelectable();
-}
-
//! Deletes the selected object
bool CRobotMain::DestroySelectedObject()
@@ -2136,10 +2113,13 @@ void CRobotMain::HiliteObject(Math::Point pos)
}
}
- if (IsSelectable(obj))
+ if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_selectInsect))
{
- assert(obj->Implements(ObjectInterfaceType::Controllable));
- dynamic_cast<CControllableObject*>(obj)->SetHighlight(true);
+ if (dynamic_cast<CControllableObject*>(obj)->GetSelectable())
+ {
+ // Don't highlight objects that would not be selectable without selectinsect
+ dynamic_cast<CControllableObject*>(obj)->SetHighlight(true);
+ }
m_map->SetHighlight(obj);
m_short->SetHighlight(obj);
m_hilite = true;
diff --git a/src/level/robotmain.h b/src/level/robotmain.h
index 18649c0..54d15ab 100644
--- a/src/level/robotmain.h
+++ b/src/level/robotmain.h
@@ -364,10 +364,7 @@ public:
void StartDetectEffect(COldObject* object, CObject* target);
- bool IsSelectable(CObject* obj);
-
void SetDebugCrashSpheres(bool draw);
-
bool GetDebugCrashSpheres();
protected:
diff --git a/src/ui/controls/target.cpp b/src/ui/controls/target.cpp
index 9ba4f4e..c90c205 100644
--- a/src/ui/controls/target.cpp
+++ b/src/ui/controls/target.cpp
@@ -149,7 +149,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
if ( !target->GetDetectable() ) continue;
if ( target->GetProxyActivate() ) continue;
if ( target->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(target)->GetSelect() ) continue;
- if ( !m_main->IsSelectable(target) ) continue;
+ if ( target->Implements(ObjectInterfaceType::Controllable) && !dynamic_cast<CControllableObject*>(target)->GetSelectable() ) continue;
if (!target->Implements(ObjectInterfaceType::Old)) continue; // TODO: To be removed after COldObjectInterface is gone
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list