SWR MARRAIGE snippet question

Posted by Jason on Thu 13 Feb 2003 01:09 AM — 15 posts, 47,413 views.

#0
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?
USA #1
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.
#2
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.
USA #3
What's the actual error message they get when trying to propose after a divorce?
#4
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.
Australia Forum Administrator #5
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;
#6
Well i know that is there... the command works the first time nick... It just won't work again after a divorce
USA #7
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).
USA #8
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.
Australia #9
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.
USA #10
sprintf() is a string print, essentially same function as send_to_char.
Australia #11
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
USA #12
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.
Australia #13
*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
USA #14
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.