/******************************************************************************
 Snippet: Wilderness system (v1.0).
 Author:  Richard Woolcock (aka KaVir).
 Date:    2nd September 1998.
 ******************************************************************************
 File:    wild_info.c
 Purpose: Deals with wilderness display information.
 ******************************************************************************
 This code is copyright (C) 1998 by Richard Woolcock.  It may be used and
 distributed freely, as long as you do not remove this copyright notice.
 ******************************************************************************/

/******************************************************************************
 Required libraries
 ******************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "wild.h"

/******************************************************************************
 Global variables
 ******************************************************************************/

/* None. */

/******************************************************************************
 Local operation prototypes
 ******************************************************************************/

void	draw_room		args( ( CHAR_DATA *ch, int x, int y ) );

/******************************************************************************
 Global operations
 ******************************************************************************/

void draw_map( CHAR_DATA *ch )
{
    int loopx, loopy;
    bool is_inside = FALSE;

    if ( ch->x < 0 || ch->x >= WILDERNESS_SIZE ||
         ch->y < 0 || ch->y >= WILDERNESS_SIZE )
    {
	send_to_char("Bug!\n\r",ch);
	return;
    }

    switch (map_data(ch->x,ch->y))
    {
	default:
	    send_to_char("You are standing in the middle of nowhere.\n\r", ch);
	    break;
	case WILD_ROAD:
	    send_to_char("You are standing on a road.\n\r", ch);
	    break;
	case WILD_BUILDING_BURNED:
	    send_to_char("You are standing in the burned remains of a building.\n\r", ch);
	    break;
	case WILD_BUILDING_DESTROYED:
	    send_to_char("You are standing on the remains of a destroyed building.\n\r", ch);
	    break;
	case WILD_BUILDING_CONSTRUCTION:
	    send_to_char("You are standing in a partly constructed building.\n\r", ch);
	    break;
	case WILD_SCORCHED_GROUND:
	    send_to_char("You are standing on scorched ground.\n\r", ch);
	    break;
	case WILD_WATER_DEEP_1:
	case WILD_WATER_DEEP_2:
	    send_to_char("You are swimming in water.\n\r", ch);
	    break;
	case WILD_FOREST_1:
	case WILD_FOREST_2:
	    send_to_char("You are standing in a light forest.\n\r", ch);
	    break;
	case WILD_FOREST_3:
	case WILD_FOREST_4:
	    send_to_char("You are standing in a thick forest.\n\r", ch);
	    break;
	case WILD_HUT:
	case WILD_HUT_OWNED:
	case WILD_HUT_LOCKED:
	    send_to_char("You are standing in a hut.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_CABIN:
	case WILD_CABIN_OWNED:
	case WILD_CABIN_LOCKED:
	    send_to_char("You are standing in a cabin.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_COTTAGE:
	case WILD_COTTAGE_OWNED:
	case WILD_COTTAGE_LOCKED:
	    send_to_char("You are standing in a cottage.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_HOUSE:
	case WILD_HOUSE_OWNED:
	case WILD_HOUSE_LOCKED:
	    send_to_char("You are standing in a house.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_MINE_STRUCTURE_EMPTY:
	case WILD_MINE_STRUCTURE_STONE:
	case WILD_MINE_STRUCTURE_IRON:
	case WILD_MINE_STRUCTURE_GOLD:
	case WILD_MINE_STRUCTURE_OIL:
	    send_to_char("You are standing inside a wooden structure.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_MINE_EMPTY:
	case WILD_MINE_STONE_1:
	case WILD_MINE_STONE_2:
	case WILD_MINE_IRON_1:
	case WILD_MINE_IRON_2:
	case WILD_MINE_GOLD_1:
	case WILD_MINE_GOLD_2:
	case WILD_MINE_OIL_1:
	case WILD_MINE_OIL_2:
	    send_to_char("You are standing in a mine.\n\r", ch);
	    is_inside = TRUE;
	    break;
	case WILD_MOUNTAINS_NONE:
	case WILD_MOUNTAINS_STONE:
	case WILD_MOUNTAINS_IRON:
	case WILD_MOUNTAINS_GOLD:
	case WILD_MOUNTAINS_OIL:
	    send_to_char("You are standing on a mountain range.\n\r", ch);
	    break;
	case WILD_PLAINS:
	    send_to_char("You are standing on a plain.\n\r", ch);
	    break;
	case WILD_FIELD_HOED:
	    send_to_char("You are standing in a hoed field.\n\r", ch);
	    break;
	case WILD_FIELD_SEEDED:
	    send_to_char("You are standing in a seeded field.\n\r", ch);
	    break;
	case WILD_FIELD_WHEAT:
	    send_to_char("You are standing in a wheat field.\n\r", ch);
	    break;
	case WILD_WATER_1:
	case WILD_WATER_2:
	    send_to_char("You are standing knee-deep in water.\n\r", ch);
	    break;
    }

    if (is_inside)
    {
	switch (map_data(ch->x,ch->y))
	{
	    default: break;
	    case WILD_MINE_STRUCTURE_EMPTY:
	    case WILD_MINE_STRUCTURE_STONE:
	    case WILD_MINE_STRUCTURE_IRON:
	    case WILD_MINE_STRUCTURE_GOLD:
	    case WILD_MINE_STRUCTURE_OIL:
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance of a small wooden structure.  To your north\n\r",ch);
			send_to_char("lies a single empty chamber.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in the central chamber.  The room is completely empty.\n\r",ch);
			break;
		}
		break;
	    case WILD_MINE_STONE_1: 
	    case WILD_MINE_STONE_2: 
	    case WILD_MINE_IRON_1: 
	    case WILD_MINE_IRON_2: 
	    case WILD_MINE_GOLD_1: 
	    case WILD_MINE_GOLD_2: 
	    case WILD_MINE_OIL_1: 
	    case WILD_MINE_OIL_2: 
	    case WILD_MINE_EMPTY: 
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance of a mine.  To your north lies the\n\r",ch);
			send_to_char("entrance to the mine shaft itself.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: south down]\n\r",ch);
			send_to_char("You are standing at the edge of the mine shaft, which leads further down.\n\r",ch);
			send_to_char("To your south lies the entrance to the mine.\n\r",ch);
			break;
		    case 2:
			send_to_char("[Exits: north south east west up]\n\r",ch);
			send_to_char("You are standing in the central mining chamber.  Mining work takes place \n\r",ch);
			send_to_char("on all sides.\n\r",ch);
			break;
		    case 3:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in a small chamber.  This is where the actual mining takes\n\r",ch);
			send_to_char("place.\n\r",ch);
			break;
		    case 4:
			send_to_char("[Exits: east]\n\r",ch);
			send_to_char("You are standing in a small chamber.  This is where the actual mining takes\n\r",ch);
			send_to_char("place.\n\r",ch);
			break;
		    case 5:
			send_to_char("[Exits: west]\n\r",ch);
			send_to_char("You are standing in a small chamber.  This is where the actual mining takes\n\r",ch);
			send_to_char("place.\n\r",ch);
			break;
		    case 6:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in a small chamber.  This is where the actual mining takes\n\r",ch);
			send_to_char("place.\n\r",ch);
			break;
		}
		break;
	    case WILD_HUT: 
	    case WILD_HUT_OWNED: 
	    case WILD_HUT_LOCKED: 
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance of a small wooden hut.  To your north\n\r",ch);
			send_to_char("is a single room.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in the centre of a small wooden hut.  To your south lies the\n\r",ch);
			send_to_char("entrance.\n\r",ch);
			break;
		}
		break;
	    case WILD_CABIN:
	    case WILD_CABIN_OWNED: 
	    case WILD_CABIN_LOCKED:
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance of a wooden cabin.  To your north lies the\n\r",ch);
			send_to_char("central room, and beyond that a bedroom.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: north south]\n\r",ch);
			send_to_char("You are standing in the centre of a wooden cabin.  To your north lies a \n\r",ch);
			send_to_char("bedroom, and to your south is the entrance to the cabin.\n\r",ch);
			break;
		    case 2:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in the bedroom of a wooden cabin.  To your south lies the\n\r",ch);
			send_to_char("centre room, and beyond that the cabin entrance.\n\r",ch);
			break;
		}
		break;
	    case WILD_COTTAGE: 
	    case WILD_COTTAGE_OWNED: 
	    case WILD_COTTAGE_LOCKED: 
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance of a small cottage.  To your north lies the\n\r",ch);
			send_to_char("main hallway, which leads eventually to a small kitchen.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your south lies the entrance to the\n\r",ch);
			send_to_char("cottage, while further to your north the hallway opens up into a kitchen.  To\n\r",ch);
			send_to_char("your east and west are small bedrooms.\n\r",ch);
			break;
		    case 2:
			send_to_char("[Exits: east]\n\r",ch);
			send_to_char("You are standing in a small bedroom.  To your east lies the main hallway, \n\r",ch);
			send_to_char("and beyond that is another bedroom.\n\r",ch);
			break;
		    case 3:
			send_to_char("[Exits: west]\n\r",ch);
			send_to_char("You are standing in a small bedroom.  To your west lies the main hallway, \n\r",ch);
			send_to_char("and beyond that is another bedroom.\n\r",ch);
			break;
		    case 4:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your north lies a small kitchen,\n\r",ch);
			send_to_char("while further to your south lies the entrance to the cottage.  To your east\n\r",ch);
			send_to_char("is a small washroom, while to your west is a cosy living room.\n\r",ch);
			break;
		    case 5:
			send_to_char("[Exits: east]\n\r",ch);
			send_to_char("You are standing in a rather cosy living room.  To your east lies the main\n\r",ch);
			send_to_char("hallway, and beyond that is a small washroom.\n\r",ch);
			break;
		    case 6:
			send_to_char("[Exits: west]\n\r",ch);
			send_to_char("You are standing in a small washroom.  To your east lies the main hallway, \n\r",ch);
			send_to_char("and beyond that is a cosy living room.\n\r",ch);
			break;
		    case 7:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in a small kitchen.  To your south, the hallway continues\n\r",ch);
			send_to_char("for some way, eventually leading to the entrance of the cottage.\n\r",ch);
			break;
		}
		break;
	    case WILD_HOUSE: 
	    case WILD_HOUSE_OWNED: 
	    case WILD_HOUSE_LOCKED: 
		switch (ch->room)
		{
		    default:
		    case 0:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in the entrance to a large house.  To your north lies the\n\r",ch);
			send_to_char("main hallway.  Beyond that lies a kitchen.\n\r",ch);
			break;
		    case 1:
			send_to_char("[Exits: north east]\n\r",ch);
			send_to_char("You are standing in a living room.  To your east lies the main hallway, with\n\r",ch);
			send_to_char("a bathroom beyond that.  To your north, through an archway, is the dining\n\r",ch);
			send_to_char("room.\n\r",ch);
			break;
		    case 2:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your south lies the entrance to\n\r",ch);
			send_to_char("the house, while further to your north the hallway opens up into a kitchen.\n\r",ch);
			send_to_char("To your east in a bathroom, while to your west you see a comfortable looking\n\r",ch);
			send_to_char("living room.\n\r",ch);
			break;
		    case 3:
			send_to_char("[Exits: west]\n\r",ch);
			send_to_char("You are standing in a bathroom.  To your west lies the main hallway, and\n\r",ch);
			send_to_char("beyond that is a comfortable looking living room.\n\r",ch);
			break;
		    case 4:
			send_to_char("[Exits: north south east]\n\r",ch);
			send_to_char("You are standing at the southern end of the dining room.  To your north the\n\r",ch);
			send_to_char("dining room continues, while to your south beyond the archway lies the living\n\r",ch);
			send_to_char("room.  To your east you see the main hallway.\n\r",ch);
			break;
		    case 5:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your east lies the bottom of a\n\r",ch);
			send_to_char("large staircase, while to your west you see the southern end of the dining\n\r",ch);
			send_to_char("room.  To your south, further down the main hallway, you see the entrance\n\r",ch);
			send_to_char("to the south, and north of you is the kitchen.\n\r",ch);
			break;
		    case 6:
			send_to_char("[Exits: west up]\n\r",ch);
			send_to_char("You are standing at the bottom of a large staircase, which leads upstairs.\n\r",ch);
			send_to_char("To your west lies the main hallway.\n\r",ch);
			break;
		    case 7:
			send_to_char("[Exits: south east]\n\r",ch);
			send_to_char("You are standing at the northern end of the dining room.  To your south, the\n\r",ch);
			send_to_char("dining room continues.  To your east lies the kitchen.\n\r",ch);
			break;
		    case 8:
			send_to_char("[Exits: south west]\n\r",ch);
			send_to_char("You are standing in the kitchen.  To your south lies the main hallway, while\n\r",ch);
			send_to_char("to your west is the northern end of the dining room.\n\r",ch);
			break;
		    case 9:
			send_to_char("[Exits: south]\n\r",ch);
			send_to_char("You are standing in the upstairs bathroom.  To your south lies the main\n\r",ch);
			send_to_char("hallway.\n\r",ch);
			break;
		    case 10:
			send_to_char("[Exits: east]\n\r",ch);
			send_to_char("You are standing in a bedroom.  To your east lies the main hallway.\n\r",ch);
			break;
		    case 11:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your north lies the bathroom, while\n\r",ch);
			send_to_char("to your west you see a bedroom.  The hallway continues south, and to your\n\r",ch);
			send_to_char("east you see a staircase leading downstairs.\n\r",ch);
			break;
		    case 12:
			send_to_char("[Exits: west down]\n\r",ch);
			send_to_char("You are standing at the top of a large staircase.  To your west lies the \n\r",ch);
			send_to_char("main hallway, and beyond that you see a bedroom.\n\r",ch);
			break;
		    case 13:
			send_to_char("[Exits: east]\n\r",ch);
			send_to_char("You are standing in a bedroom.  To your east lies the main hallway.\n\r",ch);
			break;
		    case 14:
			send_to_char("[Exits: north south east west]\n\r",ch);
			send_to_char("You are standing in the main hallway.  To your north, the hallway continues,\n\r",ch);
			send_to_char("while to your east, west and south lie bedrooms.\n\r",ch);
			break;
		    case 15:
			send_to_char("[Exits: west]\n\r",ch);
			send_to_char("You are standing in a bedroom.  To your west lies the main hallway.\n\r",ch);
			break;
		    case 16:
			send_to_char("[Exits: north]\n\r",ch);
			send_to_char("You are standing in a bedroom.  To your north lies the main hallway.\n\r",ch);
			break;
		}
		break;
	}
    }
    else 
    {
    	for ( loopy = ch->y + 5; loopy >= ch->y - 5; loopy-- )
    	{
	    for ( loopx = ch->x - 5; loopx <= ch->x + 5; loopx++ )
	    {
	    	draw_room(ch, loopx, loopy);
	    }
	    send_to_char("\n\r",ch);
    	}
    }
    return;
}

/******************************************************************************
 Local operations
 ******************************************************************************/

void draw_room( CHAR_DATA *ch, int x, int y )
{
    char buf[MAX_INPUT_LENGTH];

    while (x < 0  ) x += 1000;
    while (y < 0  ) y += 1000;
    while (x > 999) x -= 1000;
    while (y > 999) y -= 1000;

    if (ch->x == x && ch->y == y)
    {
	strcpy(buf,"<oo>");
    }
    else switch ( map_data(x,y) )
    {
	default:
	    strcpy(buf,"   ");
	    break;
	case WILD_AREA_LINK:
	    strcpy(buf,"[??]");
	    break;
	case WILD_ROAD:
	    strcpy(buf,"____");
	    break;
	case WILD_BUILDING_BURNED:
	case WILD_BUILDING_DESTROYED:
	    strcpy(buf,"{~~}");
	    break;
	case WILD_BUILDING_CONSTRUCTION:
	    strcpy(buf,"{^^}");
	    break;
	case WILD_WATER_DEEP_1:
	case WILD_WATER_DEEP_2:
	    strcpy(buf,"~~~~");
	    break;
	case WILD_FOREST_1:
	    strcpy(buf,".^..");
	    break;
	case WILD_FOREST_2:
	    strcpy(buf,".^.^");
	    break;
	case WILD_FOREST_3:
	    strcpy(buf,"^^.^");
	    break;
	case WILD_FOREST_4:
	    strcpy(buf,"^^^^");
	    break;
	case WILD_HUT:
	case WILD_HUT_OWNED:
	case WILD_HUT_LOCKED:
	    strcpy(buf," () ");
	    break;
	case WILD_CABIN:
	case WILD_CABIN_OWNED:
	case WILD_CABIN_LOCKED:
	    strcpy(buf," [] ");
	    break;
	case WILD_COTTAGE:
	case WILD_COTTAGE_OWNED:
	case WILD_COTTAGE_LOCKED:
	    strcpy(buf,"(^^)");
	    break;
	case WILD_HOUSE:
	case WILD_HOUSE_OWNED:
	case WILD_HOUSE_LOCKED:
	    strcpy(buf,"[^^]");
	    break;
	case WILD_MINE_STRUCTURE_EMPTY:
	case WILD_MINE_STRUCTURE_STONE:
	case WILD_MINE_STRUCTURE_IRON:
	case WILD_MINE_STRUCTURE_GOLD:
	case WILD_MINE_STRUCTURE_OIL:
	    strcpy(buf,"[/\\]");
	    break;
	case WILD_MINE_STONE_1:
	case WILD_MINE_STONE_2:
	case WILD_MINE_IRON_1:
	case WILD_MINE_IRON_2:
	case WILD_MINE_GOLD_1:
	case WILD_MINE_GOLD_2:
	case WILD_MINE_OIL_1:
	case WILD_MINE_OIL_2:
	case WILD_MINE_EMPTY:
	    strcpy(buf,"[\\/]");
	    break;
	case WILD_MOUNTAINS_NONE:
	case WILD_MOUNTAINS_STONE:
	case WILD_MOUNTAINS_IRON:
	case WILD_MOUNTAINS_GOLD:
	case WILD_MOUNTAINS_OIL:
	    strcpy(buf,"/\\/\\");
	    break;
	case WILD_FIELD_HOED:
	    strcpy(buf,"....");
	    break;
	case WILD_FIELD_SEEDED:
	    strcpy(buf,"....");
	    break;
	case WILD_FIELD_WHEAT:
	    strcpy(buf,"::::");
	    break;
	case WILD_PLAINS:
	    strcpy(buf,"....");
	    break;
	case WILD_WATER_1:
	case WILD_WATER_2:
	    strcpy(buf,"~~~~");
	    break;
    }

    send_to_char(buf,ch);

    return;
}
