1stMUD4.0/bin/
1stMUD4.0/doc/MPDocs/
1stMUD4.0/player/
1stMUD4.0/win32/
1stMUD4.0/win32/rom/
/**************************************************************************
*  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
*  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
*                                                                         *
*  Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael         *
*  Chastain, Michael Quan, and Mitchell Tse.                              *
*                                                                         *
*  In order to use any part of this Merc Diku Mud, you must comply with   *
*  both the original Diku license in 'license.doc' as well the Merc       *
*  license in 'license.txt'.  In particular, you may not remove either of *
*  these copyright notices.                                               *
*                                                                         *
*  Much time and thought has gone into this software and you are          *
*  benefiting.  We hope that you share your changes too.  What goes       *
*  around, comes around.                                                  *
***************************************************************************
*       ROM 2.4 is copyright 1993-1998 Russ Taylor                        *
*       ROM has been brought to you by the ROM consortium                 *
*           Russ Taylor (rtaylor@hypercube.org)                           *
*           Gabrielle Taylor (gtaylor@hypercube.org)                      *
*           Brian Moore (zump@rom.org)                                    *
*       By using this code, you have agreed to follow the terms of the    *
*       ROM license, in the file Rom24/doc/rom.license                    *
***************************************************************************
*       1stMUD ROM Derivative (c) 2001-2003 by Ryan Jennings              *
*            http://1stmud.dlmud.com/  <r-jenn@shaw.ca>                   *
***************************************************************************/
#include "merc.h"
#include "globals.h"
#include "lookup.h"
#include "olc.h"
#include "interp.h"

PROTOTYPE(void get_weather_echo, (WEATHER_DATA *));

/* Weather constants */
char *const temp_settings[MAX_CLIMATE] = {
	"cold",
	"cool",
	"normal",
	"warm",
	"hot",
};

char *const precip_settings[MAX_CLIMATE] = {
	"arid",
	"dry",
	"normal",
	"damp",
	"wet",
};

char *const wind_settings[MAX_CLIMATE] = {
	"still",
	"calm",
	"normal",
	"breezy",
	"windy",
};

char *const preciptemp_msg[6][6] = {
	/* precip = 0 */
	{
	 "Frigid temperatures settle over the land",
	 "It is bitterly cold",
	 "The weather is crisp and dry",
	 "A comfortable warmth sets in",
	 "A dry heat warms the land",
	 "Seething heat bakes the land"},
	/* precip = 1 */
	{
	 "A few flurries drift from the high clouds",
	 "Frozen drops of rain fall from the sky",
	 "An occasional raindrop falls to the ground",
	 "Mild drops of rain seep from the clouds",
	 "It is very warm, and the sky is overcast",
	 "High humidity intensifies the seering heat"},
	/* precip = 2 */
	{
	 "A brief snow squall dusts the earth",
	 "A light flurry dusts the ground",
	 "Light snow drifts down from the heavens",
	 "A light drizzle mars an otherwise perfect day",
	 "A few drops of rain fall to the warm ground",
	 "A light rain falls through the sweltering sky"},
	/* precip = 3 */
	{
	 "Snowfall covers the frigid earth",
	 "Light snow falls to the ground",
	 "A brief shower moistens the crisp air",
	 "A pleasant rain falls from the heavens",
	 "The warm air is heavy with rain",
	 "A refreshing shower eases the oppresive heat"},
	/* precip = 4 */
	{
	 "Sleet falls in sheets through the frosty air",
	 "Snow falls quickly, piling upon the cold earth",
	 "Rain pelts the ground on this crisp day",
	 "Rain drums the ground rythmically",
	 "A warm rain drums the ground loudly",
	 "Tropical rain showers pelt the seering ground"},
	/* precip = 5 */
	{
	 "A downpour of frozen rain covers the land in ice",
	 "A blizzard blankets everything in pristine white",
	 "Torrents of rain fall from a cool sky",
	 "A drenching downpour obscures the temperate day",
	 "Warm rain pours from the sky",
	 "A torrent of rain soaks the heated earth"}
};

char *const windtemp_msg[6][6] = {
	/* wind = 0 */
	{
	 "The frigid air is completely still",
	 "A cold temperature hangs over the area",
	 "The crisp air is eerily calm",
	 "The warm air is still",
	 "No wind makes the day uncomfortably warm",
	 "The stagnant heat is sweltering"},
	/* wind = 1 */
	{
	 "A light breeze makes the frigid air seem colder",
	 "A stirring of the air intensifies the cold",
	 "A touch of wind makes the day cool",
	 "It is a temperate day, with a slight breeze",
	 "It is very warm, the air stirs slightly",
	 "A faint breeze stirs the feverish air"},
	/* wind = 2 */
	{
	 "A breeze gives the frigid air bite",
	 "A breeze swirls the cold air",
	 "A lively breeze cools the area",
	 "It is a temperate day, with a pleasant breeze",
	 "Very warm breezes buffet the area",
	 "A breeze ciculates the sweltering air"},
	/* wind = 3 */
	{
	 "Stiff gusts add cold to the frigid air",
	 "The cold air is agitated by gusts of wind",
	 "Wind blows in from the north, cooling the area",
	 "Gusty winds mix the temperate air",
	 "Brief gusts of wind punctuate the warm day",
	 "Wind attempts to cut the sweltering heat"},
	/* wind = 4 */
	{
	 "The frigid air whirls in gusts of wind",
	 "A strong, cold wind blows in from the north",
	 "Strong wind makes the cool air nip",
	 "It is a pleasant day, with gusty winds",
	 "Warm, gusty winds move through the area",
	 "Blustering winds punctuate the seering heat"},
	/* wind = 5 */
	{
	 "A frigid gale sets bones shivering",
	 "Howling gusts of wind cut the cold air",
	 "An angry wind whips the air into a frenzy",
	 "Fierce winds tear through the tepid air",
	 "Gale-like winds whip up the warm air",
	 "Monsoon winds tear the feverish air"}
};

char *const precip_msg[3] = {
	"there is not a cloud in the sky",
	"pristine white clouds are in the sky",
	"thick, grey clouds mask the sun"
};

char *const wind_msg[6] = {
	"there is not a breath of wind in the air",
	"a slight breeze stirs the air",
	"a breeze wafts through the area",
	"brief gusts of wind punctuate the air",
	"angry gusts of wind blow",
	"howling winds whip the air into a frenzy"
};

/*
 * Initialize the weather for all the areas
 * Last Modified: July 21, 1997
 * Fireblade
 */
void init_area_weather()
{
	AREA_DATA *pArea;

	for (pArea = area_first; pArea; pArea = pArea->next)
	{
		int cf;

		/* init temp and temp vector */
		cf = pArea->weather.climate_temp - 2;
		pArea->weather.temp =
			number_range(-mud_info.weath_unit, mud_info.weath_unit) +
			cf * number_range(0, mud_info.weath_unit);
		pArea->weather.temp_vector =
			cf + number_range(-mud_info.rand_factor, mud_info.rand_factor);

		/* init precip and precip vector */
		cf = pArea->weather.climate_precip - 2;
		pArea->weather.precip =
			number_range(-mud_info.weath_unit, mud_info.weath_unit) +
			cf * number_range(0, mud_info.weath_unit);
		pArea->weather.precip_vector =
			cf + number_range(-mud_info.rand_factor, mud_info.rand_factor);

		/* init wind and wind vector */
		cf = pArea->weather.climate_wind - 2;
		pArea->weather.wind =
			number_range(-mud_info.weath_unit, mud_info.weath_unit) +
			cf * number_range(0, mud_info.weath_unit);
		pArea->weather.wind_vector =
			cf + number_range(-mud_info.rand_factor, mud_info.rand_factor);
	}

	return;
}

/*
 * Function to update weather vectors according to climate
 * settings, and random effects.
 * Last modified: July 18, 1997
 * - Fireblade
 */
void adjust_vectors(WEATHER_DATA * weather)
{
	double dT, dP, dW;

	if (!weather)
	{
		bug("NULL weather data.");
		return;
	}

	dT = 0;
	dP = 0;
	dW = 0;

	/* Add in random effects */
	dT += number_range(-mud_info.rand_factor, mud_info.rand_factor);
	dP += number_range(-mud_info.rand_factor, mud_info.rand_factor);
	dW += number_range(-mud_info.rand_factor, mud_info.rand_factor);

	/* Add in climate effects */
	dT += mud_info.climate_factor *
		(((weather->climate_temp - 2) * mud_info.weath_unit) -
		 (weather->temp)) / mud_info.weath_unit;
	dP += mud_info.climate_factor *
		(((weather->climate_precip - 2) * mud_info.weath_unit) -
		 (weather->precip)) / mud_info.weath_unit;
	dW += mud_info.climate_factor *
		(((weather->climate_wind - 2) * mud_info.weath_unit) -
		 (weather->wind)) / mud_info.weath_unit;

	/* now apply the effects to the vectors */
	weather->temp_vector += (int) dT;
	weather->precip_vector += (int) dP;
	weather->wind_vector += (int) dW;

	/* Make sure they are within the right range */
	weather->temp_vector = URANGE(-mud_info.max_vector,
								  weather->temp_vector, mud_info.max_vector);
	weather->precip_vector = URANGE(-mud_info.max_vector,
									weather->precip_vector,
									mud_info.max_vector);
	weather->wind_vector =
		URANGE(-mud_info.max_vector, weather->wind_vector, mud_info.max_vector);

	return;
}

/*
 * function updates weather for each area
 * Last Modified: July 31, 1997
 * Fireblade
 */
void weather_update()
{
	AREA_DATA *pArea;
	DESCRIPTOR_DATA *d;
	int limit;

	limit = 3 * mud_info.weath_unit;

	for (pArea = area_first; pArea; pArea = pArea->next)
	{
		/* Apply vectors to fields */
		pArea->weather.temp += pArea->weather.temp_vector;
		pArea->weather.precip += pArea->weather.precip_vector;
		pArea->weather.wind += pArea->weather.wind_vector;

		/* Make sure they are within the proper range */
		pArea->weather.temp = URANGE(-limit, pArea->weather.temp, limit);
		pArea->weather.precip = URANGE(-limit, pArea->weather.precip, limit);
		pArea->weather.wind = URANGE(-limit, pArea->weather.wind, limit);

		/* get an appropriate echo for the area */
		get_weather_echo(&pArea->weather);
	}

	for (pArea = area_first; pArea; pArea = pArea->next)
	{
		adjust_vectors(&pArea->weather);
	}

	/* display the echo strings to the appropriate players */
	for (d = descriptor_first; d; d = d->next)
	{
		WEATHER_DATA *weath;

		if (d->connected == CON_PLAYING &&
			IS_OUTSIDE(d->character) && IS_AWAKE(d->character))
		{
			weath = &d->character->in_room->area->weather;
			if (IS_NULLSTR(weath->echo))
				continue;
			d_printlnf(d, "%s%s{x", weath->echo_color, weath->echo);
		}
	}

	return;
}

/*
 * get weather echo messages according to area weather...
 * stores echo message in weath_data.... must be called before
 * the vectors are adjusted
 * Last Modified: August 10, 1997
 * Fireblade
 */
void get_weather_echo(WEATHER_DATA * weath)
{
	int n;
	int temp, precip, wind;
	int dT, dP, dW;
	int tindex, pindex, windex;

	/* set echo to be nothing */
	replace_string(weath->echo, "");
	replace_string(weath->echo_color, "{x");

	/* get the random number */
	n = number_bits(2);

	/* variables for convenience */
	temp = weath->temp;
	precip = weath->precip;
	wind = weath->wind;

	dT = weath->temp_vector;
	dP = weath->precip_vector;
	dW = weath->wind_vector;

	tindex = (temp + 3 * mud_info.weath_unit - 1) / mud_info.weath_unit;
	pindex = (precip + 3 * mud_info.weath_unit - 1) / mud_info.weath_unit;
	windex = (wind + 3 * mud_info.weath_unit - 1) / mud_info.weath_unit;

	/* get the echo string... mainly based on precip */
	switch (pindex)
	{
	case 0:
		if (precip - dP > -2 * mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The clouds disappear.",
				"The clouds disappear.",
				"The sky begins to break through " "the clouds.",
				"The clouds are slowly " "evaporating."
			};

			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{W");
		}
		break;

	case 1:
		if (precip - dP <= -2 * mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The sky is getting cloudy.",
				"The sky is getting cloudy.",
				"Light clouds cast a haze over " "the sky.",
				"Billows of clouds spread through " "the sky."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{D");
		}
		break;

	case 2:
		if (precip - dP > 0)
		{
			if (tindex > 1)
			{
				char *echo_strings[4] = {
					"The rain stops.",
					"The rain stops.",
					"The rainstorm tapers " "off.",
					"The rain's intensity " "breaks."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{C");
			}
			else
			{
				char *echo_strings[4] = {
					"The snow stops.",
					"The snow stops.",
					"The snow showers taper " "off.",
					"The snow flakes disappear " "from the sky."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{W");
			}
		}
		break;

	case 3:
		if (precip - dP <= 0)
		{
			if (tindex > 1)
			{
				char *echo_strings[4] = {
					"It starts to rain.",
					"It starts to rain.",
					"A droplet of rain falls " "upon you.",
					"The rain begins to " "patter."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{C");
			}
			else
			{
				char *echo_strings[4] = {
					"It starts to snow.",
					"It starts to snow.",
					"Crystal flakes begin to " "fall from the " "sky.",
					"Snow flakes drift down " "from the clouds."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{W");
			}
		}
		else if (tindex < 2 && temp - dT > -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The temperature drops and the rain " "becomes a light snow.",
				"The temperature drops and the rain " "becomes a light snow.",
				"Flurries form as the rain freezes.",
				"Large snow flakes begin to fall " "with the rain."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{W");
		}
		else if (tindex > 1 && temp - dT <= -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The snow flurries are gradually "
					"replaced by pockets of rain.",
				"The snow flurries are gradually "
					"replaced by pockets of rain.",
				"The falling snow turns to a cold drizzle.",
				"The snow turns to rain as the air warms."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{C");
		}
		break;

	case 4:
		if (precip - dP > 2 * mud_info.weath_unit)
		{
			if (tindex > 1)
			{
				char *echo_strings[4] = {
					"The lightning has stopped.",
					"The lightning has stopped.",
					"The sky settles, and the " "thunder surrenders.",
					"The lightning bursts fade as " "the storm weakens."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{D");
			}
		}
		else if (tindex < 2 && temp - dT > -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The cold rain turns to snow.",
				"The cold rain turns to snow.",
				"Snow flakes begin to fall " "amidst the rain.",
				"The driving rain begins to freeze."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{W");
		}
		else if (tindex > 1 && temp - dT <= -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The snow becomes a freezing rain.",
				"The snow becomes a freezing rain.",
				"A cold rain beats down on you " "as the snow begins to melt.",
				"The snow is slowly replaced by a heavy " "rain."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{C");
		}
		break;

	case 5:
		if (precip - dP <= 2 * mud_info.weath_unit)
		{
			if (tindex > 1)
			{
				char *echo_strings[4] = {
					"Lightning flashes in the " "sky.",
					"Lightning flashes in the " "sky.",
					"A flash of lightning splits " "the sky.",
					"The sky flashes, and the "
						"ground trembles with " "thunder."
				};
				replace_string(weath->echo, echo_strings[n]);
				replace_string(weath->echo_color, "{Y");
			}
		}
		else if (tindex > 1 && temp - dT <= -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The sky rumbles with thunder as " "the snow changes to rain.",
				"The sky rumbles with thunder as " "the snow changes to rain.",
				"The falling turns to freezing rain "
					"amidst flashes of " "lightning.",
				"The falling snow begins to melt as "
					"thunder crashes overhead."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{W");
		}
		else if (tindex < 2 && temp - dT > -mud_info.weath_unit)
		{
			char *echo_strings[4] = {
				"The lightning stops as the rainstorm "
					"becomes a blinding " "blizzard.",
				"The lightning stops as the rainstorm "
					"becomes a blinding " "blizzard.",
				"The thunder dies off as the "
					"pounding rain turns to " "heavy snow.",
				"The cold rain turns to snow and " "the lightning stops."
			};
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{C");
		}
		break;

	default:
		bug("echo_weather: invalid precip index");
		weath->precip = 0;
		break;
	}

	return;
}

/*
 * get echo messages according to time changes...
 * some echoes depend upon the weather so an echo must be
 * found for each area
 * Last Modified: August 10, 1997
 * Fireblade
 */
void get_time_echo(WEATHER_DATA * weath)
{
	int n;
	int pindex;

	n = number_bits(2);
	pindex =
		(weath->precip + 3 * mud_info.weath_unit - 1) / mud_info.weath_unit;
	replace_string(weath->echo, "");
	replace_string(weath->echo_color, "{w");

	switch (time_info.hour)
	{
	case 5:
		{
			char *echo_strings[4] = {
				"The day has begun.",
				"The day has begun.",
				"The sky slowly begins to glow.",
				"The sun slowly embarks upon a new day."
			};
			time_info.sunlight = SUN_RISE;
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{Y");
			break;
		}
	case 6:
		{
			char *echo_strings[4] = {
				"The sun rises in the east.",
				"The sun rises in the east.",
				"The hazy sun rises over the horizon.",
				"Day breaks as the sun lifts into the sky."
			};
			time_info.sunlight = SUN_LIGHT;
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{y");
			break;
		}
	case 12:
		{
			if (pindex > 0)
			{
				replace_string(weath->echo, "It's noon.");
			}
			else
			{
				char *echo_strings[2] = {
					"The intensity of the sun " "heralds the noon hour.",
					"The sun's bright rays beat down " "upon your shoulders."
				};
				replace_string(weath->echo, echo_strings[n % 2]);
			}
			time_info.sunlight = SUN_LIGHT;
			replace_string(weath->echo_color, "{W");
			break;
		}
	case 19:
		{
			char *echo_strings[4] = {
				"The sun slowly disappears in the west.",
				"The reddish sun sets past the horizon.",
				"The sky turns a reddish orange as the sun "
					"ends its journey.",
				"The sun's radiance dims as it sinks in the " "sky."
			};
			time_info.sunlight = SUN_SET;
			replace_string(weath->echo, echo_strings[n]);
			replace_string(weath->echo_color, "{R");
			break;
		}
	case 20:
		{
			if (pindex > 0)
			{
				char *echo_strings[2] = {
					"The night begins.",
					"Twilight descends around you."
				};
				replace_string(weath->echo, echo_strings[n % 2]);
			}
			else
			{
				char *echo_strings[2] = {
					"The moon's gentle glow diffuses " "through the night sky.",
					"The night sky gleams with " "glittering starlight."
				};
				replace_string(weath->echo, echo_strings[n % 2]);
			}
			time_info.sunlight = SUN_DARK;
			replace_string(weath->echo_color, "{b");
			break;
		}
	}

	return;
}

OLCED(aedit_climate)
{
	char arg[MAX_INPUT_LENGTH];
	AREA_DATA *area;

	EDIT_AREA(ch, area);

	argument = one_argument(argument, arg);

	/* Display current climate settings */
	if (IS_NULLSTR(arg))
	{
		chprintlnf(ch, "%s:", area->name);
		chprintlnf(ch, "\tTemperature:\t%s",
				   temp_settings[area->weather.climate_temp]);
		chprintlnf(ch, "\tPrecipitation:\t%s",
				   precip_settings[area->weather.climate_precip]);
		chprintlnf(ch, "\tWind:\t\t%s",
				   wind_settings[area->weather.climate_wind]);

		chprintlnf(ch, "Weather variables range from "
				   "%d to %d.", -3 * mud_info.weath_unit,
				   3 * mud_info.weath_unit);
		chprintlnf(ch, "Weather vectors range from "
				   "%d to %d.", -1 * mud_info.max_vector, mud_info.max_vector);
		chprintlnf(ch, "The maximum a vector can "
				   "change in one update is %d.",
				   mud_info.rand_factor + 2 * mud_info.climate_factor +
				   3 * mud_info.weath_unit);

		chprintln(ch, "Syntax: climate temp <number>");
		chprintln(ch, "      : climate precip <number>");
		chprintln(ch, "      : climate wind <number>");

		return FALSE;
	}
	/* set climate temperature */
	else if (!str_cmp(arg, "temp"))
	{
		int i;
		argument = one_argument(argument, arg);

		for (i = 0; i < MAX_CLIMATE; i++)
		{
			if (str_cmp(arg, temp_settings[i]))
				continue;

			area->weather.climate_temp = i;
			chprintlnf(ch, "The climate temperature "
					   "for %s is now %s.", area->name, temp_settings[i]);
			return TRUE;
		}

		if (i == MAX_CLIMATE)
		{
			chprintlnf(ch, "Possible temperature " "settings:");
			for (i = 0; i < MAX_CLIMATE; i++)
			{
				chprintlnf(ch, "\t%s", temp_settings[i]);
			}
		}

		return FALSE;
	}
	/* set climate precipitation */
	else if (!str_cmp(arg, "precip"))
	{
		int i;
		argument = one_argument(argument, arg);

		for (i = 0; i < MAX_CLIMATE; i++)
		{
			if (str_cmp(arg, precip_settings[i]))
				continue;

			area->weather.climate_precip = i;
			chprintlnf(ch, "The climate precipitation "
					   "for %s is now %s.", area->name, precip_settings[i]);
			return TRUE;
		}

		if (i == MAX_CLIMATE)
		{
			chprintlnf(ch, "Possible precipitation " "settings:");
			for (i = 0; i < MAX_CLIMATE; i++)
			{
				chprintlnf(ch, "\t%s", precip_settings[i]);
			}
		}

		return FALSE;
	}
	/* set climate wind */
	else if (!str_cmp(arg, "wind"))
	{
		int i;
		argument = one_argument(argument, arg);

		for (i = 0; i < MAX_CLIMATE; i++)
		{
			if (str_cmp(arg, wind_settings[i]))
				continue;

			area->weather.climate_wind = i;
			chprintlnf(ch, "The climate wind for %s "
					   "is now %s.", area->name, wind_settings[i]);
			return TRUE;
		}

		if (i == MAX_CLIMATE)
		{
			chprintlnf(ch, "Possible wind settings:");
			for (i = 0; i < MAX_CLIMATE; i++)
			{
				chprintlnf(ch, "\t%s", wind_settings[i]);
			}
		}

		return FALSE;
	}
	else
	{
		chprintln(ch, "Climate may only be followed by one "
				  "of the following fields:");
		chprintln(ch, "\ttemp");
		chprintln(ch, "\tprecip");
		chprintln(ch, "\twind");

		return FALSE;
	}
}

void write_time(void)
{
	WRITE_DATA *time_file;

	if ((time_file = open_write(TIME_FILE)) == NULL)
	{
		log_string("creation of new time_file failed");
	}
	else
	{
		fprintf(time_file->stream, "%d %d %d %d", time_info.hour,
				time_info.day, time_info.month, time_info.year);
		close_write(time_file);
	}
	return;
}

/*
 * update the time
 */
void time_update()
{
	AREA_DATA *pArea;
	DESCRIPTOR_DATA *d;
	WEATHER_DATA *weath;

	switch (++time_info.hour)
	{
	case 5:
	case 6:
	case 12:
	case 19:
	case 20:
		for (pArea = area_first; pArea; pArea = pArea->next)
		{
			get_time_echo(&pArea->weather);
		}

		for (d = descriptor_first; d; d = d->next)
		{
			if (d->connected == CON_PLAYING &&
				IS_OUTSIDE(d->character) && IS_AWAKE(d->character))
			{
				weath = &d->character->in_room->area->weather;
				if (IS_NULLSTR(weath->echo))
					continue;
				d_printlnf(d, "%s%s{x", weath->echo_color, weath->echo);
			}
		}
		break;
	case 24:
		time_info.hour = 0;
		time_info.day++;
		write_time();
		break;
	}

	if (time_info.day >= NUM_DAYS)
	{
		time_info.day = 0;
		time_info.month++;
	}

	if (time_info.month >= NUM_MONTHS)
	{
		time_info.month = 0;
		time_info.year++;
	}

	return;
}