Menu

#21 two undefined offset fixes, stats allignment fix

open
nobody
None
5
2005-02-26
2005-02-26
xelloss42
No

I'm using Opera, but these errors were in Firefox as well.

I was getting the following two errors:

Notice: Undefined offset: 3 in G:
\web\htdocs\sunshine\profile\lib\char.php on line 29

where the stat for Armor was supposed to be displayed,
followed by the correct armor amount.

And

Notice: Undefined offset: 14 in G:
\web\htdocs\sunshine\profile\lib\bag.php on line 40

in the bags area for each square that was empty.

Also, the character stats and attack damage stats were
a row too high for some reason, so that the values for
"strength" and "Melee Attack" were a line above the stat
box. To fix this, I just added breaks to both functions.

(in lib/char.php near line 26)
function printStat( $statname ) {
echo '<br>';

(in lib/char.php near line 55)
function printAtk( $type, $stat ) {
echo '<br>';

The first error was because the Stat exploder was
expecting four numbers separated by three colons.
Since the Armor value is only three numbers, it was
getting an error. To fix this I checked if the statname
was armor, and if so only exploded 3 parts instead of 4.
The original chunk was surrounded by an else statement.

(in lib/char.php near line 29)

function printStat( $statname ) {
echo '<br>';
if ( $statname == 'armor' ){
list($base, $current, $mod) =
explode( ":", $this->data[$statname] );
}
else {
list($base, $current, $mod, $unknown) =
explode( ":", $this->data[$statname] );
}
if( $mod == 0 ) {

The second error was caused by $item recieving
undefined values. I just checked to see if the bag slot in
question was empty, and if so, assigned a null to $item

(in lib/bag.php near line 40)

echo '&lt;div class="bagNoSlot"&gt;&lt;/div&gt;';

} else {
echo '<div class="bagSlot">';
if ( !isset( $this->contents[$slot+1] ) ) $item = null;
else $item = $this->contents[$slot+1];
if( isset( $item ) ) {
$item->out();

Discussion


Log in to post a comment.

MongoDB Logo MongoDB