Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Transfering Ownership of Houses (http://www.topmudsites.com/forums/showthread.php?t=362)

Jaegar 11-15-2003 01:54 AM

I have been working with the Circle3.1 code and have been trying to create a function which will enable the ownership of a house to be transferred.  I have created the function and it compiles cleanly, the function seems to work properly except for the portion that actually changes the owner.

Here is a copy of the function:

void hcontrol_transfer_house(struct char_data *ch, char *arg)
{
  char arg1[MAX_INPUT_LENGTH];
  struct house_control_rec temp_house;
  room_vnum virt_house;
  room_rnum real_house;
  long owner;

  /*  first arg: house vnum */
  arg = one_argument(arg, arg1);
  if (!*arg1)
  {
     send_to_char(ch, "%s", HCONTROL_FORMAT);
     return;
  }

  virt_house = atoi(arg1);
  if ((real_house = real_room(virt_house)) == NOWHERE)
  {
     send_to_char(ch, "No such room exists.\r\n");
     return;
  }
  if ((find_house(virt_house)) == NOWHERE)
  {
     send_to_char(ch, "House doesn't exists.\r\n");
     return;
  }

  /* second arg: new owners name */
  arg = one_argument(arg, arg1);
  if (!*arg1)
  {
     send_to_char(ch, "%s", HCONTROL_FORMAT);
     return;
  }

  if ((owner = get_id_by_name(arg1)) < 0)
  {
     send_to_char(ch, "Unknown player '%s'.\r\n", arg1);
     return;
  }

  temp_house.vnum = virt_house;
  temp_house.owner = owner;
  temp_house.num_of_guests = 0;

  send_to_char(ch, "House '%d' ownership transfered to '%s'.\r\n", virt_house, arg1);
  House_save_control();
}


When using the command to transfer the ownership it will read the vnum of the house and even search for the name of the new owner, it just will not replace the old owner with the new one.  Any help would be greatly appreciated.

Thanks in advance,

Jaegar

karlan 11-15-2003 05:25 AM


Sitral 11-15-2003 05:39 AM

I've got no experience with Circle, but your temp_house struct isn't doing anything. You've filled it up with information, but didn't tell the program what to do with it or where to put it, and it just gets scrapped at the end of the function.

After a quick look, try this:
[code]
struct house_control rec temp_house; // Replace this
int target; // with this.

if((find_house(virt_house)) == NOWHERE) // Replace this
if( (target=find_house(virt_house)) == NOWHERE ) // with this.

temp_house.vnum = virt_house; /*
temp_house.owner = owner; Replace these
temp_house.num_of_guests = 0; */
house_control[target].vnum = virt_house; /*
house_control[target].owner = owner; with these.
house_control[target].num_of_guests = 0; */
[/quote]

No promises (no experience). If it doesn't work, remember to put temp_house somewhere after you've given it all the relevant information (House_save_control() doesn't do this.)

Jaegar 11-15-2003 10:24 AM

Thank you very much. It is working properly now.

Thanks again,

Jaegar


All times are GMT -4. The time now is 09:47 AM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022