mirror of
https://github.com/tbamud/tbamud.git
synced 2026-03-30 08:57:20 +02:00
Remove rent system and assignments
This commit is contained in:
parent
21c66a16ae
commit
91441806a4
2 changed files with 6 additions and 432 deletions
428
src/objsave.c
428
src/objsave.c
|
|
@ -32,20 +32,8 @@
|
|||
|
||||
/* local functions */
|
||||
static int Crash_save(struct obj_data *obj, FILE *fp, int location);
|
||||
static void Crash_extract_norent_eq(struct char_data *ch);
|
||||
static void auto_equip(struct char_data *ch, struct obj_data *obj, int location);
|
||||
static int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, int display, int factor);
|
||||
static int Crash_report_unrentables(struct char_data *ch, struct char_data *recep, struct obj_data *obj);
|
||||
static void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct obj_data *obj, long *cost, long *nitems, int display, int factor);
|
||||
static int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, char *arg, int mode);
|
||||
static void Crash_rent_deadline(struct char_data *ch, struct char_data *recep, long cost);
|
||||
static void Crash_restore_weight(struct obj_data *obj);
|
||||
static void Crash_extract_objs(struct obj_data *obj);
|
||||
static int Crash_is_unrentable(struct obj_data *obj);
|
||||
static void Crash_extract_norents(struct obj_data *obj);
|
||||
static void Crash_extract_expensive(struct obj_data *obj);
|
||||
static void Crash_calculate_rent(struct obj_data *obj, int *cost);
|
||||
static void Crash_cryosave(struct char_data *ch, int cost);
|
||||
static int Crash_load_objs(struct char_data *ch);
|
||||
static int handle_obj(struct obj_data *obj, struct char_data *ch, int locate, struct obj_data **cont_rows);
|
||||
static int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch);
|
||||
|
|
@ -482,78 +470,6 @@ static void Crash_restore_weight(struct obj_data *obj)
|
|||
}
|
||||
}
|
||||
|
||||
/* Get !RENT items from equipment to inventory and extract !RENT out of worn
|
||||
* containers. */
|
||||
static void Crash_extract_norent_eq(struct char_data *ch)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < NUM_WEARS; j++) {
|
||||
if (GET_EQ(ch, j) == NULL)
|
||||
continue;
|
||||
|
||||
if (Crash_is_unrentable(GET_EQ(ch, j)))
|
||||
obj_to_char(unequip_char(ch, j), ch);
|
||||
else
|
||||
Crash_extract_norents(GET_EQ(ch, j));
|
||||
}
|
||||
}
|
||||
|
||||
static void Crash_extract_objs(struct obj_data *obj)
|
||||
{
|
||||
if (obj) {
|
||||
Crash_extract_objs(obj->contains);
|
||||
Crash_extract_objs(obj->next_content);
|
||||
extract_obj(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static int Crash_is_unrentable(struct obj_data *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return FALSE;
|
||||
|
||||
if (OBJ_FLAGGED(obj, ITEM_NORENT) ||
|
||||
GET_OBJ_RENT(obj) < 0 ||
|
||||
GET_OBJ_RNUM(obj) == NOTHING ||
|
||||
GET_OBJ_TYPE(obj) == ITEM_KEY) {
|
||||
log("Crash_is_unrentable: removing object %s", obj->short_description);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void Crash_extract_norents(struct obj_data *obj)
|
||||
{
|
||||
if (obj) {
|
||||
Crash_extract_norents(obj->contains);
|
||||
Crash_extract_norents(obj->next_content);
|
||||
if (Crash_is_unrentable(obj))
|
||||
extract_obj(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void Crash_extract_expensive(struct obj_data *obj)
|
||||
{
|
||||
struct obj_data *tobj, *max;
|
||||
|
||||
max = obj;
|
||||
for (tobj = obj; tobj; tobj = tobj->next_content)
|
||||
if (GET_OBJ_RENT(tobj) > GET_OBJ_RENT(max))
|
||||
max = tobj;
|
||||
extract_obj(max);
|
||||
}
|
||||
|
||||
static void Crash_calculate_rent(struct obj_data *obj, int *cost)
|
||||
{
|
||||
if (obj) {
|
||||
*cost += MAX(0, GET_OBJ_RENT(obj));
|
||||
Crash_calculate_rent(obj->contains, cost);
|
||||
Crash_calculate_rent(obj->next_content, cost);
|
||||
}
|
||||
}
|
||||
|
||||
void Crash_crashsave(struct char_data *ch)
|
||||
{
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
|
|
@ -592,119 +508,22 @@ void Crash_crashsave(struct char_data *ch)
|
|||
REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_CRASH);
|
||||
}
|
||||
|
||||
/* Shortened because we don't handle rent in this game */
|
||||
void Crash_idlesave(struct char_data *ch)
|
||||
{
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
int j;
|
||||
int cost, cost_eq;
|
||||
FILE *fp;
|
||||
|
||||
if (IS_NPC(ch))
|
||||
if (!ch || IS_NPC(ch))
|
||||
return;
|
||||
|
||||
if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch)))
|
||||
return;
|
||||
|
||||
if (!(fp = fopen(buf, "w")))
|
||||
return;
|
||||
|
||||
Crash_extract_norent_eq(ch);
|
||||
Crash_extract_norents(ch->carrying);
|
||||
|
||||
cost = 0;
|
||||
Crash_calculate_rent(ch->carrying, &cost);
|
||||
|
||||
cost_eq = 0;
|
||||
for (j = 0; j < NUM_WEARS; j++)
|
||||
Crash_calculate_rent(GET_EQ(ch, j), &cost_eq);
|
||||
|
||||
cost += cost_eq;
|
||||
cost *= 2; /* forcerent cost is 2x normal rent */
|
||||
|
||||
if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
|
||||
for (j = 0; j < NUM_WEARS; j++) /* Unequip players with low gold. */
|
||||
if (GET_EQ(ch, j))
|
||||
obj_to_char(unequip_char(ch, j), ch);
|
||||
|
||||
while ((cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) && ch->carrying) {
|
||||
Crash_extract_expensive(ch->carrying);
|
||||
cost = 0;
|
||||
Crash_calculate_rent(ch->carrying, &cost);
|
||||
cost *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch->carrying == NULL) {
|
||||
for (j = 0; j < NUM_WEARS && GET_EQ(ch, j) == NULL; j++) /* Nothing */ ;
|
||||
if (j == NUM_WEARS) { /* No equipment or inventory. */
|
||||
fclose(fp);
|
||||
Crash_delete_file(GET_NAME(ch));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!objsave_write_rentcode(fp, RENT_TIMEDOUT, cost, ch))
|
||||
return;
|
||||
|
||||
for (j = 0; j < NUM_WEARS; j++) {
|
||||
if (GET_EQ(ch, j)) {
|
||||
if (!Crash_save(GET_EQ(ch, j), fp, j + 1)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
Crash_restore_weight(GET_EQ(ch, j));
|
||||
Crash_extract_objs(GET_EQ(ch, j));
|
||||
}
|
||||
}
|
||||
if (!Crash_save(ch->carrying, fp, 0)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "$~\n");
|
||||
fclose(fp);
|
||||
|
||||
Crash_extract_objs(ch->carrying);
|
||||
Crash_crashsave(ch);
|
||||
}
|
||||
|
||||
/* Shortened because we don't handle rent in this game */
|
||||
void Crash_rentsave(struct char_data *ch, int cost)
|
||||
{
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
int j;
|
||||
FILE *fp;
|
||||
|
||||
if (IS_NPC(ch))
|
||||
if (!ch || IS_NPC(ch))
|
||||
return;
|
||||
|
||||
if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch)))
|
||||
return;
|
||||
|
||||
if (!(fp = fopen(buf, "w")))
|
||||
return;
|
||||
|
||||
Crash_extract_norent_eq(ch);
|
||||
Crash_extract_norents(ch->carrying);
|
||||
|
||||
if (!objsave_write_rentcode(fp, RENT_RENTED, cost, ch))
|
||||
return;
|
||||
|
||||
for (j = 0; j < NUM_WEARS; j++)
|
||||
if (GET_EQ(ch, j)) {
|
||||
if (!Crash_save(GET_EQ(ch,j), fp, j + 1)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
Crash_restore_weight(GET_EQ(ch, j));
|
||||
Crash_extract_objs(GET_EQ(ch, j));
|
||||
|
||||
}
|
||||
if (!Crash_save(ch->carrying, fp, 0)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "$~\n");
|
||||
fclose(fp);
|
||||
|
||||
Crash_extract_objs(ch->carrying);
|
||||
Crash_crashsave(ch);
|
||||
}
|
||||
|
||||
static int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch)
|
||||
|
|
@ -725,241 +544,6 @@ static int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, stru
|
|||
|
||||
}
|
||||
|
||||
static void Crash_cryosave(struct char_data *ch, int cost)
|
||||
{
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
int j;
|
||||
FILE *fp;
|
||||
|
||||
if (IS_NPC(ch))
|
||||
return;
|
||||
|
||||
if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch)))
|
||||
return;
|
||||
|
||||
if (!(fp = fopen(buf, "w")))
|
||||
return;
|
||||
|
||||
Crash_extract_norent_eq(ch);
|
||||
Crash_extract_norents(ch->carrying);
|
||||
|
||||
GET_GOLD(ch) = MAX(0, GET_GOLD(ch) - cost);
|
||||
|
||||
if (!objsave_write_rentcode(fp, RENT_CRYO, 0, ch))
|
||||
return;
|
||||
|
||||
for (j = 0; j < NUM_WEARS; j++)
|
||||
if (GET_EQ(ch, j)) {
|
||||
if (!Crash_save(GET_EQ(ch, j), fp, j + 1)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
Crash_restore_weight(GET_EQ(ch, j));
|
||||
Crash_extract_objs(GET_EQ(ch, j));
|
||||
}
|
||||
if (!Crash_save(ch->carrying, fp, 0)) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "$~\n");
|
||||
fclose(fp);
|
||||
|
||||
Crash_extract_objs(ch->carrying);
|
||||
SET_BIT_AR(PLR_FLAGS(ch), PLR_CRYO);
|
||||
}
|
||||
|
||||
/* Routines used for the receptionist. */
|
||||
static void Crash_rent_deadline(struct char_data *ch, struct char_data *recep,
|
||||
long cost)
|
||||
{
|
||||
long rent_deadline;
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
|
||||
if (!cost)
|
||||
return;
|
||||
|
||||
rent_deadline = ((GET_GOLD(ch) + GET_BANK_GOLD(ch)) / cost);
|
||||
snprintf(buf, sizeof(buf), "$n tells you, 'You can rent for %ld day%s with the gold you have\r\n"
|
||||
"on hand and in the bank.'\r\n", rent_deadline, rent_deadline != 1 ? "s" : "");
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
}
|
||||
|
||||
static int Crash_report_unrentables(struct char_data *ch, struct char_data *recep,
|
||||
struct obj_data *obj)
|
||||
{
|
||||
char buf[128];
|
||||
int has_norents = 0;
|
||||
|
||||
if (obj) {
|
||||
if (Crash_is_unrentable(obj)) {
|
||||
has_norents = 1;
|
||||
sprintf(buf, "$n tells you, 'You cannot store %s.'", OBJS(obj, ch));
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
}
|
||||
has_norents += Crash_report_unrentables(ch, recep, obj->contains);
|
||||
has_norents += Crash_report_unrentables(ch, recep, obj->next_content);
|
||||
}
|
||||
return (has_norents);
|
||||
}
|
||||
|
||||
static void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct
|
||||
obj_data *obj, long *cost, long *nitems, int display, int factor)
|
||||
{
|
||||
static char buf[256];
|
||||
|
||||
if (obj) {
|
||||
if (!Crash_is_unrentable(obj)) {
|
||||
(*nitems)++;
|
||||
*cost += MAX(0, (GET_OBJ_RENT(obj) * factor));
|
||||
if (display) {
|
||||
sprintf(buf, "$n tells you, '%5d coins for %s..'",
|
||||
(GET_OBJ_RENT(obj) * factor), OBJS(obj, ch));
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
}
|
||||
}
|
||||
Crash_report_rent(ch, recep, obj->contains, cost, nitems, display, factor);
|
||||
Crash_report_rent(ch, recep, obj->next_content, cost, nitems, display, factor);
|
||||
}
|
||||
}
|
||||
|
||||
static int Crash_offer_rent(struct char_data *ch, struct char_data *recep,
|
||||
int display, int factor)
|
||||
{
|
||||
char buf[MAX_INPUT_LENGTH];
|
||||
int i;
|
||||
long totalcost = 0, numitems = 0, norent;
|
||||
|
||||
norent = Crash_report_unrentables(ch, recep, ch->carrying);
|
||||
for (i = 0; i < NUM_WEARS; i++)
|
||||
norent += Crash_report_unrentables(ch, recep, GET_EQ(ch, i));
|
||||
|
||||
if (norent)
|
||||
return FALSE;
|
||||
|
||||
totalcost = CONFIG_MIN_RENT_COST * factor;
|
||||
|
||||
Crash_report_rent(ch, recep, ch->carrying, &totalcost, &numitems, display, factor);
|
||||
|
||||
for (i = 0; i < NUM_WEARS; i++)
|
||||
Crash_report_rent(ch, recep, GET_EQ(ch, i), &totalcost, &numitems, display, factor);
|
||||
|
||||
if (!numitems) {
|
||||
act("$n tells you, 'But you are not carrying anything! Just quit!'",
|
||||
FALSE, recep, 0, ch, TO_VICT);
|
||||
return FALSE;
|
||||
}
|
||||
if (numitems > CONFIG_MAX_OBJ_SAVE) {
|
||||
sprintf(buf, "$n tells you, 'Sorry, but I cannot store more than %d items.'",
|
||||
CONFIG_MAX_OBJ_SAVE);
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
return FALSE;
|
||||
}
|
||||
if (display) {
|
||||
sprintf(buf, "$n tells you, 'Plus, my %d coin fee..'",
|
||||
CONFIG_MIN_RENT_COST * factor);
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
sprintf(buf, "$n tells you, 'For a total of %ld coins%s.'",
|
||||
totalcost, (factor == RENT_FACTOR ? " per day" : ""));
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
if (totalcost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
|
||||
act("$n tells you, '...which I see you can't afford.'",
|
||||
FALSE, recep, 0, ch, TO_VICT);
|
||||
return FALSE;
|
||||
} else if (factor == RENT_FACTOR)
|
||||
Crash_rent_deadline(ch, recep, totalcost);
|
||||
}
|
||||
return (totalcost);
|
||||
}
|
||||
|
||||
static int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd,
|
||||
char *arg, int mode)
|
||||
{
|
||||
int cost;
|
||||
char buf[128];
|
||||
const char *action_table[] = { "smile", "dance", "sigh", "blush", "burp",
|
||||
"cough", "fart", "twiddle", "yawn" };
|
||||
|
||||
if (!cmd && !rand_number(0, 5)) {
|
||||
do_action(recep, NULL, find_command(action_table[rand_number(0, 8)]), 0);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (!ch->desc || IS_NPC(ch))
|
||||
return (FALSE);
|
||||
|
||||
if (!CMD_IS("offer") && !CMD_IS("rent"))
|
||||
return (FALSE);
|
||||
|
||||
if (!AWAKE(recep)) {
|
||||
send_to_char(ch, "%s is unable to talk to you...\r\n", HSSH(recep));
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
if (!CAN_SEE(recep, ch)) {
|
||||
act("$n says, 'I don't deal with people I can't see!'", FALSE, recep, 0, 0, TO_ROOM);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
if (CONFIG_FREE_RENT) {
|
||||
act("$n tells you, 'Rent is free here. Just quit, and your objects will be saved!'",
|
||||
FALSE, recep, 0, ch, TO_VICT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CMD_IS("rent")) {
|
||||
|
||||
if (!(cost = Crash_offer_rent(ch, recep, FALSE, mode)))
|
||||
return (TRUE);
|
||||
if (mode == RENT_FACTOR)
|
||||
snprintf(buf, sizeof(buf), "$n tells you, 'Rent will cost you %d gold coins per day.'", cost);
|
||||
else if (mode == CRYO_FACTOR)
|
||||
snprintf(buf, sizeof(buf), "$n tells you, 'It will cost you %d gold coins to be frozen.'", cost);
|
||||
act(buf, FALSE, recep, 0, ch, TO_VICT);
|
||||
|
||||
if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
|
||||
act("$n tells you, '...which I see you can't afford.'",
|
||||
FALSE, recep, 0, ch, TO_VICT);
|
||||
return (TRUE);
|
||||
}
|
||||
if (cost && (mode == RENT_FACTOR))
|
||||
Crash_rent_deadline(ch, recep, cost);
|
||||
|
||||
if (mode == RENT_FACTOR) {
|
||||
act("$n stores your belongings and helps you into your private chamber.", FALSE, recep, 0, ch, TO_VICT);
|
||||
Crash_rentsave(ch, cost);
|
||||
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has rented (%d/day, %d tot.)",
|
||||
GET_NAME(ch), cost, GET_GOLD(ch) + GET_BANK_GOLD(ch));
|
||||
} else { /* cryo */
|
||||
act("$n stores your belongings and helps you into your private chamber.\r\n"
|
||||
"A white mist appears in the room, chilling you to the bone...\r\n"
|
||||
"You begin to lose consciousness...",
|
||||
FALSE, recep, 0, ch, TO_VICT);
|
||||
Crash_cryosave(ch, cost);
|
||||
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has cryo-rented.", GET_NAME(ch));
|
||||
SET_BIT_AR(PLR_FLAGS(ch), PLR_CRYO);
|
||||
}
|
||||
|
||||
act("$n helps $N into $S private chamber.", FALSE, recep, 0, ch, TO_NOTVICT);
|
||||
|
||||
GET_LOADROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch));
|
||||
extract_char(ch); /* It saves. */
|
||||
} else {
|
||||
Crash_offer_rent(ch, recep, TRUE, mode);
|
||||
act("$N gives $n an offer.", FALSE, ch, 0, recep, TO_ROOM);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
SPECIAL(receptionist)
|
||||
{
|
||||
return (gen_receptionist(ch, (struct char_data *)me, cmd, argument, RENT_FACTOR));
|
||||
}
|
||||
|
||||
SPECIAL(cryogenicist)
|
||||
{
|
||||
return (gen_receptionist(ch, (struct char_data *)me, cmd, argument, CRYO_FACTOR));
|
||||
}
|
||||
|
||||
void Crash_save_all(void)
|
||||
{
|
||||
struct descriptor_data *d;
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ void assign_mobiles(void)
|
|||
{
|
||||
assign_kings_castle();
|
||||
|
||||
ASSIGNMOB(3095, cryogenicist);
|
||||
|
||||
ASSIGNMOB(3105, mayor);
|
||||
|
||||
ASSIGNMOB(110, postmaster);
|
||||
|
|
@ -78,12 +76,6 @@ void assign_mobiles(void)
|
|||
ASSIGNMOB(27164, postmaster);
|
||||
ASSIGNMOB(30128, postmaster);
|
||||
ASSIGNMOB(31510, postmaster);
|
||||
|
||||
ASSIGNMOB(1200, receptionist);
|
||||
ASSIGNMOB(3005, receptionist);
|
||||
ASSIGNMOB(5404, receptionist);
|
||||
ASSIGNMOB(27713, receptionist);
|
||||
ASSIGNMOB(27730, receptionist);
|
||||
}
|
||||
|
||||
/* assign special procedures to objects */
|
||||
|
|
@ -142,8 +134,6 @@ static struct spec_func_data spec_func_list[] = {
|
|||
{"Janitor", janitor },
|
||||
{"Cityguard", cityguard },
|
||||
{"Postmaster", postmaster },
|
||||
{"Receptionist", receptionist },
|
||||
{"Cryogenicist", cryogenicist},
|
||||
{"Bulletin Board", gen_board },
|
||||
{"Bank", bank },
|
||||
{"Pet Shop", pet_shops },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue