[colobot] 288/390: Issue #399 : Sniffer can delete mark and probe ground
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:21:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit bf55691e444ec6b6cda8ff7d69d418fd50befaa6
Author: Piotr Walkusz <piotrwalkusz1 at wp.pl>
Date: Sun Nov 16 23:10:01 2014 +0100
Issue #399 : Sniffer can delete mark and probe ground
---
data | 2 +-
src/CMakeLists.txt | 1 +
src/common/event.h | 3 +-
src/common/restext.cpp | 1 +
src/object/brain.cpp | 28 +++++++++-
src/object/brain.h | 1 +
src/object/task/taskdeletemark.cpp | 110 +++++++++++++++++++++++++++++++++++++
src/object/task/taskdeletemark.h | 45 +++++++++++++++
src/object/task/taskmanager.cpp | 10 ++++
src/object/task/taskmanager.h | 1 +
10 files changed, 199 insertions(+), 3 deletions(-)
diff --git a/data b/data
index b29aa97..1aa4009 160000
--- a/data
+++ b/data
@@ -1 +1 @@
-Subproject commit b29aa975122f8165f1683c5d143ed37b8c872ab4
+Subproject commit 1aa40099ac6898775f990884908bb840ae2f94d6
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9c1a0dd..6039266 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -147,6 +147,7 @@ set(BASE_SOURCES
object/task/task.cpp
object/task/taskadvance.cpp
object/task/taskbuild.cpp
+ object/task/taskdeletemark.cpp
object/task/taskfire.cpp
object/task/taskfireant.cpp
object/task/taskflag.cpp
diff --git a/src/common/event.h b/src/common/event.h
index 8c0ce52..0c5b2f5 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -160,7 +160,7 @@ enum EventType
EVENT_LIST0 = 110,
EVENT_LIST1 = 111,
- EVENT_LIST2 = 112,
+ EVENT_LIST2 = 112, // list of resolutions
EVENT_LIST3 = 113,
EVENT_LIST4 = 114,
EVENT_LIST5 = 115,
@@ -453,6 +453,7 @@ enum EventType
EVENT_OBJECT_RESET = 1233,
EVENT_OBJECT_DIMSHIELD = 1234,
EVENT_OBJECT_TARGET = 1235,
+ EVENT_OBJECT_DELSEARCH = 1236, // delete mark on ground
EVENT_OBJECT_PROGLIST = 1310,
EVENT_OBJECT_PROGRUN = 1311,
EVENT_OBJECT_PROGEDIT = 1312,
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index e52a26e..1802707 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -369,6 +369,7 @@ void InitializeRestext()
stringsEvent[EVENT_OBJECT_BEGSHIELD] = TR("Extend shield (\\key action;)");
stringsEvent[EVENT_OBJECT_ENDSHIELD] = TR("Withdraw shield (\\key action;)");
stringsEvent[EVENT_OBJECT_DIMSHIELD] = TR("Shield radius");
+ stringsEvent[EVENT_OBJECT_DELSEARCH] = TR("Delete mark");
stringsEvent[EVENT_OBJECT_PROGRUN] = TR("Execute the selected program");
stringsEvent[EVENT_OBJECT_PROGEDIT] = TR("Edit the selected program");
stringsEvent[EVENT_OBJECT_INFOOK] = TR("\\SatCom on standby");
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 2e0c2cd..d045a00 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -565,6 +565,11 @@ bool CBrain::EventProcess(const Event &event)
{
err = StartTaskSearch();
}
+
+ if ( action == EVENT_OBJECT_DELSEARCH )
+ {
+ err = StartTaskDeleteMark();
+ }
if ( action == EVENT_OBJECT_TERRAFORM )
{
@@ -980,6 +985,19 @@ Error CBrain::StartTaskSearch()
return err;
}
+// Delete mark on ground
+
+Error CBrain::StartTaskDeleteMark()
+{
+ StopTask();
+
+ m_primaryTask = new CTaskManager(m_object);
+ Error err = m_primaryTask->StartTaskDeleteMark();
+ UpdateInterface();
+ return err;
+}
+
+
// Terraformed the ground.
Error CBrain::StartTaskTerraform()
@@ -1163,7 +1181,6 @@ void CBrain::ColorFlag(int color)
UpdateInterface();
}
-
// Creates all the interface when the object is selected.
bool CBrain::CreateInterface(bool bSelect)
@@ -1474,6 +1491,14 @@ bool CBrain::CreateInterface(bool bSelect)
pos.y = oy+sy*0.5f;
pw->CreateButton(pos, dim, 40, EVENT_OBJECT_SEARCH);
DefaultEnter(pw, EVENT_OBJECT_SEARCH);
+
+ pos.x = ox+sx*9.0f;
+ pos.y = oy+sy*0.5f;
+ pw->CreateButton(pos, dim, 111, EVENT_OBJECT_GFLAT);
+
+ pos.x = ox+sx*10.1f;
+ pos.y = oy+sy*0.5f;
+ pw->CreateButton(pos, dim, 11, EVENT_OBJECT_DELSEARCH);
}
if ( type == OBJECT_MOBILErt && // Terraformer?
@@ -2118,6 +2143,7 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_FCREATE, bEnable);
EnableInterface(pw, EVENT_OBJECT_FDELETE, bEnable);
EnableInterface(pw, EVENT_OBJECT_SEARCH, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_DELSEARCH, bEnable);
EnableInterface(pw, EVENT_OBJECT_TERRAFORM, bEnable);
EnableInterface(pw, EVENT_OBJECT_RECOVER, bEnable);
EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable);
diff --git a/src/object/brain.h b/src/object/brain.h
index c117269..a67a1ef 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -132,6 +132,7 @@ public:
Error StartTaskFlag(TaskFlagOrder order, int rank);
Error StartTaskBuild(ObjectType type);
Error StartTaskSearch();
+ Error StartTaskDeleteMark();
Error StartTaskTerraform();
Error StartTaskPen(bool down, int color);
Error StartTaskRecover();
diff --git a/src/object/task/taskdeletemark.cpp b/src/object/task/taskdeletemark.cpp
new file mode 100644
index 0000000..733555f
--- /dev/null
+++ b/src/object/task/taskdeletemark.cpp
@@ -0,0 +1,110 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+
+#include "object/task/taskdeletemark.h"
+
+#include "common/iman.h"
+
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
+
+#include "math/geometry.h"
+
+#include "physics/physics.h"
+
+#include "object/robotmain.h"
+
+
+CTaskDeleteMark::CTaskDeleteMark(CObject* object) : CTask(object)
+{
+ m_bExecuted = false;
+}
+
+CTaskDeleteMark::~CTaskDeleteMark()
+{
+}
+
+
+// Management of an event.
+
+bool CTaskDeleteMark::EventProcess(const Event &event)
+{
+
+}
+
+Error CTaskDeleteMark::Start()
+{
+ DeleteMark();
+
+ m_bExecuted = true;
+
+ return ERR_OK;
+}
+
+// Indicates whether the action is finished.
+
+Error CTaskDeleteMark::IsEnded()
+{
+ if ( m_bExecuted )
+ return ERR_STOP;
+ else
+ return ERR_CONTINUE;
+}
+
+// Suddenly ends the current action.
+
+bool CTaskDeleteMark::Abort()
+{
+ return true;
+}
+
+void CTaskDeleteMark::DeleteMark()
+{
+ ObjectType type;
+ CObject* pObj;
+ Math::Vector oPos=m_object->GetPosition(0);
+ int i;
+
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ for ( i=0 ; i<1000000 ; i++ )
+ {
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
+ if ( pObj == 0 ) break;
+
+ type = pObj->GetType();
+
+ if ( type == OBJECT_MARKPOWER ||
+ type == OBJECT_MARKSTONE ||
+ type == OBJECT_MARKURANIUM ||
+ type == OBJECT_MARKKEYa ||
+ type == OBJECT_MARKKEYb ||
+ type == OBJECT_MARKKEYc ||
+ type == OBJECT_MARKKEYd )
+ {
+ if ( Math::Distance(oPos, pObj->GetPosition(0)) < 8.0f )
+ {
+ pObj->DeleteObject(); // removes the mark
+ delete pObj;
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/object/task/taskdeletemark.h b/src/object/task/taskdeletemark.h
new file mode 100644
index 0000000..5b504a5
--- /dev/null
+++ b/src/object/task/taskdeletemark.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// tasksearch.h
+
+#pragma once
+
+
+#include "object/task/task.h"
+#include "object/object.h"
+
+
+class CTaskDeleteMark : public CTask
+{
+public:
+ CTaskDeleteMark(CObject* object);
+ ~CTaskDeleteMark();
+
+ bool EventProcess(const Event &event);
+
+ Error Start();
+ Error IsEnded();
+ bool Abort();
+
+protected:
+ void DeleteMark();
+protected:
+ bool m_bExecuted;
+};
\ No newline at end of file
diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp
index 5270925..c8f843d 100644
--- a/src/object/task/taskmanager.cpp
+++ b/src/object/task/taskmanager.cpp
@@ -30,6 +30,7 @@
#include "object/task/tasktake.h"
#include "object/task/taskbuild.h"
#include "object/task/tasksearch.h"
+#include "object/task/taskdeletemark.h"
#include "object/task/taskterraform.h"
#include "object/task/taskpen.h"
#include "object/task/taskrecover.h"
@@ -133,6 +134,15 @@ Error CTaskManager::StartTaskSearch()
return (static_cast<CTaskSearch*>(m_task))->Start();
}
+// Delete mark on ground
+
+Error CTaskManager::StartTaskDeleteMark()
+{
+ m_task = new CTaskDeleteMark(m_object);
+ return (static_cast<CTaskDeleteMark*>(m_task))->Start();
+}
+
+
// Reads an information terminal.
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
diff --git a/src/object/task/taskmanager.h b/src/object/task/taskmanager.h
index 908a37a..5af456a 100644
--- a/src/object/task/taskmanager.h
+++ b/src/object/task/taskmanager.h
@@ -46,6 +46,7 @@ public:
Error StartTaskFlag(TaskFlagOrder order, int rank);
Error StartTaskBuild(ObjectType type);
Error StartTaskSearch();
+ Error StartTaskDeleteMark();
Error StartTaskInfo(const char *name, float value, float power, bool bSend);
Error StartTaskTerraform();
Error StartTaskPen(bool bDown, int color);
--
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