void Crash_cryosave(struct char_data *ch, int cost) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; 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); rent.rentcode = RENT_CRYO; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); rent.net_cost_per_diem = 0; fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time, rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems); 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(PLR_FLAGS(ch), PLR_CRYO); }
void Crash_cryosave(struct char_data * ch, int cost) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; FILE *fp; if (IS_NPC(ch)) return; if (!get_filename(GET_NAME(ch), buf, CRASH_FILE)) return; if (!(fp = fopen(buf, "wb"))) return; for (j = 0; j < NUM_WEARS; j++) if (GET_EQ(ch, j)) obj_to_char(unequip_char(ch, j), ch); Crash_extract_norents_from_equipped(ch); Crash_extract_norents(ch->carrying); GET_GOLD(ch) = MAX(0L, (long)GET_GOLD(ch) - cost); rent.rentcode = RENT_CRYO; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); rent.net_cost_per_diem = 0; if (!Crash_write_rentcode(ch, fp, &rent)) { fclose(fp); 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; } fclose(fp); Crash_extract_objs(ch->carrying); SET_BIT(PLR_FLAGS(ch), PLR_CRYO); }
int Crash_save(struct obj_data * obj, FILE * fp, int locate) { struct obj_data *tmp; int result; if (obj) { Crash_save(obj->next_content, fp, locate); Crash_save(obj->contains, fp, MIN(0,locate)-1); result = Obj_to_store_from(obj, fp, locate); for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj) GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj); if (!result) return 0; } return TRUE; }
void Crash_crashsave(struct char_data *ch) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; 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; rent.rentcode = RENT_CRASH; rent.time = time(0); fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time, rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems); 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)); } if (!Crash_save(ch->carrying, fp, 0)) { fclose(fp); return; } Crash_restore_weight(ch->carrying); fprintf(fp, "$~\n"); fclose(fp); REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH); }
void Crash_crashsave(struct char_data * ch) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; FILE *fp; if (IS_NPC(ch)) return; if (!get_filename(GET_NAME(ch), buf, CRASH_FILE)) return; if (!(fp = fopen(buf, "wb"))) return; rent.rentcode = RENT_CRASH; rent.time = time(0); if (!Crash_write_rentcode(ch, fp, &rent)) { fclose(fp); return; } if (!Crash_save(ch->carrying, fp, 0)) { fclose(fp); return; } Crash_restore_weight(ch->carrying); 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)); } } fclose(fp); REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH); }
void Crash_rentsave(struct char_data * ch, int cost) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; FILE *fp; if (IS_NPC(ch)) return; if (!get_filename(GET_NAME(ch), buf, CRASH_FILE)) return; if (!(fp = fopen(buf, "wb"))) return; for (j = 0; j < NUM_WEARS; j++) { if (GET_EQ(ch, j)) obj_to_char(unequip_char(ch, j), ch); } Crash_extract_norents_from_equipped(ch); Crash_extract_norents(ch->carrying); rent.net_cost_per_diem = cost; rent.rentcode = RENT_RENTED; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); if (!Crash_write_rentcode(ch, fp, &rent)) { fclose(fp); return; } /* NOTHING SHOULD BE EQUIPPED SINCE IT WAS ALL REMOVED A FEW BLOCKS ABOVE 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; } fclose(fp); Crash_extract_objs(ch->carrying); }
void Crash_idlesave(struct char_data * ch) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; int cost, cost_eq; FILE *fp; if (IS_NPC(ch)) return; if (!get_filename(GET_NAME(ch), buf, CRASH_FILE)) return; if (!(fp = fopen(buf, "wb"))) return; for (j = 0; j < NUM_WEARS; j++) if (GET_EQ(ch, j)) obj_to_char(unequip_char(ch, j), ch); Crash_extract_norents_from_equipped(ch); Crash_extract_norents(ch->carrying); cost_eq = 0; for (j = 0; j < NUM_WEARS; j++) Crash_calculate_rent(GET_EQ(ch,j), &cost_eq); cost = 0; Crash_calculate_rent(ch->carrying, &cost); cost <<= 1; /* forcerent cost is 2x normal rent */ cost_eq <<= 1; if (cost+cost_eq > GET_GOLD(ch) + GET_BANK_GOLD(ch)) { for (j = 0; j < NUM_WEARS; j++) /* unequip player with low money */ if (GET_EQ(ch,j)) obj_to_char(unequip_char(ch, j), ch); cost += cost_eq; cost_eq = 0; } while ((cost+cost_eq > GET_GOLD(ch) + GET_BANK_GOLD(ch)) && ch->carrying) { Crash_extract_expensive(ch->carrying); cost = 0; Crash_calculate_rent(ch->carrying, &cost); cost <<= 1; } if (!ch->carrying) { for (j = 0; j < NUM_WEARS && !(GET_EQ(ch,j)); j++) ; if (j == NUM_WEARS) { /* no eq nor inv */ fclose(fp); Crash_delete_file(GET_NAME(ch)); return; } } rent.net_cost_per_diem = cost; rent.rentcode = RENT_TIMEDOUT; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); if (!Crash_write_rentcode(ch, fp, &rent)) { fclose(fp); 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; } fclose(fp); Crash_extract_objs(ch->carrying); }
void Crash_idlesave(struct char_data *ch) { char buf[MAX_INPUT_LENGTH]; struct rent_info rent; int j; int cost, cost_eq; 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); 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; } } rent.net_cost_per_diem = cost; rent.rentcode = RENT_TIMEDOUT; rent.time = time(0); rent.gold = GET_GOLD(ch); rent.account = GET_BANK_GOLD(ch); fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time, rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems); 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); }