Page 1 of 1

Override class or create second,

PostPosted: Wed Jan 11, 12 8:31 pm
by bambi
Hi Codders!

I have a question, is it better to expand a class or to expand from that class's parent such as,

Code: Select all
class DeusExGameInfo expands GameInfo
   config;


Should I expand from DeusExGameInfo and override all its functions, which I want, or should I just expand from GameInfo?

PostPosted: Wed Jan 11, 12 8:36 pm
by Gishank
There's no 'better' way about it, it's purely a matter of choice.

Think of it this way, "AAA.uc" derives from "AAB.uc", AAA.uc has content or modifications in it that you want which the parent "AAB.uc" doesn't have - so you'd use the child "AAB.uc" as the parent so you don't have to do as much work.

Re: Override class or create second,

PostPosted: Wed Jan 11, 12 9:13 pm
by ~ô¿ô~Nobody~
bambi wrote:Hi Codders!
RAWR, It's coders... CODERS!
Anyway.. to your question..


bambi wrote:I have a question, is it better to expand a class or to expand from that class's parent such as,

Code: Select all
class DeusExGameInfo expands GameInfo
   config;


Should I expand from DeusExGameInfo and override all its functions, which I want, or should I just expand from GameInfo?
That depends on what you want to do.
I don't know your intention but in case you want to make a new game type for MP, then extending DeusExGameInfo is not the way.
You should always extend the class that has the most similarities to what you want to do.

If you want to make a game class for a game type that's basically Team deathmatch, you should extend it 'TeamDMGame'.
If it shall be a kind of deathmatch, you should extend it 'Deathmatchgame'.
In case you want to make something very different, you should possibly go up one level in the class hierarchy and extend it DeusExMPGame.

If course, you could also extend your TDM game type from DeusExMPGame for instance, but then you have to write all the team game code by yourself, instead of inheriting it from the existing 'TeamDMGame' game class.


A better but common example would be, if you wanted to make a LAM that shots shrapnel for instance. Coding wise, it will make your life much easier if you extend it the LAM class instead of 'DeusExWeapon' or something similar.. because your class will inherit the grenade code from the LAM and you don't have to write it all on your own.


So yeah, exactly what Klop said! :o

PostPosted: Wed Jan 11, 12 10:06 pm
by bambi
I understand Nobody.

This project, if I succeed, will inspire the whole dx community.

I'm fixing a very old mod that the owner has given up on. And its a great mod, with features that people are just starting to adopt.

It will be awesome, but its very slow and boring work right now. I have to open class by class and change just a couple letters....

thanks codder

PostPosted: Thu Jan 12, 12 12:00 am
by ~DJ~
If you don't mind, would you tell us more information about this forgotten mod? :oops:

PostPosted: Thu Jan 12, 12 12:28 am
by bambi
Lol. No can do. The more I work on it the more I realize how much work this will take. I'm going to ask Chin to get some maps with this mod on it.

Lets just say there are about 600 classes that I have to manually edit.

PostPosted: Thu Jan 12, 12 2:35 am
by Poor
Notepad++ has a mass replace feature and supports regular expressions (this allows you to do complex find and replaces).

PostPosted: Thu Jan 12, 12 3:21 am
by bambi
Ok please explain poor, as I'm already running intro trouble using the mass name changing. Some things are getting changed that shouldn't be.