summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2FloorPtrList.cpp
blob: fec528dd4fad019dd761235aca3ead5b8da49480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "T2FloorPtrList.h"
#include "T2Tenant.h"
#include "T2TenantArray.h"
#include "T2TenantArrayList.h"

T2FloorPtrList::T2FloorPtrList(T2TenantArrayList* inList) {
    LArrayIterator iterator(*inList);
    T2TenantArray *theArray;

    while (iterator.Next(&theArray)) {
        for (int i = 0; i < T2TenantArray::kGroupSize; i++) {
            T2Tenant *theTenant = theArray->GetIndexTenant(i);
            if (theTenant->IsUsed() && theTenant->IsFloor() && theTenant->IsBuildFinish())
                AddItem(theTenant);
        }
    }
}

/*virtual*/ T2FloorPtrList::~T2FloorPtrList() {
}

int T2FloorPtrList::CalcDistance(int inIndexA, int inIndexB) {
    int theDistance = -1;
    T2Tenant *theFloorA = (T2Tenant *) GetItem(inIndexA);
    T2Tenant *theFloorB = (T2Tenant *) GetItem(inIndexB);

    if (theFloorA && theFloorB) {
        RECT theRectA, theRectB;
        theFloorA->GetEquipArea(theRectA);
        theFloorB->GetEquipArea(theRectB);

        theDistance = (theRectA.bottom - 1) - (theRectB.bottom - 1);
        if (theDistance < 0)
            theDistance *= -1;
    }

    return theDistance;
}