1 #include "core/turn-compensator.h"
2 #include "floor/floor-town.h"
3 #include "player-info/race-types.h"
4 #include "store/store-owners.h"
5 #include "store/store-util.h"
6 #include "store/store.h"
7 #include "system/floor-type-definition.h"
8 #include "system/item-entity.h"
9 #include "system/player-type-definition.h"
10 #include "world/world.h"
13 * @brief ゲームターンからの実時間換算を行うための補正をかける
15 * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
16 * @return 修正をかけた後のゲームターン
18 int32_t turn_real(PlayerType *player_ptr, int32_t hoge)
20 switch (player_ptr->start_race) {
21 case PlayerRaceType::VAMPIRE:
22 case PlayerRaceType::SKELETON:
23 case PlayerRaceType::ZOMBIE:
24 case PlayerRaceType::SPECTRE:
25 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
32 * @brief ターンのオーバーフローに対する対処
33 * @param player_ptr プレイヤーへの参照ポインタ
34 * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
35 * @return 修正をかけた後のゲームターン
37 void prevent_turn_overflow(PlayerType *player_ptr)
39 if (w_ptr->game_turn < w_ptr->game_turn_limit) {
43 int rollback_days = 1 + (w_ptr->game_turn - w_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
44 int32_t rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
46 if (w_ptr->game_turn > rollback_turns) {
47 w_ptr->game_turn -= rollback_turns;
51 auto *floor_ptr = player_ptr->current_floor_ptr;
52 if (floor_ptr->generated_turn > rollback_turns) {
53 floor_ptr->generated_turn -= rollback_turns;
55 floor_ptr->generated_turn = 1;
57 if (w_ptr->arena_start_turn > rollback_turns) {
58 w_ptr->arena_start_turn -= rollback_turns;
60 w_ptr->arena_start_turn = 1;
62 if (player_ptr->feeling_turn > rollback_turns) {
63 player_ptr->feeling_turn -= rollback_turns;
65 player_ptr->feeling_turn = 1;
68 for (size_t i = 1; i < towns_info.size(); i++) {
69 for (auto sst : STORE_SALE_TYPE_LIST) {
70 auto *store_ptr = &towns_info[i].stores[sst];
71 if (store_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS) {
72 store_ptr->last_visit -= rollback_turns;
73 if (store_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) {
74 store_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
78 if (store_ptr->store_open) {
79 store_ptr->store_open -= rollback_turns;
80 if (store_ptr->store_open < 1) {
81 store_ptr->store_open = 1;