From 5c9d97b882e2aad735c8ebb4993a12ce77cb5d5e Mon Sep 17 00:00:00 2001 From: Coruja Date: Wed, 9 Jan 2019 21:00:01 -0200 Subject: [PATCH] Added initial support for MultiCollection.uop multi format (still incomplete) MultiCollection.uop support is required to use new TOL multis, which includes many new keeps/castles This commit is only to make Sphere detect when MultiCollection.uop is found on UO folder to make it override old multi.mul + multi.idx. But the code is commented out, still need to find a way to read MultiCollection.uop data properly PS: I don't know how to deal with UO file reading so maybe someday this thing will work, or maybe not. If someone want try it, these OrionUO commits should help with something: https://github.com/Hotride/OrionUO/commit/70eab08d36080cce310b1b072397e84d0a71ad5a https://github.com/Hotride/OrionUO/commit/7931745586e70e2e31a78f83fcbc418fd6e16c65 --- docs/REVISIONS-56-SERIES.TXT | 10 ++++++- src/common/CGrayData.cpp | 58 ++++++++++++++++++++---------------- src/common/CGrayInst.cpp | 14 ++++++++- src/common/CGrayInst.h | 4 ++- src/common/graymul.h | 4 +-- 5 files changed, 59 insertions(+), 31 deletions(-) diff --git a/docs/REVISIONS-56-SERIES.TXT b/docs/REVISIONS-56-SERIES.TXT index 633c2bc6c..f74920dbd 100644 --- a/docs/REVISIONS-56-SERIES.TXT +++ b/docs/REVISIONS-56-SERIES.TXT @@ -1326,4 +1326,12 @@ Fixed: Recall spell on ship keys not working correctly. 30-12-2018, Coruja Added: Missing functionality of item ATTR flags 'attr_blessed', 'attr_insured' and 'attr_nodroptrade' Changed: Updated REPAIR function on craft skills. -[sphere_msgs.scp]: Updated 'repair_*' messages and added new 'item_cantdroptrade' \ No newline at end of file +[sphere_msgs.scp]: Updated 'repair_*' messages and added new 'item_cantdroptrade' + +31-12-2018, Coruja +[items/multis/multis_foundations.scp]: Added new TOL house foundations +[items/multis/multis_houses.scp]: Added new TOL keeps/castles +[items/sphere_item_artifacts.scp]: Misc improvements and added new Artifacts of the Cult +[items/sphere_item_artifacts_minor.scp]: Misc improvements +[items/sphere_item_artifacts_tokuno.scp]: Misc improvements +[items/sphere_item_magic_wands.scp]: Removed unused file \ No newline at end of file diff --git a/src/common/CGrayData.cpp b/src/common/CGrayData.cpp index ac68e7e23..597c35d7b 100644 --- a/src/common/CGrayData.cpp +++ b/src/common/CGrayData.cpp @@ -332,55 +332,61 @@ size_t CGrayMulti::Load( MULTI_TYPE id ) ADDTOCALLSTACK("CGrayMulti::Load"); // Just load the whole thing. - CUOIndexRec Index; - if ( (id >= MULTI_QTY) || !g_Install.ReadMulIndex(VERFILE_MULTIIDX, VERFILE_MULTI, id, Index) ) + if ( id >= MULTI_QTY ) return 0; Release(); InitCacheTime(); // This is invalid ! m_id = id; - switch ( g_Install.GetMulFormat( VERFILE_MULTIIDX ) ) + //if ( g_Install.m_IsMultiUopFormat ) + // TO-DO: add support to read new multi UOP format here (MultiCollection.uop) + //else { - case VERFORMAT_HIGHSEAS: // high seas multi format (CUOMultiItemRec2) - m_iItemQty = Index.GetBlockLength() / sizeof(CUOMultiItemRec2); - m_pItems = new CUOMultiItemRec2 [ m_iItemQty ]; - ASSERT( m_pItems ); - - ASSERT( (sizeof(m_pItems[0]) * m_iItemQty) >= Index.GetBlockLength() ); - if ( ! g_Install.ReadMulData( VERFILE_MULTI, Index, static_cast (m_pItems) )) - return 0; - break; + CUOIndexRec index; + if ( !g_Install.ReadMulIndex(VERFILE_MULTIIDX, VERFILE_MULTI, id, index) ) + return 0; - case VERFORMAT_ORIGINAL: // old format (CUOMultiItemRec) - default: - m_iItemQty = Index.GetBlockLength() / sizeof(CUOMultiItemRec); - m_pItems = new CUOMultiItemRec2 [ m_iItemQty ]; - ASSERT( m_pItems ); + if ( g_Install.GetMulFormat(VERFILE_MULTIIDX) == VERFORMAT_HIGHSEAS ) + { + // High Seas multi format (CUOMultiItemRec2) + m_iItemQty = index.GetBlockLength() / sizeof(CUOMultiItemRec2); + m_pItems = new CUOMultiItemRec2[m_iItemQty]; + ASSERT(m_pItems); - CUOMultiItemRec* pItems = new CUOMultiItemRec[m_iItemQty]; - ASSERT( (sizeof(pItems[0]) * m_iItemQty) >= Index.GetBlockLength() ); - if ( ! g_Install.ReadMulData( VERFILE_MULTI, Index, static_cast (pItems) )) + ASSERT(m_iItemQty * sizeof(m_pItems[0]) >= index.GetBlockLength()); + if ( !g_Install.ReadMulData(VERFILE_MULTI, index, static_cast(m_pItems)) ) + return 0; + } + else + { + // Old multi format (CUOMultiItemRec) + m_iItemQty = index.GetBlockLength() / sizeof(CUOMultiItemRec); + m_pItems = new CUOMultiItemRec2[m_iItemQty]; + ASSERT(m_pItems); + + CUOMultiItemRec *pItems = new CUOMultiItemRec[m_iItemQty]; + ASSERT(m_iItemQty * sizeof(pItems[0]) >= index.GetBlockLength()); + if ( !g_Install.ReadMulData(VERFILE_MULTI, index, static_cast(pItems)) ) { delete[] pItems; return 0; } - // copy to new format - for (size_t i = 0; i < m_iItemQty; i++) + // Copy to new format + for ( size_t i = 0; i < m_iItemQty; ++i ) { m_pItems[i].m_wTileID = pItems[i].m_wTileID; m_pItems[i].m_dx = pItems[i].m_dx; m_pItems[i].m_dy = pItems[i].m_dy; m_pItems[i].m_dz = pItems[i].m_dz; m_pItems[i].m_visible = pItems[i].m_visible; - m_pItems[i].m_unknown = 0; + m_pItems[i].m_shipAccess = 0; } - delete[] pItems; - break; + } } HitCacheTime(); - return( m_iItemQty ); + return m_iItemQty; } diff --git a/src/common/CGrayInst.cpp b/src/common/CGrayInst.cpp index 0451bdd87..d3e21b405 100644 --- a/src/common/CGrayInst.cpp +++ b/src/common/CGrayInst.cpp @@ -150,7 +150,7 @@ bool CGrayInstall::OpenFile(VERFILE_TYPE i) if ( !pFile->GetFilePath().IsEmpty() && pFile->Open(pFile->GetFilePath(), OF_READ|OF_SHARE_DENY_WRITE) ) return true; - LPCTSTR pszFileName = GetBaseFileName(static_cast(i)); + LPCTSTR pszFileName = GetBaseFileName(i); if ( !pszFileName ) return false; @@ -346,6 +346,18 @@ VERFILE_TYPE CGrayInstall::OpenFiles(DWORD dwMask) } break; } + /*case VERFILE_MULTIIDX: + { + // If MultiCollection.uop is found, use it instead multi.idx + multi.mul (STILL INCOMPLETE) + OpenFile(m_File[VERFILE_MULTI], "MultiCollection.uop", OF_READ|OF_SHARE_DENY_WRITE); + if ( m_File[VERFILE_MULTI].IsFileOpen() ) + { + m_IsMultiUopFormat = true; + ++i; // skip VERFILE_MULTI + break; + } + // fall through + }*/ default: { if ( !OpenFile(static_cast(i)) ) diff --git a/src/common/CGrayInst.h b/src/common/CGrayInst.h index 298c8bedf..131286846 100644 --- a/src/common/CGrayInst.h +++ b/src/common/CGrayInst.h @@ -22,13 +22,15 @@ extern struct CGrayInstall CGrayInstall() { memset(m_FileFormat, 0, sizeof(m_FileFormat)); + m_IsMultiUopFormat = false; memset(m_IsMapUopFormat, 0, sizeof(m_IsMapUopFormat)); memset(m_UopMapAddress, 0, sizeof(m_UopMapAddress)); }; public: VERFILE_FORMAT m_FileFormat[VERFILE_QTY]; // File format versions - bool m_IsMapUopFormat[256]; // True for maps that are uop format + bool m_IsMultiUopFormat; // True when multi file is MultiCollection.uop instead multi.mul (STILL INCOMPLETE) + bool m_IsMapUopFormat[256]; // True when map file is map[x]LegacyMUL.uop instead map[x].mul MapAddress m_UopMapAddress[256][256]; // For UOP parsing (note: might need to be ajusted later if format changes) CGFile m_File[VERFILE_QTY]; // List of files to access diff --git a/src/common/graymul.h b/src/common/graymul.h index 4de0f905f..311548f8e 100644 --- a/src/common/graymul.h +++ b/src/common/graymul.h @@ -1712,8 +1712,8 @@ struct CUOMultiItemRec2 // (Multi.mul, High Seas+) signed short m_dx; // signed delta. signed short m_dy; signed short m_dz; - DWORD m_visible; // 0 or 1 (non-visible items are things like doors and signs) - DWORD m_unknown; // unknown data + DWORD m_visible; // 0 or 1 (non-static item, like doors and signs) + DWORD m_shipAccess; // 0 or 1 (rope item used to enter/exit galleons) ITEMID_TYPE GetDispID() const {