06 May, 2009, JohnnyStarr wrote in the 1st comment:
Votes: 0
The codebase is ROM 2.4 (quickmud) and i'm still trying to wrap my brain around the macros it uses.
I know that allot of it has to do with bit-flags and get / set stuff.
I do have several books on C but most of them are pretty simple and i'm wondering if anyone knows of any good documentation? or of someone really savy could explain how and why they work? thanks :wink:
06 May, 2009, Davion wrote in the 2nd comment:
Votes: 0
The macro's in C are really just direct replacements for code. An example

#define IS_GREATER(a, b) (a > b)


if(IS_GREATER(x, y) ) print ("Greater!\n");


When the C compiler runs, it'll just replace the IS_GREATER(x,y) with the defined macro. So post compile it'll just be
if(x > b)


It can get tricky sometimes when you have a parse error in a macro (in the header file) and the actual error is pointing to the line it's used in the .c file. Can get annoying quick ;).
07 May, 2009, Hades_Kane wrote in the 3rd comment:
Votes: 0
Macros are just time savers really.

For example, I have one for "is_safe" which relates to whether or not a character is safe from PK combat (or more specifically, can character A attack character B). A character under level 5 is safe, so is someone that hasn't removed their PK Safe, so is someone in a safe room, but if an arena quest with various flags are set they may not be, or if the room they are flagged in is flagged arena…

So, I declare one time in my code what is_safe is, then everywhere I need to check for whether or not a character can attack another, rather than running through a laundry list of conditions, I can just check for is_safe and I'm done with it.
07 May, 2009, JohnnyStarr wrote in the 4th comment:
Votes: 0
thanks for the clarification guys.

hey kane, i know you're mud is a ROM right? What kind of quest system do you have?
I'm going to implement a quest system similar WoW with a few differences. Is there any examples you used to build off of?
or did you just start from scratch? dont get me wrong, i'm all about being original, but it helps to have at least some basis
of comparison.
07 May, 2009, David Haley wrote in the 5th comment:
Votes: 0
Quote
So, I declare one time in my code what is_safe is, then everywhere I need to check for whether or not a character can attack another, rather than running through a laundry list of conditions, I can just check for is_safe and I'm done with it.

Frankly this is a good example of where a function would be more appropriate than a macro. Macros are appropriate when it's important to be expanding code in the context it's used in. When you're just testing something, you're better off with a function, if anything because its implementation is separated from its declaration (and there are other benefits as well).
07 May, 2009, Hades_Kane wrote in the 6th comment:
Votes: 0
David Haley said:
Quote
So, I declare one time in my code what is_safe is, then everywhere I need to check for whether or not a character can attack another, rather than running through a laundry list of conditions, I can just check for is_safe and I'm done with it.

Frankly this is a good example of where a function would be more appropriate than a macro. Macros are appropriate when it's important to be expanding code in the context it's used in. When you're just testing something, you're better off with a function, if anything because its implementation is separated from its declaration (and there are other benefits as well).


I probably have more things as a function than a macro, honestly, but at work it was the quickest thing I could think of to illustrate what macros can help you do, and that's to save time and energy :p I think some of the macros I do have are things like:
IS_FIGHTER, IS_MALE, IS_EVIL etc. quick things like basically check a number in a pfile for me so I don't have to remember what # class, gender, or alignment is.


staryavsky said:
thanks for the clarification guys.

hey kane, i know you're mud is a ROM right? What kind of quest system do you have?
I'm going to implement a quest system similar WoW with a few differences. Is there any examples you used to build off of?
or did you just start from scratch? dont get me wrong, i'm all about being original, but it helps to have at least some basis
of comparison.


We're using Mob/Room/Obj progs to custom make all of our quests. We're working on and implementing a playable storyline that will be a series of interlinked, inter-area quests that will help guide the player through the game, offering exp, money, equipment, and class upgrades as rewards. We decided against autoquests a while ago.

Good luck with whatever route you choose!
0.0/6