Jump to content

Recommended Posts

Hello,
I don't really know if someone else pointed it out but (if not) there you go.
There is really ugly yang-bug in guild building code.
Open cmd_gm.cpp, go to the do_build function and navigate this kind of code:
 

				if (test_server || GMLevel == GM_PLAYER)
					// °ÇĽł Ŕç·á ĽŇ¸đÇϱâ (Ĺ׼·żˇĽ­´Â GMµµ ĽŇ¸đ)
				{
					// °ÇĽł şńżë ĽŇ¸đ
					ch->PointChange(POINT_GOLD, -t->dwPrice);

Looks ok, right? Not really. dwPrice is typed as DWORD. It's never a good idea to subtract unsigned value.
That will not cause any damage if your PointChange function takes int as an argument but once you decide to change it to f.e long long, there you have live example:
https://onlinegdb.com/HJF-CWsCE
Mitigation:

Just cast the value to int/long long:

				if (test_server || GMLevel == GM_PLAYER)
					// °ÇĽł Ŕç·á ĽŇ¸đÇϱâ (Ĺ׼·żˇĽ­´Â GMµµ ĽŇ¸đ)
				{
					// °ÇĽł şńżë ĽŇ¸đ
					int iPrice = static_cast<int>(t->dwPrice);
					ch->PointChange(POINT_GOLD, -iPrice);

Regards

  • Love 5
Link to comment
https://metin2.dev/topic/21368-fix-guilding-building-yang-bug/
Share on other sites

  • 1 month later...
Dnia 10.06.2019 o 10:32, xGenessis napisał:

For cube.cpp

ch->PointChange(POINT_GOLD, -static_cast<int>(cube_proto->gold), false);

or just in cube.h

struct CUBE_DATA
use 

long long gold; 

instead of unsigned lol.

 

Same with buildings

in common/building.h

dwPrice into long long.

  • Love 1

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.