Example #1
0
void CScreenProfile::CreateProfileList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();

	// Get new stuff
	m_ProfileList.clear();
	g_pProfileMgr->GetProfileList(m_ProfileList);

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	// Profiles to the list
	for (StringSet::iterator iter = m_ProfileList.begin(); iter != m_ProfileList.end(); ++iter)
	{
		char *pStr = (char *)iter->c_str();
		CLTGUITextCtrl* pTextCtrl = CreateTextItem(pStr, CMD_OK, LTNULL);
		pTextCtrl->SetFont(pFont,nListFontSz);
		uint16 ndx = m_pListCtrl->AddControl(pTextCtrl);
		pTextCtrl->SetParam1(ndx);

		if (stricmp(iter->c_str(),m_pProfile->m_sName.c_str()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}
Example #2
0
	int LMDBEngine::FlushWriteBatch(BatchHolder& holder)
	{
		if (NULL != holder.txn)
		{
			StringSet::iterator it = holder.dels.begin();
			while (it != holder.dels.end())
			{
				MDB_val k;
				k.mv_data = (void*) (it->c_str());
				k.mv_size = it->size();
				mdb_del(holder.txn, m_dbi, &k, NULL);
				it++;
			}
			std::map<std::string, std::string>::iterator sit =
			        holder.inserts.begin();
			while (sit != holder.inserts.end())
			{
				MDB_val k, v;
				k.mv_data = (void*) (sit->first.c_str());
				k.mv_size = sit->first.size();
				v.mv_data = (void*) (sit->second.c_str());
				v.mv_size = sit->second.size();
				mdb_put(holder.txn, m_dbi, &k, &v, 0);
				sit++;
			}
			mdb_txn_commit(holder.txn);
			holder.txn = NULL;
			holder.Clear();
		}
		return 0;
	}
Example #3
0
    int MMKVImpl::SRandMember(DBID db, const Data& key, const StringArrayResult& members, int count)
    {
        int err = 0;
        RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment);
        StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)();
        if (IS_NOT_EXISTS(err))
        {
            return 0;
        }
        if (0 != err)
        {
            return err;
        }
        if (set->empty())
        {
            return 0;
        }

        //return whole set
        if (count > 0 && count > set->size())
        {
            StringSet::iterator it = set->begin();
            while (it != set->end())
            {
                it->ToString(members.Get());
                it++;
            }
            return 0;
        }

        int rand = 0;
        for (int i = 0; i < std::abs(count); i++)
        {
            if (count > 0)
            {
                if (i == 0)
                {
                    rand = random_between_int32(0, set->size() - 1);
                }
                else
                {
                    rand += i;
                    if (rand >= set->size())
                    {
                        rand -= set->size();
                    }
                }
            }
            else
            {
                rand = random_between_int32(0, set->size() - 1);
            }
            StringSet::iterator it = set->begin();
            it.increment_by(rand);
            it->ToString(members.Get());
        }
        return 0;
    }
void emitShinglesWithDocSizes(const StringSet& shingleSet,
    const std::string& docId) {
  assert(shingleSet.size() <= dedup::SKETCH_SIZE);

  std::string docIdWithSize = docId + dedup::DOC_SIZE_SEP +
      dedup::numToStr(shingleSet.size());
  for (StringSet::iterator it = shingleSet.begin();
      it != shingleSet.end(); ++it) {
    printf("%s\t%s\n", it->c_str(), docIdWithSize.c_str());
  }
}
Example #5
0
void GLESRenderSpec::report(LogChannel* ch)
{
	LOG_SCOPE(ch, "++ * GLESRenderSpec Report\n");

	LOG(ch, "++ - GL_VENDOR: %s\n", _vendor.c_str());
	LOG(ch, "++ - GL_RENDERER: %s\n", _renderer.c_str());
	LOG(ch, "++ - GL_VERSION: %s\n", _version.c_str());
	LOG(ch, "++ + GL_EXTENSIONS:\n");

	for (StringSet::iterator itr = _extensions.begin(), end = _extensions.end(); itr != end; ++itr)
	{
		LOG(ch, "++   - %s\n", itr->c_str());
	}

	RenderSpec::report(ch);
}
Example #6
0
 int MMKVImpl::SMembers(DBID db, const Data& key, const StringArrayResult& members)
 {
     int err = 0;
     RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment);
     StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)();
     if (NULL == set || 0 != err)
     {
         return err;
     }
     StringSet::iterator it = set->begin();
     while (it != set->end())
     {
         it->ToString(members.Get());
         it++;
     }
     return 0;
 }
Example #7
0
 int MMKVImpl::SPop(DBID db, const Data& key, const StringArrayResult& members, int count)
 {
     if (m_readonly)
     {
         return ERR_PERMISSION_DENIED;
     }
     if (count < 0)
     {
         return ERR_OFFSET_OUTRANGE;
     }
     int err = 0;
     RWLockGuard<MemorySegmentManager, WRITE_LOCK> keylock_guard(m_segment);
     EnsureWritableValueSpace();
     StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)();
     if (IS_NOT_EXISTS(err))
     {
         return 0;
     }
     if (0 != err)
     {
         return err;
     }
     if (set->empty())
     {
         return 0;
     }
     for (int i = 0; i < count && !set->empty(); i++)
     {
         StringSet::iterator it = set->begin();
         it->ToString(members.Get());
         Object cc = *it;
         set->erase(it);
         DestroyObjectContent(cc);
     }
     if (set->empty())
     {
         GenericDel(GetMMKVTable(db, false), db, Object(key, false));
     }
     return 0;
 }
Example #8
0
 int64_t MMKVImpl::SScan(DBID db, const Data& key, int64_t cursor, const std::string& pattern, int32_t limit_count,
         const StringArrayResult& results)
 {
     int err = 0;
     RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment);
     StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)();
     if (NULL == set || 0 != err)
     {
         return err;
     }
     StringSet::iterator it = set->begin();
     if (cursor >= set->size())
     {
         return 0;
     }
     it.increment_by(cursor);
     int match_count = 0;
     while (it != set->end())
     {
         std::string key_str;
         it->ToString(key_str);
         if (pattern == ""
                 || stringmatchlen(pattern.c_str(), pattern.size(), key_str.c_str(), key_str.size(), 0) == 1)
         {
             std::string& ss = results.Get();
             ss = key_str;
             match_count++;
             if (limit_count > 0 && match_count >= limit_count)
             {
                 break;
             }
         }
         cursor++;
         it++;
     }
     return it != set->end() ? cursor : 0;
 }
Example #9
0
// Build the list of Custom Levels
void CScreenSingle::BuildCustomLevelsList(int nWidth)
{
	m_Filenames.clear();
	m_pCustom->RemoveAll();

	// Get a list of world names and sort them alphabetically

    uint8 nNumPaths = g_pClientButeMgr->GetNumSingleWorldPaths();

    char pathBuf[128];
	FileEntry** pFilesArray = debug_newa(FileEntry*, nNumPaths);

	if (pFilesArray)
	{
		for (int i=0; i < nNumPaths; ++i)
		{
			pathBuf[0] = '\0';
			g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

			if (pathBuf[0])
			{
                pFilesArray[i] = g_pLTClient->GetFileList(pathBuf);
			}
			else
			{
                pFilesArray[i] = LTNULL;
			}
		}
	}



	char Buf[255];

	for (int i=0; i < nNumPaths; ++i)
	{
		pathBuf[0] = '\0';
		g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

		if (pathBuf[0] && pFilesArray[i])
		{
			sprintf(Buf, "%s\\", pathBuf);
			AddFilesToFilenames(pFilesArray[i], Buf);
            g_pLTClient->FreeFileList(pFilesArray[i]);
		}
	}

	debug_deletea(pFilesArray);

	CLTGUITextCtrl* pItem;

	uint8 nListFontSize = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize");
	int index = 0;
	StringSet::iterator iter = m_Filenames.begin();
	while (iter != m_Filenames.end())
	{
		pItem = CreateTextItem((char *)iter->c_str(), CMD_CUSTOM+index, IDS_HELP_CUSTOMLEVEL);
		pItem->SetFont(LTNULL, nListFontSize);
		pItem->SetFixedWidth(nWidth,LTTRUE);

		m_pCustom->AddControl(pItem);
		++index;
		iter++;
	}

}
Example #10
0
uint32 CScreenSingle::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	if (dwCommand >= CMD_CUSTOM)
	{

		int index = dwCommand - CMD_CUSTOM;

		//is custom level
		if (index < 1000)
		{
			StringSet::iterator iter = m_Filenames.begin();
			while (iter != m_Filenames.end() && index > 0)
			{
				iter++;
				--index;
			}
			if (iter != m_Filenames.end())
			{
				g_pMissionMgr->StartGameFromLevel(iter->c_str());
			}
			
		}
		else
		{
			index -= 1000;
			if (index < g_pMissionButeMgr->GetNumMissions())
			{
				const MISSION* pMission = g_pMissionButeMgr->GetMission(index);
				const LEVEL* pLevel = &pMission->aLevels[0];
				g_pMissionMgr->StartGameFromLevel(pLevel->szLevel);

			}
			return 1;
		}
	}

	switch(dwCommand)
	{

	case CMD_BACK:
		{


#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustom->SetSelection(kNoSelection);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS


			m_pDiff->Show(LTFALSE);
			m_pDiff->SetSelection(kNoSelection);
			m_pDiffFrame->Show(LTFALSE);

			m_pChapter->Show(LTFALSE);
			m_pChapter->SetSelection(kNoSelection);
			m_pChapterFrame->Show(LTFALSE);


			m_pScreenMgr->EscapeCurrentScreen();
			break;
		}
	case CMD_NEW_GAME:
		{

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS

			m_pDiff->Show(LTTRUE);
			m_pDiffFrame->Show(LTTRUE);

			m_pChapter->Show(LTFALSE);
			m_pChapterFrame->Show(LTFALSE);


			SetSelection(GetIndex(m_pDiff));
			m_pDiff->SetSelection(g_pGameClientShell->GetDifficulty());
			UpdateHelpText();

			break;
		}

	case CMD_CHAPTER:
		{

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS

			m_pDiff->Show(LTFALSE);
			m_pDiffFrame->Show(LTFALSE);

			m_pChapter->Show(LTTRUE);
			m_pChapterFrame->Show(LTTRUE);


			SetSelection(GetIndex(m_pChapter));
//			m_pDiff->SetSelection(g_pGameClientShell->GetDifficulty());

			break;
		}

	case CMD_EASY:
		{
			g_pGameClientShell->SetDifficulty(GD_EASY);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_MEDIUM:
		{
			g_pGameClientShell->SetDifficulty(GD_NORMAL);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_HARD:
		{
			g_pGameClientShell->SetDifficulty(GD_HARD);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_INSANE:
		{
			g_pGameClientShell->SetDifficulty(GD_VERYHARD);
			g_pMissionMgr->StartGameNew( );
			break;
		}

	case CMD_LOAD_GAME:
		{
			g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_LOAD);
			break;
		}
	case CMD_CUSTOM_LEVEL:
		{
			m_pDiff->Show(LTFALSE);
			m_pDiffFrame->Show(LTFALSE);
			m_pChapter->Show(LTFALSE);
			m_pChapterFrame->Show(LTFALSE);

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTTRUE);
			m_pCustomFrame->Show(LTTRUE);
			SetSelection(GetIndex(m_pCustom));
#endif // _REMOVE_CUSTOM_LEVELS

			break;
		}
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}
	return 1;
};
Example #11
0
void CScreenHostMission::CreateCampaignList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();
	m_CampaignList.clear();

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	m_CampaignList.insert(DEFAULT_CAMPAIGN);

	// Get new stuff
	struct _finddata_t file;
	intptr_t hFile;

	CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( );
	std::string directory = GetCampaignDir( g_pProfileMgr->GetCurrentProfileName( ), 
		pUserProfile->m_ServerGameOptions.m_eGameType );
	directory += "*.txt"; 

	// find first file
	if((hFile = _findfirst(directory.c_str(), &file)) != -1L)
	{
		do
		{
			if (_stricmp(file.name,DEFAULT_CAMPAIGN_FILE) != 0)
			{
				char *pName = strtok(file.name,".");
				m_CampaignList.insert(pName);
			}

		}
		while(_findnext(hFile, &file) == 0);
	}
	_findclose(hFile);

	// add campaigns to the list control
	for (StringSet::iterator iter = m_CampaignList.begin(); iter != m_CampaignList.end(); ++iter)
	{
		CLTGUITextCtrl* pTextCtrl = NULL;
		uint16 ndx = 0;
		if (iter->compare(DEFAULT_CAMPAIGN) == 0)
		{
			m_pDefaultTextCtrl = CreateTextItem(IDS_HOST_CAMPAIGN_DEFAULT, CMD_OK, LTNULL);
			ndx = m_pListCtrl->AddControl(m_pDefaultTextCtrl);
			m_nDefaultCampaign = ndx;
			m_pDefaultTextCtrl->Show(LTFALSE);
			m_pDefaultTextCtrl->SetParam1(ndx);
			m_pDefaultTextCtrl->SetFont(pFont,nListFontSz);
		}
		else
		{
			pTextCtrl = CreateTextItem((char *)iter->c_str(), CMD_OK, LTNULL);
			pTextCtrl->SetFont(pFont,nListFontSz);
			ndx = m_pListCtrl->AddControl(pTextCtrl);
			pTextCtrl->SetParam1(ndx);
		}

		
		

		if (iter->compare(m_pProfile->m_ServerGameOptions.GetCampaignName()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}