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

    • The Black Arrow

      Hope everyone has the blessing of undying motivation for "The Dark Mod 15th Anniversary Contest". Can't wait to see the many magnificent missions you all may have planned. Good luck, with an Ace!
      · 0 replies
    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 2 replies
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
×
×
  • Create New...