2016-07-26 23:31:47 +07:00
|
|
|
#pragma once
|
2016-07-04 12:07:29 +06:00
|
|
|
|
|
|
|
// Comments from SDK dlls/util.h:
|
|
|
|
//! This is the glue that hooks .MAP entity class names to our CPP classes.
|
|
|
|
//! The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress().
|
|
|
|
//! The function is used to intialize / allocate the object for the entity.
|
|
|
|
|
|
|
|
// Adapted from LINK_ENTITY_TO_FUNC in adminmod linkfunc.cpp.
|
2016-07-26 23:31:47 +07:00
|
|
|
typedef void (*ENTITY_FN)(entvars_t *);
|
2016-07-04 12:07:29 +06:00
|
|
|
|
2016-07-26 15:18:32 +03:00
|
|
|
// Function to perform common code of LINK_ENTITY_TO_GAME.
|
2017-05-09 19:31:09 +03:00
|
|
|
void do_link_ent(ENTITY_FN* pfnEntity, int* missing, const char* entStr, entvars_t* pev);
|
2016-07-26 15:18:32 +03:00
|
|
|
|
|
|
|
#define LINK_ENTITY_TO_GAME(entityName) \
|
2017-01-13 02:04:11 +03:00
|
|
|
C_DLLEXPORT void entityName(entvars_t *pev) { \
|
|
|
|
static ENTITY_FN pfnEntity = nullptr; \
|
2016-07-26 23:31:47 +07:00
|
|
|
static int missing = 0; \
|
2016-07-26 15:18:32 +03:00
|
|
|
do_link_ent(&pfnEntity, &missing, STRINGIZE(entityName, 0), pev); \
|
|
|
|
}
|