• 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!

(Question) Money bug, hardcoders required! +Repping (6 bars)

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
Note: Im aware that I could/should've posted this on C++ section, but the amount of people that ever checks the Support section there just didnt "sell" it for me, so Id rather take my chances and post it here!

Anyway, to the point. Checking another thread with a similar request, I just realized that this:
4294967295 (max value of uint32_t)

Is the exact amount where money "bugs" on my 0.3.5pl1 servers (and any other 0.3.5+ TFS for that matter).

I never knew why it happened, someone told me it was a LUA problem, that LUA just couldnt read values over that number so they bugged after that point, but now that I see this..
I guess maybe there is a way to change and fix this problem through sources? :blink:

About the bug:

The "money bug" Im talking about is the fact that after 4294967295 (4.2 billion), if you had for example 4294967296 and you did the command to check your money it would tell you that you have 1 gp, instead of 4294967296. It just kinda resets, and if you buy something that costs 2 gp when having 4294967296, you lose 1 gp + the other 4294967295 on the purchase :) 4294967296 gp for the price of 2, pretty good deal isnt it? :)

I already found a way to go "around" this problem, but if a direct solution like this was possible, it would definitely be better!

The question:

So Im wondering:

Is there any way to change the "uint32_t" value (the one with 4294967295 as max value) for this matter, to "uint64_t" (which has "18446744073709551615" as max value) ?

The consequences:

Do you think it would fix the problem? And would it affect the server's "technical" performance in any way? Like making it lag, or non-compatible with certain OSs or something similar?

The.. end? :blink:

Im very lousy at hardcoding and Im clueless on how to even start with this issue so some help would be very appreciated here!

As always, Ill be +Repping real helpful responses :peace:

Thanks in advance.
 
Last edited:
You will probably have to change it to 64. If you did it would only increase the ram used by your computer (But like by < a few bytes) so nothingwill really happen. All you should have to do is find something like uint_32 money and change it to uint_64 money but Ive never hardcoded (For one thing I barely know c++ and I cant compile the ot)
 
Not really, since that 32 is an Int value and 64 a Long value, that wouldn't be such a change.
That's how we can tell in C/C++ , so , you just have to find in the source code the declaration of that variable, that'd be something like :
int amountofmoney;

and just change it to :
long amountofmoney

That's the 64 bit version.
 
who would ever have so much money:O change your prices:p

Its a 95% custom high-exp project (not "fun-1-night-stand-type" <_<, its actually quite RPGish) Im into, where money "could" go that far.. however Im positive that it would be almost impossible for anyone to reach that amount in less than 2-3 months unless they save all the time without buying anything (no point for doing it) :p

But Ive encountered some people who have quite weird habits when it comes to playing OTs, so I cant risk it :D

@Rozinx:

Thanks mate, Ill check it up!

+Repped you for helping, and master-m for the quite funny reply lol

:peace:
 
Last edited:
Bump! Definitely need help, can't do it myself.

Been trying but I always get errors compiling and I dont even know the meaning of them, but of course how would I not get errors, I have no idea of what Im doing! Im just changing numbers (32 -> 64) everywhere I find anything related to money <_<

Im in the dark here, can any hardcoder help me on a more specific way?

Thanks in advance.
 
Erm, -just an idea-
How about checking the "Banker-script", when he says:
Your account balance is xxxxxxGP,
Check the Banker script, and try to get it into the talkaction, got it? :)
 
Erm, -just an idea-
How about checking the "Banker-script", when he says:
Your account balance is xxxxxxGP,
Check the Banker script, and try to get it into the talkaction, got it? :)

I dont think you understood my problem :p

The problem is in the sources, I do have that talkaction, but even if I didnt and I went to the banker with 4.3 billion he would still tell me the same thing I mentioned on my first post, because the problem is the fact that the sources are made to handle only up to that amount!

-Rebumpod-
 
Just change uint32_t to uint64_t in source? :D

I did man, I did it on everything "money related" I could find, but it kept giving me errors when trying to compile it.

I dont think Im changing the correct stuff, I need someone to tell me exactly where I need to change it, otherwise Im still just changing numbers in the dark and getting errors! :/
 
Have you thought of making a Currency script that perhaps automatically changes into something else once you hit 100 crystal coins, or something around that area incase compiling it to read longer numbers doesnt work?
 
Have you thought of making a Currency script that perhaps automatically changes into something else once you hit 100 crystal coins, or something around that area incase compiling it to read longer numbers doesnt work?

Man, nobody is understanding the real problem xD

I do have a currency system that works correctly, 100 crystals is "something" and 100 "something" is "something else", etc.

Everything on the "currency" system works perfectly, the real problem is that when the player has 4294967295 gp (4.2 billion, which in the currency system would be 42 "something else") the money just bugs, it cant possibly count anymore than that because in sources the values are set in unsigned int (uint32_t), and the max value of that integer is 4,294,967,295!

It doesnt matter if its counted on gps, or crystals, or "something else", the problem is the max value of that integer on the sources! Meaning I could have 42949672.95 stacks of 100 gp and it would still bug the same way :)

So the real question here is that I want the money system of "the whole TFS" to be counted on uint64_t instead of uint32_t as it is now, for reference:

stdint.h - Wikipedia, the free encyclopedia

As seen there, max value of the 64 one is 18,446,744,073,709,551,615, which I highly doubt I will have problems with that one :p

Thanks for trying though :peace:
 
Sorry for doing this on a second post, I guarantee its no spam I dont care about post count, I just didnt want the previous one bigger than that.

Can you post errors?

I managed to fix most of the errors by searching through all freakin files of sources and fixing the references, but this one is driving me nuts:

PHP:
../game.cpp: In member function `void Game::addMoney(Cylinder*, int64_t, uint64_t)':
../game.cpp:1849: error: no matching function for call to `min(int, int64_t&)'

../game.cpp:1853: error: no matching function for call to `min(int, int64_t&)'

make.exe: *** [obj//game.o] Error 1

Execution terminated

It comes in this part:

PHP:
void Game::addMoney(Cylinder* cylinder, int64_t money, uint64_t flags /*= 0*/)
{
	IntegerMap moneyMap = Item::items.getMoneyMap();
	int64_t tmp = 0;
	for(IntegerMap::reverse_iterator it = moneyMap.rbegin(); it != moneyMap.rend(); ++it)
	{
		tmp = money / it->first;
		money -= tmp * it->first;
		if(tmp != 0)
		{
			do
			{
				Item* remaindItem = Item::CreateItem(it->second, std::min(100, tmp));
				if(internalAddItem(NULL, cylinder, remaindItem, INDEX_WHEREEVER, flags) != RET_NOERROR)
					internalAddItem(NULL, cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);

				tmp -= std::min(100, tmp);
			}
			while(tmp > 0);
		}
	}
}

As you can see, I changed it to 64 everywhere, but that error shows, however if I change to 32 this:

PHP:
	int32_t tmp = 0;

It runs normally (giving some later errors for more references that Im fixing right now), but I dont know why that small change "fixes" it and I also dont know if it will screw something up, or what does that part even mean!
 
You cant change it, that's the maximum number that will be stored, through the sources.

What do you mean? :ninja: It cant be done?

Another thing that I forgot to mention, is the fact that it "should" be possible, considering in TFS 0.3.2 this didnt happen!

So Im guessing back then it was uint64..

And thanks Chojrak, can't rep you yet ("spread some rep" thing) but as soon as I can, I will ;)
 
If you can't, i do! xD!

Code:
Thanks for adding reputation to this user. May you be lucky enough to receive the same Reputation back in turn.

+17 ;)
 
Back
Top