I'm gonna agree, using a pointer to an attack type may increase
maintainability if done well.
It's actually going to be slightly slower than just passing everything as
parameters.  Information passed as a parameter effectively gets put into a
structure anyway, but with your own structure, you're going to have the
added overhead of allocating the memory for it and calculating offsets when
you reference something inside of it.
But again, the difference is so small, it's silly to worry about compared to
how it's going to affect maintainability.
--Palrich, NO SLEEP.

----- Original Message ----- 
From: "Chad Simmons" <[EMAIL PROTECTED]>
To: "Dale Kingston" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Tuesday, August 19, 2003 2:33 AM
Subject: Re: Question (of course)


> --- Dale Kingston <[EMAIL PROTECTED]> wrote:
> > Ok well in the start of the combat system it locates like if your hand
to
> > hand melee or ranged.
> >
> > It finds that and then sends you to that function now for melee and
ranged
> > that will locate your weapon and then pass you to a like attack_melee
> > function that figurs the damage and everything. That then passes all the
> > info to a (not sure what to call it) a function in the victims struct
called
> > attacked that gives it
> > ch->fighting->attacked(ch, sn, dam_type, dam, ATTACK_MELEE, wield);
> >
> > ok then that will call all the like block dodge all that and then call
> > damage. All the while it just kind of keeps stock pilling on all these
> > parameters that it's sending. So what I was wondering is rather then
> > collecting all this info and passing it as I go. Would it be smarter to
make
> > like an attack object that had all this infor to it. And then just run
> > through the functions with a pointer on the char to the attack object?
>
> Yes, it would be better for 2 reasons:
>
> The first is that it saves you a lot of typing when you call all these
> functions ;p
>
> The second is that when you've decided that you want to add Yet Another
> Variable (tm) to you're "attack" proceedure, you'll have to go back
through and
> add it to all the function calls, etc. Much easiser to just add it to the
> attack object, and just use what you need from the various functions.
>
> Easily maintainable code == A Good Thing(tm)
>
>
> ~Kender
>
>
> =====
> -----BEGIN GEEK CODE BLOCK-----
> Version 3.1
> GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$
> P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O
> M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@
> b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
> ------END GEEK CODE BLOCK------
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to