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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
#include "StdAfx.h"
#include "LArray.h"
#include "T2Archive.h"
#include "T2FloorInfo.h"
#include "T2OutObjArrayList.h"
#include "T2OutsideInfo.h"
T2OutsideInfo::T2OutsideInfo(const T2FloorInfo& inFloorInfo)
: mFloorInfo(inFloorInfo)
{
UINT zero = 0;
mUnitInfo = new LArray(sizeof(UINT));
mUnitInfo->InsertItemsAt(mFloorInfo.mHRange * mFloorInfo.mVRange, 1, &zero);
mNextUnitInfo = -1;
SetRect(&mArea, 0, 0, 0, 0);
}
/*virtual*/ T2OutsideInfo::~T2OutsideInfo() {
if (mUnitInfo)
delete mUnitInfo;
}
void T2OutsideInfo::Reset() {
if (IsRectEmpty(&mArea)) {
mNextUnitInfo = -1;
} else {
mCurrentPt.x = mArea.left;
mCurrentPt.y = mArea.top;
mCurrentPt.x--;
mNextUnitInfo = mFloorInfo.mHRange * mCurrentPt.y + mCurrentPt.x;
mCurrentOutObjID = 0;
}
}
void T2OutsideInfo::SetArea(const RECT& inRect) {
IntersectRect(&mArea, &inRect, &mFloorInfo.mBuildArea);
Reset();
}
POINT T2OutsideInfo::CurrentPt() const {
return mCurrentPt;
}
unsigned int T2OutsideInfo::GetUnitInfo(int inV, int inH) const {
unsigned int unitInfo = 0;
#line 111
_ASSERT((inV >= 0) && (inV < mFloorInfo.mVRange));
_ASSERT((inH >= 0) && (inH < mFloorInfo.mHRange));
if (inV >= 0 && inV < mFloorInfo.mVRange && inH >= 0 && inH < mFloorInfo.mHRange) {
int index = mFloorInfo.mHRange * inV + inH;
mUnitInfo->FetchItemAt(index, &unitInfo);
}
return unitInfo;
}
T2OutObj* T2OutsideInfo::GetOutObj(int inV, int inH) const {
unsigned int unitInfo = GetUnitInfo(inV, inH);
if (unitInfo)
return mFloorInfo.mOutObjArrayList->GetOutObjByID(unitInfo);
else
return NULL;
}
void T2OutsideInfo::FillOutObjID(const RECT& inRect, unsigned int inID) {
SetArea(inRect);
int index;
while (NextIndex(index))
mUnitInfo->AssignItemsAt(1, index, &inID);
}
unsigned int T2OutsideInfo::GetOutObjID(int inV, int inH) const {
return GetUnitInfo(inV, inH);
}
BOOL T2OutsideInfo::CalcNextUnitInfo() {
BOOL result = true;
if (!IsRectEmpty(&mArea)) {
if (mCurrentPt.y < mArea.bottom) {
mCurrentPt.x++;
if (mCurrentPt.x < mArea.right) {
mNextUnitInfo++;
} else {
mCurrentPt.x = mArea.left;
mCurrentPt.y++;
mNextUnitInfo += mFloorInfo.mHRange - (mArea.right - mArea.left) + 1;
if (mCurrentPt.y >= mArea.bottom)
result = false;
}
} else {
result = false;
}
} else {
result = false;
}
return result;
}
BOOL T2OutsideInfo::NextValue(unsigned int& outValue) {
BOOL result = true;
if (CalcNextUnitInfo())
mUnitInfo->FetchItemAt(mNextUnitInfo, &outValue);
else
result = false;
return result;
}
BOOL T2OutsideInfo::NextIndex(int& outIndex) {
BOOL result = true;
if (CalcNextUnitInfo())
outIndex = mNextUnitInfo;
else
result = false;
return result;
}
BOOL T2OutsideInfo::NextOutObj(T2OutObj*& outOutObj) {
unsigned int theOutObjID;
BOOL found;
for (found = NextValue(theOutObjID); found; found = NextValue(theOutObjID)) {
if (theOutObjID != mCurrentOutObjID) {
mCurrentOutObjID = theOutObjID;
if (theOutObjID != 0) {
outOutObj = mFloorInfo.mOutObjArrayList->GetOutObjByID(theOutObjID);
break;
}
}
}
return found;
}
void T2OutsideInfo::Read(T2Archive& inArchive) {
unsigned short v;
unsigned int numInfo, unitInfo;
inArchive >> numInfo;
for (unsigned int i = 1; i <= numInfo; i++) {
inArchive >> v;
unitInfo = v;
mUnitInfo->AssignItemsAt(1, i, &unitInfo);
}
}
void T2OutsideInfo::Write(T2Archive& inArchive) {
unsigned int numInfo, unitInfo;
numInfo = mFloorInfo.mHRange * mFloorInfo.mVRange;
inArchive << numInfo;
for (unsigned int i = 1; i <= numInfo; i++) {
mUnitInfo->FetchItemAt(i, &unitInfo);
inArchive << (unsigned short) unitInfo;
}
}
|