From bb72a2d81cf7e4e6e9d80af4b273d25680b40bd1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 26 Jan 2021 13:40:44 +0200 Subject: [PATCH 1/3] Add idGameEditBase base class for idGameEdit --- neo/framework/Game.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neo/framework/Game.h b/neo/framework/Game.h index af64d2c83..6127db6f9 100644 --- a/neo/framework/Game.h +++ b/neo/framework/Game.h @@ -239,8 +239,14 @@ class idProgram; class idInterpreter; typedef struct prstack_s prstack_t; -// FIXME: this interface needs to be reworked but it properly separates code for the time being -class idGameEdit { + +class idGameEditBase { +public: + virtual ~idGameEditBase( void ) {} +}; + + +class idGameEdit : public idGameEditBase { public: virtual ~idGameEdit( void ) {} From d07ba4284234a1c0e8592146d480606966cceb31 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 26 Jan 2021 14:09:30 +0200 Subject: [PATCH 2/3] Add all virtual methods to idGameEditBase class --- neo/framework/Game.h | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/neo/framework/Game.h b/neo/framework/Game.h index 6127db6f9..044e75ee2 100644 --- a/neo/framework/Game.h +++ b/neo/framework/Game.h @@ -243,6 +243,79 @@ typedef struct prstack_s prstack_t; class idGameEditBase { public: virtual ~idGameEditBase( void ) {} + + // These are the canonical idDict to parameter parsing routines used by both the game and tools. + virtual void ParseSpawnArgsToRenderLight( const idDict *args, renderLight_t *renderLight ) = 0; + virtual void ParseSpawnArgsToRenderEntity( const idDict *args, renderEntity_t *renderEntity ) = 0; + virtual void ParseSpawnArgsToRefSound( const idDict *args, refSound_t *refSound ) = 0; + + // Animation system calls for non-game based skeletal rendering. + virtual idRenderModel * ANIM_GetModelFromEntityDef( const char *classname ) = 0; + virtual const idVec3 &ANIM_GetModelOffsetFromEntityDef( const char *classname ) = 0; + virtual idRenderModel * ANIM_GetModelFromEntityDef( const idDict *args ) = 0; + virtual idRenderModel * ANIM_GetModelFromName( const char *modelName ) = 0; + virtual const idMD5Anim * ANIM_GetAnimFromEntityDef( const char *classname, const char *animname ) = 0; + virtual int ANIM_GetNumAnimsFromEntityDef( const idDict *args ) = 0; + virtual const char * ANIM_GetAnimNameFromEntityDef( const idDict *args, int animNum ) = 0; + virtual const idMD5Anim * ANIM_GetAnim( const char *fileName ) = 0; + virtual int ANIM_GetLength( const idMD5Anim *anim ) = 0; + virtual int ANIM_GetNumFrames( const idMD5Anim *anim ) = 0; + virtual void ANIM_CreateAnimFrame( const idRenderModel *model, const idMD5Anim *anim, int numJoints, idJointMat *frame, int time, const idVec3 &offset, bool remove_origin_offset ) = 0; + virtual idRenderModel * ANIM_CreateMeshForAnim( idRenderModel *model, const char *classname, const char *animname, int frame, bool remove_origin_offset ) = 0; + + // Articulated Figure calls for AF editor and Radiant. + virtual bool AF_SpawnEntity( const char *fileName ) = 0; + virtual void AF_UpdateEntities( const char *fileName ) = 0; + virtual void AF_UndoChanges( void ) = 0; + virtual idRenderModel * AF_CreateMesh( const idDict &args, idVec3 &meshOrigin, idMat3 &meshAxis, bool &poseIsSet ) = 0; + + + // Entity selection. + virtual void ClearEntitySelection( void ) = 0; + virtual int GetSelectedEntities( idEntity *list[], int max ) = 0; + virtual void AddSelectedEntity( idEntity *ent ) = 0; + + // Selection methods + virtual void TriggerSelected() = 0; + + // Entity defs and spawning. + virtual const idDict * FindEntityDefDict( const char *name, bool makeDefault = true ) const = 0; + virtual void SpawnEntityDef( const idDict &args, idEntity **ent ) = 0; + virtual idEntity * FindEntity( const char *name ) const = 0; + virtual const char * GetUniqueEntityName( const char *classname ) const = 0; + + // Entity methods. + virtual void EntityGetOrigin( idEntity *ent, idVec3 &org ) const = 0; + virtual void EntityGetAxis( idEntity *ent, idMat3 &axis ) const = 0; + virtual void EntitySetOrigin( idEntity *ent, const idVec3 &org ) = 0; + virtual void EntitySetAxis( idEntity *ent, const idMat3 &axis ) = 0; + virtual void EntityTranslate( idEntity *ent, const idVec3 &org ) = 0; + virtual const idDict * EntityGetSpawnArgs( idEntity *ent ) const = 0; + virtual void EntityUpdateChangeableSpawnArgs( idEntity *ent, const idDict *dict ) = 0; + virtual void EntityChangeSpawnArgs( idEntity *ent, const idDict *newArgs ) = 0; + virtual void EntityUpdateVisuals( idEntity *ent ) = 0; + virtual void EntitySetModel( idEntity *ent, const char *val ) = 0; + virtual void EntityStopSound( idEntity *ent ) = 0; + virtual void EntityDelete( idEntity *ent ) = 0; + virtual void EntitySetColor( idEntity *ent, const idVec3 color ) = 0; + + // Player methods. + virtual bool PlayerIsValid() const = 0; + virtual void PlayerGetOrigin( idVec3 &org ) const = 0; + virtual void PlayerGetAxis( idMat3 &axis ) const = 0; + virtual void PlayerGetViewAngles( idAngles &angles ) const = 0; + virtual void PlayerGetEyePosition( idVec3 &org ) const = 0; + + // In game map editing support. + virtual const idDict * MapGetEntityDict( const char *name ) const = 0; + virtual void MapSave( const char *path = NULL ) const = 0; + virtual void MapSetEntityKeyVal( const char *name, const char *key, const char *val ) const = 0; + virtual void MapCopyDictToEntity( const char *name, const idDict *dict ) const = 0; + virtual int MapGetUniqueMatchingKeyVals( const char *key, const char *list[], const int max ) const = 0; + virtual void MapAddEntity( const idDict *dict ) const = 0; + virtual int MapGetEntitiesMatchingClassWithString( const char *classname, const char *match, const char *list[], const int max ) const = 0; + virtual void MapRemoveEntity( const char *name ) const = 0; + virtual void MapEntityTranslate( const char *name, const idVec3 &v ) const = 0; }; From 7619985ad7c28386b91f5a25341e32265abfd4d4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 26 Jan 2021 14:31:20 +0200 Subject: [PATCH 3/3] Store gameEdit as idGameEditBase --- neo/d3xp/GameEdit.cpp | 4 ++-- neo/framework/Common.cpp | 2 +- neo/framework/Game.h | 4 ++-- neo/game/GameEdit.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/neo/d3xp/GameEdit.cpp b/neo/d3xp/GameEdit.cpp index 5d68b80f7..822ccf726 100644 --- a/neo/d3xp/GameEdit.cpp +++ b/neo/d3xp/GameEdit.cpp @@ -670,8 +670,8 @@ void idEditEntities::DisplayEntities( void ) { =============================================================================== */ -idGameEditExt gameEditLocal; -idGameEdit * gameEdit = &gameEditLocal; +idGameEditExt gameEditLocal; +idGameEditBase * gameEdit = &gameEditLocal; /* diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 7d98d7800..d1133d996 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -126,7 +126,7 @@ unsigned int com_msgID = -1; #ifdef __DOOM_DLL__ idGame * game = NULL; -idGameEdit * gameEdit = NULL; +idGameEditBase * gameEdit = NULL; #endif // writes si_version to the config file - in a kinda obfuscated way diff --git a/neo/framework/Game.h b/neo/framework/Game.h index 044e75ee2..44d30fa96 100644 --- a/neo/framework/Game.h +++ b/neo/framework/Game.h @@ -397,7 +397,7 @@ class idGameEdit : public idGameEditBase { virtual void MapEntityTranslate( const char *name, const idVec3 &v ) const; }; -extern idGameEdit * gameEdit; +extern idGameEditBase * gameEdit; // In game script Debugging Support class idGameEditExt : public idGameEdit { @@ -467,7 +467,7 @@ typedef struct { int version; // API version idGame * game; // interface to run the game - idGameEdit * gameEdit; // interface for in-game editing + idGameEditBase * gameEdit; // interface for in-game editing } gameExport_t; diff --git a/neo/game/GameEdit.cpp b/neo/game/GameEdit.cpp index 57e7eb28a..5e416ba5d 100644 --- a/neo/game/GameEdit.cpp +++ b/neo/game/GameEdit.cpp @@ -670,8 +670,8 @@ void idEditEntities::DisplayEntities( void ) { =============================================================================== */ -idGameEditExt gameEditLocal; -idGameEdit * gameEdit = &gameEditLocal; +idGameEditExt gameEditLocal; +idGameEditBase * gameEdit = &gameEditLocal; /*