zarius_shop.c
mcloud2/src/zarius_shop.c · 2.5 KB
From the archive roguelegion.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments 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. *
* *
* Dystopia Mud improvements copyright (C) 2000, 2001 by Brian Graversen *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "merc.h"
#include "interp.h"
/*
* Shopping commands.
*/
CHAR_DATA *find_keeper( CHAR_DATA *ch )
{
CHAR_DATA *keeper;
SHOP_DATA *pShop;
char buf [MAX_STRING_LENGTH];
pShop = NULL;
for ( keeper = ch->in_room->people; keeper; keeper = keeper->next_in_room )
{
if ( IS_NPC(keeper) && (pShop = keeper->pIndexData->pShop) != NULL )
break;
}
if ( pShop == NULL )
{
send_to_char( "You can't do that here.\n\r", ch );
return NULL;
}
/*
* Shop hours.
*/
if ( time_info.hour < pShop->open_hour )
{
strcpy( buf, "Sorry, come back later." );
do_say( keeper, buf );
return NULL;
}
if ( time_info.hour > pShop->close_hour )
{
strcpy( buf, "Sorry, come back tomorrow." );
do_say( keeper, buf );
return NULL;
}
/*
* Invisible or hidden people.
*/
if ( !can_see( keeper, ch ) )
{
strcpy( buf, "I don't trade with folks I can't see." );
do_say( keeper, buf );
return NULL;
}
return keeper;
}