Jump to content


Having problems creating new classes in fhdoom engine

  • Please log in to reply
4 replies to this topic

#1 HMart


    Advanced Member

  • Member
  • PipPipPip
  • 821 posts

Posted 14 November 2017 - 01:20 PM

Hello guys, I know this is not the TDM engine but is based on idtech 4 has well so i hope you guys can help me. I'm trying to create a new class of object in a separate file, for that i created a new .header file and a new .cpp file for my class, i then tried to copy what idSoftware has done for their own classes but no matter what i do, visual studio never compiles and gives me a bunch of errors but what really confuses me is that the errors point to the original engine code no my own code!? Is if my files are breaking the id code not mine. 


This is what i'm doing:


class myclass : public idclass{

    myclass(){Init()}; // constructor
    ~myclass(){Init()}; // destrutor

members vars
methods / functions


cpp file

#include "../idlib/precompiled.h"
#pragma hdrstop

#include "Game_local.h" // myclass header is called from inside here

CLASS_DECLARATION( idclass, myclass)

void myclass::Init(){}


I did the same thing using structs instead (afaik they are just like classes) but directly from inside the player.h and player.cpp file and that worked fine, but now i wanted to make it a separate class and i'm having a bunch of problems, i most say that i'm a beginner c++ and OOP so i most be forgetting something basic, or i'm forgetting to declare my class in some other id file, any help would be appreciated.  

#2 nbohr1more


    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9505 posts

Posted 15 November 2017 - 02:59 PM

What are you using?




I only know MSVC but I there should be an equivalent process in SCONS (etc).

You need to add the class to the project in the project definition file. In MSVC these are the vproj

files and you can add entries via GUI actions to the project trees.

Please visit TDM's IndieDB site and help promote the mod:


(Yeah, shameless promotion... but traffic is traffic folks...)

#3 HMart


    Advanced Member

  • Member
  • PipPipPip
  • 821 posts

Posted 15 November 2017 - 03:28 PM

I'm using MSVC 2015 and the project was created with CMake.


GUI actions you say, will need to google that, is the first time i'm doing such a thing but that info should be enough for me to carry on, thanks man for the help, this was driving me crazy. :)



edit: Thank you this really helped!


Not only was i able to find that Visual studio was saving the files in the wrong folder by default, i also found that i add to include my classes inside the CMakelists.txt for them to finally work.


Once again thank you. :)

Edited by HMart, 15 November 2017 - 04:32 PM.

#4 HMart


    Advanced Member

  • Member
  • PipPipPip
  • 821 posts

Posted 16 November 2017 - 12:41 PM

Just for future documentation, and if something like this happens to someone else, after making my new classes they were not being recognized by the game, even tho i did everything id did, after some head scratching and testing, found that some of the problems I was having, was because Visual Studio reset my project post-compile settings (for some reason) and so when i was compiling the project, it was not replacing the .exe in the game folder. :wacko:   

#5 HMart


    Advanced Member

  • Member
  • PipPipPip
  • 821 posts

Posted 16 November 2017 - 02:33 PM

And still problems, now my class works fine, it is detected in game and i can interact with it BUT any model i assign to it with the model key, never renders ingame, even models that work in other classes, no obvious error in the console that i can see, no black box or black model, just no visual model at all ...   :wacko:  


edit: With a hint from greebo, this was solved, i didn't do everything id software did like i thought above, apart from having to include my own show() and hide() functions and calling idEntity::Hide() and show respectively from inside them i also needed to include inside my class think() method a call to idEntity::Think(), after this the model rendered ingame.  

Edited by HMart, 20 November 2017 - 04:03 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users