void CSrScrlView::OnBnClickedAddButton() { srscrl_effectdata_t* pNewEffect = new srscrl_effectdata_t; CSrSubrecord* pSubrecord; pSubrecord = GetInputRecord()->CreateSubrecord(SR_NAME_EFID); pNewEffect->pEffect = SrCastClassNull(CSrFormidSubrecord, pSubrecord); pSubrecord = GetInputRecord()->CreateSubrecord(SR_NAME_EFIT); pNewEffect->pEffectData = SrCastClassNull(CSrEfitSubrecord, pSubrecord); if (pNewEffect->pEffect == NULL || pNewEffect->pEffectData == NULL) { delete pNewEffect; return; } pNewEffect->pEffect->InitializeNew(); pNewEffect->pEffectData->InitializeNew(); GetCurrentEffect(); m_Effects.Add(pNewEffect); AddEffectList(pNewEffect); m_EffectList.SelectRecord(m_Effects.GetSize() - 1); SetCurrentEffect(m_Effects[m_Effects.GetSize() - 1]); }
void CSrRacePageHead1::OnDropMpaList (NMHDR* pNotifyStruct, LRESULT* pResult) { srrldroprecords_t* pDropItems = (srrldroprecords_t *) pNotifyStruct; srrlcustomdata_t* pCustomData; *pResult = SRRL_DROPCHECK_ERROR; if (pDropItems == NULL) return; if (pDropItems->pCustomDatas == NULL) return; for (dword i = 0; i < pDropItems->pCustomDatas->GetSize(); ++i) { pCustomData = pDropItems->pCustomDatas->GetAt(i); if (pCustomData == NULL) continue; CSrDwordSubrecord* pIndex = SrCastClassNull(CSrDwordSubrecord, pCustomData->Subrecords[0]); CSrMpavSubrecord* pData = SrCastClassNull(CSrMpavSubrecord, pCustomData->Subrecords[1]); if (pIndex == NULL || pData == NULL) return; /* If we're just checking or not */ if (pDropItems->Notify.code == ID_SRRECORDLIST_DROP) { srraceheadmpadata_t* pMpa = m_HeadInfo.MPAData.AddNew(); pMpa->Index.CopyFull(pIndex); pMpa->Data.CopyFull(pData); pMpa->Index.SetValue(m_MpaList.GetItemCount()); AddMpaList(pMpa); } } *pResult = SRRL_DROPCHECK_OK; }
/*=========================================================================== * * Class CSrScrlView Method - void UpdateEffectList (ListIndex, Update); * *=========================================================================*/ void CSrScrlView::UpdateEffectList (const int ListIndex, const bool Update) { CSrFormidSubrecord* pEffectID; srrlcustomdata_t* pCustomData; srformid_t FormID; CString Buffer; if (GetInputRecord() == NULL) return; pCustomData = m_EffectList.GetCustomData(ListIndex); if (pCustomData == NULL) return; if (Update) m_EffectList.UpdateRecord(ListIndex); pEffectID = SrCastClassNull(CSrFormidSubrecord, pCustomData->Subrecords[0]); if (pEffectID == NULL) return; FormID = pEffectID->GetValue(); Buffer.Format("0x%08X", FormID); m_EffectList.SetCustomField(ListIndex, SR_FIELD_EFFECTID, Buffer); CSrRecord* pRecord = GetInputRecord()->GetParent()->FindFormID(FormID); CSrIdRecord* pIdRecord = SrCastClassNull(CSrIdRecord, pRecord); if (pIdRecord != NULL) m_EffectList.SetCustomField(ListIndex, SR_FIELD_EFFECTNAME, pIdRecord->GetEditorID()); Buffer.Format("%d", pCustomData->UserCount); m_EffectList.SetCustomField(ListIndex, SR_FIELD_CONDITIONCOUNT, Buffer); }
static int CALLBACK s_ItemFormIDRecListSort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { SRRL_SORTFUNC_GETPARAMS(lParam1, lParam2, lParamSort); CSrCntoSubrecord* pItem1 = SrCastClassNull(CSrCntoSubrecord, pCustomData1->Subrecords[0]); CSrCntoSubrecord* pItem2 = SrCastClassNull(CSrCntoSubrecord, pCustomData2->Subrecords[0]); if (pItem1 == NULL || pItem2 == NULL) return (0); if (pSortData->Reverse) return -(int)(pItem1->GetFormID() - pItem2->GetFormID()); return (int)(pItem1->GetFormID() - pItem2->GetFormID()); }
/*=========================================================================== * * Class CSrLvlnView Event - void OnAddLevel (); * *=========================================================================*/ void CSrLvlnView::OnAddLevel() { srrlcustomdata_t* pCustomData; CSrLvloSubrecord* pItem; POSITION ListPos; CString Buffer; int ListIndex; ListPos = m_ItemList.GetFirstSelectedItemPosition(); while (ListPos != NULL) { ListIndex = m_ItemList.GetNextSelectedItem(ListPos); pCustomData = m_ItemList.GetCustomData(ListIndex); if (pCustomData == NULL) continue; pItem = SrCastClassNull(CSrLvloSubrecord, pCustomData->Subrecords[0]); if (pItem == NULL) continue; if (pItem->GetLevel() >= 32768) continue; pItem->SetLevel(pItem->GetLevel() + 1); Buffer.Format("%u", (dword) pItem->GetLevel()); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LEVEL, Buffer); } }
/*=========================================================================== * * Class CSrContView Event - int OnDropCustomData (DropItems); * *=========================================================================*/ int CSrContView::OnDropCustomData (srrldroprecords_t& DropItems) { CSrCntoSubrecord* pItem; srlvllistinfo_t* pInfo; srrlcustomdata_t* pCustomData; dword Index; for (Index = 0; Index < DropItems.pCustomDatas->GetSize(); ++Index) { pCustomData = DropItems.pCustomDatas->GetAt(Index); if (pCustomData == NULL) return (SRRL_DROPCHECK_ERROR); if (pCustomData->pRecord == NULL) return (SRRL_DROPCHECK_ERROR); if (!SrIsValidContainerRecord(pCustomData->pRecord->GetRecordType())) return (SRRL_DROPCHECK_ERROR); pItem = SrCastClassNull(CSrCntoSubrecord, pCustomData->Subrecords[0]); if (pItem == NULL) return (SRRL_DROPCHECK_ERROR); /* If we're just checking */ if (DropItems.Notify.code == ID_SRRECORDLIST_CHECKDROP) continue; pInfo = m_LvlListInfo.AddNew(); pInfo->CopyFrom(pCustomData->Subrecords); AddItemList(pInfo); } return (SRRL_DROPCHECK_OK); }
bool CSrEpfdSubrecord::Copy (CSrSubrecord* pSubrecord) { CSrEpfdSubrecord* pSubrecord1 = SrCastClassNull(CSrEpfdSubrecord, pSubrecord); m_RecordSize = pSubrecord->GetRecordSize(); if (pSubrecord1 != NULL) { m_DataType = pSubrecord1->m_DataType; m_Data01 = pSubrecord1->m_Data01; m_Data02 = pSubrecord1->m_Data02; m_Data03 = pSubrecord1->m_Data03; m_Data04 = pSubrecord1->m_Data04; m_Data05 = pSubrecord1->m_Data05; m_Data06 = pSubrecord1->m_Data06; m_Data07 = pSubrecord1->m_Data07; m_Data07.IsLocalString = false; //TODO: Properly inherit parent file local string setting } else { memset(&m_Data01, 0, sizeof(m_Data01)); memset(&m_Data02, 0, sizeof(m_Data02)); memset(&m_Data03, 0, sizeof(m_Data03)); memset(&m_Data04, 0, sizeof(m_Data04)); memset(&m_Data05, 0, sizeof(m_Data05)); } return true; }
/*=========================================================================== * * Class CSrContView Event - void OnLvllistEdit (); * *=========================================================================*/ void CSrContView::OnLvllistEdit() { CSrCntoSubrecord* pSubrecord; srrlcustomdata_t* pCustomData; srlvllistinfo_t* pListInfo; int ListIndex; int Result; ListIndex = m_ItemList.GetSelectedItem(); if (ListIndex < 0) return; pCustomData = m_ItemList.GetCustomData(ListIndex); if (pCustomData == NULL) return; pSubrecord = SrCastClassNull(CSrCntoSubrecord, pCustomData->Subrecords[0]); if (pSubrecord == NULL) return; pListInfo = SrFindLvlListInfo(m_LvlListInfo, pSubrecord); if (pListInfo == NULL) return; Result = SrEditContItemDlg(pListInfo, m_pDlgHandler, GetInputRecord()->GetFormID()); if (Result == SR_CONTITEMDLG_RESULT_CANCEL) return; if (Result == SR_CONTITEMDLG_RESULT_DELETE) { m_LvlListInfo.Delete(pListInfo); m_ItemList.RemoveItem(ListIndex); return; } SrCreateLvlListInfoCustomData(*pCustomData, *pListInfo, m_pRecordHandler); UpdateItem(ListIndex, pListInfo); }
/*=========================================================================== * * Class CSrContView Event - void OnMinusCount (); * *=========================================================================*/ void CSrContView::OnMinusCount() { srrlcustomdata_t* pCustomData; CSrCntoSubrecord* pItem; POSITION ListPos; CString Buffer; int ListIndex; ListPos = m_ItemList.GetFirstSelectedItemPosition(); while (ListPos != NULL) { ListIndex = m_ItemList.GetNextSelectedItem(ListPos); pCustomData = m_ItemList.GetCustomData(ListIndex); if (pCustomData == NULL) continue; pItem = SrCastClassNull(CSrCntoSubrecord, pCustomData->Subrecords[0]); if (pItem == NULL) continue; if (pItem->GetCount() == 0) continue; pItem->SetCount(pItem->GetCount() - 1); Buffer.Format("%u", (dword) pItem->GetCount()); m_ItemList.SetCustomField(ListIndex, SR_FIELD_ITEMCOUNT, Buffer); } }
void CSrRacePageFace::OnDropFaceWeights (NMHDR* pNotifyStruct, LRESULT* pResult) { srrldroprecords_t* pDropItems = (srrldroprecords_t *) pNotifyStruct; srrlcustomdata_t* pCustomData; *pResult = SRRL_DROPCHECK_ERROR; if (pDropItems == NULL) return; if (pDropItems->pCustomDatas == NULL) return; for (dword i = 0; i < pDropItems->pCustomDatas->GetSize(); ++i) { pCustomData = pDropItems->pCustomDatas->GetAt(i); if (pCustomData == NULL) continue; CSrPhwtSubrecord* pWeight = SrCastClassNull(CSrPhwtSubrecord, pCustomData->Subrecords[0]); if (pWeight == NULL) return; /* If we're just checking or not */ if (pDropItems->Notify.code == ID_SRRECORDLIST_DROP) { CSrPhwtSubrecord* pNewWeight = m_RaceInfo.FacialWeights.AddNew(); pNewWeight->CopyFull(pWeight); AddWeightList(pNewWeight); } } *pResult = SRRL_DROPCHECK_OK; }
void SrCreateLvlListInfo (CSrLvlListInfoArray& InfoArray, CSrCobjRecord& Record) { CSrSubrecord* pSubrecord; CSrCntoSubrecord* pCnto; CSrCoedSubrecord* pCoed; srlvllistinfo_t* pNewInfo; int Position; InfoArray.Destroy(); pSubrecord = Record.FindFirstSubrecord(SR_NAME_CNTO, Position); while (pSubrecord != NULL) { pCnto = SrCastClass(CSrCntoSubrecord, pSubrecord); if (pCnto != NULL) { pNewInfo = InfoArray.AddNew(); pNewInfo->pCnto = new CSrCntoSubrecord; pNewInfo->pCnto->CopyFull(pCnto); pSubrecord = Record.GetSubrecord(Position + 1); pCoed = SrCastClassNull(CSrCoedSubrecord, pSubrecord); if (pCoed != NULL) { pNewInfo->pCoed = new CSrCoedSubrecord; pNewInfo->pCoed->CopyFull(pCoed); } } pSubrecord = Record.FindNextSubrecord(SR_NAME_CNTO, Position); } }
void CSrScrlView::GetCurrentEffect (void) { CString Buffer; if (m_pCurrentEffect == NULL) return; if (m_pCurrentEffect->pEffectData) { m_Magnitude.GetWindowText(Buffer); m_pCurrentEffect->pEffectData->SetMagnitude((float) atof(Buffer)); m_Area.GetWindowText(Buffer); m_pCurrentEffect->pEffectData->SetArea(atoi(Buffer)); m_Duration.GetWindowText(Buffer); m_pCurrentEffect->pEffectData->SetDuration(atoi(Buffer)); } if (m_pCurrentEffect->pEffect) { m_EffectName.GetWindowText(Buffer); Buffer.Trim(); if (Buffer.IsEmpty()) { m_pCurrentEffect->pEffect->SetValue(0); } else { CSrIdRecord* pRecord = GetInputRecord()->GetParent()->FindEditorID(Buffer); if (pRecord) m_pCurrentEffect->pEffect->SetValue(pRecord->GetFormID()); } } for (dword i = 0; i < m_Effects.GetSize(); ++i) { srrlcustomdata_t* pCustomData = (srrlcustomdata_t *) m_EffectList.GetItemData(i); if (pCustomData == NULL) continue; CSrFormidSubrecord* pEffect = SrCastClassNull(CSrFormidSubrecord, pCustomData->Subrecords[0]); if (pEffect == NULL) continue; if (pEffect != m_pCurrentEffect->pEffect) continue; pCustomData->UserCount = m_pCurrentEffect->Conditions.GetSize(); pCustomData->Subrecords.Truncate(2); int CDIndex = 2; for (dword j = 0; j < m_pCurrentEffect->Conditions.GetSize(); ++j) { srconditioninfo_t* pCondInfo = m_pCurrentEffect->Conditions[j]; pCustomData->Subrecords.Add(&pCondInfo->Condition); if (pCondInfo->pParam1 != NULL) pCustomData->Subrecords.Add(pCondInfo->pParam1); if (pCondInfo->pParam2 != NULL) pCustomData->Subrecords.Add(pCondInfo->pParam2); } UpdateEffectList(i, true); break; } }
bool CSrVmadSubrecord::Copy (CSrSubrecord* pSubrecord) { CSrVmadSubrecord* pSource = SrCastClassNull(CSrVmadSubrecord, pSubrecord); if (pSource == NULL) return false; m_Data.Copy(pSource->m_Data); UpdateRawData(); return true; }
/*=========================================================================== * * Function - bool SrSelectKeyword (EditorID, pRecordHandler, pFilter); * *=========================================================================*/ bool l_IsTypeKeywordFilter (CSrRecord* pRecord, long UserData) { const char* pFilter = (const char *) UserData; if (pFilter == NULL) return true; CSrKywdRecord* pKeyword = SrCastClassNull(CSrKywdRecord, pRecord); if (pKeyword == NULL) return false; size_t Length = strlen(pFilter); return strnicmp(pKeyword->GetEditorID(), pFilter, Length) == 0; }
void CSrFlstRecord::AddItem (const srformid_t FormID) { CSrSubrecord* pSubrecord = AddNewSubrecord(SR_NAME_LNAM); CSrFormidSubrecord* pFormID = SrCastClassNull(CSrFormidSubrecord, pSubrecord); if (pFormID != NULL) { pFormID->InitializeNew(); pFormID->SetValue(FormID); } }
void CSrScrlView::GetControlData (void) { CSrSubrecord* pNewEffect; CSrSubrecord* pNewEffectData; CSrSubrecord* pNewCondition; CSrRecordDialog::GetControlData(); GetCurrentEffect(); CSrScrlRecord* pScroll = SrCastClassNull(CSrScrlRecord, GetOutputRecord()); if (pScroll == NULL) return; pScroll->DeleteSubrecords(SR_NAME_EFID); pScroll->DeleteSubrecords(SR_NAME_EFIT); pScroll->DeleteSubrecords(SR_NAME_CTDA); pScroll->DeleteSubrecords(SR_NAME_CIS1); pScroll->DeleteSubrecords(SR_NAME_CIS2); for (dword i = 0; i < m_Effects.GetSize(); ++i) { srscrl_effectdata_t* pEffect = m_Effects[i]; if (pEffect == NULL || pEffect->pEffect == NULL || pEffect->pEffectData == NULL) continue; pNewEffect = pScroll->AddNewSubrecord(SR_NAME_EFID); if (pNewEffect) pNewEffect->Copy(pEffect->pEffect); pNewEffectData = pScroll->AddNewSubrecord(SR_NAME_EFIT); if (pNewEffectData) pNewEffectData->Copy(pEffect->pEffectData); for (dword j = 0; j < pEffect->Conditions.GetSize(); ++j) { srconditioninfo_t* pCondInfo = pEffect->Conditions[j]; CSrCtdaSubrecord* pCondition = &pCondInfo->Condition; if (pCondition == NULL) continue; pNewCondition = pScroll->AddNewSubrecord(SR_NAME_CTDA); if (pNewCondition) pNewCondition->Copy(pCondition); if (pCondInfo->pParam1) { CSrSubrecord* pNewParam = pScroll->AddNewSubrecord(SR_NAME_CIS1); if (pNewParam) pNewParam->Copy(pCondInfo->pParam1); } if (pCondInfo->pParam2) { CSrSubrecord* pNewParam = pScroll->AddNewSubrecord(SR_NAME_CIS2); if (pNewParam) pNewParam->Copy(pCondInfo->pParam2); } } } }
void CSrRacePageHead1::UpdateMpaList (const int ListIndex, const bool Update) { srrlcustomdata_t* pCustomData = m_MpaList.GetCustomData(ListIndex); CString Buffer; if (Update) m_MpaList.UpdateRecord(ListIndex); if (pCustomData == NULL) return; CSrDwordSubrecord* pIndex = SrCastClassNull(CSrDwordSubrecord, pCustomData->Subrecords[0]); CSrMpavSubrecord* pData = SrCastClassNull(CSrMpavSubrecord, pCustomData->Subrecords[1]); if (pIndex == NULL || pData == NULL) return; Buffer.Format("%d", pIndex->GetValue()); m_MpaList.SetCustomField(ListIndex, SR_FIELD_LISTUNKNOWN1, Buffer); for (dword i = 0; i < 8; ++i) { Buffer.Format("%08X", pData->GetMpavData().Unknown[i]); m_MpaList.SetCustomField(ListIndex, SR_FIELD_LISTUNKNOWN2 + i, Buffer); } }
CSrStringSubrecord* CSrSndrRecord::AddSoundFile (const char* pFilename) { CSrStringSubrecord* pNewString; if (pFilename == NULL || pFilename[0] == 0) return NULL; CSrSubrecord* pSubrecord = AddNewSubrecord(SR_NAME_ANAM); pNewString = SrCastClassNull(CSrStringSubrecord, pSubrecord); if (pNewString == NULL) return NULL; pNewString->InitializeNew(); pNewString->SetString(pFilename); return pNewString; }
CSrLvloSubrecord* CSrLvliRecord::AddItem (const srformid_t FormID, const dword Level, const dword Count) { if (GetListCount() > SR_LVLO_MAXCOUNT) return NULL; CSrSubrecord* pSubrecord = AddNewSubrecord(SR_NAME_LVLO); CSrLvloSubrecord* pNewLvlo = SrCastClassNull(CSrLvloSubrecord, pSubrecord); if (pNewLvlo == NULL) return NULL; pNewLvlo->InitializeNew(); pNewLvlo->GetListData().Count = Count; pNewLvlo->GetListData().Level = Level; pNewLvlo->GetListData().FormID = FormID; SetListCount(GetListCount() + 1); return pNewLvlo; }
void SrCreateLvlListInfoCustomData (srrlcustomdata_t& CustomData, srlvllistinfo_t& Info, CSrRecordHandler* pHandler) { CSrBaseRecord* pBaseRecord; CSrIdRecord* pIdRecord; CustomData.Subrecords.Destroy(); if (Info.pCnto != NULL) CustomData.Subrecords.Add(Info.pCnto); if (Info.pLvlo != NULL) CustomData.Subrecords.Add(Info.pLvlo); if (Info.pCoed != NULL) CustomData.Subrecords.Add(Info.pCoed); if (pHandler == NULL) return; pBaseRecord = pHandler->FindFormID(Info.GetFormID()); pIdRecord = SrCastClassNull(CSrIdRecord, pBaseRecord); CustomData.pRecord = pIdRecord; }
void CSrRacePageFace::UpdateWeightList (const int ListIndex, const bool Update) { srrlcustomdata_t* pCustomData = m_FaceWeights.GetCustomData(ListIndex); CSrPhwtSubrecord* pWeight; CString Buffer; if (Update) m_FaceWeights.UpdateRecord(ListIndex); if (pCustomData == NULL) return; pWeight = SrCastClassNull(CSrPhwtSubrecord, pCustomData->Subrecords[0]); if (pWeight == NULL) return; for (dword i = 0; i < 16; ++i) { Buffer.Format("%g", pWeight->GetPhwtData().Unknown[i]); m_FaceWeights.SetCustomField(ListIndex, SR_FIELD_LISTUNKNOWN1 + i, Buffer); } }
/*=========================================================================== * * Class CSrLvlnView Method - void UpdateItem (ListIndex, pInfo); * *=========================================================================*/ void CSrLvlnView::UpdateItem (const int ListIndex, srlvllistinfo_t* pInfo) { CSrBaseRecord* pBaseRecord; CSrIdRecord* pRecord; CString Buffer; m_ItemList.UpdateRecord(ListIndex); pBaseRecord = m_pRecordHandler->FindFormID(pInfo->GetFormID()); pRecord = SrCastClassNull(CSrIdRecord, pBaseRecord); if (pRecord == NULL) { Buffer.Format("0x%08X", pInfo->GetFormID()); m_ItemList.SetCustomField(ListIndex, SR_FIELD_FORMID, Buffer); m_ItemList.SetCustomField(ListIndex, SR_FIELD_EDITORID, ""); } /* Set custom fields */ Buffer.Format("%u", (dword) pInfo->GetLevel()); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LEVEL, Buffer); Buffer.Format("%u", (dword) pInfo->GetCount()); m_ItemList.SetCustomField(ListIndex, SR_FIELD_ITEMCOUNT, Buffer); if (pInfo->pCoed != NULL) { m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTFACTION, m_pRecordHandler->GetEditorID(pInfo->pCoed->GetCoedData().FactionID)); Buffer.Format("%d", (int) pInfo->pCoed->GetCoedData().MinRank); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTMINRANK, Buffer); Buffer.Format("%g", pInfo->pCoed->GetCoedData().Condition); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTCONDITION, Buffer); } else { m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTFACTION, ""); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTMINRANK, ""); m_ItemList.SetCustomField(ListIndex, SR_FIELD_LISTCONDITION, ""); } }
bool CSrArraySubrecord::Copy (CSrSubrecord* pSource) { Destroy(); CSrArraySubrecord* pSrcArray = SrCastClassNull(CSrArraySubrecord, pSource); if (pSrcArray == NULL) return false; m_RecordType = pSrcArray->m_RecordType; m_RecordSize = pSrcArray->m_RecordSize;; for (dword i = 0; i < pSrcArray->m_Subrecords.GetSize(); ++i) { CSrSubrecord* pSrc = pSrcArray->m_Subrecords[i]; if (pSrc == NULL) continue; CSrSubrecord* pNew = pSrc->CreateCopy(); m_Subrecords.Add(pNew); } return true; }
/*=========================================================================== * * Class CSrScrlView Event - int OnDropCustomEffectData (DropItems); * *=========================================================================*/ int CSrScrlView::OnDropCustomEffectData (srrldroprecords_t& DropItems) { CSrFormidSubrecord* pEffect; CSrEfitSubrecord* pEffectData; srrlcustomdata_t* pCustomData; srscrl_effectdata_t* pEffectInfo; dword Index; GetCurrentEffect(); /* Check all custom data dropped */ for (Index = 0; Index < DropItems.pCustomDatas->GetSize(); ++Index) { pCustomData = DropItems.pCustomDatas->GetAt(Index); if (pCustomData->pRecord == NULL) return (SRRL_DROPCHECK_ERROR); /* Check for dragging another effect record */ pEffect = SrCastClassNull(CSrFormidSubrecord, pCustomData->Subrecords[0]); if (pEffect == NULL) return (SRRL_DROPCHECK_ERROR); pEffectData = SrCastClassNull(CSrEfitSubrecord, pCustomData->Subrecords[1]); if (pEffectData == NULL) return (SRRL_DROPCHECK_ERROR); /* If we're just checking */ if (DropItems.Notify.code == ID_SRRECORDLIST_CHECKDROP) continue; pEffectInfo = m_Effects.AddNew(); if (pEffectInfo == NULL) continue; CSrSubrecord* pNewSubrecord = pCustomData->pRecord->CreateSubrecord(SR_NAME_EFID); pEffectInfo->pEffect = SrCastClassNull(CSrFormidSubrecord, pNewSubrecord); pNewSubrecord = pCustomData->pRecord->CreateSubrecord(SR_NAME_EFIT); pEffectInfo->pEffectData = SrCastClassNull(CSrEfitSubrecord, pNewSubrecord); if (pEffectInfo->pEffect == NULL || pEffectInfo->pEffectData == NULL) { m_Effects.Delete(pEffectInfo); continue; } pEffectInfo->pEffect->Copy(pEffect); pEffectInfo->pEffectData->Copy(pEffectData); for (dword i = 2; i < pCustomData->Subrecords.GetSize(); ++i) { if (pCustomData->Subrecords[i] == NULL) continue; if (pCustomData->Subrecords[i]->GetRecordType() != SR_NAME_CTDA) continue; srconditioninfo_t* pNewCond = pEffectInfo->Conditions.AddNew(); pNewCond->Condition.Copy(pCustomData->Subrecords[i]); if (pCustomData->Subrecords[i+1] == NULL) continue; if (pCustomData->Subrecords[i+1]->GetRecordType() == SR_NAME_CIS1) pNewCond->CopyParam1(pCustomData->Subrecords[i+1]); else if (pCustomData->Subrecords[i+1]->GetRecordType() == SR_NAME_CIS2) pNewCond->CopyParam2(pCustomData->Subrecords[i+1]); if (pCustomData->Subrecords[i+2] == NULL) continue; if (pCustomData->Subrecords[i+2]->GetRecordType() == SR_NAME_CIS2 && pNewCond->pParam2 == NULL) pNewCond->CopyParam2(pCustomData->Subrecords[i+1]); } AddEffectList(pEffectInfo); } return (SRRL_DROPCHECK_OK); }
void CSrScrlView::CreateEffectArray (void) { CSrScrlRecord* pScroll; CSrSubrecord* pSubrecord; CSrSubrecord* pNewSubrecord; CSrFormidSubrecord* pEffectID; srscrl_effectdata_t* pEffectData; int Position; int EfitCount; m_Effects.Empty(); pScroll = SrCastClassNull(CSrScrlRecord, GetInputRecord()); if (pScroll == NULL) return; pSubrecord = pScroll->FindFirstSubrecord(SR_NAME_EFID, Position); while (pSubrecord) { pEffectID = SrCastClass(CSrFormidSubrecord, pSubrecord); if (pEffectID == NULL) goto CreateEffectArray_EndLoop; pEffectData = new srscrl_effectdata_t; m_Effects.Add(pEffectData); pSubrecord = GetInputRecord()->CreateSubrecord(SR_NAME_EFID); pEffectData->pEffect = SrCastClassNull(CSrFormidSubrecord, pSubrecord); if (pEffectData->pEffect == NULL) goto CreateEffectArray_EndLoop; pEffectData->pEffect->InitializeNew(); pEffectData->pEffect->Copy(pEffectID); EfitCount = 0; for (int i = Position + 1; i < (int) pScroll->GetNumSubrecords(); ++i) { pSubrecord = pScroll->GetSubrecord(i); if (pSubrecord == NULL) continue; if (pSubrecord->GetRecordType() == SR_NAME_EFID) break; if (pSubrecord->GetRecordType() == SR_NAME_CTDA) { srconditioninfo_t* pNewCond = new srconditioninfo_t; pNewCond->Condition.Copy(pSubrecord); pEffectData->Conditions.Add(pNewCond); pSubrecord = pScroll->GetSubrecord(i+1); if (pSubrecord == NULL) continue; if (pSubrecord->GetRecordType() == SR_NAME_CIS1) pNewCond->CopyParam1(pSubrecord); else if (pSubrecord->GetRecordType() == SR_NAME_CIS2) pNewCond->CopyParam2(pSubrecord); pSubrecord = pScroll->GetSubrecord(i+2); if (pSubrecord == NULL) continue; if (pSubrecord->GetRecordType() == SR_NAME_CIS2 && pNewCond->pParam2 == NULL) pNewCond->CopyParam2(pSubrecord); } else if (pSubrecord->GetRecordType() == SR_NAME_EFIT) { ++EfitCount; if (EfitCount > 1) SystemLog.Printf("WARNING: More than one EFIT per EFID found in SCRL 0x%08X!", pScroll->GetFormID()); pNewSubrecord = GetInputRecord()->CreateSubrecord(SR_NAME_EFIT); pEffectData->pEffectData = SrCastClassNull(CSrEfitSubrecord, pNewSubrecord); if (pEffectData->pEffectData == NULL) continue; pEffectData->pEffectData->InitializeNew(); pEffectData->pEffectData->Copy(pSubrecord); } else { SystemLog.Printf("WARNING: Unknown subrecord type %4.4s found in SCRL effects!", pSubrecord->GetRecordType().Name); } } CreateEffectArray_EndLoop: pSubrecord = pScroll->FindNextSubrecord(SR_NAME_EFID, Position); } }