$vect = convert_line_to_elements($value);
    $line_index = 0;
    $map_id = convert_from_line_to_int($vect);
    $x = convert_to_float(convert_from_line_to_int($vect));
    $y = convert_to_float(convert_from_line_to_int($vect));
    $z = convert_to_float(convert_from_line_to_int($vect));
    $o = convert_to_float(convert_from_line_to_int($vect));
    echo "update playercreateinfo set mapID={$map_id},positionX={$x},positiony={$y},positionz={$z} where `race`={$key};<br>";
}
$vect = convert_line_to_elements($p_world_class[$DEATHKNIGHT]);
$line_index = 0;
$map_id = convert_from_line_to_int($vect);
$x = convert_to_float(convert_from_line_to_int($vect));
$y = convert_to_float(convert_from_line_to_int($vect));
$z = convert_to_float(convert_from_line_to_int($vect));
$o = convert_to_float(convert_from_line_to_int($vect));
echo "update playercreateinfo set mapID={$map_id},positionX={$x},positiony={$y},positionz={$z} where `class`={$key};<br>";
echo "<br> <br>";
$racials[$RACE_WORGEN] = "87840,69001,68996,68975,94293,68976,68992";
//in case they are not already added
$racials[$RACE_GOBLIN] = "69046,69041,69070,69042,69044,69045";
//in case they are not already added
//now generate spells
for ($trace = 0; $trace < 30; $trace++) {
    for ($tclass = 0; $tclass < 30; $tclass++) {
        if ($p_spells[$trace][$tclass]) {
            //get the index for this race class combination
            $get_query = "select `index` from playercreateinfo where class={$tclass} and race={$trace}";
            $get_res = mysql_query($get_query, $dbi) or die(" Q200611231501411 " . mysql_error($dbi));
            list($zindex) = mysql_fetch_row($get_res);
            $vect = convert_line_to_elements($p_spells[$trace][$tclass]);
示例#2
0
function read_block_move_part($line, $object_type_id)
{
    global $line_index, $bytes, $debug, $out_unk;
    $move_info = "";
    $move_info->flags = (int) $line[$line_index++];
    if ($move_info->flags & 0x20) {
        $move_info->flags2 = (int) convert_from_line_to_int($line);
        $move_info->unk1 = (int) convert_from_line_to_int($line);
        //maybe time ?
        //flag2=1 , flag1=112 -> 64
        $move_info->unkbyte1 = $line[$line_index++];
        //introduced in 2.3.0
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x20 => flags2(uint32)={$move_info->flags2} + unk(uint32)={$move_info->unk1} + unk(uint8)={$move_info->unkbyte1}\r\n");
        }
    }
    if ($move_info->flags & 0x40) {
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x40 \r\n");
        }
        if ($move_info->flags & 0x2) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x40 and move_info->flags & 0x02 => 4*32bit  (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
            }
            $move_info->x = convert_to_float(convert_from_line_to_int($line));
            // 0
            $move_info->y = convert_to_float(convert_from_line_to_int($line));
            // 0
            $move_info->z = convert_to_float(convert_from_line_to_int($line));
            // 0
            $move_info->o = convert_to_float(convert_from_line_to_int($line));
            // 0rientation
        } else {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x40 and position (4x float) => 4 * 32 bit  (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
            }
            $move_info->x = convert_to_float(convert_from_line_to_int($line));
            $move_info->y = convert_to_float(convert_from_line_to_int($line));
            $move_info->z = convert_to_float(convert_from_line_to_int($line));
            $move_info->o = convert_to_float(convert_from_line_to_int($line));
        }
        if ($move_info->flags & 0x20 && $move_info->flags2 & 0x200) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x40 and (move_info->flags & 0x20) && (move_info->flags2 & 0x0200) => 6 * 32bit  (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
            }
            $move_info->transporterguid[0] = convert_from_line_to_int($line);
            $move_info->transporterguid[1] = convert_from_line_to_int($line);
            $move_info->tr_x = convert_to_float(convert_from_line_to_int($line));
            $move_info->tr_y = convert_to_float(convert_from_line_to_int($line));
            $move_info->tr_z = convert_to_float(convert_from_line_to_int($line));
            $move_info->tr_o = convert_to_float(convert_from_line_to_int($line));
            $move_info->tr_unk = convert_from_line_to_int($line);
        }
    }
    if ($move_info->flags & 0x20) {
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x20 \r\n");
        }
        if ($move_info->flags2 & 0x1) {
        }
        // will make client show running anymation for the unit all the time to specific creatures
        if ($move_info->flags2 & 0x4) {
        }
        //no action in 2.3.0 maybe it is for client only ?
        if ($move_info->flags2 & 0x10) {
        }
        //no action in 2.3.0 maybe it is for client only ?
        if ($move_info->flags2 & 0x100) {
        }
        // will make client show running anymation for the unit all the time to specific creatures
        if ($move_info->flags2 & 0x400) {
        }
        // will make client show npc layed down playing the wounded
        if ($move_info->flags2 & 0x800) {
        }
        // some state but it will make client crash if no aditional data provided ?
        if ($move_info->flags2 & 0x100000) {
        }
        //no action in 2.3.0 maybe it is for client only ?
        if ($move_info->flags2 & 0x1000000) {
        }
        //no action in 2.3.0 maybe it is for client only ?
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x20 => alwayts 0 (not always actually)\r\n");
        }
        $move_info->unk22 = (int) convert_from_line_to_int($line);
        //seems like always 0
        if ($move_info->flags2 & 0x2000 || $move_info->flags2 & 0x1000) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x20 move_info->flags2 & 0x00002000  => 4*float (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
            }
            $move_info->punk1 = convert_to_float(convert_from_line_to_int($line));
            //should be 0
            $move_info->punk2 = convert_to_float(convert_from_line_to_int($line));
            //should be 0
            $move_info->punk3 = convert_to_float(convert_from_line_to_int($line));
            //should be 1
            $move_info->punk4 = convert_to_float(convert_from_line_to_int($line));
            //should be 0
        }
        if ($move_info->flags2 & 0x2000000) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x20 move_info->flags2 & 0x02000000 => uint32\r\n");
            }
            $move_info->unk_02000000 = convert_from_line_to_int($line);
        }
        if ($move_info->flags2 & 0x200000) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x20 move_info->flags2 & 0x00200000 => uint32\r\n");
            }
            $move_info->unk_00200000 = convert_from_line_to_int($line);
        }
        if ($move_info->flags2 & 0x4000000) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x20 move_info->flags2 & 0x04000000 => uint32 \r\n");
            }
            $move_info->unk_04000000 = convert_from_line_to_int($line);
        }
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x20 => 8 * float values as speed (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
        }
        $move_info->walks = convert_to_float(convert_from_line_to_int($line));
        $move_info->runs = convert_to_float(convert_from_line_to_int($line));
        $move_info->walkbacks = convert_to_float(convert_from_line_to_int($line));
        $move_info->swims = convert_to_float(convert_from_line_to_int($line));
        $move_info->swimbacks = convert_to_float(convert_from_line_to_int($line));
        $move_info->flys = convert_to_float(convert_from_line_to_int($line));
        $move_info->backflyS = convert_to_float(convert_from_line_to_int($line));
        $move_info->turns = convert_to_float(convert_from_line_to_int($line));
        //        if($move_info->flags2 & 0x00400000)
        //maybe not good at all but in case this is not updatemask then something else is here
        //		if(!is_valid_update_mask($line[$line_index+4],$object_type_id) || ($move_info->flags2 & 0x00400000))//skip that wierd unk number and then get mask count
        if ($move_info->flags2 & 0x8000000) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags2 & 0x08000000 => splineflags\r\n");
            }
            $move_info->splineFlags = (int) convert_from_line_to_int($line);
            if ($move_info->splineFlags & 0x10000) {
                if ($debug == 1) {
                    fputs($out_unk, "has move_info->flags2 & 0x08000000 move_info->splineFlags & 0x00010000 => 3 * float  (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
                }
                $move_info->splinex[0] = convert_to_float(convert_from_line_to_int($line));
                $move_info->spliney[0] = convert_to_float(convert_from_line_to_int($line));
                $move_info->splinez[0] = convert_to_float(convert_from_line_to_int($line));
            }
            if ($move_info->splineFlags & 0x20000) {
                if ($debug == 1) {
                    fputs($out_unk, "has move_info->flags2 & 0x08000000 move_info->splineFlags & 0x00010000 => 2* 32bit\r\n");
                }
                $move_info->splineguid[0] = convert_from_line_to_int($line);
                $move_info->splineguid[1] = convert_from_line_to_int($line);
            }
            if ($move_info->splineFlags & 0x40000) {
                if ($debug == 1) {
                    fputs($out_unk, "has move_info->flags2 & 0x08000000 move_info->splineFlags & 0x00010000 => 1 value\r\n");
                }
                $move_info->splineo = convert_to_float(convert_from_line_to_int($line));
            }
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags2 & 0x08000000 => 4 values -> last is splinecount after that (splinecount+1)*3 uint32 (bytes from first value : " . $line[$line_index] . " " . $line[$line_index + 1] . " " . $line[$line_index + 2] . " " . $line[$line_index + 3] . "\r\n");
            }
            $move_info->splinetime1 = convert_from_line_to_int($line);
            $move_info->splinetime2 = convert_from_line_to_int($line);
            $move_info->splineunk1 = convert_from_line_to_int($line);
            $move_info->splinecount = convert_from_line_to_int($line);
            if ($move_info->splinecount > $bytes / 4) {
                $move_info->splinecount = 0;
            }
            //something went wrong
            //echo "Spline found at $line_index,count ".$move_info->splinecount." investigate! <br>";
            for ($j = 0; $j <= $move_info->splinecount; $j++) {
                $move_info->splinex[$j] = convert_to_float(convert_from_line_to_int($line));
                $move_info->spliney[$j] = convert_to_float(convert_from_line_to_int($line));
                $move_info->splinez[$j] = convert_to_float(convert_from_line_to_int($line));
            }
            if ($move_info->splineFlags & 0x100) {
            }
            //no action in 2.3.0
        }
    }
    if ($move_info->flags & 0x8 && $move_info->flags & 0x10) {
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x08 && move_info->flags & 0x10 => full guid\r\n");
        }
        $move_info->guid8[0] = convert_from_line_to_int($line);
        $move_info->guid8[1] = convert_from_line_to_int($line);
    } else {
        if ($move_info->flags & 0x10) {
            if ($debug == 1) {
                fputs($out_unk, "has move_info->flags & 0x10 => uint32\r\n");
            }
            $move_info->packetrecipientcount[0] = convert_from_line_to_int($line);
            //value seems to related to flag1 value
        }
    }
    if ($move_info->flags & 0x4) {
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x04 => compressed guid\r\n");
        }
        $move_info->guid = convert_from_line_to_guid($line);
    }
    if ($move_info->flags & 0x2) {
        if ($debug == 1) {
            fputs($out_unk, "has move_info->flags & 0x02 => uint32 \r\n");
        }
        $move_info->assoc = convert_from_line_to_int($line);
        //-> maybe compressed guid ?
    }
    return $move_info;
}
    }
}
echo "Number of non common states found : {$uncommon_states_count} <br>";
ksort($common_states_sorted_non_zero);
ksort($common_states_sorted_zero);
//print_r( $common_states_sorted );
foreach ($common_states_sorted_non_zero as $key => $val) {
    if (10000000 < $val || -10000000 > $val) {
        echo "SetWorldState({$key},{$val}); //" . convert_to_float($val) . ".0f <br>";
    } else {
        echo "SetWorldState({$key},{$val}); <br>";
    }
}
foreach ($common_states_sorted_zero as $key => $val) {
    if (10000000 < $val || -10000000 > $val) {
        echo "SetWorldState({$key},{$val}); //" . convert_to_float($val) . ".0f <br>";
    } else {
        echo "SetWorldState({$key},{$val}); <br>";
    }
}
/*
for($i=0;$i<$common_states_count;$i+=2)
	if( $sv[0][$i + 1] != 0 )
	{
		if( 10000000 < $sv[0][$i+1] ||  -10000000 > $sv[0][$i+1] )
			echo "SetWorldState({$sv[0][$i]},".convert_to_float($sv[0][$i+1]).".0f);<br>";
		else		
			echo "SetWorldState({$sv[0][$i]},{$sv[0][$i+1]}); <br>";
	}
for($i=0;$i<$common_states_count;$i+=2)
	if( $sv[0][$i + 1] == 0 )
 /**
  * @dataProvider floatTestData
  */
 public function testConvertToFloat($value, $expected)
 {
     $this->assertSame($expected, convert_to_float($value));
 }
示例#5
0
                $parts = explode(" ", $text);
                $part_no = count($parts);
                //echo "'$part_no'<br>";
                for ($i = 0; $i < $part_no; $i++) {
                    $number_as_int = convert_from_hex_to_dec($parts[$i]);
                    if ($number_as_int) {
                        $asci_text .= chr($number_as_int);
                    }
                }
            }
        }
    }
}
echo "the number as int : {$number_as_int} <br>";
echo "the number as signed int : " . (int) $number_as_int . " <br>";
$as_float = convert_to_float($number_as_int);
echo "the number as float : {$as_float} <br>";
echo "the hex as text : {$asci_text} <br>";
$as_bin_mask = convert_to_binMask($number_as_int);
echo "the hex bin mask : {$as_bin_mask} <br>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function convert_to_binMask($value)
{
    for ($i = 0; $i < 32; $i++) {
        $str_out .= (int) $value & 1;
        $value = $value / 2;
    }
    return $str_out;
}
function convert_to_float($value)
{