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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
#include "StdAfx.h"
#include "CFilePlugin.h"
#include "CFilePluginList.h"
#include "CProgramPlugin.h"
#include "CResFile.h"
#include "GlobalFunc.h"
#include "T2Archive.h"
#include "T2DateTime.h"
#include "T2DLL.h"
#include "T2EquipPtrList.h"
#include "T2FloorInfo.h"
#include "T2Name.h"
#include "T2NameList.h"
#include "T2People.h"
#include "T2PeopleArrayList.h"
#include "T2PluginLoader.h"
#include "T2PluginSpecifier.h"
#include "T2Pool.h"
#include "T2RegistedTenantDB.h"
#include "T2SoundPlayer.h"
#include "T2Tenant.h"
#include "../T2TowerDoc.h"
#include "T2TowerEvent.h"
#include "T2TowerMessage.h"
#include "T2WorldDef.h"
#include "T2VisitVIP.h"
T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, CResFile* inResFile, int inSubID)
: T2EventItem(inTowerEvent, inResFile, inSubID)
{
int cycleDay = mCycleDay;
mSilhouetteType = 0;
int numVIPs;
*inResFile >> numVIPs;
T2VisitVIP *theVIP;
for (int i = 0; i < numVIPs; i++) {
theVIP = (i == 0) ? this : new T2VisitVIP(mTowerEvent, inSubID + i, mLevelBit, mExclusive, mCycleDay, mBeginTime, mEndTime);
if (theVIP)
theVIP->Init(inResFile);
if (theVIP != this)
mTowerEvent->AppendStandby(theVIP);
}
}
T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, BOOL inExclusive, int inCycleDay, int inBeginTime, int inEndTime)
: T2EventItem(inTowerEvent, inSubID, inLevelBit, inExclusive, inCycleDay, inBeginTime, inEndTime)
{
mSilhouetteType = 0;
}
/*virtual*/ T2VisitVIP::~T2VisitVIP() {
}
/*virtual*/ BOOL T2VisitVIP::IsBeginDay(int inDay) {
if (inDay > mBeginDay)
mBeginDay = inDay;
return (mBeginDay == inDay);
}
/*virtual*/ BOOL T2VisitVIP::IsBeginTime(unsigned int inTime) {
return (mBeginTime == inTime);
}
/*virtual*/ BOOL T2VisitVIP::Start(T2TowerDoc* inDoc) {
BOOL mysteriousUnusedVar = true;
T2WorldDef *theWorldDef = GetWorldDef();
mStatus = kVisitVIPStatus0;
mCheckedIn = false;
mPeopleID = 0;
mTenantID = 0;
if (mGrade <= theWorldDef->mNumOfGradeDef && inDoc->GetLevel() == mGrade) {
GradeDef *theGrade = &theWorldDef->mGradeDef[mGrade - 1];
if ((theGrade->m0 & mVisitFlag) != 0 && (inDoc->mA0 & mVisitFlag) == 0) {
T2Pool *thePool = inDoc->GetPool();
if (thePool && thePool->GetPopulation() > (theGrade->m4 / 2)) {
T2Tenant *theTenant = NULL;
CFilePlugin *thePlugin = NULL;
T2PluginSpecifier *theSpecifier = NULL;
if (GetDestinationTennant(mTenantPluginID, theTenant, thePlugin, theSpecifier)) {
if (theTenant && thePool) {
T2People *theVIP = thePool->BornVIP(mSilhouetteType, -1);
if (theVIP) {
CString tmp;
CString text;
theVIP->GetName(text);
T2Name *theName = inDoc->mNameDB->Search(theVIP);
if (theName) {
theName->SetName(text);
} else {
T2Name *newName = new T2Name(text, theVIP, false);
inDoc->mNameDB->Add(newName);
}
theVIP->mColor = 14;
if (theTenant->GetRegistID() == kTenantRegistID1) {
theTenant->RegistBelongPeople(theVIP);
theVIP->SetDestination(theTenant->GetRelatedTenantID(), mArrivalTime);
theTenant->SetStatus(kTenantStatus31);
mCheckedIn = true;
} else {
theVIP->SetDestination(theTenant->mEquipID, mArrivalTime);
}
// "様より" - From
text += "\x97\x6C\x82\xE6\x82\xE8";
RECT rect;
theTenant->GetEquipArea(rect);
int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top);
if (floorNum < 0) {
text += 'B';
floorNum = 0 - floorNum;
}
tmp.Format("%d", floorNum);
text += tmp;
// "階" - floor
text += "\x8A\x4B";
int roomNum = theTenant->GetRoomNumber(inDoc->GetFloorInfo());
if (roomNum < 0) {
text += 'B';
roomNum = 0 - roomNum;
}
tmp.Format("%d", roomNum);
text += tmp;
// "号室の" - of room number
text += "\x8D\x86\x8E\xBA\x82\xCC";
T2EquipDef *theTenantDef = theTenant->GetEquipDef();
if (theTenantDef)
theTenantDef->GetName(tmp, 0);
text += tmp;
// "に、予約がはいりました。\n今日の" - I have a reservation. Today's
text += "\x82\xC9\x81\x41\x97\x5C\x96\xF1\x82\xAA\x82\xCD\x82\xA2\x82\xE8\x82\xDC\x82\xB5\x82\xBD\x81\x42\x0A\x8D\xA1\x93\xFA\x82\xCC";
tmp.Format("%d", mArrivalTime / 60);
text += tmp;
// "時" - Time
text += "\x8E\x9E";
int minute = mArrivalTime % 60;
if (minute != 0) {
// "%d分" - %d minute
tmp.Format("%d\x95\xAA", minute);
text += tmp;
}
// "にロビーに到着する予定です。" - will arrive at the lobby on
text += "\x82\xC9\x83\x8D\x83\x72\x81\x5B\x82\xC9\x93\x9E\x92\x85\x82\xB7\x82\xE9\x97\x5C\x92\xE8\x82\xC5\x82\xB7\x81\x42";
Sounds->AddSound("VIP:Reserve", SoundPriority_1, 9002, GetWorldModuleHandle());
Sounds->Play("VIP:Reserve", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100);
DoDialog(inDoc, 8200, 8200, 1, text);
Sounds->Stop("VIP:Reserve");
Sounds->DeleteSound("VIP:Reserve");
mPeopleID = theVIP->GetPeopleID();
mTenantID = theTenant->GetEquipID();
mStatus = kVisitVIPStatus1;
}
}
} else if (thePlugin) {
CString tmp;
thePlugin->GetName(tmp);
CString str;
// "VIPを招待するには、" - To invite your VIP,
str = "\x56\x49\x50\x82\xF0\x8F\xB5\x91\xD2\x82\xB7\x82\xE9\x82\xC9\x82\xCD\x81\x41";
str += tmp;
// "の設置が必要です。" - installation is required.
str += "\x82\xCC\x90\xDD\x92\x75\x82\xAA\x95\x4B\x97\x76\x82\xC5\x82\xB7\x81\x42";
inDoc->GetTowerMessage()->InfoBarMessage(str, 900, NULL);
} else if (!theSpecifier) {
inDoc->mA0 |= mVisitFlag;
mStatus = kVisitVIPStatus4;
}
}
}
}
return (mStatus != kVisitVIPStatus0);
}
/*virtual*/ int T2VisitVIP::Exec(T2TowerDoc* inDoc) {
int result = 0;
switch (mStatus) {
case kVisitVIPStatus0:
case kVisitVIPStatus4:
case kVisitVIPStatus5:
mStatus = kVisitVIPStatus0;
result = 3;
}
if (DoReception(inDoc))
result = 3;
else
result = IsExclusive() ? 1 : 0;
return result;
}
void T2VisitVIP::Init(CResFile* inResFile) {
*inResFile >> mGrade;
*inResFile >> mTenantPluginID;
*inResFile >> mArrivalTime;
*inResFile >> mArriveAnimResID;
*inResFile >> mSatisfiedSoundID;
*inResFile >> mDissatisfiedSoundID;
int subResID;
*inResFile >> subResID;
CResFile subResFile;
if (subResFile.OpenResource(GetWorldDef()->mModuleHandle, subResID, 'VIPL'))
subResFile >> mSilhouetteType;
*inResFile >> mSatisfiedText;
*inResFile >> mDissatisfiedText;
mLevelBit = 1 << (mGrade - 1);
mDaysBeforeNextVisit = mCycleDay;
mCycleDay = 1;
mBeginDay = 0;
mPeopleID = 0;
mTenantID = 0;
mStatus = kVisitVIPStatus0;
mCheckedIn = false;
mVisitFlag = 1 << ((mGrade - 1) * 4);
while (mTowerEvent->_88 & mVisitFlag)
mVisitFlag <<= 1;
mTowerEvent->_88 |= mVisitFlag;
}
BOOL T2VisitVIP::DoReception(T2TowerDoc* inDoc) {
T2People *thePeople = inDoc->mPeopleArrayList->FindPeople(mPeopleID);
if (thePeople) {
int theSndID;
CString str;
T2Name *theName;
T2Pool *thePool;
switch (thePeople->GetStatus()) {
case kStatus2:
case kStatus3:
case kStatus4:
if (mStatus < kVisitVIPStatus2) {
Sounds->AddSound("VIP:Arrive", SoundPriority_1, 9001, GetWorldModuleHandle());
Sounds->Play("VIP:Arrive", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100);
thePeople->GetName(str);
// "様が今ロビーに到着しました。" - You have just arrived at the lobby.
str += "\x97\x6C\x82\xAA\x8D\xA1\x83\x8D\x83\x72\x81\x5B\x82\xC9\x93\x9E\x92\x85\x82\xB5\x82\xDC\x82\xB5\x82\xBD\x81\x42";
DoDialog(inDoc, 8200, mArriveAnimResID, 1, str);
Sounds->Stop("VIP:Arrive");
Sounds->DeleteSound("VIP:Arrive");
mStatus = kVisitVIPStatus2;
}
break;
case kStatus1:
if (mStatus < kVisitVIPStatus2)
break;
thePeople->GetName(str);
// "様が御帰宅なされました。\nあなたのビルに" - You have gone home. In your building
str += "\x97\x6C\x82\xAA\x8C\xE4\x8B\x41\x91\xEE\x82\xC8\x82\xB3\x82\xEA\x82\xDC\x82\xB5\x82\xBD\x81\x42\x0A\x82\xA0\x82\xC8\x82\xBD\x82\xCC\x83\x72\x83\x8B\x82\xC9";
theSndID = 0;
if (thePeople->VIPEstimation()) {
// "大変満足した様子です。\n\n「" - I am very satisfied.
str += "\x91\xE5\x95\xCF\x96\x9E\x91\xAB\x82\xB5\x82\xBD\x97\x6C\x8E\x71\x82\xC5\x82\xB7\x81\x42\x0A\x0A\x81\x75";
str += mSatisfiedText;
inDoc->mA0 |= mVisitFlag;
mStatus = kVisitVIPStatus4;
theSndID = mSatisfiedSoundID;
} else {
// "不満な様子です。\n\n「" - I'm dissatisfied.
str += "\x95\x73\x96\x9E\x82\xC8\x97\x6C\x8E\x71\x82\xC5\x82\xB7\x81\x42\x0A\x0A\x81\x75";
T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID);
if (theTenant) {
CString tmp;
RECT rect;
theTenant->GetEquipArea(rect);
int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top);
if (floorNum < 0) {
str += 'B';
floorNum = 0 - floorNum;
}
tmp.Format("%d", floorNum);
str += tmp;
// "階の - of the floor
str += "\x8A\x4B\x82\xCC";
T2EquipDef *theTenantDef = theTenant->GetEquipDef();
if (theTenantDef)
theTenantDef->GetToolName(tmp, 0);
str += tmp;
// "は遠すぎる。\n" - is too far
str += "\x82\xCD\x89\x93\x82\xB7\x82\xAC\x82\xE9\x81\x42\x0A";
}
str += mDissatisfiedText;
mBeginDay += mDaysBeforeNextVisit;
mStatus = kVisitVIPStatus6;
theSndID = mDissatisfiedSoundID;
}
DoAlert(inDoc, str, theSndID);
theName = inDoc->mNameDB->Search(thePeople);
if (theName) {
inDoc->mNameDB->RemoveName(theName);
delete theName;
}
thePool = inDoc->GetPool();
thePool->DeadVIP(thePeople);
return true;
case kStatus11:
if (mCheckedIn) {
T2DateTime *theNow = inDoc->mNow;
if (theNow && theNow->GetRawMinutes() == 600) {
T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID);
if (theTenant && theTenant->IsBelongPeople(thePeople)) {
theTenant->SetStatus(kTenantStatus34);
mCheckedIn = false;
}
}
}
break;
}
}
return false;
}
BOOL T2VisitVIP::GetDestinationTennant(DWORD inPluginID, T2Tenant*& outTenant, CFilePlugin*& outPlugin, T2PluginSpecifier*& outSpecifier) {
BOOL loaded = false;
T2TowerDoc *theTowerDoc = GetTowerDoc();
T2PluginLoader *theT2PluginLoader = theTowerDoc->mT2PluginLoader;
T2PluginSpecifier *theSpecifier;
POSITION pos;
theT2PluginLoader->SetTypeFilter(pos, 'TnPl');
while ((theSpecifier = theT2PluginLoader->GetNext(pos))) {
if (theSpecifier->mID == inPluginID) {
outPlugin = theTowerDoc->mTenantPlugins->GetItem(theSpecifier->mID);
outSpecifier = theSpecifier;
break;
}
}
if (outPlugin) {
T2FloorInfo *theFloorInfo = theTowerDoc->GetFloorInfo();
if (theFloorInfo) {
T2Tenant *theTenant = theFloorInfo->GetTenantByPID(inPluginID);
if (theTenant) {
unsigned int registID = theTenant->GetRegistID();
if (registID == kTenantRegistID1) {
theTenant = NULL;
T2RegistedTenantDB *theDB = theTowerDoc->GetRegistedTenantDB();
if (theDB) {
T2EquipPtrList *theList = theDB->GetList(kTenantRegistID1);
if (theList) {
LArrayIterator iterator(*theList);
T2Tenant *iteratorTenant;
while (!theTenant && iterator.Next(&iteratorTenant)) {
if (theFloorInfo->GetTenant(iteratorTenant->GetRelatedTenantID())) {
CProgramPlugin *plugin = iteratorTenant->GetEquipDef()->GetPlugin();
if (plugin) {
if (plugin->GetID() == inPluginID && iteratorTenant->GetStatus() == kTenantStatus30)
theTenant = iteratorTenant;
}
}
}
}
}
}
outTenant = theTenant;
loaded = true;
}
}
}
return loaded;
}
/*virtual*/ void T2VisitVIP::Write(T2Archive& inArchive) {
unsigned int len = 14;
inArchive << len;
inArchive << (short) mStatus;
inArchive << mPeopleID;
inArchive << (unsigned short) mTenantID;
inArchive << mVisitFlag;
inArchive << (short) mBeginDay;
}
/*virtual*/ void T2VisitVIP::Read(T2Archive& inArchive) {
unsigned int len;
inArchive >> len;
short s;
unsigned short su;
inArchive >> s;
mStatus = s;
inArchive >> mPeopleID;
inArchive >> su;
mTenantID = su;
inArchive >> mVisitFlag;
inArchive >> s;
mBeginDay = s;
}
|