diff --git a/asext/include/asext_api.h b/asext/include/asext_api.h index 42b5cd7..1a76a92 100644 --- a/asext/include/asext_api.h +++ b/asext/include/asext_api.h @@ -392,3 +392,14 @@ IMPORT_FUNCTION_DEFINE(ASEXT_CASRefCountedBaseClass_InternalRelease);\ IMPORT_FUNCTION_DEFINE(ASEXT_CScriptAny_Release);\ fnASEXT_CallHook *ASEXT_CallHook = NULL;\ fnASEXT_CallCASBaseCallable *ASEXT_CallCASBaseCallable = NULL; + +#define REGISTER_PLAIN_VALUE_OBJECT(name) ASEXT_RegisterObjectType(pASDoc, #name##" plain value object", #name, sizeof(name), asOBJ_VALUE);\ +ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", #name, ObjectBehaviour_Constructor, "void "#name"()", (void *)name##_ctor, 4);\ +ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", #name, ObjectBehaviour_Constructor, "void "#name"(const "#name"& in other)", (void *)name##_copyctor, 4);\ +ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", #name, ObjectBehaviour_Destructor, "void Destruct"#name"()", (void *)name##_dtor, 4);\ +ASEXT_RegisterObjectMethod(pASDoc, "operator=", #name, #name##"& opAssign(const "#name"& in other)", (void *)name##_opassign, 3); + +#define EXTERN_PLAIN_VALUE_OBJECT(name) void name##_ctor(name *pthis);\ +void name##_copyctor(name *a1, name *a2);\ +void name##_dtor(name *pthis);\ +name * SC_SERVER_DECL name##_opassign(name *a1, SC_SERVER_DUMMYARG name *a2); \ No newline at end of file diff --git a/fallguys/physics.h b/fallguys/physics.h index dca09cf..8ea9dbb 100644 --- a/fallguys/physics.h +++ b/fallguys/physics.h @@ -112,30 +112,15 @@ class PhysicVehicleParams int flags; }; -void PhysicPlayerConfigs_ctor(PhysicPlayerConfigs *pthis); -void PhysicPlayerConfigs_copyctor(PhysicPlayerConfigs *a1, PhysicPlayerConfigs *a2); -void PhysicPlayerConfigs_dtor(PhysicPlayerConfigs *pthis); -PhysicPlayerConfigs * SC_SERVER_DECL PhysicPlayerConfigs_opassign(PhysicPlayerConfigs *a1, SC_SERVER_DUMMYARG PhysicPlayerConfigs *a2); - -void PhysicShapeParams_ctor(PhysicShapeParams *pthis); -void PhysicShapeParams_copyctor(PhysicShapeParams *a1, PhysicShapeParams *a2); -void PhysicShapeParams_dtor(PhysicShapeParams *pthis); -PhysicShapeParams * SC_SERVER_DECL PhysicShapeParams_opassign(PhysicShapeParams *a1, SC_SERVER_DUMMYARG PhysicShapeParams *a2); - -void PhysicObjectParams_ctor(PhysicObjectParams *pthis); -void PhysicObjectParams_copyctor(PhysicObjectParams *a1, PhysicObjectParams *a2); -void PhysicObjectParams_dtor(PhysicObjectParams *pthis); -PhysicObjectParams * SC_SERVER_DECL PhysicObjectParams_opassign(PhysicObjectParams *a1, SC_SERVER_DUMMYARG PhysicObjectParams *a2); - -void PhysicWheelParams_ctor(PhysicWheelParams *pthis); -void PhysicWheelParams_copyctor(PhysicWheelParams *a1, PhysicWheelParams *a2); -void PhysicWheelParams_dtor(PhysicWheelParams *pthis); -PhysicWheelParams * SC_SERVER_DECL PhysicWheelParams_opassign(PhysicWheelParams *a1, SC_SERVER_DUMMYARG PhysicWheelParams *a2); - -void PhysicVehicleParams_ctor(PhysicVehicleParams *pthis); -void PhysicVehicleParams_copyctor(PhysicVehicleParams *a1, PhysicVehicleParams *a2); -void PhysicVehicleParams_dtor(PhysicVehicleParams *pthis); -PhysicVehicleParams * SC_SERVER_DECL PhysicVehicleParams_opassign(PhysicVehicleParams *a1, SC_SERVER_DUMMYARG PhysicVehicleParams *a2); +EXTERN_PLAIN_VALUE_OBJECT(PhysicPlayerConfigs); + +EXTERN_PLAIN_VALUE_OBJECT(PhysicShapeParams); + +EXTERN_PLAIN_VALUE_OBJECT(PhysicObjectParams); + +EXTERN_PLAIN_VALUE_OBJECT(PhysicWheelParams); + +EXTERN_PLAIN_VALUE_OBJECT(PhysicVehicleParams); class PhysicWheelClientInfo { diff --git a/fallguys/server_hook.cpp b/fallguys/server_hook.cpp index 5d0dc72..1b5cfbd 100644 --- a/fallguys/server_hook.cpp +++ b/fallguys/server_hook.cpp @@ -241,23 +241,13 @@ void RegisterAngelScriptMethods(void) /* PhysicPlayerConfigs */ - ASEXT_RegisterObjectType(pASDoc, "Physic player creation configs", "PhysicPlayerConfigs", sizeof(PhysicPlayerConfigs), asOBJ_VALUE); - - ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", "PhysicPlayerConfigs", ObjectBehaviour_Constructor, "void PhysicPlayerConfigs()", PhysicPlayerConfigs_ctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", "PhysicPlayerConfigs", ObjectBehaviour_Constructor, "void PhysicPlayerConfigs(const PhysicPlayerConfigs& in other)", PhysicPlayerConfigs_copyctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", "PhysicPlayerConfigs", ObjectBehaviour_Destructor, "void DestructPhysicPlayerConfigs()", PhysicPlayerConfigs_dtor, 4); - ASEXT_RegisterObjectMethod(pASDoc, "operator=", "PhysicPlayerConfigs", "PhysicPlayerConfigs& opAssign(const PhysicPlayerConfigs& in other)", PhysicPlayerConfigs_opassign, 3); + REGISTER_PLAIN_VALUE_OBJECT(PhysicPlayerConfigs); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicPlayerConfigs", "float mass", offsetof(PhysicPlayerConfigs, mass)); /* PhysicShapeParams */ - ASEXT_RegisterObjectType(pASDoc, "Physic shape creation parameters", "PhysicShapeParams", sizeof(PhysicShapeParams), asOBJ_VALUE); - - ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", "PhysicShapeParams", ObjectBehaviour_Constructor, "void PhysicShapeParams()", PhysicShapeParams_ctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", "PhysicShapeParams", ObjectBehaviour_Constructor, "void PhysicShapeParams(const PhysicShapeParams& in other)", PhysicShapeParams_copyctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", "PhysicShapeParams", ObjectBehaviour_Destructor, "void DestructPhysicShapeParams()", PhysicShapeParams_dtor, 4); - ASEXT_RegisterObjectMethod(pASDoc, "operator=", "PhysicShapeParams", "PhysicShapeParams& opAssign(const PhysicShapeParams& in other)", PhysicShapeParams_opassign, 3); + REGISTER_PLAIN_VALUE_OBJECT(PhysicShapeParams); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicShapeParams", "int type", offsetof(PhysicShapeParams, type)); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicShapeParams", "int direction", offsetof(PhysicShapeParams, direction)); @@ -268,12 +258,7 @@ void RegisterAngelScriptMethods(void) /* PhysicObjectParams */ - ASEXT_RegisterObjectType(pASDoc, "Physic object creation parameters", "PhysicObjectParams", sizeof(PhysicObjectParams), asOBJ_VALUE); - - ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", "PhysicObjectParams", ObjectBehaviour_Constructor, "void PhysicObjectParams()", PhysicObjectParams_ctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", "PhysicObjectParams", ObjectBehaviour_Constructor, "void PhysicObjectParams(const PhysicObjectParams& in other)", PhysicObjectParams_copyctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", "PhysicObjectParams", ObjectBehaviour_Destructor, "void DestructPhysicObjectParams()", PhysicObjectParams_dtor, 4); - ASEXT_RegisterObjectMethod(pASDoc, "operator=", "PhysicObjectParams", "PhysicObjectParams& opAssign(const PhysicObjectParams& in other)", PhysicObjectParams_opassign, 3); + REGISTER_PLAIN_VALUE_OBJECT(PhysicObjectParams); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicObjectParams", "float mass", offsetof(PhysicObjectParams, mass)); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicObjectParams", "float linearfriction", offsetof(PhysicObjectParams, linearfriction)); @@ -287,12 +272,7 @@ void RegisterAngelScriptMethods(void) /* PhysicWheelParams */ - ASEXT_RegisterObjectType(pASDoc, "Physic wheel creation parameters", "PhysicWheelParams", sizeof(PhysicWheelParams), asOBJ_VALUE); - - ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", "PhysicWheelParams", ObjectBehaviour_Constructor, "void PhysicWheelParams()", PhysicWheelParams_ctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", "PhysicWheelParams", ObjectBehaviour_Constructor, "void PhysicWheelParams(const PhysicWheelParams& in other)", PhysicWheelParams_copyctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", "PhysicWheelParams", ObjectBehaviour_Destructor, "void DestructPhysicWheelParams()", PhysicWheelParams_dtor, 4); - ASEXT_RegisterObjectMethod(pASDoc, "operator=", "PhysicWheelParams", "PhysicWheelParams& opAssign(const PhysicWheelParams& in other)", PhysicWheelParams_opassign, 3); + REGISTER_PLAIN_VALUE_OBJECT(PhysicWheelParams); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicWheelParams", "edict_t@ ent", offsetof(PhysicWheelParams, ent)); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicWheelParams", "Vector connectionPoint", offsetof(PhysicWheelParams, connectionPoint)); @@ -305,12 +285,7 @@ void RegisterAngelScriptMethods(void) /* PhysicVehicleParams */ - ASEXT_RegisterObjectType(pASDoc, "Physic vehicle creation parameters", "PhysicVehicleParams", sizeof(PhysicVehicleParams), asOBJ_VALUE); - - ASEXT_RegisterObjectBehaviour(pASDoc, "Default constructor", "PhysicVehicleParams", ObjectBehaviour_Constructor, "void PhysicVehicleParams()", PhysicVehicleParams_ctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Copy constructor", "PhysicVehicleParams", ObjectBehaviour_Constructor, "void PhysicVehicleParams(const PhysicVehicleParams& in other)", PhysicVehicleParams_copyctor, 4); - ASEXT_RegisterObjectBehaviour(pASDoc, "Destructor", "PhysicVehicleParams", ObjectBehaviour_Destructor, "void DestructPhysicVehicleParams()", PhysicVehicleParams_dtor, 4); - ASEXT_RegisterObjectMethod(pASDoc, "operator=", "PhysicVehicleParams", "PhysicVehicleParams& opAssign(const PhysicVehicleParams& in other)", PhysicVehicleParams_opassign, 3); + REGISTER_PLAIN_VALUE_OBJECT(PhysicVehicleParams); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicVehicleParams", "float suspensionStiffness", offsetof(PhysicVehicleParams, suspensionStiffness)); ASEXT_RegisterObjectProperty(pASDoc, "", "PhysicVehicleParams", "float suspensionCompression", offsetof(PhysicVehicleParams, suspensionCompression));