Skip to content

Conversation

Zbizu
Copy link
Contributor

@Zbizu Zbizu commented Oct 18, 2021

Description

Work in progress. It's working but the code is nowhere near its final form. Treat it as a sketch, a proof of concept for now.
Visit #3747 to take part of important decision regarding this change.

The code is ready for testing! Details can be found in comments below.

Changes Proposed

  • 12.71 support
  • 10.98 backwards compatibility This feature was voted out.
  • cid being dependent on GUID (this is necessary to save containers)
  • adjust monster/npc generated ids (the cid)
  • standardized creature id bounds (uses variable instead of hardcoded number now)
  • improved code behind mounts
  • updated summon status refresh packet
  • updated talkactions message types (blue console message is deprecated)
  • feature: packet sequencing
  • feature: login with email (you can set @admin as your email btw or if you're running otclient, still use your account name)
  • feature: right click to talk with npc
  • feature: save opened containers
  • feature: mount colors
  • feature: session end packet
  • feature: cid and GUID in onLook (gm/god only)
  • new items
  • new outfits
  • new mounts
  • new NPC bubbles
  • new condition icons (enums only for now)
  • new message types

Issues addressed: #3492, followup to #3671

Credits

Special thanks to:

  • OTBR community (especially people involved in "Global" and "Canary" projects and their OTClient fork) for providing the code and tools necessary to achieve that
  • SaiyansKing for paving the way for QT clients
  • Arch-Mina for providing version 12 tools to work with client
  • EPuncker - providing spr/dat, help with otb, game content information, testing and help with login.php
  • kokokoko - updating items.otb with new items and data
  • omarcopires - review, testing and help with login.php
  • TFS maintainers for ensuring code quality and helping with project direction

@ghost ghost added the feature New feature or functionality label Oct 18, 2021
@ghost ghost assigned ranisalt Oct 18, 2021
@Zbizu
Copy link
Contributor Author

Zbizu commented Oct 19, 2021

Version 12 is ready for testing.
10.98 compatibility dropped.

To log in, use Znote AAC with this change applied:
https://github.com/Znote/ZnoteAAC/pull/493/files (Updated)
(the packet has to look like this: login\npassword\ntoken or empty\ntimestamp divided by 30)

Please post bugs if you find any.

Known bugs:

  • sell price not displaying properly in NPC trade
  • hidden creatures still display name
  • displaying podium in game screen is very likely to crash the client due to lack of proper bytes in the packet
  • browse field crashes the client and I have no idea why
  • battle list is always on and there are weird missing containers after login

Known missing features:

  • everything added after 10.98

Things to adjust:

  • [protocolgame] use podium ItemId/flag once we get proper otb Update: podium will be added as a followup to this pr.
  • (optional/cosmetic) [protocolgame] use purse ItemId once we get proper otb to do: Update purse Id const

@mattyx14
Copy link
Contributor

I would just like to say that you try to make both items.otb the same 🙏🏼

@beats-dh
Copy link

It looks like a great job!

@Zbizu
Copy link
Contributor Author

Zbizu commented Oct 26, 2021

action bars and saved containers fully functional now

@@ -356,16 +372,31 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
writeToOutputBuffer(opcodeMessage);
}

msg.skipBytes(1); // gamemaster flag
// Change packet verifying mode for QT clients
if (version >= 1111 && operatingSystem >= CLIENTOS_QT_LINUX && operatingSystem <= CLIENTOS_QT_MAC) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we aren't allowing <= 1111, so I guess this check is redundant and checksum mode should be sequence by default, which would also delete enum for CHECKSUM_SEQUENCE

Copy link
Contributor Author

@Zbizu Zbizu Nov 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otclient compatible with protocol 1271 still uses adler32
version check is required to send "only x protocol allowed" message properly (it needs a proper header)
qt client was using checksums early too

wasn't otclient supposed to be the base client for tfs by the way?

Copy link
Member

@nekiro nekiro Nov 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then I would say otc should be fixed to act like qt client.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then I would say otc should be fixed to act like qt client.

Is there development on their behalf? OTC shouldn't block TFS but it would be nice to have them move together.

ghost
ghost previously approved these changes Nov 4, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been testing it for days already, everything fine so far

@Zbizu
Copy link
Contributor Author

Zbizu commented Nov 6, 2021

context for most recent commit: the "risky" symbol (the spark under guild emblem) is no longer used, the "helpers" packet got repurposed to show locker search results, which resulted in client crash when inviting to party. This commit fixed that.

@@ -77,7 +77,7 @@ bool IOLoginData::loginserverAuthentication(const std::string& name, const std::
{
Database& db = Database::getInstance();

DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `name`, `password`, `secret`, `type`, `premium_ends_at` FROM `accounts` WHERE `name` = {:s}", db.escapeString(name)));
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `name`, `password`, `secret`, `type`, `premium_ends_at` FROM `accounts` WHERE `name` = {:s} OR `email` = {:s}", db.escapeString(name), db.escapeString(name)));
Copy link
Member

@Znote Znote Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this faster than:

Suggested change
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `name`, `password`, `secret`, `type`, `premium_ends_at` FROM `accounts` WHERE `name` = {:s} OR `email` = {:s}", db.escapeString(name), db.escapeString(name)));
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `name`, `password`, `secret`, `type`, `premium_ends_at` FROM `accounts` WHERE {:s} IN(`name`, `email`)", db.escapeString(name)));

IN statements saves us an db.escapestring, but perhaps it breaks index scanning?
Perhaps we should make an index that stores both name and email.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just store the result of db.escapeString if you don't want to call it twice

@@ -104,8 +104,7 @@ bool IOLoginData::loginserverAuthentication(const std::string& name, const std::
uint32_t IOLoginData::gameworldAuthentication(const std::string& accountName, const std::string& password, std::string& characterName, std::string& token, uint32_t tokenTime)
{
Database& db = Database::getInstance();

DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `password`, `secret` FROM `accounts` WHERE `name` = {:s}", db.escapeString(accountName)));
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `password`, `secret` FROM `accounts` WHERE `name` = {:s} OR `email` = {:s}", db.escapeString(accountName), db.escapeString(accountName)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See suggestion iologindata.cpp#80

@@ -71,6 +71,8 @@ class Tile;
static constexpr int32_t EVENT_CREATURECOUNT = 10;
static constexpr int32_t EVENT_CREATURE_THINK_INTERVAL = 1000;
static constexpr int32_t EVENT_CHECK_CREATURE_INTERVAL = (EVENT_CREATURE_THINK_INTERVAL / EVENT_CREATURECOUNT);
static constexpr uint32_t CREATURE_ID_MIN = 0x10000000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this have to do with protocol 12? Should be a separate PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it actually does and I think he explained why, there were some changes regarding ids in new client I believe

Copy link
Member

@Znote Znote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is 74 commits in this commit history, 17+? of which are cleanups.
Since this is a big PR, we want to do a proper merge (this will give you credit for each commit instead of just one squashed one).

But we need each commit to be purpose specific and well explained, some commits could have a better description, some commits could be squashed together. (etc, 1 cleanup commit if any instead of 17, with a deeper description of what that involves).

A rebase against otland/master will remake these commits to follow after the latest commit in master branch, by using git rebase -i master (after the local master branch is up to date with otland/master) you can resort the order of your commits, and by changing pick #hash to squash #hash will squash a commit to its previous commit.

I suggest you play around with this in a version12_c branch, so this becomes a backup branch while your learning the ropes.

Normal rebase to get your commits after master: https://www.youtube.com/watch?v=f1wnYdLEpgI

In your branch, you have synced your branch to master, these commits are cluttered between your own feature branch commits, for instance the commits at october 23: https://github.com/Zbizu/forgottenserver/commits/version12_b

A regular rebase will make all the commits in your feature branch appear neatly organized after the commits in master. This is a pretty simple and straightforward.

So instead of this:
image

It becomes like this:
image

Then we can do interactive rebase to reorder, edit and squash various commits in your branch: https://www.youtube.com/watch?v=ElRzTuYln0M
To make your branch commit history tidy, clean and ready for merge.

If you have any questions using git, ask away, I'm happy to help.
Rebasing 74 commits is quite a big challenge.

@ghost ghost mentioned this pull request Nov 8, 2021
@Zbizu Zbizu closed this Nov 9, 2021
@lucasgrizante
Copy link
Contributor

Why this PR was closed?

I don't think #3784 should be merged as mostly work was done by Zbizu and not by Evil Puncker itself.

If you don't want to squash all your commits by topics, I think (but I'm no one in this community, so my opinion may not be the same as the moderators) you could at least make a single commit with a proper description (similar to the description from this PR).

You can do that doing git reset --soft origin/master and git commit again. Pretty easy (I'm sure you know it as you are an excellent programmer).

@Znote
Copy link
Member

Znote commented Nov 9, 2021

@lucasgrizante I agree with you. But I think Zbizu closed this PR because he don't want to continue it.

But perhaps he is working on a new branch to do the rebase or build a better commit structure. I did suggest to him to work on a version12_c branch. 🤞
(If this is the case, I also have a feeling its gonna be a juicy branch name). 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to version 12