The random rantings of a concerned programmer.

Archive for January, 2007

Untitled

January 14th, 2007 | Category: Uncategorized

lol, so I started moving the output of Rhubarb’s PHP scripts from HTML (eww) to XML (*scream*). XML is, by nature, a bitch to work with. And my benchmarks show that there wasn’t any performance gains from converting the forums, though the XML output is like 1/3 the size of the HTML output (which is really handy).

The only real good thing was that it really helped refactor the code, since the PHP only handles the raw data processing, and all the formatting is left to the XSL scripts on the client. Let’s take a look at before-and-after (at the cost of breaking the margins of my journal):

BEFORE:

/* processing section culled, since its basically the same */ ?>

"login.php">Main Page | "discuss.php">Forum Index

"0" width="75%"> if ( $post_sub == "" ) $post_sub = "(No Subject)"; ?> class="forum_topic"> if ( $post_id == 0 ) { // output thread table or something $query = "SELECT * FROM forum WHERE thread=0 ORDER BY lastpost DESC LIMIT $FRONT_PAGE_POST_VIEW"; $result = mysql_query( $query, $link ) or $error .= "MySQL query failed - couldn't fetch page content. ($query)
"
; while ( $line = mysql_fetch_array( $result ) ) { output_topic_head( $line['id'], $line['lastpost'], $line['subject'], $line['name'], $line['replycount'], $line['body'] ); } mysql_free_result( $result ); } else { mysql_free_result( $result ); $query = "SELECT * FROM forum WHERE thread=$post_id OR id=$post_id ORDER BY id"; $result = mysql_query( $query, $link ) or $error .= "MySQL error - couldn't fetch thread contents. ($query)
"
; while ( $line = mysql_fetch_array( $result, MYSQL_ASSOC ) ) { output_post( $reply, $line['id'], $line['time'], $line['subject'], $line['name'], $line['link'], $line['body'] ); } mysql_free_result( $result ); } ?>
"0" cellspacing="0" width="100%"class="forum_post">
"$post_sub " ); if( $post_lnk != "" ) { if ( substr($post_lnk,0,7) != "http://" ) $prefix="mailto:"; echo( "by $post_nam" ); } else echo( " by $post_nam " ); ?> "right">if( $reply ) { ?>"discuss.php?post=">Reply
"r", $post_time ); ?>
"3">

"discuss.php?post="> by replies
"FF0000"> "0000FF">

AFTER:

25;
        $MAX_POST_LENGTH = 1024;

        $link = get_connection();

        $post_id = (int) $_GET['post'];

        echo( '' );

        if ( $post_id == 0 ) {
                echo( "" );

                // display topic list
                $query = "SELECT * FROM forum WHERE thread=0 ORDER BY lastpost DESC LIMIT $FRONT_PAGE_POST_VIEW";
                $result = mysql_query( $query, $link )
                        or die( "Query failed: $query: " . mysql_error() );

                while ( $line = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
                        echo( "" );
                        echo( "" . $line['id'] . "" );
                        echo( "" . $line['name'] . "" );
                        echo( "" . $line['subject'] . "" );
                        echo( "" . $line['replycount'] . "" );
                        echo( "" );
                }

                mysql_free_result( $result );

                echo( "" );

        }
        else {
                // display thread.
                echo( "" );
                echo( "$post_id" );

                $query = "SELECT * FROM forum WHERE thread=$post_id OR id=$post_id ORDER BY id";
                $result = mysql_query( $query, $link )
                        or die( "Query failed: $query: " . mysql_error() );

                while ( $line = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
                        echo( "" );
                        echo( "" . $line['id'] . "" );
                        echo( "" . $line['name'] . "" );
                        echo( "" . $line['subject'] . "" );
                        echo( "" . $line['time'] . "" );
                        echo( " . date( "r", $line['time'] ) . "" );
                        if ( $line['link'] ) {
                                if ( substr( $line['link'],0,7 ) != "http://" ) $prefix="mailto:";
                                else $prefix = "";
                                echo( "$prefix" . $line['link'] . "" );
                        } // don't output this node if there isn't a link.
                        echo( " . $line['body'] . "]]>" );
                        echo( "" );
                }

                mysql_free_result( $result );

                echo( "" );
        }

        echo( '' );

        mysql_close( $link );
?>

Hurr. Time to figure out the XML layout for the rest of the stuff :3

3 comments

Untitled

January 02nd, 2007 | Category: Uncategorized

1) its for the forced tutorial you go through when you start the game. includes explanations of the game mechanics and stuff, basically answers all the questions I’ve been asked before by other people etc.

2) no it can’t be accessed yet lols. I need a day or two more (lol, discovered I didn’t code the script wizard yet, and I needs it) before its all done. should be nice.

3) lol that picture is gonna break my margins

3 comments

(Untitled)

January 01st, 2007 | Category: Uncategorized

lol editors

Before I had to manually input the link points by hand, basically by manually grabbing them in MS Paint. That was such a shitty method, so I’m going back and re-doing my content creation stuff. To make links on the maps, you just… click on the map to set the x,y position and the size. Pretty nifty. I’m also working on some of the artwork, as shown in the picture. I hope I can find an artist next semester so I don’t have to worry about drawing if I continue the project.

There’s also a cool wizard for setting what scripts are executed when you click on the link which pops up in a small toolbox window. That was a nightmarish day wrestling with javascript, so the toolbox could interact with the main window (like, for links which move the player to a new map, the toolbox’ll show a list of maps to move to, etc context sensitive).

I need to figure out the editors for monsters, items, and encounters, and then I think I’ll have an editor for everything I’ve implemented thus far. At that point, I’ll throw in some more content and start working on quests. Hooray!

Comments are off for this post