2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-02-06 02:30:29 +03:00
metamod-r/metamod/src/linkent.h

21 lines
819 B
C
Raw Normal View History

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
// Function to perform common code of LINK_ENTITY_TO_GAME.
2016-07-26 23:31:47 +07:00
void do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars_t *pev);
#define LINK_ENTITY_TO_GAME(entityName) \
C_DLLEXPORT void entityName(entvars_t *pev); \
void entityName(entvars_t *pev) { \
static ENTITY_FN pfnEntity = NULL; \
2016-07-26 23:31:47 +07:00
static int missing = 0; \
do_link_ent(&pfnEntity, &missing, STRINGIZE(entityName, 0), pev); \
}