Jump to content

Recommended Posts

Ok so just use long instead of integer. 64bits will not decrease anything.
It's like saying : "I set my resolution to 1920*1899 instead of 1920*1900, it's really faster !"

I think, the real problem is that :
At the beginning an integer for mana was enought, but now, with mystical weapon, it's not. So they have to pass from 32bits to a 64bits value, but maybe it's not a simple refactor, and they need time.

Share this post


Link to post
Share on other sites
Adding together two longs with values between 100,000 and 1,000,000 takes approximately three times longer than adding the same two numbers together using int32s. You can test this out yourself using a profiling tool on the code. Adding actual long values (i.e. values larger than the int32 limit) actually takes five to seven times longer. Now multiply that up by all of the calculations that this would affect and you will come to realise why it's not just as simple as changing a single variable from int to long.

You also have to put in checks whenever you're moving from long back down to int to account for the possible loss of precision or overflows that can arise from it. Add in the required typecasting and you're already looking at quadrupling the time required to perform simple arithmetic.

Share this post


Link to post
Share on other sites
Ok, but lets image that with a long it will be 100 times longer to calculate : 0.00001 ms * 100 = 0.001. Still ok...
Honestly, this is not the thing that will take too much calculation time. And for the physic calculation, how do you think this work ? Everything is calculated in real time, you have lot's of mana on the floor, and 3 position (XYZ) per gem. And for a resolution like 1920*1200 (2304000 pixels), don't you think the rasterisation process cost lots of time compared to a simple mana counter ? and this to a rate of more than 60 per sec ?
If you still think i'm wrong, so use a 32 bits in battle (because we are capped at 1500) and 64 bits in tavern (no combat, no problems of cpu consumption)

Share this post


Link to post
Share on other sites
I don't know where you pulled those numbers from. A straightforward addition of two int32 values ranging from 100,000 to 1,000,00 takes 0.001 ms.

You've given the reason why it's not using longs in your post. There are a lot more important things happening than the game needing to care about the mana cap while you're playing. You start mixing and matching variable types and you WILL screw it up somewhere, not to mention the performance hit that all machines will take due to the increased computation times for something which, at the end of the day, isn't all that important.

This is exactly the point. Real time systems are optimised. Optimisation says that int32 is sufficient for the needs of this aspect of the game.

Share this post


Link to post
Share on other sites
[QUOTE]Optimisation says that int32 is sufficient for the needs of this aspect of the game.[/QUOTE]
It depend ;)
For you yes, but for me, i prefer loosing 1 FPS and be able to carry as many mana as i want.

Share this post


Link to post
Share on other sites
If it isn't then it's more indicative of a poorly planned design philosophy rather than a problem with the code.

Share this post


Link to post
Share on other sites
If it isn't then it's more indicative of a poorly planned design philosophy rather than a problem with the code.


Yes I agree to the person I qouted ubut, they should make it a float value because float values can goto atleast 1 trillion.

Share this post


Link to post
Share on other sites
Floats can technically store numbers larger than an int32 can, but they can't do it accurately. The maximum value of a float is 3.4028235 10[SUP]38[/SUP], which is massively bigger than int32's 2.147 billion, but it's also massively less accurate.

Take a maxed float variable and subtract 15000000.0f from it. What happens? You just invested 15 million mana into your 190+^ weapon, how much mana do you have left? Let's ask the float variable. It now thinks you have 3.4028235 10[SUP]38[/SUP] mana. It hasn't changed. It hasn't changed because 15 million isn't large enough in this context to actually be taken into account by the variable.

Floats can only approximate values larger than 99 million. So they're much less suited to the task you want to give them than their int32 counterparts are.

Share this post


Link to post
Share on other sites
Got to love people arguing about how 'simple' and 'easy' it is to just use different numeric data types lol.

To be honest I think we are best going back to basics.

Share this post


Link to post
Share on other sites
The mana cap cannot be raised much higher without some changes to the underlying code. Mana is stored as a 32-bit signed integer, which means that it's maximum possible value is 2,147,483,648. An extra 147 million won't make much difference. They *could* change it to a 64-bit long, which would cap at 9,223,372,036,854,775,807, but longs are slower to process, and when calculations need to be done in real-time you only use the type that's just about big enough to hold what you want it to hold - because speed matters.

The real solution is to change the value of 1 mana, such that everything costs less and vendors for less. Thus making huge quantities of mana harder to obtain, but also worth more than they presently are. That doesn't involve changing variable types in the code, which invariably causes all sorts of bugs.


Fantastic post. Do you think that changing one integer would be enough? I.E. so a magic missle turret takes 4 instead of 40? Or do you think they would need to change "Mana" into like "Cash" so what would happen is that the amount sold and the amount you make from a level could be a two or three integer conversion?

I.E. for those having problems following along. At the end of the level you normally would have banked 5,000 mana but instead you bank 5 gold. This would give Trendy a lot of room to grow. I really hope they read your suggestion anarial, its a great way to fix this problem.

Share this post


Link to post
Share on other sites
I've read quite a bit about the mana cap over tyhe last few days, (Anarial seems to be everywhere!) and the idea of altering code merely to facilitate larger numbers is ridiculous. The only feasible solution I have seen presented has been to reduce the value of evereything by a certain amount. This ensures that the cap is plenty high enough for those that need deeper pockets, that the integrity and speed of the code is not tampered with and the relative value of everything you own remains the same.

The weapon that was worth 50 million before may only be worth 5 million now (if everything was reduced by a magnitude of 10), but it isn't really the value of the weapon that has gone down. It is the value of each piece of mana that has increased.

Share this post


Link to post
Share on other sites
Adding together two longs with values between 100,000 and 1,000,000 takes approximately three times longer than adding the same two numbers together using int32s. You can test this out yourself using a profiling tool on the code. Adding actual long values (i.e. values larger than the int32 limit) actually takes five to seven times longer. Now multiply that up by all of the calculations that this would affect and you will come to realise why it's not just as simple as changing a single variable from int to long.

You also have to put in checks whenever you're moving from long back down to int to account for the possible loss of precision or overflows that can arise from it. Add in the required typecasting and you're already looking at quadrupling the time required to perform simple arithmetic.


1) Good practice is to make a new type to handle a specific data. This means, in an header:
typedef int mana;
would become
typedef long mana;
actual code needs no variation.
The trendy database needs a one-time transition, and a maintenance can be scheduled for it.

2) The profiling you say is for long over 32 bit systems. I have a 3 years old pc ( made from even older/used components ), and it's 64 bit. So, allowing the game to be both 64 bit and 32 bit, would allow the most users with a 5 years old or less pc to play the game with full benefit of almost unlimited mana and no speed loss.

Share this post


Link to post
Share on other sites
I profiled it on a 64-bit machine.

And the code would need altering via a patch, Trendy doesn't run a server system to host games or generate loot, that's all client-side. Client-side means patch.

You can't just redefine a variable's type and expect everything to work perfectly. You can't, for instance, take the value from a long and put it into an int without casting it first, so you'd have to find every single place in which that happens and then change it. You'd also have to put in anti-overflow measures to compensate for instances when the value of the long is greater than the int32 cap. This isn't a simple measure of "change x to y, done, next!".

If you'd actually read everything I've posted so far in this thread you'd understand that. That you even suggested it's that easy is completely staggering if you're actually a programmer, which I suspect you aren't.

Share this post


Link to post
Share on other sites
Can you make me an example where the long type for mana would need to be recasted to int?
It's obvious that the long will be greater than the int, that's the aim after all, to access the 64 bit range, and keep it. This means also, to store it.

Client side patch is needed of course, but I was talking about ranked stats, including mana, which are kept online (otherwise, what would be the difference between ranked and open? ). So, aside the client patch (and a new 64 bit executable), the database need to convert the stored mana to a 64 bit type.

Share this post


Link to post
Share on other sites
Any decent compiler will forbid an uncasted assignment from a long to an int. So that'd come into play whenever you invested mana into a weapon, pet or armour or whenever you attempted to purchase anything from the tavern shop, though that depends on the implementation of those features.

Why do you think the Ranked play is so easily hacked? It's mainly handled client-side. Moving it all to server-side would greatly help reduce the ease and frequency of people cheating.

Share this post


Link to post
Share on other sites
Why do you think the Ranked play is so easily hacked? It's mainly handled client-side. Moving it all to server-side would greatly help reduce the ease and frequency of people cheating.


It would also greatly increase the cost for Trendy.

Share this post


Link to post
Share on other sites
It would also greatly increase the cost for Trendy.


Indeed it would. But maybe that is the reason for the amount of DLC that has come out since PC launch. People keep complaining that they need to stop 'DLC whoring' and fix this and that (specifically the steam/trendy disconnects scrapping the game), when they need greater income in order to fix them. Which is exactly what the above average volume of DLC is actually doing.

If they put the money they make from selling more DLC into expanding their services for the game, then why should anyone be complaining unless anything short of instant gratification is too slow for you? You are all gamers, you are familliar with the concept of event chains. You do X so you can get Y; you need Y to achieve Z, and when you achieve Z, good things happen. To resolve losing game progress due to disconnects, less hackers and a fair ecconomy, Trendy need to get dedicated servers. For dedicated servers, Trendy need money. For money, Trendy are making more DLC.

If you want to see this game that you enjoy grow and improve, by all means buy the DLC. You can't expect a company to bankrupt itself to provide a service that costs more money than they can currently afford to pay for it for free without some method of increasing their income.

I could have probably found a better thread to post this in, but the response formed organically rather than me having premeditatedly searched for a place to post it. Regardless, there it is. :)

Share this post


Link to post
Share on other sites
Yes, Trendy hosting their own server would be considerably more expensive than anything else suggested in this thread. On the other hand, it would also fix a lot of bugs in the process too, and reduce cheating on Ranked. However - that's a topic for another thread, I feel.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...