v50 Steam/Premium information for editors
- v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
- Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.
Editing User:Quietust/parsebody.php
Jump to navigation
Jump to search
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 56: | Line 56: | ||
} | } | ||
− | function readBodies ( | + | function readBodies ($file) |
{ | { | ||
+ | $bodies = array(); | ||
+ | |||
+ | $in = @fopen($file, "r"); | ||
+ | if (!$in) | ||
+ | error("unable to open body definitions from $file - please run this from the game's root folder (or from a region folder)"); | ||
+ | $token = readToken($in); | ||
+ | if (!$token || ($token[0] != 'OBJECT') || ($token[1] != 'BODY')) | ||
+ | error("file $file does not contain BODY objects"); | ||
+ | |||
$partname = $partdata = 0; | $partname = $partdata = 0; | ||
$bodyname = $bodydata = 0; | $bodyname = $bodydata = 0; | ||
Line 118: | Line 127: | ||
} | } | ||
} | } | ||
+ | fclose($in); | ||
+ | return $bodies; | ||
} | } | ||
Line 124: | Line 135: | ||
if (isset($part['UPPERBODY'])) | if (isset($part['UPPERBODY'])) | ||
{ | { | ||
− | verbose(" | + | verbose("-"); |
return TRUE; | return TRUE; | ||
} | } | ||
$types = 0; | $types = 0; | ||
+ | $found = FALSE; | ||
$numcon = $numcat = $numtype = 0; | $numcon = $numcat = $numtype = 0; | ||
if (isset($part['CON'])) | if (isset($part['CON'])) | ||
Line 145: | Line 157: | ||
{ | { | ||
$types++; | $types++; | ||
− | |||
foreach ($body as $bp) | foreach ($body as $bp) | ||
{ | { | ||
Line 152: | Line 163: | ||
if ($part['CON_CAT'] == $bp['CATEGORY']) | if ($part['CON_CAT'] == $bp['CATEGORY']) | ||
{ | { | ||
− | |||
if ($numcat) | if ($numcat) | ||
verbose("...and the $part[name] bone's connected to the $bp[name] bone"); | verbose("...and the $part[name] bone's connected to the $bp[name] bone"); | ||
Line 161: | Line 171: | ||
} | } | ||
} | } | ||
− | if (!$ | + | if (!$numcat) |
warning("Body part $part[id] could not find [CATEGORY:$part[CON_CAT]] body part to connect to!"); | warning("Body part $part[id] could not find [CATEGORY:$part[CON_CAT]] body part to connect to!"); | ||
} | } | ||
Line 167: | Line 177: | ||
{ | { | ||
$types++; | $types++; | ||
− | |||
foreach ($body as $bp) | foreach ($body as $bp) | ||
{ | { | ||
if (isset($bp[$part['CONTYPE']])) | if (isset($bp[$part['CONTYPE']])) | ||
{ | { | ||
− | |||
if ($numtype) | if ($numtype) | ||
verbose("...and the $part[name] bone's connected to the $bp[name] bone"); | verbose("...and the $part[name] bone's connected to the $bp[name] bone"); | ||
Line 180: | Line 188: | ||
} | } | ||
} | } | ||
− | if (!$ | + | if (!$numtype) |
warning("Body part $part[id] could not find [$part[CONTYPE]] body part to connect to!"); | warning("Body part $part[id] could not find [$part[CONTYPE]] body part to connect to!"); | ||
} | } | ||
Line 239: | Line 247: | ||
} | } | ||
− | $bodies = | + | //$bodies = readBodies("raw/objects/body_rcp.txt"); |
− | + | $bodies = readBodies("raw/objects/body_default.txt"); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | foreach (glob("raw/objects/*.txt") as $filename) | + | foreach (glob("raw/objects/creature_*.txt") as $filename) |
{ | { | ||
$in = fopen($filename, "r"); | $in = fopen($filename, "r"); | ||
Line 262: | Line 258: | ||
if (($token) && ($token[0] == 'OBJECT') && ($token[1] == 'CREATURE')) | if (($token) && ($token[0] == 'OBJECT') && ($token[1] == 'CREATURE')) | ||
{ | { | ||
− | $creature = | + | $creature = 0; |
while (1) | while (1) | ||
{ | { | ||
Line 270: | Line 266: | ||
if ($token[0] == 'CREATURE') | if ($token[0] == 'CREATURE') | ||
$creature = $token[1]; | $creature = $token[1]; | ||
− | if | + | if ($token[0] == 'BODY') |
{ | { | ||
if (in_array($filter, array($creature, 'all'))) | if (in_array($filter, array($creature, 'all'))) |