Jump to content

[Collector's topic] Remove Unussed code


Recommended Posts

Hi guys, I created this topic to have a collection topic about removing unnecessary code. 

Sexy Look GIF

 

blocked_country_ip


 

Spoiler

Common/tables.h

search this and remove:

 

	HEADER_GD_BLOCK_COUNTRY_IP		= 127,		// ±¤´ëżŞ IP-Block
	HEADER_GD_BLOCK_EXCEPTION		= 128,		// ±¤´ëżŞ IP-Block żążÜ


	HEADER_DG_BLOCK_COUNTRY_IP		= 171,		// ±¤´ëżŞ IP-Block
	HEADER_DG_BLOCK_EXCEPTION		= 172,		// ±¤´ëżŞ IP-Block żążÜ account

search this too and remove

 

// Block Country Ip
typedef struct tBlockCountryIp
{
	DWORD	ip_from;
	DWORD	ip_to;
} TPacketBlockCountryIp;

enum EBlockExceptionCommand
{
	BLOCK_EXCEPTION_CMD_ADD = 1,
	BLOCK_EXCEPTION_CMD_DEL = 2,
};

// Block Exception Account
typedef struct tBlockException
{
	BYTE	cmd;	// 1 == add, 2 == delete
	char	login[LOGIN_MAX_LEN + 1];
}TPacketBlockException;

db/src:

remove this files:

BlockCountry.cpp +  BlockCountry.h

 

open db/clientmanager.cpp

remove this:

 

#include "BlockCountry.h"

search this and remove:

 

		case HEADER_GD_BLOCK_COUNTRY_IP:
			sys_log(0, "HEADER_GD_BLOCK_COUNTRY_IP received");
			CBlockCountry::instance().SendBlockedCountryIp(peer);
			CBlockCountry::instance().SendBlockException(peer);
			break;

		case HEADER_GD_BLOCK_EXCEPTION:
			sys_log(0, "HEADER_GD_BLOCK_EXCEPTION received");
			BlockException((TPacketBlockException*)data);
			break;

search this and remove too:

 

void CClientManager::BlockException(TPacketBlockException* data)
{
	sys_log(0, "[BLOCK_EXCEPTION] CMD(%d) login(%s)", data->cmd, data->login);

	// save sql
	{
		char buf[1024];

		switch (data->cmd)
		{
		case BLOCK_EXCEPTION_CMD_ADD:
			snprintf(buf, sizeof(buf), "INSERT INTO block_exception VALUES('%s')", data->login);
			CDBManager::instance().AsyncQuery(buf, SQL_ACCOUNT);
			CBlockCountry::instance().AddBlockException(data->login);
			break;
		case BLOCK_EXCEPTION_CMD_DEL:
			snprintf(buf, sizeof(buf), "DELETE FROM block_exception VALUES('%s')", data->login);
			CDBManager::instance().AsyncQuery(buf, SQL_ACCOUNT);
			CBlockCountry::instance().DelBlockException(data->login);
			break;
		default:
			return;
		}

	}

	for (itertype(m_peerList) it = m_peerList.begin(); it != m_peerList.end(); ++it)
	{
		CPeer* peer = *it;

		if (!peer->GetChannel())
			continue;

		CBlockCountry::instance().SendBlockExceptionOne(peer, data->login, data->cmd);
	}
}

Open db/clientmanager.h

search this and remove:

 

	void BlockException(TPacketBlockException* data);

Open Main.cpp

search this and remove:

 

#include "BlockCountry.h"

search too and remove:

 

	CBlockCountry	BlockCountry;

and this:

 

	BlockCountry.Load();

makefile

Search this and remove too:

 

BlockCountry.cpp

 

open game src and remove this files:

Block_Country.cpp + Block_Country.h -> cpp remove too makefile

Open game/db.cpp

search this and remove:

 

void DBManager::RequestBlockException(const char* login, int cmd)
{
	TPacketBlockException packet;

	packet.cmd = cmd;
	strlcpy(packet.login, login, sizeof(packet.login));
	db_clientdesc->DBPacket(HEADER_GD_BLOCK_EXCEPTION, 0, &packet, sizeof(packet));
}

open db.h and remove this:

 

	// BLOCK EXCEPTION
	void			RequestBlockException(const char* login, int cmd);
	// BLOCK EXCEPTION

open input.cpp and remove this:

 

				else if (!stBuf.compare(0, 15, "BLOCK_EXCEPTION"))
				{
					// BLOCK_EXCEPTION cmd(add=1, del=2) login
					std::istringstream is(stBuf);
					std::string	dummy_string;
					std::string	login_string;
					int			cmd;

					is >> dummy_string >> cmd >> login_string;

					sys_log(0, "block_exception %s:%d", login_string.c_str(), cmd);
					DBManager::instance().RequestBlockException(login_string.c_str(), cmd);
					stResult = "BLOCK_EXCEPTION_YES";
				}

open input.h and remove this:

 

	void		AddBlockCountryIp(TPacketBlockCountryIp* data);
	void		BlockException(TPacketBlockException* data);

open input_db and remove this:

 

#include "block_country.h"

+ this:

 

	// request blocked_country_ip
	{
		db_clientdesc->DBPacket(HEADER_GD_BLOCK_COUNTRY_IP, 0, NULL, 0);
		dev_log(LOG_DEB0, "<sent HEADER_GD_BLOCK_COUNTRY_IP>");
	}

and this:

 

	case HEADER_DG_BLOCK_COUNTRY_IP:
		this->AddBlockCountryIp((TPacketBlockCountryIp*)c_pData);
		break;
	case HEADER_DG_BLOCK_EXCEPTION:
		this->BlockException((TPacketBlockException*)c_pData);
		break;

and more this:

 

void CInputDB::AddBlockCountryIp(TPacketBlockCountryIp* data)
{
	add_blocked_country_ip(data);
}

void CInputDB::BlockException(TPacketBlockException* data)
{
	block_exception(data);
}

open input_login.cpp and remove this:

 

#include "block_country.h"

+ this:

 

	// is blocked ip?
	{
		dev_log(LOG_DEB0, "check_blocked_country_start");

		if (!is_block_exception(login) && is_blocked_country_ip(d->GetHostName()))
		{
			sys_log(0, "BLOCK_COUNTRY_IP (%s)", d->GetHostName());
			d->SetPhase(PHASE_CLOSE);
			return;
		}

		dev_log(LOG_DEB0, "check_blocked_country_end");
	}

open packet.h and remove this:

 

	HEADER_GG_BLOCK_EXCEPTION		= 24,

 

Limit_time

 

Spoiler

open db/clientmanagerlogin.cpp

search this and remove:

 

#ifdef ENABLE_LIMIT_TIME
	static int s_updateCount = 0;
	static int s_curTime = time(0);
	if (s_updateCount > 100)
	{
		s_curTime = time(0);
		s_updateCount = 0;
	}
	++s_updateCount;

	if (s_curTime >= GLOBAL_LIMIT_TIME)
	{
		sys_err("Server life time expired.");
		exit(0);
		return;
	}
#endif


open game/desc.cpp and remove this:

 

#ifdef ENABLE_LIMIT_TIME
	if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
	{
		extern void ClearAdminPages();
		ClearAdminPages();
		extern g_bShutdown;
		g_bShutdown = true;
	}
#endif

open game/input.cpp

search this + remove:

 

#ifndef __WIN32__
#include "limit_time.h"
#endif

and this:
 

#ifdef ENABLE_LIMIT_TIME
	if (Metin2Server_IsInvalid())
	{
		extern bool g_bShutdown;
		g_bShutdown = true;
		ClearAdminPages();
	}
#endif

open input_auth.cpp

search this and remove:

 

#ifndef __WIN32__
#include "limit_time.h"
#endif

+

 

#ifdef ENABLE_LIMIT_TIME
	extern bool Metin2Server_IsInvalid();

	if (Metin2Server_IsInvalid())
	{
		extern void ClearAdminPages();
		ClearAdminPages();
		exit(1);
		return;
	}
#endif

and + this:
 

#ifdef ENABLE_LIMIT_TIME
	extern bool Metin2Server_IsInvalid();

	if (Metin2Server_IsInvalid())
	{
		extern void ClearAdminPages();
		ClearAdminPages();
		exit(1);
		return;
	}
#endif

delete two file from game folder (limit_time.h + update_limit_time.py)

Open game/main.cpp

search this and remove:

 

#ifndef __WIN32__
#include "limit_time.h"
#endif

+ this:
 

#ifdef ENABLE_LIMIT_TIME
		if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
		{
			g_bShutdown = true;
		}
#endif

and YEAH this too:

 

#ifdef ENABLE_LIMIT_TIME
	if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
	{
		return 0;
	}
#endif

open game/makefile and remove this:

 

limit_time:
	@echo update limit time
	@python update_limit_time.py

 


More removed code:

 

Spoiler

This is the hidden content, please
 or 
This is the hidden content, please

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 236
  • kekw 2
  • Eyes 6
  • Dislove 1
  • Angry 2
  • Sad 1
  • Think 2
  • Confused 1
  • Good 65
  • Love 7
  • Love 105
Link to comment
Share on other sites

1 hour ago, Hik said:

I think you can also delete passpod, openid, teen packet, vcard, aucion, login_sim etc.

Yes i make tutorial, but i upload to github. I need 2 day to write tutorial.


This is the hidden content, please


#Included passpod + openid

Edited by SamuraiHUN
  • Metin2 Dev 60
  • Eyes 1
  • Dislove 1
  • Angry 1
  • Confused 1
  • Good 18
  • Love 2
  • Love 31
Link to comment
Share on other sites

  • Premium

thanks for share!

 

here a list of (for me) unnecessary code/functions/systems:

Spoiler

Auction
Monarch
Billing (GameTime)
Matrix
Passpod
PC Bang
OpenID
HammerOfTor
CheckAwakeness
Hotbackup
Speed Server
China Intoxication Event / Teen
Siege / Castle / Fork / Battle Arena
Three Way
Auth Brazil
Dance Event
Protect Child
Lotto
Roulette
Highscore
Panama
PackageCryptInfo
Block Exception
Input_UDP
Greet / QID_DB_STRING
Mobile / SMS
g_bCheckMultiHack
Hack Shield
XTRAP
check_server
limit_time

 

  • Metin2 Dev 3
  • Angry 1
  • Love 1
Link to comment
Share on other sites

  • Active Member

You need to configure the buffer after these Remove unussed so that you never have a problem on your multiplayer server.

Buffer 64bit = 65536   use after second 8192

If you do not set the buffer then you do not suggest these changes

 

protocol.h 

search: #define DEFAULT_PACKET_BUFFER_SIZE 65536

 

change with :

 

#define DEFAULT_PACKET_BUFFER_SIZE 95536 //fix 

 

 

  • Smile Tear 2
  • Think 2
Link to comment
Share on other sites

  • Management
On 11/2/2021 at 10:50 PM, Denizeri24 said:

what the fucking stupid deleted my comment without notice?

You could have copied/pasted part of your topic before redirecting to an external link 😉

  • Good 1
Link to comment
Share on other sites

  • Active Member
1 hour ago, r00t3r said:

after i delete the billing i cant login in game, is blocked at " you will be connected"

Remove from python and source client  

They are not 100% complete

Send me a message to help you delete them correctly

Link to comment
Share on other sites

@tutorial fixed <- in db.cpp + db.h.

 

1 hour ago, Draveniou1 said:

Remove from python and source client  

They are not 100% complete

Send me a message to help you delete them correctly

In client i didn't see definition of bill/billing.

Edited by SamuraiHUN
  • Love 2
Link to comment
Share on other sites

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 3

      Crystal Metinstone

    2. 3

      Feeding game source to LLM

    3. 113

      Ulthar SF V2 (TMP4 Base)

    4. 3

      Feeding game source to LLM

    5. 0

      Target Information System

    6. 3

      Feeding game source to LLM

    7. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.