shield with their heraldry.
Don't forget to create the objs you want the descs to be saved.
diff -u -b --recursive ../../circle30bpl11/src/act.wizard.c ./act.wizard.c
--- ../../circle30bpl11/src/act.wizard.c Sun Apr 14 00:59:44 1996
+++ ./act.wizard.c Fri Aug 16 17:33:44 1996
@@ -67,6 +67,30 @@
extern char *position_types[];
extern char *connected_types[];
+int add_extra_desc(struct obj_data *obj,char *buf);
+
+void do_newbie(struct char_data *vict)
+{
+ int give_obj[] = {1300, 5423, 3071, 3081, 3086, 6002, 7211, 3104, 3015, 3015, -1};
+/* replace the 4 digit numbers on the line above with your basic eq -1 HAS
+ * to be the end field */
+
+ struct obj_data *obj;
+ int i;
+
+ for (i = 1; give_obj[i] != -1; i++) {
+ obj = read_object(give_obj[i], VIRTUAL);
+ obj_to_char(obj, vict);
+ }
+
+ /* Personalize the newbie shield with his herald */
+ obj = read_object(give_obj[0], VIRTUAL);
+ obj_to_char(obj, vict);
+ sprintf(buf, "the ancestral shield of %s", GET_NAME(vict));
+ obj->short_description=str_dup(buf);
+ sprintf(buf, "The herald of %s is engraved on it.", GET_NAME(vict));
+ add_extra_desc(obj,buf);
+}
ACMD(do_echo)
diff -u -b --recursive ../../circle30bpl11/src/house.c ./house.c
--- ../../circle30bpl11/src/house.c Sat Apr 13 04:39:21 1996
+++ ./house.c Fri Aug 16 17:24:28 1996
@@ -29,7 +29,8 @@
struct obj_data *Obj_from_store(struct obj_file_elem object);
-int Obj_to_store(struct obj_data * obj, FILE * fl);
+int Obj_to_store(struct obj_data * obj, FILE * fl, FILE *fd);
+int load_descs(struct obj_data *obj,char *buf, FILE *fd);
struct house_control_rec house_control[MAX_HOUSES];
int num_of_houses = 0;
@@ -48,12 +49,24 @@
}
+/* Return a filename of the descriptions of objs given a house vnum */
+int House_get_filedesc(int vnum, char *filename)
+{
+ if (vnum < 0)
+ return 0;
+
+ sprintf(filename, "house/%d.desc", vnum);
+ return 1;
+}
+
+
/* Load all objects for a house */
int House_load(int vnum)
{
- FILE *fl;
+ FILE *fl, *fd;
char fname[MAX_STRING_LENGTH];
struct obj_file_elem object;
+ struct obj_data *obj;
int rnum;
if ((rnum = real_room(vnum)) == -1)
@@ -64,34 +77,49 @@
/* no file found */
return 0;
}
+ if (!House_get_filedesc(vnum, fname)) {
+ fclose(fl);
+ return 0;
+ }
+ if (!(fd = fopen(fname, "r+b"))) { /* no file found */
+ fclose(fl);
+ return 0;
+ }
while (!feof(fl)) {
fread(&object, sizeof(struct obj_file_elem), 1, fl);
if (ferror(fl)) {
perror("Reading house file: House_load.");
fclose(fl);
+ fclose(fd);
return 0;
}
- if (!feof(fl))
- obj_to_room(Obj_from_store(object), rnum);
+ if (!feof(fl)) {
+ obj_to_room(obj=Obj_from_store(object), rnum);
+ if( (object.item_number >= L_DESC_NUM) && (object.item_number <= U_DESC_NUM) ) {
+ if( !feof(fd))
+ load_descs(obj, "House_load()", fd);
+ else
+ fprintf(stderr, "House_load: End of file reached with objs descs missing. Obj vnum:%d\n\r",object.item_number);
+ }
+ }
}
-
fclose(fl);
-
+ fclose(fd);
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)
+int House_save(struct obj_data * obj, FILE * fp, FILE *fd)
{
struct obj_data *tmp;
int result;
if (obj) {
- House_save(obj->contains, fp);
- House_save(obj->next_content, fp);
- result = Obj_to_store(obj, fp);
+ House_save(obj->contains, fp, fd);
+ House_save(obj->next_content, fp, fd);
+ result = Obj_to_store(obj, fp, fd);
if (!result)
return 0;
@@ -119,7 +147,7 @@
{
int rnum;
char buf[MAX_STRING_LENGTH];
- FILE *fp;
+ FILE *fp, *fd;
if ((rnum = real_room(vnum)) == -1)
return;
@@ -129,11 +157,22 @@
perror("SYSERR: Error saving house file");
return;
}
- if (!House_save(world[rnum].contents, fp)) {
+ if (!House_get_filedesc(vnum, buf)) {
fclose(fp);
return;
}
+ if (!(fd = fopen(buf, "wb"))) {
+ perror("SYSERR: Error saving house desc file");
fclose(fp);
+ return;
+ }
+ if (!House_save(world[rnum].contents, fp, fd)) {
+ fclose(fp);
+ fclose(fd);
+ return;
+ }
+ fclose(fp);
+ fclose(fd);
House_restore_weight(world[rnum].contents);
REMOVE_BIT(ROOM_FLAGS(rnum), ROOM_HOUSE_CRASH);
}
@@ -157,6 +196,20 @@
fclose(fl);
if (unlink(fname) < 0) {
sprintf(buf, "SYSERR: Error deleting house file #%d. (2)", vnum);
+ perror(buf);
+ }
+ if (!House_get_filedesc(vnum, fname))
+ return;
+ if (!(fl = fopen(fname, "rb"))) {
+ if (errno != ENOENT) {
+ sprintf(buf, "SYSERR: Error deleting house file #%d. (3)", vnum);
+ perror(buf);
+ }
+ return;
+ }
+ fclose(fl);
+ if (unlink(fname) < 0) {
+ sprintf(buf, "SYSERR: Error deleting house file with descs#%d. (4)", vnum);
perror(buf);
}
}
diff -u -b --recursive ../../circle30bpl11/src/interpreter.c ./interpreter.c
--- ../../circle30bpl11/src/interpreter.c Sat Apr 13 04:39:21 1996
+++ ./interpreter.c Thu Aug 15 18:33:17 1996
@@ -42,6 +42,7 @@
extern struct room_data *world;
/* external functions */
+void do_newbie(struct char_data *vict);
void echo_on(struct descriptor_data *d);
void echo_off(struct descriptor_data *d);
void do_start(struct char_data *ch);
@@ -1553,6 +1554,7 @@
STATE(d) = CON_PLAYING;
if (!GET_LEVEL(d->character)) {
do_start(d->character);
+ do_newbie(d->character);
send_to_char(START_MESSG, d->character);
}
look_at_room(d->character, 0);
diff -u -b --recursive ../../circle30bpl11/src/objsave.c ./objsave.c
--- ../../circle30bpl11/src/objsave.c Sat Apr 13 04:39:21 1996
+++ ./objsave.c Fri Aug 16 17:19:48 1996
@@ -37,6 +37,7 @@
ACMD(do_tell);
SPECIAL(receptionist);
SPECIAL(cryogenicist);
+int save_descs(struct obj_data *obj, FILE *fd);
struct obj_data *Obj_from_store(struct obj_file_elem object)
{
@@ -64,7 +65,7 @@
-int Obj_to_store(struct obj_data * obj, FILE * fl)
+int Obj_to_store(struct obj_data * obj, FILE * fl,FILE *fd)
{
int j;
struct obj_file_elem object;
@@ -85,6 +86,11 @@
perror("Error writing object in Obj_to_store");
return 0;
}
+ if( (object.item_number >= L_DESC_NUM) &&
+ (object.item_number <= U_DESC_NUM) ) {
+ save_descs(obj, fd);
+ }
+
return 1;
}
@@ -93,9 +99,10 @@
int Crash_delete_file(char *name)
{
char filename[50];
+ char filedesc[50];
FILE *fl;
- if (!get_filename(name, filename, CRASH_FILE))
+ if( (!get_filename(name, filename, CRASH_FILE)) || (!get_file_desc(name, filedesc, CRASH_FILE)) )
return 0;
if (!(fl = fopen(filename, "rb"))) {
if (errno != ENOENT) { /* if it fails but NOT because of no file */
@@ -105,8 +112,16 @@
return 0;
}
fclose(fl);
+ if (!(fl = fopen(filedesc, "rb"))) {
+ if (errno != ENOENT) { /* if it fails but NOT because of no file */
+ sprintf(buf1, "SYSERR: deleting crash file %s (1)", filedesc);
+ perror(buf1);
+ }
+ return 0;
+ }
+ fclose(fl);
- if (unlink(filename) < 0) {
+ if (unlink(filedesc) < 0) {
if (errno != ENOENT) { /* if it fails, NOT because of no file */
sprintf(buf1, "SYSERR: deleting crash file %s (2)", filename);
perror(buf1);
@@ -280,6 +295,58 @@
+int add_extra_desc(struct obj_data *obj,char *buf)
+{
+ struct extra_descr_data **iterator;
+
+ if(!(obj && buf))
+ return 0;
+
+ iterator = &(obj->ex_description);
+ while (*iterator != NULL)
+ iterator = &((*iterator)->next);
+ *iterator = (struct extra_descr_data *) malloc(sizeof(struct extra_descr_data));
+ (*iterator)->keyword = str_dup(obj->name);
+ (*iterator)->description = str_dup(buf);
+ (*iterator)->next=NULL;
+ return 1;
+}
+
+
+
+int load_descs(struct obj_data *obj,char *buf, FILE *fd)
+{
+ char *str;
+
+ obj->name = fread_string(fd, buf);
+ obj->description = fread_string(fd, buf);
+ obj->short_description = fread_string(fd, buf);
+ obj->action_description = fread_string(fd, buf);
+ while( (str=fread_string(fd, buf)), str )
+ add_extra_desc(obj,str);
+ return 1;
+}
+
+
+
+int save_descs(struct obj_data *obj, FILE *fd)
+{
+ struct extra_descr_data *extra;
+
+ fprintf(fd, "%s~\n", obj->name? obj->name : "");
+ fprintf(fd, "%s~\n", obj->description? obj->description : "");
+ fprintf(fd, "%s~\n", obj->short_description? obj->short_description : "");
+ fprintf(fd, "%s~\n", obj->action_description? obj->action_description : "");
+ extra=obj->ex_description;
+ while(extra) {
+ fprintf(fd, "%s~\n", extra->description);
+ extra=extra->next;
+ }
+ fprintf(fd, "~\n");
+ return 1;
+}
+
+
int Crash_load(struct char_data * ch)
/* return values:
0 - successful load, keep char in rent room.
@@ -289,16 +356,20 @@
{
void Crash_crashsave(struct char_data * ch);
- FILE *fl;
+ FILE *fl,*fd;
char fname[MAX_STRING_LENGTH];
+ char fdesc[MAX_STRING_LENGTH];
struct obj_file_elem object;
+ struct obj_data *obj;
struct rent_info rent;
int cost, orig_rent_code;
float num_of_days;
- if (!get_filename(GET_NAME(ch), fname, CRASH_FILE))
+ if( (!get_filename(GET_NAME(ch), fname, CRASH_FILE)) ||
+ (!get_file_desc(GET_NAME(ch), fdesc, CRASH_FILE)) )
return 1;
- if (!(fl = fopen(fname, "r+b"))) {
+ if( (!(fl = fopen(fname, "r+b"))) || (!(fd = fopen(fdesc, "r+b"))) ) {
+/* tenho de melhorar isto */
if (errno != ENOENT) { /* if it fails, NOT because of no file */
sprintf(buf1, "SYSERR: READING OBJECT FILE %s (5)", fname);
perror(buf1);
@@ -318,6 +389,7 @@
cost = (int) (rent.net_cost_per_diem * num_of_days);
if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
fclose(fl);
+ fclose(fd);
sprintf(buf, "%s entering game, rented equipment lost (no $).",
GET_NAME(ch));
mudlog(buf, BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE);
@@ -358,19 +430,30 @@
if (ferror(fl)) {
perror("Reading crash file: Crash_load.");
fclose(fl);
+ fclose(fd);
return 1;
}
- if (!feof(fl))
- obj_to_char(Obj_from_store(object), ch);
+
+ if (!feof(fl)) {
+ obj_to_char(obj=Obj_from_store(object), ch);
+ if( (object.item_number >= L_DESC_NUM) && (object.item_number <= U_DESC_NUM) ) {
+ if( !feof(fd))
+ load_descs(obj,"Crash_load()", fd);
+ else
+ fprintf(stderr, "Crash_load: End of file reached with objs descs missing. Obj vnum:%d\n\r",object.item_number);
+ }
+ }
}
/* turn this into a crash file by re-writing the control block */
rent.rentcode = RENT_CRASH;
rent.time = time(0);
+
rewind(fl);
Crash_write_rentcode(ch, fl, &rent);
fclose(fl);
+ fclose(fd);
if ((orig_rent_code == RENT_RENTED) || (orig_rent_code == RENT_CRYO))
return 0;
@@ -380,15 +463,15 @@
-int Crash_save(struct obj_data * obj, FILE * fp)
+int Crash_save(struct obj_data * obj, FILE * fp, FILE *fd)
{
struct obj_data *tmp;
int result;
if (obj) {
- Crash_save(obj->contains, fp);
- Crash_save(obj->next_content, fp);
- result = Obj_to_store(obj, fp);
+ Crash_save(obj->contains, fp, fd);
+ Crash_save(obj->next_content, fp, fd);
+ result = Obj_to_store(obj, fp, fd);
for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
@@ -474,7 +557,7 @@
char buf[MAX_INPUT_LENGTH];
struct rent_info rent;
int j;
- FILE *fp;
+ FILE *fp, *fd;
if (IS_NPC(ch))
return;
@@ -484,13 +567,22 @@
if (!(fp = fopen(buf, "wb")))
return;
+ if (!get_file_desc(GET_NAME(ch), buf, CRASH_FILE)) {
+ fclose(fp);
+ return;
+ }
+ if (!(fd = fopen(buf, "wb"))) {
+ fclose(fp);
+ return;
+ }
+
rent.rentcode = RENT_CRASH;
rent.time = time(0);
if (!Crash_write_rentcode(ch, fp, &rent)) {
fclose(fp);
return;
}
- if (!Crash_save(ch->carrying, fp)) {
+ if (!Crash_save(ch->carrying, fp, fd)) {
fclose(fp);
return;
}
@@ -498,13 +590,14 @@
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(ch, j)) {
- if (!Crash_save(GET_EQ(ch, j), fp)) {
+ if (!Crash_save(GET_EQ(ch, j), fp, fd)) {
fclose(fp);
return;
}
Crash_restore_weight(GET_EQ(ch, j));
}
fclose(fp);
+ fclose(fd);
REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH);
}
@@ -515,7 +608,7 @@
struct rent_info rent;
int j;
int cost;
- FILE *fp;
+ FILE *fp, *fd;
if (IS_NPC(ch))
return;
@@ -524,6 +617,14 @@
return;
if (!(fp = fopen(buf, "wb")))
return;
+ if (!get_file_desc(GET_NAME(ch), buf, CRASH_FILE)) {
+ fclose(fp);
+ return;
+ }
+ if (!(fd = fopen(buf, "wb"))) {
+ fclose(fp);
+ return;
+ }
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(ch, j))
@@ -556,11 +657,12 @@
fclose(fp);
return;
}
- if (!Crash_save(ch->carrying, fp)) {
+ if (!Crash_save(ch->carrying, fp, fd)) {
fclose(fp);
return;
}
fclose(fp);
+ fclose(fd);
Crash_extract_objs(ch->carrying);
}
@@ -571,7 +673,7 @@
char buf[MAX_INPUT_LENGTH];
struct rent_info rent;
int j;
- FILE *fp;
+ FILE *fp, *fd;
if (IS_NPC(ch))
return;
@@ -580,6 +682,14 @@
return;
if (!(fp = fopen(buf, "wb")))
return;
+ if (!get_file_desc(GET_NAME(ch), buf, CRASH_FILE)) {
+ fclose(fp);
+ return;
+ }
+ if (!(fd = fopen(buf, "wb"))) {
+ fclose(fp);
+ return;
+ }
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(ch, j))
@@ -596,11 +706,12 @@
fclose(fp);
return;
}
- if (!Crash_save(ch->carrying, fp)) {
+ if (!Crash_save(ch->carrying, fp, fd)) {
fclose(fp);
return;
}
fclose(fp);
+ fclose(fd);
Crash_extract_objs(ch->carrying);
}
@@ -611,7 +722,7 @@
char buf[MAX_INPUT_LENGTH];
struct rent_info rent;
int j;
- FILE *fp;
+ FILE *fp, *fd;
if (IS_NPC(ch))
return;
@@ -620,6 +731,10 @@
return;
if (!(fp = fopen(buf, "wb")))
return;
+ if (!get_file_desc(GET_NAME(ch), buf, CRASH_FILE))
+ return;
+ if (!(fd = fopen(buf, "wb")))
+ return;
for (j = 0; j < NUM_WEARS; j++)
if (GET_EQ(ch, j))
@@ -638,11 +753,12 @@
fclose(fp);
return;
}
- if (!Crash_save(ch->carrying, fp)) {
+ if (!Crash_save(ch->carrying, fp, fd)) {
fclose(fp);
return;
}
fclose(fp);
+ fclose(fd);
Crash_extract_objs(ch->carrying);
SET_BIT(PLR_FLAGS(ch), PLR_CRYO);
diff -u -b --recursive ../../circle30bpl11/src/structs.h ./structs.h
--- ../../circle30bpl11/src/structs.h Sat Apr 13 04:39:22 1996
+++ ./structs.h Thu Aug 15 18:33:24 1996
@@ -441,6 +441,8 @@
#define MAX_SKILLS 200 /* Used in char_file_u *DO*NOT*CHANGE* */
#define MAX_AFFECT 32 /* Used in char_file_u *DO*NOT*CHANGE* */
#define MAX_OBJ_AFFECT 6 /* Used in obj_file_elem *DO*NOT*CHANGE* */
+#define L_DESC_NUM 1300 /* used in objsave.c -> lower limit for objs with extra description */
+#define U_DESC_NUM 1399 /* upper limit for objs with extra description */
/**********************************************************************
diff -u -b --recursive ../../circle30bpl11/src/utils.c ./utils.c
--- ../../circle30bpl11/src/utils.c Sun Apr 14 00:59:59 1996
+++ ./utils.c Thu Aug 15 18:33:25 1996
@@ -460,6 +460,56 @@
return 1;
}
+int get_file_desc(char *orig_name, char *filename, int mode)
+{
+ char *prefix, *middle, *suffix, *ptr, name[64];
+
+ switch (mode) {
+ case CRASH_FILE:
+ prefix = "plrobjs";
+ suffix = "desc";
+ break;
+ case ETEXT_FILE:
+ prefix = "plrtext";
+ suffix = "text";
+ break;
+ default:
+ return 0;
+ break;
+ }
+
+ if (!*orig_name)
+ return 0;
+
+ strcpy(name, orig_name);
+ for (ptr = name; *ptr; ptr++)
+ *ptr = LOWER(*ptr);
+
+ switch (LOWER(*name)) {
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ middle = "A-E";
+ break;
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ middle = "F-J";
+ break;
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ middle = "K-O";
+ break;
+ case 'p': case 'q': case 'r': case 's': case 't':
+ middle = "P-T";
+ break;
+ case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
+ middle = "U-Z";
+ break;
+ default:
+ middle = "ZZZ";
+ break;
+ }
+
+ sprintf(filename, "%s/%s/%s.%s", prefix, middle, name, suffix);
+ return 1;
+}
+
int num_pc_in_room(struct room_data *room)
{
diff -u -b --recursive ../../circle30bpl11/src/utils.h ./utils.h
--- ../../circle30bpl11/src/utils.h Sun Apr 14 17:10:18 1996
+++ ./utils.h Thu Aug 15 18:33:25 1996
@@ -33,6 +33,7 @@
void sprinttype(int type, char *names[], char *result);
int get_line(FILE *fl, char *buf);
int get_filename(char *orig_name, char *filename, int mode);
+int get_file_desc(char *orig_name, char *filedesc, int mode);
struct time_info_data age(struct char_data *ch);
int num_pc_in_room(struct room_data *room);
Jorge Guilherme
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://cspo.queensu.ca/~fletcher/Circle/list_faq.html |
+-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST