opentibiabr / canary

Canary Server 13.x for OpenTibia community.
https://docs.opentibiabr.com/
GNU General Public License v2.0
342 stars 565 forks source link

npc trader when the item has a high value #2597

Open pedrohfk opened 2 months ago

pedrohfk commented 2 months ago

Priority

Critical

Area

What happened?

I have a custom NPC that sells items with very high prices, however, if the player has a very high amount of gold he may end up bugging the NPC.

image

What OS are you seeing the problem on?

Linux

Code of Conduct

Mirkaanks commented 2 months ago

I didn't understand, what bugged?

pedrohfk commented 2 months ago

I didn't understand, what bugged?

44 upgrade potions = 2kkk gold coins 1405 upgrade potions = 1kkk500kk gold coins.

It seems to me that the NPC is getting lost in the midst of so much money.

luanluciano93 commented 2 months ago

Surely someone type of variable is like uint32_t and makes values ​​above 4,294,967,295 impossible. You can test, values ​​above this should be buggy.

Chapeleiiro commented 2 months ago

I also have this problem

pedrohfk commented 2 months ago

Does anyone know if there is a way to enable purchases up to x value?

luanluciano93 commented 2 months ago

https://github.com/opentibiabr/canary/blob/9efbe4c10f19555208bbb755cb3dc09cc1ac8e99/src/server/network/protocol/protocolgame.cpp#L7930

the problem is with the cip client limitation, it receives a 32-bit integer, the maximum transaction value must be 4,294,967,295

pedrohfk commented 2 months ago

https://github.com/opentibiabr/canary/blob/9efbe4c10f19555208bbb755cb3dc09cc1ac8e99/src/server/network/protocol/protocolgame.cpp#L7930

the problem is with the cip client limitation, it receives a 32-bit integer, the maximum transaction value must be 4,294,967,295

But in this case there is some lock that we can put in place to prevent this bug from occurring.?

luanluciano93 commented 2 months ago

https://github.com/opentibiabr/canary/blob/9efbe4c10f19555208bbb755cb3dc09cc1ac8e99/src/server/network/protocol/protocolgame.cpp#L7930

the problem is with the cip client limitation, it receives a 32-bit integer, the maximum transaction value must be 4,294,967,295

But in this case there is some lock that we can put in place to prevent this bug from occurring.?

I would use another currency on the NPC, something worth 1kk for example

pedrohfk commented 2 months ago

@dudantas Can you see if we can put a check so this doesn't happen?

luanluciano93 commented 1 month ago

@pedrohfk try putting it here: https://github.com/opentibiabr/canary/blob/main/src/server/network/protocol/protocolgame.cpp#L8128//

if (shopBlock.itemBuyPrice >= 4294967295 || shopBlock.itemSellPrice >= 4294967295) {
    g_logger().error("[{}] itemid {} being sold/bought above the allowed value.", __FUNCTION__, shopBlock.itemId);
    return;
}