1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef ENGINE_MAP_H
4#define ENGINE_MAP_H
5
6#include <base/hash.h>
7#include <base/types.h>
8
9#include <memory>
10
11class IStorage;
12struct CUuid;
13
14enum
15{
16 MAX_MAP_LENGTH = 128
17};
18
19class IMap
20{
21public:
22 virtual ~IMap() = default;
23
24 virtual int GetDataSize(int Index) const = 0;
25 virtual void *GetData(int Index) = 0;
26 virtual void *GetDataSwapped(int Index) = 0;
27 virtual const char *GetDataString(int Index) = 0;
28 virtual void UnloadData(int Index) = 0;
29 virtual int NumData() const = 0;
30
31 virtual int GetItemSize(int Index) = 0;
32 virtual void *GetItem(int Index, int *pType = nullptr, int *pId = nullptr, CUuid *pUuid = nullptr) = 0;
33 virtual void GetType(int Type, int *pStart, int *pNum) = 0;
34 virtual int FindItemIndex(int Type, int Id) = 0;
35 virtual void *FindItem(int Type, int Id) = 0;
36 virtual int NumItems() const = 0;
37
38 [[nodiscard]] virtual bool Load(const char *pFullName, IStorage *pStorage, const char *pPath, int StorageType) = 0;
39 [[nodiscard]] virtual bool Load(IStorage *pStorage, const char *pPath, int StorageType) = 0;
40 virtual void Unload() = 0;
41 virtual bool IsLoaded() const = 0;
42 virtual IOHANDLE File() const = 0;
43
44 /**
45 * Returns the full name of the currently loaded map.
46 *
47 * @return Full map name, e.g. `subfolder1/subfolder2/my_map`.
48 */
49 virtual const char *FullName() const = 0;
50 /**
51 * Returns the base name of the currently loaded map.
52 *
53 * @return Base map name, e.g. `my_map`.
54 */
55 virtual const char *BaseName() const = 0;
56 /**
57 * Returns the path of the currently loaded map.
58 *
59 * @return Map path, e.g. `maps/subfolder1/subfolder2/my_map.map`.
60 */
61 virtual const char *Path() const = 0;
62 virtual SHA256_DIGEST Sha256() const = 0;
63 virtual unsigned Crc() const = 0;
64 virtual int Size() const = 0;
65};
66
67extern std::unique_ptr<IMap> CreateMap();
68
69#endif
70