aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2013-08-14 12:52:59 +0300
committerEugene Sandulenko2013-09-06 14:51:14 +0300
commitfce8c0f5952533b592de21205274f5cf9347a3b1 (patch)
tree481ea307373fcfd2c07954a1e54be5f54a9400e9
parent682eb87af6788cf576691ecc938da9dbc48802cf (diff)
downloadscummvm-rg350-fce8c0f5952533b592de21205274f5cf9347a3b1.tar.gz
scummvm-rg350-fce8c0f5952533b592de21205274f5cf9347a3b1.tar.bz2
scummvm-rg350-fce8c0f5952533b592de21205274f5cf9347a3b1.zip
FULLPIPE: Implement BehaviorEntry
-rw-r--r--engines/fullpipe/behavior.cpp53
-rw-r--r--engines/fullpipe/behavior.h4
-rw-r--r--engines/fullpipe/gfx.cpp1
-rw-r--r--engines/fullpipe/scene.cpp12
-rw-r--r--engines/fullpipe/scene.h1
-rw-r--r--engines/fullpipe/statics.cpp8
-rw-r--r--engines/fullpipe/statics.h1
7 files changed, 75 insertions, 5 deletions
diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp
index f2d0d5594d..5f26efabe4 100644
--- a/engines/fullpipe/behavior.cpp
+++ b/engines/fullpipe/behavior.cpp
@@ -194,8 +194,57 @@ void BehaviorInfo::initObjectBehavior(CGameVar *var, Scene *sc, StaticANIObject
}
}
-BehaviorEntry::BehaviorEntry(CGameVar *var, Scene *sc, StaticANIObject *ani, int *maxDelay) {
- warning("STUB: BehaviorEntry::BehaviorEntry()");
+BehaviorEntry::BehaviorEntry(CGameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay) {
+ _staticsId = 0;
+ _itemsCount = 0;
+
+ *minDelay = -1;
+
+ int totalPercent = 0;
+ _flags = 0;
+ _items = 0;
+
+ Statics *st = ani->getStaticsByName(var->_varName);
+ if (st)
+ _staticsId = st->_staticsId;
+
+ _itemsCount = var->getSubVarsCount();
+ if (_itemsCount) {
+ _items = (BehaviorEntryInfo**)calloc(_itemsCount, sizeof(BehaviorEntryInfo *));
+
+ for (int i = 0; i < _itemsCount; i++) {
+ CGameVar *subvar = var->getSubVarByIndex(i);
+
+ _items[i] = new BehaviorEntryInfo(subvar, sc);
+ totalPercent += _items[i]->_percent;
+
+ if (_items[i]->_delay < *minDelay)
+ *minDelay = _items[i]->_delay;
+ }
+
+ if (!*minDelay && totalPercent == 1000)
+ _flags |= 1;
+ }
+}
+
+BehaviorEntryInfo::BehaviorEntryInfo(CGameVar *subvar, Scene *sc) {
+ _messageQueue = 0;
+ _delay = 0;
+ _percent = 0;
+ _flags = 0;
+ _messageQueue = sc->getMessageQueueByName(subvar->_varName);
+
+ CGameVar *vart = subvar->getSubVarByName("dwDelay");
+ if (vart)
+ _delay = vart->_value.intValue;
+
+ vart = subvar->getSubVarByName("dwPercent");
+ if (vart)
+ _percent = 0x7FFF * vart->_value.intValue / 1000;
+
+ vart = subvar->getSubVarByName("dwFlags");
+ if (vart && vart->_varType == 2 && strstr(vart->_value.stringValue, "QDESC_AUTOSTART"))
+ _flags |= 2;
}
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/behavior.h b/engines/fullpipe/behavior.h
index ecb7d3a428..210426ebc6 100644
--- a/engines/fullpipe/behavior.h
+++ b/engines/fullpipe/behavior.h
@@ -30,6 +30,8 @@ struct BehaviorEntryInfo {
int _delay;
uint _percent;
int _flags;
+
+ BehaviorEntryInfo(CGameVar *subvar, Scene *sc);
};
struct BehaviorEntry {
@@ -38,7 +40,7 @@ struct BehaviorEntry {
int _flags;
BehaviorEntryInfo **_items;
- BehaviorEntry(CGameVar *var, Scene *sc, StaticANIObject *ani, int *maxDelay);
+ BehaviorEntry(CGameVar *var, Scene *sc, StaticANIObject *ani, int *minDelay);
};
struct BehaviorInfo {
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index d294267a66..6367407838 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -200,6 +200,7 @@ GameObject::GameObject() {
_priority = 0;
_field_20 = 0;
_field_8 = 0;
+ _objectName = 0;
}
GameObject::GameObject(GameObject *src) {
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 0bb44e4143..7f1aeaa02c 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -280,8 +280,8 @@ StaticANIObject *Scene::getStaticANIObject1ById(int obj, int a3) {
}
StaticANIObject *Scene::getStaticANIObject1ByName(char *name, int a3) {
- for (CPtrList::iterator s = _staticANIObjectList1.begin(); s != _staticANIObjectList1.end(); ++s) {
- StaticANIObject *o = (StaticANIObject *)*s;
+ for (uint n = 0; n < _staticANIObjectList1.size(); n++) {
+ StaticANIObject *o = (StaticANIObject *)_staticANIObjectList1[n];
if (!strcmp(o->_objectName, name) && (a3 == -1 || o->_okeyCode == a3))
return o;
}
@@ -340,6 +340,14 @@ MessageQueue *Scene::getMessageQueueById(int messageId) {
return 0;
}
+MessageQueue *Scene::getMessageQueueByName(char *name) {
+ for (uint i = 0; i < _messageQueueList.size(); i++)
+ if (!strcmp(((MessageQueue *)_messageQueueList[i])->_queueName, name))
+ return (MessageQueue *)_messageQueueList[i];
+
+ return 0;
+}
+
void Scene::preloadMovements(CGameVar *var) {
CGameVar *preload = var->getSubVarByName("PRELOAD");
if (!preload)
diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h
index 1b05234853..1292bedf59 100644
--- a/engines/fullpipe/scene.h
+++ b/engines/fullpipe/scene.h
@@ -60,6 +60,7 @@ class Scene : public Background {
StaticANIObject *getStaticANIObject1ById(int obj, int a3);
StaticANIObject *getStaticANIObject1ByName(char *name, int a3);
MessageQueue *getMessageQueueById(int messageId);
+ MessageQueue *getMessageQueueByName(char *name);
void deleteStaticANIObject(StaticANIObject *obj);
void addStaticANIObject(StaticANIObject *obj, bool addList2);
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index bef18293b9..de5d68983f 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -273,6 +273,14 @@ Statics *StaticANIObject::getStaticsById(int itemId) {
return 0;
}
+Statics *StaticANIObject::getStaticsByName(char *name) {
+ for (uint i = 0; i < _staticsList.size(); i++)
+ if (!strcmp(((Statics *)_staticsList[i])->_staticsName, name))
+ return (Statics *)_staticsList[i];
+
+ return 0;
+}
+
Movement *StaticANIObject::getMovementById(int itemId) {
for (uint i = 0; i < _movements.size(); i++)
if (((Movement *)_movements[i])->_id == itemId)
diff --git a/engines/fullpipe/statics.h b/engines/fullpipe/statics.h
index 97a044f95f..40fc91dc06 100644
--- a/engines/fullpipe/statics.h
+++ b/engines/fullpipe/statics.h
@@ -187,6 +187,7 @@ class StaticANIObject : public GameObject {
void setOXY(int x, int y);
Statics *getStaticsById(int id);
+ Statics *getStaticsByName(char *name);
Movement *getMovementById(int id);
int getMovementIdById(int itemId);
Movement *getMovementByName(char *name);