summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2RequestArray.cpp
blob: 65c34a32762ed0ef50c0639f91e0d53f92eb68ef (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
39
40
41
42
43
44
45
#include "T2RequestArray.h"

T2RequestArray::T2RequestArray(unsigned int startID)
    : T2ObjectArray(startID)
{
    for (unsigned int i = 0; i < 64; i++)
        mRequests[i].mRequestID = mStartID + i;
}

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

T2Request* T2RequestArray::FindUnusedRequest() {
    for (int i = 0; i < 64; i++) {
        if (!mRequests[i].IsUsed())
            return &mRequests[i];
    }

    return NULL;
}

/*virtual*/ void T2RequestArray::DispatchIdle(T2TowerDoc* towerDoc, int) {
    for (int i = 0; i < 64; i++) {
        if (mRequests[i].IsUsed())
            mRequests[i].Idle(towerDoc);
    }
}

void T2RequestArray::BreakoutEmergency(T2TowerDoc* towerDoc) {
    for (unsigned int i = 0; i < 64; i++) {
        T2Request *request = &mRequests[i];
        if (request->IsUsed())
            request->BreakoutEmergency(towerDoc);
    }
}

void T2RequestArray::Read(T2Archive& archive, T2TowerDoc* towerDoc) {
    for (int i = 0; i < 64; i++)
        mRequests[i].Load(archive, towerDoc);
}

void T2RequestArray::Write(T2Archive& archive) {
    for (int i = 0; i < 64; i++)
        mRequests[i].Save(archive);
}