Example #1
0
status_t
CamClient::
dump(int fd, Vector<String8>& args)
{
    //
    if  ( args.empty() ) {
        return  OK;
    }
    //
    MY_LOGD("args(%d)=%s", args.size(), (*args.begin()).string());
    //
    //
    ////////////////////////////////////////////////////////////////////////////
    //  Parse Command:
    ////////////////////////////////////////////////////////////////////////////
    //
    //  <Preview>
    if  ( *args.begin() == "Preview" )
    {
        args.erase(args.begin());
        mpPreviewClient->dump(fd, args);
        return  OK;
    }
    //
    //  <Record>
    if  ( *args.begin() == "Record" )
    {
        args.erase(args.begin());
        mpRecordClient->dump(fd, args);
        return  OK;
    }
    //
    //
    return OK;
}
        /**
         * Copy of inital tests.
         */
        void test_old()
        {
            Vector<double> v;           // ok: defaultkonstruktor ger vektor med flyttal
            Vector<char> *a = new Vector<char>[3];  // dynamiskt allokerade ser ut så här
            delete [] a;

            assert(v.size() == 0);      // tom från början
            v.push_back(3.14);          // lägg till ett element sist
            assert(v.size() == 1);      // nu ligger ett element i vektorn
            v.insert(0, 2.10);          // lägg till före element 0, dvs först
            assert(v[0] == 2.10 &&      // hamnade de rätt?
               v[1] == 3.14);
            assert(v.size() == 2);      // nu ligger två element i vektorn

            std::sort(v.begin(), v.end(), [](double a, double b){return a > b;});
            /* v.sort(false);              // sortera i fallande ordning */
            assert(v[0] == 3.14 &&      // hamnade de rätt?
                v[1] == 2.10);
            assert(v.size() == 2);      // ingenting ändrat?
            v[1] = 2.11;                // tilldelning av enstaka element;

            const Vector<double> &vc = v;  // skapa konstant referens
            assert(vc.size() == 2);     // ok: ändrar ej vektorn som är konstant
            assert(vc[0] == 3.14 &&     // ok: ändrar ej vektorn som är konstant
                vc[1] == 2.11);

            v.erase(0);                 // ta bort första elementet
            assert(v.size() == 1);      // rätt antal elelment
            v.clear();                  // töm hela vektorn
            assert(v.size() == 0);      // tom när alla element är borttagna

            // kontrollera att följande rader inte går att kompilera
            //vc[0] = 3.1415;             // fel: tilldelning av konstant objekt
            //Vector<char> c = v;         // fel: tilldelning av olika typer
        }
void EditorFileDialog::_favorite_toggled(bool p_toggle) {
	bool res = access==ACCESS_RESOURCES;

	String cd = get_current_dir();

	Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();

	bool found = false;
	for(int i=0;i<favorited.size();i++) {
		bool cres = favorited[i].begins_with("res://");
		if (cres!=res)
			continue;

		if (favorited[i]==cd) {
			found=true;
			break;
		}
	}

	if (found) {
		favorited.erase(cd);
		favorite->set_pressed(false);
	} else {
		favorited.push_back(cd);
		favorite->set_pressed(true);
	}

	EditorSettings::get_singleton()->set_favorite_dirs(favorited);

	_update_favorites();

}
Example #4
0
bool kill(Vector a,Vector b)
{
   for (iter k=a.begin();k!=a.end();k++)
      if (*k=='K')
      {
         a.erase(k);
         break;
      }
   for (iter k=b.begin();k!=b.end();k++)
      if (*k=='E')
      {
         b.erase(k);
         return(false);
      }
   return(true);
}
void ModuleManager::LoadModulesInFolder( const Char* pModuleDir )
{
    Vector<String>              moduleNames;
    Vector<String>::iterator    itList;
    String                      moduleName;
    Char                        searchFor[256];
    
    sprintf( searchFor, "*%s", LIBRARY_EXTENSION );
    FileManager::FindFiles( pModuleDir, searchFor, moduleNames );

// If we're in release mode on windows, ignore debug dlls
#if !defined(GD_DEBUG) && defined(GD_WINDOWS)
    for( itList = moduleNames.begin(); itList != moduleNames.end(); )
    {
        if( (*itList).substr( (*itList).length() - strlen(LIBRARY_EXTENSION_DEBUG) ) == LIBRARY_EXTENSION_DEBUG )
            moduleNames.erase( itList );
        else
            ++itList;
    }
#endif

    // Remove LIBRARY_EXTENSION from the end
    // Call LoadModule on each item.
    for( itList = moduleNames.begin(); itList != moduleNames.end(); ++itList )
    {
        moduleName = (*itList).substr( 0, (*itList).length() - strlen(LIBRARY_EXTENSION) );
        LoadModule( moduleName.c_str(), pModuleDir );
    }
}
		virtual void Render(const class RenderState& rs, float deltaTime) override
		{
			// Enable blending for all particles
			glEnable(GL_BLEND);

			// Tick all emitters and remove old ones
			for(auto it = m_emitters.begin(); it != m_emitters.end();)
			{
				(*it)->Render(rs, deltaTime);

				if(it->GetRefCount() == 1)
				{
					if((*it)->HasFinished())
					{
						// Remove unreferenced and finished emitters
						it = m_emitters.erase(it);
						continue;
					}
					else if((*it)->loops == 0)
					{
						// Deactivate unreferenced infinte duration emitters
						(*it)->Deactivate();
					}
				}

				it++;
			}
		}
// The weight factor allows us to require several events to "vote" for removing an item before 
// it happens... basically once the weights OR to 0xFF, the item is toast.
void HelpItemManager::removeInlineHelpItem(HelpItem item, bool markAsSeen, U8 weight)
{
   //TNLAssert(helpItems[item].priority == PacedHigh || helpItems[item].priority == PacedLow, "This method is only for paced items!");
   if(helpItems[item].priority == PacedHigh || helpItems[item].priority == PacedLow)      // for now
   {
      Vector<WeightedHelpItem> *queue = helpItems[item].priority == PacedHigh ? &mHighPriorityQueuedItems : 
                                                                                &mLowPriorityQueuedItems;
      S32 index = -1;
      for(S32 i = 0; i < queue->size(); i++)
         if(queue->get(i).helpItem == item)
         {
            index = i;
            break;
         }

       if(index != -1)
       {
          queue->get(index).removalWeight |= weight;
          if(queue->get(index).removalWeight == 0xFF)
            queue->erase(index);
       }
   }

   if(markAsSeen)
      mAlreadySeen[item] = true;
}
Example #8
0
// Fills bounds with points from argv starting at firstCoord; also resizes selected to match the size of bounds
static void readPolyBounds(S32 argc, const char **argv, S32 firstCoord, F32 gridSize, 
                           bool allowFirstAndLastPointToBeEqual, Vector<Point> &bounds, Vector<bool> &selected)
{
   Point p, lastP;
   
   bool isTwoPointLine = (argc - firstCoord) / 2 == 2;
   
   bounds.clear();

   // Make sure we don't crash with firstCoord = 0; argc = 7; or some uneven number
   for(S32 i = firstCoord; i < argc - 1; i += 2)
   {
      // If we are loading legacy levels (earlier than 019), then we have a gridsize multiplier
      if(gridSize != 1.f)
         p.set( (F32) (atof(argv[i]) * gridSize), (F32) (atof(argv[i+1]) * gridSize ) );
      else
         p.set( (F32) atof(argv[i]), (F32) atof(argv[i+1]));

      // Normally, we'll want to filter out adjacent points that are identical.  But we also
      // need to handle the situation where the user has created a 2-pt 0-length line.
      // Because the users demand it.  We will deliver.
      if(i == firstCoord || p != lastP || isTwoPointLine)
         bounds.push_back(p);

      lastP.set(p);
   }

   // Check if last point was same as first; if so, scrap it
   if(!allowFirstAndLastPointToBeEqual && bounds.first() == bounds.last())
      bounds.erase(bounds.size() - 1);

   selected.resize(bounds.size());
}
Example #9
0
int main()
{
    Vector<int> *m = new Vector<int>();

    for  (int i = 4;i < 60;i ++) {
        m->pushBack(i);
    }

    cout << m->getSize() << endl;
    cout << m->getCapacity() << endl;
    cout << m->getFront() << endl;
    cout << m->getBack() << endl;
    cout << m->operator[](1) << endl;

    m->insert(0,32);
    m->erase(0);
    m->resize(100);

    Vector<Course> *cr = new Vector<Course>();

    Course *cpp = new Course("C++",100);
    Course *python = new Course("Python",200);
    Course *java = new Course("Java",300);

    cr->pushBack(*cpp);
    cr->pushBack(*python);
    cr->pushBack(*java);

    delete cpp;
    delete python;
    delete java;

    return 0;
}
Example #10
0
// If there is no valid connection to master server, perodically try to create one.
// If user is playing a game they're hosting, they should get one master connection
// for the client and one for the server.
// Called from both clientGame and serverGame idle fuctions, so think of this as a kind of idle
void Game::checkConnectionToMaster(U32 timeDelta)
{
   if(mConnectionToMaster.isValid() && mConnectionToMaster->isEstablished())
      mTimeUnconnectedToMaster = 0;
   else if(mReadyToConnectToMaster)
      mTimeUnconnectedToMaster += timeDelta;

   if(!mConnectionToMaster.isValid())      // It's valid if it isn't null, so could be disconnected and would still be valid
   {
      Vector<string> *masterServerList = mSettings->getMasterServerList();

      if(masterServerList->size() == 0)
         return;

      if(mNextMasterTryTime < timeDelta && mReadyToConnectToMaster)
      {
         if(!mNameToAddressThread)
         {
            if(mHaveTriedToConnectToMaster && masterServerList->size() >= 2)
            {  
               // Rotate the list so as to try each one until we find one that works...
               masterServerList->push_back(string(masterServerList->get(0)));  // don't remove string(...), or else this line is a mystery why push_back an empty string.
               masterServerList->erase(0);
            }

            const char *addr = masterServerList->get(0).c_str();

            mHaveTriedToConnectToMaster = true;
            logprintf(LogConsumer::LogConnection, "%s connecting to master [%s]", isServer() ? "Server" : "Client", addr);

            mNameToAddressThread = new NameToAddressThread(addr);
            mNameToAddressThread->start();
         }
         else
         {
            if(mNameToAddressThread->mDone)
            {
               if(mNameToAddressThread->mAddress.isValid())
               {
                  TNLAssert(!mConnectionToMaster.isValid(), "Already have connection to master!");
                  mConnectionToMaster = new MasterServerConnection(this);

                  mConnectionToMaster->connect(mNetInterface, mNameToAddressThread->mAddress);
               }
   
               mNextMasterTryTime = GameConnection::MASTER_SERVER_FAILURE_RETRY_TIME;     // 10 secs, just in case this attempt fails
               delete mNameToAddressThread;
               mNameToAddressThread = NULL;
            }
         }
      }
      else if(!mReadyToConnectToMaster)
         mNextMasterTryTime = 0;
      else
         mNextMasterTryTime -= timeDelta;
   }

   processAnonymousMasterConnection();
}
Example #11
0
void snitch(Vector a,Vector b)
{
   for (iter k=a.begin();k!=a.end();k++)
      if (*k=='S')
      {
         a.erase(k);
         break;
      }
   for (iter k=b.begin();k!=b.end();k++)
      if (*k=='D')
      {
         b.erase(k);
         return;
      }
   a.push_back(b[0]);
   b.erase(b.begin());
}
//*****************************************************************************
inline bool OpenFiles::erase(Uint16 id){
  for (unsigned i = 0; i < m_files.size(); i++){
    if (m_files[i].m_id == id){
      m_files.erase(i);
      return true;
    }
  }
  // Item was not found in list
  return false;
}
Example #13
0
  /*
    clear any unassembled signal buffers from node
  */
  void node_failed(NodeId nodeId) {
    for (unsigned i = m_buffers.size(); i > 0; --i)
    {
      if (m_buffers[i-1]->m_node_id == nodeId)
      {
        delete m_buffers[i]; // free the memory of the signal fragment
	m_buffers.erase(i); // remove the reference from the vector.
      }
    }
  }
Example #14
0
int
main(void) {

    g_client.connect();

    srand(time(0));
    for(int i = 0; i<1000; i++) {
        int sz = g_procs.size();
        int test = rand() % 100;
        if(sz == 0 || test < 10) {
            define();
            continue;
        }

        list();

        int proc = rand() % g_procs.size();
        SimpleCpcClient::Process & p = g_procs[proc];
        if(p.m_status == "running" && test > 50) {
            ndbout_c("undefine %d: %s (running)", p.m_id, p.m_name.c_str());
            undefine(p);
            g_procs.erase(proc);
            continue;
        }
        if(p.m_status == "running" && test <= 50) {
            ndbout_c("stop %d: %s(running)", p.m_id, p.m_name.c_str());
            stop(p);
            continue;
        }
        if(p.m_status == "stopped" && test > 50) {
            ndbout_c("undefine %d: %s(stopped)", p.m_id, p.m_name.c_str());
            undefine(p);
            g_procs.erase(proc);
            continue;
        }
        if(p.m_status == "stopped" && test <= 50) {
            ndbout_c("start %d %s(stopped)", p.m_id, p.m_name.c_str());
            start(p);
            continue;
        }
        ndbout_c("Unknown: %s", p.m_status.c_str());
    }
}
Example #15
0
void UnregisterTextBlock(TextBlock *tbl)
{
	for(Vector<TextBlock *>::iterator it = registredBlocks.begin(); it != registredBlocks.end(); it++)
	{
		if (tbl == *it) 
		{
			registredBlocks.erase(it);
			return;
		}
	}
}
Example #16
0
void TrialPanel::initWithTrial(Trial* trial)
{
    _trial = trial;

    auto nameLab = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_name"));
    nameLab->setString(trial->getModelByName("nickName").asString());

    auto introLab = static_cast<Text*>(Helper::seekWidgetByName(_root, "Label_intro"));
    introLab->setString(trial->getModelByName("introduce").asString());

    Vector<Achievement*> newAchieves;
    auto achievements = trial->getAchievements();
    for(auto achievement:achievements)
    {
        newAchieves.pushBack(achievement);
    }
    // µ÷Õû˳Ðò
    auto begin = newAchieves.begin();
    auto end = newAchieves.end();
    for(auto iter = begin; iter != end;)
    {
        if((*iter)->getReached() == true)
        {
            auto remove = iter;
            iter = newAchieves.erase(iter);
            newAchieves.pushBack((*remove));
        }
        else
            iter++;
    }

    int i = 0;
    for(auto achieve:newAchieves)
    {
        auto achieveUnit = _achieveUnit->clone();

        auto numLab = static_cast<Text*>(Helper::seekWidgetByName(achieveUnit, "Label_num"));
        auto image = static_cast<ImageView*>(Helper::seekWidgetByName(achieveUnit, "Image_image"));
        auto tagLab = static_cast<Text*>(Helper::seekWidgetByName(achieveUnit, "Label_tag"));
        auto starLab = static_cast<Text*>(Helper::seekWidgetByName(achieveUnit, "Label_star"));

        tagLab->setString(achieve->getModelByName("introduce").asString());
        if(achieve->getReached() == true)
        {
            image->setVisible(false);
            starLab->setVisible(false);
            numLab->setVisible(false);
            achieveUnit->setOpacity(100);
        }
        achieveUnit->setUserData(achieve);
        achieveUnit->setTag(achieve->getId());
        _listView->pushBackCustomItem(achieveUnit);
    }
}
Example #17
0
int main ()
{
    // For convenience.
    typedef std::vector<int, std::allocator<int> >                    Vector;
    typedef std::ostream_iterator<int, char, std::char_traits<char> > Iter;

    // Populate a vector with elements from an array.
    const Vector::value_type arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    Vector v (arr + 0, arr + sizeof arr / sizeof *arr);

    // Write out the contents to cout.
    std::copy (v.begin (), v.end (), Iter (std::cout," "));
    std::cout << std::endl << std::endl;

    // Move the 7 to the end of the vector.
    Vector::iterator result = std::remove (v.begin (), v.end (), 7);

    // Delete the 7 from the vector.
    v.erase (result, v.end ());

    std::copy (v.begin (), v.end (), Iter (std::cout, " "));
    std::cout << std::endl << std::endl;

    // Remove all non-zero elements beyond the fourth element.
    v.erase (std::remove_if (v.begin () + 4, v.end (), 
                             bnd_greater( int_greater (), 0 )), v.end ());

    std::copy (v.begin (), v.end (), Iter (std::cout, " "));
    std::cout << std::endl << std::endl;

    // Now remove all 3s on output.
    std::remove_copy (v.begin (), v.end (), Iter (std::cout, " "), 3);
    std::cout << std::endl << std::endl;

    // Now remove everything satisfying predicate on output.
    std::remove_copy_if (v.begin (), v.end (), Iter (std::cout, " "),
                         bnd_greater( int_greater (), 0 ) );

    // Return 0 on success, a non-zero value on failure
    return !!v.empty ();
}
Example #18
0
 void erase_buffer(const DefragBuffer* dbuf){
   for (unsigned i = 0; i < m_buffers.size(); i++)
   {
     if (m_buffers[i] == dbuf)
     {
       delete dbuf;
       m_buffers.erase(i);
       return;
     }
   }
   assert(false); // Should never be reached
 }
Example #19
0
int main() {
	Vector<int> a;
	a.push_back(1);
	a.push_back(2);
	a.push_back(3);
	a.push_back(4);
	a.insert(3,10);
	a.insert(5,1337);
	a.erase(0);
	printVector(a); //Should return 2 3 10 4 1337
	Vector<char> b = {'a','b','c'}; //Init_list
	Vector<int> c(3); //size_t 
	Vector<int> d; //Default
	Vector<char> e = b; //copy and inside copy operator[]
	printVector(e);
	e[2]='f';
	printVector(e);
	int factor = a[1]*a[2]; //Uses lvalue operator[]
	d = c; //Copy Assign operator=
	d = std::move(a); //Move Assign operator
	Vector<float> f(3,3.14f);
	f.push_back(3.1415f);
	printVector(f);
	d.erase(0); d.erase(0); d.erase(0); d.erase(0); d.erase(0);
	cout << "Size of d is: " << d.size() << endl;
	for ( float fl : f) {cout << fl << " ";}
	return 0;
}
Example #20
0
  /* Clear bit n */
  int clear(unsigned n) {
    assert(n <= m_max_size);
    for (unsigned i = 0; i < m_vec.size(); i++)
    {
      const unsigned j = m_vec[i];
      if (j != n)
        continue;

      m_vec.erase(i);
      return 1;
    }
    return 0;
  }
Example #21
0
 AttributeS *add_attr() {
   AttributeS * attr;
   if (m_values_e.size() > 0) {
     attr = m_values_e[m_values_e.size()-1];
     m_values_e.erase(m_values_e.size()-1);
   }
   else
   {
     attr = new AttributeS;
   }
   m_values.push_back(attr);
   return attr;
 }
Example #22
0
template<class T> inline static Matrix<T> min (const View<T,true>& M, const size_t& dim = 0) {
    Vector<size_t> dims = size(M);
    size_t m = dims[0];
    size_t n = numel(M)/m;
    dims.erase(dims.begin());
    Matrix<T> ret(dims);
    for (size_t j = 0; j < n; ++j) {
        ret[j] = 1e20;
        for (size_t i = 0; i < m; ++i)
            if (ret[j]>=M[j*m+i]) ret[j] = M[j*m+i];
    }
    return ret;
}
Example #23
0
bool
Probes::removeJITWatcher(JSRuntime *rt, JITWatcher *watcher)
{
    JITWatcher **place = Find(jitWatchers, watcher);
    if (!place)
        return false;
    if (rt)
        rt->delete_(*place);
    else
        Foreground::delete_(*place);
    jitWatchers.erase(place);
    return true;
}
Example #24
0
// Form an SDP from an affineObjective and a list of
// PolynomialVectorMatrices.  affineObjective is a vector of the form
// (f, b), where the objective function will be
//
//   f + y.b
//
// with y the dual decision variables.  polVectorMatrices are
// described in SDP.h.
//
SDP bootstrapSDP(const Vector &affineObjective,
                 const vector<PolynomialVectorMatrix> &polVectorMatrices) {
  // Convert polVectorMatrices into DualConstraintGroup's
  vector<DualConstraintGroup> dualConstraintGroups;
  for (vector<PolynomialVectorMatrix>::const_iterator m = polVectorMatrices.begin();
       m != polVectorMatrices.end(); m++)
    dualConstraintGroups.push_back(dualConstraintGroupFromPolVecMat(*m));

  // Split affineObjective into objectiveConst f and dualObjective b
  Real objectiveConst = affineObjective[0];
  Vector dualObjective = affineObjective;
  dualObjective.erase(dualObjective.begin());

  return sdpFromDualConstraintGroups(dualObjective, objectiveConst, dualConstraintGroups);
}
Vector<NodeLayer*> BoardLayer::searchRoute(int sId, int gId){
    Vector<NodeLayer*> route;
    // ゴールが壁なら即終了
    if (allNode.at(gId)->getKind() == 1) {
        return route;
    }
    breadthFirstSearch(sId, gId);
    // スタートからゴールまでの経路を格納する
    route.pushBack(allNode.at(sId));
    route = setRoute(route, gId);
    if (route.size() > 0) { //成功(壁等なかった)した場合
        route.erase(0);
    }
    return route;
}
Example #26
0
bool GDNative::terminate() {

	if (!initialized) {
		ERR_PRINT("No valid library handle, can't terminate GDNative object");
		return false;
	}

	if (library->should_load_once()) {
		Vector<Ref<GDNative> > *gdnatives = &(*GDNativeLibrary::loaded_libraries)[library->get_current_library_path()];
		if (gdnatives->size() > 1) {
			// there are other GDNative's still using this library, so we actually don't terminate
			gdnatives->erase(Ref<GDNative>(this));
			initialized = false;
			return true;
		} else if (gdnatives->size() == 1) {
			// we're the last one, terminate!
			gdnatives->clear();
			// wew this looks scary, but all it does is remove the entry completely
			GDNativeLibrary::loaded_libraries->erase(GDNativeLibrary::loaded_libraries->find(library->get_current_library_path()));
		}
	}

	void *library_terminate;
	Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate);
	if (error || !library_terminate) {
		OS::get_singleton()->close_dynamic_library(native_handle);
		native_handle = NULL;
		initialized = false;
		return true;
	}

	godot_gdnative_terminate_fn library_terminate_pointer;
	library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate;

	godot_gdnative_terminate_options options;
	options.in_editor = Engine::get_singleton()->is_editor_hint();

	library_terminate_pointer(&options);

	initialized = false;

	// GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);

	OS::get_singleton()->close_dynamic_library(native_handle);
	native_handle = NULL;

	return true;
}
void ProcessTouches(int32 phase)
{
	DAVA::UIControlSystem::Instance()->OnInput(phase, activeTouches, Vector<UIEvent>());

	for(Vector<UIEvent>::iterator it = activeTouches.begin(); it != activeTouches.end(); )
	{
		if((*it).phase == UIEvent::PHASE_ENDED || (*it).phase == UIEvent::PHASE_CANCELLED)
		{
			it = activeTouches.erase(it);
		}
		else
		{
			++it;
		}
	}
}
/** 幅優先探索 */
void BoardLayer::breadthFirstSearch(int sId, int gId) {
    // 全ノードの探索情報リセット
    for (auto node: allNode) {
        node->dataInit();
    }
    // ゴールノードの探索情報リセット
    allNode.at(gId)->setComeNode(allNode.at(gId));
    allNode.at(gId)->setCost(0);
    allNode.at(gId)->setDepth(0);
    
    Vector<NodeLayer*> searchList;
    searchList.pushBack(allNode.at(gId)); // スタート位置(ゴール)の登録
    while (!searchList.empty()) {
        NodeLayer* searchNode = searchList.at(0);
//        log("%dの隣探索", searchNode->getId());
        // 探索リストの先頭の隣のノード一覧
        int count = 0;
        for (auto neighborNode: searchNode->getNeighborNode()) {
            // 未探索の場合探索リストに追加(depth付ける)
            if (neighborNode->getDepth() == -1) {
                // 壁の場合探索リストに追加しない
                if (neighborNode->getKind() == 1) {
                    //                    continue;
                }else {
                    searchList.pushBack(neighborNode);
                    neighborNode->setDepth(searchNode->getDepth()+1);
                }
//                if (neighborNode->getKind() == 0) {
//                    searchList.pushBack(neighborNode);
//                    neighborNode->setDepth(searchNode->getDepth()+1);
//                }
            }
            // ここまで+隣nodeまでの距離
            int cost = searchNode->getCost() + searchNode->getNeighborNodeDist().at(count);
            // 新規(1000)もしくは,最短なら登録
            if (neighborNode->getCost() > cost) {
//            log("隣の設定コスト%d", neighborNode->getCost());
//            log("新規コスト%d", cost);
                neighborNode->setCost(cost);
                neighborNode->setComeNode(searchNode);
//                log("  %dnodeは%dからきたとセット",neighborNode->getId(), searchNode->getId());
            }
            count ++;
        }
        searchList.erase(0);
    }
}
Example #29
0
void HelpItemManager::moveItemFromQueueToActiveList(const ClientGame *game)
{
   TNLAssert(mPacedTimer.getCurrent() == 0 && mFloodControl.getCurrent() == 0, "Expected timers to be clear!");
   S32 itemToShow = 0;

   Vector<WeightedHelpItem> *items = NULL;
   
   bool useHighPriorityQueue = true;

   while(true)
   {
      items = useHighPriorityQueue ? &mHighPriorityQueuedItems : &mLowPriorityQueuedItems;

      if(items->size() <= itemToShow)
      {
         if(useHighPriorityQueue)      // High priority queue exhausted; switch to low priority queue
         {
            itemToShow = 0;
            useHighPriorityQueue = false;
            continue;
         }
         else                          // Low priority queue exhausted; nothing to show... go home
         {
            mPacedTimer.reset();       // Set this just so we don't keep hammering this function all day
            return;
         }
      }
  
      // Handle special case -- want to suppress, but not delete, this item if there are bots in the game
      if(items->get(itemToShow).helpItem == AddBotsItem && game->getBotCount() > 0)
      {
         itemToShow += 1;
         continue;
      }

      break;      // Exit our loop... we have our item list (items) and our itemToShow
   }


   HelpItem queuedMessage = items->get(itemToShow).helpItem;
   items->erase(itemToShow);

   addInlineHelpItem(queuedMessage, true);
   mPacedTimer.reset();
}
Example #30
0
Vector<string> NexusGameType::makeParameterMenuKeys() const
{
    // Start with the keys from our parent (GameType)
    Vector<string> items = *Parent::getGameParameterMenuKeys();

    S32 index = items.getIndex("Win Score");
    TNLAssert(index >= 0, "Invalid index!");     // Protect against text of Win Score being changed in parent

    // Remove Win Score, replace it with some Nexus specific items
    items.erase(index);      // Delete "Win Score"

    // Create slots for 3 new items, and fill them with our Nexus specific items
    items.insert(index,     "Nexus Time to Open");
    items.insert(index + 1, "Nexus Time Remain Open");
    items.insert(index + 2, "Nexus Win Score");

    return items;
}