FULLPIPE: Implement BehaviorEntry

This commit is contained in:
Eugene Sandulenko 2013-08-14 12:52:59 +03:00
parent 682eb87af6
commit fce8c0f595
7 changed files with 75 additions and 5 deletions

View File

@ -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

View File

@ -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 {

View File

@ -200,6 +200,7 @@ GameObject::GameObject() {
_priority = 0;
_field_20 = 0;
_field_8 = 0;
_objectName = 0;
}
GameObject::GameObject(GameObject *src) {

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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);