void EXPECT_CALLHTTPExProtoHandle()
 {
     EXPECT_CALL(m_HTTPExHandle, AddReference()).WillRepeatedly(testing::Return(1));
     EXPECT_CALL(m_HTTPExHandle, ReleaseReference()).WillRepeatedly(testing::Return(1));
 }
void CQuadTree::AddReference( Box3f box, CEntity * pEntity, CQuadNode * node )  {

    assert( m_iLevels > 1 ); 

    int iNumInside = 0;

    Box3f boxTemp =  box;
    Box3f boxEnt = *pEntity->GetBoundingBox();

    // move box to the entity's height
    boxTemp.Center().Y() = boxEnt.Center().Y();
    boxTemp.Extent(1) = 100.0f; //extend this box infinitely

    bool bEntInQuad = false;

    Vector3f vBoxVerts[8];
    bool abValid[8] = { 1,1,1,1,1,1,1,1 };//{ 0,0,0,0,0,0,0,0 };
    bool bEntBoxInNode = false;
    bool bNodeInEntBox = false;

    //switch(TestIntersection( boxTemp,  boxEnt ) ) 
    switch(TestIntersection( boxEnt, boxTemp ) ) 
    {
        case true:  // box intersects
            node->m_EntMap[pEntity->GetId()] = pEntity; 
            bEntInQuad = true;  // find if the children intersect too
            break;

        case false:  // ent box is INSIDE or OUTSIDE the node
            // get vertices for the bounding box                
            boxEnt.ComputeVertices(vBoxVerts);

            // if entities box is contained in node box
            for (int j=0; j<8; j++ ) {
                if (InBox( vBoxVerts[j], boxTemp))  {
                    bEntBoxInNode = true;
                }
            }

            if (bEntBoxInNode == true)  {
            //if (ContOrientedBox (8, vBoxVerts, abValid, node->m_BBox))  {
                node->m_EntMap[pEntity->GetId()] = pEntity; //entity is in this node
                bEntInQuad = true;  // find out what child quads also contain this
                iNumInside++;                
            }
            else { // OUTSIDE or entities box contains the bounding box!
                boxTemp.ComputeVertices(vBoxVerts);
                
                // if node box  is contained in entities box
                for (int j=0; j<8; j++ ) {
                    if (InBox( vBoxVerts[j], boxEnt))  {
                        bNodeInEntBox = true;
                    }
                }

                if (bNodeInEntBox == true)  {
                //if (ContOrientedBox (8, vBoxVerts, abValid, boxTemp))  {
                    node->m_EntMap[pEntity->GetId()] = pEntity; //entity is in this node
                    bEntInQuad = true;  // find out what child quads also contain this

                }
                else {
                    // entity is outside, so don't add
                    bEntInQuad = false;
                    return;
                }
            }
            break;
    }

    // now this box will also intersect/be contained in the children as well
    if (bEntInQuad == true )  {
        //check if we need to subdivide even further
        if (iNumInside >= MAX_ENTS_PER_NODE)  {
            m_iLevels++;  //increase the number of levels
            SubDivide(node, m_iLevels-1);
        }

        if (node->m_pChildNode[NE] != NULL)  {
            AddReference( node->m_pChildNode[NE]->m_BBox, pEntity, node->m_pChildNode[NE]);
            //node->m_pChildNode[NE]->m_EntMap[pEntity->GetId()] = pEntity;
        }
        if (node->m_pChildNode[NW] != NULL)  {
            AddReference( node->m_pChildNode[NW]->m_BBox, pEntity, node->m_pChildNode[NW]);
            //node->m_pChildNode[NW]->m_EntMap[pEntity->GetId()] = pEntity;
        }
        if (node->m_pChildNode[SE] != NULL)  {
            AddReference( node->m_pChildNode[SE]->m_BBox, pEntity, node->m_pChildNode[SE]);
            //node->m_pChildNode[SE]->m_EntMap[pEntity->GetId()] = pEntity;
        }
        if (node->m_pChildNode[SW] != NULL)  {
            AddReference( node->m_pChildNode[SW]->m_BBox, pEntity, node->m_pChildNode[SW]);
            //node->m_pChildNode[SW]->m_EntMap[pEntity->GetId()] = pEntity;
        }        
    }

    return;
}
void ElementTabSet::OnAttach(Core::Element * ROCKET_UNUSED(element))
{
	AddReference();
}
void ElementTabSet::OnAttach(Core::Element * ROCKET_UNUSED_PARAMETER(element))
{
	ROCKET_UNUSED(element);

	AddReference();
}
Beispiel #5
0
	void SceneState::List_PostRenderObject_TrackRef_Type::push_back(PostRenderObject& item)
	{
		AddReference( item.m_pRenderObject, REFERENCE_TYPE_SCENE_STATE);
		List_PostRenderObject_Type::push_back(item);
	}
RageFileObj *RageFileManager::OpenForWriting( CString sPath, int mode, RageFile &p, int &err )
{
	LockMut( *g_Mutex );

	/*
	 * The value for a driver to open a file is the number of directories and/or files
	 * that would have to be created in order to write it, or 0 if the file already exists.
	 * For example, if we're opening "foo/bar/baz.txt", and only "foo/" exists in a
	 * driver, we'd have to create the "bar" directory and the "baz.txt" file, so the
	 * value is 2.  If "foo/bar/" exists, we'd only have to create the file, so the
	 * value is 1.  Create the file with the driver that returns the lowest value;
	 * in case of a tie, earliest-loaded driver wins.
	 *
	 * The purpose of this is to create files in the expected place.  For example, if we
	 * have both C:/games/StepMania and C:/games/DWI loaded, and we're writing
	 * "Songs/Music/Waltz/waltz.sm", and the song was loaded out of
	 * "C:/games/DWI/Songs/Music/Waltz/waltz.dwi", we want to write the new SM into the
	 * same directory (if possible).  Don't split up files in the same directory any
	 * more than we have to.
	 *
	 * If the given path can not be created, return -1.  This happens if a path
	 * that needs to be a directory is a file, or vice versa.
	 */
	NormalizePath( sPath );

	vector< pair<int,int> > Values;
	unsigned i;
	for( i = 0; i < g_Drivers.size(); ++i )
	{
		LoadedDriver &ld = g_Drivers[i];
		const CString path = ld.GetPath( sPath );
		if( path.size() == 0 )
			continue;

		const int value = ld.driver->GetPathValue( path );
		if( value == -1 )
			continue;

		Values.push_back( pair<int,int>( i, value ) );
	}

	stable_sort( Values.begin(), Values.end(), SortBySecond );

	err = 0;
	for( i = 0; i < Values.size(); ++i )
	{
		const int driver = Values[i].first;
		LoadedDriver &ld = g_Drivers[driver];
		const CString path = ld.GetPath( sPath );
		ASSERT( path.size() );

		int error;
		RageFileObj *ret = ld.driver->Open( path, mode, p, error );
		if( ret )
		{
			AddReference( ret, ld.driver );
			return ret;
		}

		/* The drivers are in order of priority; if they all return error, return the
		 * first.  Never return ERROR_WRITING_NOT_SUPPORTED. */
		if( !err && error != RageFileDriver::ERROR_WRITING_NOT_SUPPORTED )
			err = error;
	}

	if( !err )
		err = EEXIST; /* no driver could write */

	return NULL;
}
Beispiel #7
0
/* Find pattern in text string */
static Boolean DoSearch
    (
    Char*   text,           /* text string */
    UInt16  size,           /* size of text */
    Char*   pattern,        /* pattern to search for */
    UInt8   matchMode,      /* indicates if the search should be
                               case-sensitive or not */
    UInt16  xlitMode,       /* how should we transliterate? */
    UInt16* pos,            /* start position, will contain the position
                               of the pattern if found */
    UInt16* endFound,       /* end of position where pattern is found */
    Int16   depth           /* depth of this page */
    )
{
    Int16   startPos;
    Int16   charsize;
    Int16   topcharsize;
    UInt16  patternLen;
    UInt16  wplen;
    Int16   i;
    Int16   j;
    Int16   top;
    WChar   ch;
    WChar   wpattern[ 2 * ( MAX_PATTERN_LEN+1 ) ];
    Boolean guaranteed8Bits;
#ifdef BUILD_ARMLETS
    Boolean        useArmlet;
    void*          DoSearchArmlet;
    ArmSearchType  armData;
    MemHandle      armChunkH = NULL;
#endif
    static UInt8   lastMatchMode = SEARCH_UNINITIALIZED;
    static UInt16  lastXlitMode  = 0;
    static Char    xlat[ 256 ];
    static Boolean multibyteCharFix;
    static WChar   multibyteCharFixTo;
#ifdef SUPPORT_TRANSLITERATION
    static Boolean symmetricXlit;
#endif

    multibyteCharFix = false;
    if ( lastMatchMode != matchMode || xlitMode != lastXlitMode ) {
#ifdef SUPPORT_TRANSLITERATION
        symmetricXlit = SetTransliteration( xlitMode, xlat, &multibyteCharFix, 
                            &multibyteCharFixTo );
#else
        for ( i = 0 ; i < 256 ; i++ ) {
            xlat[ i ] = i;
        }
#endif
        if ( ! ( matchMode & SEARCH_CASESENSITIVE ) ) {
            for ( i = 0; i < 256; i++ )
                xlat[ i ] = TxtGlueLowerChar( ( UInt8 )xlat[ i ] );
        }
        lastMatchMode = matchMode;
    }

    startPos    = *pos;
    charsize    = 1;
    patternLen  = StrLen( pattern );

    /* expand wchar string in advance*/
    i = wplen = 0;
    while ( i < patternLen ) {
        charsize = TxtGlueGetNextChar( pattern, i, &ch );
        if ( charsize == 1 ) {
#ifdef SUPPORT_TRANSLITERATION
            if ( symmetricXlit ) {
#endif
                ch = xlat[ (UInt8) ch ];
#ifdef SUPPORT_TRANSLITERATION
            }
            else if ( ! ( matchMode & SEARCH_CASESENSITIVE ) ) {
                ch = TxtGlueLowerChar( (UInt8) ch );
            }
#endif
        }
        else if ( multibyteCharFix )
            ch = multibyteCharFixTo;

        wpattern[ wplen ] = ch;

        i       += charsize;
        wplen   += 1;
    }

    guaranteed8Bits = DeviceUses8BitChars();
#ifdef BUILD_ARMLETS
    useArmlet       = false;
    DoSearchArmlet  = NULL;

    if ( SupportArmlets() && guaranteed8Bits ) {
        armChunkH = DmGetResource( ArmletResourceType, armDoSearch );
        if ( armChunkH != NULL ) {
            DoSearchArmlet = MemHandleLock( armChunkH );

            armData.size     = size;
            armData.depth    = depth;
            armData.text     = text;
            armData.wpattern = wpattern;
            armData.wplen    = wplen;
            armData.xlat     = xlat;

            useArmlet = true;
        }
    }
#endif

    i           = top = *pos;
    j           = 0;
    topcharsize = 0;
    while ( j < wplen && i < size ) {
#ifdef BUILD_ARMLETS
        if ( useArmlet ) {
            armData.i     = i;
            armData.j     = j;
            armData.top   = top;

            ch    = (WChar) PceNativeCall( DoSearchArmlet, &armData );

            i     = armData.i;
            j     = armData.j;
            top   = armData.top;

            if ( wplen <= j || size <= i )
                break;
            charsize = topcharsize = 1;
        }
        else
#endif
        if ( guaranteed8Bits ) {
            ch = DoSearch8BitText( text, size, wpattern, wplen, xlat,
                     &i, &j, &top, 0 < depth );
            if ( wplen <= j || size <= i )
                break;
            charsize = topcharsize = 1;
        }
        else
            charsize = TxtGlueGetNextChar( text, i, &ch );

        if ( j == 0 )
            topcharsize = charsize;

        if ( ch == '\0' ) {
            if ( 0 < depth ) {
                /* if function is anchor, store it to queue */
                if ( text[ i + 1 ] == 0x0A /* ANCHOR_START */ ){
                    UInt16 reference;
                    Int16  q;
                    Int16  listSize;

                    reference = 256 * (UInt8)text[ i + 2 ] +
                        (UInt8)text[ i + 3 ];

                    listSize = ListSize( searchQueue );
                    for ( q = 0; q < listSize; q ++ ){
                        /*look up in queue, append if not exist*/
                        QueueNode *node;
                        node = ListGet( searchQueue, q + 1 );
                        if ( node->reference == reference )
                            break;
                    }
                    if ( q == listSize )
                        AddReference( reference, depth );

                }
            }
            i  += 2 + ( text[ i + 1 ] & 0x07 );
            top = i;
            j   = 0;
            continue;
        }
        if ( charsize == 1 )
            ch = xlat[ (UInt8) ch ];
        else if ( multibyteCharFix )
            ch = multibyteCharFixTo;
        if ( ch != wpattern[ j ] ) {
            top += topcharsize;
            i    = top;
            j    = 0;
            continue;
        }
        i += charsize;
        j += 1;
    }
#ifdef BUILD_ARMLETS
    if ( armChunkH != NULL ) {
        MemHandleUnlock( armChunkH );
        DmReleaseResource( armChunkH );
    }
#endif
    if ( j == wplen ) {
        *pos      = top;
        *endFound = i;
        return true;
    }
    else {
        return false;
    }
}
Beispiel #8
0
// What to do if player is seen
// default to change state to chasing
void cMonster::EventSeePlayer(cEntity * a_SeenPlayer)
{
	m_Target = a_SeenPlayer;
	AddReference(m_Target);
}
Beispiel #9
0
bool C4StartupNetListEntry::OnReference()
{
	// wrong type / still busy?
	if (!pRefClient || pRefClient->isBusy())
		return true;
	// successful?
	if (!pRefClient->isSuccess())
	{
		// couldn't get references
		SetError(pRefClient->GetError(), TT_RefReqWait);
		return true;
	}
	// Ref getting done!
	pIcon->SetAnimated(false, 1);
	// Get reference information from client
	C4Network2Reference **ppNewRefs=nullptr; int32_t iNewRefCount;
	if (!pRefClient->GetReferences(ppNewRefs, iNewRefCount))
	{
		// References could be retrieved but not read
		SetError(LoadResStr("IDS_NET_ERR_REFINVALID"), TT_RefReqWait);
		delete [] ppNewRefs;
		return true;
	}
	if (!iNewRefCount)
	{
		// References retrieved but no game open: Inform user
		sInfoText[1].Copy(LoadResStr("IDS_NET_INFONOGAME"));
		UpdateText();
	}
	else
	{
		// Grab references, count players
		C4StartupNetListEntry *pNewRefEntry = this; int iPlayerCount = 0;
		for (int i = 0; i < iNewRefCount; i++)
		{
			pNewRefEntry = AddReference(ppNewRefs[i], pNewRefEntry->GetNextLower(ppNewRefs[i]->getSortOrder()));
			iPlayerCount += ppNewRefs[i]->Parameters.PlayerInfos.GetActivePlayerCount(false);
		}
		// Count player
		sInfoText[1].Format(LoadResStr("IDS_NET_INFOGAMES"), (int) iNewRefCount, iPlayerCount);
		UpdateText();
	}
	delete [] ppNewRefs;
	// special masterserver handling
	if (eQueryType == NRQT_Masterserver)
	{
		// masterserver: schedule next query
		sInfoText[1].Format(LoadResStr("IDS_NET_INFOGAMES"), (int) iNewRefCount);
		SetTimeout(TT_Masterserver);
		return true;
	}
	// non-masterserver
	if (iNewRefCount)
	{
		// this item has been "converted" into the references - remove without further feedback
		return false;
	}
	else
	{
		// no ref found on custom adress: Schedule re-check
		SetTimeout(TT_RefReqWait);
	}
	return true;
}
Beispiel #10
0
 void IncrementObjectCount(void)
     {
         AddReference();
     }
LRESULT CALLBACK RefDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_INITDIALOG:
		refchild::hWnd = hWnd;
		refchild::hWndRefBox = GetDlgItem(hWnd,IDC_REF_BOX);
		refchild::hWndRefList = GetDlgItem(hWnd,IDC_LIST_REF);
		refchild::hWndQuadLbl = GetDlgItem(hWnd,IDC_QUAD_LBL);
		refchild::hWndIDLbl = GetDlgItem(hWnd,IDC_ID_LBL);
		refchild::hWndRefIDLbl = GetDlgItem(hWnd,IDC_REFID_LBL);
		refchild::hWndQuadTxt = GetDlgItem(hWnd,IDC_REFEDIT_QUADTYPE);
		refchild::hWndIDTxt = GetDlgItem(hWnd,IDC_REFEDIT_ID);
		refchild::hWndRefIDTxt = GetDlgItem(hWnd,IDC_REFEDIT_REFID);
		refchild::hWndAddBtn = GetDlgItem(hWnd,IDC_REFEDIT_ADD);
		refchild::hWndRemoveBtn = GetDlgItem(hWnd,IDC_REFEDIT_DELETE);
		refchild::hWndChangeBtn = GetDlgItem(hWnd,IDC_REFEDIT_CHANGE);
		refchild::hWndRefByBox = GetDlgItem(hWnd,IDC_REFBY_BOX);
		refchild::hWndRefByList = GetDlgItem(hWnd,IDC_LIST_REFFEDBY);
		refchild::hWndQSelOKBtn = GetDlgItem(hWnd, IDC_REFEDIT_OK);
		return 1;
		break;
	case WM_QUIT:
	case WM_CLOSE:
	case WM_SIZE:
		SetWindowLong(hWnd,DWL_MSGRESULT,ProcessRefResize(LOWORD(lParam), HIWORD(lParam)));
		//MessageBox(hWnd, L"LOL", L"EFEW",MB_OK);
		break;
	case WM_ERASEBKGND:
		return true;
		break;
	case WM_CTLCOLORSTATIC:
		SetBkMode((HDC)wParam, TRANSPARENT);
		return (LRESULT)(HBRUSH)GetStockObject(NULL_BRUSH);
		break;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDC_LIST_REF:
			switch (HIWORD(wParam))
			{
			case LBN_SELCHANGE:
				DisplayReference();
				break;
			case LBN_DBLCLK:
				if (!quadselectmode)
				{
					unsigned long cursel = (unsigned long)SendMessage(refchild::hWndRefList, LB_GETCURSEL, 0,0);
					if (cursel != LB_ERR)
					{
						unsigned long uniqueid = (unsigned long)SendMessage(refchild::hWndRefList, LB_GETITEMDATA, cursel, 0);
						unsigned long quadnum = dmmfile.getQuadNum(uniqueid, GETQUAD_QUADORDERSORT);
						SendMessage(maindlg::hWndQuadList, LB_SETCURSEL, (WPARAM)quadnum, 0);
						SetCurQuad();
						DisplayQuad();
					}
				}
				break;
			}
			break;
		case IDC_LIST_REFFEDBY:
			switch (HIWORD(wParam))
			{
			case LBN_DBLCLK:
					unsigned long cursel = (unsigned long)SendMessage(refchild::hWndRefByList, LB_GETCURSEL, 0,0);
					if (cursel != LB_ERR)
					{
						unsigned long uniqueid = (unsigned long)SendMessage(refchild::hWndRefByList, LB_GETITEMDATA, cursel, 0);
						unsigned long quadnum = dmmfile.getQuadNum(uniqueid, GETQUAD_QUADORDERSORT);
						SendMessage(maindlg::hWndQuadList, LB_SETCURSEL, (WPARAM)quadnum, 0);
						SetCurQuad();
						DisplayQuad();
					}
				break;
			}
			break;
		case IDC_REFEDIT_CHANGE:
			if (quadselectmode)
			{
				SetQuadSelectMode(false);
				addingref = false;
				DisplayReference();
				EnableWindow(refchild::hWndRefList, true);
			}
			else
			{
				ChangeReference();
			}
			break;
		case IDC_REFEDIT_ADD:
			EnableWindow(refchild::hWndRefList, false);
			SetQuadSelectMode(true);
			addingref = true;
			break;
		case IDC_REFEDIT_DELETE:
			RemoveReference();
			break;
		case IDC_REFEDIT_OK:
			if (quadselectmode)
			{
				if (addingref)
				{
					AddReference();
				}
				else
				{
					SetQuadSelectMode(false);
				}
			}
			else SetQuadSelectMode(true);
			break;
		}
	default:;
		//MessageBox(hWnd, L"EWFGEW", L"EWFEW", MB_OK);
	}	
	return 0;
}