ddnet/src/engine/shared/map.cpp

107 lines
1.9 KiB
C++
Raw Normal View History

2010-11-20 10:37:14 +00:00
/* (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. */
2020-09-18 16:45:42 +00:00
#include "map.h"
2010-05-29 07:25:38 +00:00
#include <engine/storage.h>
2020-09-18 16:45:42 +00:00
#include <game/mapitems.h>
2022-02-14 23:32:04 +00:00
CMap::CMap() = default;
2020-09-18 16:45:42 +00:00
void *CMap::GetData(int Index)
{
return m_DataFile.GetData(Index);
}
2023-05-15 16:04:58 +00:00
int CMap::GetDataSize(int Index) const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.GetDataSize(Index);
}
2023-05-15 16:04:58 +00:00
2020-09-18 16:45:42 +00:00
void *CMap::GetDataSwapped(int Index)
{
return m_DataFile.GetDataSwapped(Index);
}
2023-05-15 16:04:58 +00:00
2020-09-18 16:45:42 +00:00
void CMap::UnloadData(int Index)
{
m_DataFile.UnloadData(Index);
}
2023-05-15 16:04:58 +00:00
int CMap::NumData() const
{
return m_DataFile.NumData();
}
2020-09-18 16:45:42 +00:00
void *CMap::GetItem(int Index, int *pType, int *pID)
{
return m_DataFile.GetItem(Index, pType, pID);
}
2023-05-15 16:04:58 +00:00
2020-09-18 16:45:42 +00:00
int CMap::GetItemSize(int Index)
{
return m_DataFile.GetItemSize(Index);
}
2023-05-15 16:04:58 +00:00
2020-09-18 16:45:42 +00:00
void CMap::GetType(int Type, int *pStart, int *pNum)
{
m_DataFile.GetType(Type, pStart, pNum);
}
2023-05-15 16:04:58 +00:00
2020-09-18 16:45:42 +00:00
void *CMap::FindItem(int Type, int ID)
{
return m_DataFile.FindItem(Type, ID);
}
2023-05-15 16:04:58 +00:00
int CMap::NumItems() const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.NumItems();
}
bool CMap::Load(const char *pMapName)
{
IStorage *pStorage = Kernel()->RequestInterface<IStorage>();
if(!pStorage)
return false;
if(!m_DataFile.Open(pStorage, pMapName, IStorage::TYPE_ALL))
return false;
// check version
const CMapItemVersion *pItem = (CMapItemVersion *)m_DataFile.FindItem(MAPITEMTYPE_VERSION, 0);
if(!pItem || pItem->m_Version != CMapItemVersion::CURRENT_VERSION)
return false;
return true;
2020-09-18 16:45:42 +00:00
}
2023-05-15 16:04:58 +00:00
void CMap::Unload()
{
m_DataFile.Close();
}
bool CMap::IsLoaded() const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.IsOpen();
}
IOHANDLE CMap::File() const
2023-05-15 16:04:58 +00:00
{
return m_DataFile.File();
}
SHA256_DIGEST CMap::Sha256() const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.Sha256();
}
unsigned CMap::Crc() const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.Crc();
}
int CMap::MapSize() const
2020-09-18 16:45:42 +00:00
{
return m_DataFile.MapSize();
}
2010-05-29 07:25:38 +00:00
extern IEngineMap *CreateEngineMap() { return new CMap; }