Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ More C questions

More C questions

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by GregS   (15 posts)  Bio
Date Tue 23 Aug 2005 09:06 PM (UTC)
Message
1) I'm assuming the ".h" after a file name means header? Are these files just lists of structs and variables for use in other ".c" files?

2) In the file "mud.h" there are structs called "char_morph" and "morph_data". Are these statistics/information about player characters?

3) What is the very first function run when the mud starts?

4) Can anyone break down this statement and tell me exactly what it does?
"typedef void DO_FUN args( ( CHAR_DATA *ch, char *argument ) );"

~Greg
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 23 Aug 2005 09:30 PM (UTC)
Message
1) Header files

Yes, .h means header. A header is like a .c file in that everything that can go into a .c file can also go into a .h file. However the convention is that header files declare things for use later on, whereas code files actually define things.

Think of having a Java program where you have a class declaration, with methods, but without implementing the methods; then, later you write another file where you implement all the methods. Whenever you want to use the class in another .c file, you include the header. But the implementation of the methods is separate from the header.

This separation of header and code has its ups and downs...

In any case, the simple answer is that a header is where you put stuff that you want to be visible to many .c files.

2) char_morph, morph_data

I don't know exactly, but I assume these are structures about the player's current morph (shapeshift?) status. Just a guess, though.

3) 'main'

Like in Java, there is a 'main' function. So, if you look for the 'main' function, that's the one that runs when the program begins. It should be in comm.c.

4) function typedef

This is a function typedef, that I mentioned in the other post. It means that DO_FUN is a type name for a function that returns void and takes parameters CHAR_DATA* and char*.

Most typedefs look like this:

typedef [type name] [type alias]

Function typedefs are different in that they look like this:

typedef [return type] [function type alias] [function arguments]

If you are like me and think that the function arguments are part of the function "type", and thus should follow the first scheme, you will find the syntax slightly odd. But in any case, that's what it means...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #2 on Tue 23 Aug 2005 09:50 PM (UTC)
Message
char_morph and whatnot is for polymorphs (shapeshifting). I don't know if it was ever fully functional, but it has part of the basis at least
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #3 on Wed 24 Aug 2005 01:25 AM (UTC)
Message
If you were looking for the structs that list the information for players/mobs, go find struct char_data, as this lists a lot of things. Player specific data is found in the pc_data struct.

~Nick Cash
http://www.nick-cash.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,948 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.