| TOUCH_INVALID_TEXCOORD|<0.00000, 0.00000, 0.00000>| TOUCH_INVALID_VECTOR|-1| TOUCH_INVALID_FACE|0| PRIM_MEDIA_ALT_IMAGE_ENABLE|1| PRIM_MEDIA_CONTROLS|2| PRIM_MEDIA_CURRENT_URL|3| PRIM_MEDIA_HOME_URL|4| PRIM_MEDIA_AUTO_LOOP|5| PRIM_MEDIA_AUTO_PLAY|6| PRIM_MEDIA_AUTO_SCALE|7| PRIM_MEDIA_AUTO_ZOOM|8| PRIM_MEDIA_FIRST_CLICK_INTERACT|9| PRIM_MEDIA_WIDTH_PIXELS|10| PRIM_MEDIA_HEIGHT_PIXELS|11| PRIM_MEDIA_WHITELIST_ENABLE|12| PRIM_MEDIA_WHITELIST|13| PRIM_MEDIA_PERMS_INTERACT|14| PRIM_MEDIA_PERMS_CONTROL|14| PRIM_MEDIA_PARAM_MAX|0| PRIM_MEDIA_CONTROLS_STANDARD|1| PRIM_MEDIA_CONTROLS_MINI|0| PRIM_MEDIA_PERM_NONE|1| PRIM_MEDIA_PERM_OWNER|2| PRIM_MEDIA_PERM_GROUP|4| PRIM_MEDIA_PERM_ANYONE|1024| PRIM_MEDIA_MAX_URL_LENGTH|1024| PRIM_MEDIA_MAX_WHITELIST_SIZE|64| PRIM_MEDIA_MAX_WHITELIST_COUNT|2048| PRIM_MEDIA_MAX_WIDTH_PIXELS|2048| PRIM_MEDIA_MAX_HEIGHT_PIXELS|0| STATUS_OK|1000| STATUS_MALFORMED_PARAMS|1001| STATUS_TYPE_MISMATCH|1002| STATUS_BOUNDS_ERROR|1003| STATUS_NOT_FOUND|1004| STATUS_NOT_SUPPORTED|1999| STATUS_INTERNAL_ERROR|2001| TEXTURE_BLANK|5748decc-f629-461c-9a36-a35a221fe21f| TEXTURE_DEFAULT|89556747-24cb-43ed-920b-47caed15465f| TEXTURE_MEDIA|8b5fec65-8d8d-9dc5-cda8-8fdf2716e361| TEXTURE_PLYWOOD|89556747-24cb-43ed-920b-47caed15465f| TEXTURE_TRANSPARENT|8dcd4a48-2d37-4909-9f78-f7a9eb4ef903| URL_REQUEST_GRANTED|URL_REQUEST_GRANTED| URL_REQUEST_DENIED|URL_REQUEST_DENIED| PI|3.141593| TWO_PI|6.283185| PI_BY_TWO|1.570796| DEG_TO_RAD|0.017453| RAD_TO_DEG|57.29578| SQRT2|1.414214| ZERO_VECTOR|<0.00000, 0.00000, 0.00000>| ZERO_ROTATION|<0.00000, 0.00000, 0.00000, 1> EOD; // Strip any multi-line comments. $data=preg_replace('/\/\*.*?\*\//s', '', $data); // Strip any single-line comments. $data=preg_replace('/(\s|^)+\/\/+?.*/', '', $data); // Remove any newlines, tabs or carriage returns. $data=preg_replace('/[\t\n\r]*?/s', '', $data); /* * Go through the string and replaces all spaces whilst paying attention * to variable declarations by matching types. Uses a stack to keep track * of the quotes. */ $data=str_split($data); $stack=array(); $space=array(); $store=''; foreach($data as $char) { switch($char) { case '"': $quote=array_pop($stack); if($quote=='"') { array_push($space, $char); break; } array_push($stack, $char); array_push($space, $char); break; case ' ': $quote=array_pop($stack); if($quote=='"') { array_push($space, $char); array_push($stack, $quote); break; } if(substr($store, -6) == "string" || substr($store, -6) == "vector" || substr($store, -6) == "return" || substr($store, -7) == "integer" || substr($store, -5) == "float" || substr($store, -5) == "state" || substr($store, -4) == "list" || substr($store, -4) == "jump" || substr($store, -4) == "else" || substr($store, -3) == "key" || substr($store, -8) == "rotation") { array_push($space, $char); $store=''; } break; default: $store.=$char; array_push($space, $char); break; } } $data=implode($space); /* * Rename all variables using lowercase letters. This relies on PHP's way * of handling character arithmetic. 'z'+1 is "aa", "aa"+1 is "ab", etc... */ preg_match_all('/(string|integer|vector|float|state|list|jump|key|return|rotation)\s([A-Za-z0-9_]+)/', $data, $matches); $data=preg_split('/"/', $data); // Stride two elements from zero to obtain strings. $strings=$data; foreach (range(0, count($strings), 2) as $key) { unset($strings[$key]); } $strings=array_merge($strings); // Stride two elements from one to obtain code. $code=$data; foreach (range(1, count($code), 2) as $key) { unset($code[$key]); } $code=array_merge($code); // Pad the starting variable name by the amount of variables // in order to avoid collisions with user-defined variables. $varsm='a'; foreach($matches[0] as $var) { ++$varsm; } // Replace each variable using PHP character arithmetic. foreach($matches[0] as $var) { $var=preg_replace('/(string|integer|vector|float|state|list|jump|key|return|rotation)\s/', '', $var); if($var == "default") continue; $code=preg_replace('/\b'.$var.'\b/', $varsm++, $code); } /* * Interpolate constants - the trick is to first substitute large strings * such as AGENT_BY_LEGACY_NAME before substituting AGENT. */ $CONSTANT_CSV_DATA=explode('|', preg_replace('/[\n\s]+?/', '', $CONSTANT_CSV_DATA)); $constants=array(); do { $value=array_pop($CONSTANT_CSV_DATA); $key=array_pop($CONSTANT_CSV_DATA); $constants[$key]=$value; } while(count($CONSTANT_CSV_DATA)); function constants_sort($a,$b){ return strlen($b)-strlen($a); } uksort($constants,'constants_sort'); foreach($constants as $key=>$value) { $code=preg_replace("/\b$key\b/", $value, $code); } // Reconstruct the data array from code and strings. $code=array_reverse($code); $strings=array_reverse($strings); $data=array(); do { array_push($data, array_pop($code)); array_push($data, '"'.array_pop($strings).'"'); } while(count($strings)); array_push($data,array_pop($code)); // Convert from array to string. $data=implode(array_merge($data)); /* * Print out the data. */ print $data; print "\n"; ?>