howmanytimes()

As bugs and suggestions are fixed/implemented/rejected, they will be moved in here.
sh0e
Forum Maniac
Posts: 290
Joined: Mon Apr 19, 2004 6:13 pm

Post by sh0e »

i haent given his way of doing time much thought
i just assumed it worked

but what you say seems to make sense
User avatar
Devari
Mr. -1
Posts: 3194
Joined: Wed Mar 10, 2004 5:02 am
Location: British Columbia, Canada

Post by Devari »

It strikes me you could be right, Vera. floor is the only thing that makes sense there....
If you go down to the woods today, you better not go alone
It's a lovely day in the woods today, but safer to stay at home
BECAUSE EVIL FREEN IS KILLING ALL THE TEDDY BEARS AT THEIR PICNIC
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

What a team! :)
Please apply fix and see (no SSH here).
:wq
Veranor
FAF Co-Programmer
Posts: 310
Joined: Mon Mar 08, 2004 8:12 pm

Post by Veranor »

Alright, I'll do it.

Now reads as:

code: Select all

function HowManyTimes($lasttime, $perminutes) {
    global $time;
    if($lasttime == 0)
        return 1;
    return floor(($time-$lasttime)/(60*$perminutes));
}
"The truth is a trap: you can not get it without it getting you; you cannot get the truth by capturing it, only by its capturing you." - Søren Kierkegaard
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

The function of the lasttime == 0 line is to ensure if it's never been run yet, we only run it once.
:wq
Veranor
FAF Co-Programmer
Posts: 310
Joined: Mon Mar 08, 2004 8:12 pm

Post by Veranor »

The Beatles wrote: The function of the lasttime == 0 line is to ensure if it's never been run yet, we only run it once.
Yeah. That makes sense. And the purpose of the (time - time % (60 * perminutes)) is to ensure that turns don't continue to come X minutes later right? Really good work on the whole thing I must say.
"The truth is a trap: you can not get it without it getting you; you cannot get the truth by capturing it, only by its capturing you." - Søren Kierkegaard
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Thanks, but evidently some messed-up thinking. :/
:wq
User avatar
Devari
Mr. -1
Posts: 3194
Joined: Wed Mar 10, 2004 5:02 am
Location: British Columbia, Canada

Post by Devari »

Eh, inevitable bugs. I certainly couldn't have done a better job. Besides, it is otherwise quite clean. :D

Just as long as you don't use the same kind of thing as the ancient fakecron.php you gave me. Now, THAT was something that had some bugs. :P
If you go down to the woods today, you better not go alone
It's a lovely day in the woods today, but safer to stay at home
BECAUSE EVIL FREEN IS KILLING ALL THE TEDDY BEARS AT THEIR PICNIC
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Wasn't it Vera who gave you fakecron? Or didn't you write it yourself? I remember Vera developed it for WW2: Rerisen.
:wq
Veranor
FAF Co-Programmer
Posts: 310
Joined: Mon Mar 08, 2004 8:12 pm

Post by Veranor »

I wrote one for something else a long time ago but I don't believe I gave it to Devari... I didn't write the WWII one I just helped him with it.
"The truth is a trap: you can not get it without it getting you; you cannot get the truth by capturing it, only by its capturing you." - Søren Kierkegaard
User avatar
Devari
Mr. -1
Posts: 3194
Joined: Wed Mar 10, 2004 5:02 am
Location: British Columbia, Canada

Post by Devari »

On Terrouge, yes.

From my uber-nooblet days:
Yet I don't recommend you do that... turns does a lot of things. Instead I recommend you do something like... well, here's a simple solution I wrote up now:
Make a file called fakecron.php. In it:

code: Select all

<?
include('const.php');
$time = time();
$tmpdir = '/tmp';
$authhash = md5($dbpass);

$lastrun = shell_exec("cat $tmpdir/prom_lastrun.txt");
shell_exec("echo $time > $tmpdir/prom_lastrun.txt");
$lastrun = round($lastrun);

if($lastrun == 0)
	$lastrun = $time-1;

$interval = $interval-$time;
$times = floor($interval/$perminutes);

for($i=0; $i<=$times; $i++) {
	echo "<img src='turns.php?auth=$authhash' width='0' height='0' border='0' />\n";
}

?>
Then somewhere in header.html, say, right after the call to printStatsBar(), put this:

code: Select all

require_once("fakecron.php");
Then at the top of turns.php, where it goes

code: Select all

if($REQUEST_URI) {
or

code: Select all

if($_SERVER["REQUEST_URI"]) {
replace that line with:

code: Select all

if($_SERVER['REQUEST_URI'] && $_GET['auth'] != md5($dbpass)) {
Then if you go to a server with crons, all you need to do is comment out that line in header.php


Now, this solution works if you install it as I've written. However, /tmp gets cleared by random people often, so I suggest you create a dir called crontmpdir, and chmod it to 777, and set the $tmpdir variable to 'crontmpdir', NO leading slash.
You can do that via most FTP apps or this php script:
<?
shell_exec('mkdir crontmpdir');
shell_exec('chmod 0777 crontmpdir');


I'm of course assuming this is a *NIX host, as most hosts are. If it isn't, get a new host.
It worked, eventually, after a number of modifications. Then again, it was written up quickly on a whim, so it couldn't really be expected to be right on the mark. :D

As a side note, when I look at my code on Ragnarok, I tend to cringe. I was quite clueless. :P
(http://www.declarus.com/ragnarok/ragnarok.tgz)
If you go down to the woods today, you better not go alone
It's a lovely day in the woods today, but safer to stay at home
BECAUSE EVIL FREEN IS KILLING ALL THE TEDDY BEARS AT THEIR PICNIC
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Ah, but that was your code and achievement. I merely answered a question. Thanks though. :)
:wq
sh0e
Forum Maniac
Posts: 290
Joined: Mon Apr 19, 2004 6:13 pm

Post by sh0e »

the ragnarok code isnt that bad
seems to me just like rwl with hacked in rearranged/tweaked code

you kept most of the rwl bugs new and old
and a couple introduced bugs it would appear
but nothing i can see atrociously deviating from rwl
User avatar
Devari
Mr. -1
Posts: 3194
Joined: Wed Mar 10, 2004 5:02 am
Location: British Columbia, Canada

Post by Devari »

Bah. It WAS a hack job. My only acheivement was seamless integration of some FAF code. :P

I added a couple major bugs, though. Two of the RWL bugs are fixed; the city demolition bug and the bldlst/trplst/prdlst bug.

I had the original BAXX code from the first release; I'm fairly sure that many of the bugs I have no longer exist. I'd hope, for RWL's sake, that they don't. :P
If you go down to the woods today, you better not go alone
It's a lovely day in the woods today, but safer to stay at home
BECAUSE EVIL FREEN IS KILLING ALL THE TEDDY BEARS AT THEIR PICNIC
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Hah. With emphasis. We know at least 4 from when negotiations broke down.
:wq
Post Reply
  • Members connected in real time

    🔒 Close the panel of connected members