当前位置: 首页>>代码示例>>C++>>正文


C++ LList类代码示例

本文整理汇总了C++中LList的典型用法代码示例。如果您正苦于以下问题:C++ LList类的具体用法?C++ LList怎么用?C++ LList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

void AlliancesWindow::Update()
{   
    //
    // Build a list of all teams;

    LList<Team *> teams;
    for( int i = 0; i < g_app->GetWorld()->m_teams.Size(); ++i )
    {
        Team *team = g_app->GetWorld()->m_teams[i];
        teams.PutData( team );
    }


    //
    // Now put the other teams in, in alliance order

    int currentIndex = 0;

    while( teams.Size() > 0 )
    {
        Team *baseTeam = teams[0];
        m_teamOrder[currentIndex] = baseTeam->m_teamId;
        ++currentIndex;
        teams.RemoveData(0);

        for( int i = 0; i < teams.Size(); ++i )
        {
            Team *possibleAlly = teams[i];
            if( possibleAlly->m_allianceId == baseTeam->m_allianceId )
            {
                m_teamOrder[currentIndex] = possibleAlly->m_teamId;
                ++currentIndex;
                teams.RemoveData(i);
                --i;
            }
        }
    }

    //
    // Are there any votes we can see?
    
    for( int i = 0; i < MAX_TEAMS; ++i )
    {
        m_votes[i] = -1;
    }    

    currentIndex = 0;
    
    for( int i = 0; i < g_app->GetWorld()->m_votingSystem.m_votes.Size(); ++i )
    {
        if( g_app->GetWorld()->m_votingSystem.m_votes.ValidIndex(i) )
        {
            Vote *vote = g_app->GetWorld()->m_votingSystem.m_votes[i];
            if( vote->m_result == Vote::VoteUnknown &&
                vote->CanSeeVote( g_app->GetWorld()->m_myTeamId ) )
            {
                m_votes[currentIndex] = i;
                ++currentIndex;
            }
        }
    }


    //
    // Make sure we are the right size
   
    m_h = 120 + g_app->GetWorld()->m_teams.Size() * 42;
    m_h += currentIndex * 45;    

    if( currentIndex > 0 ) m_h += 10;
    
    m_h = max(m_h, 300 );

    GetButton("Close")->m_y = m_h - 25;
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:75,代码来源:alliances_window.cpp

示例2: firstKTowns

//Подточка в)
LList<int> firstKTowns(LList<City> cities, LList<int> filteredCitiesByDistance, int k)
{
	int currentCities = 0; // not used ???
	int MaxNumberOfFamousPlaces = 0;	// not used ???
	int CurrNumbOfFamousPlaces = 0; // not used ???
	int* arr = new arr[filteredCitiesByDistance.len()]; // ???
	int i = 0;
	cities.IterStart();
	LList<int> temp;
	elem<City>* e = cities.Iter();
	City a;
	while (e)
	{
		filteredCitiesByDistance.IterStart();
		elem<int>* p = filteredCitiesByDistance.Iter();
		while (p)
		{
			a = e->inf;
			if (a.ID == p->inf)
			{
				arr[i] = a.FamousPlaces;
				i++;
			}
			p = p->link;
		}
		e = e->link;
	}

	for (size_t j = 0; j < filteredCitiesByDistance.len(); j++)
	{
		for (size_t p = 0; p < filteredCitiesByDistance.len() - 1; p++)
		{
			if (arr[j] < arr[p + 1]) swap(arr[j], arr[p + 1]);
		}
	}

	for (size_t q = 0; q < k; q++)
	{
		cities.iterStart();
		elem<City>* p = cities.Iter();
		while (p)
		{
			City b = p->inf;
			if (arr[q] == b.FamousPlaces)
			{
				temp.ToEnd(b.ID);
			}
		}
	}
	delete[]arr;
	return temp;
}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:53,代码来源:zad1_fn81190.cpp

示例3: main

int main() {
  graph<Person> g;

  LList<string> peshoLikes;
  peshoLikes.ToEnd("rakia");
  peshoLikes.ToEnd("salata");
  peshoLikes.ToEnd("musaka");
  peshoLikes.ToEnd("bob");

  LList<string> pepaLikes;
  pepaLikes.ToEnd("nutela");
  pepaLikes.ToEnd("vino");
  pepaLikes.ToEnd("musaka");

  LList<string> draganLikes;
  draganLikes.ToEnd("rakia");
  draganLikes.ToEnd("nutela");
  draganLikes.ToEnd("bob");

  Person pesho("Pesho", 20, peshoLikes);
  Person ivan("Ivan", 25, LList<string>());
  Person petkan("Petkan", 22, LList<string>());
  Person mimi("Mimi", 20, LList<string>());
  Person mariika("Mariika", 22, LList<string>());
  Person pepa("Pepa", 20, pepaLikes);
  Person dragan("Dragan", 20, draganLikes);

  g.addTop(pesho);
  g.addTop(ivan);
  g.addTop(petkan);
  g.addTop(mimi);
  g.addTop(mariika);
  g.addTop(pepa);
  g.addTop(dragan);

  g.addRib(pesho, ivan);
  g.addRib(pesho, petkan);
  g.addRib(pesho, mimi); // result
  g.addRib(pesho, mariika);

  g.addRib(petkan, mimi);
  g.addRib(petkan, mariika);
  g.addRib(petkan, pepa);
  g.addRib(mimi, dragan);

  // neighbours(g, pesho).print();

  // problem_1(g, pesho);
  problem_2(g, pesho);
  return 0;
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:51,代码来源:graphproblems.cpp

示例4: Multi

	LongInt* Multi(LongInt* otherInt) //multiplication
	{
		LongInt *result = new LongInt();
		//sign
		if(intData->head->value == otherInt->intData->head->value)
			result->intData->head->value = 0;
		else
			result->intData->head->value = 1;

		LList* myList = intData;
        LNode *myNode = intData->FirstRight();
		LList *otherList = otherInt->intData;

        //the length of the result
		for(int i = 0; i < myList->count + otherList->count; i++)
		{
			LNode* zeroNode = new LNode();
			zeroNode->value = 0;
			zeroNode->next = zeroNode->prev = NULL;
			result->intData->InsertLeft(zeroNode);
			zeroNode = NULL;
		}


		for(int i = 1; myNode != myList->head; myNode = myNode->prev, i++)
		{
			LNode* otherNode = otherList->FirstRight();
			for(int j = 1; otherNode != otherList->head; otherNode = otherNode->prev, j++)
			{
				int myValue =  myNode->value;
				int otherValue = otherNode->value;
				int tempResult = myValue * otherValue;
				int carry = OverFlow(tempResult);
				tempResult = tempResult - carry * (int)pow(10.0, (double)EVERY_NODE_LEN);

				LNode* resultNode = result->intData->CountFromRight(i + j - 1);
				LNode* carryNode = result->intData->CountFromRight(i + j);

				resultNode->value += tempResult; //may carry
				int carry2 = OverFlow(resultNode->value);
				resultNode->value = resultNode->value - carry2 * (int)pow(10.0, (double)EVERY_NODE_LEN);

				carryNode->value += carry + carry2; //may carry
				int carry3 = OverFlow(carryNode->value);
				carryNode->value = carryNode->value - carry3 * (int)pow(10.0, (double)EVERY_NODE_LEN);

				carryNode->prev->value += carry3;


			}
		}

		LNode* delNode = result->intData->head->next;
		while(delNode->value == 0)
		{
			result->intData->head->next = result->intData->head->next->next;
			result->intData->head->next->prev = result->intData->head;
			delete delNode;
			delNode = result->intData->head->next;
		}

		return result;

	}
开发者ID:jasminelu,项目名称:LongInt,代码行数:64,代码来源:CS610Project1.cpp

示例5: main

int main()
{

	LList<int> llist;
	LList<int>::iterator it = llist.begin();
	LList<int>::iterator it2 = llist.end();
	it2 = LList<int>::iterator(it);
#if 1
	it  = llist.insert(it,1);
	it  = llist.insert(it,2);
	it  = llist.insert(it,3);
	it = llist.begin();
	cout<<"--------insert-------------"<<endl;
	for(;it != llist.end();it++)
		cout<<*it<<endl;

	llist.clear();

	llist.push_back(11);
	llist.push_back(12);
	llist.push_back(13);
	llist.erase(llist.begin());
	cout<<"--------push_back-------------"<<endl;
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	llist.clear();
	cout<<"--------size-------------"<<llist.size()<<endl;
	llist.push_back(14);
	llist.push_back(15);
	llist.push_back(16);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------transfer-------------"<<llist.size()<<endl;
	LList<int>::iterator first= ++llist.begin();
	LList<int>::iterator last= llist.end();
	llist.transfer(++llist.begin(),++first,last);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------reverse-------------"<<llist.size()<<endl;
	llist.reverse();
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
#endif		
	return 0;
}
开发者ID:loganwu,项目名称:ServerForMogan,代码行数:45,代码来源:listExp.cpp

示例6: RemoveUser

void RemoveUser(){
	system("CLS");
	string inputUsername, inputPassword; //for storage
	char input;
	bool Auth = false; //Auth variable
	
	cout << "\t\t" << "Account Removal Service" << endl;
	cout << "\t\t"; cout << "Enter Username: "; //get username
	getline(cin, inputUsername, '\n');
	cin.clear();

	cout << "\t\t"; cout << "Enter Password: "; //get password
	inputPassword = MaskedInput();
	cin.clear();

	cout << endl << "\t\t" << "Authenticating..." << endl;
	cout << "\t\t"; system("pause");
	Auth = S.authenticate(inputUsername, inputPassword); //Authenticate with the security class

	do{
		system("CLS");

		if (Auth){
			cout << "\t\t" << "Your Account Will be Deleted. Continue?" << endl;
			cout << "\t\t" << "[Y/N] "; cin >> input;
			if (input == 'y' || input == 'Y'){
				cout << "\t\t" << "Removing Data..." << endl;
				int deleted2 = remove((inputUsername + "Status").c_str());
				int deleted1 = remove(inputUsername.c_str());
				
				if (deleted1 != 0 && deleted2 != 0){
					perror("\t\tError deleting files!\n");
				}else{
					cout << "\t\tData successfully removed.\n";
					cout << "\t\t"; system("pause");
				}

				LList<string> *listofusers = new LList<string>();
				ifstream s("Username.txt");
				string users;
				while (getline(s, users)){
					listofusers->appendData(users);
				}

				listofusers->removeData(inputUsername);
				listofusers->FileWrite("Username.txt");
				return;

			}else if (input == 'n' || input == 'N'){
				cout << "\t\t" << "Account Deletion Process Terminated." << endl;
				cout << "\t\t"; system("pause");
				return;
			}else{
				cout << "\t\t" << "Invalid Input." << endl;
				cout << "\t\t"; system("pause");
			}
		}else{
			cout << "\t\t" << "Authentication Failed." << endl;
			cout << "\t\t"; system("pause");
			return;
		}
	} while (true);
开发者ID:bradleywernick,项目名称:Team-5,代码行数:62,代码来源:Interface.cpp

示例7: ReadData

void ReadData ( const char *inFilename,
                FILE *infile,
                LList<BranchPtr> &library )
{
   printf ( "Reading from file '%s'\n", inFilename );

   char line [128];
   LList<BranchPtr> *current = 0;

   while ( fgets ( line, sizeof(line), infile ) )
   {
      if ( StripComments ( line ) )
      {
         if ( line[0] == '[' )
         {
            // We have found the start of a new opening continuation

            current = &library;
            printf ( "processing %s\n", line );
         }
         else
         {
            // We have found the next move in the current continuation

            if ( !current )
            {
               fprintf ( stderr,
                         "Error:  move '%s' is not in a continuation!\n",
                         line );

               exit(1);
            }

            int len = (int) strlen(line);
            int isValid = 0;

            if ( len == 4 || (len == 5 && line[4] == '?') )
            {
               int x1 = line[0] - 'a';
               int y1 = line[1] - '1';
               int x2 = line[2] - 'a';
               int y2 = line[3] - '1';

               if ( x1 >= 0 && x1 <= 7 &&
                    y1 >= 0 && y1 <= 7 &&
                    x2 >= 0 && x2 <= 7 &&
                    y2 >= 0 && y2 <= 7 )
               {
                  isValid = 1;
                  unsigned short source = (x1+2) + (y1+2)*12;
                  unsigned short dest   = (x2+2) + (y2+2)*12;
                  unsigned short move   = (source << 8) | dest;

                  // First, see if this move is already there...
                  Branch *b = 0;

                  for ( unsigned j=0; j < current->numItems(); j++ )
                  {
                     Branch *x = (*current)[j];
                     if ( x->move == move )
                     {
                        b = x;
                        break;
                     }
                  }

                  if ( !b )
                  {
                     // This branch wasn't found, so create it!

                     b = new Branch;
                     if ( !b )
                     {
                        fprintf ( stderr, "Error: out of memory!\n" );
                        exit(1);
                     }

                     b->isBad = (line[4] == '?');
                     b->move  = move;

                     if ( current->addToBack ( b ) != DDC_SUCCESS )
                     {
                        fprintf ( stderr, "Error adding branch to node!\n" );
                        exit(1);
                     }
                  }

                  current = &(b->replies);
               }
            }

            if ( !isValid )
            {
               fprintf ( stderr,
                         "Error:  invalid move syntax: '%s'\n",
                         line );
               exit(1);
            }
         }
      }
//.........这里部分代码省略.........
开发者ID:LiosanGOG,项目名称:chenard,代码行数:101,代码来源:obt.cpp

示例8: START_PROFILE

void Nuke::FindTarget( int team, int targetTeam, int launchedBy, Fixed range, Fixed *longitude, Fixed *latitude, int *objectId )
{
    START_PROFILE("Nuke::FindTarget");
    
    WorldObject *launcher = g_app->GetWorld()->GetWorldObject(launchedBy);
    if( !launcher ) 
    {
        END_PROFILE("Nuke::FindTarget");
        return;
    }

    LList<int> validTargets;
        
    for( int i = 0; i < g_app->GetWorld()->m_objects.Size(); ++i )
    {
        if( g_app->GetWorld()->m_objects.ValidIndex(i) )
        {
            WorldObject *obj = g_app->GetWorld()->m_objects[i];
            if( obj->m_teamId == targetTeam &&
                obj->m_seen[team] &&
                !obj->IsMovingObject() )
            {
                Fixed distanceSqd = g_app->GetWorld()->GetDistanceSqd( launcher->m_longitude, launcher->m_latitude, obj->m_longitude, obj->m_latitude);
                if( distanceSqd <= range * range )
                {                    
                    int numTargetedNukes = CountTargetedNukes( team, obj->m_longitude, obj->m_latitude );
                    
                    if( (obj->m_type == WorldObject::TypeRadarStation && numTargetedNukes < 2 ) ||
                        (obj->m_type != WorldObject::TypeRadarStation && numTargetedNukes < 4 ) )
                    {
                        validTargets.PutData(obj->m_objectId);
                    }
                }
            }
        }
    }

    if( validTargets.Size() > 0 )
    {
        int targetId = syncrand() % validTargets.Size();
        int objIndex = validTargets[ targetId ];
        WorldObject *obj = g_app->GetWorld()->GetWorldObject(objIndex);
        if( obj )
        {
            *longitude = obj->m_longitude;
            *latitude = obj->m_latitude;
            *objectId = obj->m_objectId;
            END_PROFILE("Nuke::FindTarget");
            return;
        }
    }

    Team *friendlyTeam = g_app->GetWorld()->GetTeam( team );

    int maxPop = 500000;        // Don't bother hitting cities with less than 0.5M survivors

    for( int i = 0; i < g_app->GetWorld()->m_cities.Size(); ++i )
    {
        if( g_app->GetWorld()->m_cities.ValidIndex(i) )
        {
            City *city = g_app->GetWorld()->m_cities[i];

            if( !g_app->GetWorld()->IsFriend( city->m_teamId, team) && 
				g_app->GetWorld()->GetDistanceSqd( city->m_longitude, city->m_latitude, launcher->m_longitude, launcher->m_latitude) <= range * range)               
            {
                int numTargetedNukes = CountTargetedNukes(team, city->m_longitude, city->m_latitude);
                int estimatedPop = City::GetEstimatedPopulation( team, i, numTargetedNukes );
                if( estimatedPop > maxPop )
                {
                    maxPop = estimatedPop;
                    *longitude = city->m_longitude;
                    *latitude = city->m_latitude;
                    *objectId = -1;
                }
            }
        }
    }
    
    END_PROFILE("Nuke::FindTarget");
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:80,代码来源:nuke.cpp

示例9: TestLList

int TestLList()
{
	LList<char *> *llist = new LList<char *>();
	TEST_ASSERT(llist);

	TEST_ASSERT(!llist->valid((unsigned int)-1));
	TEST_ASSERT(!llist->valid(1));
	TEST_ASSERT(!llist->valid(0));

	llist->insert(newStr("one"));
	llist->insert(newStr("two"));
	llist->insert(newStr("three"));
	llist->insert(newStr("four"));

	TEST_ASSERT(strcmp(llist->get(0), "one") == 0);
	TEST_ASSERT(strcmp(llist->get(2), "three") == 0);
	TEST_ASSERT(strcmp(llist->get(3), "four") == 0);
	TEST_ASSERT(strcmp(llist->get(1), "two") == 0);

	delete [] llist->get(1);
	llist->remove(1);

	TEST_ASSERT(strcmp(llist->get(0), "one") == 0);
	TEST_ASSERT(strcmp(llist->get(1), "three") == 0);
	TEST_ASSERT(strcmp(llist->get(2), "four") == 0);

	while (llist->valid(0))	{
		delete [] llist->get(0);
		llist->remove(0);
	}

	TEST_ASSERT(!llist->valid((unsigned int)-1));
	TEST_ASSERT(!llist->valid(1));
	TEST_ASSERT(!llist->valid(0));

	delete llist;

	return 0;
}
开发者ID:amoylel,项目名称:crisscross,代码行数:39,代码来源:llist.cpp

示例10: GetHighResTime


//.........这里部分代码省略.........
                else
                {
                    instance->CalculatePerceivedVolume();
                    sortedIds[numSortedIds] = instance->m_id;
                    numSortedIds++;
                }
            }
        }
        END_PROFILE("Perceived Volumes" );


        //        
		// Sort sounds into perceived volume order
        // NOTE : There are exactly numSortedId elements in sortedIds.  
        // NOTE : It isn't safe to assume numSortedIds == m_sounds.NumUsed()
        
        START_PROFILE("Sort Samples" );
        qsort( sortedIds, numSortedIds, sizeof(SoundInstanceId), SoundInstanceCompare );
        END_PROFILE("Sort Samples" );


        //
		// Second pass : Recalculate all Sound Priorities starting with the nearest sounds
        // Reduce priorities as more of the same sounds are played

        BTree<float> existingInstances;
        
                
        //                
        // Also look out for the highest priority new sound to swap in

        START_PROFILE("Recalculate Priorities" );

        LList<SoundInstance *> newInstances;
        SoundInstance *newInstance = NULL;
        float highestInstancePriority = 0.0f;

        for( int i = 0; i < numSortedIds; ++i )
        {
            SoundInstanceId id = sortedIds[i];
            SoundInstance *instance = GetSoundInstance( id );
            AppDebugAssert( instance );

            instance->m_calculatedPriority = instance->m_perceivedVolume;

            BTree<float> *existingInstance = existingInstances.LookupTree( instance->m_eventName );
            if( existingInstance )
            {
                instance->m_calculatedPriority *= existingInstance->data;
                existingInstance->data *= 0.75f;
            }
            else
            {
                existingInstances.PutData( instance->m_eventName, 0.75f );
            }

            if( !instance->IsPlaying() )
            {
                if( instance->m_positionType == SoundInstance::TypeMusic )
                {
                    newInstances.PutData( instance );
                }
                else if( instance->m_calculatedPriority > highestInstancePriority )
                {
                    newInstance = instance;
                    highestInstancePriority = instance->m_calculatedPriority;
开发者ID:cahocachi,项目名称:DEFCON,代码行数:67,代码来源:soundsystem.cpp

示例11: transform

Vector3 Entity::PushFromObstructions( Vector3 const &pos, bool killem )
{
    Vector3 result = pos;    
    if( m_onGround )
    {
        result.y = g_app->m_location->m_landscape.m_heightMap->GetValue( result.x, result.z );
    }

    Matrix34 transform( m_front, g_upVector, result );

    //
    // Push from Water

    if( result.y <= 1.0 )
    {        
        double pushAngle = syncsfrand(1.0);
        double distance = 0.0;
        while( distance < 50.0 )
        {
            double angle = distance * pushAngle * M_PI;
            Vector3 offset( iv_cos(angle) * distance, 0.0, iv_sin(angle) * distance );
            Vector3 newPos = result + offset;
            double height = g_app->m_location->m_landscape.m_heightMap->GetValue( newPos.x, newPos.z );
            if( height > 1.0 )
            {
                result = newPos;
                result.y = height;
                break;
            }
            distance += 1.0;
        }
    }
    

    //
    // Push from buildings

    LList<int> *buildings = g_app->m_location->m_obstructionGrid->GetBuildings( result.x, result.z );

    for( int b = 0; b < buildings->Size(); ++b )
    {
        int buildingId = buildings->GetData(b);
        Building *building = g_app->m_location->GetBuilding( buildingId );
        if( building )
        {        
            bool hit = false;
            if( m_shape && building->DoesShapeHit( m_shape, transform ) ) hit = true;
            if( (!m_shape || m_type == TypeOfficer ) && building->DoesSphereHit( result, 1.0 ) ) hit = true;
            // cheap hack, but no point overriding the entire function for this one line
            if( !hit )
            {
                Vector3 oldPos = m_pos - m_vel * SERVER_ADVANCE_PERIOD;
                if( building->DoesRayHit( oldPos, m_front, (m_pos - oldPos).Mag() ) ) hit = true;
            }

            if( hit )
            {            
                if( building->m_type == Building::TypeLaserFence && killem &&
                    ((LaserFence *) building)->IsEnabled())
                {
                    if( !g_app->m_location->IsFriend(building->m_id.GetTeamId(), m_id.GetTeamId() ) )
                    {
                        ChangeHealth( -9999 );
                        ((LaserFence *) building)->Electrocute( m_pos );
                    }
                }
                else
                {               
                    Vector3 pushForce = (building->m_pos - result);
                    pushForce.y = 0.0f;
                    pushForce.SetLength(4.0f);
                    while( building->DoesSphereHit( result, 2.0f ) )
                    {
                        result -= pushForce;   
                        //result.y = g_app->m_location->m_landscape.m_heightMap->GetValue( result.x, result.z );
                    }
                }
            }
        }
    }

    return result;
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:83,代码来源:entity.cpp

示例12: ToggleVersionMenu

void SWInterface::ToggleVersionMenu ( char *program, int x, int y )
{

	if ( program && 
		 !IsVisibleVersionMenu ( program ) ) {

		// Create it
		
		LList <char *> software;				// Bit of a hack - think about this
		LList <float> versions;

		DataBank *db = &(game->GetWorld ()->GetPlayer ()->gateway.databank);

		for ( int di = 0; di < db->GetDataSize (); ++di ) {

			if ( db->GetDataFile (di) &&
				 db->GetDataFile (di)->TYPE == DATATYPE_PROGRAM &&
				 strcmp ( db->GetDataFile (di)->title, program ) == 0 ) {

				software.PutData ( db->GetDataFile (di)->title );
				versions.PutData ( db->GetDataFile (di)->version );

			}

		}

		// Ensures total time = 500ms

		int timesplit = 500;
		if ( software.Size () > 0 )
			timesplit /= software.Size ();

		for ( int si = 0; si < software.Size (); ++si ) {
	
			char caption [128], tooltip [128], name [128];
			UplinkSnprintf ( caption, sizeof ( caption ), "%s v%1.1f", software.GetData (si), versions.GetData (si) );
			UplinkStrncpy ( tooltip, "Runs this software application", sizeof ( tooltip ) );
			UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", si );
			EclRegisterButton ( x, y, 120, 15, caption, tooltip, name );
			EclRegisterButtonCallbacks ( name, SoftwareDraw, SoftwareClick, button_click, button_highlight );
			EclRegisterMovement ( name, x, y - si * 17, si * timesplit );

		}
		
        SgPlaySound ( RsArchiveFileOpen ("sounds/softwaremenu.wav"), "sounds/softwaremenu.wav", false );

	}
	else {

		// Remove it
		// We don't know how many entries there could be, so keep deleting until they run out

		int i = 0;
		char name [128];
		UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", i );

		while ( EclGetButton ( name ) != NULL ) {

			EclRemoveButton ( name );
			++i;
			UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", i );

		}	

		// Force redraw of the button that fathered this menu

		char bname [32];
		UplinkSnprintf ( bname, sizeof ( bname ), "hud_software %d", currentprogrambutton );
		EclDirtyButton ( bname );

		currentprogrambutton = -1;

	}

}
开发者ID:gene9,项目名称:uplink-source-code,代码行数:75,代码来源:sw_interface.cpp

示例13: ToggleSubMenu

void SWInterface::ToggleSubMenu ( int softwareTYPE, int x, int y )
{

	if ( !IsVisibleSubMenu ( softwareTYPE ) ) {

		// Create a list of all software in memory

		LList <char *> software;				// Bit of a hack - think about this
		LList <float> versions;

		DataBank *db = &(game->GetWorld ()->GetPlayer ()->gateway.databank);

		for ( int di = 0; di < db->GetDataSize (); ++di ) {

			if ( db->GetDataFile (di) &&
				 db->GetDataFile (di)->TYPE == DATATYPE_PROGRAM &&
				 db->GetDataFile (di)->softwareTYPE == softwareTYPE ) {

				// This sofware is the correct type.  Add it into the list if it isn't already there,
				// or if its version is higher than any existing program of the same name

				// First try to find a software item of the same name
				int existingindex = -1;
				
				for ( int si = 0; si < software.Size (); ++si ) {
					if ( strcmp ( software.GetData (si), db->GetDataFile (di)->title ) == 0 ) {
						existingindex = si;
						break;
					}
				}

				// If it already exists, add this item in only if it has a higher version number

				if ( existingindex == -1 ) {

					software.PutData ( db->GetDataFile (di)->title );
					versions.PutData ( db->GetDataFile (di)->version );

				}
				if ( existingindex != -1 &&	
					 db->GetDataFile (di)->version > versions.GetData (existingindex) ) {
				
					software.RemoveData ( existingindex );
					versions.RemoveData ( existingindex );

					software.PutDataAtIndex ( db->GetDataFile (di)->title, existingindex );
					versions.PutDataAtIndex ( db->GetDataFile (di)->version, existingindex );

				}

			}

		}

		int timesplit = 500;
		if ( software.Size () > 0 )
			timesplit /= software.Size ();				// Ensures total time = 500ms

		for ( int si = 0; si < software.Size (); ++si ) {
	
			char caption [128], tooltip [128], name [128];
			UplinkSnprintf ( caption, sizeof ( caption ), "%s v%1.1f", software.GetData (si), versions.GetData (si) );
			UplinkStrncpy ( tooltip, "Runs this software application", sizeof ( tooltip ) );
			UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", si );
			EclRegisterButton ( x, y, 140, 15, caption, tooltip, name );
			EclRegisterButtonCallbacks ( name, SoftwareDraw, SoftwareClick, button_click, SoftwareHighlight );
			EclRegisterMovement ( name, x, y - si * 17, si * timesplit );

		}

		currentsubmenu = softwareTYPE;

        SgPlaySound ( RsArchiveFileOpen ( "sounds/softwaremenu.wav" ), "sounds/softwaremenu.wav", false );

	}
	else {

		// Remove the software menu
		// We don't know how many entries there could be, so keep deleting until they run out

		int i = 0;
		char name [32];
		UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", i );

		while ( EclGetButton ( name ) != NULL ) {

			EclRemoveButton ( name );
			++i;
			UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", i );

		}

		// Redraw the button that was selected

		char bname [32];
		UplinkSnprintf ( bname, sizeof ( bname ), "hud_swmenu %d", currentsubmenu );
		EclDirtyButton ( bname );

		currentsubmenu = SOFTWARETYPE_NONE;

//.........这里部分代码省略.........
开发者ID:gene9,项目名称:uplink-source-code,代码行数:101,代码来源:sw_interface.cpp

示例14: SetOrders

void Officer::SetOrders( Vector3 const &_orders )
{
    static float lastOrderSet = 0.0f;

    if( !g_app->m_location->IsWalkable( m_pos, _orders ) )
    {
        g_app->m_sepulveda->Say( "officer_notwalkable" );
    }
    else
    {
        float distanceToOrders = ( _orders - m_pos ).Mag();

        if( distanceToOrders > 20.0f )
        {
            m_orderPosition = _orders;
            m_orders = OrderGoto;
            m_absorb = false;

            //
            // If there is a teleport nearby,
            // assume he wants us to go in it

            bool foundTeleport = false;

            m_ordersBuildingId = -1;
            LList<int> *nearbyBuildings = g_app->m_location->m_obstructionGrid->GetBuildings( m_orderPosition.x, m_orderPosition.z );
            for( int i = 0; i < nearbyBuildings->Size(); ++i )
            {
                int buildingId = nearbyBuildings->GetData(i);
                Building *building = g_app->m_location->GetBuilding( buildingId );
                if( building->m_type == Building::TypeRadarDish ||
                    building->m_type == Building::TypeBridge )
                {
                    float distance = ( building->m_pos - _orders ).Mag();
                    if( distance < 5.0f )
                    {
                        Teleport *teleport = (Teleport *) building;
                        m_ordersBuildingId = building->m_id.GetUniqueId();
                        Vector3 entrancePos, entranceFront;
                        teleport->GetEntrance( entrancePos, entranceFront );
                        m_orderPosition = entrancePos;
                        foundTeleport = true;
                        break;
                    }
                }
            }

            if( !foundTeleport )
            {
                m_orderPosition = PushFromObstructions( m_orderPosition );
            }


            //
            // Create the line using particles immediately,
            // so the player can see what he's just done

            float timeNow = GetHighResTime();
            if( timeNow > lastOrderSet + 1.0f )
            {
                lastOrderSet = timeNow;
                OfficerOrders orders;
                orders.m_pos = m_pos;
                orders.m_wayPoint = m_orderPosition;
                while( true )
                {
                    if( orders.m_arrivedTimer < 0.0f )
                    {
                        g_app->m_particleSystem->CreateParticle( orders.m_pos, g_zeroVector, Particle::TypeMuzzleFlash, 50.0f );
                        g_app->m_particleSystem->CreateParticle( orders.m_pos, g_zeroVector, Particle::TypeMuzzleFlash, 40.0f );
                    }
                    if( orders.Advance() ) break;
                }

                CancelOrderSounds();
                g_app->m_soundSystem->TriggerEntityEvent( this, "SetOrderGoto" );
            }
        }
        else
        {
            float timeNow = GetHighResTime();
            int researchLevel = g_app->m_globalWorld->m_research->CurrentLevel( GlobalResearch::TypeOfficer );

            if( timeNow > lastOrderSet + 0.3f )
            {
                lastOrderSet = timeNow;

                switch( researchLevel )
                {
                    case 0 :
                    case 1 :
                    case 2 :
                        m_orders = OrderNone;
                        break;

                    case 3 :
                        if      ( m_orders == OrderNone )       m_orders = OrderFollow;
                        else if ( m_orders == OrderFollow )     m_orders = OrderNone;
                        else if ( m_orders == OrderGoto )       m_orders = OrderNone;
                        break;
//.........这里部分代码省略.........
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:101,代码来源:officer.cpp

示例15: ParseMemoryLeakFile

void ParseMemoryLeakFile(const char *_inputFilename, const char *_outputFilename)
{
	/* */
	/* Start up */
	/* */

	RedBlackTree<char *, int> combined;
	RedBlackTree<char *, int> frequency;
	int                       unrecognised = 0;

	/* */
	/* Open the file and start parsing */
	/* */

	FILE                     *memoryfile = fopen(_inputFilename, "rb");

	while (memoryfile && !feof(memoryfile))	{
		char thisline[1024];

		fgets(thisline, 1024, memoryfile);

		if (!strncmp(thisline, " Data:", 6) == 0) { /* This line is a data line - useless to us */
			if (strchr(thisline, ':')) {                               /* This line does not have a source file location - useless to us */
				/* Get the size */

				char *lastcomma = strrchr(thisline, ',');
				if (lastcomma == 0) continue;

				char *ssize = lastcomma + 2;
				int   size;
				char  unused[32];

				sscanf(ssize, "%d %s", &size, unused);

				/* Get the source file name */

				char *sourcelocation = thisline;
				char *colon = strrchr(thisline, ':');

				*(colon - 1) = '\x0';

				/* Put the result into our BTree */

				int   result = 0;
				bool  found = combined.find(sourcelocation, result);

				if (found)
					combined.replace(sourcelocation, result + size);
				else
					combined.insert(sourcelocation, size);

				found = frequency.find(sourcelocation, result);

				if (frequency.exists(sourcelocation))
					frequency.replace(sourcelocation, result + size);
				else
					frequency.insert(sourcelocation, 1);
			} else {
				char *lastcomma = strrchr(thisline, ',');

				if (lastcomma) {
					char *ssize = lastcomma + 2;
					int   size;
					char  unused[32];

					sscanf(ssize, "%d %s", &size, unused);

					unrecognised += size;
				}
			}
		}
	}

	fclose(memoryfile);


	/* */
	/* Sort the results into a list */
	/* */

	LList<char *>   sorted;
	DArray<char *> *dataI = combined.ConvertIndexToDArray();
	DArray<int>    *dataD = combined.ConvertToDArray();

	int             totalsize = 0;

	for (size_t i = 0; i < dataI->size(); i++) {
		if (dataI->valid(i)) {
			char *newsource = dataI->get(i);
			int   newsize = dataD->get(i);

			totalsize += newsize;
			bool  inserted = false;

			for (size_t i = 0; i < sorted.size(); i++) {
				char *existingsource = sorted.get(i);
				int   existingsize;

				combined.find(existingsource, existingsize);

//.........这里部分代码省略.........
开发者ID:skydevgit,项目名称:crisscross,代码行数:101,代码来源:universal_include.cpp


注:本文中的LList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。