2006-12-19 22:56:18 +00:00
|
|
|
/* ************************************************************************
|
|
|
|
|
* File: house.c Part of CircleMUD *
|
|
|
|
|
* Usage: Handling of player houses *
|
|
|
|
|
* *
|
|
|
|
|
* All rights reserved. See license.doc for complete information. *
|
|
|
|
|
* *
|
|
|
|
|
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
|
|
|
|
|
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
|
|
|
|
************************************************************************ */
|
|
|
|
|
|
|
|
|
|
#include "conf.h"
|
|
|
|
|
#include "sysdep.h"
|
|
|
|
|
|
|
|
|
|
#include "structs.h"
|
|
|
|
|
#include "comm.h"
|
|
|
|
|
#include "handler.h"
|
|
|
|
|
#include "db.h"
|
|
|
|
|
#include "interpreter.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "house.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
|
|
|
|
|
/* external functions */
|
2007-01-17 01:41:47 +00:00
|
|
|
obj_save_data *objsave_parse_objects(FILE *fl);
|
|
|
|
|
int objsave_save_obj_record(struct obj_data *obj, FILE *fl, int location);
|
2006-12-19 22:56:18 +00:00
|
|
|
|
|
|
|
|
/* local globals */
|
|
|
|
|
struct house_control_rec house_control[MAX_HOUSES];
|
|
|
|
|
int num_of_houses = 0;
|
|
|
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
|
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen);
|
|
|
|
|
int House_load(room_vnum vnum);
|
|
|
|
|
int House_save(struct obj_data *obj, FILE *fp);
|
|
|
|
|
void House_restore_weight(struct obj_data *obj);
|
|
|
|
|
void House_delete_file(room_vnum vnum);
|
|
|
|
|
int find_house(room_vnum vnum);
|
|
|
|
|
void House_save_control(void);
|
2007-01-17 01:41:47 +00:00
|
|
|
void hcontrol_list_houses(struct char_data *ch, char *arg);
|
2006-12-19 22:56:18 +00:00
|
|
|
void hcontrol_build_house(struct char_data *ch, char *arg);
|
|
|
|
|
void hcontrol_destroy_house(struct char_data *ch, char *arg);
|
|
|
|
|
void hcontrol_pay_house(struct char_data *ch, char *arg);
|
2007-01-15 17:48:18 +00:00
|
|
|
void House_listrent(struct char_data *ch, room_vnum vnum);
|
2006-12-19 22:56:18 +00:00
|
|
|
ACMD(do_hcontrol);
|
|
|
|
|
ACMD(do_house);
|
|
|
|
|
|
|
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
// CONVERSION code starts here -- see comment below
|
|
|
|
|
int ascii_convert_house(struct char_data *ch, obj_vnum vnum);
|
|
|
|
|
void hcontrol_convert_houses(struct char_data *ch);
|
|
|
|
|
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location);
|
|
|
|
|
// CONVERSION code ends here -- see comment below
|
|
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
/* First, the basics: finding the filename; loading/saving objects */
|
|
|
|
|
|
|
|
|
|
/* Return a filename given a house vnum */
|
|
|
|
|
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen)
|
|
|
|
|
{
|
|
|
|
|
if (vnum == NOWHERE)
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
snprintf(filename, maxlen, LIB_HOUSE"%d.house", vnum);
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Load all objects for a house */
|
|
|
|
|
int House_load(room_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
FILE *fl;
|
|
|
|
|
char filename[MAX_STRING_LENGTH];
|
2007-01-17 01:41:47 +00:00
|
|
|
obj_save_data *loaded, *current;
|
2006-12-19 22:56:18 +00:00
|
|
|
room_rnum rnum;
|
|
|
|
|
|
|
|
|
|
if ((rnum = real_room(vnum)) == NOWHERE)
|
|
|
|
|
return (0);
|
|
|
|
|
if (!House_get_filename(vnum, filename, sizeof(filename)))
|
|
|
|
|
return (0);
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
if (!(fl = fopen(filename, "r"))) /* no file found */
|
2006-12-19 22:56:18 +00:00
|
|
|
return (0);
|
2007-01-17 01:41:47 +00:00
|
|
|
|
|
|
|
|
loaded = objsave_parse_objects(fl);
|
|
|
|
|
|
|
|
|
|
for (current = loaded; current != NULL; current = current->next)
|
|
|
|
|
obj_to_room(current->obj, rnum);
|
|
|
|
|
|
2007-01-23 03:07:23 +00:00
|
|
|
/* now it's safe to free the obj_save_data list - all members of it
|
2007-01-17 01:41:47 +00:00
|
|
|
* have been put in the correct lists by obj_to_room()
|
|
|
|
|
*/
|
|
|
|
|
while (loaded != NULL) {
|
|
|
|
|
current = loaded;
|
|
|
|
|
loaded = loaded->next;
|
|
|
|
|
free(current);
|
|
|
|
|
}
|
2006-12-19 22:56:18 +00:00
|
|
|
|
|
|
|
|
fclose(fl);
|
|
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Save all objects for a house (recursive; initial call must be followed
|
|
|
|
|
by a call to House_restore_weight) Assumes file is open already. */
|
|
|
|
|
int House_save(struct obj_data *obj, FILE *fp)
|
|
|
|
|
{
|
|
|
|
|
struct obj_data *tmp;
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
if (obj) {
|
|
|
|
|
House_save(obj->contains, fp);
|
|
|
|
|
House_save(obj->next_content, fp);
|
2007-01-17 01:41:47 +00:00
|
|
|
result = objsave_save_obj_record(obj, fp, 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!result)
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
|
|
|
|
|
GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
|
|
|
|
|
}
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* restore weight of containers after House_save has changed them for saving */
|
|
|
|
|
void House_restore_weight(struct obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj) {
|
|
|
|
|
House_restore_weight(obj->contains);
|
|
|
|
|
House_restore_weight(obj->next_content);
|
|
|
|
|
if (obj->in_obj)
|
|
|
|
|
GET_OBJ_WEIGHT(obj->in_obj) += GET_OBJ_WEIGHT(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Save all objects in a house */
|
|
|
|
|
void House_crashsave(room_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
int rnum;
|
|
|
|
|
char buf[MAX_STRING_LENGTH];
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
if ((rnum = real_room(vnum)) == NOWHERE)
|
|
|
|
|
return;
|
|
|
|
|
if (!House_get_filename(vnum, buf, sizeof(buf)))
|
|
|
|
|
return;
|
|
|
|
|
if (!(fp = fopen(buf, "wb"))) {
|
|
|
|
|
perror("SYSERR: Error saving house file");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!House_save(world[rnum].contents, fp)) {
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
House_restore_weight(world[rnum].contents);
|
|
|
|
|
REMOVE_BIT(ROOM_FLAGS(rnum), ROOM_HOUSE_CRASH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Delete a house save file */
|
|
|
|
|
void House_delete_file(room_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
char filename[MAX_INPUT_LENGTH];
|
|
|
|
|
FILE *fl;
|
|
|
|
|
|
|
|
|
|
if (!House_get_filename(vnum, filename, sizeof(filename)))
|
|
|
|
|
return;
|
|
|
|
|
if (!(fl = fopen(filename, "rb"))) {
|
|
|
|
|
if (errno != ENOENT)
|
|
|
|
|
log("SYSERR: Error deleting house file #%d. (1): %s", vnum, strerror(errno));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fclose(fl);
|
|
|
|
|
if (remove(filename) < 0)
|
|
|
|
|
log("SYSERR: Error deleting house file #%d. (2): %s", vnum, strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* List all objects in a house file */
|
|
|
|
|
void House_listrent(struct char_data *ch, room_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
FILE *fl;
|
|
|
|
|
char filename[MAX_STRING_LENGTH];
|
|
|
|
|
char buf[MAX_STRING_LENGTH];
|
2007-01-17 01:41:47 +00:00
|
|
|
obj_save_data *loaded, *current;
|
|
|
|
|
int len = 0;
|
2006-12-19 22:56:18 +00:00
|
|
|
|
|
|
|
|
if (!House_get_filename(vnum, filename, sizeof(filename)))
|
|
|
|
|
return;
|
|
|
|
|
if (!(fl = fopen(filename, "rb"))) {
|
|
|
|
|
send_to_char(ch, "No objects on file for house #%d.\r\n", vnum);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
*buf = '\0';
|
2007-01-17 01:41:47 +00:00
|
|
|
len = snprintf(buf, sizeof(buf), "filename: %s\r\n", filename);
|
|
|
|
|
|
|
|
|
|
loaded = objsave_parse_objects(fl);
|
|
|
|
|
|
|
|
|
|
for (current = loaded; current != NULL; current = current->next)
|
2007-01-23 03:07:23 +00:00
|
|
|
len += snprintf(buf+len, sizeof(buf)-len, " [%5d] (%5dau) %s\r\n",
|
2007-01-17 01:41:47 +00:00
|
|
|
GET_OBJ_VNUM(current->obj), GET_OBJ_RENT(current->obj), current->obj->short_description);
|
|
|
|
|
|
2007-01-23 03:07:23 +00:00
|
|
|
/* now it's safe to free the obj_save_data list - all members of it
|
2007-01-17 01:41:47 +00:00
|
|
|
* have been put in the correct lists by obj_to_room()
|
|
|
|
|
*/
|
|
|
|
|
while (loaded != NULL) {
|
|
|
|
|
current = loaded;
|
|
|
|
|
loaded = loaded->next;
|
|
|
|
|
extract_obj(current->obj);
|
|
|
|
|
free(current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page_string(ch->desc,buf,0);
|
2006-12-19 22:56:18 +00:00
|
|
|
fclose(fl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
* Functions for house administration (creation, deletion, etc. *
|
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
|
|
int find_house(room_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_houses; i++)
|
|
|
|
|
if (house_control[i].vnum == vnum)
|
|
|
|
|
return (i);
|
|
|
|
|
|
|
|
|
|
return (NOWHERE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Save the house control information */
|
|
|
|
|
void House_save_control(void)
|
|
|
|
|
{
|
|
|
|
|
FILE *fl;
|
|
|
|
|
|
|
|
|
|
if (!(fl = fopen(HCONTROL_FILE, "wb"))) {
|
|
|
|
|
perror("SYSERR: Unable to open house control file.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* write all the house control recs in one fell swoop. Pretty nifty, eh? */
|
|
|
|
|
fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl);
|
|
|
|
|
|
|
|
|
|
fclose(fl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* call from boot_db - will load control recs, load objs, set atrium bits */
|
|
|
|
|
/* should do sanity checks on vnums & remove invalid records */
|
|
|
|
|
void House_boot(void)
|
|
|
|
|
{
|
|
|
|
|
struct house_control_rec temp_house;
|
|
|
|
|
room_rnum real_house, real_atrium;
|
|
|
|
|
FILE *fl;
|
|
|
|
|
|
|
|
|
|
memset((char *)house_control,0,sizeof(struct house_control_rec)*MAX_HOUSES);
|
|
|
|
|
|
|
|
|
|
if (!(fl = fopen(HCONTROL_FILE, "rb"))) {
|
|
|
|
|
if (errno == ENOENT)
|
|
|
|
|
log(" House control file '%s' does not exist.", HCONTROL_FILE);
|
|
|
|
|
else
|
|
|
|
|
perror("SYSERR: " HCONTROL_FILE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (!feof(fl) && num_of_houses < MAX_HOUSES) {
|
|
|
|
|
fread(&temp_house, sizeof(struct house_control_rec), 1, fl);
|
|
|
|
|
|
|
|
|
|
if (feof(fl))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (get_name_by_id(temp_house.owner) == NULL)
|
|
|
|
|
continue; /* owner no longer exists -- skip */
|
|
|
|
|
|
|
|
|
|
if ((real_house = real_room(temp_house.vnum)) == NOWHERE)
|
|
|
|
|
continue; /* this vnum doesn't exist -- skip */
|
|
|
|
|
|
|
|
|
|
if (find_house(temp_house.vnum) != NOWHERE)
|
|
|
|
|
continue; /* this vnum is already a house -- skip */
|
|
|
|
|
|
|
|
|
|
if ((real_atrium = real_room(temp_house.atrium)) == NOWHERE)
|
|
|
|
|
continue; /* house doesn't have an atrium -- skip */
|
|
|
|
|
|
|
|
|
|
if (temp_house.exit_num < 0 || temp_house.exit_num >= NUM_OF_DIRS)
|
|
|
|
|
continue; /* invalid exit num -- skip */
|
|
|
|
|
|
|
|
|
|
if (TOROOM(real_house, temp_house.exit_num) != real_atrium)
|
|
|
|
|
continue; /* exit num mismatch -- skip */
|
|
|
|
|
|
|
|
|
|
house_control[num_of_houses++] = temp_house;
|
|
|
|
|
|
|
|
|
|
SET_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE);
|
|
|
|
|
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
|
|
|
|
|
House_load(temp_house.vnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(fl);
|
|
|
|
|
House_save_control();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* "House Control" functions */
|
|
|
|
|
|
|
|
|
|
const char *HCONTROL_FORMAT =
|
|
|
|
|
"Usage: hcontrol build <house vnum> <exit direction> <player name>\r\n"
|
|
|
|
|
" hcontrol destroy <house vnum>\r\n"
|
|
|
|
|
" hcontrol pay <house vnum>\r\n"
|
2007-01-17 01:41:47 +00:00
|
|
|
" hcontrol show [house vnum | .]\r\n";
|
2006-12-19 22:56:18 +00:00
|
|
|
|
2007-01-17 01:41:47 +00:00
|
|
|
void hcontrol_list_houses(struct char_data *ch, char *arg)
|
2006-12-19 22:56:18 +00:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char *timestr, *temp;
|
|
|
|
|
char built_on[128], last_pay[128], own_name[MAX_NAME_LENGTH + 1];
|
|
|
|
|
|
2007-01-17 01:41:47 +00:00
|
|
|
if (arg && *arg) {
|
|
|
|
|
room_vnum toshow;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2007-01-17 01:41:47 +00:00
|
|
|
if (*arg == '.')
|
|
|
|
|
toshow = GET_ROOM_VNUM(IN_ROOM(ch));
|
|
|
|
|
else
|
|
|
|
|
toshow = atoi(arg);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2007-01-17 01:41:47 +00:00
|
|
|
if ((i = find_house(toshow)) == NOWHERE) {
|
|
|
|
|
send_to_char(ch, "Unknown house, \"%s\".\r\n", arg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
House_listrent(ch, toshow);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!num_of_houses) {
|
|
|
|
|
send_to_char(ch, "No houses have been defined.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
send_to_char(ch,
|
|
|
|
|
"Address Atrium Build Date Guests Owner Last Paymt\r\n"
|
|
|
|
|
"------- ------ ---------- ------ ------------ ----------\r\n");
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_houses; i++) {
|
|
|
|
|
/* Avoid seeing <UNDEF> entries from self-deleted people. -gg 6/21/98 */
|
|
|
|
|
if ((temp = get_name_by_id(house_control[i].owner)) == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (house_control[i].built_on) {
|
|
|
|
|
timestr = asctime(localtime(&(house_control[i].built_on)));
|
|
|
|
|
*(timestr + 10) = '\0';
|
|
|
|
|
strlcpy(built_on, timestr, sizeof(built_on));
|
|
|
|
|
} else
|
|
|
|
|
strcpy(built_on, "Unknown"); /* strcpy: OK (for 'strlen("Unknown") < 128') */
|
|
|
|
|
|
|
|
|
|
if (house_control[i].last_payment) {
|
|
|
|
|
timestr = asctime(localtime(&(house_control[i].last_payment)));
|
|
|
|
|
*(timestr + 10) = '\0';
|
2006-12-27 21:16:28 +00:00
|
|
|
strlcpy(last_pay, timestr, sizeof(last_pay));
|
2006-12-19 22:56:18 +00:00
|
|
|
} else
|
|
|
|
|
strcpy(last_pay, "None"); /* strcpy: OK (for 'strlen("None") < 128') */
|
|
|
|
|
|
|
|
|
|
/* Now we need a copy of the owner's name to capitalize. -gg 6/21/98 */
|
|
|
|
|
strcpy(own_name, temp); /* strcpy: OK (names guaranteed <= MAX_NAME_LENGTH+1) */
|
|
|
|
|
send_to_char(ch, "%7d %7d %-10s %2d %-12s %s\r\n",
|
|
|
|
|
house_control[i].vnum, house_control[i].atrium, built_on,
|
|
|
|
|
house_control[i].num_of_guests, CAP(own_name), last_pay);
|
|
|
|
|
|
|
|
|
|
House_list_guests(ch, i, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hcontrol_build_house(struct char_data *ch, char *arg)
|
|
|
|
|
{
|
|
|
|
|
char arg1[MAX_INPUT_LENGTH];
|
|
|
|
|
struct house_control_rec temp_house;
|
|
|
|
|
room_vnum virt_house, virt_atrium;
|
|
|
|
|
room_rnum real_house, real_atrium;
|
|
|
|
|
sh_int exit_num;
|
|
|
|
|
long owner;
|
|
|
|
|
|
|
|
|
|
if (num_of_houses >= MAX_HOUSES) {
|
|
|
|
|
send_to_char(ch, "Max houses already defined.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* first arg: house's 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 already exists.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* second arg: direction of house's exit */
|
|
|
|
|
arg = one_argument(arg, arg1);
|
|
|
|
|
if (!*arg1) {
|
|
|
|
|
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) {
|
|
|
|
|
send_to_char(ch, "'%s' is not a valid direction.\r\n", arg1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (TOROOM(real_house, exit_num) == NOWHERE) {
|
|
|
|
|
send_to_char(ch, "There is no exit %s from room %d.\r\n", dirs[exit_num], virt_house);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
real_atrium = TOROOM(real_house, exit_num);
|
|
|
|
|
virt_atrium = GET_ROOM_VNUM(real_atrium);
|
|
|
|
|
|
|
|
|
|
if (TOROOM(real_atrium, rev_dir[exit_num]) != real_house) {
|
|
|
|
|
send_to_char(ch, "A house's exit must be a two-way door.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* third arg: player's name */
|
|
|
|
|
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.mode = HOUSE_PRIVATE;
|
|
|
|
|
temp_house.vnum = virt_house;
|
|
|
|
|
temp_house.atrium = virt_atrium;
|
|
|
|
|
temp_house.exit_num = exit_num;
|
|
|
|
|
temp_house.built_on = time(0);
|
|
|
|
|
temp_house.last_payment = 0;
|
|
|
|
|
temp_house.owner = owner;
|
|
|
|
|
temp_house.num_of_guests = 0;
|
|
|
|
|
|
|
|
|
|
house_control[num_of_houses++] = temp_house;
|
|
|
|
|
|
|
|
|
|
SET_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE);
|
|
|
|
|
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
|
|
|
|
|
House_crashsave(virt_house);
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "House built. Mazel tov!\r\n");
|
|
|
|
|
House_save_control();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hcontrol_destroy_house(struct char_data *ch, char *arg)
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
room_rnum real_atrium, real_house;
|
|
|
|
|
|
|
|
|
|
if (!*arg) {
|
|
|
|
|
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((i = find_house(atoi(arg))) == NOWHERE) {
|
|
|
|
|
send_to_char(ch, "Unknown house.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((real_atrium = real_room(house_control[i].atrium)) == NOWHERE)
|
|
|
|
|
log("SYSERR: House %d had invalid atrium %d!", atoi(arg), house_control[i].atrium);
|
|
|
|
|
else
|
|
|
|
|
REMOVE_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
|
|
|
|
|
|
|
|
|
|
if ((real_house = real_room(house_control[i].vnum)) == NOWHERE)
|
|
|
|
|
log("SYSERR: House %d had invalid vnum %d!", atoi(arg), house_control[i].vnum);
|
|
|
|
|
else
|
|
|
|
|
REMOVE_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE | ROOM_HOUSE_CRASH);
|
|
|
|
|
|
|
|
|
|
House_delete_file(house_control[i].vnum);
|
|
|
|
|
|
|
|
|
|
for (j = i; j < num_of_houses - 1; j++)
|
|
|
|
|
house_control[j] = house_control[j + 1];
|
|
|
|
|
|
|
|
|
|
num_of_houses--;
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "House deleted.\r\n");
|
|
|
|
|
House_save_control();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now, reset the ROOM_ATRIUM flag on all existing houses' atriums,
|
|
|
|
|
* just in case the house we just deleted shared an atrium with another
|
|
|
|
|
* house. --JE 9/19/94
|
|
|
|
|
*/
|
|
|
|
|
for (i = 0; i < num_of_houses; i++)
|
|
|
|
|
if ((real_atrium = real_room(house_control[i].atrium)) != NOWHERE)
|
|
|
|
|
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hcontrol_pay_house(struct char_data *ch, char *arg)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!*arg)
|
|
|
|
|
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
|
|
|
|
else if ((i = find_house(atoi(arg))) == NOWHERE)
|
|
|
|
|
send_to_char(ch, "Unknown house.\r\n");
|
|
|
|
|
else {
|
|
|
|
|
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "Payment for house %s collected by %s.", arg, GET_NAME(ch));
|
|
|
|
|
|
|
|
|
|
house_control[i].last_payment = time(0);
|
|
|
|
|
House_save_control();
|
|
|
|
|
send_to_char(ch, "Payment recorded.\r\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The hcontrol command itself, used by imms to create/destroy houses */
|
|
|
|
|
ACMD(do_hcontrol)
|
|
|
|
|
{
|
|
|
|
|
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
half_chop(argument, arg1, arg2);
|
|
|
|
|
|
|
|
|
|
if (is_abbrev(arg1, "build"))
|
|
|
|
|
hcontrol_build_house(ch, arg2);
|
|
|
|
|
else if (is_abbrev(arg1, "destroy"))
|
|
|
|
|
hcontrol_destroy_house(ch, arg2);
|
|
|
|
|
else if (is_abbrev(arg1, "pay"))
|
|
|
|
|
hcontrol_pay_house(ch, arg2);
|
|
|
|
|
else if (is_abbrev(arg1, "show"))
|
2007-01-17 01:41:47 +00:00
|
|
|
hcontrol_list_houses(ch, arg2);
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
// CONVERSION code starts here -- see comment below
|
|
|
|
|
// not in hcontrol_format
|
|
|
|
|
else if (!str_cmp(arg1, "asciiconvert"))
|
|
|
|
|
hcontrol_convert_houses(ch);
|
|
|
|
|
// CONVERSION ends here -- read more below
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
send_to_char(ch, "%s", HCONTROL_FORMAT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The house command, used by mortal house owners to assign guests */
|
|
|
|
|
ACMD(do_house)
|
|
|
|
|
{
|
|
|
|
|
char arg[MAX_INPUT_LENGTH];
|
|
|
|
|
int i, j, id;
|
|
|
|
|
|
|
|
|
|
one_argument(argument, arg);
|
|
|
|
|
|
|
|
|
|
if (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOUSE))
|
|
|
|
|
send_to_char(ch, "You must be in your house to set guests.\r\n");
|
|
|
|
|
else if ((i = find_house(GET_ROOM_VNUM(IN_ROOM(ch)))) == NOWHERE)
|
|
|
|
|
send_to_char(ch, "Um.. this house seems to be screwed up.\r\n");
|
|
|
|
|
else if (GET_IDNUM(ch) != house_control[i].owner)
|
|
|
|
|
send_to_char(ch, "Only the primary owner can set guests.\r\n");
|
|
|
|
|
else if (!*arg)
|
|
|
|
|
House_list_guests(ch, i, FALSE);
|
|
|
|
|
else if ((id = get_id_by_name(arg)) < 0)
|
|
|
|
|
send_to_char(ch, "No such player.\r\n");
|
|
|
|
|
else if (id == GET_IDNUM(ch))
|
|
|
|
|
send_to_char(ch, "It's your house!\r\n");
|
|
|
|
|
else {
|
|
|
|
|
for (j = 0; j < house_control[i].num_of_guests; j++)
|
|
|
|
|
if (house_control[i].guests[j] == id) {
|
|
|
|
|
for (; j < house_control[i].num_of_guests; j++)
|
|
|
|
|
house_control[i].guests[j] = house_control[i].guests[j + 1];
|
|
|
|
|
house_control[i].num_of_guests--;
|
|
|
|
|
House_save_control();
|
|
|
|
|
send_to_char(ch, "Guest deleted.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (house_control[i].num_of_guests == MAX_GUESTS) {
|
|
|
|
|
send_to_char(ch, "You have too many guests.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
j = house_control[i].num_of_guests++;
|
|
|
|
|
house_control[i].guests[j] = id;
|
|
|
|
|
House_save_control();
|
|
|
|
|
send_to_char(ch, "Guest added.\r\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Misc. administrative functions */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* crash-save all the houses */
|
|
|
|
|
void House_save_all(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
room_rnum real_house;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_houses; i++)
|
|
|
|
|
if ((real_house = real_room(house_control[i].vnum)) != NOWHERE)
|
|
|
|
|
if (ROOM_FLAGGED(real_house, ROOM_HOUSE_CRASH))
|
|
|
|
|
House_crashsave(house_control[i].vnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* note: arg passed must be house vnum, so there. */
|
|
|
|
|
int House_can_enter(struct char_data *ch, room_vnum house)
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
if (GET_LEVEL(ch) >= LVL_GRGOD || (i = find_house(house)) == NOWHERE)
|
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
|
|
switch (house_control[i].mode) {
|
|
|
|
|
case HOUSE_PRIVATE:
|
|
|
|
|
if (GET_IDNUM(ch) == house_control[i].owner)
|
|
|
|
|
return (1);
|
|
|
|
|
for (j = 0; j < house_control[i].num_of_guests; j++)
|
|
|
|
|
if (GET_IDNUM(ch) == house_control[i].guests[j])
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void House_list_guests(struct char_data *ch, int i, int quiet)
|
|
|
|
|
{
|
|
|
|
|
int j, num_printed;
|
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
|
|
if (house_control[i].num_of_guests == 0) {
|
|
|
|
|
if (!quiet)
|
|
|
|
|
send_to_char(ch, " Guests: None\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, " Guests: ");
|
|
|
|
|
|
|
|
|
|
for (num_printed = j = 0; j < house_control[i].num_of_guests; j++) {
|
|
|
|
|
/* Avoid <UNDEF>. -gg 6/21/98 */
|
|
|
|
|
if ((temp = get_name_by_id(house_control[i].guests[j])) == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
num_printed++;
|
|
|
|
|
send_to_char(ch, "%c%s ", UPPER(*temp), temp + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_printed == 0)
|
|
|
|
|
send_to_char(ch, "all dead");
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
/* ***********************************************************************
|
|
|
|
|
* All code below this point and the code above, marked "CONVERSION" *
|
|
|
|
|
* can be removed after you have converted your house rent files using *
|
|
|
|
|
* the command *
|
|
|
|
|
* hcontrol asciiconvert *
|
|
|
|
|
* *
|
|
|
|
|
* You can only use this command as implementor. *
|
|
|
|
|
* After you have converted your house files, I suggest a reboot, which *
|
|
|
|
|
* will let your house files load on the next bootup. *
|
|
|
|
|
* *
|
|
|
|
|
* Welcor *
|
|
|
|
|
* ***********************************************************************/
|
|
|
|
|
/*
|
2007-01-23 03:07:23 +00:00
|
|
|
* Code for conversion to ascii house rent files
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void hcontrol_convert_houses(struct char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
if (GET_LEVEL(ch) < LVL_IMPL)
|
|
|
|
|
{
|
|
|
|
|
send_to_char(ch, "Sorry, but you are not powerful enough to do that.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!num_of_houses) {
|
|
|
|
|
send_to_char(ch, "No houses have been defined.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "Converting houses:\r\n");
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_houses; i++) {
|
|
|
|
|
send_to_char(ch, " %d", house_control[i].vnum);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
if (!ascii_convert_house(ch, house_control[i].vnum))
|
2007-01-23 03:07:23 +00:00
|
|
|
{
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
// let ascii_convert_house() tell about the error
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
send_to_char(ch, "...done\r\n");
|
2007-01-23 03:07:23 +00:00
|
|
|
}
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
send_to_char(ch, "All done.\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ascii_convert_house(struct char_data *ch, obj_vnum vnum)
|
|
|
|
|
{
|
|
|
|
|
FILE *in, *out;
|
|
|
|
|
char infile[MAX_INPUT_LENGTH], *outfile;
|
|
|
|
|
struct obj_data *tmp;
|
|
|
|
|
int i, j=0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
|
|
|
|
House_get_filename(vnum, infile, sizeof(infile));
|
|
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
CREATE(outfile, char, strlen(infile)+7);
|
|
|
|
|
sprintf(outfile, "%s.ascii", infile);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
if (!(in = fopen(infile, "r+b"))) /* no file found */
|
|
|
|
|
{
|
|
|
|
|
send_to_char(ch, "...no object file found\r\n");
|
|
|
|
|
free(outfile);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(out = fopen(outfile, "w")))
|
|
|
|
|
{
|
|
|
|
|
send_to_char(ch, "...cannot open output file\r\n");
|
|
|
|
|
free(outfile);
|
|
|
|
|
fclose(in);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (!feof(in)) {
|
|
|
|
|
struct obj_file_elem object;
|
|
|
|
|
fread(&object, sizeof(struct obj_file_elem), 1, in);
|
|
|
|
|
if (ferror(in)) {
|
|
|
|
|
perror("SYSERR: Reading house file in House_load");
|
|
|
|
|
send_to_char(ch, "...read error in house rent file.\r\n");
|
|
|
|
|
free(outfile);
|
|
|
|
|
fclose(in);
|
|
|
|
|
fclose(out);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
if (!feof(in))
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
{
|
|
|
|
|
tmp = Obj_from_store(object, &i);
|
|
|
|
|
if (!objsave_save_obj_record(tmp, out, i))
|
|
|
|
|
{
|
|
|
|
|
send_to_char(ch, "...write error in house rent file.\r\n");
|
|
|
|
|
free(outfile);
|
|
|
|
|
fclose(in);
|
|
|
|
|
fclose(out);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
fprintf(out, "$~\n");
|
|
|
|
|
|
|
|
|
|
fclose(in);
|
|
|
|
|
fclose(out);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
// copy the new file over the old one
|
|
|
|
|
// remove(infile);
|
|
|
|
|
// rename(outfile, infile);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
If you are applying this as a patch to your running mud, be sure to
BACK UP YOUR FILES FIRST
This is especially true, since the circlemud 3.5 code released
during december 2006 WILL RUIN YOUR HOUSE FILES and CORRUPT your
rent files. This is due to the introduction of ASCII rent files.
Unfortunately we were too eager to add what we thought was a
magnificent idea, and in the process forgot that people with
actual live running muds might use the code we provided.
Since the development has taken place on TBA, which has no players
as such, we failed to notice that the update was not thorough enough,
and several important additions were not added - for instance, a
house file and rent file converter tool. Also, it turned out, the
addition had severely hampered the object saving and loading routines,
to a point where items were being saved in an incompatible format
in houses.
Here is how to successfully convert your circlemud 3.1 house files,
step by step:
1) backup your house files somewhere not in the /lib/house folder
2) apply patch, debug, etc.
3) run the mud
4) now copy your house files back (while the mud is running!)
5) from within the mud, type "hcontrol asciiconvert" (without the quotes).
This will give you some feedback about which houses are being processed.
6) shut down the mud
7) in lib/house, enter these commands:
rm *.house (you still have a backup of this, right ?)
for i in *.ascii; do mv "$i" "${i/.ascii}"; done
8) start the mud - your houses now contain the right items.
9) feel free to remove code in house.c marked with CONVERSION tags.
2007-01-18 00:55:30 +00:00
|
|
|
free(outfile);
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "...%d items", j);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the circle 3.1 function for reading rent files. No longer used by the rent system.
|
|
|
|
|
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location)
|
|
|
|
|
{
|
|
|
|
|
struct obj_data *obj;
|
|
|
|
|
obj_rnum itemnum;
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
*location = 0;
|
|
|
|
|
if ((itemnum = real_object(object.item_number)) == NOTHING)
|
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
|
|
obj = read_object(itemnum, REAL);
|
|
|
|
|
#if USE_AUTOEQ
|
|
|
|
|
*location = object.location;
|
|
|
|
|
#endif
|
|
|
|
|
GET_OBJ_VAL(obj, 0) = object.value[0];
|
|
|
|
|
GET_OBJ_VAL(obj, 1) = object.value[1];
|
|
|
|
|
GET_OBJ_VAL(obj, 2) = object.value[2];
|
|
|
|
|
GET_OBJ_VAL(obj, 3) = object.value[3];
|
|
|
|
|
GET_OBJ_EXTRA(obj) = object.extra_flags;
|
|
|
|
|
GET_OBJ_WEIGHT(obj) = object.weight;
|
|
|
|
|
GET_OBJ_TIMER(obj) = object.timer;
|
|
|
|
|
GET_OBJ_AFFECT(obj) = object.bitvector;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < MAX_OBJ_AFFECT; j++)
|
|
|
|
|
obj->affected[j] = object.affected[j];
|
|
|
|
|
|
|
|
|
|
return (obj);
|
|
|
|
|
}
|