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 ➜ SMAUG coding ➜ SWR MARRAIGE snippet question

SWR MARRAIGE snippet question

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


Posted by Jason   (109 posts)  Bio
Date Thu 13 Feb 2003 01:09 AM (UTC)
Message
I have put in the swr snippet for marriage in my mud... but i can't get the to beable to propose to another person after a divorce can some one help me?
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #1 on Fri 14 Feb 2003 08:52 PM (UTC)
Message
I added this code to my MUD also, but I can't really help unless you either let me in your shell to let me look at it or you tell me a bit more about your problem.

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

Posted by Jason   (109 posts)  Bio
Date Reply #2 on Sat 15 Feb 2003 08:16 AM (UTC)
Message
Well i'd let you into my shell but i'm running in cygwin of my comp... so here goes some info on it.I had the problem when i married them it would add to pfile. I fixed that. now they get married and loose the fiance status in the pfile. but when i do a divorce and make them loose the married status it will not allow the character to propose to any one else. Here is the code:void do_divorce( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *vic1;
CHAR_DATA *vic2;
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];

argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);

if (arg1[0] == '\0' && arg2[0] == '\0')
{
send_to_char("Syntax: Divorce <victim1> <victim2>\n\r", ch);
return;
}

if ((vic1 = get_char_room(ch, arg1)) == NULL)
{
sprintf(buf, "%s doesn't appear to be here. You should wait for them.\n\r", arg1);
send_to_char(buf, ch);
return;
}

if ((vic2 = get_char_room(ch, arg2)) == NULL)
{
sprintf(buf, "%s doesn't appear to be here. You should wait for then.\n\r", arg2);
send_to_char(buf, ch);
return;
}

if (vic1->pcdata->spouse == NULL)
{
sprintf(buf, "%s doesn't appear to be married.\n\r", vic1->name);
send_to_char(buf, ch);
return;
}

if (vic2->pcdata->spouse == NULL)
{
sprintf(buf, "%s doesn't appear to be married.\n\r", vic2->name);
send_to_char(buf, ch);
return;
}

if (vic1->pcdata->spouse != vic2->name)
{
sprintf(buf, "%s is not married to %s\n\r", vic1->name, vic2->name);
send_to_char(buf, ch);
return;
}

vic1->pcdata->spouse = NULL;
vic2->pcdata->spouse = NULL;
do_say(ch, "500 credits each please.");
do_say(ch, "Thank you.");
ch->gold += 1000;
vic1->gold -= 500;
vic2->gold -= 500;
sprintf(buf, "&R(&WMarriage&R} &W%s: It is my sad duty to anounce that %s and %s are now divorced.", ch->name, vic1->name, vic2->name);
}

void do_propose( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
char arg[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];

argument = one_argument(argument, arg);

if (arg[0] == '\0'){
send_to_char("Syntax: Propose <victim>\n\r", ch);
return;
}

if (( victim = get_char_room(ch, arg)) == NULL){
send_to_char("They aren't here.\n\r", ch);
return;
}

if ( ch == victim ){
send_to_char("Why would you want to propose to yourself?\n\r", ch);
if (ch->sex == SEX_MALE)
sprintf(buf, "What a moron. %s proposed to himself.", ch->name);
else if (ch->sex == SEX_FEMALE)
sprintf(buf, "What a moron. %s proposed to herself.", ch->name);
else
sprintf(buf, "What a moron. %s proposed to itself.", ch->name);

echo_to_all( AT_WHITE, buf, ECHOTAR_ALL );
return;
}


if ( IS_NPC(victim) ){
send_to_char("Why would you propose to a mob?\n\r", ch);
return;
}

if ( IS_NPC(ch) ){
send_to_char("Why would a mob propose to someone?\n\r", ch);
return;
}

if (victim->pcdata->fiance && victim->pcdata->fiance != NULL){
send_to_char("They are already engaged.\n\r", ch);
return;
}

if (victim->pcdata->spouse && victim->pcdata->spouse != NULL){
send_to_char("They are already married.\n\r", ch);
}
if (victim->pcdata->proposed && victim->pcdata->proposed != NULL){
sprintf(buf, "They have already been proposed to by %s.\n\r", victim->pcdata->proposed);
return;
}

if (victim->pcdata->propose && victim->pcdata->propose != NULL){
sprintf(buf, "They have already been proposed to %s.\n\r", victim->pcdata->propose);
return;
}

ch->pcdata->propose = victim->name;
victim->pcdata->proposed = ch->name;
act(AT_WHITE, "$n gets down on one knee and asks your hand in marriage.", ch, NULL, victim, TO_VICT);
act(AT_WHITE, "You get down on one knee and ask $N's hand in marriage.", ch, NULL, victim, TO_CHAR);
act(AT_WHITE, "$n gets down on one knee and asks for $N's hand in marriage.", ch, NULL, victim, TO_NOTVICT);
return;
}



Hope this helps.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #3 on Sat 15 Feb 2003 09:13 PM (UTC)
Message
What's the actual error message they get when trying to propose after a divorce?

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Jason   (109 posts)  Bio
Date Reply #4 on Sun 16 Feb 2003 06:58 AM (UTC)
Message
There is no error message. When i type propose <victim name> it just completely ignores the command, example:[Force] 800/2200 [Align] 0
[Health] 1320/3119 [Movement] 1000/1000 > propose ralph

[Force] 800/2200 [Align] 0
[Health] 1320/3119 [Movement] 1000/1000 >



No errors come up in the shell either.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 16 Feb 2003 10:29 PM (UTC)
Message
I would first establish if the do_propose command function is being called. Try adding this line for debugging ...


void do_propose( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
char arg[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];

  send_to_char("do_propose called\n\r", ch);


If that message does not appear, try looking in tables.c to make sure the translation between do_propose and the function itself is there.

ie. There should be a line like this:


    if ( !str_cmp( name, "do_propose" ))       return do_propose;

- Nick Gammon

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

Posted by Jason   (109 posts)  Bio
Date Reply #6 on Mon 17 Feb 2003 07:50 AM (UTC)
Message
Well i know that is there... the command works the first time nick... It just won't work again after a divorce
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #7 on Mon 17 Feb 2003 01:28 PM (UTC)
Message
I'm gonna agree with Nick on this for the best way to find where the break is in the code.... put in log strings everywhere. I'd recommend wiznet logs instead of logging to the shell since the knowledge is immediate and doesn't require hunting thru the main log to find the proverbial needle in a haystack. The only place I can see that might be screwing you up so far though is resetting the spouse field in the pfile to a NULL value. I also see there's no echo if an already married char attempts to propose again, I'd suggest adding one as an immediate way to see if the divorce function is actually clearing the marriage fields properly (I seriously think thats where your problem is).

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #8 on Fri 21 Feb 2003 12:50 AM (UTC)
Message
I think I know the problem. The fact about why you can't propose to the person again is because it when it divorce's/marry's them it doesn't set the vic1->pcdata->propose or vic1->pcdata->proposed settings. Setting it to NULL shouldn't be a problem, but Meerclar and Nick know a lot more about this then I do. I'll see if I can state how to fix it here...

Note: This varies depending on how you want your game to be.
You may want to change it around and set the propose and proposed in do_marry so that it takes them off, but its up to you. Anyways, do_divorce will not work properly like that (If you are using the code I think you are using..)

So change the part in do_divorce that looks like this:
vic1->pcdata->spouse = NULL;
vic2->pcdata->spouse = NULL;

To this:

vic1->pcdata->spouse = NULL;
vic2->pcdata->spouse = NULL;
vic1->pcdata->fiance = NULL;
vic2->pcdata->fiance = NULL;
vic1->pcdata->propose = NULL;
vic2->pcdata->propose = NULL;
vic1->pcdata->proposed = NULL;
vic2->pcdata->proposed = NULL;
REMOVE_BIT (vic1->act, PLR_MAR );
REMOVE_BIT (vic2->act, PLR_MAR );

I think that will work, test it for me and let me know. The real problem was it wasn't taking off any of the other data and it wouldn't overlap.

Anyways, hope that helpped in some way, shape, or form.

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

Posted by Dave   Australia  (93 posts)  Bio
Date Reply #9 on Sat 22 Feb 2003 03:26 AM (UTC)
Message
if (victim->pcdata->proposed && victim->pcdata->proposed != NULL){ 
sprintf(buf, "They have already been proposed to by %s.\n\r", victim->pcdata->proposed);
return;
}

if (victim->pcdata->propose && victim->pcdata->propose != NULL){ 
sprintf(buf, "They have already been proposed to %s.\n\r", victim->pcdata->propose);
return;
}
Notice how you're sprintf()ing but not actually send_to_char()ing? This could be why you see no result from the propose command.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #10 on Sat 22 Feb 2003 05:05 AM (UTC)
Message
sprintf() is a string print, essentially same function as send_to_char.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Dave   Australia  (93 posts)  Bio
Date Reply #11 on Sun 23 Feb 2003 04:30 AM (UTC)
Message
Quote:
sprintf() is a string print, essentially same function as send_to_char.
Are you sure? :) I don't know SWR intimately, but I'm pretty sure it wouldn't replace the standard C function sprintf with one that does sprintf/send_to_char, and looking back at this thread, I see that in some instances Jason's code DOES do sprintf then send_to_char, but as noted in my previous post, doesn't do it there. So whatever the case, there's still a discrepancy.

Dave
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #12 on Wed 26 Feb 2003 08:25 AM (UTC)
Message
Yes, I am quite certain. If you notice in the snipet (and this is a snipet conversion) send_to_char() is *never* used with a string that has any variable text, ie names, as part of the message. When dealing with set messages, send_to_char is easily as efficient as sprintf in handling the print demands, but sprintf has an advantage when handling variable output.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Dave   Australia  (93 posts)  Bio
Date Reply #13 on Wed 26 Feb 2003 08:44 AM (UTC)
Message
*sigh*. You just don't get it. Consider this:
if (vic2->pcdata->spouse == NULL)
{
sprintf(buf, "%s doesn't appear to be married.\n\r", vic2->name);
send_to_char(buf, ch);
return;
}
What's happening here? sprintf is doing its job and storing the result in the buf string, THEN buf is sent to the char using send_to_char(). But as I posted earlier, a couple of times this is used:
if (victim->pcdata->proposed && victim->pcdata->proposed != NULL){ 
sprintf(buf, "They have already been proposed to by %s.\n\r", victim->pcdata->proposed);
return;
}
Notice how buf is being set correctly, but it's never being sent to the character? What don't you understand?

Dave
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #14 on Wed 26 Feb 2003 07:03 PM (UTC)
Message
The problem with ppls that are already married not getting messages when they attempt to propose or whatnot again goes back to the simple fact that all of the checks for the existing messages are based exclusively on the char *receiving* the proposal. There are no checks coded for the char that is actually doing the proposal already being married, engaged or whatever. The potential error you pointed out is still based on the char *receiving* the proposal and still wouldn't do anything if the char giving the proposal is already spoken for. Granted, one would rather expect the players to know if their char is married or not but with what appears to be a busted divorce function, idiot checks seem to be in order. Of course, since this was a converted snipet in the first place, idiot checks are even more in order.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
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.


34,574 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.