Example #1
0
uint32 KmScene2732::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4804:
		GotoState(&Klaymen::stPeekInside);
		break;
	case 0x483C:
		GotoState(&Klaymen::stPeekInsideReturn);
		break;
	}
	return 0;
}
Example #2
0
uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam &param) {
	uint32 messageResult = 0;
	switch (messageNum) {
	case NM_ANIMATION_UPDATE:
		_isSittingInTeleporter = param.asInteger() != 0;
		messageResult = 1;
		break;
	case 0x4001:
	case 0x4800:
		startWalkToX(param.asPoint().x, false);
		break;
	case NM_KLAYMEN_STAND_IDLE:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stSitIdleTeleporter);
		else
			GotoState(&Klaymen::stTryStandIdle);
		break;
	case 0x4804:
		if (param.asInteger() != 0) {
			_destX = param.asInteger();
			GotoState(&Klaymen::stWalkingFirst);
		} else
			GotoState(&Klaymen::stPeekWall);
		break;
	case 0x4817:
		setDoDeltaX(param.asInteger());
		gotoNextStateExt();
		break;
	case NM_KLAYMEN_TURN_TO_USE:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stTurnToUseInTeleporter);
		break;
	case NM_KLAYMEN_RETURN_FROM_USE:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stReturnFromUseInTeleporter);
		break;
	case 0x4834:
		GotoState(&Klaymen::stStepOver);
		break;
	case 0x4835:
		sendMessage(_parentScene, 0x2000, 1);
		_isSittingInTeleporter = true;
		GotoState(&Klaymen::stSitInTeleporter);
		break;
	case 0x4836:
		sendMessage(_parentScene, 0x2000, 0);
		_isSittingInTeleporter = false;
		GotoState(&Klaymen::stGetUpFromTeleporter);
		break;
	case 0x483D:
		teleporterAppear(0x2C2A4A1C);
		break;
	case 0x483E:
		teleporterDisappear(0x3C2E4245);
		break;
	}
	return messageResult;
}
uint32 KmScene1303::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4804:
		GotoState(&Klaymen::stPeekWall1);
		break;
	case 0x483B:
		GotoState(&Klaymen::stPeekWallReturn);
		break;
	case 0x483C:
		GotoState(&Klaymen::stPeekWall2);
		break;
	}
	return 0;
}
void CPolicyImporter::StateImportPeerCertL()
    {
    LOG_("CPolicyImporter::StateImportOtherCaCertL() entry");
    SetCurrState(EStateImportPeerCert);

    iCurrOtherCaCertIndex++;

    if (iCurrOtherCaCertIndex == iCurrOtherCaCertList->Count())
        {
        GotoState(EStateImportUserPrivKey);
        LOG_("CPolicyImporter::StateImportOtherCaCertL() exit (all intermediate CAs imported)");
        return;
        }

    delete iCertFileData;
    iCertFileData = NULL;
    iCertFileData = iFileUtil.LoadFileDataL(iCurrOtherCaCertList->At(iCurrOtherCaCertIndex));
    CIkeData* data = iCurrIkeDataArray->At(iCurrIkeDataIndex);
    TPkiServiceStoreType storeType = GetStoreTypeL(data);
    iPkiService.SetStoreType(storeType);

    iPkiService.StoreCertificateL(EPKICACertificate, KDefaultKeySize, EPKIRSA, *iCertFileData,
                                  &iPkiOpContext, iStatus);

    SetNextState(EStateAfterImportPeerCert);
    SetActive();
    LOG_("CPolicyImporter::StateImportOtherCACertL() exit");
    }
void CPolicyImporter::StateImportCaCertL()
    {
    LOG_("CPolicyImporter::StateImportCaCertL() entry");
    SetCurrState(EStateImportCaCert);

    iCurrCaCertIndex++;

    if (iCurrCaCertIndex == iCurrCaCertList->Count())
        {
        GotoState(EStateImportPeerCert);
        LOG_("CPolicyImporter::StateImportCaCertL() exit (all CA certs imported)");
        return;
        }

    delete iCertFileData;
    iCertFileData = NULL;
    iCertFileData = iFileUtil.LoadFileDataL(iCurrCaCertList->At(iCurrCaCertIndex));

    iPkiService.StoreCertificateL(EPKICACertificate, KDefaultKeySize, EPKIRSA, *iCertFileData,
                                  &iPkiOpContext, iStatus);

    SetNextState(EStateAfterImportCaCert);
    SetActive();
    LOG_("CPolicyImporter::StateImportCaCertL() exit");
    }
void CPolicyImporter::StateImportUserPrivKeyL()
    {
    LOG_("CPolicyImporter::StateImportUserPrivKeyL() entry");
    SetCurrState(EStateImportUserPrivKey);

    iCurrUserPrivKeyIndex++;

    if (iCurrUserPrivKeyIndex == iCurrUserPrivKeyList->Count())
        {
        GotoState(EStateImportPinAndPol);
        LOG_("CPolicyImporter::StateImportUserPrivKeyL() exit (all keys imported)");
        return;
        }

    delete iKeyFileData;
    iKeyFileData = NULL;
    iKeyFileData = iFileUtil.LoadFileDataL(iCurrUserPrivKeyList->At(iCurrUserPrivKeyIndex));
    CIkeData* data = iCurrIkeDataArray->At(iCurrIkeDataIndex);
    TPkiServiceStoreType storeType = GetStoreTypeL(data);
    iPkiService.SetStoreType(storeType);

    iPkiService.StoreKeypair(iCurrKeyId, *iKeyFileData, iStatus);

    SetNextState(EStateAfterImportUserPrivKey);
    SetActive();
    LOG_("CPolicyImporter::StateImportUserPrivKeyL() exit");
    }
void CPolicyImporter::DoImportPolicyL(const TDesC& aDir)
    {
    LOG_("-> CPolicyImporter::DoImportPolicyL()");
    iImportDir.Copy(aDir);
    iCurrPolicyIdIndex = -1;

    BuildPolicyIdListL();

    if (iPolicyIdList->Count() == 0)
        {
        ImportComplete(KErrNone);
        return;
        }

    if (iImportSinglePolicy && iPolicyIdList->Count() != 1)
        {
        // We're supposed to import a single policy
        // only but the import directory contains
        // multiple policies...
        ImportComplete(KErrArgument);
        return;
        }

    // All is well, so begin import
    GotoState(EStateBeginPolicyImport);
    LOG_("<- CPolicyImporter::DoImportPolicyL()");
    }
void CPolicyImporter::StateBeginPolicyImportL()
    {
    SetCurrState(EStateBeginPolicyImport);

    iCurrPolicyIdIndex++;

    if (iCurrPolicyIdIndex == iPolicyIdList->Count())
        {
        ImportComplete(KErrNone);
        return;
        }

    iCurrPolicyId.Copy(iPolicyIdList->At(iCurrPolicyIdIndex));

    ParseIkeDataL();

    BuildCaCertListL();
    iCurrCaCertIndex = -1;

    BuildPeerCertListL();
    iCurrPeerCertIndex = -1;

    BuildUserPrivKeyAndUserCertListL();
    iCurrUserPrivKeyIndex = -1;
    iCurrUserCertIndex = -1;

    BuildOtherCaCertListL();
    iCurrOtherCaCertIndex=-1;
    GotoState(EStateImportCaCert);
    }
void UAmethystGameInstance::StartGameInstance()
{
#if PLATFORM_PS4 == 0
	TCHAR Parm[4096] = TEXT("");

	const TCHAR* Cmd = FCommandLine::Get();

	// Catch the case where we want to override the map name on startup (used for connecting to other MP instances)
	if (FParse::Token(Cmd, Parm, ARRAY_COUNT(Parm), 0) && Parm[0] != '-')
	{
		// if we're 'overriding' with the default map anyway, don't set a bogus 'playing' state.
		if (!MainMenuMap.Contains(Parm))
		{
			FURL DefaultURL;
			DefaultURL.LoadURLConfig(TEXT("DefaultPlayer"), GGameIni);

			FURL URL(&DefaultURL, Parm, TRAVEL_Partial);

			if (URL.Valid)
			{
				UEngine* const Engine = GetEngine();

				FString Error;

				const EBrowseReturnVal::Type BrowseRet = Engine->Browse(*WorldContext, URL, Error);

				if (BrowseRet == EBrowseReturnVal::Success)
				{
					// Success, we loaded the map, go directly to playing state
					GotoState(AmethystGameInstanceState::Playing);
					return;
				}
				else if (BrowseRet == EBrowseReturnVal::Pending)
				{
					// Assume network connection
					LoadFrontEndMap(MainMenuMap);
					ShowLoadingScreen();
					GotoState(AmethystGameInstanceState::Playing);
					return;
				}
			}
		}
	}
#endif

	GotoInitialState();
}
void CPolicyImporter::StateAttachCertificateL()
    {
    LOG_("CPolicyImporter::StateAttachCertificateL() entry");
    SetCurrState(EStateAttachCertificate);

    iCurrIkeDataIndex++;

    if (iCurrIkeDataIndex == iCurrIkeDataArray->Count())
        {
        // Import the next private key, if present
        GotoState(EStateImportUserPrivKey);
        return;
        }

    CIkeData* ikeData = iCurrIkeDataArray->At(iCurrIkeDataIndex);
    HBufC* fileName(NULL);
    TPkiServiceStoreType storeType = GetStoreTypeL(ikeData);
    iPkiService.SetStoreType(storeType);

    fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iPrivKey.iData).AllocLC();

    if (fileName->CompareF(iCurrUserPrivKeyList->At(iCurrUserPrivKeyIndex)) == 0)
        {
        CleanupStack::PopAndDestroy(fileName);
        fileName = NULL;

        fileName = iFileUtil.MakeFileName(iImportDir, ikeData->iOwnCert.iData).AllocLC();

        delete iCertFileData;
        iCertFileData = NULL;
        iCertFileData = iFileUtil.LoadFileDataL(*fileName);

        iPkiService.AttachCertificateL(iCurrKeyId, KDefaultKeySize, EPKIRSA, *iCertFileData,
                                       &iPkiOpContext, iStatus);

        SetNextState(EStateAfterAttachCertificate);
        SetActive();
        }
    else
        {
        // Attach the next certificate, if present
        GotoState(EStateAttachCertificate);
        }
    CleanupStack::PopAndDestroy(fileName); // fileName
    LOG_("CPolicyImporter::StateAttachCertificateL() exit");
    }
uint32 KmScene1305::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4001:
	case 0x4800:
		startWalkToX(param.asPoint().x, false);
		break;
	case 0x4004:
		GotoState(&Klaymen::stTryStandIdle);
		break;
	case 0x4804:
		GotoState(&KmScene1305::stCrashDown);
		break;
	case 0x4817:
		setDoDeltaX(param.asInteger());
		gotoNextStateExt();
		break;
	}
	return 0;
}
bool UAmethystGameInstance::HandleOpenCommand(const TCHAR* Cmd, FOutputDevice& Ar, UWorld* InWorld)
{
	bool const bOpenSuccessful = Super::HandleOpenCommand(Cmd, Ar, InWorld);
	if (bOpenSuccessful)
	{
		GotoState(AmethystGameInstanceState::Playing);
	}

	return bOpenSuccessful;
}
void CPolicyImporter::StateImportPinAndPolL()
    {
    LOG_("-> CPolicyImporter::StateImportPinAndPolL()");
    SetCurrState(EStateImportPinAndPol);

    HBufC* pinFile = iFileUtil.MakeFileNameLC(iImportDir, iCurrPolicyId, KPinFileExt);
    HBufC* polFile = iFileUtil.MakeFileNameLC(iImportDir, iCurrPolicyId, KPolFileExt);

    if (!iFileUtil.FileExists(*pinFile))
        {
        LOG_("<- CPolicyImporter::StateImportPinAndPolL() LEAVE: KVpnErrNoPolicyInfoFile");
        User::Leave(KVpnErrNoPolicyInfoFile);
        }
    else if (!iFileUtil.FileExists(*polFile))
        {
        LOG_("<- CPolicyImporter::StateImportPinAndPolL() LEAVE: KVpnErrNoPolicyFile");
        User::Leave(KVpnErrNoPolicyFile);
        }
    else
        {
        PatchPolicyCaCertInfoL(*polFile);

        iPolicyStore.ImportPolicyL(*pinFile, *polFile, iNewPolicyId);

        //iImportSinglePolicy is used when policy is installed via
        //OMA DM or ACU. If the policy is installed from .vpn file
        //the iImportSinglePolicy is not used.
        //The VPN destination is only created in .vpn case.
        if (iImportSinglePolicy)
            {
            GotoState(EStateEndPolicyImport);
            }
        else
            {
            GotoState(EStateCreateVpnDestination);
            }
        }
    CleanupStack::PopAndDestroy(2); // polfile, pinfile
    LOG_("<- CPolicyImporter::StateImportPinAndPolL()");
    }
Example #14
0
void StateMachine::update(int state, AnimationModuleInterface * _animation, int channel){

	if(_prevChessState!=state){
		GotoState(INTERACTIVE,true);
		_currentAnimation=(char *)GetNextAnimation().pszGetPointer();
		_animation->PlayAnimation((char *)_currentAnimation.pszGetPointer() ,channel);
	}
	else {
	setTimeOut(getTimeOut() + 1);
	if (getState() == INTERACTIVE){
		if (getTimeOut() > 300)
			GotoState(IDLE_LOOK_FRONT, true);
	}

	else if ((getState() == IDLE_LOOK_FRONT) || 
          (getState() == IDLE_LOOK_LEFT) || 
          (getState() == IDLE_LOOK_RIGHT)) 
      if (getTimeOut() > 300) 
		  GotoState(SLEEPING_BY_NODDING, true);
	}
	_prevChessState=state;
}
void UARActionStateComponent::InitializeComponent()
{
	//hack there need to be another state.
	if (CurrentState == NULL)
	{
		GotoState(ActiveState);
	}
	if (ActionStateClass)
	{
		StartActionState = ConstructObject<UARActionStateCasting>(ActionStateClass, this);
	}
	checkSlow(CurrentState != NULL);
}
void CPolicyImporter::StateAfterImportPeerCertL()
    {
    SetCurrState(EStateAfterImportPeerCert);

    iPkiService.Finalize(iPkiOpContext);

    if (iStatus != KErrNone)
        {
        User::Leave(iStatus.Int());
        }

    // Handle the next certificate, if present
    GotoState(EStateImportPeerCert);
    }
Example #17
0
bool CScriptProxy::GotoState( const char* sStateName )
{
	int nStateId = m_pScript->GetStateId( sStateName );
	if (nStateId >= 0)
	{
		GotoState( nStateId );
	}
	else
	{
		EntityWarning( "GotoState called with unknown state %s, in entity %s",sStateName,m_pEntity->GetEntityTextDescription());
		return false;
	}
	return true;
}
Example #18
0
void AGWWeaponRanged::BeginReload()
{
	if (Role < ROLE_Authority)
	{
		OnRep_ReloadBeign();
		ServerBeginReload();
	}
	else
	{
		ReloadBeginCount++;
		GotoState(ReloadState);
		if (GetNetMode() == ENetMode::NM_Standalone)
			OnRep_ReloadBeign();
	}
}
void UAmethystGameInstance::ShowMessageThenGotoState(const FText& Message, const FText& OKButtonString, const FText& CancelButtonString, const FName& NewState, const bool OverrideExisting, TWeakObjectPtr< ULocalPlayer > PlayerOwner)
{
	/* TO DO: Add logs to each stage */
	const bool bAtWelcomeScreen = PendingState == AmethystGameInstanceState::WelcomeScreen || CurrentState == AmethystGameInstanceState::WelcomeScreen;

	// Never override the welcome screen
	if (bAtWelcomeScreen)
	{
		return;
	}

	const bool bAlreadyAtMessageMenu = PendingState == AmethystGameInstanceState::MessageMenu || CurrentState == AmethystGameInstanceState::MessageMenu;
	const bool bAlreadyAtDestState = PendingState == NewState || CurrentState == NewState;

	// If we are already going to the message menu, don't override unless asked to
	if (bAlreadyAtMessageMenu && PendingMessage.NextState == NewState && !OverrideExisting)
	{
		return;
	}

	// If we are already going to the message menu, and the next dest is welcome screen, don't override
	if (bAlreadyAtMessageMenu && PendingMessage.NextState == AmethystGameInstanceState::WelcomeScreen)
	{
		return;
	}

	// If we are already at the dest state, don't override unless asked
	if (bAlreadyAtDestState && !OverrideExisting)
	{
		return;
	}

	PendingMessage.DisplayString = Message;
	PendingMessage.OKButtonString = OKButtonString;
	PendingMessage.CancelButtonString = CancelButtonString;
	PendingMessage.NextState = NewState;
	PendingMessage.PlayerOwner = PlayerOwner;

	if (CurrentState == AmethystGameInstanceState::MessageMenu)
	{
		EndMessageMenuState();
		BeginMessageMenuState();
	}
	else
	{
		GotoState(AmethystGameInstanceState::MessageMenu);
	}
}
void CPolicyImporter::StateAfterImportUserPrivKeyL()
    {
    SetCurrState(EStateAfterImportUserPrivKey);

    if (iStatus == KErrArgument || iStatus == KErrNotSupported)
        {
        User::Leave(KVpnErrInvalidUserPrivKeyFile);
        }
    else if (iStatus != KErrNone)
        {
        User::Leave(iStatus.Int());
        }

    // Attach user certificates to the imported private key
    iCurrIkeDataIndex = -1;
    GotoState(EStateAttachCertificate);
    }
void CPolicyImporter::StateAfterAttachCertificateL()
    {
    SetCurrState(EStateAfterAttachCertificate);

    iPkiService.Finalize(iPkiOpContext);

    if (iStatus == KErrArgument)
        {
        User::Leave(KVpnErrInvalidUserCertFile);
        }
    else if (iStatus != KErrNone)
        {
        User::Leave(iStatus.Int());
        }

    // Attach the next certificate, if present
    GotoState(EStateAttachCertificate);
    }
void CPolicyImporter::StateCreateVpnDestinationL()
    {
    LOG_("-> CPolicyImporter::StateCreateVpnDestinationL()");
    SetCurrState(EStateCreateVpnDestination);

        //Gets the IAP name from policy name
    TVpnPolicyInfo* policyInfo = new (ELeave) TVpnPolicyInfo;
    CleanupDeletePushL(policyInfo);

    User::LeaveIfError(iPolicyStore.GetPolicyInfo(*iNewPolicyId, *policyInfo));

    CmManagerUtils::CreateVPNConnectionMethodToIntranetL(*policyInfo,
                                                         *(iVpnApiServant.iEventLogger));

    CleanupStack::PopAndDestroy(); //policyInfo
    GotoState(EStateEndPolicyImport);

    LOG_("<- CPolicyImporter::StateCreateVpnDestinationL()");
    }
void CPolicyImporter::StateEndPolicyImportL()
    {
    LOG_("-> CPolicyImporter::StateEndPolicyImportL()");

    STACK_LEFT;

    SetCurrState(EStateEndPolicyImport);

    // Delete the files that were just imported from the import/install directory

    HBufC* fileFilter = iFileUtil.MakeFileNameLC(iImportDir, iCurrPolicyId, KAllFilesPat);
    iFileUtil.DeleteFilesL(*fileFilter);

    CleanupStack::PopAndDestroy(); // fileFilter

    LOG_EVENT_2B(R_VPN_MSG_INSTALLED_POLICY_FILE, iNewPolicyId, NULL, 0, iImportSinglePolicy);

    GotoState(EStateBeginPolicyImport);
    LOG_("<- CPolicyImporter::StateEndPolicyImportL()");
    }
uint32 KmScene1304::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4001:
	case 0x4800:
		startWalkToX(param.asPoint().x, false);
		break;
	case 0x4004:
		GotoState(&Klaymen::stTryStandIdle);
		break;
	case 0x4812:
		if (param.asInteger() == 2)
			GotoState(&Klaymen::stPickUpNeedle);
		else if (param.asInteger() == 1)
			GotoState(&Klaymen::stPickUpTube);
		else
			GotoState(&Klaymen::stPickUpGeneric);
		break;
	case 0x4817:
		setDoDeltaX(param.asInteger());
		gotoNextStateExt();
		break;
	case 0x481B:
		if (param.asPoint().y != 0)
			startWalkToXDistance(param.asPoint().y, param.asPoint().x);
		else
			startWalkToAttachedSpriteXDistance(param.asPoint().x);
		break;
	case 0x481F:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stTurnAwayFromUse);
		else if (param.asInteger() == 0)
			GotoState(&Klaymen::stTurnToUseHalf);
		else
			GotoState(&Klaymen::stWonderAbout);
		break;
	case 0x483F:
		startSpecialWalkRight(param.asInteger());
		break;
	case 0x4840:
		startSpecialWalkLeft(param.asInteger());
		break;
	}
	return 0;
}
void CPolicyImporter::StateAfterImportCaCertL()
    {
    SetCurrState(EStateAfterImportCaCert);

    iPkiService.Finalize(iPkiOpContext);


    if (iStatus == KErrArgument)
        {
        User::Leave(KVpnErrInvalidCaCertFile);
        }
    else if (iStatus != KErrNone)
        {
        User::Leave(iStatus.Int());
        }

    // Set VPN trusted
    CX509Certificate* tempCert = CX509Certificate::NewLC(*iCertFileData);
    RArray<TUid> appArray;
    CleanupClosePushL(appArray);
    appArray.AppendL(TUid::Uid(KUidVpnManager));

    const TPtrC8* serialNumber = tempCert->DataElementEncoding(
        CX509Certificate::ESerialNumber);
    const TPtrC8* issuername = tempCert->DataElementEncoding(
        CX509Certificate::EIssuerName);

    iPkiService.SetApplicabilityL(
        *issuername,
        *serialNumber,
        appArray);

    CleanupStack::PopAndDestroy(2); // appArray, tempCert

    // Handle the next certificate, if present
    GotoState(EStateImportCaCert);
    }
Example #26
0
void CMathParser::Reduce(WORD  Reduction)//{ Completes a reduction }
{
	TokenRec Token1, Token2;

	switch(Reduction)
	{
	case 1 : 
	  {
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token1.Value + Token2.Value;
	  break;
	  }//  end;
	case 2 : {//begin
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token2.Value - Token1.Value;
	  break;
	}//    end;
	case 4 :// begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token1.Value * Token2.Value;
	  break;
	}//    end;
	case 5 : //begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (fabs(Token1.Value) < 0.000001 )
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = Token2.Value / Token1.Value;
	  break;
	}//    end;

	//{ MOD operator }
	case 100 : //begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (fabs(Token1.Value) < 0.000001)
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = Round(Token2.Value) % Round(Token1.Value);
	  break;
	}//end;

	case 7 :
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (Token2.Value < 0.0)
		ErrorCode = MP_ErrMath;
	  else if ((Token1.Value * log(Token2.Value) < -MP_ExpLimit) ||
			  (Token1.Value * log(Token2.Value) > MP_ExpLimit)) 
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = exp(Token1.Value * log(Token2.Value));
	  break;
	}//end;
	case 9 : 
	{//begin
	  Pop(Token1);
	  Pop(Token2);
	  CurrToken.Value = -Token1.Value;
	  break;
	}//end;
	case 11 : break;//raise Exception.Create('Invalid reduction'); break;
	case 13 : break;//raise Exception.Create('Invalid reduction'); break;
	case 14 : 
	{//begin
	  Pop(Token1);
	  Pop(CurrToken);
	  Pop(Token1);
	  break;
	}//end;

	case 16 : 
	{//begin
		Pop(Token1);
		Pop(CurrToken);
		Pop(Token1);
		Pop(Token1);
		if( Token1.FuncName == "ABS")
		CurrToken.Value = fabs(CurrToken.Value);
		else if (Token1.FuncName == "ATAN")
		CurrToken.Value = atan(CurrToken.Value);
		else if (Token1.FuncName == "COS")
		{//      begin
		 if ((CurrToken.Value < -9E18) || (CurrToken.Value > 9E18))
			ErrorCode = MP_ErrMath;
		 else
			CurrToken.Value = cos(CurrToken.Value);
		}//end {...if Token1.FuncName = 'SIN' }
		else if (Token1.FuncName == "EXP")
		{//      begin
		if ((CurrToken.Value < -MP_ExpLimit) || (CurrToken.Value > MP_ExpLimit))// then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = exp(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "LN")// then
		{//      begin
		if (CurrToken.Value <= 0)
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = log(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "ROUND")
		{//     begin
		if ((CurrToken.Value < -1E9) || (CurrToken.Value > 1E9))
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = Round(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "SIN")
		{//      begin
		 if( (CurrToken.Value < -9E18) || (CurrToken.Value > 9E18))
			ErrorCode = MP_ErrMath;
		 else
			CurrToken.Value = sin(CurrToken.Value);
		 }//end {...if Token1.FuncName = 'SIN' }
		else if (Token1.FuncName == "SQRT")
		{//begin
		if( CurrToken.Value < 0 )//then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = sqrt(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "SQR")
		{//begin
		if ((CurrToken.Value < -MP_SQRLIMIT) || (CurrToken.Value > MP_SQRLIMIT))// then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = sqrt(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "TRUNC")
		{//begin
		if ((CurrToken.Value < -1E9) || (CurrToken.Value > 1E9))
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = (int)(CurrToken.Value);//Trunc
		}
		else if(Token1.FuncName == "NOT")//end;//EXPAND
		{
		if (CurrToken.Value < 0.001 && CurrToken.Value > -0.001)
			CurrToken.Value = 1.0;
		else 
			CurrToken.Value = 0.0;
		}
		else if(Token1.FuncName == "BOOL")//end;//EXPAND
		{
		if (CurrToken.Value < 0.001 && CurrToken.Value > -0.001)
			CurrToken.Value = 0.0;
		else 
			CurrToken.Value = 1.0;
		}
		else if(Token1.FuncName == "SGN")//end;//EXPAND
		{
		if (CurrToken.Value > 0.0)
			CurrToken.Value = 1.0;
		else 
			CurrToken.Value = 0;
		}
		break;
	}//end;
	case 3:
	case 6:
	case 8:
	case 10:
	case 12:
	case 15 : Pop(CurrToken); break;
	}//  end; { case }

	CurrToken.State = GotoState(Reduction);
	Push(CurrToken);
}
void UAmethystGameInstance::GotoInitialState()
{
	GotoState(GetInitialState());
}
void UAmethystGameInstance::OnPostDemoPlay()
{
	GotoState(AmethystGameInstanceState::Playing);
}
uint32 KmScene1308::xHandleMessage(int messageNum, const MessageParam &param) {
	switch (messageNum) {
	case 0x4001:
	case 0x4800:
		startWalkToX(param.asPoint().x, false);
		break;
	case 0x4004:
		GotoState(&Klaymen::stTryStandIdle);
		break;
	case 0x480A:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stMoveObjectSkipTurnFaceObject);
		else
			GotoState(&Klaymen::stMoveObjectFaceObject);
		break;
	case 0x480D:
		GotoState(&Klaymen::stUseLever);
		break;
	case 0x4812:
		if (param.asInteger() == 2)
			GotoState(&Klaymen::stPickUpNeedle);
		else if (param.asInteger() == 1)
			GotoState(&Klaymen::stPickUpTube);
		else
			GotoState(&Klaymen::stPickUpGeneric);
		break;
	case 0x4817:
		setDoDeltaX(param.asInteger());
		gotoNextStateExt();
		break;
	case 0x481A:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stInsertKey);
		else
			GotoState(&Klaymen::stInsertDisk);
		break;
	case 0x481B:
		if (param.asPoint().y != 0)
			startWalkToXDistance(param.asPoint().y, param.asPoint().x);
		else
			startWalkToAttachedSpriteXDistance(param.asPoint().x);
		break;
	case 0x481D:
		GotoState(&Klaymen::stTurnToUse);
		break;
	case 0x481E:
		GotoState(&Klaymen::stReturnFromUse);
		break;
	case 0x4827:
		GotoState(&Klaymen::stReleaseLever);
		break;
	case 0x4834:
		GotoState(&Klaymen::stStepOver);
		break;
	case 0x483F:
		startSpecialWalkRight(param.asInteger());
		break;
	case 0x4840:
		startSpecialWalkLeft(param.asInteger());
		break;
	}
	return 0;
}
uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam &param) {
	uint32 messageResult = 0;
	switch (messageNum) {
	case 0x2000:
		_isSittingInTeleporter = param.asInteger() != 0;
		messageResult = 1;
		break;
	case 0x4001:
	case 0x4800:
		startWalkToX(param.asPoint().x, false);
		break;
	case 0x4004:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stSitIdleTeleporter);
		else
			GotoState(&Klaymen::stTryStandIdle);
		break;
	case 0x4812:
		if (param.asInteger() == 2)
			GotoState(&Klaymen::stPickUpNeedle);
		else if (param.asInteger() == 1)
			GotoState(&Klaymen::stPickUpTube);
		else
			GotoState(&Klaymen::stPickUpGeneric);
		break;
	case 0x4816:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stPressButton);
		else if (param.asInteger() == 2)
			GotoState(&Klaymen::stPressFloorButton);
		else
			GotoState(&Klaymen::stPressButtonSide);
		break;
	case 0x4817:
		setDoDeltaX(param.asInteger());
		gotoNextStateExt();
		break;
	case 0x481A:
		GotoState(&Klaymen::stInsertDisk);
		break;
	case 0x481B:
		if (param.asPoint().y != 0)
			startWalkToXDistance(param.asPoint().y, param.asPoint().x);
		else
			startWalkToAttachedSpriteXDistance(param.asPoint().x);
		break;
	case 0x481D:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stTurnToUseInTeleporter);
		else
			GotoState(&Klaymen::stTurnToUse);
		break;
	case 0x481E:
		if (_isSittingInTeleporter)
			GotoState(&Klaymen::stReturnFromUseInTeleporter);
		else
			GotoState(&Klaymen::stReturnFromUse);
		break;
	case 0x481F:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stWonderAboutAfter);
		else if (param.asInteger() == 0)
			GotoState(&Klaymen::stWonderAboutHalf);
		else if (param.asInteger() == 4)
			GotoState(&Klaymen::stTurnAwayFromUse);
		else if (param.asInteger() == 3)
			GotoState(&Klaymen::stTurnToUseHalf);
		else
			GotoState(&Klaymen::stWonderAbout);
		break;
	case 0x482D:
		setDoDeltaX(_x > (int16)param.asInteger() ? 1 : 0);
		gotoNextStateExt();
		break;
	case 0x482E:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stWalkToFrontNoStep);
		else
			GotoState(&Klaymen::stWalkToFront);
		break;
	case 0x482F:
		if (param.asInteger() == 1)
			GotoState(&Klaymen::stTurnToFront);
		else
			GotoState(&Klaymen::stTurnToBack);
		break;
	case 0x4834:
		GotoState(&Klaymen::stStepOver);
		break;
	case 0x4835:
		sendMessage(_parentScene, 0x2000, 1);
		_isSittingInTeleporter = true;
		GotoState(&Klaymen::stSitInTeleporter);
		break;
	case 0x4836:
		sendMessage(_parentScene, 0x2000, 0);
		_isSittingInTeleporter = false;
		GotoState(&Klaymen::stGetUpFromTeleporter);
		break;
	case 0x483D:
		teleporterAppear(0xEE084A04);
		break;
	case 0x483E:
		teleporterDisappear(0xB86A4274);
		break;
	case 0x483F:
		startSpecialWalkRight(param.asInteger());
		break;
	case 0x4840:
		startSpecialWalkLeft(param.asInteger());
		break;
	}
	return messageResult;
}