Shop stands are affected by integer overflow

bug
Tags: #<Tag:0x00007fb3eedb19c0>

#1

Today I found shop stands offering items for 99,999,999c each. Could not resist to test out how the game handles such big numbers :smile:

Result is that the total overflows when going over 4.2 billion (2^32, unsigned integer). So buying 43 of those items just costs me 5,032,704c. Have not found a combination to get it nearly free but better to handle this correctly before somebody with a different price that results in a low total gets robbed.


#2

Yea it should get fixed tho it may just be a visual bug(would have to test on test servers but I don’t have pc copy) But who has 5mil to blow on 43 items anyhow.


#3

Do you have screenshots showing this in game?


#4

Nice find!


#5

It’s 2^31 because it’s 2’s-complement representation. Also, signed integer overflow is underfined behaviour in C++, so it’s possible it would just crash the server instead of wrapping, depending on the command-line options passed to the compiler.

Sorry, couldn’t resist. It’s my day job.


#6

Currently not at my gaming pc. Can make screenshots in about 7 hours.

Sorry to disappoint you but this time it is actually 2^32 because 42 items with 4.2 billion still shows fine hence unsigned int :wink:


#7

I have a few stands with items listed for that price if you need to do more testing :smile:


#8

@vdragon Here are the screenshots with my alt wanting to spent his riches:

20190328190919_1
Item price of the shop stand


42 are still ok


43 show wrong total

Did some further tests and did not manage to trick the game. May just be a client issue but as I dont know the implementations I cannot say for sure.


#9

I’ve checked this in game and couldn’t reproduce this issue. However, after discussing this with one of the software engineers, it could be that this may have been fixed with the next incoming update. Check this again when the live game is up to date.


#10

ok I will check again when next update arrives

Update: Checked again and works as expected now