Jump to content

How To Building the Source Code without the Extern (vcpkg method)


Recommended Posts

Hello, this is a random and unwanted tutorial for building the Metin2 source code with vcpkg.

It was intended for new comers for sure, but it might get more complicated than it should be.
If you remember the wiki pages about building the source and creating the Extern from scratch, this is the cleaned and updated 2020 method™ .

 

This tutorial focuses doing changes on both some revisions that I have on the internet and the original leaked one.

 

We will use vcpkg, but this tutorial also contains several fixes that are required to get a general source file to be built.

 

Introduction

vcpkg is a C++ package manager for Windows, Linux, Mac (and FreeBSD). It allows us to build any third party program required by any of our applications, and keep them updated.

It also allows us to easily install anything new it might be required to our sources.

In Metin2, this program fully replaces the old Extern directory.

The tutorial is compatible for both Windows and FreeBSD, both client and server.

 

This method also supports adding custom inclusions or libraries inside the vcpkg installation
root, I'll explain more later on the topic.

 

Why shoud you use this method?

 

  • You want a quick and slimmer way of distributing your sources, the idea

would be not distributing the Extern at all, and let people perform the installation of vcpkg in their PC.

  • Keep all the third party components of Metin2 always up to date.

You might get better performance and security enchanges. (Most commonly the Python update)

  • You want to achieve static linking (removing extra DLL in your client or SO in the game). My client source only contain SpeedTreeRT and Granny2 dll files (which could be removed if you use static Granny 2.9 and build SpeedTreeRT from sources)


Changes applied:

  • Modify inclusions & libraries to use vcpkg. (No more Extern, for ever)
  • Updated various files to use the last version from vcpkg.
  • Changes old NANOBEGIN/NANOEND to the last SDK and fix some bugs that were generated by using Nanomites with debug builds.
  • Cleaned up Makefile and enable static library usage (no more .so)
  • Fixes some bugs or issues that you can get if you use the server under Windows.

 

Compatibility and incompatibility

  • I was not able to get libmariadb working with FreeBSD, it might have been due to the fact that I was compiling with a FreeBSD 64-bit application, in case something bad happens, I suggest you mitigate by dropping https://pkg.freebsd.org/FreeBSD:(YOUR FREEBSD VERSION):amd64/latest/All/mariadb-connector-c-3.1.9.txz include and lib files inside (vcpkg directory)\installed\x86-freebsd. (FreeBSD recently updated their pkg to 3.1.9, it might work now)
  • MariaDB might use system-wide zlib, which is an issue if you are using a 64-bit machine.
  • You can not build in 32-bit vcpkg under 64-bit (I was using a cross-toolchain and I never got it to work), get a 32-bit build machine. It might be possible to get multilib to build on FreeBSD, but I am not aware of any method that could be achieved under vcpkg.
  • You need internet on your FreeBSD virtual machine or VPS, it also needs to be updated to a relavant version, any supported FreeBSD version is fine, check them at https://www.freebsd.org/
  • You need to use, at least, Windows 7 SP1 to build the Client (or Server).
  • I do not reccomend using clang for building your source, I get some issues with Crypto++. Please report if cryptopp is working fine
  • I have tested this tutorial with an older version that I've released somewhere else, please report any issue you get with this new method.

 

Windows prerequisites


Get the last version of Visual Studio here: https://visualstudio.microsoft.com/downloads/

Choose the workload "C++ desktop application development" (or something similar) in Visual Studio installer.

 

MAKE SURE TO INSTALL THE VISUAL STUDIO ENGLISH LANGUAGE PACK AS WELL, OR VCPKG WILL NOT WORK.

YOU CAN INSTALL LANGUAGE PACK BY CLICKING THE "LANGUAGE PACK" OPTION IN VISUALSTUDIO INSTALLER.


We can download Git from here https://git-scm.com/download/win and CMake from here https://cmake.org/download/



FreeBSD Setup (Server only)

This process must be executed only in the BUILD MACHINE, not in the place where the Server will be started.

Type the following command:
 

pkg install gcc makedepend gmake cmake git openssl ninja

 

Then, type the following commands:

cd (folder where we want to store vcpkg)
git clone --depth=1 https://github.com/microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.sh -disableMetrics -useSystemBinaries
./vcpkg install devil cryptopp boost-system boost-container boost-unordered boost-algorithm boost-pool


Windows setup (Client and, optionally, Server)

Under Windows, type the following commands: (Please note that you need to launch all this commands in an elevated/administrator command prompt)
 

cd (folder where we want to store vcpkg)
git clone --depth=1 https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg -disableMetrics
vcpkg integrate install
vcpkg install devil:x86-windows-static cryptopp:x86-windows-static boost-system:x86-windows-static boost-container:x86-windows-static boost-unordered:x86-windows-static boost-algorithm:x86-windows-static lzo:x86-windows-static python2:x86-windows-static

 


If you use the Type6 Snappy compression, also type the following command:

vpckg install snappy:x86-windows-static


If you want to build a Server under Windows, also type the following command:

vcpkg install libmariadb:x86-windows-static openssl:x86-windows-static boost-pool:x86-windows-static

 

Inside your client source directory (where there's Metin2Client.sln) create a new folder called Extern (unfortunally some components cannot be distributed via vcpkg) and extract this pack inside that folder.

 

Server: Common changes
 

You need to follow the OpenSSL update to build the sources. You might also need to follow the char_skill compilation fix if you get some issue.


This changes must be done inside game/src.


Open cipher.h and modify the following line:

encoder_->ProcessData((byte*)buffer, (const byte*)buffer, length);

to:

encoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);

and from:

decoder_->ProcessData((byte*)buffer, (const byte*)buffer, length);

to:

decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);



Open cipher.cpp and delete the following line:
 

#include <cryptopp/cryptoppLibLink.h>



Open utils.cpp and delete this lines if you have them:

 

#ifdef WIN32
extern "C" void my_make_scrambled_password(char *to, const char *password, size_t pass_len);
#endif


and if you have this lines, change them:
 

#ifdef WIN32
    my_make_scrambled_password(hash_buf, tmp_pwd, strlen(tmp_pwd));
#else
    make_scrambled_password(hash_buf, tmp_pwd);
#endif


to:

 make_scrambled_password(hash_buf, tmp_pwd);


Then, search if you have this lines:

#ifndef SHA1_HASH_SIZE
#define SHA1_HASH_SIZE 20
#endif

 

if you have them, add this after those 3 lines:

extern "C" {
    #include "sha1.h"
}

char *hexify(char * const result, const unsigned char *digest,

         const size_t size_result, size_t size_digest)

{

    static const char * const hexchars = "0123456789ABCDEF";

    char *result_pnt = result;


    if (size_digest <= (size_t) 0 ||

        size_result <= (size_digest * (size_t) 2U)) {

        return NULL;

    }

    do {

        *result_pnt++ = hexchars[(*digest >> 4) & 0xf];

        *result_pnt++ = hexchars[*digest & 0xf];

        digest++;

        size_digest--;

    } while (size_digest > (size_t) 0U);

    *result_pnt = 0;


    return result;

}


// Implementation from commit 2db6b50c7b7c638104bd9639994f0574e8f4813c in Pure-ftp source.

void make_scrambled_password(char scrambled_password[42], const char password[255])

{

    SHA1_CTX      ctx;

    unsigned char h0[20], h1[20];


    SHA1Init(&ctx);

    SHA1Update(&ctx, (unsigned char*)password, strlen(password));

    SHA1Final(h0, &ctx);

    SHA1Init(&ctx);

    SHA1Update(&ctx, h0, sizeof h0);

#ifdef HAVE_EXPLICIT_BZERO

    explicit_bzero(h0, strlen(password));

#else

    volatile unsigned char *pnt_ = (volatile unsigned char *) h0;

    size_t                     i = (size_t) 0U;


    while (i < strlen(password)) {

        pnt_[i++] = 0U;

    }

#endif


    SHA1Final(h1, &ctx);

    *scrambled_password = '*';

    hexify(scrambled_password + 1U, h1,

            42, sizeof h1);

}

 

Download the following two files (sha1.c and sha1.h) and put them inside game/src folder.

https://github.com/clibs/sha1/blob/master/sha1.h

https://github.com/clibs/sha1/blob/master/sha1.c

 

Open input_auth.cpp and if you have this lines, change them from:
 

#ifdef __WIN32__

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'", szLogin);

#else

        // @fixme138 1. PASSWORD('%s') -> %s 2. szPasswd wrapped inside mysql_hash_password(%s).c_str()

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'",

                mysql_hash_password(szPasswd).c_str(), szLogin);

#endif


to:

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'",

                mysql_hash_password(szPasswd).c_str(), szLogin);


Inside this file, change this lines if you have them:
 

#ifdef __WIN32__

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'", szLogin);

#else

        // @fixme138 1. PASSWORD('%s') -> %s 2. szPasswd wrapped inside mysql_hash_password(%s).c_str()

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'",

                mysql_hash_password(szPasswd).c_str(), szLogin);

#endif


to:

  DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,

                "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"

                "UNIX_TIMESTAMP(silver_expire),"

                "UNIX_TIMESTAMP(gold_expire),"

                "UNIX_TIMESTAMP(safebox_expire),"

                "UNIX_TIMESTAMP(autoloot_expire),"

                "UNIX_TIMESTAMP(fish_mind_expire),"

                "UNIX_TIMESTAMP(marriage_fast_expire),"

                "UNIX_TIMESTAMP(money_drop_rate_expire),"

                "UNIX_TIMESTAMP(create_time)"

                " FROM account WHERE login='%s'",

                mysql_hash_password(szPasswd).c_str(), szLogin);

  


Open the file libsql/AsyncSQL.cpp and change:
 

fprintf(stdout, "AsyncSQL: connected to %s (reconnect %d)\n", m_stHost.c_str(), m_hDB.reconnect);[


in

fprintf(stdout, "AsyncSQL: connected to %s\n", m_stHost.c_str());


Open the file libthecore/src/log.c and change:
 

#ifndef __WIN32__

    // log_level이 1 이상일 경우에는 테스트일 경우가 많으니 stdout에도 출력한다.

    if (log_level_bits > 1)

    {

#endif


in:
 

    // log_level이 1 이상일 경우에는 테스트일 경우가 많으니 stdout에도 출력한다.

    if (log_level_bits > 1)

    {



also change this line, you will find it some lines after the last change:
 

#ifndef __WIN32__

    }

#endif


in:
 

}


Open the file libthecore/include/stdafx.h and delete

//struct timespec

{

    time_t  tv_sec;         /* seconds */

    long    tv_nsec;        /* and nanoseconds */

};

also delete this line:
 

#define strtof(str, endptr) (float)strtod(str, endptr)

 

If you have libserverkey, open libserverkey/RSACrypto.cpp and delete this lines:

#ifdef _WIN32

#include <atlenc.h>

#endif


also ope nthe file libserverkey/RSACrypto.h and delete this lines:

#ifdef _WIN32

// needed only for using openssl

#pragma comment(lib, "libeay32")

#endif


Open libserverkey/CheckServerKey.h and change
 

#ifdef _WIN32

#include <atlenc.h>

#else

#include "base64_ssl.h"

#endif

to:
 

#include "base64_ssl.h"


Also inside this file, modifiy this:
 

#ifdef _WIN32

    if (FALSE == Base64Decode(key.c_str(), key.size(), buf, &buflen))

    {

        errorString = "base64 decode failed";

        return false;

    }

#else

    if (false == unbase64_ssl((unsigned char *)key.c_str(), key.size(), buf, buflen))

    {

        errorString = "base64 decode failed";

        return false;

    }

    buflen = strlen((const char *)buf);

#endif


to:
 

if (false == unbase64_ssl((unsigned char *)key.c_str(), key.size(), buf, buflen))

    {

        errorString = "base64 decode failed";

        return false;

    }

    buflen = strlen((const char *)buf);



Open db/src/CsvReader.h and change:

#if _MSC_VER

    #include <hash_map>

#else

    #include <map>

#endif

to:

#include <boost/unordered_map.hpp>

also change this:
 

#if _MSC_VER

    typedef stdext::hash_map<std::string, size_t> NAME2INDEX_MAP;

    typedef stdext::hash_map<size_t, std::string> INDEX2NAME_MAP;

#else

    typedef std::map<std::string, size_t> NAME2INDEX_MAP;

    typedef std::map<size_t, std::string> INDEX2NAME_MAP;

#endif


to this:

    typedef boost::unordered_map<std::string, size_t> NAME2INDEX_MAP;

    typedef boost::unordered_map<size_t, std::string> INDEX2NAME_MAP;


Open the file db/src/Main.cpp and delete this lines:

#ifdef __FreeBSD__

    _malloc_options = "A";

#endif[/CODE]

cancelliamo anche queste righe:

[CODE]#ifdef __FreeBSD__

extern const char * _malloc_options;

#endif


Open game/src/MarkImage.h and before this:

 

#include <IL/il.h>



add this:
 

#define IL_STATIC_LIB 1




Server: FreeBSD only changes

We have to modify "CC = (something)" in "CC = g++" open those files with a text editor and modify it, here's the list of files:

- libthecore/src/Makefile

- libsql/Makefile

- libpoly/Makefile

- libgame/src/Makefile

- libserverkey/Makefile

- db/src/Makefile

- game/src/Makefile

- game/src/quest/Makefile (Here it's called CPP not CC)

We also have to modify

"CC= gccX" (where X is a number) in "CC = gcc" inside "liblua/config" (or liblua/5.0/config)


Open libsql/Makefile and delete the following lines:
 

IFLAGS = -I/usr/local/include/ #sometimes necessary included IFLAGS = -I/usr/local/include/mysql



or the following lines if you have them:
oppure potreste avere le seguenti righe che sono da rimuovere:
 

IFLAGS = -I../libmysql/5.x-5.1.35 IFLAGS = -I../libmysql/7.x-5.1.35


Before "LIBS =" add this:
 

VCPKG_DIR=(Your vcpkg directory) IFLAGS = -I$(VCPKG_DIR)/installed/x86-freebsd/include


 Check if you have "-m32" inside this files, otherwise  add this before "LIBS = "
 

CFLAGS += -m32



This check and add process must be done for the following files:

- libthecore/src/Makefile
- libsql/Makefile
- libpoly/Makefile
- libserverkey/Makefile
- libgame/src/Makefile


Open the file game/src/quest/Makefile and if you don't have "-m32" add this before "all: qc cc"
 

CFLAGS += -m32


If you don't have "ENABLE_STATIC = 0" add this before "all: qc cc"
 

CPP += -static



If you have "ENABLE_STATIC = 0" change the 0 in 1.


If you are under FreeBSD x64, you have to add this before "all: qc cc".
 

LIBDIR += -L/usr/local/lib32/gccX[/CODE] While for x86 Freebsd, this

LIBDIR += -L/usr/local/lib/gccX[/CODE]


	Replace X with the gcc major version, you can verify that by typing "gcc --version" in the console.




You can get something like this:


gcc (FreeBSD Ports Collection) 9.3.0
 

In my case, the number is 9.

Open "db/src/Makefile", and delete this lines if you have them
 

ifeq ($(BSD_VERSION), 7)

INCDIR += -I../../libmysql/7.x-5.1.35

LIBDIR += -L../../libmysql/7.x-5.1.35

else

INCDIR += -I../../libmysql/5.x-5.1.35

LIBDIR += -L../../libmysql/5.x-5.1.35

endif


also delete this lines if you have them:
 

# boost

INCDIR += -I../../boost


and also delete this lines:

# Boost

INCDIR += -I../../../Extern/include/boost


# MySQL

INCDIR += -I/usr/local/include/mysql

LIBS += /usr/local/lib/mysql/libmysqlclient.a /usr/lib/libz.a


and also this line:
 

INCDIR += -I/usr/local/include

and this ones:

# Project Libraries

INCDIR += -I../../../Extern/include

LIBDIR += -I../../../Extern/lib


also delete this word:
 

-lmysqlclient



and this one as well:

-Wl,-rpath=/usr/local/lib/gccX

(there could be any number where there is X)

If you don't have "-m32" add before "SRCS =    (some text)" or "CPPFILE = (some text)" this:

CFLAGS += -m32


Add this before "SRCS =    (some text)" or "CPPFILE = (some text)" this:

VCPKG_ROOT (your vcpkg directory)
LIBS += -lmariadbclient -lssl -lcrypto -lz
INCDIR += -I$(VCPKG_ROOT)/installed/x86-freebsd/include
LIBDIR += -L$(VCPKG_ROOT)/installed/x86-freebsd/lib

 

Under FreeBSD x64, you have to add this after the LIBDIR += code you have added before:

LIBDIR += -L/usr/local/lib32/gccX


Under FreeBSD x86 this:

LIBDIR += -L/usr/local/lib/gccX

 

Replace X with your gcc major version code, you can grab that from "gcc --version".


If you don't have "ENABLE_STATIC = 0" add this before the code we added before (LIBDIR += and INCDR +=)
 

CFLAGS += -static

 

If you have "ENABLE_STATIC = 0" change the 0 to 1.


Open game/src/Makefile and delete the following lines (it doesn't matter if you don't have all of them)
 

# boost

INCDIR += -I../../../Extern/include/boost


# DevIL

INCDIR += -I../../libdevil

LIBDIR += -L../../libdevil

LIBS += -lIL -lpng -ltiff -lmng -llcms -ljpeg


# MySQL

ifeq ($(BSD_VERSION), 7)

INCDIR += -I../../libmysql/7.x-5.1.35

LIBDIR += -L../../libmysql/7.x-5.1.35

else

INCDIR += -I../../libmysql/5.x-5.1.35

LIBDIR += -L../../libmysql/5.x-5.1.35

endif


LIBS += -lmysqlclient -lz

# Miscellaneous external libraries

INCDIR += -I../../../Extern/include

LIBDIR += -L../../../Extern/lib

LIBS += -lcryptopp -lgtest


# HackShield

INCDIR += -I../../libhackshield/include

LIBDIR += -L../../libhackshield/lib

LIBS += -lanticpxsvr


# XTrap

INCDIR += -I../../libxtrap/include

and

# Boost

INCDIR += -I../../../Extern/include/boost


# DevIL

INCDIR += -I../../../Extern/include/IL

LIBS += ../../../Extern/lib/libIL.a\

        ../../../Extern/lib/libjasper.a\

        ../../../Extern/lib/libpng.a\

        ../../../Extern/lib/libtiff.a\

        ../../../Extern/lib/libjbig.a\

        ../../../Extern/lib/libmng.a\

        /usr/lib/liblzma.a\

        ../../../Extern/lib/liblcms.a\

        ../../../Extern/lib/libjpeg.a


# MySQL

INCDIR += -I/usr/local/include/mysql

LIBS += /usr/local/lib/mysql/libmysqlclient.a /usr/lib/libz.a


# CryptoPP

LIBS += ../../../Extern/lib/libcryptopp.a

and

# OpenSSL

INCDIR += -I/usr/include

LIBS += -lssl -lcrypto

# LIBS += /usr/lib/libssl.a

and

# Project Libraries

INCDIR += -I../../../Extern/include

INCDIR += -I/usr/local/include

LIBDIR += -L/usr/local/lib


Before "CFILE    = minilzo.c" add this:
 

VCPKG_ROOT= (your vcpkg directory)

INCDIR += -I$(VCPKG_ROOT)/installed/x86-freebsd/include
LIBDIR += -L$(VCPKG_ROOT)/m2pkg/installed/x86-freebsd/lib
LIBS += -lmariadbclient -lcryptopp -lIL -lpng -ljpeg -lssl -lcrypto

Under FreeBSD x64, you have to add this after the LIBDIR += code you have added before:

LIBDIR += -L/usr/local/lib32/gccX


Under FreeBSD x86 this:

LIBDIR += -L/usr/local/lib/gccX

 

Replace X with your gcc major version code, you can grab that from "gcc --version".



If you don't have "ENABLE_STATIC = 0" add this before the code we added before (LIBDIR += and INCDR +=)
 

CFLAGS += -static

 

If you have "ENABLE_STATIC = 0" change the 0 to 1.



Replace:
 

CFILE    = minilzo.c

with:
 

CFILE    = minilzo.c sha1.c



Some sources might not have CFILE, in case you don't have it add "sha1.c" after "item_manager_read_tables.cpp" like this:

 

item_manager_read_tables.cpp sha1.c


Server: Changes for Windows

Open m2server.sln or Metin2Server.sln and update the toolchain if you ask it, ignore any "ServerkeyGenerator" error.


Open game.2008.vcxproj with a text editor and add after this:
 

<ClCompile Include="war_map.cpp" />

this:

<ClCompile Include="sha1.c" />

<ClCompile Include="sha1.h" />

 

If you used an old version of the tutorial, please remove this line:

<VcpkgUserTriplet>x86-windows-static</VcpkgUserTriplet>

You have to remove this line in all the vcxproj files.

 

Open the solution with VisualStudio, select ALL projects, then right click the selection and click Properties.

Inside the properties, click on the left "vcpkg" and make sure to select:

"Static libraries: Yes"

"Auto link: Yes"

spacer.png


 


Client changes


Open EterBase/cipher.h  and change the following lines:


Open cipher.h and modify the following line:

encoder_->ProcessData((byte*)buffer, (const byte*)buffer, length);

to:

encoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);

and from:

decoder_->ProcessData((byte*)buffer, (const byte*)buffer, length);

to:

decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);




Open Eterbase/lzo.cpp and delete this line:
 

#include <lzo-2.03/lzoLibLink.h>


"lzo-2.03" may vary, it's important to delete the lzoLibLink inclusion.

Open EterBase/lzo.h and check that the #include with lzo1x.h is like this:
 

#include <lzo/lzo1x.h>



Open UserInterface/MarkImage.h and before this:
 

#include <IL/il.h>

add this:

#define IL_STATIC_LIB 1

 

 

Open UserInterface.cpp and delete the following line:
 

#include <cryptopp/cryptoppLibLink.h>


Inside UserInterface.cpp modifiy this:

 

static const char * sc_apszPythonLibraryFilenames[] =

{

    "UserDict.pyc",

    "future.pyc",

    "copy_reg.pyc",

    "linecache.pyc",

    "ntpath.pyc",

    "os.pyc",

    "site.pyc",

    "stat.pyc",

    "string.pyc",

    "traceback.pyc",

    "types.pyc",

    "\n",

};

to:
 

static const char * sc_apszPythonLibraryFilenames[] =

{

#if PY_MINOR_VERSION == 7

    "abc.pyc",

    "bisect.pyc",

    "codecs.pyc",

    "collections.pyc",

    "copy.pyc",

    "copy_reg.pyc",

    "fnmatch.pyc",

    "functools.pyc",

    "genericpath.pyc",

    "heapq.pyc",

    "keyword.pyc",

    "linecache.pyc",

    "locale.pyc",

    "ntpath.pyc",

    "os.pyc",

    "pyexpat.pyd",

    "random.pyc",

    "re.pyc",

    "shutil.pyc",

    "site.pyc",

    "sre_compile.pyc",

    "sre_constants.pyc",

    "sre_parse.pyc",

    "stat.pyc",

    "string.pyc",

    "sysconfig.pyc",

    "traceback.pyc",

    "types.pyc",

    "UserDict.pyc",

    "warnings.pyc",

    "weakref.pyc",

    "_abcoll.pyc",

    "_weakrefset.pyc",

    "__future__.pyc",

    "encodings\\aliases.pyc",

    "encodings\\ascii.pyc",

    "encodings\\cp1250.pyc",

    "encodings\\cp1251.pyc",

    "encodings\\cp1252.pyc",

    "encodings\\cp949.pyc",

    "encodings\\utf_8.pyc",

    "encodings\\__init__.pyc",

    "xml\\__init__.pyc",

    "xml\\dom\\domreg.pyc",

    "xml\\dom\\expatbuilder.pyc",

    "xml\\dom\\minicompat.pyc",

    "xml\\dom\\minidom.pyc",

    "xml\\dom\\NodeFilter.pyc",

    "xml\\dom\\xmlbuilder.pyc",

    "xml\\dom\\__init__.pyc",

    "xml\\parsers\\expat.pyc",

    "xml\\parsers\\__init__.pyc",

#else

    "UserDict.pyc",

    "__future__.pyc",

    "copy_reg.pyc",

    "linecache.pyc",

    "ntpath.pyc",

    "os.pyc",

    "site.pyc",

    "stat.pyc",

    "string.pyc",

    "traceback.pyc",

    "types.pyc",

#endif

    "\n",

};[


Delete the following lines:
 

#if GrannyProductMinorVersion==4

#pragma comment( lib, "granny2.4.0.10.lib" )

#elif GrannyProductMinorVersion==7

#pragma comment( lib, "granny2.7.0.30.lib" )

#elif GrannyProductMinorVersion==8

#pragma comment( lib, "granny2.8.49.0.lib" )

#elif GrannyProductMinorVersion==9

#pragma comment( lib, "granny2.9.12.0.lib" )

#else

#error "unknown granny version"

#endif

or this line:

#pragma comment( lib, "granny2.lib" )

Also delete this lines:

//ifdef _DEBUG

//#pragma comment( lib, "python2_d.lib" )

//#else

#pragma comment( lib, "python2.lib" )

//#endif

#pragma comment( lib, "devil.lib" )

#ifdef _DEBUG

#pragma comment( lib, "jpegd.lib" )

#else

#pragma comment( lib, "jpeg.lib" )

#endif

#pragma comment( lib, "cryptopp-static.lib" )

#pragma comment( lib, "snappy.lib" )

#pragma comment( lib, "lzo2.lib" )


Delete snappy inclusion if you don't use Type6.

Disable this ifdef if you have it:
#define ENABLE_PYLIB_CHECK


Open EterPack/EterPack.cpp and delete this line:
 

#include <cryptopp/cryptoppLibLink.h>


Open UserInterface/GuildMarkUploader.cpp and delete:
 

(ILvoid*)



Open EterLib/JpegFile.cpp and make sure that jpeglib.h inclusion is like this:

#include <jpeglib.h>



then remove this line:

#include <libjpeg-6b/jpegLibLink.h>


"libjpeg-6b" may vary.


Inside GrpDetector.h add this after #include <d3dx8.h>

#include <string>



Inside ScriptLib\StdAfx.h replace:

#ifdef _DEBUG

    #undef _DEBUG

    #include "../../Extern/Python2/Python.h"

    #define _DEBUG

#else

    #include "../../Extern/Python2/Python.h"

#endif

#include "../../Extern/Python2/node.h"

#include "../../Extern/Python2/grammar.h"

#include "../../Extern/Python2/token.h"

#include "../../Extern/Python2/parsetok.h"

#include "../../Extern/Python2/errcode.h"

#include "../../Extern/Python2/compile.h"

#include "../../Extern/Python2/symtable.h"

#include "../../Extern/Python2/eval.h"

#include "../../Extern/Python2/marshal.h"

the Python inclusion may vary

to

#include <python2.7/Python.h>
#include <python2.7/node.h>
#include <python2.7/grammar.h>
#include <python2.7/token.h>
#include <python2.7/parsetok.h>
#include <python2.7/errcode.h>
#include <python2.7/compile.h>
#include <python2.7/eval.h>
#include <python2.7/marshal.h>

#undef BYTE // Fixed python bitset.h build issue



Inside scriptLib/PythonLauncher.h modify
 

#include "../../Extern/Python2/frameobject.h"

to:
 

#include <python2.7/frameobject.h>



Open scriptLib/PythonLauncher.cpp and modify:
 

#include "../../Extern/Python2/frameobject.h"

to:

#include <python2.7/frameobject.h>


Open scriptLib/PythonMarshal.cpp  and modify:

#include "../../Extern/Python2/longintrepr.h"

to:

#include <python2.7/longintrepr.h>


Open ScriptLib/PythonUtils.cpp and if we don't have this
 

#define PyLong_AsLong PyLong_AsLongLong

#define PyLong_AsUnsignedLong PyLong_AsUnsignedLongLong


add it after this:

#include "PythonUtils.h"


Open EterBase\StdAfx.h and modify:

// Armadillo nanomite protection

#ifndef NANOBEGIN

    #ifdef __BORLANDC__

        #define NANOBEGIN     __emit__ (0xEB,0x03,0xD6,0xD7,0x01)

        #define NANOEND       __emit__ (0xEB,0x03,0xD6,0xD7,0x00)

    #else

        #define NANOBEGIN     __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x01

        #define NANOEND       __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x00

    #endif

#endif

in:

// Armadillo nanomite protection

#if !defined(NANOBEGIN) && !defined(NANOEND)

    #ifdef _DEBUG

        #define NANOBEGIN

        #define NANOEND

    #else

        #include <armadillo/SecuredSections.h>

    #endif

#endif


This change also needs to be applied to the following files:

- EterGrnLib/StdAfx.h
- MilesLib/StdAfx.h
- SpeedTreeLib/StdAfx.h


Open MilesLib/StdAfx.h and delete this line:
 

#include <mss.h>


Open the client sln file (like Metin2Client.sln or Metin2Client_VC90.sln)
if it asks for any linked update press yes.

 

Then go to UserInterface properties, select at the top of the window "Configuration: ", it might be Debug, Release, Distribute, and set it "All configurations":

spacer.png

Modify /SAFESEH to /SAFESEH:NO.

spacer.png
 

Select ALL projects, then right click the selection and click Properties.

Inside the properties, click on the left "vcpkg" and make sure to select:

"Static libraries: Yes"

"Auto link: Yes"

spacer.png

Go to C/C++, General, you will find "Extra inclusion directories" for something similar. Press the little arrow in the text, then modify.

Add the following:

$(SolutionDir)Extern\include.

Then, select the UserInterface project. Go to Linker, General and find "Extra library directory". Press the little arrow in the text, then Modify. Add the following:

$(SolutionDir)Extern\lib.

 

If you used an old version of the tutorial, please remove this line:

<VcpkgUserTriplet>x86-windows-static</VcpkgUserTriplet>

You have to remove this line in all .vcxproj files.

 


Client: Cleanup and update of binary files

Open our clinet directory and delete all DLL with the exception of this (MAKE SURE TO NOT RMEOVE ANY EXTRA DLL YOU HAVE INSERTED)

- SpeedTreeRT.dll
- granny2.dll
- MSS32.dll

Delete the "lib" directory and replace with this directory
This directory works for Python 2.7.

 

Final notes and infos
 

  • If you use Granny 2.9 open EterBase/ServiceDefs.h and add this:
#define __GRANNY_VERSION__ 9


after

#define _IMPROVED_PACKET_ENCRYPTION_

 

  • The vcpkg folder already contains MSL (required for marty sources), check in share/moduleinfo.txt and if there is a new commit, you can replace the inclusions, you can also upload the new updated package and I can update the tutorial.
  • The Python libraries I have distributed works for 2.7.15, it includes expat and some encoding modules, if vcpkg update them, perform the update of the lib by yourself (you can also upload the new lib file for everyone to use) or notify me about that I'll try to get a new update.
  • pyexpat.pyd was bult by me with Visual Studio 2019 (Toolchain version 16.2) and Specre mitigation
  • I have disabled the extra ENABLE_PYLIB_CHECK (found on marty sources as well) for the following reasons:

- Does not support Python 2.7.15 and I haven't got the will to make a script to calculate the new hashes

- I don't mind using that check, the official check is less secure but it works for a basic check.

 

Fell free to comment with the check code updated and I'll update the post.

  • The Visual Studio and Makefile updates do not apply with CMake or Premake (pff anyone uses them unironically?)
  • The tutorial might not be 100% accurate for all the sources, I have tested it with mainline_released, a marty internet released and some friends sources (Client side)
  • FreeBSD currently does not work on vcpkg, I will look at fixing the issues when I have time.
  • The log.c changes removed 1058340518920543890 logging messages on Windows.
  • The armadillo change not only update the nanomites to the last version (while Armadillo is deprecated) but also fixes some debugging issues, sometimes, calling those asm routimes might corrupt the debugger, so it's better to disable them if they are not required (Debug builds)
  • If you need newer version of granny2, modify grann2.h accordingly, you can also share the update if you wish to.
  • This version of the tutorial is more updated than the one I have released on the other kek it forum. Changes:

- Removed all x86-windows-static specification as the new vcpkg integration is easier to use.

- Ability to customize the vcpkg root directory

- Removed all infos about compiling the sources and so on as they were not required in this forum (I do really expect that people knows how to build in this forum)

- Removed all the old manual linking as vcpkg supports automatic linking now


I apologize for any grammar error or formatting error, I have not checked the post twice, you can freely report any error in the comments.
 

Good luck in your experiments.

Edited by arves100
Update some boring stuff about vcpkg & shit (see edit history)
  • Love 14
  • Think 1
  • See 2

Ripymir(2013)

Link to post
Posted (edited)

#update

Added screenshot of vcpkg.

Removed symtable and typedef since they are not used.

Added changes for removing the old method

Added missing static link in vcpkg for server.

 

New note: mariadb uses it's integrated zlib, this causes issues in client build.

Edited by arves100 (see edit history)

Ripymir(2013)

Link to post


gcc-9_4                        Meta-port for the default version of the GNU Compiler Collection
gcc9-9.3.0_1                   GNU Compiler Collection 9
And ninja

ninja-1.10.0,2                 Small build system closest in spirit to Make
 

Link to post
1 minute ago, Flourine said:


gcc-9_4                        Meta-port for the default version of the GNU Compiler Collection
gcc9-9.3.0_1                   GNU Compiler Collection 9
And ninja

ninja-1.10.0,2                 Small build system closest in spirit to Make
 

Try to change this line inside src/vcpkg/base/system.cpp

https://github.com/microsoft/vcpkg/blob/56fffbe49dfb4dd8fae0940f272c5fd2b86be991/toolsrc/src/vcpkg/base/system.cpp#L50

to

#elif defined(__x86__) || defined(_M_X86) || defined(__i386__)

Ripymir(2013)

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.