// BLANKART
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file  dehacked.h
/// \brief Dehacked files.

#ifndef __DEHACKED_H__
#define __DEHACKED_H__

#include "m_fixed.h" // for get_number

#ifdef __cplusplus
extern "C" {
#endif

struct dehinfo_t
{
	UINT32 namehash; // excluding prefix (no MT_ or S_)
	UINT32 nameofs; // into strbuf_t
};

void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile);
void DEH_Link(const char *name, dehinfo_t *info, strbuf_t **buf);
INT32 DEH_ReadFreeslot(const char *type, const char *word, INT32 *out);

// SRB2Kart
extern int freeslotusage[2][2];
void DEH_UpdateMaxFreeslots(void);

fixed_t get_number(const char *word);
FUNCPRINTF void deh_warning(const char *first, ...);
void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext);

extern boolean gamedataadded;
extern boolean titlechanged;
extern boolean introchanged;

#define MAXRECURSION 30
extern const char *superactions[MAXRECURSION];
extern UINT8 superstack;

// If the dehacked patch does not match this version, we throw a warning
#define PATCHVERSION 2

#define MAXLINELEN 1024

// the code was first write for a file
// converted to use memory with this functions
struct MYFILE
{
	char *data;
	char *curpos;
	size_t size;
	UINT16 wad;
};
#define myfeof(a) (a->data + a->size <= a->curpos)
char *myfgets(char *buf, size_t bufsize, MYFILE *f);
char *myhashfgets(char *buf, size_t bufsize, MYFILE *f);


#ifdef __cplusplus
} // extern "C"
#endif

#endif
