room.c
./mudd/src/room.c · 2.8 KB
From the archive emlen.tar.gz
Download the archive « Back to the archive contents
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"
#ifndef WINDOWS
#include <sys/time.h>
#endif
void
z_areachange (CHAR_DATA * ch, char *argy)
{
char arg1[SML_LENGTH];
char arg2[SML_LENGTH];
int start_vnum = -1;
int end_vnum = -1;
int new_area_num = -1;
int i;
ROOM_DATA *room;
AREA_DATA *a;
AREA_DATA *destination_area = NULL;
DEFINE_COMMAND ("z_areachange", z_areachange, POSITION_DEAD, MAX_LEVEL, LOG_ALWAYS, "This command moves vnums into a new area, without changing the vnums.")
argy = one_argy (argy, arg1);
argy = one_argy (argy, arg2);
start_vnum = atoi (arg1);
end_vnum = atoi (arg2);
new_area_num = atoi (argy);
if (start_vnum <= 0 || end_vnum <= 0 || start_vnum > end_vnum ||
new_area_num < 0)
{
send_to_char ("Invalid. Syntax: z_areachange <min vnum> <max vnum> <new area>.\n\r", ch);
return;
}
for (a = area_first; a != NULL; a = a->next)
{
if (a->vnum == new_area_num)
{
destination_area = a;
break;
}
}
if (!destination_area)
{
send_to_char ("Destination area vnum not found.\n\r", ch);
return;
}
/* Purge the world of mobs */
for (i = 0; i < HASH_MAX; i++)
{
for (room = room_hash[i]; room != NULL; room = room->next)
{
raw_purge (room);
}
}
for (i = start_vnum; i < end_vnum; i++)
{
if ((room = get_room_index (i)) == NULL)
continue;
room->area = destination_area;
}
reset_world ();
send_to_char ("Operation complete. Please asave complete at this time.\n\r", ch);
return;
}
void
do_idea (CHAR_DATA * ch, char *argy)
{
FILE *fpp;
DEFINE_COMMAND ("idea", do_idea, POSITION_DEAD, 0, LOG_NORMAL, "Allows you to enter an idea for the admin to read later on.")
if (!ch)
return;
if ((fpp = fopen ("ideas.txt", "a+")) == NULL)
return;
fprintf (fpp, "%s at %d: %s\n", NAME (ch), (ch->in_room ? ch->in_room->vnum : 0), argy);
fclose (fpp);
send_to_char ("Noted! Thanks!\n\r", ch);
return;
}
ROOM_DATA *
new_room (void)
{
ROOM_DATA *oneroom;
short door;
oneroom = mem_alloc (sizeof (*oneroom));
oneroom->vnum = 0;
oneroom->data_type = K_ROOM;
oneroom->room_flags = 0;
oneroom->room_flags2 = 0;
oneroom->light = 0;
oneroom->sector_type = 1;
oneroom->name = &str_empty[0];
oneroom->description = &str_empty[0];
for (door = 0; door <= 5; door++)
oneroom->exit[door] = NULL;
oneroom->tracks = NULL;
oneroom->blood = 0;
oneroom->command_objs = 0;
oneroom->contents = NULL;
oneroom->people = NULL;
oneroom->resets = NULL;
oneroom->pcs = 0;
for (door = 0; door < MAX_COINS; door++)
oneroom->coins[door] = 0;
oneroom->extra_descr = NULL;
oneroom->trap = NULL;
return oneroom;
}