First of all, what version of socketmud are you talking about? Secondly, that _TXT_GREETING sounds like it would be a macro that has not yet been defined.
Very strange that it would be in that directory instead of the main directory. Anyhow, it does indeed look like those are macros. However, I don't know as such what they are meant to contain. You can try doing a search of all of the source files for those macros to see if they are defined elsewhere (by "grep "_TXT_GREETING" *" for instance), but you may simply have to give them new values.
Looking at what is in the regular socketmud release, it looks like for txt_greeting you could do the following:
Very strange that it would be in that directory instead of the main directory. Anyhow, it does indeed look like those are macros. However, I don't know as such what they are meant to contain. You can try doing a search of all of the source files for those macros to see if they are defined elsewhere (by "grep "_TXT_GREETING" *" for instance), but you may simply have to give them new values.
Looking at what is in the regular socketmud release, it looks like for txt_greeting you could do the following:
#define _TXT_GREETING "What is your name? "
Maybe it's me, but why bother defining it when it's comething that's only used once in the code like that when you could simply change the line to:
going through the code more and it seems like every one of the errors are for messages. like the greeting line or password verification and password errors. so either i make a .h file for them all or i do what the last poster said.
Very strange that it would be in that directory instead of the main directory. Anyhow, it does indeed look like those are macros. However, I don't know as such what they are meant to contain. You can try doing a search of all of the source files for those macros to see if they are defined elsewhere (by "grep "_TXT_GREETING" *" for instance), but you may simply have to give them new values.
Looking at what is in the regular socketmud release, it looks like for txt_greeting you could do the following:
#define _TXT_GREETING "What is your name? "
Maybe it's me, but why bother defining it when it's comething that's only used once in the code like that when you could simply change the line to:
text_to_buffer(sock_new, "What is your name?");
Well, in some cases it can be less of a hassle tracking down string literals to edit if they're kept in a different location in macro form. It just depends, I would say.
why bother defining it when it's comething that's only used once in the code like that
Ease of maintenance for one thing. Tracking down hardcoded text messages can be a PITA. It would also make it easier in case you wanted to have that same message in multiple places in the code in the future (perhaps a display of all text messages in the game, for review, etc).
why bother defining it when it's comething that's only used once in the code like that
Ease of maintenance for one thing. Tracking down hardcoded text messages can be a PITA. It would also make it easier in case you wanted to have that same message in multiple places in the code in the future (perhaps a display of all text messages in the game, for review, etc).
For strings that are used repeatedly I definitely see the use, but a string like that will only ever be used once. I don't see how this is much of a pain to track either: grep "What is your name?" *.c
Because it's all in one place. Say someone wants to translate a project, it would be much better if they were all like that instead of thrown about in various source files.
16 Mar, 2009, David Haley wrote in the 18th comment:
Votes: 0
It's best practice to adopt, well, best practices from the getgo even if their benefit will come up later. If you do it from the start, it's that much less you have to change later when you find that maybe you should have used a constant after all. (Or function decomposition, or good variable names, or data encapsulation, or ….)
socket.c:356: error: ‘_TXT_GREETING’ undeclared (first use in this function)
this is the bit of code it is referencing:
/* send the greeting */
text_to_buffer(sock_new, greeting);
text_to_buffer(sock_new, _TXT_GREETING);
/* everything went as it was supposed to */
return TRUE;
}