Re: Emulating Habbo v14 - C++
Hey for those are curious.
Been nearly a month since I created this thread.
So far it's been fun and challenging!
When I first started this project, I was trying out a new coding standard and fleshing out my code - although It did not last long and resorted back to my coding standard; everything is now documented from low level to high level.
Packet Protocol
I had a good look at how I should tackle the packet protocol.
I've decided to split the client packets into handlers. Each client packet has it's own handler function in its respective file having an reference of the socket class. This way the code is split and easier to manage.
For server packets, I went with using OOP. Each server packet has its own class. Again makes it easier to change the packet structure of the packet without having to go every single code which defines the packet.
An example of my current implementation:
Code:
HabboPacket::Room::Chat l_Packet;
l_Packet.Message = "Hey this is Quadral!";
m_Habbo->ToSocket()->SendPacket(l_Packet.Write());
Design Layout
Forgotten how many times I've refactored my code... When I first started began coding the basic layout of the emulator, I kept
steering into the wrong direction due to the reason that my design layout was not suited for Habbo. Right now I think I am steering into the right direction, as my steering is becoming heavier as
stone to steer again.
The current design layout is letting the user thread to handle calculating less or intensive functions e.g Way-Points and then allow the world update to deal with the function outcome and re-calculate if need to be.
Users can have their own thread or share the same thread with other users depending on the users thread update latency (latency must be < 500ms). You can configure the thread optimisation settings to only launch 2 static threads to handle users connections, or let the server to dynamically handle user thread connections depending on population (this can be resource heavy).
Although I'm not sure what population I am aiming for to handle a stable player base as yet I have not simulated any real players performing actions. This is something I am planning to do next before I move onto any stuff.
Right now, the world update is on its own thread to handle; Processing way points, room update, habbo statuses, ping, bots etc... Since the world gets updated every 500ms I can use this tick to calculate how many seconds has been passed to process a certain action e.g habbo wave timer.
For the database, I decided to split the database into two; one for handling user info and one for room info - this way everything is more clean and simple to use. Along with this the core on start-up will proactively check if any room entries exist in the user database info to ensure there's no rooms which are just junk... this goes the same with other stuff which is separated from users database.
What has been done?
So far:
Messenger - 98% completed. 2 Packets (Error Packets) needs to be coded
PathFinding - 90% completed. Checks for dynamic objects (players only at the moment) and static objects.
Navigator - 90% completed. Need to code search users and create rooms.
Habbo Club - 90% completed. Need to code the Gift part.
Badges - 100% completed.
WalkWays (Walking into another room) - 100% completed.
Furniture - 50% completed. Still need to code the catalogue.
FuseRights - 40% completed. Need to code the moderation packets
Rank - 100% completed. Users can now set their ranks and gets updated accordingly.
And probably more other stuff I cannot think off atm!
Thanks for reading.