Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[PLUS] CatalogIndex clean up and sub pages fix (done properly).
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Damien" data-source="post: 429717" data-attributes="member: 72299"><p>I've took the time to clean up one of the worst written composers in Plus, which causes alot of problems for people adding sub pages to categories in the catalog, or sub pages of sub pages. This "fix" or clean up code allows you to add as many sub pages as you like, as well as not foreaching the catalog pages multiple times (for counts ext.). But enough of that, let's get cleaning <img src="/styles/default/xenforo/smilies/emojione/biggrin.png" class="smilie" loading="lazy" alt=":D" title="Big Grin :D" data-shortname=":D" />.</p><p></p><p>Firstly in CatalogManager.cs find this code:</p><p>[CODE]</p><p>public ICollection<CatalogPage> GetPages()</p><p>{</p><p> return _pages.Values;</p><p>}</p><p>[/CODE]</p><p></p><p>Changing it to this:</p><p>[CODE]</p><p>public ICollection<CatalogPage> GetPages(GameClient session, int pageId)</p><p>{</p><p> List<CatalogPage> pages = new List<CatalogPage>();</p><p> foreach (CatalogPage page in this._pages.Values)</p><p> {</p><p> if (page.ParentId != pageId || page.MinimumRank > session.GetHabbo().Rank || (page.MinimumVIP > session.GetHabbo().VIPRank && session.GetHabbo().Rank == 1))</p><p> {</p><p> continue;</p><p> }</p><p> pages.Add(page);</p><p> }</p><p> return pages;</p><p>}</p><p>[/CODE]</p><p></p><p></p><p>Secondly in GetCatalogIndexEvent.cs find this code:</p><p>[CODE]</p><p>session.SendPacket(new CatalogIndexComposer(session, PlusEnvironment.GetGame().GetCatalog().GetPages()));</p><p>[/CODE]</p><p></p><p>Changing it to this:</p><p>[CODE]</p><p>session.SendPacket(new CatalogIndexComposer(session, PlusEnvironment.GetGame().GetCatalog().GetPages(session, -1)));</p><p>[/CODE]</p><p></p><p></p><p>And lastly in CatalogIndexComposer.cs replace the entire class with this:</p><p>[CODE]</p><p>public class CatalogIndexComposer : ServerPacket</p><p>{</p><p> public CatalogIndexComposer(GameClient session, ICollection<CatalogPage> pages)</p><p> : base(ServerPacketHeader.CatalogIndexMessageComposer)</p><p> {</p><p> base.WriteBoolean(true);</p><p> base.WriteInteger(0);</p><p> base.WriteInteger(-1);</p><p> base.WriteString("root");</p><p> base.WriteString("");</p><p> base.WriteInteger(0);</p><p></p><p> base.WriteInteger(pages.Count);</p><p> foreach (CatalogPage page in pages)</p><p> {</p><p> Append(session, page);</p><p> }</p><p></p><p> base.WriteBoolean(false);</p><p> base.WriteString("NORMAL");</p><p> }</p><p></p><p> public void Append(GameClient session, CatalogPage page)</p><p> {</p><p> ICollection<CatalogPage> pages = PlusEnvironment.GetGame().GetCatalog().GetPages(session, page.Id);</p><p></p><p> base.WriteBoolean(page.Visible);</p><p> base.WriteInteger(page.Icon);</p><p> base.WriteInteger(page.Enabled ? page.Id : -1);</p><p> base.WriteString(page.PageLink);</p><p> base.WriteString(page.Caption);</p><p></p><p> base.WriteInteger(page.ItemOffers.Count);</p><p> foreach (int key in page.ItemOffers.Keys)</p><p> {</p><p> base.WriteInteger(key);</p><p> }</p><p></p><p> base.WriteInteger(pages.Count);</p><p> foreach (CatalogPage nextPage in pages)</p><p> {</p><p> Append(session, nextPage);</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p></p><p>Now we're all done, enjoy, love you all, peace, dab emoji.</p><p>[USER=61877]@Muff[/USER] for helping test.</p><p>[USER=11276]@Dolan[/USER] for requesting this in the first place.</p><p>[USER=66193]@JynX[/USER] cause he's just sexy.</p></blockquote><p></p>
[QUOTE="Damien, post: 429717, member: 72299"] I've took the time to clean up one of the worst written composers in Plus, which causes alot of problems for people adding sub pages to categories in the catalog, or sub pages of sub pages. This "fix" or clean up code allows you to add as many sub pages as you like, as well as not foreaching the catalog pages multiple times (for counts ext.). But enough of that, let's get cleaning :D. Firstly in CatalogManager.cs find this code: [CODE] public ICollection<CatalogPage> GetPages() { return _pages.Values; } [/CODE] Changing it to this: [CODE] public ICollection<CatalogPage> GetPages(GameClient session, int pageId) { List<CatalogPage> pages = new List<CatalogPage>(); foreach (CatalogPage page in this._pages.Values) { if (page.ParentId != pageId || page.MinimumRank > session.GetHabbo().Rank || (page.MinimumVIP > session.GetHabbo().VIPRank && session.GetHabbo().Rank == 1)) { continue; } pages.Add(page); } return pages; } [/CODE] Secondly in GetCatalogIndexEvent.cs find this code: [CODE] session.SendPacket(new CatalogIndexComposer(session, PlusEnvironment.GetGame().GetCatalog().GetPages())); [/CODE] Changing it to this: [CODE] session.SendPacket(new CatalogIndexComposer(session, PlusEnvironment.GetGame().GetCatalog().GetPages(session, -1))); [/CODE] And lastly in CatalogIndexComposer.cs replace the entire class with this: [CODE] public class CatalogIndexComposer : ServerPacket { public CatalogIndexComposer(GameClient session, ICollection<CatalogPage> pages) : base(ServerPacketHeader.CatalogIndexMessageComposer) { base.WriteBoolean(true); base.WriteInteger(0); base.WriteInteger(-1); base.WriteString("root"); base.WriteString(""); base.WriteInteger(0); base.WriteInteger(pages.Count); foreach (CatalogPage page in pages) { Append(session, page); } base.WriteBoolean(false); base.WriteString("NORMAL"); } public void Append(GameClient session, CatalogPage page) { ICollection<CatalogPage> pages = PlusEnvironment.GetGame().GetCatalog().GetPages(session, page.Id); base.WriteBoolean(page.Visible); base.WriteInteger(page.Icon); base.WriteInteger(page.Enabled ? page.Id : -1); base.WriteString(page.PageLink); base.WriteString(page.Caption); base.WriteInteger(page.ItemOffers.Count); foreach (int key in page.ItemOffers.Keys) { base.WriteInteger(key); } base.WriteInteger(pages.Count); foreach (CatalogPage nextPage in pages) { Append(session, nextPage); } } } [/CODE] Now we're all done, enjoy, love you all, peace, dab emoji. [USER=61877]@Muff[/USER] for helping test. [USER=11276]@Dolan[/USER] for requesting this in the first place. [USER=66193]@JynX[/USER] cause he's just sexy. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[PLUS] CatalogIndex clean up and sub pages fix (done properly).
Top