Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packet compression #4870

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Add packet compression #4870

merged 3 commits into from
Dec 20, 2024

Conversation

nekiro
Copy link
Member

@nekiro nekiro commented Dec 9, 2024

Pull Request Prelude

Changes Proposed

Add missing packet compression for big packets

Issues addressed:
None

How to test:
Login to game, walk around, no crashes? works

@nekiro nekiro force-pushed the add-packet-compression branch 3 times, most recently from 02692d5 to 259ee4f Compare December 9, 2024 15:14
@nekiro nekiro force-pushed the add-packet-compression branch from 259ee4f to 202873c Compare December 9, 2024 15:18
@kojimhojo
Copy link

kojimhojo commented Dec 9, 2024

I was test this pr

1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_7UV282A0LJD6HKYT.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_WVPT28ZTJM2D5DRQ.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_PHA839T1F3WJNADU.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_UQQ0CKG94LMSIJTD.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_BY0BRRYLGSJPV7M2.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_CC66XSVYT629IPHD.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_O3UET4IWMWPEWHUH.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_JLP2YU5E50UTN58Y.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_3IXG4BE2WK51GMUG.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_W77GNRDQU6L8J5J6.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_DEI15LZQFC5MQXGQ.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_M5357L0YAAIQIYYX.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_CUC7PH7VGPESK21R.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_FZXZHF2F6A11DIV8.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_6PQ6CCA4WWXC3I24.cpp')
1>D:\src\outputmessage.cpp(25,55): warning C4459: declaration of 'bufferedProtocols' hides global declaration
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_CUC7PH7VGPESK21R.cpp')
1>D:\src\outputmessage.cpp(21,27):
1>see declaration of '`anonymous-namespace'::bufferedProtocols'
1>D:\src\outputmessage.cpp(31,47): warning C4459: declaration of 'bufferedProtocols' hides global declaration
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_CUC7PH7VGPESK21R.cpp')
1>D:\src\outputmessage.cpp(21,27):
1>see declaration of '`anonymous-namespace'::bufferedProtocols'
1>unity_8NZJOI7GO26MNSLA.cpp
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_FZXZHF2F6A11DIV8.cpp')
1>D:\src\protocol.h(55,22): warning C4018: '>=': signed/unsigned mismatch
1>(compiling source file '/theforgo.A10F9657/x64/Release/unity_8NZJOI7GO26MNSLA.cpp')

in cipsoft client works fine

but in otc by enabling the feature "GameSequencedPackets"
g_game.enableFeature(GameSequencedPackets)

mehah/otclient@4e79004
"SPX Protocol Support (with compress)"

error

ERROR: failed to decompress message - too many length or distance symbols
at:
    [C++]: ?internalRecvData@Protocol@@AEAAXPEAEG@Z
    
    ERROR: failed to decompress message - invalid stored block lengths
at:
    [C++]: ?internalRecvData@Protocol@@AEAAXPEAEG@Z

@nekiro
Copy link
Member Author

nekiro commented Dec 9, 2024

in cipsoft client works fine

but in otc by enabling the feature "GameSequencedPackets" g_game.enableFeature(GameSequencedPackets)

mehah/otclient@4e79004 "SPX Protocol Support (with compress)"

If cip client works, then it must be something different at otclient side or incorrect configuration.

@kokekanon
Copy link

kokekanon commented Dec 9, 2024

in cipsoft client works fine
but in otc by enabling the feature "GameSequencedPackets" g_game.enableFeature(GameSequencedPackets)
mehah/otclient@4e79004 "SPX Protocol Support (with compress)"

If cip client works, then it must be something different at otclient side or incorrect configuration.

The client is fine, the issue is with TFS ,specifically in this line (in void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)[forgottenserver/src/protocolgame.cpp]. This if statement only integrates CipSoft, not OTCR Windows.

image

if (version >= 1111 && operatingSystem >= CLIENTOS_QT_LINUX && operatingSystem < CLIENTOS_OTCLIENT_LINUX) {
setChecksumMode(CHECKSUM_SEQUENCE);
}

@kojimhojo tries to delete that if and it will work with g_game.enableFeature(GameSequencedPackets)

-	// Change packet verifying mode for QT clients
-	if (version >= 1111 && operatingSystem >= CLIENTOS_QT_LINUX && operatingSystem < CLIENTOS_OTCLIENT_LINUX) {
-		setChecksumMode(CHECKSUM_SEQUENCE);
-	}
+
+	setChecksumMode(CHECKSUM_SEQUENCE);
+

I confirm that it works in OTCR


example : player open higscore module

Server
packet size before: 4360
packet size after: 1734

Client

WARNING: raw: 4360
WARNING: descompression: 1734

floor
asdasva

@nekiro
Copy link
Member Author

nekiro commented Dec 10, 2024

I assume change works on both clients then.

@kojimhojo
Copy link

thanks.
i test it and works
ty

@ArturKnopik
Copy link
Contributor

ArturKnopik commented Dec 18, 2024

Tested on Cipsoft client, it's working.

This changes require update in wiki about new zlib dependency.

@@ -49,6 +49,7 @@ endif ()

# Find packages.
find_package(OpenSSL 3.0.0 REQUIRED COMPONENTS Crypto)
find_package(ZLIB REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Require update in wiki about new zlib dependency.

@ArturKnopik ArturKnopik added the feature New feature or functionality label Dec 20, 2024
@nekiro nekiro merged commit 4577a88 into otland:master Dec 20, 2024
16 checks passed
@nekiro nekiro deleted the add-packet-compression branch December 20, 2024 20:15
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.

4 participants