Jump to content

Fix Guilding Building Yang Bug


Recommended Posts

  • Bronze

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
Share on other sites

  • 1 month later...

Announcements



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