AwakenedLands Forums

Full Version: suggestion for display coherence
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Suggest processing player request results before the sidebar is generated so that displayed APs, energy, etc are always correct.

Dragon

Well, this could probably be possible, but the thing is that I am guessing is that the game's scripts include all of the user menu before each page's script is ran. So, when a certain game script does some thing to your action points or energy points, it does that after the user menu is displayed and well, that code has already ran and will not be ran again, unless you request a webpage, therefore defeating the purpose of this topic. Now, if the user menu's code was ran after the game's scripts, then you could keep your action points and energy up to date, because all of the update queries on your action points and energy can be executed, before the user menu and then the user menu's code can execute a query to get your action points and energy points, that was just updated and then display accordingly. But, there is probably a much better way to do this, which I have not heard of. May be some thing with AJAX? I have heard that this can make your website live, with out needing to reload the page and looking for updates.

*Comes back down to Earth*
Right, I'm sure the reason it displays the old value right now is an order-of-operations thing like you describe. It shouldn't take AJAX to resolve it, though. I don't know precisely how much effort it would be without seeing the code involved, but the math of the operations being performed can be run before the display code starts. Probably the difficulty involved is that the operations themselves produce direct output. Conceivably something like this:

<? include('/path/to/general_header.php') ?>
<? include('/path/to/sidebar.php') ?>
<? do_gym_training() ?>
<? include('/path/to/general_footer.php') ?>

The trouble is likely that do_gym_training() does both the math and the output, and it's not trivial to separate them. The reasonably easy, somewhat hackish fix for that is to do this:

<? include('/path/to/general_header.php') ?>
<?
ob_start();
do_gym_training();
$content = ob_get_flush();
?>
<? include('/path/to/sidebar.php') ?>
<?= $content ?>
<? include('/path/to/general_footer.php') ?>

That uses PHP's output buffering to trap do_gym_training()'s output while allowing its math to complete, and then sends the output after the sidebar is produced (with do_gym_training()'s math taken into account).

Yeah, I write a lot of PHP. Smile
chaosprime Wrote:Right, I'm sure the reason it displays the old value right now is an order-of-operations thing like you describe. It shouldn't take AJAX to resolve it, though. I don't know precisely how much effort it would be without seeing the code involved, but the math of the operations being performed can be run before the display code starts. Probably the difficulty involved is that the operations themselves produce direct output. Conceivably something like this:

<? include('/path/to/general_header.php') ?>
<? include('/path/to/sidebar.php') ?>
<? do_gym_training() ?>
<? include('/path/to/general_footer.php') ?>

The trouble is likely that do_gym_training() does both the math and the output, and it's not trivial to separate them. The reasonably easy, somewhat hackish fix for that is to do this:

<? include('/path/to/general_header.php') ?>
<?
ob_start();
do_gym_training();
$content = ob_get_flush();
?>
<? include('/path/to/sidebar.php') ?>
<?= $content ?>
<? include('/path/to/general_footer.php') ?>

That uses PHP's output buffering to trap do_gym_training()'s output while allowing its math to complete, and then sends the output after the sidebar is produced (with do_gym_training()'s math taken into account).



Yeah, I write a lot of PHP. Smile

Whuh?! You lost me at "<? include('/path/to/general_header.php') ?>" ...and I can't speak a lick of Spanish.

buuddha

McCule Wrote:
chaosprime Wrote:Right, I'm sure the reason it displays the old value right now is an order-of-operations thing like you describe. It shouldn't take AJAX to resolve it, though. I don't know precisely how much effort it would be without seeing the code involved, but the math of the operations being performed can be run before the display code starts. Probably the difficulty involved is that the operations themselves produce direct output. Conceivably something like this:

<? include('/path/to/general_header.php') ?>
<? include('/path/to/sidebar.php') ?>
<? do_gym_training() ?>
<? include('/path/to/general_footer.php') ?>

The trouble is likely that do_gym_training() does both the math and the output, and it's not trivial to separate them. The reasonably easy, somewhat hackish fix for that is to do this:

<? include('/path/to/general_header.php') ?>
<?
ob_start();
do_gym_training();
$content = ob_get_flush();
?>
<? include('/path/to/sidebar.php') ?>
<?= $content ?>
<? include('/path/to/general_footer.php') ?>

That uses PHP's output buffering to trap do_gym_training()'s output while allowing its math to complete, and then sends the output after the sidebar is produced (with do_gym_training()'s math taken into account).



Yeah, I write a lot of PHP. Smile

Whuh?! You lost me at "<? include('/path/to/general_header.php') ?>" ...and I can't speak a lick of Spanish.

i think that was some form of portugese...
buuddha Wrote:
McCule Wrote:Whuh?! You lost me at "<? include('/path/to/general_header.php') ?>" ...and I can't speak a lick of Spanish.

i think that was some form of portugese...

As long as Zenith can read it, I'm happy...
Its really no big deal if you can do basic math calculations in your head.
"I have 23 ap, that crime takes 9 ap , how much will I have left.....O gawd! da maths hurted my brain!!!!1"

Dragon

Thank you for that clear explanation, chaosprime. After some thought, I now understand how it all pans out. You see, I have done some PHP/MySQL in the past, but I am probably no where near your and Zenith's level, but hey, I still got some skills to pay the bills.

Razz

buuddha

Dragon Wrote:Thank you for that clear explanation, chaosprime. After some thought, I now understand how it all pans out. You see, I have done some PHP/MySQL in the past, but I am probably no where near your and Zenith's level, but hey, I still got some skills to pay the bills.

Razz

liar...you dont know portuguese.

Dragon

buuddha Wrote:
Dragon Wrote:Thank you for that clear explanation, chaosprime. After some thought, I now understand how it all pans out. You see, I have done some PHP/MySQL in the past, but I am probably no where near your and Zenith's level, but hey, I still got some skills to pay the bills.

Razz

liar...you dont know portuguese.

O Oh, mas eu !

Smile
Reference URL's