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"
|
2013-06-01 13:26:22 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/storage.h>
|
2020-09-18 16:45:42 +00:00
|
|
|
|
2013-06-01 13:26:22 +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
|
|
|
|
2023-05-15 16:15:17 +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
|
|
|
|
2023-05-15 16:17:56 +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
|
|
|
|
2023-05-15 16:15:17 +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;
|
2013-06-01 13:26:22 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2023-05-15 16:15:17 +00:00
|
|
|
bool CMap::IsLoaded() const
|
2020-09-18 16:45:42 +00:00
|
|
|
{
|
|
|
|
return m_DataFile.IsOpen();
|
|
|
|
}
|
|
|
|
|
2023-05-15 16:15:17 +00:00
|
|
|
IOHANDLE CMap::File() const
|
2023-05-15 16:04:58 +00:00
|
|
|
{
|
|
|
|
return m_DataFile.File();
|
|
|
|
}
|
|
|
|
|
2023-05-15 16:15:17 +00:00
|
|
|
SHA256_DIGEST CMap::Sha256() const
|
2020-09-18 16:45:42 +00:00
|
|
|
{
|
|
|
|
return m_DataFile.Sha256();
|
|
|
|
}
|
|
|
|
|
2023-05-15 16:15:17 +00:00
|
|
|
unsigned CMap::Crc() const
|
2020-09-18 16:45:42 +00:00
|
|
|
{
|
|
|
|
return m_DataFile.Crc();
|
|
|
|
}
|
|
|
|
|
2023-05-15 16:15:17 +00:00
|
|
|
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; }
|