Exemple #1
0
//执行
void COpScript::Execute(CMoveShape* pShape)
{
#ifdef _RUNSTACKINFO1_
    CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() begin");
#endif
    //  [5/4/2009 chenxianj]
    //CScript *pTempScript =  PopFreeScript("COpScript::Execute");
    //if (pTempScript)
    //{
    //	pTempScript->SetVariableList(m_pParam->pVariableList);
    //	pTempScript->SetUsedItemID(m_pParam->GoodsGuid);
    //	pTempScript->SetSrcShapeEx(m_pParam->pUser);
    //	//  [5/4/2009 chenxianj]
    //	itExpress it = m_Expressions.begin();
    //	for(;it != m_Expressions.end();it++)
    //	{
    //		if(m_pParam->pUser)
    //			pTempScript->SetRegion(dynamic_cast<CRegion*>(m_pParam->pUser->GetFather()));
    //		else
    //			pTempScript->SetRegion(NULL);


    //		(*it)->Execute(pTempScript,pShape);

    //	}
    //	//  [5/4/2009 chenxianj]
    //	PushFreeScript(pTempScript);
    //}
    Script::RunEnv env( m_pParam->pUser, pShape, static_cast<CRegion*>( m_pParam->pUser->GetFather() ),
                        m_pParam->pVariableList );
    VariableList *varList = m_pParam->pVariableList;
    if( !varList->AddVar( "$ParamA", (double)(DWORD)m_pParam->pUser ) )
    {
        varList->SetVarValue( "$ParamA", (double)(DWORD) m_pParam->pUser );
    }
    if( !varList->AddVar( "$ParamB", (double)(DWORD)pShape ) )
    {
        varList->SetVarValue( "$ParamB", (double)(DWORD) pShape );
    }

    Script *script = GetInst( ScriptSys ).NewScript( env );
    for( itExpress it = m_Expressions.begin(); it != m_Expressions.end(); ++ it )
    {
        CExpressions *exp = *it;
        int ret = exp->Execute( script, pShape );
        if( !script->CanDelete( ret ) )
        {
            // yield script, cannot run.
            assert( "Yield script" && 0 );
        }
    }
    GetInst( ScriptSys ).DelScript( script );

#ifdef _RUNSTACKINFO1_
    CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() end");
#endif
}