示例#1
0
int CNode::Process(CPlayer *pPlayer, int iPointId, int iLastPoint, int iType, CVector3 vecVelocity)
{
	int iChangeNode = 0;
	// Set the node to the player point
	SetPoint(iPointId);
	// Set it to the next link
	unsigned short usStartLink = GetLinkId();
	unsigned short usLinkCount = GetLinkCount();
	BYTE byteCount = 0;
	// Do we need to change the node ?
	while(!iChangeNode)
	{
		// Generate a random link id
		unsigned short usLinkId = usStartLink + (rand() % usLinkCount);
		// Set the node to the next random link
		SetLink(usLinkId);
		// Keep looping until we get a differente link point
		while(m_nodeLink.usNodeId == iLastPoint && usLinkCount > 1)
		{
			// Increase the attempts count
			byteCount++;
			if(byteCount > 10) 
				break;

			// Generate a random link id
			unsigned short usLinkId = usStartLink + (rand() % usLinkCount);
			// Set the node to the next random link
			SetLink(usLinkId);
		}
		// Check if we need to change the node id
		if(m_nodeLink.usAreaId != m_iNodeId)
		{
			if(m_nodeLink.usAreaId != 65535)
			{
				if((iChangeNode = CCallbackManager::OnChangeNode(pPlayer->GetId(), (int)m_nodeLink.usAreaId)))
					return pPlayer->ChangeNode(m_nodeLink.usAreaId, usLinkId);
			}
			else
				return 0;
		}
		else
		{
			// Set the next point
			SetPoint(m_nodeLink.usNodeId);
			// Get the point position
			CVector3 vecPosition;
			GetPosition(&vecPosition);
			// Set the player velocity
			pPlayer->SetVelocity(vecVelocity);
			// Move the player to it
			pPlayer->GoTo(vecPosition, iType == NODE_TYPE_PED ? MOVE_TYPE_WALK : MOVE_TYPE_DRIVE, true);

			return m_nodeLink.usNodeId;
		}
	}
	return 0;
}
示例#2
0
NS_IMETHODIMP 
HTMLBodyElement::SetLink(const nsAString& aLink)
{
  ErrorResult rv;
  SetLink(aLink, rv);
  return rv.StealNSResult();
}
示例#3
0
EXPORT_C void CLogEvent::CopyL(const CLogEvent& aEvent)
/** Makes a copy of the specified log event.

@param aEvent The log event to be copied. */
	{
	// Set data first as this is the only function that can leave
	// If this function fails nothing will be changed
	SetDataL(aEvent.Data());

	SetId(aEvent.Id());
	SetEventType(aEvent.EventType());
	SetTime(aEvent.Time());
	SetDurationType(aEvent.DurationType());
	SetDuration(aEvent.Duration());
	SetContact(aEvent.Contact());
	SetLink(aEvent.Link());
	SetDescription(aEvent.Description());
	SetRemoteParty(aEvent.RemoteParty());
	SetDirection(aEvent.Direction());
	SetStatus(aEvent.Status());
	SetSubject(aEvent.Subject());
	SetNumber(aEvent.Number());

	ClearFlags(KLogFlagsMask);
	SetFlags(aEvent.Flags());
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
	SetSimId(aEvent.SimId());
#endif
	}
示例#4
0
IMAGE_NAMESPACE 
void MarkImageUpdated( Image child_image )
{
	Image image;
	for( image = child_image; image && image->pParent; image = image->pParent );

	;;

	{
		INDEX idx;
		struct glSurfaceData *data;
		struct glSurfaceImageData *current_image_data = NULL;
		LIST_FORALL( l.glSurface, idx, struct glSurfaceData *, data )
		{
			struct glSurfaceImageData *image_data;
			image_data = (struct glSurfaceImageData *)GetLink( &image->glSurface, idx );
			if( !image_data )
			{
				image_data = New( struct glSurfaceImageData );
				image_data->glIndex = 0;
				image_data->flags.updated = 1;
				SetLink( &image->glSurface, idx, image_data );
			}
			if( image_data->glIndex )
			{
				image_data->flags.updated = 1;
				//glDeleteTextures( 1, &image_data->glIndex );
				//image_data->glIndex = 0;
			}
			if( data == l.glActiveSurface )
				current_image_data = image_data;
		}
		//return current_image_data;
	}
示例#5
0
static void CPROC CheckFiles( uintptr_t psv )
{
	INDEX idx;
	struct input_file *file;
	if( l.flags.bLog )
		lprintf( WIDE("Check Files...") );
	LIST_FORALL( l.files, idx, struct input_file*, file )
	{
		FILE *input;
		static TEXTCHAR buf[256];
		if( l.flags.bLog )
			lprintf( WIDE("check %s"), file->filename );
		input = sack_fopen( 0, file->filename, WIDE("rt") );
		if( input )
		{
			INDEX var_idx = 0;
			while( fgets( buf, sizeof( buf ), input ) )
			{
				size_t end;
				struct variable_tracker *var =(struct variable_tracker*)GetLink( &file->vars, var_idx );
				//lprintf( WIDE("buf .. %s"), buf );
				while( ( end = strlen(buf) ) && ( buf[end-1] == '\n' ) )
					buf[end-1] = 0;
				if( l.flags.bLog )
					lprintf( WIDE("Content %p %s"), var, buf );
				if( !var )
				{
					TEXTCHAR tmp_name[128];
					snprintf( tmp_name, sizeof( tmp_name ), WIDE("<File %s.%d>"), file->varname, var_idx+1 );
					var = New( struct variable_tracker );
					var->var_content = StrDup( buf );
					var->var_name = StrDup( tmp_name );
					lprintf( WIDE("Newvar %s=%s"), tmp_name, buf );
					var->variable = CreateLabelVariable( tmp_name, LABEL_TYPE_STRING, &var->var_content );
					SetLink( &file->vars, var_idx, var );
				}
				else
				{
					if( StrCmp( var->var_content, buf ) )
					{
						Release( var->var_content );
						var->var_content = StrDup( buf );
						lprintf( WIDE("Change var %s=%s"), var->var_name, buf );
 						LabelVariableChanged( var->variable );
					}
				}

				var_idx++;
			}
			sack_fclose( input );
		}
示例#6
0
int CNode::ProcessNodeChange(CPlayer *pPlayer, unsigned short usLinkId, int iType, CVector3 vecVelocity)
{
	// Set the node link
	SetLink(usLinkId);
	// Set the next point
	SetPoint(m_nodeLink.usNodeId);
	// Get the point position
	CVector3 vecPosition;
	GetPosition(&vecPosition);
	// Set the player velocity
	pPlayer->SetVelocity(vecVelocity);
	// Move the player to it
	pPlayer->GoTo(vecPosition, iType == NODE_TYPE_PED ? MOVE_TYPE_WALK : MOVE_TYPE_DRIVE, true);

	return m_nodeLink.usNodeId;
}
示例#7
0
void DestroyProcess( PENTITY pe )
{
	PPROCESS process = (PPROCESS)GetLink( &pe->pPlugin, iProcess );
	Log( WIDE("Killing process this represents") );
	if( process )
	{
		if( WaitForSingleObject( process->pi.hProcess, 0 ) == WAIT_TIMEOUT )
		{
	      TerminateProcess( process->pi.hProcess, 0xD1E );
		}
		CloseHandle( process->pi.hProcess );
		CloseHandle( process->pi.hThread );
		LineRelease( process->command );
		LineRelease( process->directory );
		Release( process );
		SetLink( &pe->pPlugin, iProcess, NULL );
	}
}
示例#8
0
int
set_menu_format(MENU *m, int rows, int cols)
{
	if (rows < 0 || cols < 0) {
		return (E_BAD_ARGUMENT);
	}
	if (m) {
		if (Posted(m)) {
			return (E_POSTED);
		}
		if (rows == 0) {
			rows = FRows(m);
		}
		if (cols == 0) {
			cols = FCols(m);
		}

		/* The pattern buffer is allocated after items have been */
		/* connected */
		if (Pattern(m)) {
			IthPattern(m, 0) = '\0';
			Pindex(m) = 0;
		}

		FRows(m) = rows;
		FCols(m) = cols;
		Cols(m) = min(cols, Nitems(m));
		Rows(m) = (Nitems(m)-1) / cols + 1;
		Height(m) = min(rows, Rows(m));
		Top(m) = 0;
		Current(m) = IthItem(m, 0);
		SetLink(m);
		_scale(m);
	} else {
		if (rows > 0) {
			FRows(Dfl_Menu) = rows;
		}
		if (cols > 0) {
			FCols(Dfl_Menu) = cols;
		}
	}
	return (E_OK);
}
示例#9
0
bool ObjectDetector::SetObject( HOBJECT hObject )
{
	ObjectDetectorLink* pLink = m_iRootLink.m_pNext;
	ClearObject();

	// Find this object in the registered list
	while( pLink )
	{
		if( pLink->m_hObject == hObject )
		{
			SetLink( pLink );
			break;
		}

		pLink = pLink->m_pNext;
	}

	return ( m_pTrackedLink != NULL );
}
示例#10
0
int
set_menu_opts(MENU *m, int opt)
{
	ITEM **ip;

	if (m) {
		if (Posted(m)) {
			return (E_POSTED);
		}

		/* Check to see if the ROWMAJOR option is changing.  If so, */
		/* set top and current to 0. */
		if ((opt & O_ROWMAJOR) != RowMajor(m)) {
			Top(m) = 0;
			Current(m) = IthItem(m, 0);
			(void) set_menu_format(m, FRows(m), FCols(m));
		}

		/* if O_NONCYCLIC option changed, set bit to re-link items */
		if ((opt & O_NONCYCLIC) != (Mopt(m) & O_NONCYCLIC)) {
			SetLink(m);
		}

		Mopt(m) = opt;
		if (OneValue(m) && Items(m)) {
			for (ip = Items(m); *ip; ip++) {
				/* Unset values if selection not allowed. */
				Value(*ip) = FALSE;
			}
		}
		_scale(m);		/* Redo sizing information */
	} else {
		Mopt(Dfl_Menu) = opt;
	}
	return (E_OK);
}
示例#11
0
HOBJECT ObjectDetector::AcquireObject( bool bFromPrevious )
{
	// Make sure the object to the currently tracked link is still valid
	if( m_pTrackedLink && !m_pTrackedLink->m_hObject.GetData() )
	{
		ReleaseLink( *m_pTrackedLink );
		ClearObject();
	}

	// If we don't have any acquire flags set... then don't do anything
	if( !( m_nBehaviorFlags & ODBF_ACQUIREMASK ) )
	{
		return NULL;
	}

	// Keep track of the links that fit the previous, best, and current requirements
	ObjectDetectorLink* pPrevTracked = ( bFromPrevious ? m_pTrackedLink : NULL );
	ObjectDetectorLink* pCurrTracked = NULL;
	ObjectDetectorLink* pBestTracked = NULL;

	// Requirement ranges and other data tracking variables
	float fPrevRR = 0.0f;
	float fCurrRR = 1000000.0f;
	float fBestRR = 1000000.0f;
	float fTempRR, fActiveRR;
	uint32 nAttemptedTests, nPassedTests;
	bool bContinue;

	// Get the previously tracked link data... add up the RR values even if the
	// tests don't pass.  This way we get a relative value to compare to regardless
	// of whether it can be acquired again during this attempt.
	if( pPrevTracked )
	{
		LTVector vPos, vDims;
		GetObjectSpatialData( pPrevTracked, vPos, vDims );

		if( m_nBehaviorFlags & ODBF_ACQUIREFORWARD )
		{
			TestParamsForward( pPrevTracked, vPos, vDims, fTempRR );
			fPrevRR += fTempRR;
		}

		if( m_nBehaviorFlags & ODBF_ACQUIREDIRECTION )
		{
			TestParamsDirection( pPrevTracked, vPos, vDims, fTempRR );
			fPrevRR += fTempRR;
		}

		if( m_nBehaviorFlags & ODBF_ACQUIREFOV )
		{
			TestParamsFOV( pPrevTracked, vPos, vDims, fTempRR );
			fPrevRR += fTempRR;
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRESPHERE )
		{
			TestParamsSphere( pPrevTracked, vPos, vDims, fTempRR );
			fPrevRR += fTempRR;
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRECYLINDER )
		{
			TestParamsCylinder( pPrevTracked, vPos, vDims, fTempRR );
			fPrevRR += fTempRR;
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRECUSTOM )
		{
			TestParamsCustom( pPrevTracked, fTempRR );
			fPrevRR += fTempRR;
		}
	}

	// Go through each registered object
	ObjectDetectorLink* pLink = m_iRootLink.m_pNext;

	while( pLink )
	{
		LTVector vPos, vDims;
		GetObjectSpatialData( pLink, vPos, vDims );

		// Ignore the previous tracked link
		if( pLink == pPrevTracked )
		{
			pLink = pLink->m_pNext;
			continue;
		}

		// If this link has invalid object data... release it
		if( !pLink->m_hObject.GetData() )
		{
			ObjectDetectorLink* pRemove = pLink;
			pLink = pLink->m_pNext;
			ReleaseLink( *pRemove );
			continue;
		}

		// Check our user flag verification
		if( m_nUserFlagVerification )
		{
			uint32 nUserFlags;
			g_pLTClient->Common()->GetObjectFlags( pLink->m_hObject, OFT_User, nUserFlags );

			if( ( nUserFlags & m_nUserFlagVerification ) != m_nUserFlagVerification )
			{
				continue;
			}
		}

		// Zero out our temporary requirement range
		fActiveRR = 0.0f;
		nAttemptedTests = 0;
		nPassedTests = 0;

		// Check all the necessary params
		if( m_nBehaviorFlags & ODBF_ACQUIREFORWARD )
		{
			++nAttemptedTests;

			if( TestParamsForward( pLink, vPos, vDims, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		if( m_nBehaviorFlags & ODBF_ACQUIREDIRECTION )
		{
			++nAttemptedTests;

			if( TestParamsDirection( pLink, vPos, vDims, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		if( m_nBehaviorFlags & ODBF_ACQUIREFOV )
		{
			++nAttemptedTests;

			if( TestParamsFOV( pLink, vPos, vDims, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRESPHERE )
		{
			++nAttemptedTests;

			if( TestParamsSphere( pLink, vPos, vDims, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRECYLINDER )
		{
			++nAttemptedTests;

			if( TestParamsCylinder( pLink, vPos, vDims, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		if( m_nBehaviorFlags & ODBF_ACQUIRECUSTOM )
		{
			++nAttemptedTests;

			if( TestParamsCustom( pLink, fTempRR ) )
			{
				fActiveRR += fTempRR;
				++nPassedTests;
			}
		}

		// Make sure we passed the required tests...
		if( m_nBehaviorFlags & ODBF_INCLUSIVEACQUIRE )
		{
			bContinue = ( nPassedTests == nAttemptedTests );
		}
		else
		{
			bContinue = ( nPassedTests > 0 );
		}

		if( bContinue )
		{
			// Make sure we have a line of site to this object
			if( m_nBehaviorFlags & ODBF_ACQUIRELINEOFSITE )
			{
				bContinue = TestLineOfSite( pLink );
			}

			// If we passed the line of site test...
			if( bContinue )
			{
				// If the active test is better than our best... track it!
				if( fActiveRR < fBestRR )
				{
					fBestRR = fActiveRR;
					pBestTracked = pLink;
				}

				// If the active test is after our previous, but better than the current... track it too!
				if( ( fActiveRR > fPrevRR ) && ( fActiveRR < fCurrRR ) )
				{
					fCurrRR = fActiveRR;
					pCurrTracked = pLink;
				}
			}
		}

		// Move on to the next object
		pLink = pLink->m_pNext;
	}

	// Reset our verification timers
	memcpy( m_fActiveVerifyFailureDelays, m_fVerifyFailureDelays, sizeof( float ) * ODBF_TESTSAVAILABLE );

	// Set our tracked link to the proper one
	if( pCurrTracked )
	{
		SetLink( pCurrTracked );
	}
	else if( pBestTracked )
	{
		SetLink( pBestTracked );
	}
	else if( !pPrevTracked )
	{
		ClearObject();
	}

	return GetObject();
}
示例#12
0
int CPROC MakeProcess( PSENTIENT ps, PENTITY peInit, PTEXT parameters )
{
	// parameters specify command and parameters to launch...
	// perhaps a working directory? May or may not want it
	// in the current directory...
	// /make process test WIDE("command arguments") WIDE("work path") <attributes?>
	// /make process test WIDE("notepad trigger.txt") 
	PSENTIENT ps2;
	PPROCESS process = New( PROCESS );
	TEXTCHAR MyPath[256];
	GetCurrentPath( MyPath, sizeof( MyPath ) );
	ps2 = CreateAwareness( peInit );
	MemSet( process, 0, sizeof( PROCESS ) );
	Log( WIDE("Have a process, and woke it up... setting the link") );
	SetLink( &peInit->pPlugin, iProcess, process );
	SetLink( &peInit->pDestroy, iProcess, DestroyProcess );
	Log( WIDE("Set the link, getting params...") );
	{
		PTEXT text, cmd = NULL;
		text = GetParam( ps, &parameters );
		if( text && TextIs( text, WIDE("\"") ) )
		{
	      Log( WIDE("Found a quote, getting command line") );
			while( (text = GetParam( ps, &parameters )) && !TextIs( text, WIDE("\"") ) )
			{
				cmd = SegAppend( cmd, SegDuplicate( text ) );
			}
			cmd->format.position.offset.spaces = 0;
			process->command = BuildLine( cmd );
			if( text ) // closed, and may have start path....
			{
				text = GetParam( ps, &parameters );
		   	if( text && TextIs( text, WIDE("\"") ) )
				{
					Log( WIDE("Found a quote, getting the path") );
					while( (text = GetParam( ps, &parameters )) && !TextIs( text, WIDE("\"") ) )
					{
						cmd = SegAppend( cmd, SegDuplicate( text ) );
		   		}
		   		cmd->format.position.offset.spaces = 0;
		   		process->directory = BuildLine( cmd );
				}
			}
		}
		else
		{
			DECLTEXT( msg, WIDE("Must specify process to execute in quotes (\")") );
			EnqueLink( &ps->Command->Output, &msg );
		WakeAThread( ps2 );
			return -1; // abort creation.
		}
	}
	Log2( WIDE("Starting %s in %s"), GetText( process->command ), GetText( process->directory ) );
	process->si.cb = sizeof( process->si );
	// remaining startup info members are NULL - specifying we do NOT care
	// why why when where how the process starts.
	if( StartProcess( process ) )
	{
		DECLTEXTSZ( msg, 256 );
		msg.data.size = snprintf( msg.data.data, 256*sizeof(TEXTCHAR), WIDE("Failed to start \"%s\" in \"%s\" error: %ld"),
										 GetText( process->command ),
										 GetText( process->directory ),
										 GetLastError() );
		EnqueLink( &ps->Command->Output, SegDuplicate( (PTEXT)&msg ) );
		WakeAThread( ps2 );
		return -1; // abort creation.
	}
	// well otherwise would seem we've launched a valid application
	// we have valid process and thread handles to it which can be monitored
	// and well that's about that.
	WakeAThread( ps2 );
	return 0;
}
示例#13
0
文件: link.cpp 项目: hfvw/wxExtension
const wxString wxExLink::GetPath(
    const wxString& text,
    int& line_no,
    int& column_no) const
{
    const wxString path(FindPath(text));
    wxString link(path);

#ifdef DEBUG
    wxLogMessage("+wxExLink::GetPath. text: " + text +
                 "\nlink: " + link + "\ncwd: " + wxGetCwd());
#endif

    SetLink(link, line_no, column_no);

    if (
        link.empty() ||
        // Otherwise, if you happen to select text that
        // ends with a separator, wx asserts.
        wxFileName::IsPathSeparator(link.Last()))
    {
        return wxEmptyString;
    }

    wxFileName file(link);
    wxString fullpath;

    if (file.FileExists())
    {
        file.MakeAbsolute();
        fullpath = file.GetFullPath();
    }
    else
    {
#ifdef DEBUG
        wxLogMessage("File " + link + " does not exist");
#endif
        if (
            file.IsRelative() &&
            m_STC != NULL &&
            m_STC->GetFileName().FileExists())
        {
            if (file.MakeAbsolute(m_STC->GetFileName().GetPath()))
            {
                if (file.FileExists())
                {
                    fullpath = file.GetFullPath();
                }
            }
            else
            {
                wxString pwd;

                if (wxGetEnv("PWD", &pwd))
                {
                    if (file.MakeAbsolute(pwd))
                    {
                        if (file.FileExists())
                        {
                            fullpath = file.GetFullPath();
                        }
                    }
                }
            }
#ifdef DEBUG
            wxLogMessage("Fullpath " + fullpath);
#endif
        }

        if (fullpath.empty())
        {
            // Check whether last word is a file.
            wxString word = path.AfterLast(' ').Trim();

            if (
                !word.empty() &&
                !wxFileName::IsPathSeparator(link.Last()) &&
                wxFileExists(word))
            {
                wxFileName file(word);
                file.MakeAbsolute();
                fullpath = file.GetFullPath();
                // And reset line or column.
                line_no = 0;
                column_no = 0;
#ifdef DEBUG
                wxLogMessage("Fullpath updated " + fullpath);
#endif
            }

            if (fullpath.empty() && !m_PathList.empty())
            {
                fullpath = m_PathList.FindAbsoluteValidPath(link);

                if (
                    fullpath.empty() &&
                    !word.empty() &&
                    SetLink(word, line_no, column_no))
                {
                    fullpath = m_PathList.FindAbsoluteValidPath(word);
                }
            }

            // Do nothing if fullpath.empty(),
            // as we return empty string if no path could be found.
#ifdef DEBUG
            wxLogMessage("Fullpath after pathlist update " + fullpath);
#endif
        }
    }

#ifdef DEBUG
    wxLogMessage("-wxExLink::GetPath: " + fullpath);
#endif
    return fullpath;
}
示例#14
0
int InitImage( PSENTIENT ps, PENTITY pe, PTEXT parameters )
{
	INDEX idx;
	for( idx = 0; idx < NUM_IMAGE_VARS; idx++ )
	{
      PTEXT saveparms = parameters;
		PTEXT arg;
		Image parent = GetLink( &FindContainer( pe )->pPlugin, iImage );
		arg = GetParam( ps, &parameters );
		if( IsNumber( arg ) )
		{
			PTEXT arg2 = GetParam( ps, &parameters );
			if( IsNumber( arg2 ) )
			{
            Image image;
				if( parent )
					image = MakeSubImage( parent
											  , 0, 0 // need other 2 arguments.
											  , atoi( GetText( arg ) )
											  , atoi( GetText( arg2 ) )
											  );
            else
					image = MakeImageFile( atoi( GetText( arg ) )
													, atoi( GetText( arg2 ) ) );
				SetLink( &pe->pPlugin, iImage, image );
				if( ps->CurrentMacro )
					ps->CurrentMacro->state.flags.bSuccess = TRUE;
				else
				{
					DECLTEXT( msg, "Invalid second parameter, expecting a number" );
               EnqueLink( &ps->Command->Output, &msg );
				}
				// if more args - warn?
			}
		}
		else
		{
         Image image;
			// expect that the remainder is a name..
			parameters = saveparms;
			arg = GetFileName( ps, &parameters );
         // loaded image file doesn't care for parent status...
			image = LoadImageFile( GetText( arg ) );
			if( image )
			{
				SetLink( &pe->pPlugin, iImage, image );
				if( ps->CurrentMacro )
					ps->CurrentMacro->state.flags.bSuccess = TRUE;
				else
				{
					DECLTEXT( msg, "Failed to load image..." );
               EnqueLink( &ps->Command->Output, &msg );
				}
			}
		}
		AddVolatileVariable( pe, ImageVars + idx, 0 );
		{
			int n;
			for( n = 0; n < NUM_METHODS; n++ )
            AddMethod( pe, ImageMethods + n );
		}

	}
	return 0; // return success
}