mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
7acf2c1573
Simplify the usage of datafile reader and writer by adding utility functions to read and write zero-terminated UTF-8 strings. Improve validation of string data read from datafiles. It is ensure that string data is null-terminated, has no internal NUL-characters and is valid UTF-8. Fix loading of external sounds in the editor. The wrong path variable was being used, so the sound files would not be loaded from correct folder. Add tests for new datafile reader/writer functions.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
/* (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. */
|
|
#ifndef ENGINE_MAP_H
|
|
#define ENGINE_MAP_H
|
|
|
|
#include "kernel.h"
|
|
#include <base/hash.h>
|
|
|
|
enum
|
|
{
|
|
MAX_MAP_LENGTH = 128
|
|
};
|
|
|
|
class IMap : public IInterface
|
|
{
|
|
MACRO_INTERFACE("map", 0)
|
|
public:
|
|
virtual int GetDataSize(int Index) const = 0;
|
|
virtual void *GetData(int Index) = 0;
|
|
virtual void *GetDataSwapped(int Index) = 0;
|
|
virtual const char *GetDataString(int Index) = 0;
|
|
virtual void UnloadData(int Index) = 0;
|
|
virtual int NumData() const = 0;
|
|
|
|
virtual int GetItemSize(int Index) = 0;
|
|
virtual void *GetItem(int Index, int *pType = nullptr, int *pID = nullptr) = 0;
|
|
virtual void GetType(int Type, int *pStart, int *pNum) = 0;
|
|
virtual int FindItemIndex(int Type, int ID) = 0;
|
|
virtual void *FindItem(int Type, int ID) = 0;
|
|
virtual int NumItems() const = 0;
|
|
};
|
|
|
|
class IEngineMap : public IMap
|
|
{
|
|
MACRO_INTERFACE("enginemap", 0)
|
|
public:
|
|
virtual bool Load(const char *pMapName) = 0;
|
|
virtual void Unload() = 0;
|
|
virtual bool IsLoaded() const = 0;
|
|
virtual IOHANDLE File() const = 0;
|
|
|
|
virtual SHA256_DIGEST Sha256() const = 0;
|
|
virtual unsigned Crc() const = 0;
|
|
virtual int MapSize() const = 0;
|
|
};
|
|
|
|
extern IEngineMap *CreateEngineMap();
|
|
|
|
#endif
|