Log in

View Full Version : Long Progress Reports Messing Up?



Ian
12-03-2012, 08:15 PM
One of my scripts has been having this a problem now that I enabled SixHourFix. Everything seems to be reporting fine except for the xp/h, and that only messes up on long reports, For example:



~~~~~~~~~~~~Almost AIO PowerMiner~~~~~~~~~~
~By BMWxi~
Iron Mined: 33474 (588 P/H)
Mining XP earned: 1171590 (-377 P/H)
Total Time: 56 Hours, 50 Minutes and 2 Seconds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See how the xp/h is -377?

This is on a shorter one, but using the same version:

~~~~~~~~~~~~Almost AIO PowerMiner~~~~~~~~~~
~By BMWxi~
Iron Mined: 8758 (652 P/H)
Mining XP earned: 306530 (22842 P/H)
Total Time: 13 Hours, 25 Minutes and 10 Seconds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The xp/h is fine.

Here is how the proggy is calculated:

begin
IronPH := Round((Iron * 3600) / (GetTimeRunning / 1000));
MiningXPPH := Round(((Iron * 35) * 3600) / (GetTimeRunning / 1000));
ClearDebug;
Writeln('~~~~~~~~~~~~Almost AIO PowerMiner~~~~~~~~~~');
Writeln(' ~By BMWxi~ ');
Writeln('Iron Mined: ' + IntToStr(Iron) + ' (' + IntToStr(IronPH) + ' P/H)');
Writeln('Mining XP earned: ' + (ToStr(Iron * 35)+ ' (' + IntToStr(MiningXPPH)) + ' P/H)');
Writeln('Total Time: ' + TimeRunning);
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' );
end;
Does anyone know why it is going negative when running for a long time? I don't see any reason why it would, so I'm a bit puzzled.

footballjds
12-03-2012, 08:21 PM
i'm not even gonna look at it. But i assume the variable is floating away into the mystery beyond because an int can only be so large.

Le Jingle
12-03-2012, 08:21 PM
33474 (iron mined), 56 (hours):

MiningXPPH := Round( ... );
... = ((Iron * 35) * 3600) / (GetTimeRunning / 1000)

33474 * 35 = 1171590

1171590 * 3600 = 4217724000

4,217,724,000 => is approx. twice as much as the max value an int/integer can hold.

a possibly fix:

var
// MiningXPPH: integer;
// to
MiningXPPH: int64;


e: :ninja:'d

Ian
12-03-2012, 08:22 PM
i'm not even gonna look at it. But i assume the variable is floating away into the mystery beyond because an int can only be so large.

Then could I fix it by dividing the xp by 1000 and then writing "k xp" after?

footballjds
12-03-2012, 08:25 PM
Then could I fix it by dividing the xp by 1000 and then writing "k xp" after?

You could. Or you could calculate it differently.

Ian
12-03-2012, 08:33 PM
You could. Or you could calculate it differently.

Ok thanks :). I'll see which way I like more.

footballjds
12-03-2012, 08:36 PM
Ok thanks :). I'll see which way I like more.

This works, no? Makes gobbz more sense to me anyhow. You already calculate the IronPH why calculate it again on the next line? :P

procedure Proggy;
var
IronPH, MiningXPPH: integer;
begin
IronPH := Round((Iron * 3600) / (GetTimeRunning/1000));
MiningXPPH := IronPH*35;
ClearDebug;
Writeln('~~~~~~~~~~~~Almost AIO PowerMiner~~~~~~~~~~');
Writeln(' ~By BMWxi~ ');
Writeln('Iron Mined: ' + IntToStr(Iron) + ' (' + IntToStr(IronPH) + ' P/H)');
Writeln('Mining XP earned: ' + (ToStr(Iron * 35)+ ' (' + IntToStr(MiningXPPH)) + ' P/H)');
Writeln('Total Time: ' + TimeRunning);
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' );
end;

Ian
12-03-2012, 09:28 PM
Yeah, I've just been using the same format back from when I first started. That would work I think, I'll just run some tests now.

footballjds
12-03-2012, 09:29 PM
Yeah, I've just been using the same format back from when I first started. That would work I think, I'll just run some tests now.

it will work, orePerHour*ExpPerOre = EXPPerHour

Ian
12-03-2012, 09:32 PM
it will work, orePerHour*ExpPerOre = EXPPerHour

I know that the math works, I want to see if it fixes the negative xp error

footballjds
12-03-2012, 09:37 PM
I know that the math works, I want to see if it fixes the negative xp error

oh, well it DEFINITELY will, unless ofc you mine enough iron ore :P you'll have to mine a bit under 600,000 ores before it breaks again. I'd LOVE to see a proggy that long :)

Ian
12-03-2012, 09:39 PM
oh, well it DEFINITELY will, unless ofc you mine enough iron ore :P

Thank you for your help :)

footballjds
12-03-2012, 09:40 PM
Thank you for your help :)

np, good luck getting 600k iron ores in one run :)