Example #1
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;
}
// 0 to skip using
$debugging_rows = 11111150;
//echo ToHex( 0x0F,4 )."-".ToHex( 0xFF,4 )."-".ToHex( 0xABC,4 );
while ($inp_h && !feof($inp_h)) {
    $debugging_rows--;
    if ($debugging_rows <= 0) {
        break;
    }
    //take 1 line
    $line = fgets($inp_h);
    $vect = convert_line_to_elements($line);
    $line_size = count($vect);
    $line_index = 0;
    $guid1 = convert_from_line_to_guid($vect);
    //echo "$line_index<br>";
    $guid2 = convert_from_line_to_guid($vect);
    //echo "$line_index<br>";
    $x = convert_to_float(convert_from_line_to_int($vect));
    //echo "$line_index<br>";
    $y = convert_to_float(convert_from_line_to_int($vect));
    //echo "$line_index<br>";
    $z = convert_to_float(convert_from_line_to_int($vect));
    //echo "$line_index<br>";
    $sync = convert_from_line_to_int($vect);
    //echo "$line_index<br>";
    $f1 = $vect[$line_index++];
    if (($f1 & $SearchForFlag1) == 0) {
        continue;
    }
    //echo "$line_index<br>";
    if ($f1 == 3) {