Ejemplo n.º 1
0
int CBuilding::DeforeRemove()
{
	const SBuildingConfigData *buidlingData = GetBuildingData( property.index );
    if ( buidlingData == NULL )
        return false;

	// 清除阻挡失败
	if ( !RelationBlock( FALSE ) )
		return false;

	//if ( buidlingData->qwtileMask || buidlingData->dwtileLimit )
	//{
	//	if ( m_ParentRegion == NULL )
	//		return false;

	//	POINT blkpos = { m_wCurX  - ( property.inverse ? ( 8 - buidlingData->centerx  ) : buidlingData->centerx ), 
	//		m_wCurY - buidlingData->centery };

	//	for ( int row = 0; row < 8; row ++ )
	//	{
	//		for ( int col = 0; col < 8; col ++ )
	//		{		
	//			int tx = blkpos.x + col;
	//			int ty = blkpos.y + row;

	//			if ( ( tx >= m_ParentRegion->m_RegionW ) || 
	//				( ty >= m_ParentRegion->m_RegionH ) ) 
	//				return false;

	//			if ( ( ( LPBYTE )&buidlingData->dwtileLimit )[ row ] & ( 1 << ( property.inverse ? 7 - col : col ) ) )
	//			{
	//				// 放置限制
	//				DWORD tiles = m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ];
	//				tiles &= 0xfffffffb;
	//				m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] = tiles;
	//			}
	//			if ( ( ( LPBYTE )&buidlingData->dwtileMask )[ row ] & ( 1 << ( property.inverse ? 7 - col : col ) ) )
	//			{
	//				// 阻挡
	//				DWORD tiles = m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] ;
	//				tiles |= 0x1;
	//				m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] = tiles;
	//			}
	//		}
	//	}
	//}

	if ( buidlingData->ctrlScript )
	{
        g_Script.SetCondition( NULL, NULL, NULL, this );
		LuaFunctor( g_Script, FormatString( "Building_Remove_%d", buidlingData->ctrlScript ) ) ();
        g_Script.CleanCondition();
	}
    return 0;
}
void ManipulatorGameData::SetBuildingAbility( const std::wstring& buildingName, int slotIndex, const std::wstring& abilName )
{
	assert(slotIndex >= 0 && slotIndex < 15);
	(const_cast<SBuildingData*>(GetBuildingData(buildingName)))->m_vecAbilities[slotIndex] = Utility::UnicodeToEngine(abilName);
}
Ejemplo n.º 3
0
int CBuilding::AfterCreate( CPlayer *pPlayer, BOOL isGenerate )
{
    if ( m_ParentRegion == NULL )
        return false;

    const SBuildingConfigData *buidlingData = GetBuildingData( property.index );
    if ( buidlingData == NULL )
        return false;

    // 初次创建,并且有创建脚本!
    if ( isGenerate && buidlingData->ctrlScript )
    {
		lite::Variant ret;
		// 作为帮派大门来说,就使用它来设置帮派参数!
		g_Script.SetCondition( NULL, pPlayer, NULL, this );
		LuaFunctor( g_Script, FormatString( "Building_CreateScript_%d", buidlingData->ctrlScript ) ) ( &ret );
        g_Script.CleanCondition();

		try
		{
			if ( ret.dataType != lite::Variant::VT_EMPTY && ret.dataType != lite::Variant::VT_NULL )
				if ( ( int )ret == -1 ) 
					return -1;
		}
		catch ( lite::Xcpt & )
		{
		}
    }

    // 如果有初始化脚本,则调用!暂时只用来设置帮派场景入口!
    if ( buidlingData->initScript )
    {
		lite::Variant ret;
        g_Script.SetCondition( NULL, pPlayer, NULL, this );
		LuaFunctor( g_Script, FormatString( "Building_InitScript_%d", buidlingData->initScript ) ) ( &ret );
        g_Script.CleanCondition();

		try
		{
			if ( ret.dataType != lite::Variant::VT_EMPTY && ret.dataType != lite::Variant::VT_NULL )
				if ( ( int )ret == -1 ) 
					return -1;
		}
		catch ( lite::Xcpt & )
		{
		}
    }

    // 设置阻挡信息
	RelationBlock( TRUE );
	//if ( buidlingData->qwtileMask || buidlingData->dwtileLimit )
	//{
	//	POINT blkpos = { m_wCurX  - ( property.inverse ? ( 8 - buidlingData->centerx  ) : buidlingData->centerx ), 
	//		m_wCurY - buidlingData->centery };

	//	for ( int row = 0; row < 8; row ++ )
	//	{
	//		for ( int col = 0; col < 8; col ++ )
	//		{		
	//			int tx = blkpos.x + col;
	//			int ty = blkpos.y + row;

	//			if ( ( tx >= m_ParentRegion->m_RegionW ) || 
	//				( ty >= m_ParentRegion->m_RegionH ) ) 
	//				return false;

	//			if ( ( ( LPBYTE )&buidlingData->dwtileLimit )[ row ] & ( 1 << ( property.inverse ? 7 - col : col ) ) )
	//			{
	//				// 放置限制
	//				DWORD tiles = m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ];
	//				tiles |= TILETYPE_LIMIT;
	//				m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] = tiles;
	//			}
	//			if ( ( ( LPBYTE )&buidlingData->dwtileMask )[ row ] & ( 1 << ( property.inverse ? 7 - col : col ) ) )
	//			{
	//				// 阻挡
	//				DWORD tiles = m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] ;
	//				tiles &= 0xfffffffe;
	//				m_ParentRegion->m_pdwTiles[ tx + ( ty * m_ParentRegion->m_RegionW ) ] = tiles;
	//			}
	//		}
	//	}
	//}

	return true;
}
Ejemplo n.º 4
0
int CBuilding::OnCreate( _W64 long pParameter )
{
    //if ( sizeof( CreateParameter ) != size )
    //    return false;

	param = *( CreateParameter * )pParameter;

    if ( param.loadData == NULL )
    {
        const SBuildingConfigData *buidlingData = GetBuildingData( param.index );
        if ( buidlingData == NULL )
            return false;

        memset( &property, 0, sizeof( property ) );

        property.index = param.index;
        property.inverse = param.inverse;
        //property.ownerType = param.ownerType;
        //memcpy( property.owner, param.ownerName, sizeof( property.owner ) );

//         property.curX = m_wCurX = param.x;
//         property.curY = m_wCurY = param.y;

        // 暂时将建筑物设置为停用状态
        property.usingState = 0;
        property.ownerType = param.ownerType;
        property.owner = param.ownerName;

	    if ( !GenerateNewUniqueId( reinterpret_cast< SItemBase& >( property ) ) )
	    {
		    rfalse( 2, 1, "创建建筑唯一ID错误!" );
		    return false;
	    }
    }
    else
    {
        lite::Serialreader slr( ( LPVOID )param.loadData );
        lite::Variant lvt = slr();
        if ( ( lvt.dataType != lite::Variant::VT_POINTER ) || ( lvt.dataSize != sizeof( SaveBlock_fixed ) ) )
            return false;

        const SaveBlock_fixed &block = *( const SaveBlock_fixed* )lvt._pointer;

        const SBuildingConfigData *buidlingData = GetBuildingData( block.index );
        if ( buidlingData == NULL )
            return false;

        memset( &property, 0, sizeof( property ) );

        property.index = block.index;
        reinterpret_cast< QWORD& >( property ) = reinterpret_cast< const QWORD& >( block );
        if ( block.ownerName[10] != 0 )
            return false;
        property.owner = block.ownerName;
        
		//property.inverse = ?
        //property.ownerType = block->ownerType;
        //memcpy( property.owner, block->ownerName, sizeof( property.owner ) );

        if ( slr.curSize() < slr.maxSize() )
        {
            lvt = slr();

            if ( ( lvt.dataType != lite::Variant::VT_RPC_OP ) || ( lvt._rpcop != 0x13579 ) )
                return false;

            // 是否有额外的扩展数据?
            while ( slr.curSize() < slr.maxSize() )
            {
                // 压入所有的扩展数据!
                LPCSTR key = slr();

                // 避免保留一个空的数据!
                if ( slr.curSize() >= slr.maxSize() )
                    return false;

                // 注意,使用深阶拷贝,避免在之后数据失效。。。
                svarMap[ key ].DeepCopy( slr() );
            }
        }
    }

    return true;
}