#if defined(macintosh) #include <types.h> #else #include <sys/types.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "merc.h" char *get_room_description(CHAR_DATA *ch, char *descr) { char message[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH]; char temp[MAX_STRING_LENGTH]; char rdesc[MAX_STRING_LENGTH]; int i, letters, space, newspace, line; EXIT_DATA *pexit; /* Count the number of each type of message, and abbreviate in case of very long strings */ /* Get room's desc first, tack other stuff in after that. */ strcpy(buf, ch->in_room->description); sprintf(buf, "\n\r"); sprintf(message, " "); /* One sentence about the room we're in */ switch(ch->in_room->sector_type) { case 0: break; case 1: strcat(message, " The city street is"); // if (ch->in_room->curr_vegetation > 66) // strcat(message, " lined by lush trees and hedges"); strcat(message, ". "); break; case 2: strcat(message, " Rocky, steep terrain leads up into these mountain peaks. "); break; case 3: strcat(message, " Water swirls all around. "); break; case 4: strcat(message, " The thin air swirls past, barely making even its presence known. "); break; case 5: strcat(message, " The details of this location are strangely difficult to determine. "); break; case 6: strcat(message, " Molten lava flows through the volcanic caverns. "); break; case 7: strcat(message, " The solid ice shows no trace of life. "); break; default: strcat(message, ""); break; } strcat(buf, message); /* List appropriate room flags */ strcpy(message, ""); if (IS_AFFECTED(ch, AFF_DETECT_MAGIC)) { if (IS_SET(ch->in_room->room_flags, ROOM_SAFE)) strcat(message, "A magical aura seems to promote a feeling of peace. "); if (IS_SET(ch->in_room->room_flags, ROOM_NO_RECALL)) strcat(message, "A very weak pulling sensation emenates from this place. "); } if (IS_SET(ch->in_room->room_flags, ROOM_DARK)) strcat(message, "It is quite dark in here. "); if (IS_SET(ch->in_room->room_flags, ROOM_PRIVATE)) strcat(message, "A sign on the wall states, 'This room is private.' "); strcat(buf, message); /* List exits */ for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next ) { if (pexit->to_room) { if (IS_SET(pexit->exit_info, EX_HIDDEN) || IS_SET(pexit->exit_info, EX_SECRET)) continue; strcpy(message, ""); if (IS_SET(pexit->exit_info, EX_ISDOOR)) { if (IS_SET(pexit->exit_info, EX_BASHED)) strcat(message, "bashed in "); else { if (IS_SET(pexit->exit_info, EX_NOPASSDOOR) || IS_SET(pexit->exit_info, EX_BASHPROOF)) strcat(message, "thick looking "); if (IS_SET(pexit->exit_info, EX_CLOSED)) strcat(message, "closed "); else strcat(message, "open "); } if (strcmp(pexit->keyword, "")) strcat(message, pexit->keyword); else strcat(message, "door"); strcat(message, " leads "); strcat(message, dir_name[pexit->vdir]); strcat(message, ". "); strcat(buf, capitalize(message)); } else { /* Don't say anything about normal exits, only interesting ones */ if (pexit->to_room->sector_type != ch->in_room->sector_type) { strcpy(temp, ""); switch (pexit->to_room->sector_type) { case 0: strcat(temp, "A building lies %s from here. "); break; case 1: strcat(temp, "A well worn road leads %s from here. "); break; case 2: strcat(temp, "Fields lie to the %s. "); break; case 3: strcat(temp, "Tall trees obscure the horizon to the %s. "); break; case 4: strcat(temp, "Rough, hilly terrain lies %s from here. "); break; case 5: strcat(temp, "Steep mountains loom to the %s. "); break; case 6: /* Is the water frozen? */ // if (IS_OUTSIDE(ch) && ((ch->in_room->area->weather->temp + 3*weath_unit -1)/weath_unit < 3)) strcat(temp, "Some fairly shallow water to the %s seems frozen enough to walk on. "); // else // strcat(temp, "Fairly shallow water is visible to the %s. "); break; case 7: /* Is the water frozen? */ // if (IS_OUTSIDE(ch) && ((ch->in_room->area->weather->temp + 3*weath_unit -1)/weath_unit < 3)) strcat(temp, "The water to the %s is frozen solid. "); // else // strcat(temp, "The water %s of here looks quite deep. "); break; case 8: strcat(temp, "Murky water swirls endlessly %s of here. "); break; case 9: strcat(temp, "There is nothing but open air %s from here. "); break; case 10: strcat(temp, "Desert sands reach %s into the distance. "); break; case 12: strcat(temp, "The sandy ocean floor stretches %s. "); break; case 13: strcat(temp, "Dimly lit caverns continue %s from here. "); break; case 14: strcat(temp, "Molten lava flows %s from here. "); break; case 15: strcat(temp, "Muddy swamplands continue to the %s. "); break; case 16: strcat(temp, "Solid ice is visible to the %s. "); break; case 17: strcat(temp, "The beach can be seen to the %s. "); } sprintf(message, temp, dir_name[pexit->vdir]); strcat(buf, message); } } } } strcat(buf, " "); i=0; letters=0; /* Strip \r and \n */ for (i=0; i<strlen(buf); i++) { if (buf[i] != '\r' && buf[i] != '\n') { rdesc[letters]=buf[i]; letters++; } else if (buf[i] == '\r') { rdesc[letters]=' '; letters++; } rdesc[letters]='\0'; } i=0; letters=0; space=0; newspace=0; line=0; strcpy(buf, rdesc); /* Add \r\n's back in at their appropriate places */ for (i=0; i<strlen(buf); i++) { if (buf[i]==' ') { space=i; newspace=letters; } if (line > 70) { i=space; letters=newspace; rdesc[letters++]='\r'; rdesc[letters++]='\n'; line=0; } else if (!(buf[i]==' ' && buf[i+1]==' ')) { rdesc[letters]=buf[i]; letters++; /* Index for rdesc; i is the index for buf */ line++; /* Counts number of characters on this line */ } rdesc[letters+1]='\0'; } if (strlen(rdesc) > 0) strcat(rdesc, "\r\n"); descr=STRALLOC(rdesc); return descr; }