Jump to content

Recommended Posts

  • Developer


I noticed that every my client have the same bug, maybe sharing the fix prevents me from having to apply it to everyone and it also helps others who try the function and have problems.

an example of buggy usage:

File: scriptLib\PythonUtils.cpp


bool PyTuple_GetUnsignedLong(PyObject* poArgs, int pos, unsigned long* ret)
{
	if (pos >= PyTuple_Size(poArgs))
		return false;

	PyObject * poItem = PyTuple_GetItem(poArgs, pos);

	if (!poItem)
		return false;

	*ret = PyLong_AsUnsignedLong(poItem);
	return true;
}

 

the problem seems to be PyLong_AsUnsignedLongLong which is buggy:

#define PyLong_AsUnsignedLong PyLong_AsUnsignedLongLong

 

 

how we could fix it?

//replacing
#define PyLong_AsUnsignedLong (unsigned long)PyLong_AsLongLong

 

  • Love 10

My youtube channel  on which you can see my works here

Link to comment
https://metin2.dev/topic/21537-fix-getasunsignedlong/
Share on other sites

  • 5 years later...

PythonUtils.cpp add this: 
 

bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret)
{
    if (pos >= PyTuple_Size(poArgs))
        return false;

    PyObject* poItem = PyTuple_GetItem(poArgs, pos);

    if (!poItem)
        return false;

    *ret = PyLong_AsLongLong(poItem);
    return true;
}

PythonUtils.h add this:

bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret);
 

  • Think 1
Link to comment
https://metin2.dev/topic/21537-fix-getasunsignedlong/#findComment-169275
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.