Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Level Packer v2.1.0 | djazz | Utility | 9.4 |
<?php
ini_set('memory_limit', 10000000000);
ini_set('max_execution_time', 0);
/**
* class.Level.php
*
* Provides an interface to read Level (J2L) files.
*
* LICENSE:
*
* DO WHAT THE FUCK YOU WANT TO LICENSE
* Version 2, December 2004
*
* Copyright (C) 2009 Stijn Peeters
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
*
* DO WHAT THE FUCK YOU WANT TO LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*
* @package J2Ov4
* @author Stijn Peeters
* @copyright Copyright (c) 2009, Stijn Peeters
* @version 0.5
* @link http://www.stijnpeeters.nl/
*/
/**
* Level class
*
* Reads and interprets Jazz Jackrabbit 2 Level files
*
* @package J2Ov4
* @author Stijn Peeters
* @copyright Copyright (c) 2009, Stijn Peeters
* @version 0.5
* @todo Support for flipped and animated tiles
* @todo Other stuff I didn't think of yet!
*/
/**
* @var int The handle to the Level tile to read from.
* @access private
*/
$rResource=null;
/**
* @var mixed Image Data header bytes (raw pixels).
* @access private
*/
$_Header = false;
/**
* @var mixed Level info header bytes.
* @access private
*/
$_LevelInfo = false;
/**
* @var mixed Level event data bytes.
* @access private
*/
$_EventData = false;
/**
* @var mixed Tile dictionary bytes.
* @access private
*/
$_Dictionary = false;
/**
* @var mixed Tile cache bytes.
* @access private
*/
$_TileCache = false;
/**
* @var int Quick Preview image (GDLib resource).
* @access private
*/
$rQuickPreview = null;
/**
* @var int Real Preview image (GDLib resource).
* @access private
*/
$rRealPreview = null;
/**
* @var array Level information such as tileset, settings, name, etc
* @access private
*/
$aLevelInfo = array();
/**
* @var array Parsed dictionary data to be used in rendering the level.
* @access private
*/
$aWords = array();
/**
* @var array The version of the level.
* @access private
*/
$sVersion = '';
/**
* @var array Byte offsets for several parts of the level.
*/
$aOffsets = array();
/**
* @var boolean Whether debug messages should be printed or not.
* @access private
*/
$bDebug = false;
/**
* Size of the Level header
*/
define( "SIZE_HEADER" ,262 );
/**
* Every tile will be x pixels in the preview
*/
define( "PREVIEW_SCALE" ,32 );
/**
* Max width/height of the image, to prevent out of memory problems
*/
define( "MAX_DIMENSION" ,10000 );
/**
* Level info structure (see php's pack() function for syntax info)
*/
define( "LEVL_STRUCT" ,'xWTF/
vJcsHorizontal/
vSecurityEnvelope1/
vJcsVertical/
CSecurityEnvelope2/
CSecEnvAndLayer/
CMinimumAmbient/
CStartingAmbient/
vAnimsUsed/
CSplitScreenDivider/
CIsItMultiplayer/
VStreamSize/
a32LevelName/
a32Tileset/
a32BonusLevel/
a32NextLevel/
a32SecretLevel/
a32MusicFile/
A8192HelpStrings/
V8LayerProperties/
x8LayerUnknown1/
C8IsLayerUsed/
V8JcsLayerWidth/
V8LayerWidth/
V8LayerHeight/
x16LayerUnknown2/
x32LayerUnknown3/
x32LayerUnknown4/
x24LayerUnknown5/
l8LayerXSpeed/
l8LayerYSpeed/
l8LayerAutoXSpeed/
l8LayerAutoYSpeed/
x8LayerUnknown6/
C3LayerRGB1/
C3LayerRGB2/
C3LayerRGB3/
C3LayerRGB4/
C3LayerRGB5/
C3LayerRGB6/
C3LayerRGB7/
C3LayerRGB8/
vStaticTiles' );
/**
* This is the directory the class will look in for cached tileset images
*/
define( "CACHE_DIR" ,'./' );
/**
* This is the directory the class will look in for tilesets if no image is found
*/
define( "ROOT_DIR" ,'./' );
/**
* Magic byte value for TSF tilesets
*/
define( "VERSION_TSF" ,515 );
/**
* Magic byte value for 1.23 tilesets
*/
define( "VERSION_123" ,514 );
/**
* Constructor method
*/
function construct($sFilename) {
global $rResource,$aOffsets;
if(!is_readable($sFilename)) {
debug('Tileset file not found');
return false;
}
$sPath = $sFilename;
$rResource = fopen($sPath, 'rb');
$rQuickPreview = false;
$rRealPreview = false;
getHeader();
return getLevelInfo();
}
/**
* Retrieve Level header
*/
function getHeader() {
global $rResource,$aOffsets,$sVersion;
$_Header = fread($rResource, SIZE_HEADER);
$aOffsets = array();
list(,$aOffsets['info_c']) = unpack('V', substr($_Header, 230, 4));
list(,$aOffsets['info_u']) = unpack('V', substr($_Header, 234, 4));
/*list(,$aOffsets['evnt_c']) = unpack('V', substr($_Header, 238, 4));
list(,$aOffsets['evnt_u']) = unpack('V', substr($_Header, 242, 4));
list(,$aOffsets['dict_c']) = unpack('V', substr($_Header, 246, 4));
list(,$aOffsets['dict_u']) = unpack('V', substr($_Header, 250, 4));
list(,$aOffsets['tile_c']) = unpack('V', substr($_Header, 254, 4));
list(,$aOffsets['tile_u']) = unpack('V', substr($_Header, 258, 4));*/
list(,$sVersion) = unpack('v', substr($_Header, 220, 2));
}
/**
* Get level info data
*/
function getInfoData() {
global $rResource,$aOffsets,$_LevelInfo;
if(!$_LevelInfo) {
$_LevelInfo = gzuncompress(fread($rResource, $aOffsets['info_c']));
}
return $_LevelInfo;
}
/**
* Get level info
*/
function getLevelInfo($mReturn = false) {
global $aLevelInfo, $_LevelInfo;
if($aLevelInfo) {
if($mReturn == 'layers') {
return $aLevelInfo['layers'];
}
return $aLevelInfo;
}
//if(!$_LevelInfo) {
getInfoData();
//}
$sFormat = str_replace(array("\n", "\r", ' '), '', LEVL_STRUCT);
$aLevelInfo = unpack($sFormat, $_LevelInfo);
$aLevelInfo = $aLevelInfo;
if($mReturn == 'layers') {
return $aLevelInfo['layers'];
}
$_LevelInfo=false;
$aa=$aLevelInfo;
$aLevelInfo=false;
return $aa;
}
?>
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.