Jump to content

Recommended Posts

Hello

I have been trying to recompile server sources for Avenor2 files. I have pretty much been able to compile libgame, liblua, libpoly, libsql, libthecore, db but game won't compile and give me over 5000 errors.

After some investigating, most of them are due to WORD type that is not recognised properly. I am using VS 2019 and I have compared sources from this setup :

 

Has someone managed to compile those server files in particular ?

Here is an example of error : https://metin2.download/picture/iVu45B8yO4lWdo028FS2WswLiTc4gN5i/.png

Am I missing a library ? A bit clueless at this point to be honest ...

Thanks!

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

'WORD' is most likely a typedef for an unsigned 16-bit integer type. It's probably defined in some header you are not including.

If you can't find the header it is defined, you can define it yourself like:

//C style typedef
//typedef unsigned short WORD;

//Still C style, but using sized types from <cstdint>
//typedef std::uint16_t WORD;

//This is the (modern) C++ way
using WORD = std::uint16_t;

That should solve your 'WORD' problem. I still think you should scan your headers, 'WORD' is probably defined somewhere.

I recommend you stop using these types (like WORD, BYTE, etc), and use the types defined in <cstdint> (like std::uint32_t, std::int32_t, etc).

Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166107
Share on other sites

Sorry for the late reply just got home work.

Thanks for your contribution @TheEqualizer that gives me good hints to look for.

After some researches I learnt that these types are defined in the SDK 10.0.

Both my projects are using SDK 10.0 so the problem is somewhere else.

From https://learn.microsoft.com/en-us/windows/win32/winmsg/makeword

It states : Header : minwindef.h (include Windows.h (there is a typo it states Windows.h whereas it is actually windows.h)

It is defined in minwindef.h :

typedef unsigned long       DWORD;
typedef int                 BOOL;
typedef unsigned char       BYTE;
typedef unsigned short      WORD;

So I have tried checking from a VS2022 project that compiles where this header would be included :

- main.cc of libpoly

- loadlib.c from liblua

- stdafx.h from libthecore

From my VS2019 project (Avenor2 server sources) It is included at the exact same places + typedef.h that includes wndows.h.

Could it be an issue where a library is compiled in the wrong order ? I have tried including windows.h from the main of game project (VS2019 project) as a test (I assumed it would atleast give me a different build result as the entire game project would have that header included) but it doesn't change anything.

I believe simply putting this define might be a work-around but I wonder if that it is just going to move the problem elsewhere (if the header is not loaded maybe an entire lib is not loaded or something similar which would lead to server crash).

Any ideas I didn't think of to figure this out ? I have compared project references, includes, build orders and dependencies and they both have similar settings (VS2019 / VS2022). Only noticeable difference is the GCC version used which I don't expect to be the reason of the issue here.

Edit : this piece of code from liblua/src/lib/loadlib.c (VS2019 project) might be useful

/*
** In Windows, default is to use dll; otherwise, default is not to use dll
*/
#ifndef USE_DLL
/*
** In Windows, default is to use dll; otherwise, default is not to use dll
*/
#ifndef USE_DLL
#ifdef _WIN32
#define USE_DLL	1
#else
#define USE_DLL	0
#endif
#endif


#if USE_DLL
#define LOADLIB
/*
* This is an implementation of loadlib for Windows using native functions.
*/

#include <windows.h>

Thanks !

Edited by huntmaster
Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166118
Share on other sites

Since your problem is the server source (which runs on linux), then you won't get the windows defines/typedefs. I think you should search the server files until you find the one that contains the definitions you are missing.

I don't work on server stuff, so I can't give specific pointers.

 

EDIT: I just did a search, and the definitions you are looking for should be inside "libthecore/typedef.h", so I believe you probably got the dependencies wrong which is causing this file not to be included.

Edited by TheEqualizer
Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166119
Share on other sites

Thanks for your fast reply.

Here are my dependencies and build orders for both projects, nothing seems wrong to me 😕

(I removed libserverkey on purpose for Avenor2 sources as they were not included and i c/p from VS2022 project but they don't really belong there)

https://metin2.download/picture/oWcS429zO2WEnd2heN7ie0S8Ct4s5lv1/.png

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166121
Share on other sites

Sorry for double post but for some reason I am unable to edit my previous one.

Update :

The type WORD is not recognized at the very beginning of my main (VS2019) whereas it is on the VS2022 project which means that from the very beginning of game compilation word is not defined as an unsigned short.

For test purposes here is my main.cpp (game) :

int main(int argc, char** argv)
{

	ilInit();
	DWORD test_var; // DWORD is recognised as typedef unsigned long
	QWORDZZZ test_var3; // QWORDZZZ is recognised as unsigned short
	WORD test_var2; // WORD is recognised as WORD(<error-type>)
      ...
}

Here is my typedef.h (from libthecore) :

#ifndef __INC_LIBTHECORE_TYPEDEF_H__
#define __INC_LIBTHECORE_TYPEDEF_H__

typedef unsigned long int       QWORD;
typedef unsigned char           UBYTE;
typedef signed char             sbyte;
typedef unsigned short		sh_int;

typedef unsigned short       QWORDZZZ; // A custom type I created 
typedef unsigned short 		WORD;

#ifndef __WIN32__

#ifndef __cplusplus
typedef unsigned char		bool;
#endif
typedef unsigned int		DWORD;
typedef int			BOOL;
typedef unsigned char		BYTE;
typedef unsigned short 		WORD;
typedef long			LONG;
typedef unsigned long		ULONG;
typedef int			INT;
typedef unsigned int		UINT;

typedef int			socket_t;

 

So I created a new type called QWORDZZZ (unsigned short) in typedef.h

The main() from game can access it and recognizes it as a proper type (unsigned short)

But if I try to define WORD such as above (as an unsigned short) it gets override by WORD(<error-type>)

I make 2 conclusions :

- During game compilation, it reaches the typedef.h from libthecore which contains the definition of WORD (my source of errors in the compilation)

- WORD gets override by something else in the process / is not considered declared

Any ideas?

Edited by huntmaster
Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166124
Share on other sites

Sorry, I went through the post quickly so maybe I don't have all the info.. But why do you want to use this sf? It's a leak, screw it.. If it's worth anything, take some ideas and code snippets from it.. Anyway, I don't think there's anything more to it that we haven't seen before..

Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166126
Share on other sites

18 hours ago, Filachilla said:

Sorry, I went through the post quickly so maybe I don't have all the info.. But why do you want to use this sf? It's a leak, screw it.. If it's worth anything, take some ideas and code snippets from it.. Anyway, I don't think there's anything more to it that we haven't seen before..

Why would I not ? Didn't feel like starting from scratch to re implement everything that exists and has already been implemented ...

At this point It's more about fixing those sources than anything else lol

After a bunch of hours looking into the code, I have found where my type get lost in the code :

game/src/utils.h

inline uint16_t MAKEWORD(BYTE a, BYTE b)
{
	return static_cast<uint16_t>(a) | (static_cast<uint16_t>(b) << 8);
}

When I get this commented I jump from 5k+ errors to 300ish.

I don't quite understand why is that so if someone could explain I would appreciate !

Link to comment
https://metin2.dev/topic/32807-avenor2-server-sources/#findComment-166134
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



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.