Jump to content

Recommended Posts

Offline stalls system

 

pkodev-shop.png

 

 

One of the gaming aspects of the game is trading between characters through special stalls, which players can open by learning a special skill. The player sell his items for a certain price, and other players can buy them.

 

However, for such trading, the player have to be in the game, that is, be connected to the server, which makes him to leave his computer constantly turned on and keep the game client minimized. This is very inconvenient, so the system of "offline" stalls was invented, which allows players to disconnect from the server and still remain trading in the stalls.

 

There are several ways to implement such a system, but the most common system is "offline" stalls through a proxy server:

1) The game client (Game.exe) connects to the proxy server;
2) The proxy server, in turn, opens a connection to the GateServer.exe;
3) Further, the proxy server transfers all packets between Game.exe and GateServer.exe, while analyzing them;
4) When a player opens a trade stall, the proxy server captures this (GateServer.exe sent Game.exe a successful stall opening packet);
5) If a player disconnects from the server while in a trading stall, then the proxy server closes the connection to Game.exe, but at the same time keeps the connection to GateServer.exe and starts imitating Game.exe. Thus, GateServer.exe is unaware of the fact that Game.exe is disconnected and the player's character remains to trade in the stall on the server.

Game.exe |
Game.exe | <---------> pkodev.stallserver.exe <---------> GateServer.exe
Game.exe |

 

This topic discusses the development of such a proxy server - PKOdev.NET Stall Server.

 

 

Warning! The application is currently under development. The application has not been fully tested and is not stable. This means that errors, bugs and critical vulnerabilities may be present. Use it for testing purposes only!

 

 

Features

 

1) Offline stalls system;

2) Limiting the number of offline stalls from one IP address;

3) Limiting the trading time in an offline stall;

4) Automatic disconnection of the account from the server when a player tries to enter his account while trading in an offline stall;

5) Notification of players in the chat that a player trades in an offline stall (in PM);

6) Prevention of SQL-injections in login and PIN create (change) packets from game client;

7) Setting for the maximum number of connections from the same IP address and the interval between connections.

 

 

to-do

 

1) Translate comments in files Server.h and Server.cpp to English language;

2) Fix application crash when processing packets;

3) Fix application crash on startup when local port is closed;

4) Fix bridge hanging when blocking packets on enabled encryption in GateServer.cfg (thanks to @small666 for finding the bug);

5) Make thread synchronization when processing packets;

6) Close the offline stall if it is empty;

7) Modification of GateServer.exe to determine the IP addresses of clients that are behind the server of offline stalls. At this point in the logs and database, the IP addresses of all clients will be written as 127.0.0.1 (if both GateServer.exe and pkodev.stallserver.exe are running on the same machine).

8 ) Compatibility with Corsairs Online (CO) source code.

 

 

Building and running

 

1) Clone the repository with the project to your disk (the link will be below);
2) Open the solution file pkodev.stallserver.sln in Visual Studio 2022 Community (or higher version);
3) Build the solution. The server executables will appear in the bin folder;
4) Place the configuration file pkodev.stallserver.cfg from the cfg folder in the same directory as the server executable file pkodev.stallserver.exe;
5) Customize the configuration file pkodev.stallserver.cfg (the file is well commented);
6) To connect the game client (Game.exe) to the offline stall server, you need to install the pkodev.mod.stallserver mod;
7) To connect the offline stall server to GateServer.exe, the GateServer should be without any modifications, for example, from the PKO 1.38 server files.

8 ) Run offline stall server executable pkodev.stallserver.exe.

 

Git repository

 

https://github.com/V3ct0r1024/pkodev.stallserver

  • Like 1
  • Thanks 4

Share this post


Link to post
Share on other sites

- Thank you very much, will you still continue working on this system even after sharing?

- Do the problems you talked about with multithreading still exist?
 

Share this post


Link to post
Share on other sites
5 hours ago, V3ct0r said:

Features

 

1) Offline stalls system;

2) Limiting the number of offline stalls from one IP address;

3) Limiting the trading time in an offline stall;

4) Automatic disconnection of the account from the server when a player tries to enter his account while trading in an offline stall;

5) Notification of players in the chat that a player trades in an offline stall (in PM);

6) Prevention of SQL-injections in login and PIN create (change) packets from game client;

7) Setting for the maximum number of connections from the same IP address and the interval between connections.

 

5 hours ago, V3ct0r said:

to-do

 

1) Translate comments in files Server.h and Server.cpp to English language;

2) Fix application crash when processing packets;

3) Fix application crash on startup when local port is closed;

4) Make thread synchronization when processing packets;

5) Close the offline stall if it is empty;

6) Modification of GateServer.exe to determine the IP addresses of clients that are behind the server of offline stalls. At this point in the logs and database, the IP addresses of all clients will be written as 127.0.0.1 (if both GateServer.exe and pkodev.stallserver.exe are running on the same machine).

7) Compatibility with Corsairs Online (CO) source code.

 


Thanks for sharing this mod, i’d like to know if this one will include the http feature as it used to have on the one we used to buy from you, cuz i didn’t see it inside the configure file or on features list you mentioned above.

Share this post


Link to post
Share on other sites
16 hours ago, ShadowJr said:

- Thank you very much, will you still continue working on this system even after sharing?

Yes, I will.

 

16 hours ago, ShadowJr said:

- Do the problems you talked about with multithreading still exist?

Yes. All problems mentioned in the "to-do" list are requiring fixes.

 

15 hours ago, Rinor said:

Thanks for sharing this mod, i’d like to know if this one will include the http feature as it used to have on the one we used to buy from you, cuz i didn’t see it inside the configure file or on features list you mentioned above.

This feature is not implemented yet. For now, I want to focus on the issues from the "to-do" list.

  • Thanks 1

Share this post


Link to post
Share on other sites

03/10/2022

 

+ Translation of comments in Server.h and Server.cpp files into English;
+ Fixed server crash when processing packets from the client. The problem was in the procedure for reading strings from the buffer, when the parser tried to read a string with zero length;
+ Fixed crash when stopping the server due to incorrect order of releasing resources;
+ Minor code changes.

 

All changes have been commited to the project repository on Github. I ask interested users to test pkodev.stallserver.exe and send reports to this topic. Maybe someone will run it on their test server. Thanks for any help!

  • Thanks 2

Share this post


Link to post
Share on other sites
2 hours ago, V3ct0r said:

03/10/2022

 

+ Translation of comments in Server.h and Server.cpp files into English;
+ Fixed server crash when processing packets from the client. The problem was in the procedure for reading strings from the buffer, when the parser tried to read a string with zero length;
+ Fixed crash when stopping the server due to incorrect order of releasing resources;
+ Minor code changes.

 

All changes have been commited to the project repository on Github. I ask interested users to test pkodev.stallserver.exe and send reports to this topic. Maybe someone will run it on their test server. Thanks for any help!

Thank you very much @V3ct0r!  do you also intend to make it compatible with corsairs source code?

Share this post


Link to post
Share on other sites
On 3/10/2022 at 5:15 PM, ShadowJr said:

Thank you very much @V3ct0r!  do you also intend to make it compatible with corsairs source code?

Yes, I do

  • Thanks 1

Share this post


Link to post
Share on other sites

04/18/2022

 

+ Fixed bridge hanging when blocking packets on enabled encryption in GateServer.cfg (thanks to @small666 for finding the bug);

+ Made thread synchronization;

+ Code optimization and other minor changes.

 

All changes have been commited to the project repository on GitHub. I will still be grateful for any help in development, especially for testing.

  • Thanks 2

Share this post


Link to post
Share on other sites

Hello @ShadowJr,

 

do you can (or someone else) send to me CO full server files and client for tests?


Share this post


Link to post
Share on other sites

04/21/2022

 

+ The project has been upgraded to Visual Studio Community 2022;

+ Added the feature to automatically close the offline stall if it becomes empty (all items are sold). This behavior is enabled or disabled using the 'close_stall_on_empty' option in the 'pkodev.stallserver.cfg' configuration file;

+ Sending the client's IP address in the login packet to the GateServer to determine the IP addresses of the players behind the StallServer. GateServer should have the appropriate extension installed. This behavior is enabled or disabled using the 'ip_mod' option in the 'pkodev.stallserver.cfg' configuration file;

+ Insignificant code fixes and other minor changes.

 

 

All changes have been commited to the project repository on GitHub. Don't forget to update the configuration file 'pkodev.stallserver.cfg'.

 

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites
On 4/21/2022 at 4:04 PM, V3ct0r said:

04/21/2022

 

+ The project has been upgraded to Visual Studio Community 2022;

+ Added the feature to automatically close the offline stall if it becomes empty (all items are sold). This behavior is enabled or disabled using the 'close_stall_on_empty' option in the 'pkodev.stallserver.cfg' configuration file;

+ Sending the client's IP address in the login packet to the GateServer to determine the IP addresses of the players behind the StallServer. GateServer should have the appropriate extension installed. This behavior is enabled or disabled using the 'ip_mod' option in the 'pkodev.stallserver.cfg' configuration file;

+ Insignificant code fixes and other minor changes.

 

 

All changes have been commited to the project repository on GitHub. Don't forget to update the configuration file 'pkodev.stallserver.cfg'.

 

Hello @V3ct0r Any news on using your offline stall with CO Source code?

Share this post


Link to post
Share on other sites

Hello @ShadowJr,

 

I've started work on CO compatibility.

  • Thanks 1

Share this post


Link to post
Share on other sites

05/05/2022

 

+ Added console commands to manage the server;

1) '/close' - Stop the server.
2) '/disconnect' - Disconnect clients: [all] - all clients; [offline] - offline stalls only.
3) '/help' - Show available console commands.
4) '/kick' - Disconnect a client by character name or account: [character] [character name] - by character name; [account] [account name] - by account.
5) '/notice' - Send a message to the system chat channel to all connected clients.
6) '/stat' - Show server statistics.
7) '/stop' - Stop the server.

stallserver_update050522.png

 

+ Made a decrement of the number of tasks for worker threads when a client disconnected from the server;

+ Fixed disconnection of the client from the server in the method void Bridge::disconnect();

+ Insignificant code fixes and other minor changes.

 

 

All changes have been commited to the project repository on GitHub.

  • Thanks 1

Share this post


Link to post
Share on other sites

05/07/2022

 

+ Fixed a bug in the '/notice' console command - spaces could not be used in the message (thanks to @small666 for finding the bug!);

+ Added '/gmnotice' console command - works similar to '/notice' command, with the difference that messages are sent to GM chat at the top of the client GUI;

+ Added handling of exceptions that may occur during the execution of a console command;

+ Destructors of all interfaces (OOP) are made virtual;

+ Fixed server crash in Bridge::endpoint::~endpoint() destructor when shutting down the server.

 

 

All changes have been commited to the project repository on GitHub.


Share this post


Link to post
Share on other sites

Hello @ShadowJr,

 

On 4/19/2022 at 2:54 PM, ShadowJr said:

Hey @V3ct0r I think the @deguix repository is a good one to do this

https://gitlab.com/deguix/corsairs-online-public
 

I ran into a ton of errors trying to compile and run these sources. Can you send me compiled server and client files with databases for tests? 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, V3ct0r said:

Olá @ShadowJr,

 

Encontrei uma tonelada de erros tentando compilar e executar essas fontes. Você pode me enviar arquivos compilados de servidor e cliente com bancos de dados para testes?

Hello @V3ct0r 

 

As I can't send these files as public, I sent them through my Discord:  ShadowJr#5627

Thank you!

Share this post


Link to post
Share on other sites

I just can't make work all CO files which I've received. I am facing with various errors, starting from src compilation and ending with client crash when enter a map.

 

@ShadowJr, @K1D0

  • Sad 2

Share this post


Link to post
Share on other sites
15 minutes ago, ShadowJr said:

Even the last one I sent now? I tested everything before sending

I will check tomorrow.

  • Thanks 1

Share this post


Link to post
Share on other sites

Hey guys,


I've been trying to make it work but I think there is a problem. All I am getting is either "Connection failed" or "ToClient listen failed" error appears on GateServer (attached below) I guess because 1973 is used in both pkodev.stallserver.cfg & gateserver.cfg.

 

Can someone guide us exactly through it, please post your configuration will help a lot!

Thanks

 

spacer.png
 

Share this post


Link to post
Share on other sites

Hello @Sultan,

 

Game.exe |
Game.exe | <---------> pkodev.stallserver.exe (port: 1973) <---------> GateServer.exe (port: 2715)
Game.exe |

 

GateServer.cfg:

[ToClient]
Port = 2715

 

pkodev.stallserver.cfg:

[ToClient]
port   = 1973                   // [integer] Port       Game.exe -> StallServer.exe

[ToGate]
host   = 127.0.0.1              // [string]  IP address StallServer.exe -> GateServer.exe
port   = 2715                   // [integer] Port       StallServer.exe -> GateServer.exe

 

Where 2715 is any free port on your system.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...