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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Compiling the server ➜ Source Code

Source Code

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


Pages: 1 2  3  4  5  

Posted by Kris   USA  (198 posts)  Bio
Date Tue 13 Mar 2001 04:45 PM (UTC)
Message
Where in the source code is the stuff for sacrificing corpses? I.E. messages like "Your deity appreciates your offer and may accept it later." and "Thoric gives you one gold coin for your sacrifice." Obviously, I want to change it from 'Thoric' to 'Kris'. I searched the entire src directory, but couldn't find any specific references to sacrificing.
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 13 Mar 2001 05:44 PM (UTC)

Amended on Tue 13 Mar 2001 05:46 PM (UTC) by Nick Gammon

Message
Here is how to find such things. Use grep, which searches files, like this:


$ grep 'your sacrifice' *.c
act_obj.c: sprintf( buf, "%s gives you one gold coin for your sacrifice.\n\r"
, name );


This shows that the relevant code is in act_obj.c.

If you edit that file, at around line 2220 you will see:


	strcpy( name, "Thoric" );
    }
    ch->gold += 1;
    if ( obj->item_type == ITEM_CORPSE_NPC
    ||   obj->item_type == ITEM_CORPSE_PC )
       adjust_favor( ch, 5, 1 );
    sprintf( buf, "%s gives you one gold coin for your sacrifice.\n\r", name );



You can see where the word Thoric comes from - just change that and recompile.

That code was in a function "do_sacrifice". If you had done a grep on "sacrifice" you would have found that too.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #2 on Wed 18 Apr 2001 02:08 AM (UTC)
Message
Ya know how when you're invissed, you show up as "Someone" from another person's perspective? I want to change "Someone" to "A shadow". However, virtually every source file has the word "Someone" in it, and, in many cases, it's all over the place! I thought I had it, but when I compiled and ran it, it still showed up as someone. What source file should I edit for this, and, if possible, could you tell me what line of code it is as well? Thanks :)
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 18 Apr 2001 10:53 PM (UTC)

Amended on Wed 18 Apr 2001 10:55 PM (UTC) by Nick Gammon

Message
Search for "someone" (in quotes). I found only 25 of these, which you probably need to change all of them, otherwise it will change in some spots but not others.

If you are using Cygwin, you can use "grep" to do this. Put the "someone" into single quotes (ie. double quotes inside single quotes, like in the example):

There are only about 4 different files here, just use your editor to do a "change all" once you have edited each one.

The "-i" says "case insensitive".

Also there are 23 in the list below, another 2 are in the file mud.h.


$ grep '"someone"' *.c -i
imc-mercbase.c: : (chdata->wizi ? "A Mystical Being" : "someone");
imc-mercbase.c: return imc_visible(imc_getdata(ch),vict) ? imc_nameof(name) :
"someone";
imc-mercbase.c: (imc_getdata(ch))->wizi ? "A Mystical Being" : "someone",
mud);
magic.c: strcpy( buf, "Someone" );
misc.c: const char *iroom = "Someone";
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );
mud_prog.c: : strcpy( t, "someone" );

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #4 on Thu 19 Apr 2001 05:02 AM (UTC)
Message
Ok, I just did that, and changed every reference of "someone" to "a shadow" and recompiled. I then did the grep command again, and it returned nothing, which confirms that I got it all. However, it still shows up as "Someone" instead of "A shadow"! I.e. "Someone says 'test'", "Someone waves" instead of "A shadow says 'test'", "A shadow waves". I then tried broadening the grep search, thinking that perhaps the 'someone' isn't alone in the quotes. So I removed the double quotes, i.e. typing:
grep 'someone' *.c -i > grep.txt
This is the list I recieved:
act_comm.c: send_to_char( "You cannot disband a group if you're following someone.\n\r", ch );
act_comm.c: send_to_char( "But you are following someone else!\n\r", ch );
act_info.c:/* Had to add unknowns because someone added new positions and didn't
act_info.c: strcat( buf, "someone who left??" );
act_info.c: strcat( buf, "someone who left??" );
act_info.c: * spamming someone and then logging off quickly to evade
act_info.c: /* Prevent someone from ignoring themself... */
act_obj.c: send_to_char( "That's someone else's corpse.\n\r", ch );
act_obj.c: send_to_char( "Someone tells you, 'No littering here!'\n\r", ch );
act_wiz.c: /* Oops someone forgot to clear up the memory --Shaddai */
act_wiz.c: write_to_descriptor( victim->desc->descriptor, "\n\rYou feel like someone is watching your every move...\n\r", 0 );
act_wiz.c: /*You can demote yourself but not someone else at your own trust.-- Narn*/
act_wiz.c: send_to_char( "Try taking it out on someone else first.\n\r", ch );
act_wiz.c: /* p_next = p->next; */ /* In case someone DOES try to AT MOBS SLAY # */
act_wiz.c: /* Just a security precaution so you don't rename someone you don't mean
clans.c: send_to_char("You cannot shove someone into a death trap.\n\r", ch);
clans.c: send_to_char("You cannot drag someone into a death trap.\n\r", ch);
clans.c: send_to_char("You cannot do that to someone who is standing.\n\r", ch);
comm.c: sprintf( buf, "\n\rMake sure to use a password that won't be easily guessed by someone else."
comm.c:/* if ( is_name( name, "all auto immortal self someone god demigod dog guard cat ass fuck shit piss crap quit" ) )
comments.c: /* Put in to prevent crashing when someone issues a comment command
fight.c: * See if we got a pointer to someone who recently died...
fight.c: * want to show why you can't kill someone you can't turn it off. This is
fight.c: msg = "You hear someone's death cry.";
grub.c: * this function. F.Y.I - if an object is not "carried_by" someone,
grub.c: * in a container carried by someone - or in a container on the ground.
ice.c:/* see if someone can talk on a channel - lots of string stuff here! */
ice.c: /* Private channel - can only hear if someone with the right mud name is
imc-config.c:/* find ignore data on someone */
imc-mercbase.c: sprintf(buf, "someone@%s", mud);
imc-mercbase.c: /* just check for deny, since you can rtell someone < IMC_LEVEL_RTELL */
interp.c: sprintf ( cmd_flag_buf, "You can't %s while you are possessing someone!\n\r",
magic.c: ? victim->desc->original->name : "someone else");
magic.c: ? victim->name : "someone else");
magic.c: sprintf( buf2, "Someone makes %s say '%s'.\n\r", speaker, target_name );
misc.c: send_to_char( "That's someone else's corpse.\n\r", ch );
misc.c: act( AT_ACTION, "Someone raps loudly from the other side of the $d.",
misc.c: send_to_char( "Someone tells you, 'No littering here!'\n\r", ch );
mud_comm.c: act( AT_TELL, "$n tells you, 'Sorry... you must seek someone more powerful than I.'",
mud_comm.c:/* hey... if an immortal's following someone, they should go with a mortal
mud_comm.c:/* lets the mobile force someone to do something. must be mortal level
polymorph.c: send_to_char ("Someone deleted your morph!\n\r", ch);
services.c:// someone calls ControlService in reference to our service.
skills.c: * if someone gouged you in the eye.
skills.c: send_to_char( "You can't backstab someone who is in combat.\n\r", ch );
skills.c: /* can't properly target someone heavily in battle */
special.c:/* if a spell casting mob is hating someone... try and summon them */
update.c: sprintf( buf, "Someone save me from %s!", rch->name );
update.c: act( AT_ACTION, "Someone should fetch a healer for $n.", ch, NULL, NULL, TO_ROOM );
update.c: case 9: t = "You hear someone call your name in the distance...\n\r"; break;

None of this appears to be even -remotely- relevant. Many are just part of comments. Also, I noticed that imc-mercbase.c doesn't generate an object file, and thus doesn't compile with everything else. Normally I have to delete its object file, otherwise cygwin doesn't know that the .c file has been updated. That would only be relevant here if the coding I needed to change was contained in imc-mercbase.c. Any other ideas perhaps? This is kinda amusing, but I want to get Someone outa hiding so I can make him A shadow :P =)
Thanks for your help in the chase.
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 19 Apr 2001 05:55 AM (UTC)
Message
Did you do mud.h as well? That won't be found by grep of *.c.

I did the following, and it worked:

* changed the two references there
* did: rm *.o
* did: make

This is the code I changed:



/*
 * Description macros.
 */
#define PERS(ch, looker)        ( can_see( (looker), (ch) ) ?           \
                                ( IS_NPC(ch) ? (ch)->short_descr        \
                                : (ch)->name ) : "someone" )

#define MORPHPERS(ch, looker)   ( can_see( (looker), (ch) ) ?           \
                                (ch)->morph->morph->short_desc       \
                                : "someone" )



You need to remove the .o files because it won't notice the change to mud.h otherwise.

Then I tested by logging in and doing a wave - see log below.

The other places should probably be changed also, but obviously the one in mud.h was important.


... Please leave north to experience the Darkhaven Academy.
... You may now "save" to make your character permanent.

<Type HELP START>
A shadow waves happily.

<Type HELP START><Type HELP START>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #6 on Tue 24 Apr 2001 02:51 AM (UTC)
Message
I want to make it so that everyone connected to the mud can see when a player quits and enters the mud. With a little guessing, I did added the following line in act_comm.c after the line act( AT_SAY, "A strange voice says, 'We await your return, $n...'", ch, NULL, NULL, TO_CHAR );
--------------------------------------------------------
echo_to_all( AT_IMMORT, "$n has left Aethia.", ECHOTAR_ALL);

The result is that it ends up showing to everyone who's connected as "$n as left Aethia." --literally (i.e. it shows $n instead of the player's name). How do I fix that?
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 24 Apr 2001 04:48 AM (UTC)

Amended on Tue 24 Apr 2001 04:49 AM (UTC) by Nick Gammon

Message
Do something like the following excerpt from act_wiz.c.

You need to construct a string with the player name in it, and then echo that string.


    char buf[MAX_STRING_LENGTH];

    sprintf( buf, "Balzhur screams, 'You are MINE %s!!!'", victim->name );
    echo_to_all( AT_IMMORT, buf, ECHOTAR_ALL );


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #8 on Tue 08 May 2001 11:46 PM (UTC)
Message
You know how when you're posting on a board, it cuts you off and returns (long line trimmed) after typing more than 79 characters? My admins have been screaming at me to fix this, as it is extremely annoying, especially when trying to post via telnet. I found the code responsible in build.c:
if ( strlen(argument) > 79 )
{
strncpy( buf, argument, 79 );
buf[79] = 0;
send_to_char( "(Long line trimmed)\n\r> ", ch );
}

I then tried changing the '79' to '160', just as a test. Like so:
if ( strlen(argument) > 160 )
{
strncpy( buf, argument, 160 );
buf[160] = 0;
send_to_char( "(Long line trimmed)\n\r> ", ch );
}
It would work just fine, and wouldn't trim the line until after it went over 160 chars. However, when I try to save the post, the server locks up and I have to manually shut it down. I just spent about 2 hours sifting through the source code, tinkering here and there, but every time I try to increase the limit, it crashes. What should I change? (Ideally, we'd like to have no limit on the number of chars in a line, or just a really high limit so we wouldn't have to walk on ice and hit 'enter' all the time to avoid being cut-off).
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #9 on Wed 09 May 2001 01:06 AM (UTC)
Message
Oh and I couldn't get the code you mentioned earlier to work. It said that victim was undefined, so I looked at how it was defined in act_wiz.c, and mimicked it:

void do_quit( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;

At the beginning of the file is where I put the declaration for buf. The rest of the code I inserted as follows:

act( AT_SAY, "A strange voice says, 'We await your return, $n...'", ch, NULL, NULL, TO_CHAR );

sprintf( buf, "<FYI> %s has left Aethia.", victim->name );
echo_to_all( AT_IMMORT, buf, ECHOTAR_ALL );

act( AT_BYE, "$n has left the game.", ch, NULL, NULL, TO_CANSEE );

Now, whenever I quit, the hard drive makes a brief, ugly buzzing noise and all my chars get disconnected from the server. What did I do wrong? (sorry bout not posting this sooner; I haven't been on recently)
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 09 May 2001 03:53 AM (UTC)
Message
First, the board problem. They put the test for 79 characters there for a reason, and the reason can be found in mud.h:


struct	editor_data
{
    sh_int		numlines;
    sh_int		on_line;
    sh_int		size;
    char		line[49][81];
};



As you can see the "line" allows for 49 lines of 80 characters (plus 1 for the null at the end). Thus, if you want 160 character lines I would make the "81" into "161" or maybe "162".

They probably did it that way because SMAUG normally has a maximum of 79 character lines (so they don't wrap in an ugly way on an 80-character screen).

What is wrong with just using the 49 lines to put in a lengthy message rather than trying to make the lines really long?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #11 on Wed 09 May 2001 03:56 AM (UTC)
Message
As for the crash with the victim name, you can't get away with just adding an uninitialised variable like that. You got rid of the compile error but swapped it for a runtime error.

The example I gave was from somewhere that "victim" was a valid pointer to a victim's character.

In the context you are doing it, you just want the character itself, eg. change this line:


sprintf( buf, "<FYI> %s has left Aethia.", ch->name );


In this function "ch" is defined, as it is passed down to the function, and that is the name of the person you want to broadcast anyway.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #12 on Thu 10 May 2001 02:03 AM (UTC)
Message
The <FYI> thing works beautifully now =)... however, the problem with the (long line trimmed) thing was unaffected by the changes I made to mud.h. The thing is, we're used to muds that line-wrap as you type, so you don't have to hit enter all the time. Everyone's complaining to me about it, and I can't say I blame them really. Is there anything else I should try?
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #13 on Fri 11 May 2001 01:56 AM (UTC)

Amended on Fri 11 May 2001 02:24 AM (UTC) by Nick Gammon

Message
I attempted to change the 'whois' information today. Basically, I just made it more like a table type format, and more condusive to some planned additions later on (i.e. kingdom, guild, and email listing). I don't get any compile errors on it. However, when I attempt to use the whois command on the mud, the hard drive buzzes briefly and disconnects everyone from the server, giving no error messages whatsoever.
In act_info.c, after the line:
set_pager_color( AT_GREY, ch );
I put the old code in comment tags, and inserted the new code:



  pager_printf(ch, "\n\n\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-WHOIS %s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n", victim->name);
  pager_printf(ch, "| Name: | %s *************************************** | Gender: | %s \n",
        victim->name,
        victim->sex == SEX_MALE ? "Male" :
        victim->sex == SEX_FEMALE ? "Female" : "Neutral"
        );
  pager_printf(ch, "| Level: | %s ******************************************** | Race: | %s \n",
        victim->level,
        capitalize(race_table[victim->race]->race_name)
        );
  pager_printf(ch, "| Class: | %s *************************************** | Age: | %s \n",
        class_table[victim->class]->who_name,
        get_age(victim)
        );
  pager_printf(ch, "| Kingdom: | None *************************************** | Guild: | None \n");
  pager_printf(ch, "----------------------------------------------------------------------------------\n");
 if(victim->pcdata->homepage && victim->pcdata->homepage[0] != '\0')
  pager_printf(ch, "| Webpage: | %s\n",
        show_tilde( victim->pcdata->homepage ) );
 else
  pager_printf(ch, "| Webpage: | Unlisted\n");
  
  pager_printf(ch, "| Email:   | Unlisted\n");
  pager_printf(ch, "--------------------------------------AUTOBIOGRAPHY-------------------------------\n");
 if(victim->pcdata->bio && victim->pcdata->bio[0] != '\0')
  pager_printf(ch, "\n%s\n\n",
	victim->pcdata->bio);
 else
  pager_printf(ch, "\nNo biographical information available for %s at this time.\n\n",
	victim->name );
 if(IS_IMMORTAL(ch))
 {
 	pager_printf(ch, "##############################  -INFO FOR IMMORTALS-  ############################\n");
 	pager_printf(ch, "| Mob Kills: | %s **************************** | Mob-Caused Deaths: | %s \n",
 	      victim->pcdata->mkills, 
 	      victim->pcdata->mdeaths
 	      );
 	pager_printf(ch, "| Player Kills: | %s ********************** | Player-Caused Deaths: | %s \n",
 	      victim->pcdata->pkills, 
 	      victim->pcdata->pdeaths
 	      );
    if(xIS_SET(victim->act, PLR_SILENCE) || xIS_SET(victim->act, PLR_NO_EMOTE) 
    || xIS_SET(victim->act, PLR_NO_TELL) || xIS_SET(victim->act, PLR_THIEF) 
    || xIS_SET(victim->act, PLR_KILLER) )
    {
      pager_printf(ch, "----------------------------------------------------------------------------------\n");
      sprintf(buf2, "This player has the following flags set:");
      if(xIS_SET(victim->act, PLR_SILENCE)) 
        strcat(buf2, " silence");
      if(xIS_SET(victim->act, PLR_NO_EMOTE)) 
        strcat(buf2, " noemote");
      if(xIS_SET(victim->act, PLR_NO_TELL) )
        strcat(buf2, " notell");
      if(xIS_SET(victim->act, PLR_THIEF) )
        strcat(buf2, " thief");
      if(xIS_SET(victim->act, PLR_KILLER) )
        strcat(buf2, " killer");
      strcat(buf2, ".\n\r");
      send_to_pager(buf2, ch);
      pager_printf(ch, "----------------------------------------------------------------------------------\n");
    }
  if ( victim->desc && victim->desc->host[0]!='\0' )
     {
     pager_printf(ch, "----------------------------------------------------------------------------------\n");
     sprintf (buf2, "%s's IP info: %s ", victim->name, victim->desc->host);
     if (get_trust(ch) >= LEVEL_GOD)
        strcat (buf2, victim->desc->user);
     strcat (buf2, "\n\r");
     send_to_pager(buf2, ch);
     }

 }
  pager_printf(ch, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-WHOIS %s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n", victim->name);
}



Sorry bout the length of this, but I don't even know what the error is, let alone what's causing it. Thanks for your help on this =)
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #14 on Fri 11 May 2001 02:31 AM (UTC)
Message
You have to be careful when using %d and %s inside the printf.

Here is one problem line:


  pager_printf(ch, "| Level: | %s ******************************************** | Race: | %s \n",
        victim->level,
        capitalize(race_table[victim->race]->race_name)
        );



The level is a number not a string, thus you must use %d and not %s. At runtime it will try to interpret the level number as a string and very probably crash.

You have similar problems further down with:


victim->pcdata->mkills,
victim->pcdata->mdeaths
victim->pcdata->pkills,
victim->pcdata->pdeaths


All these will be numbers, not strings.



- Nick Gammon

www.gammon.com.au, www.mushclient.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.


167,452 views.

This is page 1, subject is 5 pages long: 1 2  3  4  5  [Next page]

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.