mt_rand problems

Started by sh0e, April 13, 2004, 09:59:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sh0e

 mt_rand only returns integer values
these are only the ones ive found from quick looks
there may be more

military.php:
$lwiz = floor($enemy[wizards]*mt_rand(0.1,1)/100);

pvtmarketsell.php:
$users["pmkt_$type"] += $amount*mt_rand(0.20,0.66);

Devari

 Hm... I don't know, everything seems to work...

I'll run some:
print"";

Stuff on the variables... See if it outputs 0 (which the function of mt_rand would lead me to believe) or some other number...

Right now is too late in the night, though. Don't feel like opening up that stupid FTP program...

sh0e

 well heres how it comes out for me
but it might be that my version of php is behaving differently

php-cli -a
Interactive mode enabled

echo mt_rand(0.3,0.7);
0
echo mt_rand(0.4,1);
0
echo mt_rand(0.4,1);
0


Devari

 Whoa... I don't get this...

Output:

Quote0
Group 1 won through their opponents.
5003
Group 2 won through their opponents.
5003
Group 3 won through their opponents.
0
Group 4 won through their opponents.
Your ____ breaks through _________'s defenses and captures 216 ____ of _____! In the effort, you lost:
1,502 ___________
In their defense, _________ lost:
504 _____________
1 _______
You also captured 8,108 ________!


From this code:

   if ($group[$i][act] == "capture") {
    $lwiz = floor($enemy[wizards]*mt_rand(0.1,1)/100);
    echo "$lwiz";
    $lwizgain = floor($lwiz*(min(0.95,($enemy[wizards]/$enemy[land])/(($users[wizards]+1)/$users[land]))));
    $tlwizgain += $lwizgain;
    $losses[d][wizards] += $lwiz;
    $users[wizards] += $lwizgain;
   }


Is this the same (minus the echo) as the recent BAXX code?



On a totally random note, there is some forum software that colour codes PHP syntax in your posts if you use special tags. vSomething-or-other, I think.

sh0e

 the proof for
pvtmarketsell.php:
$users["pmkt_$type"] += $amount*mt_rand(0.20,0.66);

original stats of market
Quote
Unit     Owned     Avail     Cost     Afford     Buy
Rats  173,641  8,474,296  $540  8,474,296  
Weasels  104,519  8,474,296  $1,080  8,474,296  
Stoats  149,042  8,474,296  $2,160  8,474,296  
Skiffs  60,614  8,474,296  $3,240  8,474,296  
Food  425,863,682  45,180,000  $10  45,180,000

bought 100k each for these stats:
Quote
Unit     Owned     Avail     Cost     Afford     Buy
Rats  273,641  8,374,296  $540  8,374,296  
Weasels  204,519  8,374,296  $1,080  8,374,296  
Stoats  249,042  8,374,296  $2,160  8,374,296  
Skiffs  160,614  8,374,296  $3,240  8,374,296  
Food  425,863,682  45,180,000  $10  45,180,000  

>thus now there are 100k free pvtmarket buy slots to fill

sold 1k of each on pvtmarket sell
Quote
1,000 Rats sold for $173,000
1,000 Weasels sold for $367,000
1,000 Stoats sold for $778,000
1,000 Skiffs sold for $1,231,000

100k free buy slots are untouched
Quote
Unit     Owned     Avail     Cost     Afford     Buy
Rats  272,641  8,374,296  $540  8,374,296  
Weasels  203,519  8,374,296  $1,080  8,374,296  
Stoats  248,042  8,374,296  $2,160  8,374,296  
Skiffs  159,614  8,374,296  $3,240  8,374,296  

selling adds 0 to the refilling of pvtmarket buying
thus proving that this mt_rand problem is in effect of currently used baax code


you mean vbulletin?
you could always color code it yourself :P

Devari

 Yeah... That's it. vBulletin.

Luckily I have no private market in my BAXX-based game. :P

That also explain the bug Juska was complaining about with same amounts in the Mercs.

I suppose that the capture code explains why capture doesn't work sometimes...

So, to make it equivelent to what it is now, Retto just needs to change:


    $lwiz = floor($enemy[wizards]*mt_rand(0.1,1)/100);


to

    $lwiz = floor($enemy[wizards]*mt_rand(1,10)/1000);


Correctus?

sh0e

 ya.. looks right
meh the capture percentages look too low.. seems barely worth it

and
pvtmarketsell.php:
$users["pmkt_$type"] += $amount*mt_rand(0.20,0.66);
should be
$users["pmkt_$type"] += $amount*mt_rand(20,66)/100;

Veranor

 I miss the days when we still had the referer spoofing bug... I think it was one of my best finds.
#127.0.0.1 rovl.org

sh0e

Quote from: VeranorI miss the days when we still had the referer spoofing bug... I think it was one of my best finds.
ok?
i dont know what it has to do with anything but http referer spoofing is quite trivial
its not really a bug.. but a small loophole of http spec design
there is no "fix" for referer spoofing as getting referer info is dependent on trusting the client

Veranor

 
Quote from: sh0eok?
i dont know what it has to do with anything but http referer spoofing is quite trivial
its not really a bug.. but a small loophole of http spec design
there is no "fix" for referer spoofing as getting referer info is dependent on trusting the client
No no no I mean you used to be able to do:

serverhere.com/main.php?HTTP_REFERER=http://www.serverhere.com/main.php&any_other_getvariable_you_want_to_set_here

You can still technically do it, but it was so very very very simple that you could control a user through a link. Coupled with the javascript insertion that happened when html was allowed for a brief period of time here... well.. yeah.


EDIT:

Anyways, if you look through the very old versions of the code you'll see because it uses $HTTP_REFERER not $_SERVER['HTTP_REFERER']....

EDIT2:

And no it doesn't have anything to do with the topic at hand but I think the issue was resolved and I was just making a casual remark, seeing that you've found so many bugs recently it would have been crazy on some of the older versions of this game (where less was changed and it was mostly the old old old old pre 4.0 Sf.net code)
#127.0.0.1 rovl.org

sh0e

 oh i see
i havent exactly been around very long so i wouldnt know
but thats certainly interesting i guess