summaryrefslogtreecommitdiffhomepage
path: root/Stars45/SimObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Stars45/SimObject.cpp')
-rw-r--r--Stars45/SimObject.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/Stars45/SimObject.cpp b/Stars45/SimObject.cpp
index 01a69f6..b414e03 100644
--- a/Stars45/SimObject.cpp
+++ b/Stars45/SimObject.cpp
@@ -1,15 +1,15 @@
/* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: SimObject.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: SimObject.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Simulation Object and Observer classes
+ OVERVIEW
+ ========
+ Simulation Object and Observer classes
*/
#include "MemDebug.h"
@@ -23,53 +23,53 @@
SimObserver::~SimObserver()
{
- ListIter<SimObject> observed = observe_list;
- while (++observed)
- observed->Unregister(this);
+ ListIter<SimObject> observed = observe_list;
+ while (++observed)
+ observed->Unregister(this);
}
void
SimObserver::Observe(SimObject* obj)
{
- if (obj) {
- obj->Register(this);
+ if (obj) {
+ obj->Register(this);
- if (!observe_list.contains(obj))
- observe_list.append(obj);
- }
+ if (!observe_list.contains(obj))
+ observe_list.append(obj);
+ }
}
void
SimObserver::Ignore(SimObject* obj)
{
- if (obj) {
- obj->Unregister(this);
- observe_list.remove(obj);
- }
+ if (obj) {
+ obj->Unregister(this);
+ observe_list.remove(obj);
+ }
}
bool
SimObserver::Update(SimObject* obj)
{
- if (obj)
- observe_list.remove(obj);
+ if (obj)
+ observe_list.remove(obj);
- return true;
+ return true;
}
const char*
SimObserver::GetObserverName() const
{
- static char name[32];
- sprintf(name, "SimObserver 0x%08x", (DWORD) this);
- return name;
+ static char name[32];
+ sprintf(name, "SimObserver 0x%08x", (DWORD) this);
+ return name;
}
// +--------------------------------------------------------------------+
SimObject::~SimObject()
{
- Notify();
+ Notify();
}
// +--------------------------------------------------------------------+
@@ -77,33 +77,33 @@ SimObject::~SimObject()
void
SimObject::Notify()
{
- if (!notifying) {
- notifying = true;
-
- int nobservers = observers.size();
- int nupdate = 0;
-
- if (nobservers > 0) {
- ListIter<SimObserver> iter = observers;
- while (++iter) {
- SimObserver* observer = iter.value();
- observer->Update(this);
- nupdate++;
- }
-
- observers.clear();
- }
-
- if (nobservers != nupdate) {
- ::Print("WARNING: incomplete notify sim object '%s' - %d of %d notified\n",
- Name(), nupdate, nobservers);
- }
-
- notifying = false;
- }
- else {
- ::Print("WARNING: double notify on sim object '%s'\n", Name());
- }
+ if (!notifying) {
+ notifying = true;
+
+ int nobservers = observers.size();
+ int nupdate = 0;
+
+ if (nobservers > 0) {
+ ListIter<SimObserver> iter = observers;
+ while (++iter) {
+ SimObserver* observer = iter.value();
+ observer->Update(this);
+ nupdate++;
+ }
+
+ observers.clear();
+ }
+
+ if (nobservers != nupdate) {
+ ::Print("WARNING: incomplete notify sim object '%s' - %d of %d notified\n",
+ Name(), nupdate, nobservers);
+ }
+
+ notifying = false;
+ }
+ else {
+ ::Print("WARNING: double notify on sim object '%s'\n", Name());
+ }
}
// +--------------------------------------------------------------------+
@@ -111,8 +111,8 @@ SimObject::Notify()
void
SimObject::Register(SimObserver* observer)
{
- if (!notifying && !observers.contains(observer))
- observers.append(observer);
+ if (!notifying && !observers.contains(observer))
+ observers.append(observer);
}
// +--------------------------------------------------------------------+
@@ -120,8 +120,8 @@ SimObject::Register(SimObserver* observer)
void
SimObject::Unregister(SimObserver* observer)
{
- if (!notifying)
- observers.remove(observer);
+ if (!notifying)
+ observers.remove(observer);
}
// +--------------------------------------------------------------------+
@@ -129,22 +129,22 @@ SimObject::Unregister(SimObserver* observer)
void
SimObject::Activate(Scene& scene)
{
- if (rep)
- scene.AddGraphic(rep);
- if (light)
- scene.AddLight(light);
+ if (rep)
+ scene.AddGraphic(rep);
+ if (light)
+ scene.AddLight(light);
- active = true;
+ active = true;
}
void
SimObject::Deactivate(Scene& scene)
{
- if (rep)
- scene.DelGraphic(rep);
- if (light)
- scene.DelLight(light);
+ if (rep)
+ scene.DelGraphic(rep);
+ if (light)
+ scene.DelLight(light);
- active = false;
+ active = false;
}