#ifdef MENUQC
#define NULL (0, null_entity)
+ #define world NULL
#else
#define NULL (0, world)
#endif
if (pure) {
make_pure(this);
#ifdef CSQC
- setorigin(this, '0 0 10000');
+ setorigin(this, world.mins + '0 0 20');
#endif
#ifdef SVQC
- setorigin(this, '0 0 -10000');
+ setorigin(this, world.maxs - '0 0 20');
#endif
}
return this;
#define NEW(cname, ...) \
OVERLOAD_(spawn##cname, new_pure(cname) P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
- #define TRANSMUTE(cname, this, ...) \
- OVERLOAD_(spawn##cname, (this.transmute = true, this.classname = #cname, this) P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
+ #define _TRANSMUTE(cname, this, ...) \
+ OVERLOAD_(spawn##cname, this P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
#define CONSTRUCT(cname, ...) \
OVERLOAD_(spawn##cname, this P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
#define NEW(cname, ...) \
OVERLOAD(spawn##cname, new_pure(cname),##__VA_ARGS__)
- #define TRANSMUTE(cname, this, ...) \
- OVERLOAD(spawn##cname, (this.transmute = true, this.classname = #cname, this),##__VA_ARGS__)
+ #define _TRANSMUTE(cname, this, ...) \
+ OVERLOAD(spawn##cname, this,##__VA_ARGS__)
#define CONSTRUCT(cname, ...) \
OVERLOAD(spawn##cname, this,##__VA_ARGS__)
#endif
+#define TRANSMUTE(cname, this, ...) MACRO_BEGIN \
+ entity _e = (this); \
+ if (_e.vtblbase != cname##_vtbl) { \
+ _e.transmute = true; \
+ _e.classname = #cname; \
+ _TRANSMUTE(cname, _e, __VA_ARGS__); \
+ } \
+ MACRO_END
+
#define CONSTRUCTOR(cname, ...) \
cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) \
{ \
entityclass(cname, base); \
class(cname).bool instanceOf##cname; \
bool is_##cname(entity e) { return e.instanceOf##cname; } \
+ void isnt_##cname(entity e) { eprint(e); } \
VTBL(cname, base) \
_INIT_STATIC(cname) \
{ \
METHOD(cname, dtor, void(cname this)) \
{ \
METHOD_REFERENCE(cname, dtorimpl)(this); \
+ this.instanceOf##cname = false; \
entity super = SUPER(cname); \
if (super != cname##_vtbl) super.dtor(this); \
} \