• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Currency Issues: Source Edit?

matthewharrison

New Member
Joined
Nov 21, 2011
Messages
42
Reaction score
1
I added two new custom currencies to my server, scarab coin and skull. Once you have 100cc you can change it to a scarab coin, once you have 100 scarab coins you can change it to a skull.

It seems that the currency has some sort of limit though, once you have more than 14 skulls, or 1.4 billion, NPC's can't seem to get the amount right. I was told over at otfans that it seems like a problem with overflow. They said it seems like a server bug but that I might be able to source edit to fix it.

I have the sources, but I don't know where to start, if someone could point me in the right direction, or possibly give me another solution, I'd appreciate it very much! Thanks for reading!
 
give us more detail and we see if we can help :)

Ok! Thanks :D Not really sure what other details I can give you, but I'll do my best..

First of all,
I am using The Forgotten Server 0.3.6pl1.r80

Here's my current currency and values (one's in red being custom..which should be obvious :p):
Code:
Gold Coin = 1
Platinum Coin = 100
Crystal Coin = 10,000
[COLOR="#B22222"]Scarab Coin = 1,000,000
Skull = 100,000,000[/COLOR]


My server uses the NPC Trade system, so the window is brought up showing their products, on the bottom of the window it shows your "Money", being the amount of money you have.

So when I have 5 skulls, it says 500,000,000 which is fine, that is correct. When I have 10 skulls, it says 1,000,000,000 which is 1 billion, which is also correct.
.
Now when I get to 21, it says I have 2.1 billion, nothing wrong with that, but once you get 22 skulls or more, that's when the problems start. Here's what's happening in the NPC Trade window.

With 22 skulls it says -2,094,967,296 and won't allow me to buy any items
With 23 skulls it says -1,994,967,296 and won't allow me to buy any items
With 100 skulls it says 1,410,065,408 and WILL allow me to buy items, but gives me back the wrong amount of "change" I guess you would say. The reason for giving back the wrong amount of change is because the server thinks that 100 skulls = 1,410,065,408, which is approx. 1.4 billion, when it is really equal to 10 billion.

So if I had 100 skulls, or 10 billion, I'd only get w/e amount of gp/platinum/crystal plus 13 skulls if I were to purchase something that costs 1 million from an NPC.


I hope all of that isn't too confusing, it is kind of hard to explain, but hopefully you can get something out of that and help me out some!
Thank you! :)
 
the problem is both in server (game.cpp, game.h and possibly more) and in client, but you can only fix the first completely - the 2nd has to be hacked (ProtocolGame::sendGoods msg->AddU32(std::max(2147483647, g_game.getMoney(player)));)
 
That is 2,147,483,647 is the highest number a basic 32 bit computer can reach/calculate.
2147483647 - Wikipedia, the free encyclopedia

Ok, thanks! Is there anyway I can fix this? I'm just about to start looking around myself, but thought I'd ask just incase you knew.

Here's a couple things about my computer:
Gateway MD7811u
4GB RAM
500GB Hard Drive
Windows 7, 64bit
Intel Centrino
 
Haha, well my computer runs windows 7 64 bit, it's an Intel Core 2 Duo T6600 @ 2.20GHz
Says right in "System" inside control panel, "System type: 64-bit Operating System"

Yes, then you need to download 64-bit server, alternatively, you can follow Cykotitan's instructions.
 
my instructions are the only way, the likelihood of finding a 64-bit binary is close to zero which makes the option not worth a mention. besides, it would have no effect because the variables would stay int32_t/uint32_t
 
Back
Top