mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Use std::vector<CMapNameItem> instead of sorted_array
This commit is contained in:
parent
9b2f0fe3c4
commit
9dece943e7
|
@ -1,7 +1,7 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <base/tl/sorted_array.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "base/system.h"
|
||||
#include "gamecontext.h"
|
||||
|
@ -3080,18 +3080,19 @@ void CGameContext::ConAddMapVotes(IConsole::IResult *pResult, void *pUserData)
|
|||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
||||
sorted_array<CMapNameItem> MapList;
|
||||
std::vector<CMapNameItem> MapList;
|
||||
pSelf->Storage()->ListDirectory(IStorage::TYPE_ALL, "maps", MapScan, &MapList);
|
||||
std::sort(MapList.begin(), MapList.end());
|
||||
|
||||
for(int i = 0; i < MapList.size(); i++)
|
||||
for(auto &Item : MapList)
|
||||
{
|
||||
char aDescription[64];
|
||||
str_format(aDescription, sizeof(aDescription), "Map: %s", MapList[i].m_aName);
|
||||
str_format(aDescription, sizeof(aDescription), "Map: %s", Item.m_aName);
|
||||
|
||||
char aCommand[IO_MAX_PATH_LENGTH * 2 + 10];
|
||||
char aMapEscaped[IO_MAX_PATH_LENGTH * 2];
|
||||
char *pDst = aMapEscaped;
|
||||
str_escape(&pDst, MapList[i].m_aName, aMapEscaped + sizeof(aMapEscaped));
|
||||
str_escape(&pDst, Item.m_aName, aMapEscaped + sizeof(aMapEscaped));
|
||||
str_format(aCommand, sizeof(aCommand), "change_map \"%s\"", aMapEscaped);
|
||||
|
||||
pSelf->AddVote(aDescription, aCommand);
|
||||
|
@ -3102,15 +3103,12 @@ void CGameContext::ConAddMapVotes(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
int CGameContext::MapScan(const char *pName, int IsDir, int DirType, void *pUserData)
|
||||
{
|
||||
sorted_array<CMapNameItem> *pMapList = (sorted_array<CMapNameItem> *)pUserData;
|
||||
|
||||
if(IsDir || !str_endswith(pName, ".map"))
|
||||
return 0;
|
||||
|
||||
CMapNameItem Item;
|
||||
int Length = str_length(pName);
|
||||
str_truncate(Item.m_aName, sizeof(Item.m_aName), pName, Length - 4);
|
||||
pMapList->add(Item);
|
||||
str_truncate(Item.m_aName, sizeof(Item.m_aName), pName, str_length(pName) - str_length(".map"));
|
||||
static_cast<std::vector<CMapNameItem> *>(pUserData)->push_back(Item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue