Jump to content

Update Client Compilation to ISO C++17


Recommended Posts

  • Premium

Why?

Why not?

Seriously though, why?

I was legit just bored.

 

Ok, first of all, we need to indicate to Visual Studio that we wanna compile with the flag /std:c++17. You do so by selecting all the projects on the right and clicking properties:

2422347RqZibz.png

 

and click on Apply (duh)

Then let's fix the first issue, the introduction of std::byte.

For some reason (and you should never ever ever ever ever ever do it), there are some:

using namespace std;

in the code. DELETE. THEM. ALL.

Now compile. Yeah, it's not over, because now, we should edit all the std functions (make_pair, string, declarations of maps, vectors etc.) adding std:: before, for ex:

operator const string() const { return m_sRaw; }

becomes

operator const std::string() const { return m_sRaw; }

just compile and fix them all whenever you find them.

A few of them are more "difficult".

Open Stl.h in EterBase and there's gonna be:

namespace std
{
	template <class _Ty>
	class void_mem_fun_t
		: public unary_function<_Ty *, void> {
	public:
		explicit void_mem_fun_t(void (_Ty::*_Pm)())
			: _Ptr(_Pm) {}
		void operator()(_Ty *_P) const
		{((_P->*_Ptr)()); }
	private:
		void (_Ty::*_Ptr)();
		};
	template<class _Ty> inline
	void_mem_fun_t<_Ty> void_mem_fun(void (_Ty::*_Pm)())
	{return (void_mem_fun_t<_Ty>(_Pm)); }

	template<class _Ty>
	class void_mem_fun_ref_t : public unary_function<_Ty, void> {
	public:
		explicit void_mem_fun_ref_t(void (_Ty::*_Pm)())
			: _Ptr(_Pm) {}
		void operator()(_Ty& _X) const
		{return ((_X.*_Ptr)()); }
	private:
		void (_Ty::*_Ptr)();
	};

	template<class _Ty> inline
	void_mem_fun_ref_t<_Ty> void_mem_fun_ref(void (_Ty::*_Pm)())
	{return (void_mem_fun_ref_t< _Ty>(_Pm)); }


		// TEMPLATE CLASS mem_fun1_t
template<class _R, class _Ty, class _A>
	class void_mem_fun1_t : public binary_function<_Ty *, _A, _R> {
public:
	explicit void_mem_fun1_t(_R (_Ty::*_Pm)(_A))
		: _Ptr(_Pm) {}
	_R operator()(_Ty *_P, _A _Arg) const
		{return ((_P->*_Ptr)(_Arg)); }
private:
	_R (_Ty::*_Ptr)(_A);
	};
		// TEMPLATE FUNCTION mem_fun1
template<class _R, class _Ty, class _A> inline
	void_mem_fun1_t<_R, _Ty, _A> void_mem_fun1(_R (_Ty::*_Pm)(_A))
	{return (void_mem_fun1_t<_R, _Ty, _A>(_Pm)); }


}

fucking remove this shit.

 

Then replace all the:

std::void_mem_fun

with

std::mem_fn

Then in cipher.cpp replace

std::auto_ptr

into

std::unique_ptr

and then boost is gonna come busting our ass, so just upgrade the folder downloading the last version and..nope:

Quote

Severity    Code    Description    Project    File    Line    Suppression State
Error    C4996    'std::allocator<std::pair<const K,T>>::is_always_equal': warning STL4010: Various members of std::allocator are deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.    SoundLibrary    F:\*******\Third-party\include\boost\unordered\detail\implementation.hpp    1452    
 

Alright, I'd suggest to just disable this error:

How to disable by Microsoft (do it for every project causing this error)

If you fix boost's code, kudos to you.

Then, after a lot of:

Quote

warning C5033: 'register' is no longer a supported storage class

from Python, it should be compiled.

 

If you have ikarus offline shop, you should recompile libconfig with the same settings (probably cryptopp aswell? Honestly I can't remember)

 

  • Metin2 Dev 18
  • Not Good 1
  • Scream 1
  • Good 8
  • Love 8
  • Love 22
Link to comment
Share on other sites

  • 1 year later...

from 

'register' is no longer a supported storage class

in to EterBase/Random.cpp search

unsigned long random()
{       
	register long x, hi, lo, t;
	
	/*
	* Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
	* From "Random number generators: good ones are hard to find",
	* Park and Miller, Communications of the ACM, vol. 31, no. 10,
	* October 1988, p. 1195.
	*/ 
	x = randseed;
	hi = x / 127773;
	lo = x % 127773;
	t = 16807 * lo - 2836 * hi;
	if (t <= 0)
		t += 0x7fffffff;
	randseed = t;
	return (t);
}

change like this or replace  

unsigned long random()
{
	/*
	* Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
	* From "Random number generators: good ones are hard to find",
	* Park and Miller, Communications of the ACM, vol. 31, no. 10,
	* October 1988, p. 1195.
	*/
	long x = randseed;
	long hi = x / 127773;
	long lo = x % 127773;
	long t = 16807 * lo - 2836 * hi;
	if (t <= 0)
		t += 0x7fffffff;
	randseed = t;
	return (t);
}

search in to tea.cpp

void tea_code(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
{
	register unsigned long y = sy, z = sz, sum = 0;
	unsigned long		n = TEA_ROUND;
	
	while (n-- > 0)
	{
		y	+= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
		sum	+= DELTA;
		z	+= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
	}
	
	*(dest++)	= y;
	*dest	= z;
}

void tea_decode(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
{
#pragma warning(disable:4307)
	register unsigned long y = sy, z = sz, sum = DELTA * TEA_ROUND;
#pragma warning(default:4307)

	unsigned long		n = TEA_ROUND;
	
	while (n-- > 0)
	{
		z -= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
		sum -= DELTA;
		y -= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
	}
	
	*(dest++)	= y;
	*dest	= z;
}

replace with this :

void tea_code(const uint32_t sz, const uint32_t sy, const uint32_t * key, uint32_t * dest)
{
	uint32_t y = sy, z = sz, sum = 0;
	uint32_t n = TEA_ROUND;

	while (n-- > 0)
	{
		y += ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
		sum += DELTA;
		z += ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
	}

	*(dest++) = y;
	*dest = z;
}

void tea_decode(const uint32_t sz, const uint32_t sy, const uint32_t * key, uint32_t * dest)
{
#pragma warning(disable : 4307)
	uint32_t y = sy, z = sz, sum = DELTA * TEA_ROUND;
#pragma warning(default : 4307)

	uint32_t n = TEA_ROUND;

	while (n-- > 0)
	{
		z -= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
		sum -= DELTA;
		y -= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
	}

	*(dest++) = y;
	*dest = z;
}

search in to Utils.cpp:

int MINMAX(int min, int value, int max)
{
	if (max < min)
		return MAX(min, value);

    register int tv;
    tv = (min > value ? min : value);
    return (max < tv) ? max : tv;
}

replace with this :

int MINMAX(int min, int value, int max)
{
	if (max < min)
		return MAX(min, value);

	int tv = (min > value ? min : value);
	return (max < tv) ? max : tv;
}

search

float fMINMAX(float min, float value, float max)
{               
    register float tv;
	
    tv = (min > value ? min : value);
    return (max < tv) ? max : tv;
}

replace with this :

float fMINMAX(float min, float value, float max)
{
	float tv = (min > value ? min : value);
	return (max < tv) ? max : tv;
}

 

Edited by spectrum
update
  • Love 1
Link to comment
Share on other sites

Announcements



×
×
  • 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.