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. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <base/system.h>
|
|
|
|
#include <engine/map.h>
|
|
|
|
#include <engine/storage.h>
|
|
|
|
#include "datafile.h"
|
|
|
|
|
|
|
|
class CMap : public IEngineMap
|
|
|
|
{
|
|
|
|
CDataFileReader m_DataFile;
|
|
|
|
public:
|
|
|
|
CMap() {}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void *GetData(int Index) { return m_DataFile.GetData(Index); }
|
2014-01-10 23:46:32 +00:00
|
|
|
virtual int GetUncompressedDataSize(int Index) { return m_DataFile.GetUncompressedDataSize(Index); }
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void *GetDataSwapped(int Index) { return m_DataFile.GetDataSwapped(Index); }
|
|
|
|
virtual void UnloadData(int Index) { m_DataFile.UnloadData(Index); }
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual void *GetItem(int Index, int *pType, int *pID) { return m_DataFile.GetItem(Index, pType, pID); }
|
2011-07-13 20:38:32 +00:00
|
|
|
virtual int GetItemSize(int Index) { return m_DataFile.GetItemSize(Index); }
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void GetType(int Type, int *pStart, int *pNum) { m_DataFile.GetType(Type, pStart, pNum); }
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual void *FindItem(int Type, int ID) { return m_DataFile.FindItem(Type, ID); }
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int NumItems() { return m_DataFile.NumItems(); }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Unload()
|
|
|
|
{
|
|
|
|
m_DataFile.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool Load(const char *pMapName)
|
|
|
|
{
|
|
|
|
IStorage *pStorage = Kernel()->RequestInterface<IStorage>();
|
|
|
|
if(!pStorage)
|
|
|
|
return false;
|
2010-10-06 21:07:35 +00:00
|
|
|
return m_DataFile.Open(pStorage, pMapName, IStorage::TYPE_ALL);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual bool IsLoaded()
|
|
|
|
{
|
|
|
|
return m_DataFile.IsOpen();
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual unsigned Crc()
|
|
|
|
{
|
|
|
|
return m_DataFile.Crc();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern IEngineMap *CreateEngineMap() { return new CMap; }
|