Jump to content

Jira

Premium
  • Posts

    191
  • Joined

  • Days Won

    2
  • Feedback

    0%

Posts posted by Jira

  1. item drop penalty

     source/server/game/char_battle.cpp | 12 +++++++++++-
     1 file changed, 11 insertions(+), 1 deletion(-)
    
    diff --git a/source/server/game/char_battle.cpp b/source/server/game/char_battle.cpp
    index 4b0c013..9f9fab6 100644
    --- a/source/server/game/char_battle.cpp
    +++ b/source/server/game/char_battle.cpp
    @@ -1107,8 +1107,18 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
     		std::vector<BYTE> vec_bSlots;
     
     		for (i = 0; i < INVENTORY_MAX_NUM; ++i)
    -			if (GetInventoryItem(i))
    +		{
    +			if ((pkItem = GetInventoryItem(i)))
    +			{
    +				if (pkItem->GetType() == ITEM_QUEST)
    +				{
    +					if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
    +						continue;
    +				}
    +
     				vec_bSlots.push_back(i);
    +			}
    +		}
     
     		if (!vec_bSlots.empty())
     		{

     

    • Good 1
  2. If you send the move and attack packet to target and if you have the same position as the target then this check is pointless.

    An extra check that you can add 

    if (fHittingDistance == 0.0f && victim->GetX() == ch->GetX() && victim->GetY() == ch->GetY() && !victim->IsPC())
    	return;

     

    • Think 1
  3. It also has a memory leak

    The name of the timer is never deallocated when CancelServerTimers or ClearServerTimer is called

    Spoiler
    diff --git a/game/src/questevent.cpp b/game/src/questevent.cpp
    index 21fa0ed5b5a3fa3d0572494137602c2ee5cbc2c4..2a6cf3f73c7732d4d67c0bf044d510f1225ceaa8 100644
    --- a/game/src/questevent.cpp
    +++ b/game/src/questevent.cpp
    @@ -20,6 +20,19 @@ namespace quest
     		event_cancel(ppEvent);
     	}
     
    +	void CancelServerTimerEvent(LPEVENT* ppEvent)
    +	{
    +		quest_server_event_info* info = dynamic_cast<quest_server_event_info*>((*ppEvent)->info);
    +
    +		if (info)
    +		{
    +			delete [] (info->name);
    +			info->name = NULL;
    +		}
    +
    +		event_cancel(ppEvent);
    +	}
    +
     	EVENTFUNC(quest_server_timer_event)
     	{
     		quest_server_event_info * info = dynamic_cast<quest_server_event_info *>( event->info );
    diff --git a/game/src/questevent.h b/game/src/questevent.h
    index 2be83a0106e2f01cc8d1f50e7f2779957842c176..76500b52fd10d8f22965920f1a9d234b91b7ead3 100644
    --- a/game/src/questevent.h
    +++ b/game/src/questevent.h
    @@ -37,4 +37,5 @@ namespace quest
     	extern LPEVENT quest_create_server_timer_event(const char* name, double when, unsigned int timernpc = QUEST_NO_NPC, bool loop = false, unsigned int arg = 0);
     	extern LPEVENT quest_create_timer_event(const char* name, unsigned int player_id, double when, unsigned int npc_id=QUEST_NO_NPC, bool loop = false);
     	extern void CancelTimerEvent(LPEVENT* ppEvent);
    -}
    \ No newline at end of file
    +	extern void CancelServerTimerEvent(LPEVENT* ppEvent);
    +}
    diff --git a/game/src/questmanager.cpp b/game/src/questmanager.cpp
    index 2e58b776c4c3af97d2d0654d227d239ff177bf32..c2ed5eca1352f79f87003f7382b82db8f2682fd3 100644
    --- a/game/src/questmanager.cpp
    +++ b/game/src/questmanager.cpp
    @@ -21,6 +21,7 @@
     #include "dungeon.h"
     #include "regen.h"
    +#include "questevent.h"
    @@ -1853,7 +1854,7 @@ namespace quest
     		if (it != m_mapServerTimer.end())
     		{
     			LPEVENT event = it->second;
    -			event_cancel(&event);
    +			CancelServerTimerEvent(&event);
     
     			m_mapServerTimer.erase(it);
     		}
    @@ -1864,7 +1865,7 @@ namespace quest
     		auto it = m_mapServerTimer.begin();
     		while (it != m_mapServerTimer.end()) {
     			if (it->first.second == arg) {
    -				event_cancel(&it->second);
    +				CancelServerTimerEvent(&it->second);
     				it = m_mapServerTimer.erase(it);
     				continue;
     			}

     

     

    • Metin2 Dev 1
  4. I think you meant to do like this, with your fix you cannot drop gold.

    void CInputMain::ItemDrop2(LPCHARACTER ch, const char * data)
    {
    	TPacketCGItemDrop2 * pinfo = (TPacketCGItemDrop2 *) data;
    	if (!ch)
    		return;
      
    	if (pinfo->gold > 0)
    		ch->DropGold(pinfo->gold);
    	else
    	{
    		LPITEM pkItem = ch->GetItem(pinfo->Cell);
    		if (!pkItem)
    			return;
    
    		if (pkItem->IsEquipped())
    			return;
    
    		ch->DropItem(pinfo->Cell);
    	}
    }

    But it's better to check inside of CHARACTER::DropItem function. Btw don't use macros it's enough to put a comment like // FIXME: can't drop equipment

  5. 43 minutes ago, Draveniou1 said:

    Need 1 example

    EXAMPLE:
    
    CLIENTSIDE:
    typedef struct command_login3
    {
        BYTE	header;
        char	name[ID_MAX_NUM + 1];
        char	pwd[PASS_MAX_NUM + 1];
        DWORD	adwClientKey[4];
    #ifdef PROTECT_KEY_FROM_HACKERS
    	long		28374235784954363253456345346346345634563456678678977823834681293345634563456675674784784574124792375237;
    //max hacker 255  :) not unlock
    #endif
    } TPacketCGLogin3;
    
    SERVERSIDE:
    typedef struct command_login3
    {
    	BYTE	header;
    	char	login[LOGIN_MAX_LEN + 1];
    	char	passwd[PASSWD_MAX_LEN + 1];
    	DWORD	adwClientKey[4];
    #ifdef PROTECT_KEY_FROM_HACKERS
    	long		28374235784954363253456345346346345634563456678678977823834681293345634563456675674784784574124792375237;
    #endif
    } TPacketCGLogin3;
    
    
    
    SERVICE CLIENT/SERVER
    #define PROTECT_KEY_FROM_HACKERS
    
    
    
    Hackers can not find more than 250 BYTES as the number 28374235784954363253456345346346345634563456678678977823834681293345634563456675674784784574124792375237 
    It will protect you

     

    I can find that key in 1min. What are you doing here is a bad practice, you can trick just the  kids. 

    • Good 1
  6. for client crash

    void CPythonApplication::__ResetCameraWhenMinimize()
    {
    	if (m_CursorHandleMap.empty()) // FIXME
    		return;
    
    	CCameraManager& rkCmrMgr = CCameraManager::Instance();
    	CCamera* pkCmrCur = rkCmrMgr.GetCurrentCamera();
    	if (pkCmrCur)
    	{
    		pkCmrCur->EndDrag();
    	}
    
    	SetCursorNum(NORMAL);
    	if (CURSOR_MODE_HARDWARE == GetCursorMode())
    	{
    		SetCursorVisible(TRUE);
    	}
    }

    and

    void CPythonApplication::DestroyCursors()
    {
    	for (auto itor = m_CursorHandleMap.begin(); itor != m_CursorHandleMap.end(); ++itor)
    		DestroyCursor((HCURSOR)itor->second);
    	m_CursorHandleMap.clear();	// FIXME
    }

    😁

    • Good 1
  7. Spoiler
    
    #ifndef __INC_METIN_II_STL_H__
    #define __INC_METIN_II_STL_H__
    
    #include <vector>
    #include <string>
    #include <map>
    #include <list>
    #include <functional>
    #include <stack>
    #include <set>
    #include <algorithm>
    #ifdef __GNUC__
    #include <ext/functional>
    #endif
    
    #ifdef min
    #undef min
    #endif
    
    #ifdef max
    #undef max
    #endif
    
    #ifdef minmax
    #undef minmax
    #endif
    
    #ifndef itertype
    #define itertype(v) typeof((v).begin())
    #endif
    
    inline void stl_lowers(std::string& rstRet)
    {
    	for (size_t i = 0; i < rstRet.length(); ++i)
    		rstRet[i] = tolower(rstRet[i]);
    }
    
    struct stringhash       
    {
    	size_t operator () (const std::string & str) const
    	{
    		const unsigned char * s = (const unsigned char*) str.c_str();
    		const unsigned char * end = s + str.size();
    		size_t h = 0;
    
    		while (s < end)
    		{
    			h *= 16777619;
    			h ^= *(s++);
    		}
    
    		return h;
    	}
    };
    
    // code from tr1/functional_hash.h
    template<typename T>
    struct hash;
    
    template<typename _Tp>
    struct hash<_Tp*>
    : public std::unary_function<_Tp*, std::size_t>
    {
    	std::size_t
    		operator()(_Tp* __p) const
    		{ return reinterpret_cast<std::size_t>(__p); }
    };
    
    namespace std
    {
    	template <class container, class Pred>
    		void erase_if (container & a, typename container::iterator first, typename container::iterator past, Pred pred)
    		{
    			while (first != past)
    				if (pred(*first))
    					a.erase(first++);
    				else
    					++first;
    		}
    
    	template <class container>
    		void wipe(container & a)
    		{
    			typename container::iterator first, past;
    
    			first = a.begin();
    			past = a.end();
    
    			while (first != past)
    				delete *(first++);
    
    			a.clear();
    		}
    
    	template <class container>
    		void wipe_second(container & a)
    		{
    			typename container::iterator first, past;
    
    			first = a.begin();
    			past = a.end();
    
    			while (first != past)
    			{
    				delete first->second;
    				++first;
    			}
    
    			a.clear();
    		}
    
    	template <typename T> T min(T a, T b)
    	{
    		return a < b ? a : b;
    	}
    
    	template <typename T> T max(T a, T b)
    	{
    		return a > b ? a : b;
    	}
    
    	template <typename T> T minmax(T min, T value, T max)
    	{
    		T tv;
    
    		tv = (min > value ? min : value);
    		return (max < tv) ? max : tv;
    	}
    
    	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)); }
    };
    
    #endif

     

     

  8. 1 minute ago, viperkit said:

    Have you had this error?

    Thanks for the answer, I'm trying to solve it!

    Yes, if the platform selected is Win32 you must to define _USE_32BIT_TIME_T because time_t is by default __time64_t .

    If you run in debug mode you can get a runtime error if isn't defined _USE_32BIT_TIME_T

    That cmake project doesn't add definition for _USE_32BIT_TIME_T.

    You can solve like this:

    if(CMAKE_SIZEOF_VOID_P MATCHES 4)
    	add_definitions(-D_USE_32BIT_TIME_T)
    endif()

    Generate and rebuild.

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