Jump to content

Recommended Posts

  • Bot

I'm trying to use static as less as possible. What is the reason this really needs to be static?

Also, what about couples that play together on one IP?

Idea is good, not perfect solution, but at least something.

  • Love 1

english_banner.gif

Link to comment
https://metin2.dev/topic/20622-function-same-ip-detection/#findComment-111794
Share on other sites

Vegas quest functions

Server/quest_functions:

pc.get_ip
npc.get_ip



Src/game/questlua_pc.cpp
 

int pc_get_ip(lua_State* L)
    {
        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        if(!ch) return 0;
        lua_pushstring(L, ch->GetDesc()->GetHostName());
        return 1;
    }

    { "get_ip",                pc_get_ip                            },



Src/game/questlua_npc.cpp
 

int npc_get_ip(lua_State* L)
    {
        LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
        if (npc && npc->IsPC())
            lua_pushstring(L, npc->GetDesc()->GetHostName());
        else
            lua_pushstring(L, "");
        return 1;
    }

    { "get_ip",                        npc_get_ip                        },


 

#include "desc.h"
Link to comment
https://metin2.dev/topic/20622-function-same-ip-detection/#findComment-111813
Share on other sites

  • Forum Moderator

Good idea, but you should return false if GetDesc is nullptr, not true.

static const bool __FN_check_ip_ptr(const LPCHARACTER pkChr, const LPCHARACTER pkTargetChr)
{
	if (!pkChr || !pkTargetChr)
		return false;
	
	const LPDESC pkDesc = pkChr->GetDesc();
	const LPDESC pkTargetDesc = pkTargetChr->GetDesc();
	if (!pkDesc || !pkTargetDesc)
		return false;
	
	const std::string & stIPAddress1 = pkDesc->GetHostName();
	const std::string & stIPAddress2 = pkTargetDesc->GetHostName();
	return (!stIPAddress1.compare(stIPAddress2));
}

static const bool __FN_check_ip_str(const std::string & stIPAddress1, const std::string & stIPAddress2)
{
	return (!stIPAddress1.compare(stIPAddress2));
}

// const bool bIsSameIP = __FN_check_ip_ptr(ch, tch);
// const bool bIsSameIP = __FN_check_ip_str(row[0], row[1]);

It's a little bit useless if two guys play metin2 from same network connection, as @Chyu ^^ said.
We can use HWID (Hardware Identification) for this detection, much better.

  • Love 5
Link to comment
https://metin2.dev/topic/20622-function-same-ip-detection/#findComment-111841
Share on other sites

  • Honorable Member

moved to: 

This is the hidden content, please

Added somewhere (even .h)

inline bool ch_compare_ip(LPCHARACTER ch1, LPCHARACTER ch2)
{
	if (!ch1 || !ch2 || !ch1->GetDesc() || !ch2->GetDesc())
		return false;
	const std::string ip1 = ch1->GetDesc()->GetHostName();
	const std::string ip2 = ch2->GetDesc()->GetHostName();
	return (ip1.compare(ip2) == 0);
}

or if added in char.h inside CHARACTER:

inline bool CHARACTER::CompareIP(LPCHARACTER ch2)
{
	if (!ch2 || !this->GetDesc() || !ch2->GetDesc())
		return false;
	const std::string ip1 = this->GetDesc()->GetHostName();
	const std::string ip2 = ch2->GetDesc()->GetHostName();
	return (ip1.compare(ip2) == 0);
}

 

Edited by martysama0134
  • Metin2 Dev 6
  • Good 4
  • Love 10
Link to comment
https://metin2.dev/topic/20622-function-same-ip-detection/#findComment-111937
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.