[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  More C questions
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

More C questions

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


Posted by GregS   (15 posts)  [Biography] 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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] 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
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] 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.


4,736 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]