#include "StdAfx.h" #include "T2Archive.h" #include "T2StopInfoArray.h" T2StopInfoArray::T2StopInfoArray() : LArray(1) { } /*virtual*/ T2StopInfoArray::~T2StopInfoArray() { } void T2StopInfoArray::Init(int count) { Expand(EEquipPos_2, count); } void T2StopInfoArray::AllClear() { RemoveItemsAt(mItemCount, 1); } void T2StopInfoArray::Expand(EEquipPos pos, int count) { int where; if (pos == EEquipPos_2) where = mItemCount + 1; else if (pos == EEquipPos_3) where = 1; else return; if (count > 0) { int actualCount = count * 2; unsigned char nullVal = 0; for (int i = 0; i < actualCount; i++) InsertItemsAt(1, where, &nullVal); } else { int actualCount = -count * 2; for (int i = 0; i < actualCount; i++) RemoveItemsAt(1, where); } } BOOL T2StopInfoArray::IsStopPos(int i, ERequestUpDown upDown) { return GetStopAt(i, upDown) > 0; } BOOL T2StopInfoArray::IsOnStopPos(int i, ERequestUpDown upDown) { return (GetStopAt(i, upDown) & 2) > 0; } BOOL T2StopInfoArray::IsOffStopPos(int i, ERequestUpDown upDown) { return (GetStopAt(i, upDown) & 1) > 0; } void T2StopInfoArray::SetOnStop(int i, ERequestUpDown upDown) { char v = GetStopAt(i, upDown) | 2; SetStopAt(i, upDown, v); } void T2StopInfoArray::SetOffStop(int i, ERequestUpDown upDown) { char v = GetStopAt(i, upDown) | 1; SetStopAt(i, upDown, v); } void T2StopInfoArray::ClearOnStop(int i, ERequestUpDown upDown) { char v = GetStopAt(i, upDown) & 1; SetStopAt(i, upDown, v); } void T2StopInfoArray::ClearOffStop(int i, ERequestUpDown upDown) { char v = GetStopAt(i, upDown) & 2; SetStopAt(i, upDown, v); } char T2StopInfoArray::GetStopAt(int i, ERequestUpDown upDown) { char v; FetchItemAt(GetIndex(i, upDown), &v); return v; } void T2StopInfoArray::SetStopAt(int i, ERequestUpDown upDown, char v) { AssignItemsAt(1, GetIndex(i, upDown), &v); } int T2StopInfoArray::GetIndex(int i, ERequestUpDown upDown) const { int index = 1; index += i * 2; if (upDown == ERequestUpDown_1) index++; return index; } /*static*/ T2StopInfoArray* T2StopInfoArray::ReadStopInfoArray(T2Archive& archive) { T2StopInfoArray *array = NULL; DWORD code; archive >> code; if (code == 'SIfA') array = new T2StopInfoArray; if (array) array->ReadAsChar(archive); return array; } /*static*/ void T2StopInfoArray::WriteStopInfoArray(T2StopInfoArray* array, T2Archive& archive) { DWORD code; if (!array) { code = 'xSIA'; archive << code; } else { code = 'SIfA'; archive << code; array->WriteAsChar(archive); } }