I've seen in Zeno's mud and a few other that they have a command for changes, i was wondering if that was a snippet or what?
Changes thing
Posted by Metsuro on Sun 02 Oct 2005 11:03 PM — 43 posts, 138,124 views.
Yeah, it's a snippet.
That's all I know, I'm not sure where to find it.
Quote:
* Original code by Xkilla
* Cleaned up by Dreimas
* Converted for Smaug by Zarius
* Original code by Xkilla
* Cleaned up by Dreimas
* Converted for Smaug by Zarius
That's all I know, I'm not sure where to find it.
http://www.mudmagic.com/codes/server-snippet/1743
Ok I can not for the life of me get this to work, following the "instructions" so huh would anyone mind helping me or giving me a easier way to follow heh
What's wrong? Compile errors?
if you read the instructions to me its missing a few things like it says to add a changes.c but it doesn't do anything with the changes.c so that it will compile and what not. It also says to add a changes.h but you dont have one and some of the bits look like typos to me but i'm not sure heh..
Just an observation here, but if we know that Zarius converted it for Smaug, and we're (presumably, since this is a smaug forum) talking about putting it into a Smaug mud, why not just ask him where to get his Smaug port of the snippet? Doesn't Zarius have a website with quite a few snippets?
Or even create one, seeing as alot of smaugs use a help file for their changes, adding this to stock even would prolly be really nice because of how much easier having it would be for imms and players to know whats happening.
I have a modified version of the snippet here: http://www.darkwarriors.net/downloads/changes.tar.gz. I have it installed on an SWR, but from whats used I think it should pretty much drop right in.
Compiling o/changes.o....
changes.c: In function `load_changes':
changes.c:47: warning: too many arguments for format
changes.c: In function `delete_change':
changes.c:114: warning: implicit declaration of function `CALLOC'
changes.c:114: warning: cast does not match function type
changes.c: In function `do_chedit':
changes.c:242: warning: too many arguments for format
changes.c:243: warning: too many arguments for format
changes.c:244: warning: too many arguments for format
make[1]: *** [o/changes.o] Error 1
make: *** [all] Error 2
thats what I get when I added it.
changes.c: In function `load_changes':
changes.c:47: warning: too many arguments for format
changes.c: In function `delete_change':
changes.c:114: warning: implicit declaration of function `CALLOC'
changes.c:114: warning: cast does not match function type
changes.c: In function `do_chedit':
changes.c:242: warning: too many arguments for format
changes.c:243: warning: too many arguments for format
changes.c:244: warning: too many arguments for format
make[1]: *** [o/changes.o] Error 1
make: *** [all] Error 2
thats what I get when I added it.
ok now i've narrowed it down( I hope...) to just
compiling o/changes.o....
changes.c: In function `delete_change':
changes.c:114: warning: implicit declaration of function `CALLOC'
changes.c:114: warning: cast does not match function type
make[1]: *** [o/changes.o] Error 1
make: *** [all] Error 2
compiling o/changes.o....
changes.c: In function `delete_change':
changes.c:114: warning: implicit declaration of function `CALLOC'
changes.c:114: warning: cast does not match function type
make[1]: *** [o/changes.o] Error 1
make: *** [all] Error 2
Odd, I don't get those. To fix, however, you should be able to pull off the ", 0" on like 47, change CALLOC to calloc and make 242, 243, and 244 look like:
That SHOULD fix it, no gaurantees. You'll have to play with it a bit to get it to work right on what your compiling on.
[EDIT] This is what happens when I take my time in replying...
send_to_char("Syntax: chedit load/save\n\r",ch);
send_to_char("Syntax: chedit delete (change number)\n\r",ch);
send_to_char("Syntax: chedit immchange (change number)\n\r",ch);
That SHOULD fix it, no gaurantees. You'll have to play with it a bit to get it to work right on what your compiling on.
[EDIT] This is what happens when I take my time in replying...
*blink* Immchange? I was planning to put that in for my changes system. Is this something you did?
ok i got it to work CALLOC should be replaced with calloc i think not 100% sure but i did it that way and it works now i think.
[EDIT] woo another problem. One I really have no idea how to fix wooo.
Compiling o/tables.o....
tables.c: In function `skill_function':
tables.c:244: error: `do_addchange' undeclared (first use in this function)
tables.c:244: error: (Each undeclared identifier is reported only once
tables.c:244: error: for each function it appears in.)
tables.c:246: error: `do_addimmchange' undeclared (first use in this function)
tables.c:342: error: `do_changes' undeclared (first use in this function)
tables.c:350: error: `do_chedit' undeclared (first use in this function)
tables.c: In function `skill_name':
tables.c:1413: error: `do_addchange' undeclared (first use in this function)
tables.c:1415: error: `do_addimmchange' undeclared (first use in this function)
tables.c:1507: error: `do_changes' undeclared (first use in this function)
tables.c:1513: error: `do_chedit' undeclared (first use in this function)
make[1]: *** [o/tables.o] Error 1
make: *** [all] Error 2
[EDIT] woo another problem. One I really have no idea how to fix wooo.
Compiling o/tables.o....
tables.c: In function `skill_function':
tables.c:244: error: `do_addchange' undeclared (first use in this function)
tables.c:244: error: (Each undeclared identifier is reported only once
tables.c:244: error: for each function it appears in.)
tables.c:246: error: `do_addimmchange' undeclared (first use in this function)
tables.c:342: error: `do_changes' undeclared (first use in this function)
tables.c:350: error: `do_chedit' undeclared (first use in this function)
tables.c: In function `skill_name':
tables.c:1413: error: `do_addchange' undeclared (first use in this function)
tables.c:1415: error: `do_addimmchange' undeclared (first use in this function)
tables.c:1507: error: `do_changes' undeclared (first use in this function)
tables.c:1513: error: `do_chedit' undeclared (first use in this function)
make[1]: *** [o/tables.o] Error 1
make: *** [all] Error 2
Yes, I added the immchanges. There were just some things that I did not want the mortals seeing.
As for that, I missed a step in the snippet instructions. You have to add the declarations into mud.h, same as you would for any other command.
Should be what you need.
As for that, I missed a step in the snippet instructions. You have to add the declarations into mud.h, same as you would for any other command.
DECLARE_DO_FUN( do_addchange );
DECLARE_DO_FUN( do_addimmchange );
DECLARE_DO_FUN( do_changes );
DECLARE_DO_FUN( do_chedit);
Should be what you need.
Your late again I realized i needed to put them in after toying around a bit hehe. Now on Gatz mud and I think Zeno's as well when you log in and theres a new change the mud informs you of the new change, how could one do something like that?
I have this in my nanny() under the CON_PRESS_ENTER case:This just tells people of how many there are total, but you could pull the line that has how many changes today from the changes.c file fairly easily.
if (maxChanges > 0)
{
for (i = 0; i < maxChanges; i++)
if (changes_table[i].immchange == 1
&& !IS_IMMORTAL(ch))
immchanges++;
ch_printf(ch,
"&BT&zhere is a total of &B[&w %3d &B]&z changes in the database.\n\r",
maxChanges - immchanges);
}
Sorry but i'm really new at this stuff... so wouldn'y you have to define maxChanges, changes_table, immchanges, and i?
I know i can use do_changes(ch, 0) in nanny to show the changes... but to me thats just spammy...
This is what I have.
i = num_changes();
if( i > 0 )
{
sprintf(buf, "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", i );
send_to_char(buf, ch);
}
what is num_changes though?
Came with the changes snippet. I'm not sure off hand.
like in greavens example the variables would have to be global wouldn't they so that you could reuse them from a different function?
If you want to know what it is, it's a function from changes.c, I thought you meant what is the code.
Man my head is killing me from trying to figure this out. alright so i got bored and just placed your example in, Zeno and it comes up with a comm.c:2504: warning: implicit declaration of function `num_changes' meaning there isn't a function num_changes right?
Why don't you look? If there is, then you need to define the function prototype at the top of comm.c
because I actually dont know what I'm doing and taking random guesses here? seriouslly I have no idea what i'm saying... I'm just doing...
Well does the function exist? That's the first thing to check.
no it doesn't, so i should add it changes.c right? but after doing so i still get the same error.
I'm not sure I understand. If the function doesn't exist, how are you adding it if you don't know what the function body contains?
int num_changes( void )
{
char *test;
int today;
int i;
i = 0;
test = current_date();
today = 0;
for ( i = 0; i < maxChanges; i++)
if (!str_cmp(test,changes_table[i].date))
today++;
return today;
}
that is the function from the website samson produced which I am guessing is very close to yours. possibly not.
{
char *test;
int today;
int i;
i = 0;
test = current_date();
today = 0;
for ( i = 0; i < maxChanges; i++)
if (!str_cmp(test,changes_table[i].date))
today++;
return today;
}
that is the function from the website samson produced which I am guessing is very close to yours. possibly not.
Oh okay. Then you need to add the function prototype to the top of comm.c:
int num_changes args( ( void ) );
but would i place the function in changes.c or comm.c then?
I really need to just try things on my own, i seem to find them like that. Thank you for all your help Zeno.
I just recently installed this and got numerous errors. I followed the readme and also the changes made on page 1. Here's the error.
Any suggestions or a solution on how to fix this would be appreciated.
o/changes.o(.text+0x0): In function `my_strftime':
/tmp/changes.c:35: multiple definition of `my_strftime'
o/changes.o(.text+0x0):/tmp/changes.c:35: first defined here
o/changes.o(.text+0x1b): In function `load_changes':
/tmp/changes.c:40: multiple definition of `load_changes'
o/changes.o(.text+0x1b):/tmp/changes.c:40: first defined here
o/changes.o(.text+0x151): In function `current_date':
/tmp/changes.c:73: multiple definition of `current_date'
o/changes.o(.text+0x151):/tmp/changes.c:73: first defined here
o/changes.o(.text+0x17f): In function `save_changes':
/tmp/changes.c:83: multiple definition of `save_changes'
o/changes.o(.text+0x17f):/tmp/changes.c:83: first defined here
o/changes.o(.text+0x284): In function `delete_change':
/tmp/changes.c:109: multiple definition of `delete_change'
o/changes.o(.text+0x284):/tmp/changes.c:109: first defined here
o/changes.o(.text+0x418): In function `do_addchange':
/tmp/changes.c:147: multiple definition of `do_addchange'
o/changes.o(.text+0x418):/tmp/changes.c:147: first defined here
o/changes.o(.text+0x57e): In function `do_addimmchange':
/tmp/changes.c:191: multiple definition of `do_addimmchange'
o/changes.o(.text+0x57e):/tmp/changes.c:191: first defined here
o/changes.o(.text+0x6bc): In function `do_chedit':
/tmp/changes.c:229: multiple definition of `do_chedit'
o/changes.o(.text+0x6bc):/tmp/changes.c:229: first defined here
o/changes.o(.text+0x8fe): In function `do_changes':
/tmp/changes.c:319: multiple definition of `do_changes'
o/changes.o(.text+0x8fe):/tmp/changes.c:319: first defined hereAny suggestions or a solution on how to fix this would be appreciated.
Looks like you're defining something twice. Make sure you're not doing that.
How would I go about checking\finding the duplicates? Which files might they be located in? I don't understand how this could of happened if I followed everything correctly.
Which file? Well the error message tells you:
File changes.c, line 35.
It seems strange both definitions are in the same file, perhaps you are linking the file in twice.
It is also strange you are compiling in the /tmp directory, that is usually used for temporary files.
/tmp/changes.c:35: multiple definition of `my_strftime'
/tmp/changes.c:35: first defined here
File changes.c, line 35.
It seems strange both definitions are in the same file, perhaps you are linking the file in twice.
It is also strange you are compiling in the /tmp directory, that is usually used for temporary files.
Well it works but when players log in it doesn't show.
I was wondering, where is a good place to stick this code in:
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
This is where mine is now:
do_look( ch, "auto" );
mail_count( ch );
if( !ch->was_in_room && ch->in_room == get_room_index( ROOM_VNUM_TEMPLE ) )
ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
else if( ch->was_in_room == get_room_index( ROOM_VNUM_TEMPLE ) )
ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
else if( !ch->was_in_room )
ch->was_in_room = ch->in_room;
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
break;
}
return;
}
But it doesn't seem to compile there.
In some area's it says:
comm.c:2538: undefined reference to `num_changes'
But the area's i can put it in ( right enter press [ENTER] to get in the mud )
It doesn't show. I want it to show right after you auto look in the game. Help? xD :P
I was wondering, where is a good place to stick this code in:
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
This is where mine is now:
do_look( ch, "auto" );
mail_count( ch );
if( !ch->was_in_room && ch->in_room == get_room_index( ROOM_VNUM_TEMPLE ) )
ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
else if( ch->was_in_room == get_room_index( ROOM_VNUM_TEMPLE ) )
ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
else if( !ch->was_in_room )
ch->was_in_room = ch->in_room;
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
break;
}
return;
}
But it doesn't seem to compile there.
In some area's it says:
comm.c:2538: undefined reference to `num_changes'
But the area's i can put it in ( right enter press [ENTER] to get in the mud )
It doesn't show. I want it to show right after you auto look in the game. Help? xD :P
Btw i also tried right under my:
case CON_PRESS_ENTER:
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
if( chk_watch( get_trust( ch ), ch->name, d->host ) ) /* --Gorog */
SET_BIT( ch->pcdata->flags, PCFLAG_WATCH );
else
REMOVE_BIT( ch->pcdata->flags, PCFLAG_WATCH );
if( ch->position == POS_MOUNTED )
ch->position = POS_STANDING;
set_pager_color( AT_PLAIN, ch );
if( xIS_SET( ch->act, PLR_RIP ) )
send_rip_screen( ch );
if( xIS_SET( ch->act, PLR_ANSI ) )
send_to_pager( "\033[2J", ch );
but it just says:
omm.c:2332: undefined reference to `num_changes'
Here's where i defined my numchanges btw,
/*
* Global variables.
*/
int num_changes args( ( void ) );
IMMORTAL_HOST *immortal_host_start; /* Start of Immortal legal domains */
IMMORTAL_HOST *immortal_host_end; /* End of Immortal legal domains */
DESCRIPTOR_DATA *first_descriptor; /* First descriptor */
DESCRIPTOR_DATA *last_descriptor; /* Last descriptor */
DESCRIPTOR_DATA *d_next; /* Next descriptor in loop */
int num_descriptors;
bool mud_down; /* Shutdown */
Near top of Comm.c
><
case CON_PRESS_ENTER:
i = num_changes();
if( i > 0 )
{
send_to_desc_color ( "&RThere have been &G%d&R change(s) to the MUD today. &WType &z'&YCHANGES&z'&W to view them.\n\r", d );
send_to_char(buf, ch);
}
if( chk_watch( get_trust( ch ), ch->name, d->host ) ) /* --Gorog */
SET_BIT( ch->pcdata->flags, PCFLAG_WATCH );
else
REMOVE_BIT( ch->pcdata->flags, PCFLAG_WATCH );
if( ch->position == POS_MOUNTED )
ch->position = POS_STANDING;
set_pager_color( AT_PLAIN, ch );
if( xIS_SET( ch->act, PLR_RIP ) )
send_rip_screen( ch );
if( xIS_SET( ch->act, PLR_ANSI ) )
send_to_pager( "\033[2J", ch );
but it just says:
omm.c:2332: undefined reference to `num_changes'
Here's where i defined my numchanges btw,
/*
* Global variables.
*/
int num_changes args( ( void ) );
IMMORTAL_HOST *immortal_host_start; /* Start of Immortal legal domains */
IMMORTAL_HOST *immortal_host_end; /* End of Immortal legal domains */
DESCRIPTOR_DATA *first_descriptor; /* First descriptor */
DESCRIPTOR_DATA *last_descriptor; /* Last descriptor */
DESCRIPTOR_DATA *d_next; /* Next descriptor in loop */
int num_descriptors;
bool mud_down; /* Shutdown */
Near top of Comm.c
><
OK, I tried that, and got this message:
Now the important thing about this message is it is a linker error, not a compiler error. If it was a compiler error it would look like this (I omitted the prototype line to cause this message):
The difference tells us what to do. Simply moving the code around won't solve the linker error. The link error means it cannot find the implementation of num_changes. The compile error means it cannot find the prototype (definition) of num_changes. There is a big difference.
This is the prototype (which you have used correctly):
The implementation is this part (shown earlier in this thread):
You need to check that:
o/comm.o(.text+0x49f7): In function `nanny':
/home/nick/smaugfuss/src/comm.c:2319: undefined reference to `num_changes'
collect2: ld returned 1 exit status
Now the important thing about this message is it is a linker error, not a compiler error. If it was a compiler error it would look like this (I omitted the prototype line to cause this message):
comm.c: In function `nanny':
comm.c:2318: warning: implicit declaration of function `num_changes'
The difference tells us what to do. Simply moving the code around won't solve the linker error. The link error means it cannot find the implementation of num_changes. The compile error means it cannot find the prototype (definition) of num_changes. There is a big difference.
This is the prototype (which you have used correctly):
int num_changes args( ( void ) );
The implementation is this part (shown earlier in this thread):
int num_changes( void )
{
char *test;
// yadda yadda
return today;
}
You need to check that:
- You have put this code into a file somewhere
- That file is part of the project - that is, it is being linked in.
Im sorry nick, I don't understand where to put.
int num_changes( void )
{
char *test;
// yadda yadda
return today;
}
I've tried comm.c and changes.c but it just tells me errors where today; is undefined and test is an unused variable.
>.<
int num_changes( void )
{
char *test;
// yadda yadda
return today;
}
I've tried comm.c and changes.c but it just tells me errors where today; is undefined and test is an unused variable.
>.<
In C, a line starting with // is a comment, meaning that it doesn't affect the program. When Nick put in
It might help you a lot to google for a beginner's C tutorial. A lot of these problems and concepts are covered and it will help you a great deal to have an understanding of the basics; it's not that hard to get just a start and the benefit for you will be very great.
"// yadda yadda" he was basically saying "...". The full function, as he said, is earlier in the thread; here it is:int num_changes( void )
{
char *test;
int today;
int i;
i = 0;
test = current_date();
today = 0;
for ( i = 0; i < maxChanges; i++)
if (!str_cmp(test,changes_table[i].date))
today++;
return today;
}It might help you a lot to google for a beginner's C tutorial. A lot of these problems and concepts are covered and it will help you a great deal to have an understanding of the basics; it's not that hard to get just a start and the benefit for you will be very great.