void Creature::addAttack(string& prt,
	list<Condition>::iterator s1,
	list<Condition>::iterator e1,
	list<Action>::iterator s2,
	list<Action>::iterator e2)
{
	Trigger trig = Trigger("attack",prt,true);
	list<Condition>::iterator i;
	for(i=s1;i!=e1;++i){
		trig.addCondition(*i);
	}
	list<Action>::iterator t;
	for(t=s2;t!=e2;++t){
		trig.addAction(*t);
	}
	addTrigger(trig);
	defaultEvents = tri.begin();
}
Exemple #2
0
Fichier : event.c Projet : etix/vlc
static void VarListDel( input_thread_t *p_input,
                        const char *psz_variable, int i_event,
                        int i_value )
{
    vlc_value_t val;

    if( i_value >= 0 )
    {
        val.i_int = i_value;
        var_Change( p_input, psz_variable, VLC_VAR_DELCHOICE, &val, NULL );
    }
    else
    {
        var_Change( p_input, psz_variable, VLC_VAR_CLEARCHOICES, &val, NULL );
    }

    Trigger( p_input, i_event );
}
Exemple #3
0
void CDiskObject::SetSystemErrorMessage( int error,const CString& elements)
/* ============================================================
	Function :		CDiskObject::SetSystemErrorMessage
	Description :	Sets the error message string with the 
					system error message as gotten from 
					"GetLastError". "elements" will be appended.
	Access :		Private

	Return :		void
	Parameters :	int error			-	error number from 
											"GetLastError"
					CString elements	-	files or directories 
											to add to the message
					
	Usage :			Call to set the error message.

   ============================================================*/
{
	LPVOID msgBuff;

	// Format error message from system
	::FormatMessage( 
		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		error,
		MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
		( LPTSTR ) &msgBuff,
		0,
		NULL
	);

	// Create the error string
	m_errorMessage = CString( ( LPTSTR ) msgBuff );
	m_errorMessage.TrimLeft( );
	m_errorMessage.TrimRight( );

	if( elements.GetLength( ) )
		m_errorMessage += _TCHAR( ' ' ) + elements;

	Trigger ( m_errorMessage );

	// Free the buffer.
	LocalFree( msgBuff );
}
void MatlabNet::Process(){
	// check to see if connection has been established
	if(validSession && mInitialized){
		divisorCount++;
		if(divisorCount == SAMPLE_RATE_DIVISOR){
			divisorCount = 0;
			// copy values into buffer
			for(int i=0; i < MATLAB_NET_NUM_CH; i++){
				mpValBuf[i] = *mpValPtrArr[i];
			}
			
			// put buffer into thread communication fifo
			mpFifo->Put(mpValBuf);
			
			// trigger the server to read buffer and send data
			Trigger(0);
		}
	}
}
void BattleSquad::setUnitNum(int val)
{
	DataLibrary* datalib = DataLibrary::getSingletonPtr();

	datalib->setData(getPath() + "/UnitNum", val);

	LuaTempContext* luatempcontext = new LuaTempContext();
	luatempcontext->strMap["squadid"] = getSquadId();
	Trigger("UnitNumChange", luatempcontext);
	delete luatempcontext;

	if(getUnitNum() <= 0)
	{
		LuaTempContext* luatempcontext = new LuaTempContext();
		luatempcontext->strMap["squadid"] = getSquadId();
		MapDataManager::getSingleton().Trigger("SquadAnnihilated", luatempcontext);
		delete luatempcontext;
	}
}
void SinglePlayerPauseState::KeyDown(int Key) {
	switch(Key)
	{
		case SDLK_ESCAPE:
			engine->SetState("SinglePlayerGame");
			break;
		
		case SDLK_RETURN:
			Trigger();
			break;
		
		case SDLK_LEFT:
		case SDLK_UP:
			if(activeButton > 0)
				activeButton--;
			break;
		
		case SDLK_RIGHT:
		case SDLK_DOWN:
			if(activeButton < 2)
				activeButton++;
			break;
		
		case SDLK_w:
			worldState->playerEnt.toggleMoveFlag(PLAYER_FORWARD);
			break;
		
		case SDLK_s:
			worldState->playerEnt.toggleMoveFlag(PLAYER_BACKWARD);
			break;
		
		case SDLK_a:
			worldState->playerEnt.toggleMoveFlag(PLAYER_LEFT);
			break;
		
		case SDLK_d:
			worldState->playerEnt.toggleMoveFlag(PLAYER_RIGHT);
			break;
		
		default: break;
	}
};
bool BattleSquad::tryMove(int srcx, int srcy, int tgx, int tgy, float &apleft, unsigned int &eventflag)
{
	MapDataManager* mapdatamanager = MapDataManager::getSingletonPtr();
	if(mapdatamanager->getPassable(tgx, tgy, getFaction()))
	{
		float mapapcost = 0.0f;
		if(getHorseId() != "none")
			mapapcost = mapdatamanager->getCavApCost(tgx, tgy, getFaction());
		else
			mapapcost = mapdatamanager->getInfApCost(tgx, tgy, getFaction());

		LuaTempContext* luatempcontext = new LuaTempContext();
		luatempcontext->strMap["squadid"] = getSquadId();
		luatempcontext->intMap["srcx"] = srcx;
		luatempcontext->intMap["srcy"] = srcy;
		luatempcontext->intMap["tgtx"] = tgx;
		luatempcontext->intMap["tgty"] = tgy;
		luatempcontext->floatMap["apcost"] = mapapcost;
		Trigger("TryMove", luatempcontext);
		mapdatamanager->Trigger("TryMove", luatempcontext);
		mapapcost = luatempcontext->floatMap["apcost"];
		delete luatempcontext;

		if(mapapcost <= apleft)
		{
			apleft -= mapapcost;
			if(mapapcost <= 2)
			{
				eventflag |= MOVEEVENT_CHARGE;
				int curdir = GetDirection(srcx, srcy, tgx, tgy);
				eventflag |= SetChargeDir(curdir);
			}
			else
			{
				eventflag &= ~MOVEEVENT_CHARGE;
			}
			return true;
		}
	}
	eventflag |= MOVEEVENT_WRONG;
	return false;
}
Exemple #8
0
BOOL CDiskObject::EmptyDirectory( const CString& directory )
/* ============================================================
	Function :		CDiskObject::EmptyDirectory
	Description :	Will delete all files in directory. 
	Access :		Public

	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" will 
											get an error 
											string if "FALSE"
	Parameters :	CString directory	-	the directory to
											empty.

	Usage :			Call to empty a directory.

   ============================================================*/
{
	ClearError( );
	CString indir( directory );
	QualifyPath( indir );

	// Enumerate all files
	CStringArray files;
	BOOL result = EnumFilesInDirectory( indir, files );
	if( result )
	{
		INT_PTR max = files.GetSize( );
		for( INT_PTR t = 0 ; t < max ; t++ )
		{
			// Loop and delete
			CString file = files[ t ];
			Trigger( file );
			if( !( result = ::DeleteFile( indir + file ) ) )
			{
				SetSystemErrorMessage( ::GetLastError( ), indir + file );
				t = max;
			}
		}
	}

	return result;
}
Exemple #9
0
bool Trap::Process()
{
	if (chkarea_timer.Enabled() && chkarea_timer.Check()
		/*&& zone->GetClientCount() > 0*/ )
	{
		Mob* trigger = entity_list.GetTrapTrigger(this);
		if (trigger && !(trigger->IsClient() && trigger->CastToClient()->GetGM()))
		{
			Trigger(trigger);
		}
	}
	if (respawn_timer.Enabled() && respawn_timer.Check())
	{
		detected = false;
		disarmed = false;
		chkarea_timer.Enable();
		respawn_timer.Disable();
	}
	return true;
}
bool BattleSquad::changeFormation(int formation, bool costap)
{
	if(canChangeFormation(formation) != SKILLSTATE_AVAILABLE)
		return false;
	setFormation(formation);
	LuaTempContext* luatempcontext = new LuaTempContext();
	luatempcontext->strMap["squadid"] = getSquadId();
	luatempcontext->intMap["formation"] = formation;
	Trigger("ChangeFormation", luatempcontext);
	delete luatempcontext;
	if(costap)
	{
		float ap = getActionPoint();
		float apcost = getAPTypeCostModify(SKILLAPTYPE_SETUP);
		ap -= apcost;
		setAPTypeCostModify(SKILLAPTYPE_SETUP, apcost + 1.0f);
		setActionPoint(ap);
	}
	return true;
}
Exemple #11
0
bool Sound::Write(u_int32_t address, u_int32_t value, MemoryAccess memAccess)
{
	if(address >= bAddress && address <= eAddress)
	{
		if(memAccess == MA16)
		{
			u_int16_t *data = reinterpret_cast<u_int16_t*>(&snd);
			data[(address - bAddress) / 2] = value;
		}
		else // MA32
		{
			u_int32_t *data = reinterpret_cast<u_int32_t*>(&snd);
			data[(address - bAddress) / 4] = value;
		}

		Trigger();

		return true;
	}
	return false;
}
Exemple #12
0
void VCommand::Trigger(sLONG inChoiceIndex, const ICommandListener* inExcept)
{
	VValueSingle* singleValue = NULL;

	if (fChoiceList != NULL)
	{
		VValue*	value = VValue::NewValueFromValueKind(fChoiceList->GetElemValueKind());
		if (value != NULL)
		{
			singleValue = dynamic_cast<VValueSingle*>(value);
			if (singleValue == NULL)
				delete value;
		}
	}

	if (testAssert(singleValue != NULL))
	{
		fChoiceList->GetValue(*singleValue, inChoiceIndex);
		Trigger(*singleValue, inExcept);
		delete singleValue;
	}
}
Exemple #13
0
void UiBacklight::OnTimer( unsigned long cookie )
{
    switch( cookie )
    {
        case TimerSwitchOff:
            if( (time(NULL) - _backlightTimeout - _lastTriggerTime) > 10 )
            {
                //looks like a time warp, retrigger
                Trigger();
            }else{
                Switch( false );
            }
        break;
        case TimerDimmDown:
            SetBrightness( _currentBrightness - DimmStep );
            if( _currentBrightness > _minBrightness )
            {
                RequestTimer( DimmInterval, TimerDimmDown );
            }
        break;
    }
}
Exemple #14
0
BOOL CDiskObject::CopyDirectory( const CString& sourceDirectory,const CString& destDirectory )
/* ============================================================
	Function :		CDiskObject::CopyDirectory
	Description :	Copies all the files from "sourceDirectory" 
					to "destDirectory". Existing files will be
					overwritten. "destDirectory" will be created
					if necessary. Subdirectories will not be
					copied.
	Access :		Public
					
	Return :		BOOL					-	"TRUE" if OK. 
												"GetErrorMessage" 
												will get an error 
												string if "FALSE"
	Parameters :	CString sourceDirectory	-	copy from.
					CString destDirectory	-	copy to.

	Usage :			Call to copy a directory to another 
					directory.

   ============================================================*/
{
	ClearError( );
	CString source( sourceDirectory );
	CString dest( destDirectory );
	QualifyPath( source );
	QualifyPath( dest );

	Trigger( dest );

	// We don't care if this fails - CopyFiles will 
	// return an error in that case.
	::CreateDirectory( dest, NULL );

	return CopyFiles( source, dest );

}
/*****************************************************************************
 * Event for input.c
 *****************************************************************************/
void input_SendEventDead( input_thread_t *p_input )
{
    p_input->b_dead = true;

    Trigger( p_input, INPUT_EVENT_DEAD );
}
void input_SendEventAout( input_thread_t *p_input )
{
    Trigger( p_input, INPUT_EVENT_AOUT );
}
/*****************************************************************************
 * Event for control.c/input.c
 *****************************************************************************/
void input_SendEventBookmark( input_thread_t *p_input )
{
    Trigger( p_input, INPUT_EVENT_BOOKMARK );
}
void CN3FXBundleGame::Trigger(int iSourceID, int iTargetID, int iTargetJoint, int iSndID)
{
	m_bRegion = false;

	CPlayerBase* pTarget = CGameProcedure::s_pProcMain->CharacterGetByID(iTargetID, false);
	if(!pTarget) return;
	
	CPlayerBase* pSource = CGameProcedure::s_pProcMain->CharacterGetByID(iSourceID, true);
	if(pSource)
	{
		if(pSource->m_pShapeExtraRef)
		{
			__Vector3 vMin = pSource->m_pShapeExtraRef->Min();
			__Vector3 vMax = pSource->m_pShapeExtraRef->Max();
			m_vPos = vMin + ((vMax-vMin)*0.5f);	
		}
		else
		{
			const __Matrix44* pMtx = pSource->JointMatrixGet(m_iSourceJoint);
			if(!pMtx) m_vPos = pSource->Position();
			else pSource->JointPosGet(m_iSourceJoint, m_vPos);
		}

		m_vDestPos = pSource->Position() + pSource->Direction();		
	}

	//CPlayerBase* pTarget = CGameProcedure::s_pProcMain->CharacterGetByID(iTargetID, false);
	if(pTarget && pTarget!=pSource)
	{
		if(m_bDependScale)
		{
			//m_vTargetScale.x = m_vTargetScale.z = pTarget->Radius() * 2.0f;
			//m_vTargetScale.y = pTarget->Height();
			float width = pTarget->Radius() * 2.0f;
			if(width > pTarget->Height()) m_fTargetScale = width;
			else m_fTargetScale = pTarget->Height();
		}

		if(pTarget->m_pShapeExtraRef)
		{
			__Vector3 vMin = pTarget->m_pShapeExtraRef->Min();
			__Vector3 vMax = pTarget->m_pShapeExtraRef->Max();

			m_vDestPos = vMin + ((vMax-vMin)*0.5f);	
		}
		else
		{
			__Vector3 vMin = pTarget->Min();
			__Vector3 vMax = pTarget->Max();
			m_vDestPos = vMin + ((vMax-vMin)*0.5f);
			//m_vDestPos = pTarget->Position();
			
			if(iTargetJoint==-1)
			{
				__Vector3 vMin = pTarget->Min();
				__Vector3 vMax = pTarget->Max();
	
				m_vDestPos = vMin + ((vMax-vMin)*0.5f);	
				m_vDestPos.y = vMin.y;
				//m_vDestPos = pTarget->Position();	
			}
			else if(iTargetJoint>-1)
			{
				const __Matrix44* pMtx = pTarget->JointMatrixGet(iTargetJoint);
				if(!pMtx) m_vDestPos = pTarget->Position() + (pTarget->Height()*0.5f);
				else pTarget->JointPosGet(iTargetJoint, m_vDestPos);
			}
		}
	//	m_vDir = pTarget->Direction();
	//	m_vDir.Normalize();
	}

	m_fDistance = (m_vDestPos - m_vPos).Magnitude();
	m_fHeight = m_fDistance/2.0f;

	m_vDir = m_vDestPos - m_vPos;
	m_vDir.Normalize();
	
	if(m_bStatic)
	{
		Trigger(iSourceID, m_vDestPos, iSndID);
		return;
	}

	CN3FXBundle::Trigger(iSourceID, iTargetID, iTargetJoint, iSndID);
}
void input_SendEventMetaEpg( input_thread_t *p_input )
{
    Trigger( p_input, INPUT_EVENT_ITEM_EPG );
}
Exemple #20
0
BOOL CDiskObject::EnumFilesInDirectoryWithFilter( const CString& strFilter,const CString& sourceDirectory, CStringArray& files, int mode )
/* ============================================================
	Function :		CDiskObject::EnumFilesInDirectoryWithFilter
	Description :	Enumerates all files matching "strFilter" in 
					the directory "sourceDirectory", and adds 
					them to the "CStringArray" "files". Will not 
					add subdirectories.
	Access :		Public
					
	Return :		BOOL					-	"TRUE" if OK. 
												"GetErrorMessage" 
												will contain errors
	Parameters :	CString strFilter		-	the file name filter
					CString sourceDirectory	-	source directory
					CStringArray& files		-	output array
					
	Usage :			Call to get a filtered list of files from 
					a directory.

   ============================================================*/
{

	ClearError( );
	CString source( sourceDirectory );
	QualifyPath( source );
	CString sourceFiles( source + strFilter );
	BOOL result = TRUE;
	WIN32_FIND_DATA ff;

	HANDLE findhandle = FindFirstFile( sourceFiles, &ff );
	if( findhandle != INVALID_HANDLE_VALUE )
	{
		BOOL res = TRUE;
		while( res )
		{
			// We only want files
			if( !( ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
			{
				BOOL    added = FALSE;
				CString file;
				file = ff.cFileName;

				if( mode == EF_FULLY_QUALIFIED )
					file = sourceDirectory + file;


				if ( !added )
				{
					files.Add( file );
				}

				Trigger( file );
			}

			res = FindNextFile( findhandle, &ff );
		}

		FindClose( findhandle );
	}
	else
	{
		// Set error message
		SetSystemErrorMessage( ::GetLastError( ), sourceFiles );
		result = FALSE;
	}

	return result;

}
Exemple #21
0
int main(int argc, char *argv[]){

#ifndef CONSOLE_TEST
  if(SetupGPIO() != TOYHACK_SUCCEEDED){
    std::cerr << "Could not initialize libminityra." << std::endl;
    return TOYHACK_ERROR;
  }
#endif

  TConsole console(cmd_descriptions);

  std::cout << "Minityra management console" << std::endl;
  std::cout << "Copyright (C) 2016 Yasumasa Suenaga" << std::endl;
  std::cout << std::endl;

  while(true){
    const char *cmd = console.GetCommand("minityra> ");

    if(strcmp(cmd, "help") == 0){
      console.PrintHelp();
    }
    else if(strcmp(cmd, "list") == 0){
      print_judenchi_list();
    }
    else if(strcmp(cmd, "judenchi") == 0){
      int id = -1;

      /* Read Judenchi ID */
      try{
        id = console.GetNextArgAsInt();

        if(!ID_ISIN(id)){
          throw -1;
        }

      }
      catch(...){
        std::cerr << "Invalid Judenchi ID." << std::endl;
        continue;
      }

      print_judenchi("Judenchi", id);

#ifndef CONSOLE_TEST
      if(SetJudenchi(id) != TOYHACK_SUCCEEDED){
        std::cerr << "Cannot set Judenchi." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "gabu") == 0){

#ifndef CONSOLE_TEST
      if(Gabu() != TOYHACK_SUCCEEDED){
        std::cerr << "Cannot send gabu command." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "mode") == 0){
      int mode = -1;

      try{
        const char *mode_str = console.GetNextArgAsString();

        if(strcmp(mode_str, "overcharge") == 0){
          mode = MODE_OVERCHARGE;
        }
        else if(strcmp(mode_str, "carnival") == 0){
          mode = MODE_CARNIVAL;
        }
        else{
          throw -1;
        }

      }
      catch(...){
        std::cerr << "Invalid mode." << std::endl;
      }

#ifndef CONSOLE_TEST
      if(Kururincho(mode) != TOYHACK_SUCCEEDED){
        std::cerr << "Cannot send kururincho command." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "gaburevolver") == 0){
      bool isOn;

      try{
        isOn = console.GetNextArgAsOnOff();
      }
      catch(...){
        std::cerr << "Invalid argument(s)." << std::endl;
        continue;
      }

#ifdef CONSOLE_TEST
      std::cout << isOn << std::endl;
#else
      if(isOn && (DockGaburevolver() != TOYHACK_SUCCEEDED)){
        std::cerr << "Cannot dock to gaburevolver." << std::endl;
      }
      else if(!isOn && (UndockGaburevolver() != TOYHACK_SUCCEEDED)){
        std::cerr << "Cannot undock from gaburevolver." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "trigger") == 0){

#ifndef CONSOLE_TEST
      if(Trigger() != TOYHACK_SUCCEEDED){
        std::cerr << "Cannot send trigger command." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "side") == 0){

#ifndef CONSOLE_TEST
      if(SideSwitch() != TOYHACK_SUCCEEDED){
        std::cerr << "Cannot send side switch command." << std::endl;
      }
#endif

    }
    else if(strcmp(cmd, "henshin") == 0){
      SetJudenchi(-1);
      Kururincho(MODE_CARNIVAL);
      sleep(1);
      SetJudenchi(55); // Carnival Judenchi
      Gabu();
      sleep(10);
      Trigger();
    }
    else if(strcmp(cmd, "kamichange") == 0){
      SideSwitch();
      sleep(3);
      SetJudenchi(-1);
      sleep(1);

      for(int Cnt = 0; Cnt < 3; Cnt++){
        int id = -1;

        /* Read Judenchi ID */
        try{
          id = console.GetNextArgAsInt();

          if(!ID_ISIN(id)){
            throw -1;
          }

        }
        catch(...){
          std::cerr << "Invalid Judenchi ID." << std::endl;
          break;
        }

        SetJudenchi(id);
        sleep(1);
        Gabu();
        sleep(2);
      }

      Trigger();
    }
    else if(strcmp(cmd, "exit") == 0){
      break;
    }
    else{
      std::cerr << "Error: Unknown command." << std::endl;
    }

  }

  return 0;
}
Exemple #22
0
bool plResponderModifier::MsgReceive(plMessage* msg)
{
    plNotifyMsg* pNMsg = plNotifyMsg::ConvertNoRef(msg);
    if (pNMsg)
    {
        if (pNMsg->fType == plNotifyMsg::kResponderFF)
        {
            ISetResponderStateFromNotify(pNMsg);
            IFastForward(true);
        }
        else if (pNMsg->fType == plNotifyMsg::kResponderChangeState)
        {
            ISetResponderStateFromNotify(pNMsg);
            DirtySynchState(kSDLResponder, 0);
        }
        else
        {
            // assumes state of 0 means untriggered and state of 1 is triggered
            if ((pNMsg->fState != 0 && (fFlags & kDetectTrigger)) ||
                (pNMsg->fState == 0 && (fFlags & kDetectUnTrigger)))
            {
                Trigger(pNMsg);
                DirtySynchState(kSDLResponder, 0);
            }
        }

        return true;
    }

    plResponderEnableMsg *pEnableMsg = plResponderEnableMsg::ConvertNoRef(msg);
    if (pEnableMsg)
    {
        fEnabled = pEnableMsg->fEnable;
        DirtySynchState(kSDLResponder, 0);
        return true;
    }

    plEventCallbackMsg *pEventMsg = plEventCallbackMsg::ConvertNoRef(msg);
    plTimerCallbackMsg *timerMsg = plTimerCallbackMsg::ConvertNoRef(msg);
    if (pEventMsg || timerMsg)
    {
        uint32_t waitID = pEventMsg ? pEventMsg->fUser : timerMsg->fID;

        if (waitID != -1)
        {
            // Flag that this callback completed and try sending in case any commands were waiting on this
            fCompletedEvents.SetBit(waitID);

            ResponderLog(ILog(plStatusLog::kWhite, "Got callback from command %d(id:%d)", ICmdFromWait((int8_t)waitID)+1, waitID));

            IContinueSending();
            DirtySynchState(kSDLResponder, 0);
        }
        // The is one of the stop callbacks we generated for debug mode
        else if (fDebugAnimBox)
            IDebugAnimBox(false);

        return true;
    }

    // pass sdl msg to sdlMod
    plSDLModifierMsg* sdlMsg = plSDLModifierMsg::ConvertNoRef(msg);
    if (sdlMsg && fResponderSDLMod)
    {
        if (fResponderSDLMod->MsgReceive(sdlMsg))
            return true;    // msg handled
    }

    return plSingleModifier::MsgReceive(msg);
}
Exemple #23
0
//	-----------------------------------------------------------------------------
//if an effect is hit, and it can blow up, then blow it up
//returns true if it blew up
int CSegment::CheckEffectBlowup (int nSide, CFixVector& vHit, CObject* blowerP, int bForceBlowup)
{
	int				tm, tmf, ec, nBitmap = 0;
	int				bOkToBlow = 0, nSwitchType = -1;
	short				nSound, bPermaTrigger;
	ubyte				vc;
	fix				u, v;
	fix				xDestSize;
	tEffectClip*	ecP = NULL;
	CBitmap*			bmP;
	CWall*			wallP;
	CTrigger*		trigP;
	CObject*			parentP = (!blowerP || (blowerP->cType.laserInfo.parent.nObject < 0)) ? NULL : OBJECTS + blowerP->cType.laserInfo.parent.nObject;
	//	If this CWall has a CTrigger and the blowerP-upper is not the CPlayerData or the buddy, abort!

if (parentP) {
	if ((parentP->info.nType == OBJ_ROBOT) && ROBOTINFO (parentP->info.nId).companion)
		bOkToBlow = 1;
	if (!(bOkToBlow || (parentP->info.nType == OBJ_PLAYER)) &&
		 ((wallP = Wall (nSide)) && (wallP->nTrigger < gameData.trigs.m_nTriggers)))
		return 0;
	}

if (!(tm = m_sides [nSide].m_nOvlTex))
	return 0;

tmf = m_sides [nSide].m_nOvlOrient;		//tm flags
ec = gameData.pig.tex.tMapInfoP [tm].nEffectClip;
if (ec < 0) {
	if (gameData.pig.tex.tMapInfoP [tm].destroyed == -1)
		return 0;
	nBitmap = -1;
	nSwitchType = 0;
	}
else {
	ecP = gameData.eff.effectP + ec;
	if (ecP->flags & EF_ONE_SHOT)
		return 0;
	nBitmap = ecP->nDestBm;
	if (nBitmap < 0)
		return 0;
	nSwitchType = 1;
	}
//check if it's an animation (monitor) or casts light
bmP = gameData.pig.tex.bitmapP + gameData.pig.tex.bmIndexP [tm].index;
LoadBitmap (gameData.pig.tex.bmIndexP [tm].index, gameStates.app.bD1Data);
//this can be blown up...did we hit it?
if (!bForceBlowup) {
	HitPointUV (nSide, &u, &v, NULL, vHit, 0);	//evil: always say face zero
	bForceBlowup = !PixelTranspType (tm, tmf,  m_sides [nSide].m_nFrame, u, v);
	}
if (!bForceBlowup)
	return 0;

if (IsMultiGame && netGame.bIndestructibleLights && !nSwitchType)
	return 0;
//note: this must get called before the texture changes,
//because we use the light value of the texture to change
//the static light in the CSegment
wallP = Wall (nSide);
bPermaTrigger = (trigP = Trigger (nSide)) && (trigP->flags & TF_PERMANENT);
if (!bPermaTrigger)
	SubtractLight (Index (), nSide);
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordEffectBlowup (Index (), nSide, vHit);
if (nSwitchType) {
	xDestSize = ecP->xDestSize;
	vc = ecP->nDestVClip;
	}
else {
	xDestSize = I2X (20);
	vc = 3;
	}
/*Object*/CreateExplosion (short (Index ()), vHit, xDestSize, vc);
if (nSwitchType) {
	if ((nSound = gameData.eff.vClipP [vc].nSound) != -1)
		audio.CreateSegmentSound (nSound, Index (), 0, vHit);
	if ((nSound = ecP->nSound) != -1)		//kill sound
		audio.DestroySegmentSound (Index (), nSide, nSound);
	if (!bPermaTrigger && (ecP->nDestEClip != -1) && (gameData.eff.effectP [ecP->nDestEClip].nSegment == -1)) {
		tEffectClip	*newEcP = gameData.eff.effectP + ecP->nDestEClip;
		int nNewBm = newEcP->changingWallTexture;
		if (ChangeTextures (-1, nNewBm)) {
			newEcP->xTimeLeft = EffectFrameTime (newEcP);
			newEcP->nCurFrame = 0;
			newEcP->nSegment = Index ();
			newEcP->nSide = nSide;
			newEcP->flags |= EF_ONE_SHOT | ecP->flags;
			newEcP->flags &= ~EF_INITIALIZED;
			newEcP->nDestBm = ecP->nDestBm;

			Assert ((nNewBm != 0) && (m_sides [nSide].m_nOvlTex != 0));
			m_sides [nSide].m_nOvlTex = nNewBm;		//replace with destoyed
			}
		}
	else {
		Assert ((nBitmap != 0) && (m_sides [nSide].m_nOvlTex != 0));
		if (!bPermaTrigger)
			m_sides [nSide].m_nOvlTex = nBitmap;		//replace with destoyed
		}
	}
else {
	if (!bPermaTrigger)
		m_sides [nSide].m_nOvlTex = gameData.pig.tex.tMapInfoP [tm].destroyed;
	//assume this is a light, and play light sound
	audio.CreateSegmentSound (SOUND_LIGHT_BLOWNUP, Index (), 0, vHit);
	}
return 1;		//blew up!
}
Exemple #24
0
BOOL CDiskObject::EnumDirectories( const CString& sourceDirectory, CStringArray& directories )
/* ============================================================
	Function :		CDiskObject::EnumDirectories
	Description :	Enumerates all directories in directory 
					"sourceDirectory", and adds them to the 
					"CStringArray" "directories". Each entry will
					be a fully qualified name
	Access :		Public

	Return :		BOOL						-	"TRUE" if OK. 
													"GetErrorMessage" 
													will contain errors
	Parameters :	CString sourceDirectory		-	start directory
					CStringArray& directories	-	"CStringArray" to be 
													filled with the 
													directory names.

	Usage :			Call to get a list of directories in a 
					directory tree.

   ============================================================*/
{
	ClearError( );

	CString source( sourceDirectory );
	QualifyPath( source );
	CString sourceFiles( source + _T( "*.*" ) );
	BOOL result = TRUE;
	WIN32_FIND_DATA ff;

	HANDLE findhandle = FindFirstFile( sourceFiles, &ff );
	if( findhandle != INVALID_HANDLE_VALUE)
	{

		BOOL res = TRUE;
		while( res)
		{
			// We only want directories
			if( ( ff.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) && _tcscmp( ff.cFileName, _T( "." ) ) && _tcscmp( ff.cFileName, _T( ".." ) ) )
			{
				directories.Add( ff.cFileName );
				Trigger( ff.cFileName );
			}

			if( res )
				res = FindNextFile( findhandle, &ff );
			else
				result = FALSE;
		}

		FindClose( findhandle );
	}
	else
	{
		// Set error message
		SetSystemErrorMessage( ::GetLastError( ), sourceFiles );
		result = FALSE;
	}

	return result;
}
void SinglePlayerPauseState::MouseButtonDown(int Button, Vector2 Location) {
	MouseMotion(Location);
	Trigger();
};
Exemple #26
0
BOOL CDiskObject::CopyFiles( CStringArray& files,const CString& destDirectory )
/* ============================================================
	Function :		CDiskObject::CopyFiles
	Description :	The function copies the files in the 
					"CStringArray" "files" to the directory 
					"destDirectory". Existing files will be
					overwritten. The destination will be 
					created if it doesn't already exist.
	Access :		Public
					
	Return :		BOOL					-	"TRUE" if OK. 
												"GetErrorMessage" 
												will return 
												errors.
	Parameters :	CStringArray& files		-	a string array 
												with the files 
												to copy
					CString destDirectory	-	destination
					
	Usage :			Copy a list of files to a directory.

   ============================================================*/
{
	ClearError( );
	CString dest( destDirectory );

	BOOL result = TRUE;
	if( files.GetSize( ) )
	{
		QualifyPath( dest );

		// Create destination, if necessary
		if( ( result = CreateDirectory( dest ) ) )
		{
			INT_PTR max = files.GetSize( );
			for( INT_PTR t = 0 ; t < max ; t++ )
			{
				// Loop and copy the files
				CString file;
				file = files[ t ];
				if( file.GetLength( ) )
				{
					Trigger( file );
					QualifyFile( file );

					// Create destination filename
					CString to = dest + GetFileName( file );
					if( !( result = ::CopyFile( file, to, FALSE ) ) )
					{
						// Set error message
						SetSystemErrorMessage( ::GetLastError( ),
												file + 
												_T( " -> " ) + 
												dest + 
												file );
						t = max;
					}
				}
			}
		}
	}
	else
	{
		SetInternalErrorMessage( );
		result =  FALSE;
	}

	return result;
}
Exemple #27
0
BOOL CDiskObject::CreateDirectory( const CString& directory )
/* ============================================================
	Function :		CDiskObject::CreateDirectory
	Description :	Will recursively create the directory 
					"directory".
	Access :		Public

	Return :		BOOL				-	"TRUE" if OK. 
											"GetErrorMessage" 
											will get an 
											error string if 
											"FALSE"
	Parameters :	CString directory	-	directory to 
											create

	Usage :			Call to create a directory chain.

   ============================================================*/
{
	ClearError( );

	BOOL result = TRUE;
	CString indir( directory );
	if( indir.GetLength( ) )
	{
		QualifyPath( indir );

		_TCHAR drive[ _MAX_PATH ];
		_TCHAR dir[ _MAX_DIR ];
		_TCHAR fname[ _MAX_FNAME ];
		_TCHAR ext[ _MAX_EXT ];

		// Split directory into parts
		_tsplitpath( indir, drive, dir, fname, ext );

		TCHAR currentDirectory[ _MAX_PATH ];
		::GetCurrentDirectory( _MAX_PATH, currentDirectory );

		CStringArray directories;
		CString parts = dir;

		if( parts.GetLength( ) > 2 )
		{
			if( parts.Left( 2 ) == _T( "\\\\" ) )
			{
				// We have an UNC name
				CString strComputer;
				parts = parts.Right( parts.GetLength( ) - 2 );
				int findDir = parts.Find( _TCHAR( '\\' ) );
				if( findDir!=-1)
				{
					strComputer = _T( "\\\\" ) + parts.Left( findDir );
					parts = parts.Right( parts.GetLength( ) - ( findDir + 1 ) );
				}
				_tcscpy( drive, strComputer );
			}
		}

		CString strRoot( drive );

		// Strip leading \'s
		while( parts.GetLength( ) && parts[0] == _TCHAR( '\\' ) )
			parts = parts.Right( parts.GetLength( ) - 1 );

		// Cut into separate directories
		int find = parts.Find( _TCHAR( '\\' ) );
		while( find != -1 )
		{
			directories.Add( parts.Left( find ) );
			parts = parts.Right( parts.GetLength( ) - ( find + 1 ) );
			find = parts.Find( _TCHAR( '\\' ) );
		}

		if( parts.GetLength( ) )
			directories.Add( parts );

		if( fname )
			directories.Add( fname );

		// Loop directories one-by-one, creating as necessary
		INT_PTR max = directories.GetSize( );
		CString strCurrentDirectory( strRoot );

		for( INT_PTR t = 0 ; t < max ; t++ )
		{
			strCurrentDirectory += _TCHAR( '\\' ) + directories[ t ];
			Trigger( strCurrentDirectory );
			if( !( result = ::SetCurrentDirectory( strCurrentDirectory ) ) )
			{
				if( !( result = ::CreateDirectory( strCurrentDirectory, NULL ) ) )
				{
					SetSystemErrorMessage( ::GetLastError( ), strCurrentDirectory );
					t = max;
				}
			}
		}

		::SetCurrentDirectory( currentDirectory );

	}
	else
	{
		SetInternalErrorMessage( );
		result = FALSE;
	}
	return result;
}
void input_SendEventAbort( input_thread_t *p_input )
{
    Trigger( p_input, INPUT_EVENT_ABORT );
}
void input_SendEventStatistics( input_thread_t *p_input )
{
    Trigger( p_input, INPUT_EVENT_STATISTICS );
}
Exemple #30
0
void UiBacklight::SetTimeout( int timeout )
{
	LOG( Logger::LOG_DEBUG, "UiBacklight::SetTimeout( %d )", timeout);
	_backlightTimeout = timeout;
	Trigger();
}