Jump to content
The Dark Mod Forums

Having problems creating new classes in fhdoom engine


HMart

Recommended Posts

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:

header

class myclass : public idclass{
public:
CLASS_PROTOTYPE( myclass);

    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)
END_CLASS

void myclass::Init(){}

etc.

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.

Link to comment
Share on other sites

What are you using?

 

SCONS, CMAKE, MSVC?

 

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:

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...