2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#pragma hdrstop
|
2012-12-22 15:18:19 +00:00
|
|
|
#include "precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
int c_PlaceObject2;
|
|
|
|
int c_PlaceObject3;
|
|
|
|
|
|
|
|
#define PlaceFlagHasClipActions BIT( 7 )
|
|
|
|
#define PlaceFlagHasClipDepth BIT( 6 )
|
|
|
|
#define PlaceFlagHasName BIT( 5 )
|
|
|
|
#define PlaceFlagHasRatio BIT( 4 )
|
|
|
|
#define PlaceFlagHasColorTransform BIT( 3 )
|
|
|
|
#define PlaceFlagHasMatrix BIT( 2 )
|
|
|
|
#define PlaceFlagHasCharacter BIT( 1 )
|
|
|
|
#define PlaceFlagMove BIT( 0 )
|
|
|
|
|
|
|
|
#define PlaceFlagPad0 BIT( 7 )
|
|
|
|
#define PlaceFlagPad1 BIT( 6 )
|
|
|
|
#define PlaceFlagPad2 BIT( 5 )
|
|
|
|
#define PlaceFlagHasImage BIT( 4 )
|
|
|
|
#define PlaceFlagHasClassName BIT( 3 )
|
|
|
|
#define PlaceFlagCacheAsBitmap BIT( 2 )
|
|
|
|
#define PlaceFlagHasBlendMode BIT( 1 )
|
|
|
|
#define PlaceFlagHasFilterList BIT( 0 )
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSWFSpriteInstance::PlaceObject2
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idSWFSpriteInstance::PlaceObject2( idSWFBitStream& bitstream )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
c_PlaceObject2++;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
uint64 flags = bitstream.ReadU8();
|
|
|
|
int depth = bitstream.ReadU16();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int characterID = -1;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasCharacter ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
characterID = bitstream.ReadU16();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
swfDisplayEntry_t* display = NULL;
|
|
|
|
|
|
|
|
if( ( flags & PlaceFlagMove ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// modify an existing entry
|
|
|
|
display = FindDisplayEntry( depth );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject2: trying to modify entry %d, which doesn't exist", depth );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( characterID >= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// We are very picky about what kind of objects can change characters
|
|
|
|
// Shapes can become other shapes, but sprites can never change
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display->spriteInstance || display->textInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject2: Trying to change the character of a sprite after it's been created" );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFDictionaryEntry* dictEntry = sprite->swf->FindDictionaryEntry( characterID );
|
|
|
|
if( dictEntry != NULL )
|
|
|
|
{
|
|
|
|
if( dictEntry->type == SWF_DICT_SPRITE || dictEntry->type == SWF_DICT_EDITTEXT )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject2: Trying to change the character of a shape to a sprite" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
display->characterID = characterID;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( characterID < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject2: Trying to create a new object without a character" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// create a new entry
|
|
|
|
display = AddDisplayEntry( depth, characterID );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject2: trying to create a new entry at %d, but an item already exists there", depth );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasMatrix ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bitstream.ReadMatrix( display->matrix );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasColorTransform ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bitstream.ReadColorXFormRGBA( display->cxf );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasRatio ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->ratio = bitstream.ReadU16() * ( 1.0f / 65535.0f );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasName ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr name = bitstream.ReadString();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display->spriteInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->spriteInstance->name = name;
|
|
|
|
scriptObject->Set( name, display->spriteInstance->GetScriptObject() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( display->textInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
scriptObject->Set( name, display->textInstance->GetScriptObject() );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasClipDepth ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->clipDepth = bitstream.ReadU16();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags & PlaceFlagHasClipActions ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// FIXME: clip actions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSWFSpriteInstance::PlaceObject3
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idSWFSpriteInstance::PlaceObject3( idSWFBitStream& bitstream )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
c_PlaceObject3++;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
uint64 flags1 = bitstream.ReadU8();
|
|
|
|
uint64 flags2 = bitstream.ReadU8();
|
|
|
|
uint16 depth = bitstream.ReadU16();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( ( flags2 & PlaceFlagHasClassName ) != 0 || ( ( ( flags2 & PlaceFlagHasImage ) != 0 ) && ( ( flags1 & PlaceFlagHasCharacter ) != 0 ) ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bitstream.ReadString(); // ignored
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int characterID = -1;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasCharacter ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
characterID = bitstream.ReadU16();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
swfDisplayEntry_t* display = NULL;
|
|
|
|
|
|
|
|
if( ( flags1 & PlaceFlagMove ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// modify an existing entry
|
|
|
|
display = FindDisplayEntry( depth );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject3: trying to modify entry %d, which doesn't exist", depth );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( characterID >= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// We are very picky about what kind of objects can change characters
|
|
|
|
// Shapes can become other shapes, but sprites can never change
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display->spriteInstance || display->textInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject3: Trying to change the character of a sprite after it's been created" );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFDictionaryEntry* dictEntry = sprite->swf->FindDictionaryEntry( characterID );
|
|
|
|
if( dictEntry != NULL )
|
|
|
|
{
|
|
|
|
if( dictEntry->type == SWF_DICT_SPRITE || dictEntry->type == SWF_DICT_EDITTEXT )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject3: Trying to change the character of a shape to a sprite" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
display->characterID = characterID;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( characterID < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject3: Trying to create a new object without a character" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// create a new entry
|
|
|
|
display = AddDisplayEntry( depth, characterID );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idLib::Warning( "PlaceObject3: trying to create a new entry at %d, but an item already exists there", depth );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasMatrix ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bitstream.ReadMatrix( display->matrix );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasColorTransform ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bitstream.ReadColorXFormRGBA( display->cxf );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasRatio ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->ratio = bitstream.ReadU16() * ( 1.0f / 65535.0f );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasName ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr name = bitstream.ReadString();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( display->spriteInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->spriteInstance->name = name;
|
|
|
|
scriptObject->Set( name, display->spriteInstance->GetScriptObject() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( display->textInstance )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
scriptObject->Set( name, display->textInstance->GetScriptObject() );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasClipDepth ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->clipDepth = bitstream.ReadU16();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags2 & PlaceFlagHasFilterList ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// we don't support filters and because the filter list is variable length we
|
|
|
|
// can't support anything after the filter list either (blend modes and clip actions)
|
|
|
|
idLib::Warning( "PlaceObject3: has filters" );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags2 & PlaceFlagHasBlendMode ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
display->blendMode = bitstream.ReadU8();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( ( flags1 & PlaceFlagHasClipActions ) != 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// FIXME:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idSWFSpriteInstance::RemoveObject2
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idSWFSpriteInstance::RemoveObject2( idSWFBitStream& bitstream )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
RemoveDisplayEntry( bitstream.ReadU16() );
|
|
|
|
}
|