• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[C++/Linux] Compiling old engine (sources) on Debian 10 / Ubuntu 20.04

OP
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,368
Solutions
44
Reaction score
1,823
Location
Poland
GitHub
gesior
@Gsp
Looks like you did some wrong changes in protocol.h and protocol.cpp. There should be declared Protocol::RSA_decrypt
or somehow your ProtocolGame and ProtocolOld classes do not 'extend' Protocol class.
It looks almost impossible, as that method was already there in 0.4. My changes only added second version with different parameters.

If you still need help, message me on Discord: Gesior.pl#3208
(I will post information how to fix that problem when we find it out)
 

Gsp

RP
Joined
Jan 3, 2008
Messages
250
Solutions
1
Reaction score
4
@Gesior.pl Thank you for your response. I was able to fix all three errors by adding:

bool ProtocolGame::parseFirstPacket(NetworkMessage& msg)
{
if(g_game.getGameState() == GAMESTATE_SHUTDOWN)
{
getConnection()->close();
return false;
}

OperatingSystem_t operatingSystem = (OperatingSystem_t)msg.get<uint16_t>();
uint16_t version = msg.get<uint16_t>();
#ifdef _MULTIPLATFORM77
if(!RSA_decrypt(msg))
{
getConnection()->close();
return false;
}

uint32_t key[4] = {msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>(), msg.get<uint32_t>()};
#endif

these 2 lines like this way.
Then I got another error.

Bash:
g++ -I/usr/include/libxml2   -O2 -fomit-frame-pointer -D__USE_MYSQL__    -D__WAR_SYSTEM__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D_THREAD_SAFE -D_REENTRANT   -Wno-strict-aliasing -Wno-unused-parameter -pipe   -o theforgottenserver actions.o  allocator.o baseevents.o beds.o chat.o combat.o condition.o configmanager.o connection.o container.o creature.o creatureevent.o cylinder.o database.o databasemanager.o databasemysql.o   depot.o dispatcher.o exception.o fileloader.o game.o  globalevent.o group.o house.o housetile.o ioban.o ioguild.o iologindata.o iomap.o iomapserialize.o item.o itemattributes.o items.o luascript.o mailbox.o manager.o map.o monster.o monsters.o movement.o networkmessage.o npc.o otserv.o outfit.o outputmessage.o party.o player.o position.o protocol.o protocolgame.o protocolhttp.o protocollogin.o protocolold.o quests.o raids.o scheduler.o scriptmanager.o server.o spawn.o spells.o status.o talkaction.o teleport.o textlogger.o thing.o tile.o tools.o trashholder.o waitlist.o weapons.o vocation.o  -lmysqlclient -llua -lcrypto -lcryptopp -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp  -lxml2 -lpthread -lgmp -ldl -lgmp
/usr/bin/ld: otserv.o: warning: relocation against `_ZTV13ProtocolLogin' in read-only section `.text._ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE[_ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE]'
/usr/bin/ld: otserv.o: in function `Service<ProtocolLogin>::makeProtocol(boost::shared_ptr<Connection>) const':
otserv.cpp:(.text._ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE[_ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE]+0x99): undefined reference to `vtable for ProtocolLogin'
/usr/bin/ld: otserv.cpp:(.text._ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE[_ZNK7ServiceI13ProtocolLoginE12makeProtocolEN5boost10shared_ptrI10ConnectionEE]+0xea): undefined reference to `vtable for ProtocolLogin'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:504: theforgottenserver] Error 1
make[1]: Leaving directory '/root/source'
make: *** [Makefile:446: all] Error 2

I'm not good at reading this kind of errors so this was confusing. I thought it may be a gcc issue or a boost problem, i downgraded the boost to 1.55, it was still the same. I tried adding some flags, didnt work. I tried including
#include <boost/utility.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
in related files, didnt work. Then I opened the otserv.cpp and removed this line below

{
services->add<ProtocolLogin>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
services->add<ProtocolOldLogin>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
}

services->add<ProtocolGame>(g_config.getNumber(ConfigManager::GAME_PORT), ipList);
services->add<ProtocolOldGame>(g_config.getNumber(ConfigManager::LOGIN_PORT), ipList);
std::clog << "> Bound ports: ";

after this I was able to compile it but I'm not sure if players will be able to log in lol
 
OP
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,368
Solutions
44
Reaction score
1,823
Location
Poland
GitHub
gesior
@Gsp
About that error:
Code:
/usr/bin/ld: otserv.o: in function `Service<ProtocolLogin>::makeProtocol(boost::shared_ptr<Connection>) const':
If you remove that line, players won't be able to login to account (list characters).
I got no idea what that error means, but I would remove all files .o from directory and try to compile again.

As I see, you are running some engine with multiprotocol support:
Code:
#ifdef _MULTIPLATFORM77
It's harder to apply RSA changes, because you must check original code and copy all extra #ifdef to valid places in my code.
 

Gsp

RP
Joined
Jan 3, 2008
Messages
250
Solutions
1
Reaction score
4
Thank you Gesior. I give up. I'll try switching to your engine and see what happens.

@Gesior.pl After many hours of editing I was able to compile my old engine on Debian 11. Thank you once again for creating this guide.
My advice to people who are going to edit TFS 0.4 3884 is to use this release as your base. I copied most of the codes from there to my source and edited them according to this guide. Gesior's source is advanced, 3884 is simple and outdated, that one i linked is between these two.

Last error I got was

g++ -I/usr/include/libxml2 -O2 -fomit-frame-pointer -D__USE_MYSQL__ -D__WAR_SYSTEM__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D_THREAD_SAFE -D_REENTRANT -g -Wno-strict-aliasing -Wno-unused-parameter -pipe -o theforgottenserver rsa.o actions.o allocator.o baseevents.o beds.o chat.o combat.o condition.o configmanager.o connection.o container.o creature.o creatureevent.o cylinder.o database.o databasemanager.o databasemysql.o depot.o dispatcher.o exception.o fileloader.o game.o globalevent.o group.o house.o housetile.o ioban.o ioguild.o iologindata.o iomap.o iomapserialize.o item.o itemattributes.o items.o luascript.o mailbox.o manager.o map.o monster.o monsters.o movement.o networkmessage.o npc.o otserv.o outfit.o outputmessage.o party.o player.o position.o protocol.o protocolgame.o protocolhttp.o protocollogin.o protocolold.o quests.o raids.o scheduler.o scriptmanager.o server.o spawn.o spells.o status.o talkaction.o teleport.o textlogger.o thing.o tile.o tools.o trashholder.o waitlist.o weapons.o vocation.o -lmysqlclient -llua -lcryptopp -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread -lpthread
/usr/bin/ld: /usr/local/lib/liblua.a(loadlib.o): undefined reference to symbol '[email protected]@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
adding -ldl to flags instantly fixed the problem.

on tools.cpp I had to make some changes on this part
seems to be working now for me.

C++:
std::string transformToSHA1(std::string plainText, bool upperCase)
{
    // Crypto++ SHA1 object
    CryptoPP::SHA1 hash;
    // Use native byte instead of casting chars
    CryptoPP::byte digest[CryptoPP::SHA1::DIGESTSIZE];
    // Do the actual calculation, require a byte value so we need a cast
    hash.CalculateDigest( digest, (CryptoPP::byte*)plainText.c_str(), plainText.length());
    // Crypto++ HexEncoder object
    CryptoPP::HexEncoder encoder;
    // Our output
    std::string output;
    // Encode to base64
    encoder.Attach(new CryptoPP::StringSink(output));
    encoder.Put(digest, sizeof(digest));
    encoder.MessageEnd();

    // Make sure we want uppercase
    if(upperCase)
        return output;

    // Convert to lowercase if needed
    return asLowerCaseString(output);
}
 

hiwyn

New Member
Joined
Aug 30, 2021
Messages
34
Reaction score
4
could you help us to compile on debian 11 @Gesior.pl
even on start i got a problem:
E: Unable to locate package libcrypto++6
 
OP
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,368
Solutions
44
Reaction score
1,823
Location
Poland
GitHub
gesior
could you help us to compile on debian 11 @Gesior.pl
even on start i got a problem:
E: Unable to locate package libcrypto++6
On Debian 11 there is version 8, not 6. You can try to compile using it. Replace:
Code:
libcrypto++6
with:
Code:
libcrypto++8
 

rexgandi

Member
Joined
Oct 22, 2011
Messages
130
Reaction score
6
no, tell me if u got

But link dead...
 
OP
OP
Gesior.pl

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,368
Solutions
44
Reaction score
1,823
Location
Poland
GitHub
gesior

But link dead...
What is a problem? Author of that 'fix' did not describe what was a problem.
 
Top