[Sphere-axis-commits] CVS: Axis/S_Sphere52 Item.cpp,1.4,1.5 Item.h,1.3,1.4 itemeditdlg.cpp,1.7,1.8 S
Brought to you by:
pesterle
From: Philip E. <pes...@us...> - 2003-08-05 20:43:08
|
Update of /cvsroot/sphere-axis/Axis/S_Sphere52 In directory sc8-pr-cvs1:/tmp/cvs-serv24790/S_Sphere52 Modified Files: Item.cpp Item.h itemeditdlg.cpp ScriptsMain.cpp ScriptsMain.h WorldItem.cpp Log Message: Base items loaded as part of the CWorldItem::LoadBase() method are now cached. Index: Item.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/Item.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Item.cpp 23 Jul 2003 19:10:57 -0000 1.4 --- Item.cpp 5 Aug 2003 20:43:05 -0000 1.5 *************** *** 85,89 **** this->m_iCharges = 0; this->m_iSpeed = 0; ! this->m_wAttr = 0; this->m_csDupeItem = _T(""); this->m_dwMore1 = 0; --- 85,89 ---- this->m_iCharges = 0; this->m_iSpeed = 0; ! this->m_dwAttr = 0; this->m_csDupeItem = _T(""); this->m_dwMore1 = 0; *************** *** 153,157 **** this->m_iSpeed = pCopy->m_iSpeed; this->m_iTimer = pCopy->m_iTimer; ! this->m_wAttr = pCopy->m_wAttr; this->m_csDupeItem = pCopy->m_csDupeItem; this->m_csDispID = pCopy->m_csDispID; --- 153,157 ---- this->m_iSpeed = pCopy->m_iSpeed; this->m_iTimer = pCopy->m_iTimer; ! this->m_dwAttr = pCopy->m_dwAttr; this->m_csDupeItem = pCopy->m_csDupeItem; this->m_csDispID = pCopy->m_csDispID; *************** *** 492,497 **** case 19: bTagsHandled[19] = true; ! if (this->m_wAttr != 0) ! csNewVal.Format(_T("ATTR=%04x\n"), this->m_wAttr); break; case 20: --- 492,497 ---- case 19: bTagsHandled[19] = true; ! if (this->m_dwAttr != 0) ! csNewVal.Format(_T("ATTR=%08x\n"), this->m_dwAttr); break; case 20: *************** *** 676,680 **** break; case 19: // ATTR ! this->m_wAttr = (WORD) ahextoi(csValue); break; case 20: // SPEED this->m_iSpeed = _tstoi(csValue); break; --- 676,680 ---- break; case 19: // ATTR ! this->m_dwAttr = ahextoi(csValue); break; case 20: // SPEED this->m_iSpeed = _tstoi(csValue); break; Index: Item.h =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/Item.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Item.h 23 Jul 2003 19:10:57 -0000 1.3 --- Item.h 5 Aug 2003 20:43:05 -0000 1.4 *************** *** 42,46 **** void Copy(CItem *pCopy); void Dupe(CItem *); ! WORD m_wAttr; CIntRange m_irSellValue; CIntRange m_irBuyValue; --- 42,46 ---- void Copy(CItem *pCopy); void Dupe(CItem *); ! DWORD m_dwAttr; CIntRange m_irSellValue; CIntRange m_irBuyValue; Index: itemeditdlg.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/itemeditdlg.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** itemeditdlg.cpp 24 Jul 2003 20:12:44 -0000 1.7 --- itemeditdlg.cpp 5 Aug 2003 20:43:05 -0000 1.8 *************** *** 541,545 **** EnableControls(true); m_ccbDupeitem.SetCurSel(-1); ! if (pItem->m_wAttr & 0x20) { m_cbMagical.SetCheck(1); --- 541,545 ---- EnableControls(true); m_ccbDupeitem.SetCurSel(-1); ! if (pItem->m_dwAttr & 0x20) { m_cbMagical.SetCheck(1); *************** *** 1095,1099 **** m_pItem->m_irSellValue.min = tmp; } ! m_pItem->m_wAttr = ( this->m_cbMagical.GetCheck() == 1 ) ? 0x0020 : 0x0000; } else --- 1095,1099 ---- m_pItem->m_irSellValue.min = tmp; } ! m_pItem->m_dwAttr = ( this->m_cbMagical.GetCheck() == 1 ) ? 0x0020 : 0x0000; } else *************** *** 1138,1142 **** m_pItem->m_irSellValue.max = 0; m_pItem->m_irSellValue.min = 0; ! m_pItem->m_wAttr = 0; m_pItem->m_csDispID = _T(""); } --- 1138,1142 ---- m_pItem->m_irSellValue.max = 0; m_pItem->m_irSellValue.min = 0; ! m_pItem->m_dwAttr = 0; m_pItem->m_csDispID = _T(""); } Index: ScriptsMain.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/ScriptsMain.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** ScriptsMain.cpp 4 Aug 2003 14:17:41 -0000 1.30 --- ScriptsMain.cpp 5 Aug 2003 20:43:05 -0000 1.31 *************** *** 165,168 **** --- 165,169 ---- m_pRCDlg = NULL; m_bDeleteRC = false; + m_aItemCache.MaxEntries(4096); } *************** *** 3571,3573 **** --- 3572,3614 ---- else return m_vMulFiles[index]; + } + + CItem * CScriptsMain::LoadItemFromCache(CString sID) + { + int idx = m_aItemCache.Find(sID); + if ( idx != -1 ) + { + CItem * pItem = m_aItemCache.GetAt(idx); + m_aItemCache.Promote(pItem); + return pItem; + } + + // Find the base script + idx =m_aItems.Find(sID); + if ( idx == -1 ) + { + DWORD dwDef = DefLookup(sID); + if ( dwDef != 0 ) + { + CString csDef; + csDef.Format(_T("0%x"), dwDef); + idx = Main->m_pScripts->m_aItems.Find(csDef); + } + if ( idx == -1 ) + { + LOG(locale->String(IDS_SCRIPTS_NOBASEITEM), sID); + return NULL; + } + } + CDisplayedScriptBase * pObject = (CDisplayedScriptBase *) Main->m_pScripts->m_aItems.GetAt(idx); + if ( !pObject ) + return false; + + // Load the item and add it to the cache + CItem *pItem = new CItem; + pItem->CopyBase(pObject); + pItem->Load(_T("[%s]")); + + m_aItemCache.Cache(pItem); + return pItem; } Index: ScriptsMain.h =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/ScriptsMain.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** ScriptsMain.h 27 Jul 2003 20:44:55 -0000 1.20 --- ScriptsMain.h 5 Aug 2003 20:43:05 -0000 1.21 *************** *** 32,35 **** --- 32,37 ---- #include "MapScriptEditDlg.h" #include "RemoteConsoleDlg.h" + #include "ScriptCache.h" + #include "Item.h" #include <vector> *************** *** 359,362 **** --- 361,366 ---- void DeleteRC() { m_bDeleteRC = true; } + CItem * LoadItemFromCache(CString sID); + protected: bool m_bDefsLoaded; *************** *** 455,457 **** --- 459,462 ---- vector<CString> m_vMulFiles; CRemoteConsoleDlg * m_pRCDlg; + CScriptCache<class CItem*> m_aItemCache; }; Index: WorldItem.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/S_Sphere52/WorldItem.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** WorldItem.cpp 4 Aug 2003 14:17:41 -0000 1.4 --- WorldItem.cpp 5 Aug 2003 20:43:05 -0000 1.5 *************** *** 203,234 **** CString sBase; sBase.Format(_T("%04x"), ahextoi(m_csBaseID)); ! int idx = Main->m_pScripts->m_aItems.Find(sBase); ! if ( idx == -1 ) ! { ! DWORD dwDef = DefLookup(m_csBaseID); ! if ( dwDef != 0 ) ! { ! CString csDef; ! csDef.Format(_T("0%x"), dwDef); ! idx = Main->m_pScripts->m_aItems.Find(csDef); ! } ! if ( idx == -1 ) ! { ! LOG(locale->String(IDS_SCRIPTS_NOBASEITEM), m_csBaseID); ! return false; ! } ! } ! CDisplayedScriptBase * pObject = (CDisplayedScriptBase *) Main->m_pScripts->m_aItems.GetAt(idx); ! if ( !pObject ) return false; ! CItem base; ! base.CopyBase(pObject); ! base.Load(_T("[%s]")); ! ! this->m_dwItemType = base.m_dwType; ! this->m_dwMore1 = base.m_dwMore1; ! this->m_dwMore2 = base.m_dwMore2; ! this->m_dwAttr = (DWORD) base.m_wAttr; ! // this->m_csName = base.m_csItemName; -- Don't do this...we should use the tiledata for the name unless the name is set in the worldfile return true; --- 203,214 ---- CString sBase; sBase.Format(_T("%04x"), ahextoi(m_csBaseID)); ! // Load the base item from cache ! CItem * pBase = Main->m_pScripts->LoadItemFromCache(sBase); ! if ( !pBase ) return false; ! this->m_dwItemType = pBase->m_dwType; ! this->m_dwMore1 = pBase->m_dwMore1; ! this->m_dwMore2 = pBase->m_dwMore2; ! this->m_dwAttr = pBase->m_dwAttr; return true; |