123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|601|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Updating installation progress

Fri, 07 May 2021, 05:40
Afr0

Updating installation progress


I'm making an installer for Project Dollhouse.
I'm probably going to yank out the UI-code and put it in a separate function (or class), but bear with me for now.
I'm updating the progressbar as it's installing, but the progressbar is updating much more rapidly than the actual installation process! Why? Is something wrong with my maths?



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 07 May 2021, 06:02
Jayenkai
Aaah, Progress Bars.. The bane of all coders!

I'm kinda lost in your code, but I assume it's "Installation.Value" which uses a %'age sign.
Remember that % isn't Percentage. It's a Modulus value, the remainder of (a / b) (eg 10/4 = remainder 2)

Oooh, oooh, oooh! I can use my JSE for an example!!!

Assuming you want a 0->100% value for that, you'll want to be doing ..

JSE is here

Hurray for "fit for purpose!"

-=-=-
''Load, Next List!''
Fri, 07 May 2021, 08:41
spinal
Project Dollhous is still going? It's been like 50 years?!!
I usually abandon projects after a couple of weeks.

-=-=-
Check out my excellent homepage!
Fri, 07 May 2021, 10:42
cyangames
I hope you finish it Afro, I know how tough long term projects can become!

-=-=-
Web / Game Dev, occasionally finishes off coding games also!
Fri, 07 May 2021, 13:06
Afr0
Thanks guys!
The reason it's taking so long is partially because of studies, and partially because I've been writing in my sparetime, as well as recently spending more time in the gym.
I'm considering either becoming an author or an indie dev when I'm done studying. Maybe I'll do both. Right now I'm working on a cyberpunk book. I've been thinking about possibly turning that into an RPG.
The thing about gamedev though, is that it's so bloody hard!
That's part of the reason Project Dollhouse has taken so long as well, because you think a feature is going to take x number of weeks to implement, and then it turns out to take months!!
Implementing the file system was relatively simple, because it didn't require extensive maths and I had done similar stuff before. But the GUI (which I've been working on for... the last... couple of years...) turned out to be ridiculously hard, because it required quite a lot of maths and I absolutely had no idea what I was doing (I've done basic collision detection and stuff like that before, but independent resolution rendering, UI script parsing, dragging controls, creating controls (I.E messageboxes) from smaller images, layering and so on... I had no idea what I was doing!!)
The gist is: gamedev is hard, writing is super easy in comparison.
To be fair though, it hasn't helped that The Sims Online was basically a giant MMO patch added onto what was essentially one giant hack of a codebase.
I vividly remember talking to one of the devs [of TSO] on Discord a few years back - he told me that the simulation logic (meaning the VM that runs the SimAntics programs that actually makes up the AI) of The Sims was a 30,000 lines function that he had to disentangle and rebuild to make it work in TSO. A stoner in the team, whose name shall remain anonymous, upon questioning said "it's the hacks, man, the hacks..."
The Sims' codebase had two separate maths libraries, and the file formats... well, let me put it this way: it's amazing that that game, which was the best selling PC game of all time, ran at all. On anything. For any length of time.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 07 May 2021, 13:27
Jayenkai
Layer upon layer, it's how things get built. Start with some hacked code, and then throw on some more, until everything appears like it's working.
It takes some doing to dismantle something like that, and rebuild it all from scratch.
Keep going! You're doing well.

-=-=-
''Load, Next List!''
Fri, 07 May 2021, 13:35
Afr0
Thanks Jay!!
Your code isn't working though! What am I not getting?



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 07 May 2021, 13:41
Jayenkai
In what way is it not working

Describe what is happening, and what you want to be happening. Due to maths'n'shit I might be accidentally leading you down the wrong path!

-=-=-
''Load, Next List!''
Fri, 07 May 2021, 13:43
Afr0
Well, the progressbar isn't updating at all, now!
The InstallationStatus.Value, btw, says "Gets or sets the current magnitude of the range control".

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 07 May 2021, 13:50
Afr0
I made it work!
You were right that I needed TopmostValue, I.E 100%
I had to Google "percentage formula" >_>



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 07 May 2021, 14:44
Jayenkai
Glad you got it sorted!
Sat, 08 May 2021, 09:13
shroom_monk
I'm late to the thread, and I guess you already figured out the reason when you fixed it Afr0, but in case anyone else stumbles on this thread later...

The difference between

and

despite them appearing mathematically equivalent is that because integer division always rounds down, the first code snippet will likely evaluate to an unhelpful rounded value within the brackets. In particular, it TopmostValue < TotalCount, it will always evaluate to 0. But say TopmostValue is not-quite-double TotalCount, then the brackets will evaluate to 1 (rather than, say, 1.9), and so you'll still get an incorrect result.

The second snippet avoids this by doing the multiplication first, which will always be exact (because it's always an integer). The division will then give the correct answer rounded to the nearest integer.

If this were done with floating point values rather than integers then the two snippets would be the same (well, up to floating point precision, anyway).

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Sat, 08 May 2021, 11:08
Jayenkai
Yeah, I forgot about that. Been a long time since I worried about that kind of thing, but I used to, all the time.
Grrr..

-=-=-
''Load, Next List!''