diff options
Diffstat (limited to 'engines/agos/contain.cpp')
-rw-r--r-- | engines/agos/contain.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index b7950f7034..043e48feb4 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -98,4 +98,33 @@ int AGOSEngine::sizeOfRec(Item *o, int d) { return 0; } +int AGOSEngine::weighUp(Item *x) { + return weightRec(x, 0); +} + +int AGOSEngine::weightRec(Item *x, int d) { + int n = weightOf(x); + Item *o; + + if (d > 32) + return 0; + o = derefItem(x->child); + while (o) { + n += weightRec(o, d + 1); + o = derefItem(o->next); + } + + return n; +} + +int AGOSEngine::weightOf(Item *x) { + SubObject *o = (SubObject *)findChildOfType(x, 2); + SubPlayer *p = (SubPlayer *)findChildOfType(x, 3); + if (o) + return o->objectWeight; + if (p) + return p->weight; + return 0; +} + } // End of namespace AGOS |