Jump to content
The Dark Mod Forums
Sign in to follow this  
HMart

Having problems creating new classes in fhdoom engine

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.

Share this post


Link to post
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...)

Share this post


Link to post
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

Share this post


Link to post
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:

Share this post


Link to post
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

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...