<ClCompile Include="..\..\src\grid\grid.c" />\r
<ClCompile Include="..\..\src\io\inet.c" />\r
<ClCompile Include="..\..\src\locale\japanese.c" />\r
- <ClCompile Include="..\..\src\io\load.c" />\r
+ <ClCompile Include="..\..\src\savedata\load.c" />\r
<ClCompile Include="..\..\src\main-win.c" />\r
<ClCompile Include="..\..\src\mind\mind.c" />\r
<ClCompile Include="..\..\src\monster\monster-info.c" />\r
<ClCompile Include="..\..\src\room\rooms.c" />\r
<ClCompile Include="..\..\src\room\pit-nest-kinds-table.c" />\r
<ClCompile Include="..\..\src\store\rumor.c" />\r
- <ClCompile Include="..\..\src\io\save.c" />\r
+ <ClCompile Include="..\..\src\savedata\save.c" />\r
<ClCompile Include="..\..\src\core\scores.c" />\r
<ClCompile Include="..\..\src\player\selfinfo.c" />\r
<ClCompile Include="..\..\src\io\signal-handlers.c" />\r
<ClInclude Include="..\..\src\birth\history.h" />\r
<ClInclude Include="..\..\src\io\inet.h" />\r
<ClInclude Include="..\..\src\main\init.h" />\r
- <ClInclude Include="..\..\src\io\load.h" />\r
+ <ClInclude Include="..\..\src\savedata\load.h" />\r
<ClInclude Include="..\..\src\mind\mind.h" />\r
<ClInclude Include="..\..\src\monster\monster-processor.h" />\r
<ClInclude Include="..\..\src\monster\monster-status.h" />\r
<ClInclude Include="..\..\src\room\rooms-vault.h" />\r
<ClInclude Include="..\..\src\room\rooms.h" />\r
<ClInclude Include="..\..\src\store\rumor.h" />\r
- <ClInclude Include="..\..\src\io\save.h" />\r
+ <ClInclude Include="..\..\src\savedata\save.h" />\r
<ClInclude Include="..\..\src\core\scores.h" />\r
<ClInclude Include="..\..\src\player\selfinfo.h" />\r
<ClInclude Include="..\..\src\mind\mind-sniper.h" />\r
<ClCompile Include="..\..\src\locale\japanese.c">
<Filter>locale</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\io\save.c">
- <Filter>io</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\io\load.c">
- <Filter>io</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\grid\grid.c">
<Filter>grid</Filter>
</ClCompile>
<ClCompile Include="..\..\src\spell-kind\magic-item-recharger.c">
<Filter>spell-kind</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\savedata\save.c">
+ <Filter>savedata</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\savedata\load.c">
+ <Filter>savedata</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\cmd\cmd-basic.h">
<ClInclude Include="..\..\src\spell\spells-summon.h">
<Filter>spell</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\io\save.h">
- <Filter>io</Filter>
- </ClInclude>
- <ClInclude Include="..\..\src\io\load.h">
- <Filter>io</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\grid\feature.h">
<Filter>grid</Filter>
</ClInclude>
<ClInclude Include="..\..\src\spell-kind\magic-item-recharger.h">
<Filter>spell-kind</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\savedata\save.h">
+ <Filter>savedata</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\savedata\load.h">
+ <Filter>savedata</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
<Filter Include="object-potion">
<UniqueIdentifier>{3e8ea357-82a2-4978-a257-338b953d1469}</UniqueIdentifier>
</Filter>
+ <Filter Include="savedata">
+ <UniqueIdentifier>{2bfe9405-f65a-4dac-afde-56800ae04b9f}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\angband.rc" />
-Iinfo-reader -Iinventory -Iio -Iio-dump -Iknowledge -Imarket -Imelee \
-Imind -Imonster -Imonster-attack -Imonster-floor -Imonster-race -Ilore \
-Imspell -Imutation -Iobject -Iobject-enchant -Iobject-hook -Iobject-potion \
- -Ipet -Iplayer -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell \
- -Ispell-kind -Ispell-realm -Istatus -Isv-definition -Isystem -Iterm -Iutil \
- -Iview -Iwizard -Iworld
+ -Ipet -Iplayer -Iplayer-attack -Irealm -Iroom -Isavedata -Ispecific-object \
+ -Ispell -Ispell-kind -Ispell-realm -Istatus -Isv-definition -Isystem -Iterm \
+ -Iutil -Iview -Iwizard -Iworld
install-exec-hook:
if SET_GID
#include "cmd-io/cmd-save.h"
#include "cmd-io/cmd-dump.h"
#include "core/stuff-handler.h"
-#include "io/save.h"
#include "io/signal-handlers.h"
#include "io/write-diary.h"
#include "monster/monster-status.h" // 違和感。要調査.
#include "player/player-move.h"
+#include "savedata/save.h"
#include "term/screen-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
void do_cmd_save_game(player_type *creature_ptr, int is_autosave)
{
if (is_autosave)
- {
msg_print(_("自動セーブ中", "Autosaving the game..."));
- }
else
- {
disturb(creature_ptr, TRUE, TRUE);
- }
msg_print(NULL);
handle_stuff(creature_ptr);
(void)strcpy(creature_ptr->died_from, _("(セーブ)", "(saved)"));
signals_ignore_tstp();
if (save_player(creature_ptr))
- {
prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
- }
else
- {
prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0);
- }
signals_handle_tstp();
Term_fresh();
#include "core/stuff-handler.h"
#include "game-option/cheat-options.h"
#include "io/input-key-acceptor.h"
-#include "io/save.h"
#include "io/signal-handlers.h"
#include "io/uid-checker.h"
#include "main/music-definitions-table.h"
#include "main/sound-of-music.h"
#include "player/process-death.h"
+#include "savedata/save.h"
#include "term/screen-processor.h"
#include "util/angband-files.h"
#include "util/int-char-converter.h"
#include "io/input-key-acceptor.h"
#include "io/input-key-processor.h"
#include "io/read-pref-file.h"
-#include "io/save.h"
#include "io/screen-util.h"
#include "io/signal-handlers.h"
#include "io/targeting.h"
#include "player/player-skill.h"
#include "player/process-name.h"
#include "realm/realm-names-table.h"
+#include "savedata/save.h"
#include "spell/spells-status.h"
#include "spell/technic-info-table.h"
#include "store/store-util.h"
#include "grid/grid.h"
#include "inventory/inventory-slot-types.h"
#include "io/files-util.h"
-#include "io/load.h"
-#include "io/save.h"
#include "io/uid-checker.h"
#include "io/write-diary.h"
#include "main/sound-of-music.h"
#include "player/player-class.h"
#include "player/player-personalities-types.h"
#include "player/special-defense-types.h"
+#include "savedata/load.h"
+#include "savedata/save.h"
#include "spell-kind/spells-floor.h"
#include "system/system-variables.h"
#include "util/angband-files.h"
bool repair_monsters;
-static FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */
-static u32b latest_visit_mark; /*!<フロアを渡った回数?(確認中) / Max number of visit_mark */
+static FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */
+static u32b latest_visit_mark; /*!<フロアを渡った回数?(確認中) / Max number of visit_mark */
#define MAX_PARTY_MON 21 /*!< フロア移動時に先のフロアに連れて行けるペットの最大数 Maximum number of preservable pets */
static monster_type party_mon[MAX_PARTY_MON]; /*!< フロア移動に保存するペットモンスターの配列 */
u32b saved_floor_file_sign;
/*!
- * @brief 保存フロア配列を初期化する / Initialize saved_floors array.
+ * @brief 保存フロア配列を初期化する / Initialize saved_floors array.
* @param creature_ptr プレーヤーへの参照ポインタ
* @param force テンポラリファイルが残っていた場合も警告なしで強制的に削除するフラグ
* @details Make sure that old temporary files are not remaining as gurbages.
*/
void init_saved_floors(player_type *creature_ptr, bool force)
{
- char floor_savefile[1024];
- int i;
- int fd = -1;
- BIT_FLAGS mode = 0644;
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- saved_floor_type *sf_ptr = &saved_floors[i];
-
- /* File name */
- sprintf(floor_savefile, "%s.F%02d", savefile, i);
-
- /* Grab permissions */
- safe_setuid_grab(creature_ptr);
-
- /* Try to create the file */
- fd = fd_make(floor_savefile, mode);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- /* Failed! */
- if (fd < 0)
- {
- if (!force)
- {
- msg_print(_("エラー:古いテンポラリ・ファイルが残っています。", "Error: There are old temporary files."));
- msg_print(_("変愚蛮怒を二重に起動していないか確認してください。", "Make sure you are not running two game processes simultaneously."));
- msg_print(_("過去に変愚蛮怒がクラッシュした場合は一時ファイルを", "If the temporary files are garbage from an old crashed process, "));
- msg_print(_("強制的に削除して実行を続けられます。", "you can delete them safely."));
- if (!get_check(_("強制的に削除してもよろしいですか?", "Do you delete the old temporary files? ")))
- quit(_("実行中止", "Aborted."));
- force = TRUE;
- }
- }
- else
- {
- /* Close the "fd" */
- (void)fd_close(fd);
- }
-
- /* Grab permissions */
- safe_setuid_grab(creature_ptr);
-
- /* Simply kill the temporary file */
- (void)fd_kill(floor_savefile);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- sf_ptr->floor_id = 0;
- }
-
- /* No floor_id used yet (No.0 is reserved to indicate non existance) */
- max_floor_id = 1;
-
- /* vist_mark is from 1 */
- latest_visit_mark = 1;
-
- /* A sign to mark temporary files */
- saved_floor_file_sign = (u32b)time(NULL);
-
- /* No next floor yet */
- new_floor_id = 0;
-
- /* No change floor mode yet */
- creature_ptr->change_floor_mode = 0;
+ char floor_savefile[1024];
+ int i;
+ int fd = -1;
+ BIT_FLAGS mode = 0644;
+ for (i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
+
+ /* File name */
+ sprintf(floor_savefile, "%s.F%02d", savefile, i);
+
+ /* Grab permissions */
+ safe_setuid_grab(creature_ptr);
+
+ /* Try to create the file */
+ fd = fd_make(floor_savefile, mode);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ /* Failed! */
+ if (fd < 0) {
+ if (!force) {
+ msg_print(_("エラー:古いテンポラリ・ファイルが残っています。", "Error: There are old temporary files."));
+ msg_print(_("変愚蛮怒を二重に起動していないか確認してください。", "Make sure you are not running two game processes simultaneously."));
+ msg_print(_("過去に変愚蛮怒がクラッシュした場合は一時ファイルを", "If the temporary files are garbage from an old crashed process, "));
+ msg_print(_("強制的に削除して実行を続けられます。", "you can delete them safely."));
+ if (!get_check(_("強制的に削除してもよろしいですか?", "Do you delete the old temporary files? ")))
+ quit(_("実行中止", "Aborted."));
+ force = TRUE;
+ }
+ } else {
+ /* Close the "fd" */
+ (void)fd_close(fd);
+ }
+
+ /* Grab permissions */
+ safe_setuid_grab(creature_ptr);
+
+ /* Simply kill the temporary file */
+ (void)fd_kill(floor_savefile);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ sf_ptr->floor_id = 0;
+ }
+
+ /* No floor_id used yet (No.0 is reserved to indicate non existance) */
+ max_floor_id = 1;
+
+ /* vist_mark is from 1 */
+ latest_visit_mark = 1;
+
+ /* A sign to mark temporary files */
+ saved_floor_file_sign = (u32b)time(NULL);
+
+ /* No next floor yet */
+ new_floor_id = 0;
+
+ /* No change floor mode yet */
+ creature_ptr->change_floor_mode = 0;
}
/*!
*/
void clear_saved_floor_files(player_type *creature_ptr)
{
- char floor_savefile[1024];
- int i;
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- saved_floor_type *sf_ptr = &saved_floors[i];
+ char floor_savefile[1024];
+ int i;
+ for (i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
- /* No temporary file */
- if (!sf_ptr->floor_id) continue;
- if (sf_ptr->floor_id == creature_ptr->floor_id) continue;
+ /* No temporary file */
+ if (!sf_ptr->floor_id)
+ continue;
+ if (sf_ptr->floor_id == creature_ptr->floor_id)
+ continue;
- /* File name */
- sprintf(floor_savefile, "%s.F%02d", savefile, i);
+ /* File name */
+ sprintf(floor_savefile, "%s.F%02d", savefile, i);
- /* Grab permissions */
- safe_setuid_grab(creature_ptr);
+ /* Grab permissions */
+ safe_setuid_grab(creature_ptr);
- /* Simply kill the temporary file */
- (void)fd_kill(floor_savefile);
+ /* Simply kill the temporary file */
+ (void)fd_kill(floor_savefile);
- /* Drop permissions */
- safe_setuid_drop();
- }
+ /* Drop permissions */
+ safe_setuid_drop();
+ }
}
/*!
*/
saved_floor_type *get_sf_ptr(FLOOR_IDX floor_id)
{
- int i;
+ int i;
- /* floor_id No.0 indicates no floor */
- if (!floor_id) return NULL;
+ /* floor_id No.0 indicates no floor */
+ if (!floor_id)
+ return NULL;
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- saved_floor_type *sf_ptr = &saved_floors[i];
+ for (i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
- if (sf_ptr->floor_id == floor_id) return sf_ptr;
- }
+ if (sf_ptr->floor_id == floor_id)
+ return sf_ptr;
+ }
- /* None found */
- return NULL;
+ /* None found */
+ return NULL;
}
-
/*!
* @brief 参照ポインタ先の保存フロアを抹消する / kill a saved floor and get an empty space
* @param creature_ptr プレーヤーへの参照ポインタ
*/
static void kill_saved_floor(player_type *creature_ptr, saved_floor_type *sf_ptr)
{
- char floor_savefile[1024];
- if (!sf_ptr) return;
+ char floor_savefile[1024];
+ if (!sf_ptr)
+ return;
- /* Already empty */
- if (!sf_ptr->floor_id) return;
+ /* Already empty */
+ if (!sf_ptr->floor_id)
+ return;
- if (sf_ptr->floor_id == creature_ptr->floor_id)
- {
- /* Kill current floor */
- creature_ptr->floor_id = 0;
+ if (sf_ptr->floor_id == creature_ptr->floor_id) {
+ /* Kill current floor */
+ creature_ptr->floor_id = 0;
- /* Current floor doesn't have temporary file */
- }
- else
- {
- /* File name */
- sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id);
+ /* Current floor doesn't have temporary file */
+ } else {
+ /* File name */
+ sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id);
- /* Grab permissions */
- safe_setuid_grab(creature_ptr);
+ /* Grab permissions */
+ safe_setuid_grab(creature_ptr);
- /* Simply kill the temporary file */
- (void)fd_kill(floor_savefile);
+ /* Simply kill the temporary file */
+ (void)fd_kill(floor_savefile);
- /* Drop permissions */
- safe_setuid_drop();
- }
+ /* Drop permissions */
+ safe_setuid_drop();
+ }
- /* No longer exists */
- sf_ptr->floor_id = 0;
+ /* No longer exists */
+ sf_ptr->floor_id = 0;
}
-
/*!
* @brief 新規に利用可能な保存フロアを返す / Initialize new saved floor and get its floor id.
* @param creature_ptr プレーヤーへの参照ポインタ
*/
FLOOR_IDX get_new_floor_id(player_type *creature_ptr)
{
- saved_floor_type *sf_ptr = NULL;
- FLOOR_IDX i;
-
- /* Look for empty space */
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- sf_ptr = &saved_floors[i];
-
- if (!sf_ptr->floor_id) break;
- }
-
- /* None found */
- if (i == MAX_SAVED_FLOORS)
- {
- s16b oldest = 0;
- u32b oldest_visit = 0xffffffffL;
-
- /* Search for oldest */
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- sf_ptr = &saved_floors[i];
-
- /* Don't kill current floor */
- if (sf_ptr->floor_id == creature_ptr->floor_id) continue;
-
- /* Don't kill newer */
- if (sf_ptr->visit_mark > oldest_visit) continue;
-
- oldest = i;
- oldest_visit = sf_ptr->visit_mark;
- }
-
- /* Kill oldest saved floor */
- sf_ptr = &saved_floors[oldest];
- kill_saved_floor(creature_ptr, sf_ptr);
-
- /* Use it */
- i = oldest;
- }
-
- /* Prepare new floor data */
- sf_ptr->savefile_id = i;
- sf_ptr->floor_id = max_floor_id;
- sf_ptr->last_visit = 0;
- sf_ptr->upper_floor_id = 0;
- sf_ptr->lower_floor_id = 0;
- sf_ptr->visit_mark = latest_visit_mark++;
-
- /* sf_ptr->dun_level may be changed later */
- sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level;
-
-
- /* Increment number of floor_id */
- if (max_floor_id < MAX_SHORT) max_floor_id++;
-
- /* 32767 floor_ids are all used up! Re-use ancient IDs */
- else max_floor_id = 1;
-
- return sf_ptr->floor_id;
+ saved_floor_type *sf_ptr = NULL;
+ FLOOR_IDX i;
+
+ /* Look for empty space */
+ for (i = 0; i < MAX_SAVED_FLOORS; i++) {
+ sf_ptr = &saved_floors[i];
+
+ if (!sf_ptr->floor_id)
+ break;
+ }
+
+ /* None found */
+ if (i == MAX_SAVED_FLOORS) {
+ s16b oldest = 0;
+ u32b oldest_visit = 0xffffffffL;
+
+ /* Search for oldest */
+ for (i = 0; i < MAX_SAVED_FLOORS; i++) {
+ sf_ptr = &saved_floors[i];
+
+ /* Don't kill current floor */
+ if (sf_ptr->floor_id == creature_ptr->floor_id)
+ continue;
+
+ /* Don't kill newer */
+ if (sf_ptr->visit_mark > oldest_visit)
+ continue;
+
+ oldest = i;
+ oldest_visit = sf_ptr->visit_mark;
+ }
+
+ /* Kill oldest saved floor */
+ sf_ptr = &saved_floors[oldest];
+ kill_saved_floor(creature_ptr, sf_ptr);
+
+ /* Use it */
+ i = oldest;
+ }
+
+ /* Prepare new floor data */
+ sf_ptr->savefile_id = i;
+ sf_ptr->floor_id = max_floor_id;
+ sf_ptr->last_visit = 0;
+ sf_ptr->upper_floor_id = 0;
+ sf_ptr->lower_floor_id = 0;
+ sf_ptr->visit_mark = latest_visit_mark++;
+
+ /* sf_ptr->dun_level may be changed later */
+ sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level;
+
+ /* Increment number of floor_id */
+ if (max_floor_id < MAX_SHORT)
+ max_floor_id++;
+
+ /* 32767 floor_ids are all used up! Re-use ancient IDs */
+ else
+ max_floor_id = 1;
+
+ return sf_ptr->floor_id;
}
-
/*!
* @brief フロア切り替え時の処理フラグを追加する / Prepare mode flags of changing floor
* @param creature_ptr プレーヤーへの参照ポインタ
* @param mode 追加したい所持フラグ
* @return なし
*/
-void prepare_change_floor_mode(player_type *creature_ptr, BIT_FLAGS mode)
-{
- creature_ptr->change_floor_mode |= mode;
-}
+void prepare_change_floor_mode(player_type *creature_ptr, BIT_FLAGS mode) { creature_ptr->change_floor_mode |= mode; }
/*!
* @brief 階段移動先のフロアが生成できない時に簡単な行き止まりマップを作成する / Builds the dead end
*/
static void build_dead_end(player_type *creature_ptr)
{
- POSITION x, y;
+ POSITION x, y;
- clear_cave(creature_ptr);
+ clear_cave(creature_ptr);
- /* Mega-Hack -- no player yet */
- creature_ptr->x = creature_ptr->y = 0;
+ /* Mega-Hack -- no player yet */
+ creature_ptr->x = creature_ptr->y = 0;
- /* Fill the arrays of floors and walls in the good proportions */
- set_floor_and_wall(0);
+ /* Fill the arrays of floors and walls in the good proportions */
+ set_floor_and_wall(0);
- /* Smallest area */
- creature_ptr->current_floor_ptr->height = SCREEN_HGT;
- creature_ptr->current_floor_ptr->width = SCREEN_WID;
+ /* Smallest area */
+ creature_ptr->current_floor_ptr->height = SCREEN_HGT;
+ creature_ptr->current_floor_ptr->width = SCREEN_WID;
- /* Filled with permanent walls */
- for (y = 0; y < MAX_HGT; y++)
- {
- for (x = 0; x < MAX_WID; x++)
- {
- /* Create "solid" perma-wall */
- place_bold(creature_ptr, y, x, GB_SOLID_PERM);
- }
- }
+ /* Filled with permanent walls */
+ for (y = 0; y < MAX_HGT; y++) {
+ for (x = 0; x < MAX_WID; x++) {
+ /* Create "solid" perma-wall */
+ place_bold(creature_ptr, y, x, GB_SOLID_PERM);
+ }
+ }
- /* Place at center of the floor */
- creature_ptr->y = creature_ptr->current_floor_ptr->height / 2;
- creature_ptr->x = creature_ptr->current_floor_ptr->width / 2;
+ /* Place at center of the floor */
+ creature_ptr->y = creature_ptr->current_floor_ptr->height / 2;
+ creature_ptr->x = creature_ptr->current_floor_ptr->width / 2;
- /* Give one square */
- place_bold(creature_ptr, creature_ptr->y, creature_ptr->x, GB_FLOOR);
+ /* Give one square */
+ place_bold(creature_ptr, creature_ptr->y, creature_ptr->x, GB_FLOOR);
- wipe_generate_random_floor_flags(creature_ptr->current_floor_ptr);
+ wipe_generate_random_floor_flags(creature_ptr->current_floor_ptr);
}
-
/*!
* @brief フロア移動時のペット保存処理 / Preserve_pets
* @param master_ptr プレーヤーへの参照ポインタ
*/
static void preserve_pet(player_type *master_ptr)
{
- int num;
- MONSTER_IDX i;
-
- for (num = 0; num < MAX_PARTY_MON; num++)
- {
- party_mon[num].r_idx = 0;
- }
-
- if (master_ptr->riding)
- {
- monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[master_ptr->riding];
-
- /* Pet of other pet don't follow. */
- if (m_ptr->parent_m_idx)
- {
- master_ptr->riding = 0;
- master_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
- master_ptr->riding_ryoute = master_ptr->old_riding_ryoute = FALSE;
- }
- else
- {
- /* Preserve the mount */
- (void)COPY(&party_mon[0], m_ptr, monster_type);
-
- /* Delete from this floor */
- delete_monster_idx(master_ptr, master_ptr->riding);
- }
- }
-
- /*
- * If player is in wild mode, no pets are preserved
- * except a monster whom player riding
- */
- if (!master_ptr->wild_mode && !master_ptr->current_floor_ptr->inside_arena && !master_ptr->phase_out)
- {
- for (i = master_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--)
- {
- monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
-
- if (!monster_is_valid(m_ptr)) continue;
- if (!is_pet(m_ptr)) continue;
- if (i == master_ptr->riding) continue;
-
- if (reinit_wilderness)
- {
- /* Don't lose sight of pets when getting a Quest */
- }
- else
- {
- POSITION dis = distance(master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx);
-
- /* Confused (etc.) monsters don't follow. */
- if (monster_confused_remaining(m_ptr) || monster_stunned_remaining(m_ptr) || monster_csleep_remaining(m_ptr)) continue;
-
- /* Pet of other pet don't follow. */
- if (m_ptr->parent_m_idx) continue;
-
- /*
- * Pets with nickname will follow even from 3 blocks away
- * when you or the pet can see the other.
- */
- if (m_ptr->nickname &&
- ((player_has_los_bold(master_ptr, m_ptr->fy, m_ptr->fx) && projectable(master_ptr, master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx)) ||
- (los(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x) && projectable(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x))))
- {
- if (dis > 3) continue;
- }
- else
- {
- if (dis > 1) continue;
- }
- }
-
- (void)COPY(&party_mon[num], &master_ptr->current_floor_ptr->m_list[i], monster_type);
-
- num++;
-
- /* Delete from this floor */
- delete_monster_idx(master_ptr, i);
- }
- }
-
- if (record_named_pet)
- {
- for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
- {
- monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
- GAME_TEXT m_name[MAX_NLEN];
-
- if (!monster_is_valid(m_ptr)) continue;
- if (!is_pet(m_ptr)) continue;
- if (!m_ptr->nickname) continue;
- if (master_ptr->riding == i) continue;
-
- monster_desc(master_ptr, m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
- exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
- }
- }
-
-
- /* Pet of other pet may disappear. */
- for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
- {
- monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
-
- /* Are there its parent? */
- if (m_ptr->parent_m_idx && !master_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
- {
- /* Its parent have gone, it also goes away. */
-
- if (is_seen(master_ptr, m_ptr))
- {
- GAME_TEXT m_name[MAX_NLEN];
- monster_desc(master_ptr, m_name, m_ptr, 0);
- msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
- }
-
- delete_monster_idx(master_ptr, i);
- }
- }
+ int num;
+ MONSTER_IDX i;
+
+ for (num = 0; num < MAX_PARTY_MON; num++) {
+ party_mon[num].r_idx = 0;
+ }
+
+ if (master_ptr->riding) {
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[master_ptr->riding];
+
+ /* Pet of other pet don't follow. */
+ if (m_ptr->parent_m_idx) {
+ master_ptr->riding = 0;
+ master_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+ master_ptr->riding_ryoute = master_ptr->old_riding_ryoute = FALSE;
+ } else {
+ /* Preserve the mount */
+ (void)COPY(&party_mon[0], m_ptr, monster_type);
+
+ /* Delete from this floor */
+ delete_monster_idx(master_ptr, master_ptr->riding);
+ }
+ }
+
+ /*
+ * If player is in wild mode, no pets are preserved
+ * except a monster whom player riding
+ */
+ if (!master_ptr->wild_mode && !master_ptr->current_floor_ptr->inside_arena && !master_ptr->phase_out) {
+ for (i = master_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--) {
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
+
+ if (!monster_is_valid(m_ptr))
+ continue;
+ if (!is_pet(m_ptr))
+ continue;
+ if (i == master_ptr->riding)
+ continue;
+
+ if (reinit_wilderness) {
+ /* Don't lose sight of pets when getting a Quest */
+ } else {
+ POSITION dis = distance(master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx);
+
+ /* Confused (etc.) monsters don't follow. */
+ if (monster_confused_remaining(m_ptr) || monster_stunned_remaining(m_ptr) || monster_csleep_remaining(m_ptr))
+ continue;
+
+ /* Pet of other pet don't follow. */
+ if (m_ptr->parent_m_idx)
+ continue;
+
+ /*
+ * Pets with nickname will follow even from 3 blocks away
+ * when you or the pet can see the other.
+ */
+ if (m_ptr->nickname
+ && ((player_has_los_bold(master_ptr, m_ptr->fy, m_ptr->fx) && projectable(master_ptr, master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx))
+ || (los(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x)
+ && projectable(master_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x)))) {
+ if (dis > 3)
+ continue;
+ } else {
+ if (dis > 1)
+ continue;
+ }
+ }
+
+ (void)COPY(&party_mon[num], &master_ptr->current_floor_ptr->m_list[i], monster_type);
+
+ num++;
+
+ /* Delete from this floor */
+ delete_monster_idx(master_ptr, i);
+ }
+ }
+
+ if (record_named_pet) {
+ for (i = master_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
+ GAME_TEXT m_name[MAX_NLEN];
+
+ if (!monster_is_valid(m_ptr))
+ continue;
+ if (!is_pet(m_ptr))
+ continue;
+ if (!m_ptr->nickname)
+ continue;
+ if (master_ptr->riding == i)
+ continue;
+
+ monster_desc(master_ptr, m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+ exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
+ }
+ }
+
+ /* Pet of other pet may disappear. */
+ for (i = master_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
+
+ /* Are there its parent? */
+ if (m_ptr->parent_m_idx && !master_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx) {
+ /* Its parent have gone, it also goes away. */
+
+ if (is_seen(master_ptr, m_ptr)) {
+ GAME_TEXT m_name[MAX_NLEN];
+ monster_desc(master_ptr, m_name, m_ptr, 0);
+ msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
+ }
+
+ delete_monster_idx(master_ptr, i);
+ }
+ }
}
-
/*!
* @brief フロア移動時にペットを伴った場合の準備処理 / Pre-calculate the racial counters of preserved pets
* @param master_ptr プレーヤーへの参照ポインタ
*/
void precalc_cur_num_of_pet(player_type *player_ptr)
{
- monster_type *m_ptr;
- int i;
- int max_num = player_ptr->wild_mode ? 1 : MAX_PARTY_MON;
+ monster_type *m_ptr;
+ int i;
+ int max_num = player_ptr->wild_mode ? 1 : MAX_PARTY_MON;
- for (i = 0; i < max_num; i++)
- {
- m_ptr = &party_mon[i];
+ for (i = 0; i < max_num; i++) {
+ m_ptr = &party_mon[i];
- /* Skip empty monsters */
- if (!monster_is_valid(m_ptr)) continue;
+ /* Skip empty monsters */
+ if (!monster_is_valid(m_ptr))
+ continue;
- /* Hack -- Increase the racial counter */
- real_r_ptr(m_ptr)->cur_num++;
- }
+ /* Hack -- Increase the racial counter */
+ real_r_ptr(m_ptr)->cur_num++;
+ }
}
/*!
*/
static void place_pet(player_type *master_ptr)
{
- int i;
- int max_num = master_ptr->wild_mode ? 1 : MAX_PARTY_MON;
- floor_type *floor_ptr = master_ptr->current_floor_ptr;
- for (i = 0; i < max_num; i++)
- {
- POSITION cy = 0, cx = 0;
- MONSTER_IDX m_idx;
-
- if (!(party_mon[i].r_idx)) continue;
-
- if (i == 0)
- {
- m_idx = m_pop(floor_ptr);
- master_ptr->riding = m_idx;
- if (m_idx)
- {
- cy = master_ptr->y;
- cx = master_ptr->x;
- }
- }
- else
- {
- int j;
- POSITION d;
-
- for (d = 1; d < A_MAX; d++)
- {
- for (j = 1000; j > 0; j--)
- {
- scatter(master_ptr, &cy, &cx, master_ptr->y, master_ptr->x, d, 0);
- if (monster_can_enter(master_ptr, cy, cx, &r_info[party_mon[i].r_idx], 0)) break;
- }
- if (j) break;
- }
- m_idx = (d == 6) ? 0 : m_pop(floor_ptr);
- }
-
- if (m_idx)
- {
- monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[m_idx];
- monster_race *r_ptr;
-
- master_ptr->current_floor_ptr->grid_array[cy][cx].m_idx = m_idx;
-
- m_ptr->r_idx = party_mon[i].r_idx;
-
- /* Copy all member of the structure */
- *m_ptr = party_mon[i];
- r_ptr = real_r_ptr(m_ptr);
-
- m_ptr->fy = cy;
- m_ptr->fx = cx;
- m_ptr->current_floor_ptr = master_ptr->current_floor_ptr;
- m_ptr->ml = TRUE;
- m_ptr->mtimed[MTIMED_CSLEEP] = 0;
- m_ptr->hold_o_idx = 0;
- m_ptr->target_y = 0;
-
- if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
- {
- /* Monster is still being nice */
- m_ptr->mflag |= (MFLAG_NICE);
-
- /* Must repair monsters */
- repair_monsters = TRUE;
- }
- update_monster(master_ptr, m_idx, TRUE);
- lite_spot(master_ptr, cy, cx);
-
- /* Pre-calculated in precalc_cur_num_of_pet() */
- /* r_ptr->cur_num++; */
-
- /* Hack -- Count the number of "reproducers" */
- if (r_ptr->flags2 & RF2_MULTIPLY) master_ptr->current_floor_ptr->num_repro++;
-
- }
- else
- {
- monster_type *m_ptr = &party_mon[i];
- monster_race *r_ptr = real_r_ptr(m_ptr);
- GAME_TEXT m_name[MAX_NLEN];
-
- monster_desc(master_ptr, m_name, m_ptr, 0);
- msg_format(_("%sとはぐれてしまった。", "You have lost sight of %s."), m_name);
- if (record_named_pet && m_ptr->nickname)
- {
- monster_desc(master_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
- exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name);
- }
-
- /* Pre-calculated in precalc_cur_num_of_pet(), but need to decrease */
- if (r_ptr->cur_num) r_ptr->cur_num--;
- }
- }
-
- /* For accuracy of precalc_cur_num_of_pet() */
- (void)C_WIPE(party_mon, MAX_PARTY_MON, monster_type);
+ int i;
+ int max_num = master_ptr->wild_mode ? 1 : MAX_PARTY_MON;
+ floor_type *floor_ptr = master_ptr->current_floor_ptr;
+ for (i = 0; i < max_num; i++) {
+ POSITION cy = 0, cx = 0;
+ MONSTER_IDX m_idx;
+
+ if (!(party_mon[i].r_idx))
+ continue;
+
+ if (i == 0) {
+ m_idx = m_pop(floor_ptr);
+ master_ptr->riding = m_idx;
+ if (m_idx) {
+ cy = master_ptr->y;
+ cx = master_ptr->x;
+ }
+ } else {
+ int j;
+ POSITION d;
+
+ for (d = 1; d < A_MAX; d++) {
+ for (j = 1000; j > 0; j--) {
+ scatter(master_ptr, &cy, &cx, master_ptr->y, master_ptr->x, d, 0);
+ if (monster_can_enter(master_ptr, cy, cx, &r_info[party_mon[i].r_idx], 0))
+ break;
+ }
+ if (j)
+ break;
+ }
+ m_idx = (d == 6) ? 0 : m_pop(floor_ptr);
+ }
+
+ if (m_idx) {
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[m_idx];
+ monster_race *r_ptr;
+
+ master_ptr->current_floor_ptr->grid_array[cy][cx].m_idx = m_idx;
+
+ m_ptr->r_idx = party_mon[i].r_idx;
+
+ /* Copy all member of the structure */
+ *m_ptr = party_mon[i];
+ r_ptr = real_r_ptr(m_ptr);
+
+ m_ptr->fy = cy;
+ m_ptr->fx = cx;
+ m_ptr->current_floor_ptr = master_ptr->current_floor_ptr;
+ m_ptr->ml = TRUE;
+ m_ptr->mtimed[MTIMED_CSLEEP] = 0;
+ m_ptr->hold_o_idx = 0;
+ m_ptr->target_y = 0;
+
+ if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare) {
+ /* Monster is still being nice */
+ m_ptr->mflag |= (MFLAG_NICE);
+
+ /* Must repair monsters */
+ repair_monsters = TRUE;
+ }
+ update_monster(master_ptr, m_idx, TRUE);
+ lite_spot(master_ptr, cy, cx);
+
+ /* Pre-calculated in precalc_cur_num_of_pet() */
+ /* r_ptr->cur_num++; */
+
+ /* Hack -- Count the number of "reproducers" */
+ if (r_ptr->flags2 & RF2_MULTIPLY)
+ master_ptr->current_floor_ptr->num_repro++;
+
+ } else {
+ monster_type *m_ptr = &party_mon[i];
+ monster_race *r_ptr = real_r_ptr(m_ptr);
+ GAME_TEXT m_name[MAX_NLEN];
+
+ monster_desc(master_ptr, m_name, m_ptr, 0);
+ msg_format(_("%sとはぐれてしまった。", "You have lost sight of %s."), m_name);
+ if (record_named_pet && m_ptr->nickname) {
+ monster_desc(master_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
+ exe_write_diary(master_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name);
+ }
+
+ /* Pre-calculated in precalc_cur_num_of_pet(), but need to decrease */
+ if (r_ptr->cur_num)
+ r_ptr->cur_num--;
+ }
+ }
+
+ /* For accuracy of precalc_cur_num_of_pet() */
+ (void)C_WIPE(party_mon, MAX_PARTY_MON, monster_type);
}
-
/*!
* @brief ユニークモンスターやアーティファクトの所在フロアを更新する / Hack -- Update location of unique monsters and artifacts
* @param cur_floor_id 現在のフロアID
* @return なし
- * @details
+ * @details
* The r_ptr->floor_id and a_ptr->floor_id are not updated correctly\n
* while new floor creation since dungeons may be re-created by\n
* auto-scum option.\n
*/
static void update_unique_artifact(floor_type *floor_ptr, s16b cur_floor_id)
{
- int i;
-
- /* Maintain unique monsters */
- for (i = 1; i < floor_ptr->m_max; i++)
- {
- monster_race *r_ptr;
- monster_type *m_ptr = &floor_ptr->m_list[i];
-
- if (!monster_is_valid(m_ptr)) continue;
-
- /* Extract real monster race */
- r_ptr = real_r_ptr(m_ptr);
-
- /* Memorize location of the unique monster */
- if ((r_ptr->flags1 & RF1_UNIQUE) ||
- (r_ptr->flags7 & RF7_NAZGUL))
- {
- r_ptr->floor_id = cur_floor_id;
- }
- }
-
- /* Maintain artifatcs */
- for (i = 1; i < floor_ptr->o_max; i++)
- {
- object_type *o_ptr = &floor_ptr->o_list[i];
-
- if (!object_is_valid(o_ptr)) continue;
-
- /* Memorize location of the artifact */
- if (object_is_fixed_artifact(o_ptr))
- {
- a_info[o_ptr->name1].floor_id = cur_floor_id;
- }
- }
-}
+ int i;
+ /* Maintain unique monsters */
+ for (i = 1; i < floor_ptr->m_max; i++) {
+ monster_race *r_ptr;
+ monster_type *m_ptr = &floor_ptr->m_list[i];
+
+ if (!monster_is_valid(m_ptr))
+ continue;
+
+ /* Extract real monster race */
+ r_ptr = real_r_ptr(m_ptr);
+
+ /* Memorize location of the unique monster */
+ if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) {
+ r_ptr->floor_id = cur_floor_id;
+ }
+ }
+
+ /* Maintain artifatcs */
+ for (i = 1; i < floor_ptr->o_max; i++) {
+ object_type *o_ptr = &floor_ptr->o_list[i];
+
+ if (!object_is_valid(o_ptr))
+ continue;
+
+ /* Memorize location of the artifact */
+ if (object_is_fixed_artifact(o_ptr)) {
+ a_info[o_ptr->name1].floor_id = cur_floor_id;
+ }
+ }
+}
/*!
* @brief フロア移動時、プレイヤーの移動先モンスターが既にいた場合ランダムな近隣に移動させる / When a monster is at a place where player will return,
*/
static void get_out_monster(player_type *protected_ptr)
{
- int tries = 0;
- POSITION dis = 1;
- POSITION oy = protected_ptr->y;
- POSITION ox = protected_ptr->x;
- floor_type *floor_ptr = protected_ptr->current_floor_ptr;
- MONSTER_IDX m_idx = floor_ptr->grid_array[oy][ox].m_idx;
+ int tries = 0;
+ POSITION dis = 1;
+ POSITION oy = protected_ptr->y;
+ POSITION ox = protected_ptr->x;
+ floor_type *floor_ptr = protected_ptr->current_floor_ptr;
+ MONSTER_IDX m_idx = floor_ptr->grid_array[oy][ox].m_idx;
- /* Nothing to do if no monster */
- if (!m_idx) return;
+ /* Nothing to do if no monster */
+ if (!m_idx)
+ return;
- /* Look until done */
- while (TRUE)
- {
- monster_type *m_ptr;
+ /* Look until done */
+ while (TRUE) {
+ monster_type *m_ptr;
- /* Pick a (possibly illegal) location */
- POSITION ny = rand_spread(oy, dis);
- POSITION nx = rand_spread(ox, dis);
+ /* Pick a (possibly illegal) location */
+ POSITION ny = rand_spread(oy, dis);
+ POSITION nx = rand_spread(ox, dis);
- tries++;
+ tries++;
- /* Stop after 1000 tries */
- if (tries > 10000) return;
+ /* Stop after 1000 tries */
+ if (tries > 10000)
+ return;
- /*
- * Increase distance after doing enough tries
- * compared to area of possible space
- */
- if (tries > 20 * dis * dis) dis++;
+ /*
+ * Increase distance after doing enough tries
+ * compared to area of possible space
+ */
+ if (tries > 20 * dis * dis)
+ dis++;
- /* Ignore illegal locations */
- if (!in_bounds(floor_ptr, ny, nx)) continue;
+ /* Ignore illegal locations */
+ if (!in_bounds(floor_ptr, ny, nx))
+ continue;
- /* Require "empty" floor space */
- if (!is_cave_empty_bold(protected_ptr, ny, nx)) continue;
+ /* Require "empty" floor space */
+ if (!is_cave_empty_bold(protected_ptr, ny, nx))
+ continue;
- /* Hack -- no teleport onto glyph of warding */
- if (is_glyph_grid(&floor_ptr->grid_array[ny][nx])) continue;
- if (is_explosive_rune_grid(&floor_ptr->grid_array[ny][nx])) continue;
+ /* Hack -- no teleport onto glyph of warding */
+ if (is_glyph_grid(&floor_ptr->grid_array[ny][nx]))
+ continue;
+ if (is_explosive_rune_grid(&floor_ptr->grid_array[ny][nx]))
+ continue;
- /* ...nor onto the Pattern */
- if (pattern_tile(floor_ptr, ny, nx)) continue;
+ /* ...nor onto the Pattern */
+ if (pattern_tile(floor_ptr, ny, nx))
+ continue;
- /*** It's a good place ***/
+ /*** It's a good place ***/
- m_ptr = &floor_ptr->m_list[m_idx];
+ m_ptr = &floor_ptr->m_list[m_idx];
- /* Update the old location */
- floor_ptr->grid_array[oy][ox].m_idx = 0;
+ /* Update the old location */
+ floor_ptr->grid_array[oy][ox].m_idx = 0;
- /* Update the new location */
- floor_ptr->grid_array[ny][nx].m_idx = m_idx;
+ /* Update the new location */
+ floor_ptr->grid_array[ny][nx].m_idx = m_idx;
- /* Move the monster */
- m_ptr->fy = ny;
- m_ptr->fx = nx;
+ /* Move the monster */
+ m_ptr->fy = ny;
+ m_ptr->fx = nx;
- /* No need to do update_monster() */
+ /* No need to do update_monster() */
- /* Success */
- return;
- }
+ /* Success */
+ return;
+ }
}
/*!
*/
static void locate_connected_stairs(player_type *creature_ptr, floor_type *floor_ptr, saved_floor_type *sf_ptr, BIT_FLAGS floor_mode)
{
- POSITION x, y, sx = 0, sy = 0;
- POSITION x_table[20];
- POSITION y_table[20];
- int num = 0;
- int i;
-
- /* Search usable stairs */
- for (y = 0; y < floor_ptr->height; y++)
- {
- for (x = 0; x < floor_ptr->width; x++)
- {
- grid_type *g_ptr = &floor_ptr->grid_array[y][x];
- feature_type *f_ptr = &f_info[g_ptr->feat];
- bool ok = FALSE;
-
- if (floor_mode & CFM_UP)
- {
- if (have_flag(f_ptr->flags, FF_LESS) && have_flag(f_ptr->flags, FF_STAIRS) &&
- !have_flag(f_ptr->flags, FF_SPECIAL))
- {
- ok = TRUE;
-
- /* Found fixed stairs? */
- if (g_ptr->special &&
- g_ptr->special == sf_ptr->upper_floor_id)
- {
- sx = x;
- sy = y;
- }
- }
- }
-
- else if (floor_mode & CFM_DOWN)
- {
- if (have_flag(f_ptr->flags, FF_MORE) && have_flag(f_ptr->flags, FF_STAIRS) &&
- !have_flag(f_ptr->flags, FF_SPECIAL))
- {
- ok = TRUE;
-
- /* Found fixed stairs */
- if (g_ptr->special &&
- g_ptr->special == sf_ptr->lower_floor_id)
- {
- sx = x;
- sy = y;
- }
- }
- }
-
- else
- {
- if (have_flag(f_ptr->flags, FF_BLDG))
- {
- ok = TRUE;
- }
- }
-
- if (ok && (num < 20))
- {
- x_table[num] = x;
- y_table[num] = y;
- num++;
- }
- }
- }
-
- if (sx)
- {
- /* Already fixed */
- creature_ptr->y = sy;
- creature_ptr->x = sx;
- }
- else if (!num)
- {
- /* No stairs found! -- No return */
- prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE | CFM_NO_RETURN);
-
- /* Mega Hack -- It's not the stairs you enter. Disable it. */
- if (!feat_uses_special(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat)) floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].special = 0;
- }
- else
- {
- /* Choose random one */
- i = randint0(num);
-
- /* Point stair location */
- creature_ptr->y = y_table[i];
- creature_ptr->x = x_table[i];
- }
+ POSITION x, y, sx = 0, sy = 0;
+ POSITION x_table[20];
+ POSITION y_table[20];
+ int num = 0;
+ int i;
+
+ /* Search usable stairs */
+ for (y = 0; y < floor_ptr->height; y++) {
+ for (x = 0; x < floor_ptr->width; x++) {
+ grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+ feature_type *f_ptr = &f_info[g_ptr->feat];
+ bool ok = FALSE;
+
+ if (floor_mode & CFM_UP) {
+ if (have_flag(f_ptr->flags, FF_LESS) && have_flag(f_ptr->flags, FF_STAIRS) && !have_flag(f_ptr->flags, FF_SPECIAL)) {
+ ok = TRUE;
+
+ /* Found fixed stairs? */
+ if (g_ptr->special && g_ptr->special == sf_ptr->upper_floor_id) {
+ sx = x;
+ sy = y;
+ }
+ }
+ }
+
+ else if (floor_mode & CFM_DOWN) {
+ if (have_flag(f_ptr->flags, FF_MORE) && have_flag(f_ptr->flags, FF_STAIRS) && !have_flag(f_ptr->flags, FF_SPECIAL)) {
+ ok = TRUE;
+
+ /* Found fixed stairs */
+ if (g_ptr->special && g_ptr->special == sf_ptr->lower_floor_id) {
+ sx = x;
+ sy = y;
+ }
+ }
+ }
+
+ else {
+ if (have_flag(f_ptr->flags, FF_BLDG)) {
+ ok = TRUE;
+ }
+ }
+
+ if (ok && (num < 20)) {
+ x_table[num] = x;
+ y_table[num] = y;
+ num++;
+ }
+ }
+ }
+
+ if (sx) {
+ /* Already fixed */
+ creature_ptr->y = sy;
+ creature_ptr->x = sx;
+ } else if (!num) {
+ /* No stairs found! -- No return */
+ prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE | CFM_NO_RETURN);
+
+ /* Mega Hack -- It's not the stairs you enter. Disable it. */
+ if (!feat_uses_special(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat))
+ floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].special = 0;
+ } else {
+ /* Choose random one */
+ i = randint0(num);
+
+ /* Point stair location */
+ creature_ptr->y = y_table[i];
+ creature_ptr->x = x_table[i];
+ }
}
/*!
*/
void leave_floor(player_type *creature_ptr)
{
- grid_type *g_ptr = NULL;
- feature_type *f_ptr;
- saved_floor_type *sf_ptr;
- MONRACE_IDX quest_r_idx = 0;
- DUNGEON_IDX i;
- FLOOR_IDX tmp_floor_idx = 0;
-
- /* Preserve pets and prepare to take these to next floor */
- preserve_pet(creature_ptr);
-
- /* Remove all mirrors without explosion */
- remove_all_mirrors(creature_ptr, FALSE);
-
- if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
-
- /* New floor is not yet prepared */
- new_floor_id = 0;
-
- /* Temporarily get a floor_id (for Arena) */
- if (!creature_ptr->floor_id &&
- (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) &&
- !(creature_ptr->change_floor_mode & CFM_NO_RETURN))
- {
- /* Get temporary floor_id */
- tmp_floor_idx = get_new_floor_id(creature_ptr);
- }
-
- /* Search the quest monster index */
- for (i = 0; i < max_q_idx; i++)
- {
- if ((quest[i].status == QUEST_STATUS_TAKEN) &&
- ((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
- (quest[i].type == QUEST_TYPE_RANDOM)) &&
- (quest[i].level == creature_ptr->current_floor_ptr->dun_level) &&
- (creature_ptr->dungeon_idx == quest[i].dungeon) &&
- !(quest[i].flags & QUEST_FLAG_PRESET))
- {
- quest_r_idx = quest[i].r_idx;
- }
- }
-
- /* Maintain quest monsters */
- for (i = 1; i < creature_ptr->current_floor_ptr->m_max; i++)
- {
- monster_race *r_ptr;
- monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
-
- if (!monster_is_valid(m_ptr)) continue;
-
- /* Only maintain quest monsters */
- if (quest_r_idx != m_ptr->r_idx) continue;
-
- /* Extract real monster race */
- r_ptr = real_r_ptr(m_ptr);
-
- /* Ignore unique monsters */
- if ((r_ptr->flags1 & RF1_UNIQUE) ||
- (r_ptr->flags7 & RF7_NAZGUL)) continue;
-
- /* Delete non-unique quest monsters */
- delete_monster_idx(creature_ptr, i);
- }
-
- /* Check if there is a same item */
- for (i = 0; i < INVEN_PACK; i++)
- {
- object_type *o_ptr = &creature_ptr->inventory_list[i];
-
- if (!object_is_valid(o_ptr)) continue;
-
- /* Delete old memorized location of the artifact */
- if (object_is_fixed_artifact(o_ptr))
- {
- a_info[o_ptr->name1].floor_id = 0;
- }
- }
-
- /* Extract current floor info or NULL */
- sf_ptr = get_sf_ptr(creature_ptr->floor_id);
-
- /* Choose random stairs */
- if ((creature_ptr->change_floor_mode & CFM_RAND_CONNECT) && tmp_floor_idx)
- {
- locate_connected_stairs(creature_ptr, creature_ptr->current_floor_ptr, sf_ptr, creature_ptr->change_floor_mode);
- }
-
- /* Extract new dungeon level */
- if (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS)
- {
- /* Extract stair position */
- g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
- f_ptr = &f_info[g_ptr->feat];
-
- /* Get back to old saved floor? */
- if (g_ptr->special && !have_flag(f_ptr->flags, FF_SPECIAL) && get_sf_ptr(g_ptr->special))
- {
- /* Saved floor is exist. Use it. */
- new_floor_id = g_ptr->special;
- }
-
- /* Mark shaft up/down */
- if (have_flag(f_ptr->flags, FF_STAIRS) && have_flag(f_ptr->flags, FF_SHAFT))
- {
- prepare_change_floor_mode(creature_ptr, CFM_SHAFT);
- }
- }
-
- /* Climb up/down some sort of stairs */
- if (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP))
- {
- int move_num = 0;
-
- /* Extract level movement number */
- if (creature_ptr->change_floor_mode & CFM_DOWN) move_num = 1;
- else if (creature_ptr->change_floor_mode & CFM_UP) move_num = -1;
-
- /* Shafts are deeper than normal stairs */
- if (creature_ptr->change_floor_mode & CFM_SHAFT)
- move_num += SGN(move_num);
-
- /* Get out from or Enter the dungeon */
- if (creature_ptr->change_floor_mode & CFM_DOWN)
- {
- if (!creature_ptr->current_floor_ptr->dun_level)
- move_num = d_info[creature_ptr->dungeon_idx].mindepth;
- }
- else if (creature_ptr->change_floor_mode & CFM_UP)
- {
- if (creature_ptr->current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth)
- move_num = -creature_ptr->current_floor_ptr->dun_level;
- }
-
- creature_ptr->current_floor_ptr->dun_level += move_num;
- }
-
- /* Leaving the dungeon to town */
- if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->dungeon_idx)
- {
- creature_ptr->leaving_dungeon = TRUE;
- if (!vanilla_town && !lite_town)
- {
- creature_ptr->wilderness_y = d_info[creature_ptr->dungeon_idx].dy;
- creature_ptr->wilderness_x = d_info[creature_ptr->dungeon_idx].dx;
- }
- creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
- creature_ptr->dungeon_idx = 0;
-
- /* Reach to the surface -- Clear all saved floors */
- creature_ptr->change_floor_mode &= ~CFM_SAVE_FLOORS; // TODO
- }
-
- /* Kill some old saved floors */
- if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS))
- {
- /* Kill all saved floors */
- for (i = 0; i < MAX_SAVED_FLOORS; i++)
- kill_saved_floor(creature_ptr, &saved_floors[i]);
-
- /* Reset visit_mark count */
- latest_visit_mark = 1;
- }
- else if (creature_ptr->change_floor_mode & CFM_NO_RETURN)
- {
- /* Kill current floor */
- kill_saved_floor(creature_ptr, sf_ptr);
- }
-
- /* No current floor -- Left/Enter dungeon etc... */
- if (!creature_ptr->floor_id)
- {
- /* No longer need to save current floor */
- return;
- }
-
- /* Mark next floor_id on the previous floor */
- if (!new_floor_id)
- {
- /* Get new id */
- new_floor_id = get_new_floor_id(creature_ptr);
-
- /* Connect from here */
- if (g_ptr && !feat_uses_special(g_ptr->feat))
- {
- g_ptr->special = new_floor_id;
- }
- }
-
- /* Fix connection -- level teleportation or trap door */
- if (creature_ptr->change_floor_mode & CFM_RAND_CONNECT)
- {
- if (creature_ptr->change_floor_mode & CFM_UP)
- sf_ptr->upper_floor_id = new_floor_id;
- else if (creature_ptr->change_floor_mode & CFM_DOWN)
- sf_ptr->lower_floor_id = new_floor_id;
- }
-
- /* If you can return, you need to save previous floor */
- if ((creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) &&
- !(creature_ptr->change_floor_mode & CFM_NO_RETURN))
- {
- /* Get out of the my way! */
- get_out_monster(creature_ptr);
-
- /* Record the last visit turn of current floor */
- sf_ptr->last_visit = current_world_ptr->game_turn;
-
- forget_lite(creature_ptr->current_floor_ptr);
- forget_view(creature_ptr->current_floor_ptr);
- clear_mon_lite(creature_ptr->current_floor_ptr);
-
- /* Save current floor */
- if (!save_floor(creature_ptr, sf_ptr, 0))
- {
- /* Save failed -- No return */
- prepare_change_floor_mode(creature_ptr, CFM_NO_RETURN);
-
- /* Kill current floor */
- kill_saved_floor(creature_ptr, get_sf_ptr(creature_ptr->floor_id));
- }
- }
+ grid_type *g_ptr = NULL;
+ feature_type *f_ptr;
+ saved_floor_type *sf_ptr;
+ MONRACE_IDX quest_r_idx = 0;
+ DUNGEON_IDX i;
+ FLOOR_IDX tmp_floor_idx = 0;
+
+ /* Preserve pets and prepare to take these to next floor */
+ preserve_pet(creature_ptr);
+
+ /* Remove all mirrors without explosion */
+ remove_all_mirrors(creature_ptr, FALSE);
+
+ if (creature_ptr->special_defense & NINJA_S_STEALTH)
+ set_superstealth(creature_ptr, FALSE);
+
+ /* New floor is not yet prepared */
+ new_floor_id = 0;
+
+ /* Temporarily get a floor_id (for Arena) */
+ if (!creature_ptr->floor_id && (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) && !(creature_ptr->change_floor_mode & CFM_NO_RETURN)) {
+ /* Get temporary floor_id */
+ tmp_floor_idx = get_new_floor_id(creature_ptr);
+ }
+
+ /* Search the quest monster index */
+ for (i = 0; i < max_q_idx; i++) {
+ if ((quest[i].status == QUEST_STATUS_TAKEN) && ((quest[i].type == QUEST_TYPE_KILL_LEVEL) || (quest[i].type == QUEST_TYPE_RANDOM))
+ && (quest[i].level == creature_ptr->current_floor_ptr->dun_level) && (creature_ptr->dungeon_idx == quest[i].dungeon)
+ && !(quest[i].flags & QUEST_FLAG_PRESET)) {
+ quest_r_idx = quest[i].r_idx;
+ }
+ }
+
+ /* Maintain quest monsters */
+ for (i = 1; i < creature_ptr->current_floor_ptr->m_max; i++) {
+ monster_race *r_ptr;
+ monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
+
+ if (!monster_is_valid(m_ptr))
+ continue;
+
+ /* Only maintain quest monsters */
+ if (quest_r_idx != m_ptr->r_idx)
+ continue;
+
+ /* Extract real monster race */
+ r_ptr = real_r_ptr(m_ptr);
+
+ /* Ignore unique monsters */
+ if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
+ continue;
+
+ /* Delete non-unique quest monsters */
+ delete_monster_idx(creature_ptr, i);
+ }
+
+ /* Check if there is a same item */
+ for (i = 0; i < INVEN_PACK; i++) {
+ object_type *o_ptr = &creature_ptr->inventory_list[i];
+
+ if (!object_is_valid(o_ptr))
+ continue;
+
+ /* Delete old memorized location of the artifact */
+ if (object_is_fixed_artifact(o_ptr)) {
+ a_info[o_ptr->name1].floor_id = 0;
+ }
+ }
+
+ /* Extract current floor info or NULL */
+ sf_ptr = get_sf_ptr(creature_ptr->floor_id);
+
+ /* Choose random stairs */
+ if ((creature_ptr->change_floor_mode & CFM_RAND_CONNECT) && tmp_floor_idx) {
+ locate_connected_stairs(creature_ptr, creature_ptr->current_floor_ptr, sf_ptr, creature_ptr->change_floor_mode);
+ }
+
+ /* Extract new dungeon level */
+ if (creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) {
+ /* Extract stair position */
+ g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
+ f_ptr = &f_info[g_ptr->feat];
+
+ /* Get back to old saved floor? */
+ if (g_ptr->special && !have_flag(f_ptr->flags, FF_SPECIAL) && get_sf_ptr(g_ptr->special)) {
+ /* Saved floor is exist. Use it. */
+ new_floor_id = g_ptr->special;
+ }
+
+ /* Mark shaft up/down */
+ if (have_flag(f_ptr->flags, FF_STAIRS) && have_flag(f_ptr->flags, FF_SHAFT)) {
+ prepare_change_floor_mode(creature_ptr, CFM_SHAFT);
+ }
+ }
+
+ /* Climb up/down some sort of stairs */
+ if (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP)) {
+ int move_num = 0;
+
+ /* Extract level movement number */
+ if (creature_ptr->change_floor_mode & CFM_DOWN)
+ move_num = 1;
+ else if (creature_ptr->change_floor_mode & CFM_UP)
+ move_num = -1;
+
+ /* Shafts are deeper than normal stairs */
+ if (creature_ptr->change_floor_mode & CFM_SHAFT)
+ move_num += SGN(move_num);
+
+ /* Get out from or Enter the dungeon */
+ if (creature_ptr->change_floor_mode & CFM_DOWN) {
+ if (!creature_ptr->current_floor_ptr->dun_level)
+ move_num = d_info[creature_ptr->dungeon_idx].mindepth;
+ } else if (creature_ptr->change_floor_mode & CFM_UP) {
+ if (creature_ptr->current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth)
+ move_num = -creature_ptr->current_floor_ptr->dun_level;
+ }
+
+ creature_ptr->current_floor_ptr->dun_level += move_num;
+ }
+
+ /* Leaving the dungeon to town */
+ if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->dungeon_idx) {
+ creature_ptr->leaving_dungeon = TRUE;
+ if (!vanilla_town && !lite_town) {
+ creature_ptr->wilderness_y = d_info[creature_ptr->dungeon_idx].dy;
+ creature_ptr->wilderness_x = d_info[creature_ptr->dungeon_idx].dx;
+ }
+ creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
+ creature_ptr->dungeon_idx = 0;
+
+ /* Reach to the surface -- Clear all saved floors */
+ creature_ptr->change_floor_mode &= ~CFM_SAVE_FLOORS; // TODO
+ }
+
+ /* Kill some old saved floors */
+ if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS)) {
+ /* Kill all saved floors */
+ for (i = 0; i < MAX_SAVED_FLOORS; i++)
+ kill_saved_floor(creature_ptr, &saved_floors[i]);
+
+ /* Reset visit_mark count */
+ latest_visit_mark = 1;
+ } else if (creature_ptr->change_floor_mode & CFM_NO_RETURN) {
+ /* Kill current floor */
+ kill_saved_floor(creature_ptr, sf_ptr);
+ }
+
+ /* No current floor -- Left/Enter dungeon etc... */
+ if (!creature_ptr->floor_id) {
+ /* No longer need to save current floor */
+ return;
+ }
+
+ /* Mark next floor_id on the previous floor */
+ if (!new_floor_id) {
+ /* Get new id */
+ new_floor_id = get_new_floor_id(creature_ptr);
+
+ /* Connect from here */
+ if (g_ptr && !feat_uses_special(g_ptr->feat)) {
+ g_ptr->special = new_floor_id;
+ }
+ }
+
+ /* Fix connection -- level teleportation or trap door */
+ if (creature_ptr->change_floor_mode & CFM_RAND_CONNECT) {
+ if (creature_ptr->change_floor_mode & CFM_UP)
+ sf_ptr->upper_floor_id = new_floor_id;
+ else if (creature_ptr->change_floor_mode & CFM_DOWN)
+ sf_ptr->lower_floor_id = new_floor_id;
+ }
+
+ /* If you can return, you need to save previous floor */
+ if ((creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) && !(creature_ptr->change_floor_mode & CFM_NO_RETURN)) {
+ /* Get out of the my way! */
+ get_out_monster(creature_ptr);
+
+ /* Record the last visit turn of current floor */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
+
+ forget_lite(creature_ptr->current_floor_ptr);
+ forget_view(creature_ptr->current_floor_ptr);
+ clear_mon_lite(creature_ptr->current_floor_ptr);
+
+ /* Save current floor */
+ if (!save_floor(creature_ptr, sf_ptr, 0)) {
+ /* Save failed -- No return */
+ prepare_change_floor_mode(creature_ptr, CFM_NO_RETURN);
+
+ /* Kill current floor */
+ kill_saved_floor(creature_ptr, get_sf_ptr(creature_ptr->floor_id));
+ }
+ }
}
-
/*!
* @brief フロアの切り替え処理 / Enter new floor.
* @param creature_ptr プレーヤーへの参照ポインタ
*/
void change_floor(player_type *creature_ptr)
{
- saved_floor_type *sf_ptr;
- bool loaded = FALSE;
-
- /* The dungeon is not ready */
- current_world_ptr->character_dungeon = FALSE;
-
- /* No longer in the trap detecteded region */
- creature_ptr->dtrap = FALSE;
-
- /* Mega-Hack -- no panel yet */
- panel_row_min = 0;
- panel_row_max = 0;
- panel_col_min = 0;
- panel_col_max = 0;
-
- /* Mega-Hack -- not ambushed on the wildness? */
- creature_ptr->ambush_flag = FALSE;
-
- /* No saved floors (On the surface etc.) */
- if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) &&
- !(creature_ptr->change_floor_mode & CFM_FIRST_FLOOR))
- {
- generate_floor(creature_ptr);
-
- /* Paranoia -- No new saved floor */
- new_floor_id = 0;
- }
-
- /* In the dungeon */
- else
- {
- /* No floor_id yet */
- if (!new_floor_id)
- {
- /* Get new id */
- new_floor_id = get_new_floor_id(creature_ptr);
- }
-
- /* Pointer for infomations of new floor */
- sf_ptr = get_sf_ptr(new_floor_id);
-
- /* Try to restore old floor */
- if (sf_ptr->last_visit)
- {
- /* Old saved floor is exist */
- if (load_floor(creature_ptr, sf_ptr, 0))
- {
- loaded = TRUE;
-
- /* Forbid return stairs */
- if (creature_ptr->change_floor_mode & CFM_NO_RETURN)
- {
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
-
- if (!feat_uses_special(g_ptr->feat))
- {
- if (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP))
- {
- /* Reset to floor */
- g_ptr->feat = feat_ground_type[randint0(100)];
- }
-
- g_ptr->special = 0;
- }
- }
- }
- }
-
- /*
- * Set lower/upper_floor_id of new floor when the new
- * floor is right-above/right-under the current floor.
- *
- * Stair creation/Teleport level/Trap door will take
- * you the same floor when you used it later again.
- */
- if (creature_ptr->floor_id)
- {
- saved_floor_type *cur_sf_ptr = get_sf_ptr(creature_ptr->floor_id);
-
- if (creature_ptr->change_floor_mode & CFM_UP)
- {
- /* New floor is right-above */
- if (cur_sf_ptr->upper_floor_id == new_floor_id)
- sf_ptr->lower_floor_id = creature_ptr->floor_id;
- }
- else if (creature_ptr->change_floor_mode & CFM_DOWN)
- {
- /* New floor is right-under */
- if (cur_sf_ptr->lower_floor_id == new_floor_id)
- sf_ptr->upper_floor_id = creature_ptr->floor_id;
- }
- }
-
- /* Break connection to killed floor */
- else
- {
- if (creature_ptr->change_floor_mode & CFM_UP)
- sf_ptr->lower_floor_id = 0;
- else if (creature_ptr->change_floor_mode & CFM_DOWN)
- sf_ptr->upper_floor_id = 0;
- }
-
- /* Maintain monsters and artifacts */
- if (loaded)
- {
- MONSTER_IDX i;
- GAME_TURN tmp_last_visit = sf_ptr->last_visit;
- GAME_TURN absence_ticks;
- int alloc_chance = d_info[creature_ptr->dungeon_idx].max_m_alloc_chance;
- GAME_TURN alloc_times;
-
- while (tmp_last_visit > current_world_ptr->game_turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
- absence_ticks = (current_world_ptr->game_turn - tmp_last_visit) / TURNS_PER_TICK;
-
- /* Maintain monsters */
- for (i = 1; i < creature_ptr->current_floor_ptr->m_max; i++)
- {
- monster_race *r_ptr;
- monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
-
- if (!monster_is_valid(m_ptr)) continue;
-
- if (!is_pet(m_ptr))
- {
- /* Restore HP */
- m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
-
- /* Remove timed status (except MTIMED_CSLEEP) */
- (void)set_monster_fast(creature_ptr, i, 0);
- (void)set_monster_slow(creature_ptr, i, 0);
- (void)set_monster_stunned(creature_ptr, i, 0);
- (void)set_monster_confused(creature_ptr, i, 0);
- (void)set_monster_monfear(creature_ptr, i, 0);
- (void)set_monster_invulner(creature_ptr, i, 0, FALSE);
- }
-
- /* Extract real monster race */
- r_ptr = real_r_ptr(m_ptr);
-
- /* Ignore non-unique */
- if (!(r_ptr->flags1 & RF1_UNIQUE) &&
- !(r_ptr->flags7 & RF7_NAZGUL)) continue;
-
- /* Appear at a different floor? */
- if (r_ptr->floor_id != new_floor_id)
- {
- /* Disapper from here */
- delete_monster_idx(creature_ptr, i);
- }
- }
-
- /* Maintain artifatcs */
- for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++)
- {
- object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[i];
-
- if (!object_is_valid(o_ptr)) continue;
-
- /* Ignore non-artifact */
- if (!object_is_fixed_artifact(o_ptr)) continue;
-
- /* Appear at a different floor? */
- if (a_info[o_ptr->name1].floor_id != new_floor_id)
- {
- /* Disappear from here */
- delete_object_idx(creature_ptr, i);
- }
- else
- {
- /* Cancel preserve */
- a_info[o_ptr->name1].cur_num = 1;
- }
- }
-
- (void)place_quest_monsters(creature_ptr);
-
- /* Place some random monsters */
- alloc_times = absence_ticks / alloc_chance;
-
- if (randint0(alloc_chance) < (absence_ticks % alloc_chance))
- alloc_times++;
-
- for (i = 0; i < alloc_times; i++)
- {
- /* Make a (group of) new monster */
- (void)alloc_monster(creature_ptr, 0, 0, summon_specific);
- }
-
- }
-
- /* New floor_id or failed to restore */
- else /* if (!loaded) */
- {
- if (sf_ptr->last_visit)
- {
- /* Temporary file is broken? */
- msg_print(_("階段は行き止まりだった。", "The staircases come to a dead end..."));
-
- /* Create simple dead end */
- build_dead_end(creature_ptr);
-
- /* Break connection */
- if (creature_ptr->change_floor_mode & CFM_UP)
- {
- sf_ptr->upper_floor_id = 0;
- }
- else if (creature_ptr->change_floor_mode & CFM_DOWN)
- {
- sf_ptr->lower_floor_id = 0;
- }
- }
- else
- {
- generate_floor(creature_ptr);
- }
-
- /* Record last visit turn */
- sf_ptr->last_visit = current_world_ptr->game_turn;
-
- /* Set correct dun_level value */
- sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level;
-
- /* Create connected stairs */
- if (!(creature_ptr->change_floor_mode & CFM_NO_RETURN))
- {
- /* Extract stair position */
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
-
- /*** Create connected stairs ***/
-
- /* No stairs down from Quest */
- if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level))
- {
- g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(creature_ptr, feat_down_stair, FF_SHAFT) : feat_down_stair;
- }
-
- /* No stairs up when ironman_downward */
- else if ((creature_ptr->change_floor_mode & CFM_DOWN) && !ironman_downward)
- {
- g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(creature_ptr, feat_up_stair, FF_SHAFT) : feat_up_stair;
- }
-
- /* Paranoia -- Clear mimic */
- g_ptr->mimic = 0;
-
- /* Connect to previous floor */
- g_ptr->special = creature_ptr->floor_id;
- }
- }
-
- /* Arrive at random grid */
- if (creature_ptr->change_floor_mode & (CFM_RAND_PLACE))
- {
- (void)new_player_spot(creature_ptr);
- }
-
- /* You see stairs blocked */
- else if ((creature_ptr->change_floor_mode & CFM_NO_RETURN) && (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP)))
- {
- if (!creature_ptr->blind)
- {
- msg_print(_("突然階段が塞がれてしまった。", "Suddenly the stairs is blocked!"));
- }
- else
- {
- msg_print(_("ゴトゴトと何か音がした。", "You hear some noises."));
- }
- }
-
- /*
- * Update visit mark
- *
- * The "turn" is not always different number because
- * the level teleport doesn't take any turn. Use
- * visit mark instead of last visit turn to find the
- * oldest saved floor.
- */
- sf_ptr->visit_mark = latest_visit_mark++;
- }
-
- /* Place preserved pet monsters */
- place_pet(creature_ptr);
-
- /* Reset travel target place */
- forget_travel_flow(creature_ptr->current_floor_ptr);
-
- /* Hack -- maintain unique and artifacts */
- update_unique_artifact(creature_ptr->current_floor_ptr, new_floor_id);
-
- /* Now the player is in new floor */
- creature_ptr->floor_id = new_floor_id;
-
- /* The dungeon is ready */
- current_world_ptr->character_dungeon = TRUE;
-
- /* Hack -- Munchkin characters always get whole map */
- if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)
- wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
-
- /* Remember when this level was "created" */
- creature_ptr->current_floor_ptr->generated_turn = current_world_ptr->game_turn;
-
- /* No dungeon feeling yet */
- creature_ptr->feeling_turn = creature_ptr->current_floor_ptr->generated_turn;
- creature_ptr->feeling = 0;
-
- /* Clear all flags */
- creature_ptr->change_floor_mode = 0L;
-
- select_floor_music(creature_ptr);
- creature_ptr->change_floor_mode = 0;
+ saved_floor_type *sf_ptr;
+ bool loaded = FALSE;
+
+ /* The dungeon is not ready */
+ current_world_ptr->character_dungeon = FALSE;
+
+ /* No longer in the trap detecteded region */
+ creature_ptr->dtrap = FALSE;
+
+ /* Mega-Hack -- no panel yet */
+ panel_row_min = 0;
+ panel_row_max = 0;
+ panel_col_min = 0;
+ panel_col_max = 0;
+
+ /* Mega-Hack -- not ambushed on the wildness? */
+ creature_ptr->ambush_flag = FALSE;
+
+ /* No saved floors (On the surface etc.) */
+ if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) && !(creature_ptr->change_floor_mode & CFM_FIRST_FLOOR)) {
+ generate_floor(creature_ptr);
+
+ /* Paranoia -- No new saved floor */
+ new_floor_id = 0;
+ }
+
+ /* In the dungeon */
+ else {
+ /* No floor_id yet */
+ if (!new_floor_id) {
+ /* Get new id */
+ new_floor_id = get_new_floor_id(creature_ptr);
+ }
+
+ /* Pointer for infomations of new floor */
+ sf_ptr = get_sf_ptr(new_floor_id);
+
+ /* Try to restore old floor */
+ if (sf_ptr->last_visit) {
+ /* Old saved floor is exist */
+ if (load_floor(creature_ptr, sf_ptr, 0)) {
+ loaded = TRUE;
+
+ /* Forbid return stairs */
+ if (creature_ptr->change_floor_mode & CFM_NO_RETURN) {
+ grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
+
+ if (!feat_uses_special(g_ptr->feat)) {
+ if (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP)) {
+ /* Reset to floor */
+ g_ptr->feat = feat_ground_type[randint0(100)];
+ }
+
+ g_ptr->special = 0;
+ }
+ }
+ }
+ }
+
+ /*
+ * Set lower/upper_floor_id of new floor when the new
+ * floor is right-above/right-under the current floor.
+ *
+ * Stair creation/Teleport level/Trap door will take
+ * you the same floor when you used it later again.
+ */
+ if (creature_ptr->floor_id) {
+ saved_floor_type *cur_sf_ptr = get_sf_ptr(creature_ptr->floor_id);
+
+ if (creature_ptr->change_floor_mode & CFM_UP) {
+ /* New floor is right-above */
+ if (cur_sf_ptr->upper_floor_id == new_floor_id)
+ sf_ptr->lower_floor_id = creature_ptr->floor_id;
+ } else if (creature_ptr->change_floor_mode & CFM_DOWN) {
+ /* New floor is right-under */
+ if (cur_sf_ptr->lower_floor_id == new_floor_id)
+ sf_ptr->upper_floor_id = creature_ptr->floor_id;
+ }
+ }
+
+ /* Break connection to killed floor */
+ else {
+ if (creature_ptr->change_floor_mode & CFM_UP)
+ sf_ptr->lower_floor_id = 0;
+ else if (creature_ptr->change_floor_mode & CFM_DOWN)
+ sf_ptr->upper_floor_id = 0;
+ }
+
+ /* Maintain monsters and artifacts */
+ if (loaded) {
+ MONSTER_IDX i;
+ GAME_TURN tmp_last_visit = sf_ptr->last_visit;
+ GAME_TURN absence_ticks;
+ int alloc_chance = d_info[creature_ptr->dungeon_idx].max_m_alloc_chance;
+ GAME_TURN alloc_times;
+
+ while (tmp_last_visit > current_world_ptr->game_turn)
+ tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
+ absence_ticks = (current_world_ptr->game_turn - tmp_last_visit) / TURNS_PER_TICK;
+
+ /* Maintain monsters */
+ for (i = 1; i < creature_ptr->current_floor_ptr->m_max; i++) {
+ monster_race *r_ptr;
+ monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
+
+ if (!monster_is_valid(m_ptr))
+ continue;
+
+ if (!is_pet(m_ptr)) {
+ /* Restore HP */
+ m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
+
+ /* Remove timed status (except MTIMED_CSLEEP) */
+ (void)set_monster_fast(creature_ptr, i, 0);
+ (void)set_monster_slow(creature_ptr, i, 0);
+ (void)set_monster_stunned(creature_ptr, i, 0);
+ (void)set_monster_confused(creature_ptr, i, 0);
+ (void)set_monster_monfear(creature_ptr, i, 0);
+ (void)set_monster_invulner(creature_ptr, i, 0, FALSE);
+ }
+
+ /* Extract real monster race */
+ r_ptr = real_r_ptr(m_ptr);
+
+ /* Ignore non-unique */
+ if (!(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_NAZGUL))
+ continue;
+
+ /* Appear at a different floor? */
+ if (r_ptr->floor_id != new_floor_id) {
+ /* Disapper from here */
+ delete_monster_idx(creature_ptr, i);
+ }
+ }
+
+ /* Maintain artifatcs */
+ for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++) {
+ object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[i];
+
+ if (!object_is_valid(o_ptr))
+ continue;
+
+ /* Ignore non-artifact */
+ if (!object_is_fixed_artifact(o_ptr))
+ continue;
+
+ /* Appear at a different floor? */
+ if (a_info[o_ptr->name1].floor_id != new_floor_id) {
+ /* Disappear from here */
+ delete_object_idx(creature_ptr, i);
+ } else {
+ /* Cancel preserve */
+ a_info[o_ptr->name1].cur_num = 1;
+ }
+ }
+
+ (void)place_quest_monsters(creature_ptr);
+
+ /* Place some random monsters */
+ alloc_times = absence_ticks / alloc_chance;
+
+ if (randint0(alloc_chance) < (absence_ticks % alloc_chance))
+ alloc_times++;
+
+ for (i = 0; i < alloc_times; i++) {
+ /* Make a (group of) new monster */
+ (void)alloc_monster(creature_ptr, 0, 0, summon_specific);
+ }
+
+ }
+
+ /* New floor_id or failed to restore */
+ else /* if (!loaded) */
+ {
+ if (sf_ptr->last_visit) {
+ /* Temporary file is broken? */
+ msg_print(_("階段は行き止まりだった。", "The staircases come to a dead end..."));
+
+ /* Create simple dead end */
+ build_dead_end(creature_ptr);
+
+ /* Break connection */
+ if (creature_ptr->change_floor_mode & CFM_UP) {
+ sf_ptr->upper_floor_id = 0;
+ } else if (creature_ptr->change_floor_mode & CFM_DOWN) {
+ sf_ptr->lower_floor_id = 0;
+ }
+ } else {
+ generate_floor(creature_ptr);
+ }
+
+ /* Record last visit turn */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
+
+ /* Set correct dun_level value */
+ sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level;
+
+ /* Create connected stairs */
+ if (!(creature_ptr->change_floor_mode & CFM_NO_RETURN)) {
+ /* Extract stair position */
+ grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
+
+ /*** Create connected stairs ***/
+
+ /* No stairs down from Quest */
+ if ((creature_ptr->change_floor_mode & CFM_UP) && !quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level)) {
+ g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(creature_ptr, feat_down_stair, FF_SHAFT) : feat_down_stair;
+ }
+
+ /* No stairs up when ironman_downward */
+ else if ((creature_ptr->change_floor_mode & CFM_DOWN) && !ironman_downward) {
+ g_ptr->feat = (creature_ptr->change_floor_mode & CFM_SHAFT) ? feat_state(creature_ptr, feat_up_stair, FF_SHAFT) : feat_up_stair;
+ }
+
+ /* Paranoia -- Clear mimic */
+ g_ptr->mimic = 0;
+
+ /* Connect to previous floor */
+ g_ptr->special = creature_ptr->floor_id;
+ }
+ }
+
+ /* Arrive at random grid */
+ if (creature_ptr->change_floor_mode & (CFM_RAND_PLACE)) {
+ (void)new_player_spot(creature_ptr);
+ }
+
+ /* You see stairs blocked */
+ else if ((creature_ptr->change_floor_mode & CFM_NO_RETURN) && (creature_ptr->change_floor_mode & (CFM_DOWN | CFM_UP))) {
+ if (!creature_ptr->blind) {
+ msg_print(_("突然階段が塞がれてしまった。", "Suddenly the stairs is blocked!"));
+ } else {
+ msg_print(_("ゴトゴトと何か音がした。", "You hear some noises."));
+ }
+ }
+
+ /*
+ * Update visit mark
+ *
+ * The "turn" is not always different number because
+ * the level teleport doesn't take any turn. Use
+ * visit mark instead of last visit turn to find the
+ * oldest saved floor.
+ */
+ sf_ptr->visit_mark = latest_visit_mark++;
+ }
+
+ /* Place preserved pet monsters */
+ place_pet(creature_ptr);
+
+ /* Reset travel target place */
+ forget_travel_flow(creature_ptr->current_floor_ptr);
+
+ /* Hack -- maintain unique and artifacts */
+ update_unique_artifact(creature_ptr->current_floor_ptr, new_floor_id);
+
+ /* Now the player is in new floor */
+ creature_ptr->floor_id = new_floor_id;
+
+ /* The dungeon is ready */
+ current_world_ptr->character_dungeon = TRUE;
+
+ /* Hack -- Munchkin characters always get whole map */
+ if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)
+ wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
+
+ /* Remember when this level was "created" */
+ creature_ptr->current_floor_ptr->generated_turn = current_world_ptr->game_turn;
+
+ /* No dungeon feeling yet */
+ creature_ptr->feeling_turn = creature_ptr->current_floor_ptr->generated_turn;
+ creature_ptr->feeling = 0;
+
+ /* Clear all flags */
+ creature_ptr->change_floor_mode = 0L;
+
+ select_floor_music(creature_ptr);
+ creature_ptr->change_floor_mode = 0;
}
+++ /dev/null
-/*!
- * @file save.c
- * @brief セーブファイル書き込み処理 / Purpose: interact with savefiles
- * @date 2014/07/12
- * @author
- * <pre>
- * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies. Other copyrights may also apply.
- * </pre>
- */
-
-#include "io/save.h"
-#include "birth/quick-start.h"
-#include "cmd-building/cmd-building.h"
-#include "util/sort.h"
-#include "dungeon/dungeon.h"
-#include "dungeon/quest.h"
-#include "floor/floor-events.h"
-#include "floor/floor-town.h"
-#include "floor/floor.h"
-#include "floor/wild.h"
-#include "game-option/birth-options.h"
-#include "game-option/cheat-options.h"
-#include "game-option/option-flags.h"
-#include "game-option/option-types-table.h"
-#include "game-option/runtime-arguments.h"
-#include "game-option/special-options.h"
-#include "game-option/text-display-options.h"
-#include "grid/grid.h"
-#include "inventory/inventory-slot-types.h"
-#include "io/load.h"
-#include "io/report.h"
-#include "io/uid-checker.h"
-#include "monster-race/monster-race.h"
-#include "monster/monster-compaction.h"
-#include "monster/monster-info.h"
-#include "monster/monster-status.h"
-#include "object-enchant/artifact.h"
-#include "object/object-kind.h"
-#include "store/store-util.h"
-#include "store/store.h"
-#include "system/angband-version.h"
-#include "util/angband-files.h"
-#include "util/quarks.h"
-#include "view/display-messages.h"
-#include "world/world.h"
-
- /*
- * Some "local" parameters, used to help write savefiles
- */
-
-static FILE *fff; /* Current save "file" */
-static byte xor_byte; /* Simple encryption */
-static u32b v_stamp = 0L; /* A simple "checksum" on the actual values */
-static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */
-
-/*!
- * @brief 1バイトをファイルに書き込む / These functions place information into a savefile a byte at a time
- * @param v 書き込むバイト値
- * @return なし
- */
-static void sf_put(byte v)
-{
- /* Encode the value, write a character */
- xor_byte ^= v;
- (void)putc((int)xor_byte, fff);
-
- /* Maintain the checksum info */
- v_stamp += v;
- x_stamp += xor_byte;
-}
-
-
-/*!
- * @brief 1バイトをファイルに書き込む(sf_put()の糖衣)
- * @param v 書き込むバイト
- * @return なし
- */
-static void wr_byte(byte v)
-{
- sf_put(v);
-}
-
-
-/*!
- * @brief 符号なし16ビットをファイルに書き込む
- * @param v 書き込む符号なし16bit値
- * @return なし
- */
-static void wr_u16b(u16b v)
-{
- sf_put((byte)(v & 0xFF));
- sf_put((byte)((v >> 8) & 0xFF));
-}
-
-
-/*!
- * @brief 符号あり16ビットをファイルに書き込む
- * @param v 書き込む符号あり16bit値
- * @return なし
- */
-static void wr_s16b(s16b v)
-{
- wr_u16b((u16b)v);
-}
-
-
-/*!
- * @brief 符号なし32ビットをファイルに書き込む
- * @param v 書き込む符号なし32bit値
- * @return なし
- */
-static void wr_u32b(u32b v)
-{
- sf_put((byte)(v & 0xFF));
- sf_put((byte)((v >> 8) & 0xFF));
- sf_put((byte)((v >> 16) & 0xFF));
- sf_put((byte)((v >> 24) & 0xFF));
-}
-
-
-/*!
- * @brief 符号あり32ビットをファイルに書き込む
- * @param v 書き込む符号あり32bit値
- * @return なし
- */
-static void wr_s32b(s32b v)
-{
- wr_u32b((u32b)v);
-}
-
-
-/*!
- * @brief 文字列をファイルに書き込む
- * @param str 書き込む文字列
- * @return なし
- */
-static void wr_string(concptr str)
-{
- while (*str)
- {
- wr_byte(*str);
- str++;
- }
- wr_byte(*str);
-}
-
-
-/*
- * These functions write info in larger logical records
- */
-
-
- /*!
- * @brief アイテムオブジェクトを書き込む / Write an "item" record
- * @param o_ptr アイテムオブジェクト保存元ポインタ
- * @return なし
- */
-static void wr_item(object_type *o_ptr)
-{
- BIT_FLAGS flags = 0x00000000;
-
- if (o_ptr->pval) flags |= SAVE_ITEM_PVAL;
- if (o_ptr->discount) flags |= SAVE_ITEM_DISCOUNT;
- if (o_ptr->number != 1) flags |= SAVE_ITEM_NUMBER;
- if (o_ptr->name1) flags |= SAVE_ITEM_NAME1;
- if (o_ptr->name2) flags |= SAVE_ITEM_NAME2;
- if (o_ptr->timeout) flags |= SAVE_ITEM_TIMEOUT;
- if (o_ptr->to_h) flags |= SAVE_ITEM_TO_H;
- if (o_ptr->to_d) flags |= SAVE_ITEM_TO_D;
- if (o_ptr->to_a) flags |= SAVE_ITEM_TO_A;
- if (o_ptr->ac) flags |= SAVE_ITEM_AC;
- if (o_ptr->dd) flags |= SAVE_ITEM_DD;
- if (o_ptr->ds) flags |= SAVE_ITEM_DS;
- if (o_ptr->ident) flags |= SAVE_ITEM_IDENT;
- if (o_ptr->marked) flags |= SAVE_ITEM_MARKED;
- if (o_ptr->art_flags[0]) flags |= SAVE_ITEM_ART_FLAGS0;
- if (o_ptr->art_flags[1]) flags |= SAVE_ITEM_ART_FLAGS1;
- if (o_ptr->art_flags[2]) flags |= SAVE_ITEM_ART_FLAGS2;
- if (o_ptr->art_flags[3]) flags |= SAVE_ITEM_ART_FLAGS3;
- if (o_ptr->art_flags[4]) flags |= SAVE_ITEM_ART_FLAGS4;
- if (o_ptr->curse_flags) flags |= SAVE_ITEM_CURSE_FLAGS;
- if (o_ptr->held_m_idx) flags |= SAVE_ITEM_HELD_M_IDX;
- if (o_ptr->xtra1) flags |= SAVE_ITEM_XTRA1;
- if (o_ptr->xtra2) flags |= SAVE_ITEM_XTRA2;
- if (o_ptr->xtra3) flags |= SAVE_ITEM_XTRA3;
- if (o_ptr->xtra4) flags |= SAVE_ITEM_XTRA4;
- if (o_ptr->xtra5) flags |= SAVE_ITEM_XTRA5;
- if (o_ptr->feeling) flags |= SAVE_ITEM_FEELING;
- if (o_ptr->inscription) flags |= SAVE_ITEM_INSCRIPTION;
- if (o_ptr->art_name) flags |= SAVE_ITEM_ART_NAME;
-
- /*** Item save flags ***/
- wr_u32b(flags);
-
- /*** Write only un-obvious elements ***/
- wr_s16b(o_ptr->k_idx);
-
- wr_byte((byte)o_ptr->iy);
- wr_byte((byte)o_ptr->ix);
-
- if (flags & SAVE_ITEM_PVAL) wr_s16b(o_ptr->pval);
-
- if (flags & SAVE_ITEM_DISCOUNT) wr_byte(o_ptr->discount);
- if (flags & SAVE_ITEM_NUMBER) wr_byte((byte)o_ptr->number);
-
- wr_s16b((s16b)o_ptr->weight);
-
- if (flags & SAVE_ITEM_NAME1) wr_byte((byte)o_ptr->name1);
- if (flags & SAVE_ITEM_NAME2) wr_byte((byte)o_ptr->name2);
- if (flags & SAVE_ITEM_TIMEOUT) wr_s16b(o_ptr->timeout);
-
- if (flags & SAVE_ITEM_TO_H) wr_s16b(o_ptr->to_h);
- if (flags & SAVE_ITEM_TO_D) wr_s16b((s16b)o_ptr->to_d);
- if (flags & SAVE_ITEM_TO_A) wr_s16b(o_ptr->to_a);
- if (flags & SAVE_ITEM_AC) wr_s16b(o_ptr->ac);
- if (flags & SAVE_ITEM_DD) wr_byte((byte)o_ptr->dd);
- if (flags & SAVE_ITEM_DS) wr_byte((byte)o_ptr->ds);
-
- if (flags & SAVE_ITEM_IDENT) wr_byte(o_ptr->ident);
-
- if (flags & SAVE_ITEM_MARKED) wr_byte(o_ptr->marked);
-
- if (flags & SAVE_ITEM_ART_FLAGS0) wr_u32b(o_ptr->art_flags[0]);
- if (flags & SAVE_ITEM_ART_FLAGS1) wr_u32b(o_ptr->art_flags[1]);
- if (flags & SAVE_ITEM_ART_FLAGS2) wr_u32b(o_ptr->art_flags[2]);
- if (flags & SAVE_ITEM_ART_FLAGS3) wr_u32b(o_ptr->art_flags[3]);
- if (flags & SAVE_ITEM_ART_FLAGS4) wr_u32b(o_ptr->art_flags[4]);
-
- if (flags & SAVE_ITEM_CURSE_FLAGS) wr_u32b(o_ptr->curse_flags);
-
- /* Held by monster index */
- if (flags & SAVE_ITEM_HELD_M_IDX) wr_s16b(o_ptr->held_m_idx);
-
- /* Extra information */
- if (flags & SAVE_ITEM_XTRA1) wr_byte(o_ptr->xtra1);
- if (flags & SAVE_ITEM_XTRA2) wr_byte(o_ptr->xtra2);
- if (flags & SAVE_ITEM_XTRA3) wr_byte(o_ptr->xtra3);
- if (flags & SAVE_ITEM_XTRA4) wr_s16b(o_ptr->xtra4);
- if (flags & SAVE_ITEM_XTRA5) wr_s16b(o_ptr->xtra5);
-
- /* Feelings */
- if (flags & SAVE_ITEM_FEELING) wr_byte(o_ptr->feeling);
-
- if (flags & SAVE_ITEM_INSCRIPTION) wr_string(quark_str(o_ptr->inscription));
- if (flags & SAVE_ITEM_ART_NAME) wr_string(quark_str(o_ptr->art_name));
-}
-
-
-/*!
- * @brief モンスター情報を書き込む / Write a "monster" record
- * @param m_ptr モンスター情報保存元ポインタ
- * @return なし
- */
-static void wr_monster(monster_type *m_ptr)
-{
- BIT_FLAGS flags = 0x00000000;
- if (!is_original_ap(m_ptr)) flags |= SAVE_MON_AP_R_IDX;
- if (m_ptr->sub_align) flags |= SAVE_MON_SUB_ALIGN;
- if (monster_csleep_remaining(m_ptr)) flags |= SAVE_MON_CSLEEP;
- if (monster_fast_remaining(m_ptr)) flags |= SAVE_MON_FAST;
- if (monster_slow_remaining(m_ptr)) flags |= SAVE_MON_SLOW;
- if (monster_stunned_remaining(m_ptr)) flags |= SAVE_MON_STUNNED;
- if (monster_confused_remaining(m_ptr)) flags |= SAVE_MON_CONFUSED;
- if (monster_fear_remaining(m_ptr)) flags |= SAVE_MON_MONFEAR;
- if (m_ptr->target_y) flags |= SAVE_MON_TARGET_Y;
- if (m_ptr->target_x) flags |= SAVE_MON_TARGET_X;
- if (monster_invulner_remaining(m_ptr)) flags |= SAVE_MON_INVULNER;
- if (m_ptr->smart) flags |= SAVE_MON_SMART;
- if (m_ptr->exp) flags |= SAVE_MON_EXP;
- if (m_ptr->mflag2) flags |= SAVE_MON_MFLAG2;
- if (m_ptr->nickname) flags |= SAVE_MON_NICKNAME;
- if (m_ptr->parent_m_idx) flags |= SAVE_MON_PARENT;
-
- /*** Monster save flags ***/
- wr_u32b(flags);
-
- /*** Write only un-obvious elements ***/
- wr_s16b(m_ptr->r_idx);
- wr_byte((byte)m_ptr->fy);
- wr_byte((byte)m_ptr->fx);
- wr_s16b((s16b)m_ptr->hp);
- wr_s16b((s16b)m_ptr->maxhp);
- wr_s16b((s16b)m_ptr->max_maxhp);
- wr_u32b(m_ptr->dealt_damage);
-
- /* Monster race index of its appearance */
- if (flags & SAVE_MON_AP_R_IDX) wr_s16b(m_ptr->ap_r_idx);
-
- if (flags & SAVE_MON_SUB_ALIGN) wr_byte(m_ptr->sub_align);
- if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]);
-
- wr_byte((byte)m_ptr->mspeed);
- wr_s16b(m_ptr->energy_need);
-
- byte tmp8u;
- if (flags & SAVE_MON_FAST)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_FAST];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_SLOW)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_SLOW];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_STUNNED)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_STUNNED];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_CONFUSED)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_CONFUSED];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_MONFEAR)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_MONFEAR];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_TARGET_Y) wr_s16b((s16b)m_ptr->target_y);
- if (flags & SAVE_MON_TARGET_X) wr_s16b((s16b)m_ptr->target_x);
- if (flags & SAVE_MON_INVULNER)
- {
- tmp8u = (byte)m_ptr->mtimed[MTIMED_INVULNER];
- wr_byte(tmp8u);
- }
- if (flags & SAVE_MON_SMART) wr_u32b(m_ptr->smart);
- if (flags & SAVE_MON_EXP) wr_u32b(m_ptr->exp);
- if (flags & SAVE_MON_MFLAG2) wr_byte(m_ptr->mflag2);
- if (flags & SAVE_MON_NICKNAME) wr_string(quark_str(m_ptr->nickname));
- if (flags & SAVE_MON_PARENT) wr_s16b(m_ptr->parent_m_idx);
-}
-
-
-/*!
- * @brief モンスターの思い出を書き込む / Write a "lore" record
- * @param r_idx モンスター種族ID
- * @return なし
- */
-static void wr_lore(MONRACE_IDX r_idx)
-{
- /* Count sights/deaths/kills */
- monster_race *r_ptr = &r_info[r_idx];
- wr_s16b((s16b)r_ptr->r_sights);
- wr_s16b((s16b)r_ptr->r_deaths);
- wr_s16b((s16b)r_ptr->r_pkills);
- wr_s16b((s16b)r_ptr->r_akills);
- wr_s16b((s16b)r_ptr->r_tkills);
-
- /* Count wakes and ignores */
- wr_byte(r_ptr->r_wake);
- wr_byte(r_ptr->r_ignore);
-
- /* Extra stuff */
- wr_byte(r_ptr->r_xtra1);
- wr_byte(r_ptr->r_xtra2);
-
- /* Count drops */
- wr_byte((byte)r_ptr->r_drop_gold);
- wr_byte((byte)r_ptr->r_drop_item);
-
- /* Count spells */
- wr_byte(0); /* unused now */
- wr_byte(r_ptr->r_cast_spell);
-
- /* Count blows of each type */
- wr_byte(r_ptr->r_blows[0]);
- wr_byte(r_ptr->r_blows[1]);
- wr_byte(r_ptr->r_blows[2]);
- wr_byte(r_ptr->r_blows[3]);
-
- /* Memorize flags */
- wr_u32b(r_ptr->r_flags1);
- wr_u32b(r_ptr->r_flags2);
- wr_u32b(r_ptr->r_flags3);
- wr_u32b(r_ptr->r_flags4);
- wr_u32b(r_ptr->r_flags5);
- wr_u32b(r_ptr->r_flags6);
- wr_u32b(r_ptr->r_flagsr);
-
- /* Monster limit per level */
- wr_byte((byte)r_ptr->max_num);
-
- /* Location in saved floor */
- wr_s16b(r_ptr->floor_id);
-
- wr_byte(0);
-}
-
-
-/*!
- * @brief その他のゲーム情報を書き込む(実質はアイテムの鑑定情報のみ) / Write an "xtra" record
- * @param k_idx ベースアイテムのID
- * @return なし
- */
-static void wr_xtra(KIND_OBJECT_IDX k_idx)
-{
- byte tmp8u = 0;
-
- object_kind *k_ptr = &k_info[k_idx];
-
- if (k_ptr->aware) tmp8u |= 0x01;
- if (k_ptr->tried) tmp8u |= 0x02;
-
- wr_byte(tmp8u);
-}
-
-
-/*!
- * @brief セーブデータに店舗情報を書き込む / Write a "store" record
- * @param store_ptr 店舗情報の参照ポインタ
- * @return なし
- */
-static void wr_store(store_type *store_ptr)
-{
- /* Save the "open" counter */
- wr_u32b(store_ptr->store_open);
-
- /* Save the "insults" */
- wr_s16b(store_ptr->insult_cur);
-
- /* Save the current owner */
- wr_byte(store_ptr->owner);
-
- /* Save the stock size */
- wr_s16b(store_ptr->stock_num);
-
- /* Save the "haggle" info */
- wr_s16b(store_ptr->good_buy);
- wr_s16b(store_ptr->bad_buy);
-
- wr_s32b(store_ptr->last_visit);
-
- /* Save the stock */
- for (int j = 0; j < store_ptr->stock_num; j++)
- {
- /* Save each item in stock */
- wr_item(&store_ptr->stock[j]);
- }
-}
-
-
-/*!
- * @brief セーブデータに乱数情報を書き込む / Write RNG state
- * @return 常に0(成功を返す)
- */
-static errr wr_randomizer(void)
-{
- wr_u16b(0);
- wr_u16b(Rand_place);
-
- for (int i = 0; i < RAND_DEG; i++)
- {
- wr_u32b(Rand_state[i]);
- }
-
- return 0;
-}
-
-
-/*!
- * @brief ゲームオプション情報を書き込む / Write the "options"
- * @return なし
- */
-static void wr_options(void)
-{
- for (int i = 0; i < 4; i++) wr_u32b(0L);
-
- /*** Special options ***/
- /* Write "delay_factor" */
- wr_byte(delay_factor);
-
- /* Write "hitpoint_warn" */
- wr_byte(hitpoint_warn);
-
- /* Write "mana_warn" */
- wr_byte(mana_warn);
-
- /*** Cheating options ***/
-
- u16b c = 0;
- if (current_world_ptr->wizard) c |= 0x0002;
-
- if (cheat_sight) c |= 0x0040;
- if (cheat_turn) c |= 0x0080;
-
- if (cheat_peek) c |= 0x0100;
- if (cheat_hear) c |= 0x0200;
- if (cheat_room) c |= 0x0400;
- if (cheat_xtra) c |= 0x0800;
- if (cheat_know) c |= 0x1000;
- if (cheat_live) c |= 0x2000;
- if (cheat_save) c |= 0x4000;
- if (cheat_diary_output) c |= 0x8000;
-
- wr_u16b(c);
-
- /* Autosave info */
- wr_byte(autosave_l);
- wr_byte(autosave_t);
- wr_s16b(autosave_freq);
-
- /*** Extract options ***/
- /* Analyze the options */
- for (int i = 0; option_info[i].o_desc; i++)
- {
- int os = option_info[i].o_set;
- int ob = option_info[i].o_bit;
-
- /* Process real entries */
- if (!option_info[i].o_var) continue;
-
- if (*option_info[i].o_var)
- {
- option_flag[os] |= (1L << ob);
- }
- else
- {
- option_flag[os] &= ~(1L << ob);
- }
- }
-
- /*** Normal options ***/
- /* Dump the flags */
- for (int i = 0; i < 8; i++) wr_u32b(option_flag[i]);
-
- /* Dump the masks */
- for (int i = 0; i < 8; i++) wr_u32b(option_mask[i]);
-
- /*** Window options ***/
- /* Dump the flags */
- for (int i = 0; i < 8; i++) wr_u32b(window_flag[i]);
-
- /* Dump the masks */
- for (int i = 0; i < 8; i++) wr_u32b(window_mask[i]);
-}
-
-
-/*!
- * @brief ダミー情報スキップを書き込む / Hack -- Write the "ghost" info
- * @return なし
- */
-static void wr_ghost(void)
-{
- wr_string(_("不正なゴースト", "Broken Ghost"));
-
- /* Hack -- stupid data */
- for (int i = 0; i < 60; i++) wr_byte(0);
-}
-
-
-/*!
- * @brief クイック・スタート情報を書き込む / Save quick start data
- * @return なし
- */
-static void save_quick_start(void)
-{
- wr_byte(previous_char.psex);
- wr_byte((byte)previous_char.prace);
- wr_byte((byte)previous_char.pclass);
- wr_byte((byte)previous_char.pseikaku);
- wr_byte((byte)previous_char.realm1);
- wr_byte((byte)previous_char.realm2);
-
- wr_s16b(previous_char.age);
- wr_s16b(previous_char.ht);
- wr_s16b(previous_char.wt);
- wr_s16b(previous_char.sc);
- wr_s32b(previous_char.au);
-
- for (int i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max[i]);
- for (int i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max_max[i]);
-
- for (int i = 0; i < PY_MAX_LEVEL; i++) wr_s16b((s16b)previous_char.player_hp[i]);
-
- wr_s16b(previous_char.chaos_patron);
-
- for (int i = 0; i < 8; i++) wr_s16b(previous_char.vir_types[i]);
-
- for (int i = 0; i < 4; i++) wr_string(previous_char.history[i]);
-
- /* UNUSED : Was number of random quests */
- wr_byte(0);
-
- /* No quick start after using debug mode or cheat options */
- if (current_world_ptr->noscore) previous_char.quick_ok = FALSE;
-
- wr_byte((byte)previous_char.quick_ok);
-}
-
-
-/*!
- * @brief その他の情報を書き込む / Write some "extra" info
- * @return なし
- */
-static void wr_extra(player_type *creature_ptr)
-{
- wr_string(creature_ptr->name);
- wr_string(creature_ptr->died_from);
- wr_string(creature_ptr->last_message ? creature_ptr->last_message : "");
-
- save_quick_start();
-
- for (int i = 0; i < 4; i++)
- {
- wr_string(creature_ptr->history[i]);
- }
-
- /* Race/Class/Gender/Spells */
- wr_byte((byte)creature_ptr->prace);
- wr_byte((byte)creature_ptr->pclass);
- wr_byte((byte)creature_ptr->pseikaku);
- wr_byte((byte)creature_ptr->psex);
- wr_byte((byte)creature_ptr->realm1);
- wr_byte((byte)creature_ptr->realm2);
- wr_byte(0);
-
- wr_byte((byte)creature_ptr->hitdie);
- wr_u16b(creature_ptr->expfact);
-
- wr_s16b(creature_ptr->age);
- wr_s16b(creature_ptr->ht);
- wr_s16b(creature_ptr->wt);
-
- /* Dump the stats (maximum and current) */
- for (int i = 0; i < A_MAX; ++i) wr_s16b(creature_ptr->stat_max[i]);
- for (int i = 0; i < A_MAX; ++i) wr_s16b(creature_ptr->stat_max_max[i]);
- for (int i = 0; i < A_MAX; ++i) wr_s16b(creature_ptr->stat_cur[i]);
-
- /* Ignore the transient stats */
- for (int i = 0; i < 12; ++i) wr_s16b(0);
-
- wr_u32b(creature_ptr->au);
-
- wr_u32b(creature_ptr->max_exp);
- wr_u32b(creature_ptr->max_max_exp);
- wr_u32b(creature_ptr->exp);
- wr_u32b(creature_ptr->exp_frac);
- wr_s16b(creature_ptr->lev);
-
- for (int i = 0; i < 64; i++) wr_s16b(creature_ptr->spell_exp[i]);
- for (int i = 0; i < 5; i++)
- for (int j = 0; j < 64; j++)
- wr_s16b(creature_ptr->weapon_exp[i][j]);
-
- for (int i = 0; i < GINOU_MAX; i++) wr_s16b(creature_ptr->skill_exp[i]);
- for (int i = 0; i < 108; i++) wr_s32b(creature_ptr->magic_num1[i]);
- for (int i = 0; i < 108; i++) wr_byte(creature_ptr->magic_num2[i]);
-
- wr_byte((byte)creature_ptr->start_race);
- wr_s32b(creature_ptr->old_race1);
- wr_s32b(creature_ptr->old_race2);
- wr_s16b(creature_ptr->old_realm);
-
- for (int i = 0; i < MAX_MANE; i++)
- {
- wr_s16b((s16b)creature_ptr->mane_spell[i]);
- wr_s16b((s16b)creature_ptr->mane_dam[i]);
- }
-
- wr_s16b(creature_ptr->mane_num);
-
- for (int i = 0; i < MAX_BOUNTY; i++)
- {
- wr_s16b(current_world_ptr->bounty_r_idx[i]);
- }
-
- for (int i = 0; i < 4; i++)
- {
- wr_s16b(battle_mon[i]);
- wr_u32b(mon_odds[i]);
- }
-
- wr_s16b(creature_ptr->town_num); /* -KMW- */
-
- /* Write arena and rewards information -KMW- */
- wr_s16b(creature_ptr->arena_number);
- wr_s16b(creature_ptr->current_floor_ptr->inside_arena);
- wr_s16b(creature_ptr->current_floor_ptr->inside_quest);
- wr_s16b(creature_ptr->phase_out);
- wr_byte(creature_ptr->exit_bldg);
- wr_byte(0); /* Unused */
-
- wr_s16b((s16b)creature_ptr->oldpx);
- wr_s16b((s16b)creature_ptr->oldpy);
-
- /* Was number of creature_ptr->rewards[] */
- wr_s16b(0);
-
- wr_s32b(creature_ptr->mhp);
- wr_s32b(creature_ptr->chp);
- wr_u32b(creature_ptr->chp_frac);
-
- wr_s32b(creature_ptr->msp);
- wr_s32b(creature_ptr->csp);
- wr_u32b(creature_ptr->csp_frac);
-
- /* Max Player and Dungeon Levels */
- wr_s16b(creature_ptr->max_plv);
- byte tmp8u = (byte)current_world_ptr->max_d_idx;
- wr_byte(tmp8u);
- for (int i = 0; i < tmp8u; i++)
- wr_s16b((s16b)max_dlv[i]);
-
- /* More info */
- wr_s16b(0);
- wr_s16b(0);
- wr_s16b(0);
- wr_s16b(0);
- wr_s16b(creature_ptr->sc);
- wr_s16b(creature_ptr->concent);
-
- wr_s16b(0); /* old "rest" */
- wr_s16b(creature_ptr->blind);
- wr_s16b(creature_ptr->paralyzed);
- wr_s16b(creature_ptr->confused);
- wr_s16b(creature_ptr->food);
- wr_s16b(0); /* old "food_digested" */
- wr_s16b(0); /* old "protection" */
- wr_s16b(creature_ptr->energy_need);
- wr_s16b(creature_ptr->enchant_energy_need);
- wr_s16b(creature_ptr->fast);
- wr_s16b(creature_ptr->slow);
- wr_s16b(creature_ptr->afraid);
- wr_s16b(creature_ptr->cut);
- wr_s16b(creature_ptr->stun);
- wr_s16b(creature_ptr->poisoned);
- wr_s16b(creature_ptr->image);
- wr_s16b(creature_ptr->protevil);
- wr_s16b(creature_ptr->invuln);
- wr_s16b(creature_ptr->ult_res);
- wr_s16b(creature_ptr->hero);
- wr_s16b(creature_ptr->shero);
- wr_s16b(creature_ptr->shield);
- wr_s16b(creature_ptr->blessed);
- wr_s16b(creature_ptr->tim_invis);
- wr_s16b(creature_ptr->word_recall);
- wr_s16b(creature_ptr->recall_dungeon);
- wr_s16b(creature_ptr->alter_reality);
- wr_s16b(creature_ptr->see_infra);
- wr_s16b(creature_ptr->tim_infra);
- wr_s16b(creature_ptr->oppose_fire);
- wr_s16b(creature_ptr->oppose_cold);
- wr_s16b(creature_ptr->oppose_acid);
- wr_s16b(creature_ptr->oppose_elec);
- wr_s16b(creature_ptr->oppose_pois);
- wr_s16b(creature_ptr->tsuyoshi);
- wr_s16b(creature_ptr->tim_esp);
- wr_s16b(creature_ptr->wraith_form);
- wr_s16b(creature_ptr->resist_magic);
- wr_s16b(creature_ptr->tim_regen);
- wr_s16b(creature_ptr->tim_pass_wall);
- wr_s16b(creature_ptr->tim_stealth);
- wr_s16b(creature_ptr->tim_levitation);
- wr_s16b(creature_ptr->tim_sh_touki);
- wr_s16b(creature_ptr->lightspeed);
- wr_s16b(creature_ptr->tsubureru);
- wr_s16b(creature_ptr->magicdef);
- wr_s16b(creature_ptr->tim_res_nether);
- wr_s16b(creature_ptr->tim_res_time);
- wr_byte((byte)creature_ptr->mimic_form);
- wr_s16b(creature_ptr->tim_mimic);
- wr_s16b(creature_ptr->tim_sh_fire);
- wr_s16b(creature_ptr->tim_sh_holy);
- wr_s16b(creature_ptr->tim_eyeeye);
-
- /* by henkma */
- wr_s16b(creature_ptr->tim_reflect);
- wr_s16b(creature_ptr->multishadow);
- wr_s16b(creature_ptr->dustrobe);
-
- wr_s16b(creature_ptr->chaos_patron);
- wr_u32b(creature_ptr->muta1);
- wr_u32b(creature_ptr->muta2);
- wr_u32b(creature_ptr->muta3);
-
- for (int i = 0; i < 8; i++)
- wr_s16b(creature_ptr->virtues[i]);
- for (int i = 0; i < 8; i++)
- wr_s16b(creature_ptr->vir_types[i]);
-
- wr_s16b(creature_ptr->ele_attack);
- wr_u32b(creature_ptr->special_attack);
- wr_s16b(creature_ptr->ele_immune);
- wr_u32b(creature_ptr->special_defense);
- wr_byte(creature_ptr->knowledge);
- wr_byte(creature_ptr->autopick_autoregister);
- wr_byte(0);
- wr_byte((byte)creature_ptr->action);
- wr_byte(0);
- wr_byte(preserve_mode);
- wr_byte(creature_ptr->wait_report_score);
-
- /* Future use */
- for (int i = 0; i < 12; i++) wr_u32b(0L);
-
- /* Ignore some flags */
- wr_u32b(0L);
- wr_u32b(0L);
- wr_u32b(0L);
-
- /* Write the "object seeds" */
- wr_u32b(current_world_ptr->seed_flavor);
- wr_u32b(current_world_ptr->seed_town);
-
- /* Special stuff */
- wr_u16b(creature_ptr->panic_save);
- wr_u16b(current_world_ptr->total_winner);
- wr_u16b(current_world_ptr->noscore);
-
- /* Write death */
- wr_byte(creature_ptr->is_dead);
-
- /* Write feeling */
- wr_byte(creature_ptr->feeling);
-
- /* Turn when level began */
- wr_s32b(creature_ptr->current_floor_ptr->generated_turn);
-
- /* Turn of last "feeling" */
- wr_s32b(creature_ptr->feeling_turn);
-
- /* Current turn */
- wr_s32b(current_world_ptr->game_turn);
-
- wr_s32b(current_world_ptr->dungeon_turn);
-
- wr_s32b(current_world_ptr->arena_start_turn);
-
- wr_s16b(today_mon);
- wr_s16b(creature_ptr->today_mon);
- wr_s16b(creature_ptr->riding);
-
- /* Current floor_id */
- wr_s16b(creature_ptr->floor_id);
-
- /* Save temporary preserved pets (obsolated) */
- wr_s16b(0);
-
- wr_u32b(current_world_ptr->play_time);
- wr_s32b(creature_ptr->visit);
- wr_u32b(creature_ptr->count);
-}
-
-
-/*!
- * @brief 保存フロアの書き込み / Actually write a saved floor data using effectively compressed format.
- * @param sf_ptr 保存したいフロアの参照ポインタ
- * @return なし
- */
-static void wr_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr)
-{
- /*** Basic info ***/
- /* Dungeon floor specific info follows */
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
- if (!sf_ptr)
- {
- /*** Not a saved floor ***/
-
- wr_s16b((s16b)floor_ptr->dun_level);
- }
- else
- {
- /*** The saved floor ***/
-
- wr_s16b(sf_ptr->floor_id);
- wr_byte((byte)sf_ptr->savefile_id);
- wr_s16b((s16b)sf_ptr->dun_level);
- wr_s32b(sf_ptr->last_visit);
- wr_u32b(sf_ptr->visit_mark);
- wr_s16b(sf_ptr->upper_floor_id);
- wr_s16b(sf_ptr->lower_floor_id);
- }
-
- wr_u16b((u16b)floor_ptr->base_level);
- wr_u16b((s16b)player_ptr->current_floor_ptr->num_repro);
- wr_u16b((u16b)player_ptr->y);
- wr_u16b((u16b)player_ptr->x);
- wr_u16b((u16b)floor_ptr->height);
- wr_u16b((u16b)floor_ptr->width);
- wr_byte(player_ptr->feeling);
-
- /*********** Make template for grid_type **********/
-
- /*
- * Usually number of templates are fewer than 255. Even if
- * more than 254 are exist, the occurrence of each template
- * with larger ID is very small when we sort templates by
- * occurrence. So we will use two (or more) bytes for
- * templete ID larger than 254.
- *
- * Ex: 256 will be "0xff" "0x01".
- * 515 will be "0xff" "0xff" "0x03"
- */
-
- /* Fake max number */
- u16b max_num_temp = 255;
-
- /* Allocate the "template" array */
- grid_template_type *templates;
- C_MAKE(templates, max_num_temp, grid_template_type);
-
- /* Extract template array */
- u16b num_temp = 0;
- for (int y = 0; y < floor_ptr->height; y++)
- {
- for (int x = 0; x < floor_ptr->width; x++)
- {
- grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-
- int i;
- for (i = 0; i < num_temp; i++)
- {
- if (templates[i].info == g_ptr->info &&
- templates[i].feat == g_ptr->feat &&
- templates[i].mimic == g_ptr->mimic &&
- templates[i].special == g_ptr->special)
- {
- /* Same terrain is exist */
- templates[i].occurrence++;
- break;
- }
- }
-
- /* Are there same one? */
- if (i < num_temp) continue;
-
- /* If the max_num_temp is too small, increase it. */
- if (num_temp >= max_num_temp)
- {
- grid_template_type *old_template = templates;
-
- /* Re-allocate the "template" array */
- C_MAKE(templates, max_num_temp + 255, grid_template_type);
- (void)C_COPY(templates, old_template, max_num_temp, grid_template_type);
- C_KILL(old_template, max_num_temp, grid_template_type);
- max_num_temp += 255;
- }
-
- /* Add new template */
- templates[num_temp].info = g_ptr->info;
- templates[num_temp].feat = g_ptr->feat;
- templates[num_temp].mimic = g_ptr->mimic;
- templates[num_temp].special = g_ptr->special;
- templates[num_temp].occurrence = 1;
-
- /* Increase number of template */
- num_temp++;
- }
- }
-
- /* Sort by occurrence */
- int dummy_why;
- ang_sort(player_ptr, templates, &dummy_why, num_temp, ang_sort_comp_cave_temp, ang_sort_swap_cave_temp);
-
- /*** Dump templates ***/
-
- /* Total templates */
- wr_u16b(num_temp);
-
- /* Dump the templates */
- for (int i = 0; i < num_temp; i++)
- {
- grid_template_type *ct_ptr = &templates[i];
- wr_u16b((u16b)ct_ptr->info);
- wr_s16b(ct_ptr->feat);
- wr_s16b(ct_ptr->mimic);
- wr_s16b(ct_ptr->special);
- }
-
- /*** "Run-Length-Encoding" of floor ***/
- /* Note that this will induce two wasted bytes */
- byte count = 0;
- u16b prev_u16b = 0;
-
- for (int y = 0; y < floor_ptr->height; y++)
- {
- for (int x = 0; x < floor_ptr->width; x++)
- {
- grid_type *g_ptr = &floor_ptr->grid_array[y][x];
- int i;
- for (i = 0; i < num_temp; i++)
- {
- if (templates[i].info == g_ptr->info &&
- templates[i].feat == g_ptr->feat &&
- templates[i].mimic == g_ptr->mimic &&
- templates[i].special == g_ptr->special)
- break;
- }
-
- /* Extract an ID */
- u16b tmp16u = (u16b)i;
-
- /* If the run is broken, or too full, flush it */
- if ((tmp16u == prev_u16b) && (count != MAX_UCHAR))
- {
- count++;
- continue;
- }
-
- wr_byte((byte)count);
-
- while (prev_u16b >= MAX_UCHAR)
- {
- /* Mark as actual data is larger than 254 */
- wr_byte(MAX_UCHAR);
- prev_u16b -= MAX_UCHAR;
- }
-
- wr_byte((byte)prev_u16b);
- prev_u16b = tmp16u;
- count = 1;
- }
- }
-
- /* Flush the data (if any) */
- if (count > 0)
- {
- wr_byte((byte)count);
-
- while (prev_u16b >= MAX_UCHAR)
- {
- /* Mark as actual data is larger than 254 */
- wr_byte(MAX_UCHAR);
- prev_u16b -= MAX_UCHAR;
- }
-
- wr_byte((byte)prev_u16b);
- }
-
- /* Free the "template" array */
- C_KILL(templates, max_num_temp, grid_template_type);
-
- /*** Dump objects ***/
-
- /* Total objects */
- wr_u16b(floor_ptr->o_max);
-
- /* Dump the objects */
- for (int i = 1; i < floor_ptr->o_max; i++)
- {
- object_type *o_ptr = &floor_ptr->o_list[i];
- wr_item(o_ptr);
- }
-
- /*** Dump the monsters ***/
-
- /* Total monsters */
- wr_u16b(floor_ptr->m_max);
-
- /* Dump the monsters */
- for (int i = 1; i < floor_ptr->m_max; i++)
- {
- monster_type *m_ptr = &floor_ptr->m_list[i];
- wr_monster(m_ptr);
- }
-}
-
-
-/*!
- * @brief 現在フロアの書き込み /
- * Write the current dungeon (new method)
- * @player_ptr プレーヤーへの参照ポインタ
- * @return 保存に成功したらTRUE
- */
-static bool wr_dungeon(player_type *player_ptr)
-{
- forget_lite(player_ptr->current_floor_ptr);
- forget_view(player_ptr->current_floor_ptr);
- clear_mon_lite(player_ptr->current_floor_ptr);
-
- /* Update lite/view */
- player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
- player_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
-
- /*** Meta info ***/
-
- /* Number of floor_id used from birth */
- wr_s16b(max_floor_id);
-
- /* Current dungeon type */
- wr_byte((byte)player_ptr->dungeon_idx);
-
-
- /*** No saved floor (On the surface etc.) ***/
- if (!player_ptr->floor_id)
- {
- /* No array elements */
- wr_byte(0);
-
- /* Write the current floor data */
- wr_saved_floor(player_ptr, NULL);
-
- /* Success */
- return TRUE;
- }
-
-
- /*** In the dungeon ***/
-
- /* Number of array elements */
- wr_byte(MAX_SAVED_FLOORS);
-
- /* Write the saved_floors array */
- for (int i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- saved_floor_type *sf_ptr = &saved_floors[i];
-
- wr_s16b(sf_ptr->floor_id);
- wr_byte((byte)sf_ptr->savefile_id);
- wr_s16b((s16b)sf_ptr->dun_level);
- wr_s32b(sf_ptr->last_visit);
- wr_u32b(sf_ptr->visit_mark);
- wr_s16b(sf_ptr->upper_floor_id);
- wr_s16b(sf_ptr->lower_floor_id);
- }
-
- /* Extract pointer to current floor */
- saved_floor_type *cur_sf_ptr;
- cur_sf_ptr = get_sf_ptr(player_ptr->floor_id);
-
- /* Save current floor to temporary file */
- if (!save_floor(player_ptr, cur_sf_ptr, (SLF_SECOND))) return FALSE;
-
- /* Move data in temporary files to the savefile */
- for (int i = 0; i < MAX_SAVED_FLOORS; i++)
- {
- saved_floor_type *sf_ptr = &saved_floors[i];
- if (!sf_ptr->floor_id) continue;
- if (!load_floor(player_ptr, sf_ptr, (SLF_SECOND | SLF_NO_KILL)))
- {
- wr_byte(1);
- continue;
- }
-
- wr_byte(0);
- wr_saved_floor(player_ptr, sf_ptr);
- }
-
- if (!load_floor(player_ptr, cur_sf_ptr, (SLF_SECOND))) return FALSE;
- return TRUE;
-}
-
-
-/*!
- * @brief セーブデータの書き込み /
- * Actually write a save-file
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return 成功すればtrue
- */
-static bool wr_savefile_new(player_type *player_ptr)
-{
- /* Compact the objects */
- compact_objects(player_ptr, 0);
-
- /* Compact the monsters */
- compact_monsters(player_ptr, 0);
-
- /* Guess at the current time */
- u32b now = (u32b)time((time_t *)0);
-
- /* Note the operating system */
- current_world_ptr->sf_system = 0L;
-
- /* Note when the file was saved */
- current_world_ptr->sf_when = now;
-
- /* Note the number of saves */
- current_world_ptr->sf_saves++;
-
- /*** Actually write the file ***/
- /* Dump the file header */
- xor_byte = 0;
- wr_byte(FAKE_VER_MAJOR);
- xor_byte = 0;
- wr_byte(FAKE_VER_MINOR);
- xor_byte = 0;
- wr_byte(FAKE_VER_PATCH);
- xor_byte = 0;
-
- /* Initial value of xor_byte */
- byte tmp8u = (byte)Rand_external(256);
- wr_byte(tmp8u);
-
- /* Reset the checksum */
- v_stamp = 0L;
- x_stamp = 0L;
-
- /* Write the savefile version for Hengband 1.1.1 and later */
- wr_byte(H_VER_EXTRA);
- wr_byte(H_VER_PATCH);
- wr_byte(H_VER_MINOR);
- wr_byte(H_VER_MAJOR);
-
- /* Operating system */
- wr_u32b(current_world_ptr->sf_system);
-
- /* Time file last saved */
- wr_u32b(current_world_ptr->sf_when);
-
- /* Number of past lives */
- wr_u16b(current_world_ptr->sf_lives);
-
- /* Number of times saved */
- wr_u16b(current_world_ptr->sf_saves);
-
- wr_u32b(0L);
- wr_u16b(0);
- wr_byte(0);
-
-#ifdef JP
-# ifdef EUC
- /* EUC kanji code */
- wr_byte(2);
-# endif
-# ifdef SJIS
- /* SJIS kanji code */
- wr_byte(3);
-# endif
-#else
- /* ASCII */
- wr_byte(1);
-#endif
-
- /* Write the RNG state */
- wr_randomizer();
-
- /* Write the boolean "options" */
- wr_options();
-
- /* Dump the number of "messages" */
- u32b tmp32u = message_num();
- if (compress_savefile && (tmp32u > 40)) tmp32u = 40;
- wr_u32b(tmp32u);
-
- /* Dump the messages (oldest first!) */
- for (int i = tmp32u - 1; i >= 0; i--)
- {
- wr_string(message_str((s16b)i));
- }
-
- /* Dump the monster lore */
- u16b tmp16u = max_r_idx;
- wr_u16b(tmp16u);
- for (MONRACE_IDX r_idx = 0; r_idx < tmp16u; r_idx++)
- {
- wr_lore(r_idx);
- }
-
- /* Dump the object memory */
- tmp16u = max_k_idx;
- wr_u16b(tmp16u);
- for (KIND_OBJECT_IDX k_idx = 0; k_idx < tmp16u; k_idx++)
- {
- wr_xtra(k_idx);
- }
-
- /* Dump the towns */
- tmp16u = max_towns;
- wr_u16b(tmp16u);
-
- /* Dump the quests */
- tmp16u = max_q_idx;
- wr_u16b(tmp16u);
-
- /* Dump the quests */
- tmp8u = MAX_RANDOM_QUEST - MIN_RANDOM_QUEST;
- wr_byte(tmp8u);
-
- for (int i = 0; i < max_q_idx; i++)
- {
- quest_type* const q_ptr = &quest[i];
-
- /* Save status for every quest */
- wr_s16b(q_ptr->status);
-
- /* And the dungeon level too */
- /* (prevents problems with multi-level quests) */
- wr_s16b((s16b)q_ptr->level);
-
- wr_byte((byte)q_ptr->complev);
- wr_u32b(q_ptr->comptime);
-
- bool is_quest_running = q_ptr->status == QUEST_STATUS_TAKEN;
- is_quest_running |= q_ptr->status == QUEST_STATUS_COMPLETED;
- is_quest_running |= !is_fixed_quest_idx(i);
- if (!is_quest_running) continue;
-
- wr_s16b((s16b)q_ptr->cur_num);
- wr_s16b((s16b)q_ptr->max_num);
- wr_s16b(q_ptr->type);
- wr_s16b(q_ptr->r_idx);
- wr_s16b(q_ptr->k_idx);
- wr_byte((byte)q_ptr->flags);
- wr_byte((byte)q_ptr->dungeon);
- }
-
- /* Dump the position in the wilderness */
- wr_s32b(player_ptr->wilderness_x);
- wr_s32b(player_ptr->wilderness_y);
-
- wr_byte(player_ptr->wild_mode);
- wr_byte(player_ptr->ambush_flag);
-
- wr_s32b(current_world_ptr->max_wild_x);
- wr_s32b(current_world_ptr->max_wild_y);
-
- /* Dump the wilderness seeds */
- for (int i = 0; i < current_world_ptr->max_wild_x; i++)
- {
- for (int j = 0; j < current_world_ptr->max_wild_y; j++)
- {
- wr_u32b(wilderness[j][i].seed);
- }
- }
-
- /* Hack -- Dump the artifacts */
- tmp16u = max_a_idx;
- wr_u16b(tmp16u);
- for (int i = 0; i < tmp16u; i++)
- {
- artifact_type *a_ptr = &a_info[i];
- wr_byte(a_ptr->cur_num);
- wr_s16b(a_ptr->floor_id);
- }
-
- /* Write the "extra" information */
- wr_extra(player_ptr);
-
- /* Dump the "player hp" entries */
- tmp16u = PY_MAX_LEVEL;
- wr_u16b(tmp16u);
- for (int i = 0; i < tmp16u; i++)
- {
- wr_s16b((s16b)player_ptr->player_hp[i]);
- }
-
- /* Write spell data */
- wr_u32b(player_ptr->spell_learned1);
- wr_u32b(player_ptr->spell_learned2);
- wr_u32b(player_ptr->spell_worked1);
- wr_u32b(player_ptr->spell_worked2);
- wr_u32b(player_ptr->spell_forgotten1);
- wr_u32b(player_ptr->spell_forgotten2);
-
- wr_s16b(player_ptr->learned_spells);
- wr_s16b(player_ptr->add_spells);
-
- /* Dump the ordered spells */
- for (int i = 0; i < 64; i++)
- {
- wr_byte((byte)player_ptr->spell_order[i]);
- }
-
- for (int i = 0; i < INVEN_TOTAL; i++)
- {
- object_type *o_ptr = &player_ptr->inventory_list[i];
- if (!o_ptr->k_idx) continue;
-
- /* Dump index */
- wr_u16b((u16b)i);
-
- /* Dump object */
- wr_item(o_ptr);
- }
-
- /* Add a sentinel */
- wr_u16b(0xFFFF);
-
- /* Note the towns */
- tmp16u = max_towns;
- wr_u16b(tmp16u);
-
- /* Note the stores */
- tmp16u = MAX_STORES;
- wr_u16b(tmp16u);
-
- /* Dump the stores of all towns */
- for (int i = 1; i < max_towns; i++)
- {
- for (int j = 0; j < MAX_STORES; j++)
- {
- wr_store(&town_info[i].store[j]);
- }
- }
-
- /* Write the pet command settings */
- wr_s16b(player_ptr->pet_follow_distance);
- wr_s16b(player_ptr->pet_extra_flags);
-
- /* Write screen dump for sending score */
- if (screen_dump && (player_ptr->wait_report_score || !player_ptr->is_dead))
- {
- wr_string(screen_dump);
- }
- else
- {
- wr_string("");
- }
-
- /* Player is not dead, write the dungeon */
- if (!player_ptr->is_dead)
- {
- /* Dump the dungeon */
- if (!wr_dungeon(player_ptr)) return FALSE;
-
- /* Dump the ghost */
- wr_ghost();
-
- /* No scripts */
- wr_s32b(0);
- }
-
- /* Write the "value check-sum" */
- wr_u32b(v_stamp);
-
- /* Write the "encoded checksum" */
- wr_u32b(x_stamp);
-
- if (ferror(fff) || (fflush(fff) == EOF)) return FALSE;
- return TRUE;
-}
-
-
-/*!
- * @brief セーブデータ書き込みのサブルーチン /
- * Medium level player saver
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return 成功すればtrue
- * @details
- * Angband 2.8.0 will use "fd" instead of "fff" if possible
- */
-static bool save_player_aux(player_type *player_ptr, char *name)
-{
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Create the savefile */
- int file_permission = 0644;
- int fd = fd_make(name, file_permission);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- bool is_save_successful = FALSE;
- fff = NULL;
- if (fd >= 0)
- {
- /* Close the "fd" */
- (void)fd_close(fd);
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Open the savefile */
- fff = angband_fopen(name, "wb");
-
- /* Drop permissions */
- safe_setuid_drop();
-
- /* Successful open */
- if (fff)
- {
- /* Write the savefile */
- if (wr_savefile_new(player_ptr)) is_save_successful = TRUE;
-
- /* Attempt to close it */
- if (angband_fclose(fff)) is_save_successful = FALSE;
- }
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Remove "broken" files */
- if (!is_save_successful) (void)fd_kill(name);
-
- /* Drop permissions */
- safe_setuid_drop();
- }
-
- if (!is_save_successful) return FALSE;
-
- counts_write(player_ptr, 0, current_world_ptr->play_time);
- current_world_ptr->character_saved = TRUE;
- return TRUE;
-}
-
-
-/*!
- * @brief セーブデータ書き込みのメインルーチン /
- * Attempt to save the player in a savefile
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return 成功すればtrue
- */
-bool save_player(player_type *player_ptr)
-{
- char safe[1024];
- strcpy(safe, savefile);
- strcat(safe, ".new");
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- fd_kill(safe);
-
- /* Drop permissions */
- safe_setuid_drop();
- update_playtime();
-
- /* Attempt to save the player */
- bool result = FALSE;
- if (save_player_aux(player_ptr, safe))
- {
- char temp[1024];
-
- /* Old savefile */
- strcpy(temp, savefile);
- strcat(temp, ".old");
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Remove it */
- fd_kill(temp);
-
- /* Preserve old savefile */
- fd_move(savefile, temp);
-
- /* Activate new savefile */
- fd_move(safe, savefile);
-
- /* Remove preserved savefile */
- fd_kill(temp);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- /* Hack -- Pretend the character was loaded */
- current_world_ptr->character_loaded = TRUE;
-
- result = TRUE;
- }
-
- /* Return the result */
- return result;
-}
-
-
-/*!
- * @brief セーブデータ読み込みのメインルーチン /
- * Attempt to Load a "savefile"
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @return 成功すればtrue
- * @details
- * <pre>
- * Version 2.7.0 introduced a slightly different "savefile" format from
- * older versions, requiring a completely different parsing method.
- *
- * Note that savefiles from 2.7.0 - 2.7.2 are completely obsolete.
- *
- * Pre-2.8.0 savefiles lose some data, see "load2.c" for info.
- *
- * Pre-2.7.0 savefiles lose a lot of things, see "load1.c" for info.
- *
- * On multi-user systems, you may only "read" a savefile if you will be
- * allowed to "write" it later, this prevents painful situations in which
- * the player loads a savefile belonging to someone else, and then is not
- * allowed to save his game when he quits.
- *
- * We return "TRUE" if the savefile was usable, and we set the global
- * flag "current_world_ptr->character_loaded" if a real, living, character was loaded.
- *
- * Note that we always try to load the "current" savefile, even if
- * there is no such file, so we must check for "empty" savefile names.
- * </pre>
- */
-bool load_player(player_type *player_ptr)
-{
- concptr what = "generic";
-
- current_world_ptr->game_turn = 0;
- player_ptr->is_dead = FALSE;
-
-
- /* Allow empty savefile name */
- if (!savefile[0]) return TRUE;
-
-
-#if !defined(WINDOWS)
-
- /* Fix this */
-
- /* Verify the existance of the savefile */
- if (access(savefile, 0) < 0)
- {
- /* Give a message */
- msg_print(_("セーブファイルがありません。", "Savefile does not exist."));
-
- msg_print(NULL);
-
- /* Allow this */
- return TRUE;
- }
-
-#endif
-
- errr err = 0;
- int fd = -1;
- byte vvv[4];
- if (!err)
- {
- /* Open the savefile */
- fd = fd_open(savefile, O_RDONLY);
-
- /* No file */
- if (fd < 0) err = -1;
-
- /* Message (below) */
- if (err) what = _("セーブファイルを開けません。", "Cannot open savefile");
- }
-
- /* Process file */
- if (!err)
- {
- /* Read the first four bytes */
- if (fd_read(fd, (char*)(vvv), 4)) err = -1;
-
- /* What */
- if (err) what = _("セーブファイルを読めません。", "Cannot read savefile");
- (void)fd_close(fd);
- }
-
- /* Process file */
- if (!err)
- {
- /* Extract version */
- current_world_ptr->z_major = vvv[0];
- current_world_ptr->z_minor = vvv[1];
- current_world_ptr->z_patch = vvv[2];
- current_world_ptr->sf_extra = vvv[3];
-
- Term_clear();
-
- /* Attempt to load */
- err = rd_savefile_new(player_ptr);
-
- /* Message (below) */
- if (err) what = _("セーブファイルを解析出来ません。", "Cannot parse savefile");
- }
-
- if (!err)
- {
- /* Invalid turn */
- if (!current_world_ptr->game_turn) err = -1;
-
- /* Message (below) */
- if (err) what = _("セーブファイルが壊れています", "Broken savefile");
- }
-
- if (!err)
- {
- /* Give a conversion warning */
- if ((FAKE_VER_MAJOR != current_world_ptr->z_major) ||
- (FAKE_VER_MINOR != current_world_ptr->z_minor) ||
- (FAKE_VER_PATCH != current_world_ptr->z_patch))
- {
- if (current_world_ptr->z_major == 2 && current_world_ptr->z_minor == 0 && current_world_ptr->z_patch == 6)
- {
- msg_print(_("バージョン 2.0.* 用のセーブファイルを変換しました。", "Converted a 2.0.* savefile."));
- }
- else
- {
- msg_format(_("バージョン %d.%d.%d 用のセーブ・ファイルを変換しました。", "Converted a %d.%d.%d savefile."),
- (current_world_ptr->z_major > 9) ? current_world_ptr->z_major - 10 : current_world_ptr->z_major, current_world_ptr->z_minor, current_world_ptr->z_patch);
- }
- msg_print(NULL);
- }
-
- /* Player is dead */
- if (player_ptr->is_dead)
- {
- /* Cheat death */
- if (arg_wizard)
- {
- /* A character was loaded */
- current_world_ptr->character_loaded = TRUE;
- return TRUE;
- }
-
- /* Player is no longer "dead" */
- player_ptr->is_dead = FALSE;
-
- /* Count lives */
- current_world_ptr->sf_lives++;
-
- return TRUE;
- }
-
- /* A character was loaded */
- current_world_ptr->character_loaded = TRUE;
-
- {
- u32b tmp = counts_read(player_ptr, 2);
- if (tmp > player_ptr->count)
- player_ptr->count = tmp;
- if (counts_read(player_ptr, 0) > current_world_ptr->play_time || counts_read(player_ptr, 1) == current_world_ptr->play_time)
- counts_write(player_ptr, 2, ++player_ptr->count);
- counts_write(player_ptr, 1, current_world_ptr->play_time);
- }
-
- /* Success */
- return TRUE;
- }
-
- msg_format(_("エラー(%s)がバージョン%d.%d.%d 用セーブファイル読み込み中に発生。", "Error (%s) reading %d.%d.%d savefile."),
- what, (current_world_ptr->z_major > 9) ? current_world_ptr->z_major - 10 : current_world_ptr->z_major, current_world_ptr->z_minor, current_world_ptr->z_patch);
- msg_print(NULL);
- return FALSE;
-}
-
-
-/*!
- * @brief ゲームプレイ中のフロア一時保存出力処理サブルーチン / Actually write a temporary saved floor file
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param sf_ptr 保存フロア参照ポインタ
- * @return なし
- */
-static bool save_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr)
-{
- /* Compact the objects */
- compact_objects(player_ptr, 0);
- /* Compact the monsters */
- compact_monsters(player_ptr, 0);
-
- /*** Actually write the file ***/
- /* Initial value of xor_byte */
- byte tmp8u = (byte)randint0(256);
- xor_byte = 0;
- wr_byte(tmp8u);
-
- /* Reset the checksum */
- v_stamp = 0L;
- x_stamp = 0L;
-
- /* Write the sign of this process */
- wr_u32b(saved_floor_file_sign);
-
- /* Dump the dungeon floor */
- wr_saved_floor(player_ptr, sf_ptr);
-
- /* Write the "value check-sum" */
- wr_u32b(v_stamp);
-
- /* Write the "encoded checksum" */
- wr_u32b(x_stamp);
-
- if (ferror(fff) || (fflush(fff) == EOF)) return FALSE;
- return TRUE;
-}
-
-
-/*!
- * @brief ゲームプレイ中のフロア一時保存出力処理メインルーチン / Attempt to save the temporarily saved-floor data
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param sf_ptr 保存フロア参照ポインタ
- * @param mode 保存オプション
- * @return なし
- */
-bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mode)
-{
- FILE *old_fff = NULL;
- byte old_xor_byte = 0;
- u32b old_v_stamp = 0;
- u32b old_x_stamp = 0;
-
- char floor_savefile[1024];
- if (!(mode & SLF_SECOND))
- {
- }
-
- /* We have one file already opened */
- else
- {
- /* Backup original values */
- old_fff = fff;
- old_xor_byte = xor_byte;
- old_v_stamp = v_stamp;
- old_x_stamp = x_stamp;
- }
-
- /* New savefile */
- sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id);
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Remove it */
- fd_kill(floor_savefile);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- /* Attempt to save the player */
-
- /* No file yet */
- fff = NULL;
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Create the savefile */
- int fd = fd_make(floor_savefile, 0644);
-
- /* Drop permissions */
- safe_setuid_drop();
-
- bool is_save_successful = FALSE;
- if (fd >= 0)
- {
- /* Close the "fd" */
- (void)fd_close(fd);
-
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- /* Open the savefile */
- fff = angband_fopen(floor_savefile, "wb");
-
- /* Drop permissions */
- safe_setuid_drop();
-
- /* Successful open */
- if (fff)
- {
- /* Write the savefile */
- if (save_floor_aux(player_ptr, sf_ptr)) is_save_successful = TRUE;
-
- /* Attempt to close it */
- if (angband_fclose(fff)) is_save_successful = FALSE;
- }
-
- /* Remove "broken" files */
- if (!is_save_successful)
- {
- /* Grab permissions */
- safe_setuid_grab(player_ptr);
-
- (void)fd_kill(floor_savefile);
-
- /* Drop permissions */
- safe_setuid_drop();
- }
- }
-
- if (!(mode & SLF_SECOND))
- {
- }
-
- /* We have one file already opened */
- else
- {
- /* Restore original values */
- fff = old_fff;
- xor_byte = old_xor_byte;
- v_stamp = old_v_stamp;
- x_stamp = old_x_stamp;
- }
-
- return is_save_successful;
-}
*/
#include "io/signal-handlers.h"
-#include "system/system-variables.h"
-#include "core/game-closer.h"
-#include "io/save.h"
-#include "world/world.h"
-#include "term/term-color-types.h"
-#include "io/write-diary.h"
#include "cmd-io/cmd-dump.h"
+#include "core/game-closer.h"
#include "floor/floor-events.h"
+#include "io/write-diary.h"
+#include "savedata/save.h"
+#include "system/system-variables.h"
+#include "term/term-color-types.h"
+#include "world/world.h"
-s16b signal_count; /* Hack -- Count interupts */
+s16b signal_count; /* Hack -- Count interupts */
#ifdef HANDLE_SIGNALS
*/
static void handle_signal_suspend(int sig)
{
- (void)signal(sig, SIG_IGN);
+ (void)signal(sig, SIG_IGN);
#ifdef SIGSTOP
- Term_fresh();
- Term_xtra(TERM_XTRA_ALIVE, 0);
- (void)kill(0, SIGSTOP);
- Term_xtra(TERM_XTRA_ALIVE, 1);
- Term_redraw();
- Term_fresh();
+ Term_fresh();
+ Term_xtra(TERM_XTRA_ALIVE, 0);
+ (void)kill(0, SIGSTOP);
+ Term_xtra(TERM_XTRA_ALIVE, 1);
+ Term_redraw();
+ Term_fresh();
#endif
- (void)signal(sig, handle_signal_suspend);
+ (void)signal(sig, handle_signal_suspend);
}
-
/*!
* todo ここにplayer_typeを追加すると関数ポインタ周りの収拾がつかなくなるので保留
* @brief OSからのシグナルを受けて中断、終了する /
*/
static void handle_signal_simple(int sig)
{
- (void)signal(sig, SIG_IGN);
- if (!current_world_ptr->character_generated || current_world_ptr->character_saved)
- quit(NULL);
-
- signal_count++;
- if (p_ptr->is_dead)
- {
- (void)strcpy(p_ptr->died_from, _("強制終了", "Abortion"));
- forget_lite(p_ptr->current_floor_ptr);
- forget_view(p_ptr->current_floor_ptr);
- clear_mon_lite(p_ptr->current_floor_ptr);
- close_game(p_ptr);
- quit(_("強制終了", "interrupt"));
- }
- else if (signal_count >= 5)
- {
- (void)strcpy(p_ptr->died_from, _("強制終了中", "Interrupting"));
- forget_lite(p_ptr->current_floor_ptr);
- forget_view(p_ptr->current_floor_ptr);
- clear_mon_lite(p_ptr->current_floor_ptr);
- p_ptr->playing = FALSE;
- p_ptr->is_dead = TRUE;
- p_ptr->leaving = TRUE;
- close_game(p_ptr);
- quit(_("強制終了", "interrupt"));
- }
- else if (signal_count >= 4)
- {
- Term_xtra(TERM_XTRA_NOISE, 0);
- Term_erase(0, 0, 255);
- Term_putstr(0, 0, -1, TERM_WHITE, _("熟慮の上の自殺!", "Contemplating suicide!"));
- Term_fresh();
- }
- else if (signal_count >= 2)
- {
- Term_xtra(TERM_XTRA_NOISE, 0);
- }
-
- (void)signal(sig, handle_signal_simple);
+ (void)signal(sig, SIG_IGN);
+ if (!current_world_ptr->character_generated || current_world_ptr->character_saved)
+ quit(NULL);
+
+ signal_count++;
+ if (p_ptr->is_dead) {
+ (void)strcpy(p_ptr->died_from, _("強制終了", "Abortion"));
+ forget_lite(p_ptr->current_floor_ptr);
+ forget_view(p_ptr->current_floor_ptr);
+ clear_mon_lite(p_ptr->current_floor_ptr);
+ close_game(p_ptr);
+ quit(_("強制終了", "interrupt"));
+ } else if (signal_count >= 5) {
+ (void)strcpy(p_ptr->died_from, _("強制終了中", "Interrupting"));
+ forget_lite(p_ptr->current_floor_ptr);
+ forget_view(p_ptr->current_floor_ptr);
+ clear_mon_lite(p_ptr->current_floor_ptr);
+ p_ptr->playing = FALSE;
+ p_ptr->is_dead = TRUE;
+ p_ptr->leaving = TRUE;
+ close_game(p_ptr);
+ quit(_("強制終了", "interrupt"));
+ } else if (signal_count >= 4) {
+ Term_xtra(TERM_XTRA_NOISE, 0);
+ Term_erase(0, 0, 255);
+ Term_putstr(0, 0, -1, TERM_WHITE, _("熟慮の上の自殺!", "Contemplating suicide!"));
+ Term_fresh();
+ } else if (signal_count >= 2) {
+ Term_xtra(TERM_XTRA_NOISE, 0);
+ }
+
+ (void)signal(sig, handle_signal_simple);
}
-
/*!
* todo ここにp_ptrを追加すると関数ポインタ周りの収拾がつかなくなるので保留
* @brief OSからのシグナルを受けて強制終了する /
*/
static void handle_signal_abort(int sig)
{
- int wid, hgt;
- Term_get_size(&wid, &hgt);
+ int wid, hgt;
+ Term_get_size(&wid, &hgt);
- (void)signal(sig, SIG_IGN);
- if (!current_world_ptr->character_generated || current_world_ptr->character_saved) quit(NULL);
+ (void)signal(sig, SIG_IGN);
+ if (!current_world_ptr->character_generated || current_world_ptr->character_saved)
+ quit(NULL);
- forget_lite(p_ptr->current_floor_ptr);
- forget_view(p_ptr->current_floor_ptr);
- clear_mon_lite(p_ptr->current_floor_ptr);
+ forget_lite(p_ptr->current_floor_ptr);
+ forget_view(p_ptr->current_floor_ptr);
+ clear_mon_lite(p_ptr->current_floor_ptr);
- Term_erase(0, hgt - 1, 255);
- Term_putstr(0, hgt - 1, -1, TERM_RED,
- _("恐ろしいソフトのバグが飛びかかってきた!", "A gruesome software bug LEAPS out at you!"));
+ Term_erase(0, hgt - 1, 255);
+ Term_putstr(0, hgt - 1, -1, TERM_RED, _("恐ろしいソフトのバグが飛びかかってきた!", "A gruesome software bug LEAPS out at you!"));
- Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ...", "Panic save..."));
+ Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ...", "Panic save..."));
- exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム異常終了----", "-- Tried Panic Save and Aborted Game --"));
- Term_fresh();
+ exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム異常終了----", "-- Tried Panic Save and Aborted Game --"));
+ Term_fresh();
- p_ptr->panic_save = 1;
- (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
+ p_ptr->panic_save = 1;
+ (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
- signals_ignore_tstp();
+ signals_ignore_tstp();
- if (save_player(p_ptr))
- {
- Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
- }
- else
- {
- Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
- }
+ if (save_player(p_ptr)) {
+ Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
+ } else {
+ Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
+ }
- Term_fresh();
- quit(_("ソフトのバグ", "software bug"));
+ Term_fresh();
+ quit(_("ソフトのバグ", "software bug"));
}
-
/*!
* @brief OSからのSIGTSTPシグナルを無視する関数 /
* Ignore SIGTSTP signals (keyboard suspend)
void signals_ignore_tstp(void)
{
#ifdef SIGTSTP
- (void)signal(SIGTSTP, SIG_IGN);
+ (void)signal(SIGTSTP, SIG_IGN);
#endif
}
-
/*!
* @brief OSからのSIGTSTPシグナルハンドラ /
* Handle SIGTSTP signals (keyboard suspend)
void signals_handle_tstp(void)
{
#ifdef SIGTSTP
- (void)signal(SIGTSTP, handle_signal_suspend);
+ (void)signal(SIGTSTP, handle_signal_suspend);
#endif
}
-
/*!
* @brief OSからのシグナルハンドルを初期化する /
* Prepare to handle the relevant signals
void signals_init(void)
{
#ifdef SIGHUP
- (void)signal(SIGHUP, SIG_IGN);
+ (void)signal(SIGHUP, SIG_IGN);
#endif
#ifdef SIGTSTP
- (void)signal(SIGTSTP, handle_signal_suspend);
+ (void)signal(SIGTSTP, handle_signal_suspend);
#endif
#ifdef SIGINT
- (void)signal(SIGINT, handle_signal_simple);
+ (void)signal(SIGINT, handle_signal_simple);
#endif
#ifdef SIGQUIT
- (void)signal(SIGQUIT, handle_signal_simple);
+ (void)signal(SIGQUIT, handle_signal_simple);
#endif
#ifdef SIGFPE
- (void)signal(SIGFPE, handle_signal_abort);
+ (void)signal(SIGFPE, handle_signal_abort);
#endif
#ifdef SIGILL
- (void)signal(SIGILL, handle_signal_abort);
+ (void)signal(SIGILL, handle_signal_abort);
#endif
#ifdef SIGTRAP
- (void)signal(SIGTRAP, handle_signal_abort);
+ (void)signal(SIGTRAP, handle_signal_abort);
#endif
#ifdef SIGIOT
- (void)signal(SIGIOT, handle_signal_abort);
+ (void)signal(SIGIOT, handle_signal_abort);
#endif
#ifdef SIGKILL
- (void)signal(SIGKILL, handle_signal_abort);
+ (void)signal(SIGKILL, handle_signal_abort);
#endif
#ifdef SIGBUS
- (void)signal(SIGBUS, handle_signal_abort);
+ (void)signal(SIGBUS, handle_signal_abort);
#endif
#ifdef SIGSEGV
- (void)signal(SIGSEGV, handle_signal_abort);
+ (void)signal(SIGSEGV, handle_signal_abort);
#endif
#ifdef SIGTERM
- (void)signal(SIGTERM, handle_signal_abort);
+ (void)signal(SIGTERM, handle_signal_abort);
#endif
#ifdef SIGPIPE
- (void)signal(SIGPIPE, handle_signal_abort);
+ (void)signal(SIGPIPE, handle_signal_abort);
#endif
#ifdef SIGEMT
- (void)signal(SIGEMT, handle_signal_abort);
+ (void)signal(SIGEMT, handle_signal_abort);
#endif
#ifdef SIGDANGER
- (void)signal(SIGDANGER, handle_signal_abort);
+ (void)signal(SIGDANGER, handle_signal_abort);
#endif
#ifdef SIGSYS
- (void)signal(SIGSYS, handle_signal_abort);
+ (void)signal(SIGSYS, handle_signal_abort);
#endif
#ifdef SIGXCPU
- (void)signal(SIGXCPU, handle_signal_abort);
+ (void)signal(SIGXCPU, handle_signal_abort);
#endif
#ifdef SIGPWR
- (void)signal(SIGPWR, handle_signal_abort);
+ (void)signal(SIGPWR, handle_signal_abort);
#endif
}
* @brief ダミー /
* Do nothing
*/
-void signals_ignore_tstp(void)
-{
-}
-
+void signals_ignore_tstp(void) {}
/*!
* @brief ダミー /
* Do nothing
*/
-void signals_handle_tstp(void)
-{
-}
-
+void signals_handle_tstp(void) {}
/*!
* @brief ダミー /
* Do nothing
*/
-void signals_init(void)
-{
-}
+void signals_init(void) {}
#endif
/*!
-* todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
-* @file main-win.c
-* @brief Windows版固有実装(メインエントリポイント含む)
-* @date 2018/03/16
-* @author Hengband Team
-* @detail
-*
-* <h3>概要</h3>
-* Windows98かその前後の頃を起点としたAPI実装。
-* 各種のゲームエンジンは無論、
-* DirectXといった昨今描画に標準的となったライブラリも用いていない。
-* タイルの描画処理などについては、現在動作の詳細を検証中。
-*
-* <h3>フォーク元の概要</h3>
-* <p>
-* Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
-*
-* This software may be copied and distributed for educational, research,
-* and not for profit purposes provided that this copyright and statement
-* are included in all such copies.
-* </p>
-* <p>
-* This file helps Angband work with Windows computers.
-*
-* To use this file, use an appropriate "Makefile" or "Project File",
-* make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
-* make sure to obtain various extra files as described below.
-*
-* The official compilation uses the CodeWarrior Pro compiler, which
-* includes a special project file and precompilable header file.
-* </p>
-*
-* <p>
-* The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
-* and/or color redefinitions.
-* </p>
-*
-* <p>
-* The "lib/user/font-win.prf" contains attr/char mappings for use with the
-* normal "lib/xtra/font/*.fon" font files.
-* </p>
-*
-* <p>
-* The "lib/user/graf-win.prf" contains attr/char mappings for use with the
-* special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
-* item.
-* </p>
-*
-* <p>
-* Compiling this file, and using the resulting executable, requires
-* several extra files not distributed with the standard Angband code.
-* In any case, some "*.fon" files (including "8X13.FON" if nothing else)
-* must be placed into "lib/xtra/font/". All of these extra files can be found
-* in the "ext-win" archive.
-* </p>
-*
-* <p>
-* The "term_xtra_win_clear()" function should probably do a low-level
-* clear of the current window, and redraw the borders and other things,
-* if only for efficiency.
-* </p>
-*
-* <p>
-* A simpler method is needed for selecting the "tile size" for windows.
-* </p>
-*
-* <p>
-* The various "warning" messages assume the existance of the "screen.w"
-* window, I think, and only a few calls actually check for its existance,
-* this may be okay since "NULL" means "on top of all windows". (?) The
-* user must never be allowed to "hide" the main window, or the "menubar"
-* will disappear.
-* </p>
-*
-* <p>
-* Special "Windows Help Files" can be placed into "lib/xtra/help/" for
-* use with the "winhelp.exe" program. These files *may* be available
-* at the ftp site somewhere, but I have not seen them.
-* </p>
-*
-* <p>
-* Initial framework (and most code) by Ben Harrison (benh@phial.com).
-*
-* Original code by Skirmantas Kligys (kligys@scf.usc.edu).
-*
-* Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
-* and Chris R. Martin (crm7479@tam2000.tamu.edu).
-* </p>
-*/
+ * todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
+ * @file main-win.c
+ * @brief Windows版固有実装(メインエントリポイント含む)
+ * @date 2018/03/16
+ * @author Hengband Team
+ * @detail
+ *
+ * <h3>概要</h3>
+ * Windows98かその前後の頃を起点としたAPI実装。
+ * 各種のゲームエンジンは無論、
+ * DirectXといった昨今描画に標準的となったライブラリも用いていない。
+ * タイルの描画処理などについては、現在動作の詳細を検証中。
+ *
+ * <h3>フォーク元の概要</h3>
+ * <p>
+ * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
+ *
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.
+ * </p>
+ * <p>
+ * This file helps Angband work with Windows computers.
+ *
+ * To use this file, use an appropriate "Makefile" or "Project File",
+ * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
+ * make sure to obtain various extra files as described below.
+ *
+ * The official compilation uses the CodeWarrior Pro compiler, which
+ * includes a special project file and precompilable header file.
+ * </p>
+ *
+ * <p>
+ * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
+ * and/or color redefinitions.
+ * </p>
+ *
+ * <p>
+ * The "lib/user/font-win.prf" contains attr/char mappings for use with the
+ * normal "lib/xtra/font/*.fon" font files.
+ * </p>
+ *
+ * <p>
+ * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
+ * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
+ * item.
+ * </p>
+ *
+ * <p>
+ * Compiling this file, and using the resulting executable, requires
+ * several extra files not distributed with the standard Angband code.
+ * In any case, some "*.fon" files (including "8X13.FON" if nothing else)
+ * must be placed into "lib/xtra/font/". All of these extra files can be found
+ * in the "ext-win" archive.
+ * </p>
+ *
+ * <p>
+ * The "term_xtra_win_clear()" function should probably do a low-level
+ * clear of the current window, and redraw the borders and other things,
+ * if only for efficiency.
+ * </p>
+ *
+ * <p>
+ * A simpler method is needed for selecting the "tile size" for windows.
+ * </p>
+ *
+ * <p>
+ * The various "warning" messages assume the existance of the "screen.w"
+ * window, I think, and only a few calls actually check for its existance,
+ * this may be okay since "NULL" means "on top of all windows". (?) The
+ * user must never be allowed to "hide" the main window, or the "menubar"
+ * will disappear.
+ * </p>
+ *
+ * <p>
+ * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
+ * use with the "winhelp.exe" program. These files *may* be available
+ * at the ftp site somewhere, but I have not seen them.
+ * </p>
+ *
+ * <p>
+ * Initial framework (and most code) by Ben Harrison (benh@phial.com).
+ *
+ * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
+ *
+ * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
+ * and Chris R. Martin (crm7479@tam2000.tamu.edu).
+ * </p>
+ */
#include "autopick/autopick-pref-processor.h"
#include "cmd-io/cmd-process-screen.h"
#include "world/world.h"
#ifdef WINDOWS
-#include <windows.h>
+#include "dungeon/dungeon.h"
+#include "savedata/save.h"
+#include "term/z-term.h"
#include <direct.h>
#include <locale.h>
-#include "term/z-term.h"
-#include "io/save.h"
-#include "dungeon/dungeon.h"
+#include <windows.h>
/*
* Available graphic modes
*/
-#define GRAPHICS_NONE 0
-#define GRAPHICS_ORIGINAL 1
-#define GRAPHICS_ADAM_BOLT 2
-#define GRAPHICS_HENGBAND 3
+#define GRAPHICS_NONE 0
+#define GRAPHICS_ORIGINAL 1
+#define GRAPHICS_ADAM_BOLT 2
+#define GRAPHICS_HENGBAND 3
/*
* Menu constants -- see "ANGBAND.RC"
*/
-#define IDM_FILE_NEW 100
-#define IDM_FILE_OPEN 101
-#define IDM_FILE_SAVE 110
-#define IDM_FILE_SCORE 120
-#define IDM_FILE_MOVIE 121
-#define IDM_FILE_EXIT 130
-
-#define IDM_WINDOW_VIS_0 200
-#define IDM_WINDOW_VIS_1 201
-#define IDM_WINDOW_VIS_2 202
-#define IDM_WINDOW_VIS_3 203
-#define IDM_WINDOW_VIS_4 204
-#define IDM_WINDOW_VIS_5 205
-#define IDM_WINDOW_VIS_6 206
-#define IDM_WINDOW_VIS_7 207
-
-#define IDM_WINDOW_FONT_0 210
-#define IDM_WINDOW_FONT_1 211
-#define IDM_WINDOW_FONT_2 212
-#define IDM_WINDOW_FONT_3 213
-#define IDM_WINDOW_FONT_4 214
-#define IDM_WINDOW_FONT_5 215
-#define IDM_WINDOW_FONT_6 216
-#define IDM_WINDOW_FONT_7 217
-
-#define IDM_WINDOW_POS_0 220
-#define IDM_WINDOW_POS_1 221
-#define IDM_WINDOW_POS_2 222
-#define IDM_WINDOW_POS_3 223
-#define IDM_WINDOW_POS_4 224
-#define IDM_WINDOW_POS_5 225
-#define IDM_WINDOW_POS_6 226
-#define IDM_WINDOW_POS_7 227
-
-#define IDM_WINDOW_BIZ_0 230
-#define IDM_WINDOW_BIZ_1 231
-#define IDM_WINDOW_BIZ_2 232
-#define IDM_WINDOW_BIZ_3 233
-#define IDM_WINDOW_BIZ_4 234
-#define IDM_WINDOW_BIZ_5 235
-#define IDM_WINDOW_BIZ_6 236
-#define IDM_WINDOW_BIZ_7 237
-
-#define IDM_WINDOW_I_WID_0 240
-#define IDM_WINDOW_I_WID_1 241
-#define IDM_WINDOW_I_WID_2 242
-#define IDM_WINDOW_I_WID_3 243
-#define IDM_WINDOW_I_WID_4 244
-#define IDM_WINDOW_I_WID_5 245
-#define IDM_WINDOW_I_WID_6 246
-#define IDM_WINDOW_I_WID_7 247
-
-#define IDM_WINDOW_D_WID_0 250
-#define IDM_WINDOW_D_WID_1 251
-#define IDM_WINDOW_D_WID_2 252
-#define IDM_WINDOW_D_WID_3 253
-#define IDM_WINDOW_D_WID_4 254
-#define IDM_WINDOW_D_WID_5 255
-#define IDM_WINDOW_D_WID_6 256
-#define IDM_WINDOW_D_WID_7 257
-
-#define IDM_WINDOW_I_HGT_0 260
-#define IDM_WINDOW_I_HGT_1 261
-#define IDM_WINDOW_I_HGT_2 262
-#define IDM_WINDOW_I_HGT_3 263
-#define IDM_WINDOW_I_HGT_4 264
-#define IDM_WINDOW_I_HGT_5 265
-#define IDM_WINDOW_I_HGT_6 266
-#define IDM_WINDOW_I_HGT_7 267
-
-#define IDM_WINDOW_D_HGT_0 270
-#define IDM_WINDOW_D_HGT_1 271
-#define IDM_WINDOW_D_HGT_2 272
-#define IDM_WINDOW_D_HGT_3 273
-#define IDM_WINDOW_D_HGT_4 274
-#define IDM_WINDOW_D_HGT_5 275
-#define IDM_WINDOW_D_HGT_6 276
-#define IDM_WINDOW_D_HGT_7 277
-
-#define IDM_OPTIONS_NO_GRAPHICS 400
-#define IDM_OPTIONS_OLD_GRAPHICS 401
-#define IDM_OPTIONS_NEW_GRAPHICS 402
+#define IDM_FILE_NEW 100
+#define IDM_FILE_OPEN 101
+#define IDM_FILE_SAVE 110
+#define IDM_FILE_SCORE 120
+#define IDM_FILE_MOVIE 121
+#define IDM_FILE_EXIT 130
+
+#define IDM_WINDOW_VIS_0 200
+#define IDM_WINDOW_VIS_1 201
+#define IDM_WINDOW_VIS_2 202
+#define IDM_WINDOW_VIS_3 203
+#define IDM_WINDOW_VIS_4 204
+#define IDM_WINDOW_VIS_5 205
+#define IDM_WINDOW_VIS_6 206
+#define IDM_WINDOW_VIS_7 207
+
+#define IDM_WINDOW_FONT_0 210
+#define IDM_WINDOW_FONT_1 211
+#define IDM_WINDOW_FONT_2 212
+#define IDM_WINDOW_FONT_3 213
+#define IDM_WINDOW_FONT_4 214
+#define IDM_WINDOW_FONT_5 215
+#define IDM_WINDOW_FONT_6 216
+#define IDM_WINDOW_FONT_7 217
+
+#define IDM_WINDOW_POS_0 220
+#define IDM_WINDOW_POS_1 221
+#define IDM_WINDOW_POS_2 222
+#define IDM_WINDOW_POS_3 223
+#define IDM_WINDOW_POS_4 224
+#define IDM_WINDOW_POS_5 225
+#define IDM_WINDOW_POS_6 226
+#define IDM_WINDOW_POS_7 227
+
+#define IDM_WINDOW_BIZ_0 230
+#define IDM_WINDOW_BIZ_1 231
+#define IDM_WINDOW_BIZ_2 232
+#define IDM_WINDOW_BIZ_3 233
+#define IDM_WINDOW_BIZ_4 234
+#define IDM_WINDOW_BIZ_5 235
+#define IDM_WINDOW_BIZ_6 236
+#define IDM_WINDOW_BIZ_7 237
+
+#define IDM_WINDOW_I_WID_0 240
+#define IDM_WINDOW_I_WID_1 241
+#define IDM_WINDOW_I_WID_2 242
+#define IDM_WINDOW_I_WID_3 243
+#define IDM_WINDOW_I_WID_4 244
+#define IDM_WINDOW_I_WID_5 245
+#define IDM_WINDOW_I_WID_6 246
+#define IDM_WINDOW_I_WID_7 247
+
+#define IDM_WINDOW_D_WID_0 250
+#define IDM_WINDOW_D_WID_1 251
+#define IDM_WINDOW_D_WID_2 252
+#define IDM_WINDOW_D_WID_3 253
+#define IDM_WINDOW_D_WID_4 254
+#define IDM_WINDOW_D_WID_5 255
+#define IDM_WINDOW_D_WID_6 256
+#define IDM_WINDOW_D_WID_7 257
+
+#define IDM_WINDOW_I_HGT_0 260
+#define IDM_WINDOW_I_HGT_1 261
+#define IDM_WINDOW_I_HGT_2 262
+#define IDM_WINDOW_I_HGT_3 263
+#define IDM_WINDOW_I_HGT_4 264
+#define IDM_WINDOW_I_HGT_5 265
+#define IDM_WINDOW_I_HGT_6 266
+#define IDM_WINDOW_I_HGT_7 267
+
+#define IDM_WINDOW_D_HGT_0 270
+#define IDM_WINDOW_D_HGT_1 271
+#define IDM_WINDOW_D_HGT_2 272
+#define IDM_WINDOW_D_HGT_3 273
+#define IDM_WINDOW_D_HGT_4 274
+#define IDM_WINDOW_D_HGT_5 275
+#define IDM_WINDOW_D_HGT_6 276
+#define IDM_WINDOW_D_HGT_7 277
+
+#define IDM_OPTIONS_NO_GRAPHICS 400
+#define IDM_OPTIONS_OLD_GRAPHICS 401
+#define IDM_OPTIONS_NEW_GRAPHICS 402
#define IDM_OPTIONS_NEW2_GRAPHICS 403
-#define IDM_OPTIONS_BIGTILE 409
-#define IDM_OPTIONS_SOUND 410
-#define IDM_OPTIONS_MUSIC 411
-#define IDM_OPTIONS_SAVER 420
-#define IDM_OPTIONS_MAP 430
-#define IDM_OPTIONS_BG 440
-#define IDM_OPTIONS_OPEN_BG 441
+#define IDM_OPTIONS_BIGTILE 409
+#define IDM_OPTIONS_SOUND 410
+#define IDM_OPTIONS_MUSIC 411
+#define IDM_OPTIONS_SAVER 420
+#define IDM_OPTIONS_MAP 430
+#define IDM_OPTIONS_BG 440
+#define IDM_OPTIONS_OPEN_BG 441
-#define IDM_DUMP_SCREEN_HTML 450
+#define IDM_DUMP_SCREEN_HTML 450
-#define IDM_HELP_CONTENTS 901
+#define IDM_HELP_CONTENTS 901
/*
* Exclude parts of WINDOWS.H that are not needed (Win32)
*/
#define WIN32_LEAN_AND_MEAN
-#define NONLS /* All NLS defines and routines */
-#define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
-#define NOMCX /* Modem Configuration Extensions */
+#define NONLS /* All NLS defines and routines */
+#define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
+#define NOMCX /* Modem Configuration Extensions */
/*
* Include the "windows" support file
#include <windows.h>
/*
-* Exclude parts of MMSYSTEM.H that are not needed
-*/
-#define MMNODRV /* Installable driver support */
-#define MMNOWAVE /* Waveform support */
-#define MMNOMIDI /* MIDI support */
-#define MMNOAUX /* Auxiliary audio support */
-#define MMNOTIMER /* Timer support */
-#define MMNOJOY /* Joystick support */
-#define MMNOMCI /* MCI support */
-#define MMNOMMIO /* Multimedia file I/O support */
+ * Exclude parts of MMSYSTEM.H that are not needed
+ */
+#define MMNODRV /* Installable driver support */
+#define MMNOWAVE /* Waveform support */
+#define MMNOMIDI /* MIDI support */
+#define MMNOAUX /* Auxiliary audio support */
+#define MMNOTIMER /* Timer support */
+#define MMNOJOY /* Joystick support */
+#define MMNOMCI /* MCI support */
+#define MMNOMMIO /* Multimedia file I/O support */
#define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
#define MOUSE_SENS 40
* doesn't use mmsystem.h instead it includes the winmm library
* which performs a similar function.
*/
-#include <mmsystem.h>
#include <commdlg.h>
+#include <mmsystem.h>
/*
* Include the support for loading bitmaps
*/
#include "term/readdib.h"
-#define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
+#define MoveTo(H, X, Y) MoveToEx(H, X, Y, NULL)
/*
* Foreground color bits
*/
-#define VID_BLACK 0x00
-#define VID_BLUE 0x01
-#define VID_GREEN 0x02
-#define VID_CYAN 0x03
-#define VID_RED 0x04
-#define VID_MAGENTA 0x05
-#define VID_YELLOW 0x06
-#define VID_WHITE 0x07
+#define VID_BLACK 0x00
+#define VID_BLUE 0x01
+#define VID_GREEN 0x02
+#define VID_CYAN 0x03
+#define VID_RED 0x04
+#define VID_MAGENTA 0x05
+#define VID_YELLOW 0x06
+#define VID_WHITE 0x07
/*
* Bright text
*/
-#define VID_BRIGHT 0x08
+#define VID_BRIGHT 0x08
/*!
* @struct term_data
* as attempting to represent the name of a font.
* </p>
*/
-typedef struct
-{
- term t;
- concptr s;
- HWND w;
- DWORD dwStyle;
- DWORD dwExStyle;
-
- uint keys;
- TERM_LEN rows; /* int -> uint */
- TERM_LEN cols;
-
- uint pos_x; //!< タームの左上X座標
- uint pos_y; //!< タームの左上Y座標
- uint size_wid;
- uint size_hgt;
- uint size_ow1;
- uint size_oh1;
- uint size_ow2;
- uint size_oh2;
-
- bool size_hack;
- bool xtra_hack;
- bool visible;
- bool bizarre;
- concptr font_want;
- concptr font_file;
- HFONT font_id;
- int font_wid; //!< フォント横幅
- int font_hgt; //!< フォント縦幅
- int tile_wid; //!< タイル横幅
- int tile_hgt; //!< タイル縦幅
-
- uint map_tile_wid;
- uint map_tile_hgt;
-
- bool map_active;
- LOGFONT lf;
-
- bool posfix;
+typedef struct {
+ term t;
+ concptr s;
+ HWND w;
+ DWORD dwStyle;
+ DWORD dwExStyle;
+
+ uint keys;
+ TERM_LEN rows; /* int -> uint */
+ TERM_LEN cols;
+
+ uint pos_x; //!< タームの左上X座標
+ uint pos_y; //!< タームの左上Y座標
+ uint size_wid;
+ uint size_hgt;
+ uint size_ow1;
+ uint size_oh1;
+ uint size_ow2;
+ uint size_oh2;
+
+ bool size_hack;
+ bool xtra_hack;
+ bool visible;
+ bool bizarre;
+ concptr font_want;
+ concptr font_file;
+ HFONT font_id;
+ int font_wid; //!< フォント横幅
+ int font_hgt; //!< フォント縦幅
+ int tile_wid; //!< タイル横幅
+ int tile_hgt; //!< タイル縦幅
+
+ uint map_tile_wid;
+ uint map_tile_hgt;
+
+ bool map_active;
+ LOGFONT lf;
+
+ bool posfix;
} term_data;
-#define MAX_TERM_DATA 8 //!< Maximum number of windows
+#define MAX_TERM_DATA 8 //!< Maximum number of windows
static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
static term_data *my_td; //!< Hack -- global "window creation" pointer
*/
static COLORREF win_clr[256];
-
/*
* Flag for macro trigger with dump ASCII
*/
* The entries below are taken from the "color bits" defined above.
* Note that many of the choices below suck, but so do crappy monitors.
*/
-static BYTE win_pal[256] =
-{
- VID_BLACK, /* Dark */
- VID_WHITE, /* White */
- VID_CYAN, /* Slate XXX */
- VID_RED | VID_BRIGHT, /* Orange XXX */
- VID_RED, /* Red */
- VID_GREEN, /* Green */
- VID_BLUE, /* Blue */
- VID_YELLOW, /* Umber XXX */
- VID_BLACK | VID_BRIGHT, /* Light Dark */
- VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
- VID_MAGENTA, /* Violet XXX */
- VID_YELLOW | VID_BRIGHT, /* Yellow */
- VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
- VID_GREEN | VID_BRIGHT, /* Light Green */
- VID_BLUE | VID_BRIGHT, /* Light Blue */
- VID_YELLOW /* Light Umber XXX */
+static BYTE win_pal[256] = {
+ VID_BLACK, /* Dark */
+ VID_WHITE, /* White */
+ VID_CYAN, /* Slate XXX */
+ VID_RED | VID_BRIGHT, /* Orange XXX */
+ VID_RED, /* Red */
+ VID_GREEN, /* Green */
+ VID_BLUE, /* Blue */
+ VID_YELLOW, /* Umber XXX */
+ VID_BLACK | VID_BRIGHT, /* Light Dark */
+ VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
+ VID_MAGENTA, /* Violet XXX */
+ VID_YELLOW | VID_BRIGHT, /* Yellow */
+ VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
+ VID_GREEN | VID_BRIGHT, /* Light Green */
+ VID_BLUE | VID_BRIGHT, /* Light Blue */
+ VID_YELLOW /* Light Umber XXX */
};
/*
* Hack -- initialization list for "special_key"
*/
static byte special_key_list[] = {
- VK_CLEAR, VK_PAUSE, VK_CAPITAL,
- VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
- VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
- VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
- VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
- VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
- VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
- VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
- VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
- VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
- VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
- VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
- VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
- VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
- VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
- VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
- VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
- VK_NONAME, VK_PA1,
- 0 /* End of List */
+ VK_CLEAR, VK_PAUSE, VK_CAPITAL, VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI, VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE, VK_PRIOR, VK_NEXT, VK_END,
+ VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT, VK_INSERT, VK_DELETE, VK_HELP, VK_APPS, VK_NUMPAD0, VK_NUMPAD1,
+ VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD, VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL,
+ VK_DIVIDE, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19,
+ VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL, VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM, VK_NONAME, VK_PA1,
+ 0 /* End of List */
};
static byte ignore_key_list[] = {
- VK_ESCAPE, VK_TAB, VK_SPACE,
- 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
- VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
- VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
- VK_LMENU, VK_RMENU,
- 0 /* End of List */
+ VK_ESCAPE, VK_TAB, VK_SPACE, 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
+ VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL, VK_LMENU, VK_RMENU, 0 /* End of List */
};
/* Function prototype */
/* bg */
static void delete_bg(void)
{
- if (hBG != NULL)
- {
- DeleteObject(hBG);
- hBG = NULL;
- }
+ if (hBG != NULL) {
+ DeleteObject(hBG);
+ hBG = NULL;
+ }
}
-
static int init_bg(void)
{
- char * bmfile = bg_bitmap_file;
- delete_bg();
- if (use_bg == 0) return 0;
-
- hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- if (!hBG) {
- plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
- use_bg = 0;
- return 0;
- }
-
- use_bg = 1;
- return 1;
+ char *bmfile = bg_bitmap_file;
+ delete_bg();
+ if (use_bg == 0)
+ return 0;
+
+ hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ if (!hBG) {
+ plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
+ use_bg = 0;
+ return 0;
+ }
+
+ use_bg = 1;
+ return 1;
}
-
static void DrawBG(HDC hdc, RECT *r)
{
- if (!use_bg || !hBG)
- return;
-
- int x = r->left, y = r->top;
- int nx = x;
- int ny = y;
- BITMAP bm;
- GetObject(hBG, sizeof(bm), &bm);
- int swid = bm.bmWidth;
- int shgt = bm.bmHeight;
-
- HDC hdcSrc = CreateCompatibleDC(hdc);
- HBITMAP hOld = SelectObject(hdcSrc, hBG);
-
- do {
- int sx = nx % swid;
- int cwid = MIN(swid - sx, r->right - nx);
- do {
- int sy = ny % shgt;
- int chgt = MIN(shgt - sy, r->bottom - ny);
- BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
- ny += chgt;
- } while (ny < r->bottom);
-
- ny = y;
- nx += cwid;
- } while (nx < r->right);
-
- SelectObject(hdcSrc, hOld);
- DeleteDC(hdcSrc);
+ if (!use_bg || !hBG)
+ return;
+
+ int x = r->left, y = r->top;
+ int nx = x;
+ int ny = y;
+ BITMAP bm;
+ GetObject(hBG, sizeof(bm), &bm);
+ int swid = bm.bmWidth;
+ int shgt = bm.bmHeight;
+
+ HDC hdcSrc = CreateCompatibleDC(hdc);
+ HBITMAP hOld = SelectObject(hdcSrc, hBG);
+
+ do {
+ int sx = nx % swid;
+ int cwid = MIN(swid - sx, r->right - nx);
+ do {
+ int sy = ny % shgt;
+ int chgt = MIN(shgt - sy, r->bottom - ny);
+ BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
+ ny += chgt;
+ } while (ny < r->bottom);
+
+ ny = y;
+ nx += cwid;
+ } while (nx < r->right);
+
+ SelectObject(hdcSrc, hOld);
+ DeleteDC(hdcSrc);
}
-
/*
* Check for existance of a file
*/
static bool check_file(concptr s)
{
- char path[1024];
- strcpy(path, s);
- DWORD attrib = GetFileAttributes(path);
- if (attrib == INVALID_FILE_NAME) return FALSE;
- if (attrib & FILE_ATTRIBUTE_DIRECTORY) return FALSE;
-
- return TRUE;
+ char path[1024];
+ strcpy(path, s);
+ DWORD attrib = GetFileAttributes(path);
+ if (attrib == INVALID_FILE_NAME)
+ return FALSE;
+ if (attrib & FILE_ATTRIBUTE_DIRECTORY)
+ return FALSE;
+
+ return TRUE;
}
-
/*
* Check for existance of a directory
*/
static bool check_dir(concptr s)
{
- char path[1024];
- strcpy(path, s);
- int i = strlen(path);
- if (i && (path[i - 1] == '\\')) path[--i] = '\0';
-
- DWORD attrib = GetFileAttributes(path);
- if (attrib == INVALID_FILE_NAME) return FALSE;
- if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return FALSE;
-
- return TRUE;
+ char path[1024];
+ strcpy(path, s);
+ int i = strlen(path);
+ if (i && (path[i - 1] == '\\'))
+ path[--i] = '\0';
+
+ DWORD attrib = GetFileAttributes(path);
+ if (attrib == INVALID_FILE_NAME)
+ return FALSE;
+ if (!(attrib & FILE_ATTRIBUTE_DIRECTORY))
+ return FALSE;
+
+ return TRUE;
}
-
/*
* Validate a file
*/
static void validate_file(concptr s)
{
- if (check_file(s)) return;
+ if (check_file(s))
+ return;
- quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
+ quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
}
-
/*
* Validate a directory
*/
static void validate_dir(concptr s, bool vital)
{
- if (check_dir(s)) return;
-
- if (vital)
- {
- quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
- }
- else if (mkdir(s))
- {
- quit_fmt("Unable to create directory:\n%s", s);
- }
+ if (check_dir(s))
+ return;
+
+ if (vital) {
+ quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
+ } else if (mkdir(s)) {
+ quit_fmt("Unable to create directory:\n%s", s);
+ }
}
-
/*!
* @brief (Windows版固有実装)Get the "size" for a window
*/
static void term_getsize(term_data *td)
{
- if (td->cols < 1) td->cols = 1;
- if (td->rows < 1) td->rows = 1;
-
- TERM_LEN wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
- TERM_LEN hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
-
- RECT rc;
- rc.left = 0;
- rc.right = rc.left + wid;
- rc.top = 0;
- rc.bottom = rc.top + hgt;
-
- AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
- td->size_wid = rc.right - rc.left;
- td->size_hgt = rc.bottom - rc.top;
- if (!td->w) return;
-
- GetWindowRect(td->w, &rc);
- td->pos_x = rc.left;
- td->pos_y = rc.top;
+ if (td->cols < 1)
+ td->cols = 1;
+ if (td->rows < 1)
+ td->rows = 1;
+
+ TERM_LEN wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
+ TERM_LEN hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
+
+ RECT rc;
+ rc.left = 0;
+ rc.right = rc.left + wid;
+ rc.top = 0;
+ rc.bottom = rc.top + hgt;
+
+ AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
+ td->size_wid = rc.right - rc.left;
+ td->size_hgt = rc.bottom - rc.top;
+ if (!td->w)
+ return;
+
+ GetWindowRect(td->w, &rc);
+ td->pos_x = rc.left;
+ td->pos_y = rc.top;
}
-
/*
* Write the "prefs" for a single term
*/
static void save_prefs_aux(int i)
{
- term_data *td = &data[i];
- GAME_TEXT sec_name[128];
- char buf[1024];
+ term_data *td = &data[i];
+ GAME_TEXT sec_name[128];
+ char buf[1024];
- if (!td->w) return;
+ if (!td->w)
+ return;
- sprintf(sec_name, "Term-%d", i);
+ sprintf(sec_name, "Term-%d", i);
- if (i > 0)
- {
- strcpy(buf, td->visible ? "1" : "0");
- WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
- }
+ if (i > 0) {
+ strcpy(buf, td->visible ? "1" : "0");
+ WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
+ }
#ifdef JP
- strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
+ strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
#else
- strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
+ strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
#endif
- WritePrivateProfileString(sec_name, "Font", buf, ini_file);
-
- wsprintf(buf, "%d", td->lf.lfWidth);
- WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
- wsprintf(buf, "%d", td->lf.lfHeight);
- WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
- wsprintf(buf, "%d", td->lf.lfWeight);
- WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
-
- strcpy(buf, td->bizarre ? "1" : "0");
- WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
-
- wsprintf(buf, "%d", td->tile_wid);
- WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
-
- wsprintf(buf, "%d", td->tile_hgt);
- WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
-
- WINDOWPLACEMENT lpwndpl;
- lpwndpl.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement(td->w, &lpwndpl);
-
- RECT rc = lpwndpl.rcNormalPosition;
- if (i == 0) wsprintf(buf, "%d", normsize.x);
- else wsprintf(buf, "%d", td->cols);
-
- WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
-
- if (i == 0) wsprintf(buf, "%d", normsize.y);
- else wsprintf(buf, "%d", td->rows);
-
- WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
- if (i == 0)
- {
- strcpy(buf, IsZoomed(td->w) ? "1" : "0");
- WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
- }
-
- GetWindowRect(td->w, &rc);
- wsprintf(buf, "%d", rc.left);
- WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
-
- wsprintf(buf, "%d", rc.top);
- WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
- if (i > 0)
- {
- strcpy(buf, td->posfix ? "1" : "0");
- WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
- }
+ WritePrivateProfileString(sec_name, "Font", buf, ini_file);
+
+ wsprintf(buf, "%d", td->lf.lfWidth);
+ WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
+ wsprintf(buf, "%d", td->lf.lfHeight);
+ WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
+ wsprintf(buf, "%d", td->lf.lfWeight);
+ WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
+
+ strcpy(buf, td->bizarre ? "1" : "0");
+ WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
+
+ wsprintf(buf, "%d", td->tile_wid);
+ WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
+
+ wsprintf(buf, "%d", td->tile_hgt);
+ WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
+
+ WINDOWPLACEMENT lpwndpl;
+ lpwndpl.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(td->w, &lpwndpl);
+
+ RECT rc = lpwndpl.rcNormalPosition;
+ if (i == 0)
+ wsprintf(buf, "%d", normsize.x);
+ else
+ wsprintf(buf, "%d", td->cols);
+
+ WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
+
+ if (i == 0)
+ wsprintf(buf, "%d", normsize.y);
+ else
+ wsprintf(buf, "%d", td->rows);
+
+ WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
+ if (i == 0) {
+ strcpy(buf, IsZoomed(td->w) ? "1" : "0");
+ WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
+ }
+
+ GetWindowRect(td->w, &rc);
+ wsprintf(buf, "%d", rc.left);
+ WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
+
+ wsprintf(buf, "%d", rc.top);
+ WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
+ if (i > 0) {
+ strcpy(buf, td->posfix ? "1" : "0");
+ WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
+ }
}
-
/*
* Write the "prefs"
* We assume that the windows have all been initialized
*/
static void save_prefs(void)
{
- char buf[128];
- sprintf(buf, "%d", arg_graphics);
- WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
+ char buf[128];
+ sprintf(buf, "%d", arg_graphics);
+ WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
- strcpy(buf, arg_bigtile ? "1" : "0");
- WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
+ strcpy(buf, arg_bigtile ? "1" : "0");
+ WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
- strcpy(buf, arg_sound ? "1" : "0");
- WritePrivateProfileString("Angband", "Sound", buf, ini_file);
+ strcpy(buf, arg_sound ? "1" : "0");
+ WritePrivateProfileString("Angband", "Sound", buf, ini_file);
- strcpy(buf, arg_music ? "1" : "0");
- WritePrivateProfileString("Angband", "Music", buf, ini_file);
+ strcpy(buf, arg_music ? "1" : "0");
+ WritePrivateProfileString("Angband", "Music", buf, ini_file);
- strcpy(buf, use_bg ? "1" : "0");
- WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
- WritePrivateProfileString("Angband", "BackGroundBitmap",
- bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
+ strcpy(buf, use_bg ? "1" : "0");
+ WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
+ WritePrivateProfileString("Angband", "BackGroundBitmap", bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
- for (int i = 0; i < MAX_TERM_DATA; ++i)
- {
- save_prefs_aux(i);
- }
+ for (int i = 0; i < MAX_TERM_DATA; ++i) {
+ save_prefs_aux(i);
+ }
}
-
/*
* Load the "prefs" for a single term
*/
static void load_prefs_aux(int i)
{
- term_data *td = &data[i];
- GAME_TEXT sec_name[128];
- char tmp[1024];
-
- int dispx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- int dispy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- int posx = 0;
- int posy = 0;
-
- sprintf(sec_name, "Term-%d", i);
- sprintf(sec_name, "Term-%d", i);
- if (i > 0)
- {
- td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
- }
+ term_data *td = &data[i];
+ GAME_TEXT sec_name[128];
+ char tmp[1024];
+
+ int dispx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ int dispy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ int posx = 0;
+ int posy = 0;
+
+ sprintf(sec_name, "Term-%d", i);
+ sprintf(sec_name, "Term-%d", i);
+ if (i > 0) {
+ td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
+ }
#ifdef JP
- GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
+ GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
#else
- GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
+ GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
#endif
- td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
+ td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
- td->font_want = string_make(tmp);
- int hgt = 15;
- int wid = 0;
- td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
- td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
- td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
+ td->font_want = string_make(tmp);
+ int hgt = 15;
+ int wid = 0;
+ td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
+ td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
+ td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
- td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
- td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
+ td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
+ td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
- td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
- td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
- normsize.x = td->cols; normsize.y = td->rows;
+ td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
+ td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
+ normsize.x = td->cols;
+ normsize.y = td->rows;
- if (i == 0)
- {
- win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
- }
+ if (i == 0) {
+ win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
+ }
- posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
- posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
- td->pos_x = MIN(MAX(0, posx), dispx - 128);
- td->pos_y = MIN(MAX(0, posy), dispy - 128);
+ posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
+ posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
+ td->pos_x = MIN(MAX(0, posx), dispx - 128);
+ td->pos_y = MIN(MAX(0, posy), dispy - 128);
- if (i > 0)
- {
- td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
- }
+ if (i > 0) {
+ td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
+ }
}
-
/*
* Load the "prefs"
*/
static void load_prefs(void)
{
- arg_graphics = (byte)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
- arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
- use_bigtile = arg_bigtile;
- arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
- arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
- use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
- GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
- for (int i = 0; i < MAX_TERM_DATA; ++i)
- {
- load_prefs_aux(i);
- }
+ arg_graphics = (byte)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
+ arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
+ use_bigtile = arg_bigtile;
+ arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
+ arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
+ use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
+ GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
+ for (int i = 0; i < MAX_TERM_DATA; ++i) {
+ load_prefs_aux(i);
+ }
}
-
/*
* - Taken from files.c.
*
*/
static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
{
- s16b k = 0;
- char *s = buf;
+ s16b k = 0;
+ char *s = buf;
- while (k < num)
- {
- char *t;
- for (; *s && iswspace(*s); ++s) /* loop */;
+ while (k < num) {
+ char *t;
+ for (; *s && iswspace(*s); ++s) /* loop */
+ ;
- if (!*s) break;
+ if (!*s)
+ break;
- for (t = s; *t && !iswspace(*t); ++t) /* loop */;
+ for (t = s; *t && !iswspace(*t); ++t) /* loop */
+ ;
- if (*t) *t++ = '\0';
+ if (*t)
+ *t++ = '\0';
- tokens[k++] = s;
- s = t;
- }
+ tokens[k++] = s;
+ s = t;
+ }
- return k;
+ return k;
}
-
static void load_sound_prefs(void)
{
- char tmp[1024];
- char ini_path[1024];
- char wav_path[1024];
- char *zz[SAMPLE_SOUND_MAX];
-
- path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
- for (int i = 0; i < SOUND_MAX; i++)
- {
- GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
- int num = tokenize_whitespace(tmp, SAMPLE_SOUND_MAX, zz);
- for (int j = 0; j < num; j++)
- {
- /* Access the sound */
- path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
-
- /* Save the sound filename, if it exists */
- if (check_file(wav_path))
- sound_file[i][j] = string_make(zz[j]);
- }
- }
+ char tmp[1024];
+ char ini_path[1024];
+ char wav_path[1024];
+ char *zz[SAMPLE_SOUND_MAX];
+
+ path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
+ for (int i = 0; i < SOUND_MAX; i++) {
+ GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
+ int num = tokenize_whitespace(tmp, SAMPLE_SOUND_MAX, zz);
+ for (int j = 0; j < num; j++) {
+ /* Access the sound */
+ path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
+
+ /* Save the sound filename, if it exists */
+ if (check_file(wav_path))
+ sound_file[i][j] = string_make(zz[j]);
+ }
+ }
}
-
static void load_music_prefs(void)
{
- char tmp[1024];
- char ini_path[1024];
- char wav_path[1024];
- char *zz[SAMPLE_MUSIC_MAX];
- char key[80];
-
- path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
- GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
- for (int i = 0; i < MUSIC_BASIC_MAX; i++)
- {
- GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
- int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
- for (int j = 0; j < num; j++)
- {
- path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
- if (check_file(wav_path))
- music_file[i][j] = string_make(zz[j]);
- }
- }
-
- for (int i = 0; i < current_world_ptr->max_d_idx; i++)
- {
- sprintf(key, "dungeon%03d", i);
- GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
- int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
- for (int j = 0; j < num; j++)
- {
- path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
- if (check_file(wav_path))
- dungeon_music_file[i][j] = string_make(zz[j]);
- }
- }
-
- for (int i = 0; i < max_q_idx; i++)
- {
- sprintf(key, "quest%03d", i);
- GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
- int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
- for (int j = 0; j < num; j++)
- {
- path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
- if (check_file(wav_path))
- quest_music_file[i][j] = string_make(zz[j]);
- }
- }
-
- for (int i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
- {
- sprintf(key, "town%03d", i);
- GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
- int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
- for (int j = 0; j < num; j++)
- {
- path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
- if (check_file(wav_path))
- town_music_file[i][j] = string_make(zz[j]);
- }
- }
+ char tmp[1024];
+ char ini_path[1024];
+ char wav_path[1024];
+ char *zz[SAMPLE_MUSIC_MAX];
+ char key[80];
+
+ path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
+ GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
+ for (int i = 0; i < MUSIC_BASIC_MAX; i++) {
+ GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
+ int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
+ for (int j = 0; j < num; j++) {
+ path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
+ if (check_file(wav_path))
+ music_file[i][j] = string_make(zz[j]);
+ }
+ }
+
+ for (int i = 0; i < current_world_ptr->max_d_idx; i++) {
+ sprintf(key, "dungeon%03d", i);
+ GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
+ int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
+ for (int j = 0; j < num; j++) {
+ path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
+ if (check_file(wav_path))
+ dungeon_music_file[i][j] = string_make(zz[j]);
+ }
+ }
+
+ for (int i = 0; i < max_q_idx; i++) {
+ sprintf(key, "quest%03d", i);
+ GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
+ int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
+ for (int j = 0; j < num; j++) {
+ path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
+ if (check_file(wav_path))
+ quest_music_file[i][j] = string_make(zz[j]);
+ }
+ }
+
+ for (int i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
+ {
+ sprintf(key, "town%03d", i);
+ GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
+ int num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
+ for (int j = 0; j < num; j++) {
+ path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
+ if (check_file(wav_path))
+ town_music_file[i][j] = string_make(zz[j]);
+ }
+ }
}
-
/*
* Create the new global palette based on the bitmap palette
* (if any), and the standard 16 entry palette derived from
*/
static int new_palette(void)
{
- int i, nEntries;
- int pLogPalSize;
- int lppeSize;
- LPLOGPALETTE pLogPal;
- LPPALETTEENTRY lppe;
- term_data *td;
- if (!paletted) return TRUE;
-
- lppeSize = 0;
- lppe = NULL;
- nEntries = 0;
-
- HPALETTE hBmPal = infGraph.hPalette;
- if (hBmPal)
- {
- lppeSize = 256 * sizeof(PALETTEENTRY);
- lppe = (LPPALETTEENTRY)ralloc(lppeSize);
- nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
- if ((nEntries == 0) || (nEntries > 220))
- {
- plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
- rnfree(lppe, lppeSize);
- return FALSE;
- }
- }
-
- pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
- pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
- pLogPal->palVersion = 0x300;
- pLogPal->palNumEntries = nEntries + 16;
- for (i = 0; i < nEntries; i++)
- {
- pLogPal->palPalEntry[i] = lppe[i];
- }
-
- for (i = 0; i < 16; i++)
- {
- LPPALETTEENTRY p;
- p = &(pLogPal->palPalEntry[i + nEntries]);
- p->peRed = GetRValue(win_clr[i]);
- p->peGreen = GetGValue(win_clr[i]);
- p->peBlue = GetBValue(win_clr[i]);
- p->peFlags = PC_NOCOLLAPSE;
- }
-
- if (lppe) rnfree(lppe, lppeSize);
-
- HPALETTE hNewPal = CreatePalette(pLogPal);
- if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
-
- rnfree(pLogPal, pLogPalSize);
- td = &data[0];
- HDC hdc = GetDC(td->w);
- SelectPalette(hdc, hNewPal, 0);
- i = RealizePalette(hdc);
- ReleaseDC(td->w, hdc);
- if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
-
- for (i = 1; i < MAX_TERM_DATA; i++)
- {
- td = &data[i];
- hdc = GetDC(td->w);
- SelectPalette(hdc, hNewPal, 0);
- ReleaseDC(td->w, hdc);
- }
-
- if (hPal) DeleteObject(hPal);
-
- hPal = hNewPal;
- return TRUE;
+ int i, nEntries;
+ int pLogPalSize;
+ int lppeSize;
+ LPLOGPALETTE pLogPal;
+ LPPALETTEENTRY lppe;
+ term_data *td;
+ if (!paletted)
+ return TRUE;
+
+ lppeSize = 0;
+ lppe = NULL;
+ nEntries = 0;
+
+ HPALETTE hBmPal = infGraph.hPalette;
+ if (hBmPal) {
+ lppeSize = 256 * sizeof(PALETTEENTRY);
+ lppe = (LPPALETTEENTRY)ralloc(lppeSize);
+ nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
+ if ((nEntries == 0) || (nEntries > 220)) {
+ plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
+ rnfree(lppe, lppeSize);
+ return FALSE;
+ }
+ }
+
+ pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
+ pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
+ pLogPal->palVersion = 0x300;
+ pLogPal->palNumEntries = nEntries + 16;
+ for (i = 0; i < nEntries; i++) {
+ pLogPal->palPalEntry[i] = lppe[i];
+ }
+
+ for (i = 0; i < 16; i++) {
+ LPPALETTEENTRY p;
+ p = &(pLogPal->palPalEntry[i + nEntries]);
+ p->peRed = GetRValue(win_clr[i]);
+ p->peGreen = GetGValue(win_clr[i]);
+ p->peBlue = GetBValue(win_clr[i]);
+ p->peFlags = PC_NOCOLLAPSE;
+ }
+
+ if (lppe)
+ rnfree(lppe, lppeSize);
+
+ HPALETTE hNewPal = CreatePalette(pLogPal);
+ if (!hNewPal)
+ quit(_("パレットを作成できません!", "Cannot create palette!"));
+
+ rnfree(pLogPal, pLogPalSize);
+ td = &data[0];
+ HDC hdc = GetDC(td->w);
+ SelectPalette(hdc, hNewPal, 0);
+ i = RealizePalette(hdc);
+ ReleaseDC(td->w, hdc);
+ if (i == 0)
+ quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
+
+ for (i = 1; i < MAX_TERM_DATA; i++) {
+ td = &data[i];
+ hdc = GetDC(td->w);
+ SelectPalette(hdc, hNewPal, 0);
+ ReleaseDC(td->w, hdc);
+ }
+
+ if (hPal)
+ DeleteObject(hPal);
+
+ hPal = hNewPal;
+ return TRUE;
}
-
/*!
* @brief グラフィクスを初期化する / Initialize graphics
* @details
*/
static bool init_graphics(void)
{
- char buf[1024];
- BYTE wid, hgt, twid, thgt, ox, oy;
- concptr name;
-
- if (arg_graphics == GRAPHICS_ADAM_BOLT)
- {
- wid = 16;
- hgt = 16;
- twid = 16;
- thgt = 16;
- ox = 0;
- oy = 0;
- name = "16X16.BMP";
-
- ANGBAND_GRAF = "new";
- }
- else if (arg_graphics == GRAPHICS_HENGBAND)
- {
- wid = 32;
- hgt = 32;
- twid = 32;
- thgt = 32;
- ox = 0;
- oy = 0;
- name = "32X32.BMP";
-
- ANGBAND_GRAF = "ne2";
- }
- else
- {
- wid = 8;
- hgt = 8;
- twid = 8;
- thgt = 8;
- ox = 0;
- oy = 0;
- name = "8X8.BMP";
- ANGBAND_GRAF = "old";
- }
-
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
- if (!ReadDIB(data[0].w, buf, &infGraph))
- {
- plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
- return FALSE;
- }
-
- infGraph.CellWidth = wid;
- infGraph.CellHeight = hgt;
- infGraph.TileWidth = twid;
- infGraph.TileHeight = thgt;
- infGraph.OffsetX = ox;
- infGraph.OffsetY = oy;
-
- if (arg_graphics == GRAPHICS_ADAM_BOLT)
- {
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
- if (!ReadDIB(data[0].w, buf, &infMask))
- {
- plog_fmt("Cannot read bitmap file '%s'", buf);
- return FALSE;
- }
- }
-
- if (arg_graphics == GRAPHICS_HENGBAND)
- {
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
- if (!ReadDIB(data[0].w, buf, &infMask))
- {
- plog_fmt("Cannot read bitmap file '%s'", buf);
- return FALSE;
- }
- }
-
- if (!new_palette())
- {
- plog(_("パレットを実現できません!", "Cannot activate palette!"));
- return FALSE;
- }
-
- current_graphics_mode = arg_graphics;
- return (current_graphics_mode);
+ char buf[1024];
+ BYTE wid, hgt, twid, thgt, ox, oy;
+ concptr name;
+
+ if (arg_graphics == GRAPHICS_ADAM_BOLT) {
+ wid = 16;
+ hgt = 16;
+ twid = 16;
+ thgt = 16;
+ ox = 0;
+ oy = 0;
+ name = "16X16.BMP";
+
+ ANGBAND_GRAF = "new";
+ } else if (arg_graphics == GRAPHICS_HENGBAND) {
+ wid = 32;
+ hgt = 32;
+ twid = 32;
+ thgt = 32;
+ ox = 0;
+ oy = 0;
+ name = "32X32.BMP";
+
+ ANGBAND_GRAF = "ne2";
+ } else {
+ wid = 8;
+ hgt = 8;
+ twid = 8;
+ thgt = 8;
+ ox = 0;
+ oy = 0;
+ name = "8X8.BMP";
+ ANGBAND_GRAF = "old";
+ }
+
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
+ if (!ReadDIB(data[0].w, buf, &infGraph)) {
+ plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
+ return FALSE;
+ }
+
+ infGraph.CellWidth = wid;
+ infGraph.CellHeight = hgt;
+ infGraph.TileWidth = twid;
+ infGraph.TileHeight = thgt;
+ infGraph.OffsetX = ox;
+ infGraph.OffsetY = oy;
+
+ if (arg_graphics == GRAPHICS_ADAM_BOLT) {
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
+ if (!ReadDIB(data[0].w, buf, &infMask)) {
+ plog_fmt("Cannot read bitmap file '%s'", buf);
+ return FALSE;
+ }
+ }
+
+ if (arg_graphics == GRAPHICS_HENGBAND) {
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
+ if (!ReadDIB(data[0].w, buf, &infMask)) {
+ plog_fmt("Cannot read bitmap file '%s'", buf);
+ return FALSE;
+ }
+ }
+
+ if (!new_palette()) {
+ plog(_("パレットを実現できません!", "Cannot activate palette!"));
+ return FALSE;
+ }
+
+ current_graphics_mode = arg_graphics;
+ return (current_graphics_mode);
}
-
/*
* Initialize music
*/
static void init_music(void)
{
- if (!can_use_music)
- {
- load_music_prefs();
- can_use_music = TRUE;
- }
+ if (!can_use_music) {
+ load_music_prefs();
+ can_use_music = TRUE;
+ }
}
/*
*/
static void stop_music(void)
{
- mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
- mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
+ mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
+ mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
}
-
/*
* Initialize sound
*/
static void init_sound(void)
{
- if (!can_use_sound)
- {
- load_sound_prefs();
- can_use_sound = TRUE;
- }
+ if (!can_use_sound) {
+ load_sound_prefs();
+ can_use_sound = TRUE;
+ }
}
-
/*
* Resize a window
*/
static void term_window_resize(term_data *td)
{
- if (!td->w) return;
+ if (!td->w)
+ return;
- SetWindowPos(td->w, 0, 0, 0,
- td->size_wid, td->size_hgt,
- SWP_NOMOVE | SWP_NOZORDER);
- InvalidateRect(td->w, NULL, TRUE);
+ SetWindowPos(td->w, 0, 0, 0, td->size_wid, td->size_hgt, SWP_NOMOVE | SWP_NOZORDER);
+ InvalidateRect(td->w, NULL, TRUE);
}
-
/*
* todo 引数のpathを消す
* Force the use of a new "font file" for a term_data.
*/
static errr term_force_font(term_data *td, concptr path)
{
- if (td->font_id) DeleteObject(td->font_id);
-
- (void)path;
- td->font_id = CreateFontIndirect(&(td->lf));
- int wid = td->lf.lfWidth;
- int hgt = td->lf.lfHeight;
- if (!td->font_id) return 1;
-
- if (!wid || !hgt)
- {
- HDC hdcDesktop;
- HFONT hfOld;
- TEXTMETRIC tm;
-
- hdcDesktop = GetDC(HWND_DESKTOP);
- hfOld = SelectObject(hdcDesktop, td->font_id);
- GetTextMetrics(hdcDesktop, &tm);
- SelectObject(hdcDesktop, hfOld);
- ReleaseDC(HWND_DESKTOP, hdcDesktop);
-
- wid = tm.tmAveCharWidth;
- hgt = tm.tmHeight;
- }
-
- td->font_wid = wid;
- td->font_hgt = hgt;
-
- return 0;
+ if (td->font_id)
+ DeleteObject(td->font_id);
+
+ (void)path;
+ td->font_id = CreateFontIndirect(&(td->lf));
+ int wid = td->lf.lfWidth;
+ int hgt = td->lf.lfHeight;
+ if (!td->font_id)
+ return 1;
+
+ if (!wid || !hgt) {
+ HDC hdcDesktop;
+ HFONT hfOld;
+ TEXTMETRIC tm;
+
+ hdcDesktop = GetDC(HWND_DESKTOP);
+ hfOld = SelectObject(hdcDesktop, td->font_id);
+ GetTextMetrics(hdcDesktop, &tm);
+ SelectObject(hdcDesktop, hfOld);
+ ReleaseDC(HWND_DESKTOP, hdcDesktop);
+
+ wid = tm.tmAveCharWidth;
+ hgt = tm.tmHeight;
+ }
+
+ td->font_wid = wid;
+ td->font_hgt = hgt;
+
+ return 0;
}
-
-
/*
* Allow the user to change the font for this window.
*/
static void term_change_font(term_data *td)
{
- CHOOSEFONT cf;
- memset(&cf, 0, sizeof(cf));
- cf.lStructSize = sizeof(cf);
- cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
- cf.lpLogFont = &(td->lf);
-
- if (!ChooseFont(&cf)) return;
-
- term_force_font(td, NULL);
- td->bizarre = TRUE;
- td->tile_wid = td->font_wid;
- td->tile_hgt = td->font_hgt;
- term_getsize(td);
- term_window_resize(td);
+ CHOOSEFONT cf;
+ memset(&cf, 0, sizeof(cf));
+ cf.lStructSize = sizeof(cf);
+ cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
+ cf.lpLogFont = &(td->lf);
+
+ if (!ChooseFont(&cf))
+ return;
+
+ term_force_font(td, NULL);
+ td->bizarre = TRUE;
+ td->tile_wid = td->font_wid;
+ td->tile_hgt = td->font_hgt;
+ term_getsize(td);
+ term_window_resize(td);
}
-
/*
* Allow the user to lock this window.
*/
-static void term_window_pos(term_data *td, HWND hWnd)
-{
- SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-}
+static void term_window_pos(term_data *td, HWND hWnd) { SetWindowPos(td->w, hWnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); }
static void windows_map(player_type *player_ptr);
*/
static void term_data_redraw(player_type *player_ptr, term_data *td)
{
- if (td->map_active)
- {
- windows_map(player_ptr);
- return;
- }
-
- Term_activate(&td->t);
- Term_redraw();
- Term_activate(term_screen);
+ if (td->map_active) {
+ windows_map(player_ptr);
+ return;
+ }
+
+ Term_activate(&td->t);
+ Term_redraw();
+ Term_activate(term_screen);
}
-
void term_inversed_area(HWND hWnd, int x, int y, int w, int h)
{
- term_data *td = (term_data *)GetWindowLong(hWnd, 0);
- int tx = td->size_ow1 + x * td->tile_wid;
- int ty = td->size_oh1 + y * td->tile_hgt;
- int tw = w * td->tile_wid - 1;
- int th = h * td->tile_hgt - 1;
+ term_data *td = (term_data *)GetWindowLong(hWnd, 0);
+ int tx = td->size_ow1 + x * td->tile_wid;
+ int ty = td->size_oh1 + y * td->tile_hgt;
+ int tw = w * td->tile_wid - 1;
+ int th = h * td->tile_hgt - 1;
- HDC hdc = GetDC(hWnd);
- HBRUSH myBrush = CreateSolidBrush(RGB(255, 255, 255));
- HBRUSH oldBrush = SelectObject(hdc, myBrush);
- HPEN oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
+ HDC hdc = GetDC(hWnd);
+ HBRUSH myBrush = CreateSolidBrush(RGB(255, 255, 255));
+ HBRUSH oldBrush = SelectObject(hdc, myBrush);
+ HPEN oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
- PatBlt(hdc, tx, ty, tw, th, PATINVERT);
+ PatBlt(hdc, tx, ty, tw, th, PATINVERT);
- SelectObject(hdc, oldBrush);
- SelectObject(hdc, oldPen);
+ SelectObject(hdc, oldBrush);
+ SelectObject(hdc, oldPen);
}
-
/*!
* @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
*/
static errr term_user_win(int n)
{
- (void)n;
- return 0;
+ (void)n;
+ return 0;
}
-
/*
* React to global changes
*/
static errr term_xtra_win_react(player_type *player_ptr)
{
- if (colors16)
- {
- for (int i = 0; i < 256; i++)
- {
- win_pal[i] = angband_color_table[i][0];
- }
- }
- else
- {
- COLORREF code;
- byte rv, gv, bv;
- bool change = FALSE;
- for (int i = 0; i < 256; i++)
- {
- rv = angband_color_table[i][1];
- gv = angband_color_table[i][2];
- bv = angband_color_table[i][3];
- code = PALETTERGB(rv, gv, bv);
- if (win_clr[i] != code)
- {
- change = TRUE;
- win_clr[i] = code;
- }
- }
-
- if (change) (void)new_palette();
- }
-
- if (use_sound != arg_sound)
- {
- init_sound();
- use_sound = arg_sound;
- }
-
- if (use_music != arg_music)
- {
- init_music();
- use_music = arg_music;
- if (!arg_music) stop_music();
- else select_floor_music(player_ptr);
- }
-
- if (use_graphics != arg_graphics)
- {
- if (arg_graphics && !init_graphics())
- {
- plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
- arg_graphics = GRAPHICS_NONE;
- }
-
- use_graphics = arg_graphics;
- reset_visuals(player_ptr, process_autopick_file_command);
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- term *old = Term;
- term_data *td = &data[i];
- if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
- {
- Term_activate(&td->t);
- Term_resize(td->cols, td->rows);
- Term_redraw();
- Term_activate(old);
- }
- }
-
- return 0;
+ if (colors16) {
+ for (int i = 0; i < 256; i++) {
+ win_pal[i] = angband_color_table[i][0];
+ }
+ } else {
+ COLORREF code;
+ byte rv, gv, bv;
+ bool change = FALSE;
+ for (int i = 0; i < 256; i++) {
+ rv = angband_color_table[i][1];
+ gv = angband_color_table[i][2];
+ bv = angband_color_table[i][3];
+ code = PALETTERGB(rv, gv, bv);
+ if (win_clr[i] != code) {
+ change = TRUE;
+ win_clr[i] = code;
+ }
+ }
+
+ if (change)
+ (void)new_palette();
+ }
+
+ if (use_sound != arg_sound) {
+ init_sound();
+ use_sound = arg_sound;
+ }
+
+ if (use_music != arg_music) {
+ init_music();
+ use_music = arg_music;
+ if (!arg_music)
+ stop_music();
+ else
+ select_floor_music(player_ptr);
+ }
+
+ if (use_graphics != arg_graphics) {
+ if (arg_graphics && !init_graphics()) {
+ plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
+ arg_graphics = GRAPHICS_NONE;
+ }
+
+ use_graphics = arg_graphics;
+ reset_visuals(player_ptr, process_autopick_file_command);
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ term *old = Term;
+ term_data *td = &data[i];
+ if ((td->cols != td->t.wid) || (td->rows != td->t.hgt)) {
+ Term_activate(&td->t);
+ Term_resize(td->cols, td->rows);
+ Term_redraw();
+ Term_activate(old);
+ }
+ }
+
+ return 0;
}
-
/*
* Process at least one event
*/
static errr term_xtra_win_event(int v)
{
- MSG msg;
- if (v)
- {
- if (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- else
- {
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- return 0;
+ MSG msg;
+ if (v) {
+ if (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ } else {
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ return 0;
}
-
/*
* Process all pending events
*/
static errr term_xtra_win_flush(void)
{
- MSG msg;
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return 0;
-}
+ MSG msg;
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return 0;
+}
/*
* Hack -- clear the screen
*/
static errr term_xtra_win_clear(void)
{
- term_data *td = (term_data*)(Term->data);
-
- RECT rc;
- rc.left = td->size_ow1;
- rc.right = rc.left + td->cols * td->tile_wid;
- rc.top = td->size_oh1;
- rc.bottom = rc.top + td->rows * td->tile_hgt;
-
- HDC hdc = GetDC(td->w);
- SetBkColor(hdc, RGB(0, 0, 0));
- SelectObject(hdc, td->font_id);
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
-
- if (use_bg)
- {
- rc.left = 0; rc.top = 0;
- DrawBG(hdc, &rc);
- }
-
- ReleaseDC(td->w, hdc);
- return 0;
+ term_data *td = (term_data *)(Term->data);
+
+ RECT rc;
+ rc.left = td->size_ow1;
+ rc.right = rc.left + td->cols * td->tile_wid;
+ rc.top = td->size_oh1;
+ rc.bottom = rc.top + td->rows * td->tile_hgt;
+
+ HDC hdc = GetDC(td->w);
+ SetBkColor(hdc, RGB(0, 0, 0));
+ SelectObject(hdc, td->font_id);
+ ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
+
+ if (use_bg) {
+ rc.left = 0;
+ rc.top = 0;
+ DrawBG(hdc, &rc);
+ }
+
+ ReleaseDC(td->w, hdc);
+ return 0;
}
-
/*
* Hack -- make a noise
*/
static errr term_xtra_win_noise(void)
{
- MessageBeep(MB_ICONASTERISK);
- return 0;
+ MessageBeep(MB_ICONASTERISK);
+ return 0;
}
-
/*
* Hack -- make a sound
*/
static errr term_xtra_win_sound(int v)
{
- char buf[1024];
- if (!use_sound) return 1;
- if ((v < 0) || (v >= SOUND_MAX)) return 1;
-
- int i;
- for (i = 0; i < SAMPLE_SOUND_MAX; i++)
- {
- if (!sound_file[v][i])
- break;
- }
-
- if (i == 0) return 1;
-
- path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
- return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
+ char buf[1024];
+ if (!use_sound)
+ return 1;
+ if ((v < 0) || (v >= SOUND_MAX))
+ return 1;
+
+ int i;
+ for (i = 0; i < SAMPLE_SOUND_MAX; i++) {
+ if (!sound_file[v][i])
+ break;
+ }
+
+ if (i == 0)
+ return 1;
+
+ path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
+ return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
}
/*
*/
static errr term_xtra_win_music(int n, int v)
{
- int i = 0;
- char buf[1024];
- if (n == TERM_XTRA_MUSIC_MUTE)
- {
- mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
- mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
- }
-
- if (!use_music) return 1;
-
- if (n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return 1;
- else if (v < 0 || v >= 1000) return(1); /*!< TODO */
-
- switch (n)
- {
- case TERM_XTRA_MUSIC_BASIC:
- for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!music_file[v][i]) break;
- break;
- case TERM_XTRA_MUSIC_DUNGEON:
- for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!dungeon_music_file[v][i]) break;
- break;
- case TERM_XTRA_MUSIC_QUEST:
- for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!quest_music_file[v][i]) break;
- break;
- case TERM_XTRA_MUSIC_TOWN:
- for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!town_music_file[v][i]) break;
- break;
- }
-
- if (i == 0)
- {
- return 1;
- }
-
- switch (n)
- {
- case TERM_XTRA_MUSIC_BASIC:
- path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
- break;
- case TERM_XTRA_MUSIC_DUNGEON:
- path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
- break;
- case TERM_XTRA_MUSIC_QUEST:
- path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
- break;
- case TERM_XTRA_MUSIC_TOWN:
- path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
- break;
- }
-
- if (current_music_type == n && current_music_id == v)
- {
- return 0;
- }
- current_music_type = n;
- current_music_id = v;
-
- mop.lpstrDeviceType = mci_device_type;
- mop.lpstrElementName = buf;
- mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
- mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
- mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
- mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
- mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
- return 0;
+ int i = 0;
+ char buf[1024];
+ if (n == TERM_XTRA_MUSIC_MUTE) {
+ mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
+ mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
+ }
+
+ if (!use_music)
+ return 1;
+
+ if (n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX)))
+ return 1;
+ else if (v < 0 || v >= 1000)
+ return (1); /*!< TODO */
+
+ switch (n) {
+ case TERM_XTRA_MUSIC_BASIC:
+ for (i = 0; i < SAMPLE_MUSIC_MAX; i++)
+ if (!music_file[v][i])
+ break;
+ break;
+ case TERM_XTRA_MUSIC_DUNGEON:
+ for (i = 0; i < SAMPLE_MUSIC_MAX; i++)
+ if (!dungeon_music_file[v][i])
+ break;
+ break;
+ case TERM_XTRA_MUSIC_QUEST:
+ for (i = 0; i < SAMPLE_MUSIC_MAX; i++)
+ if (!quest_music_file[v][i])
+ break;
+ break;
+ case TERM_XTRA_MUSIC_TOWN:
+ for (i = 0; i < SAMPLE_MUSIC_MAX; i++)
+ if (!town_music_file[v][i])
+ break;
+ break;
+ }
+
+ if (i == 0) {
+ return 1;
+ }
+
+ switch (n) {
+ case TERM_XTRA_MUSIC_BASIC:
+ path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
+ break;
+ case TERM_XTRA_MUSIC_DUNGEON:
+ path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
+ break;
+ case TERM_XTRA_MUSIC_QUEST:
+ path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
+ break;
+ case TERM_XTRA_MUSIC_TOWN:
+ path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
+ break;
+ }
+
+ if (current_music_type == n && current_music_id == v) {
+ return 0;
+ }
+ current_music_type = n;
+ current_music_id = v;
+
+ mop.lpstrDeviceType = mci_device_type;
+ mop.lpstrElementName = buf;
+ mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
+ mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
+ mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
+ mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
+ mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
+ return 0;
}
-
/*
* Delay for "x" milliseconds
*/
static int term_xtra_win_delay(int v)
{
- Sleep(v);
- return 0;
+ Sleep(v);
+ return 0;
}
-
/*
* todo z-termに影響があるのでplayer_typeの追加は保留
* Do a "special thing"
*/
static errr term_xtra_win(int n, int v)
{
- switch (n)
- {
- case TERM_XTRA_NOISE:
- {
- return (term_xtra_win_noise());
- }
- case TERM_XTRA_MUSIC_BASIC:
- case TERM_XTRA_MUSIC_DUNGEON:
- case TERM_XTRA_MUSIC_QUEST:
- case TERM_XTRA_MUSIC_TOWN:
- {
- return (term_xtra_win_music(n, v));
- }
- case TERM_XTRA_SOUND:
- {
- return (term_xtra_win_sound(v));
- }
- case TERM_XTRA_BORED:
- {
- return (term_xtra_win_event(0));
- }
- case TERM_XTRA_EVENT:
- {
- return (term_xtra_win_event(v));
- }
- case TERM_XTRA_FLUSH:
- {
- return (term_xtra_win_flush());
- }
- case TERM_XTRA_CLEAR:
- {
- return (term_xtra_win_clear());
- }
- case TERM_XTRA_REACT:
- {
- return (term_xtra_win_react(p_ptr));
- }
- case TERM_XTRA_DELAY:
- {
- return (term_xtra_win_delay(v));
- }
- }
-
- return 1;
+ switch (n) {
+ case TERM_XTRA_NOISE: {
+ return (term_xtra_win_noise());
+ }
+ case TERM_XTRA_MUSIC_BASIC:
+ case TERM_XTRA_MUSIC_DUNGEON:
+ case TERM_XTRA_MUSIC_QUEST:
+ case TERM_XTRA_MUSIC_TOWN: {
+ return (term_xtra_win_music(n, v));
+ }
+ case TERM_XTRA_SOUND: {
+ return (term_xtra_win_sound(v));
+ }
+ case TERM_XTRA_BORED: {
+ return (term_xtra_win_event(0));
+ }
+ case TERM_XTRA_EVENT: {
+ return (term_xtra_win_event(v));
+ }
+ case TERM_XTRA_FLUSH: {
+ return (term_xtra_win_flush());
+ }
+ case TERM_XTRA_CLEAR: {
+ return (term_xtra_win_clear());
+ }
+ case TERM_XTRA_REACT: {
+ return (term_xtra_win_react(p_ptr));
+ }
+ case TERM_XTRA_DELAY: {
+ return (term_xtra_win_delay(v));
+ }
+ }
+
+ return 1;
}
-
/*
* Low level graphics (Assumes valid input).
*
*/
static errr term_curs_win(int x, int y)
{
- term_data *td = (term_data*)(Term->data);
- int tile_wid, tile_hgt;
- if (td->map_active)
- {
- tile_wid = td->map_tile_wid;
- tile_hgt = td->map_tile_hgt;
- }
- else
- {
- tile_wid = td->tile_wid;
- tile_hgt = td->tile_hgt;
- }
-
- RECT rc;
- rc.left = x * tile_wid + td->size_ow1;
- rc.right = rc.left + tile_wid;
- rc.top = y * tile_hgt + td->size_oh1;
- rc.bottom = rc.top + tile_hgt;
-
- HDC hdc = GetDC(td->w);
- FrameRect(hdc, &rc, hbrYellow);
- ReleaseDC(td->w, hdc);
- return 0;
+ term_data *td = (term_data *)(Term->data);
+ int tile_wid, tile_hgt;
+ if (td->map_active) {
+ tile_wid = td->map_tile_wid;
+ tile_hgt = td->map_tile_hgt;
+ } else {
+ tile_wid = td->tile_wid;
+ tile_hgt = td->tile_hgt;
+ }
+
+ RECT rc;
+ rc.left = x * tile_wid + td->size_ow1;
+ rc.right = rc.left + tile_wid;
+ rc.top = y * tile_hgt + td->size_oh1;
+ rc.bottom = rc.top + tile_hgt;
+
+ HDC hdc = GetDC(td->w);
+ FrameRect(hdc, &rc, hbrYellow);
+ ReleaseDC(td->w, hdc);
+ return 0;
}
-
/*
* Low level graphics (Assumes valid input).
*
*/
static errr term_bigcurs_win(int x, int y)
{
- term_data *td = (term_data*)(Term->data);
- int tile_wid, tile_hgt;
- if (td->map_active)
- {
- term_curs_win(x, y);
- return 0;
- }
- else
- {
- tile_wid = td->tile_wid;
- tile_hgt = td->tile_hgt;
- }
-
- RECT rc;
- rc.left = x * tile_wid + td->size_ow1;
- rc.right = rc.left + 2 * tile_wid;
- rc.top = y * tile_hgt + td->size_oh1;
- rc.bottom = rc.top + tile_hgt;
-
- HDC hdc = GetDC(td->w);
- FrameRect(hdc, &rc, hbrYellow);
- ReleaseDC(td->w, hdc);
- return 0;
+ term_data *td = (term_data *)(Term->data);
+ int tile_wid, tile_hgt;
+ if (td->map_active) {
+ term_curs_win(x, y);
+ return 0;
+ } else {
+ tile_wid = td->tile_wid;
+ tile_hgt = td->tile_hgt;
+ }
+
+ RECT rc;
+ rc.left = x * tile_wid + td->size_ow1;
+ rc.right = rc.left + 2 * tile_wid;
+ rc.top = y * tile_hgt + td->size_oh1;
+ rc.bottom = rc.top + tile_hgt;
+
+ HDC hdc = GetDC(td->w);
+ FrameRect(hdc, &rc, hbrYellow);
+ ReleaseDC(td->w, hdc);
+ return 0;
}
-
/*
* Low level graphics (Assumes valid input).
*
*/
static errr term_wipe_win(int x, int y, int n)
{
- term_data *td = (term_data*)(Term->data);
- RECT rc;
- rc.left = x * td->tile_wid + td->size_ow1;
- rc.right = rc.left + n * td->tile_wid;
- rc.top = y * td->tile_hgt + td->size_oh1;
- rc.bottom = rc.top + td->tile_hgt;
-
- HDC hdc = GetDC(td->w);
- SetBkColor(hdc, RGB(0, 0, 0));
- SelectObject(hdc, td->font_id);
- if (use_bg)
- DrawBG(hdc, &rc);
- else
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
-
- ReleaseDC(td->w, hdc);
- return 0;
+ term_data *td = (term_data *)(Term->data);
+ RECT rc;
+ rc.left = x * td->tile_wid + td->size_ow1;
+ rc.right = rc.left + n * td->tile_wid;
+ rc.top = y * td->tile_hgt + td->size_oh1;
+ rc.bottom = rc.top + td->tile_hgt;
+
+ HDC hdc = GetDC(td->w);
+ SetBkColor(hdc, RGB(0, 0, 0));
+ SelectObject(hdc, td->font_id);
+ if (use_bg)
+ DrawBG(hdc, &rc);
+ else
+ ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
+
+ ReleaseDC(td->w, hdc);
+ return 0;
}
-
/*
* Low level graphics. Assumes valid input.
*
*/
static errr term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
{
- term_data *td = (term_data*)(Term->data);
- static HBITMAP WALL;
- static HBRUSH myBrush, oldBrush;
- static HPEN oldPen;
- static bool init_done = FALSE;
-
- if (!init_done) {
- WALL = LoadBitmap(hInstance, AppName);
- myBrush = CreatePatternBrush(WALL);
- init_done = TRUE;
- }
-
- RECT rc;
- rc.left = x * td->tile_wid + td->size_ow1;
- rc.right = rc.left + n * td->tile_wid;
- rc.top = y * td->tile_hgt + td->size_oh1;
- rc.bottom = rc.top + td->tile_hgt;
-
- HDC hdc = GetDC(td->w);
- SetBkColor(hdc, RGB(0, 0, 0));
- if (colors16)
- {
- SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
- }
- else if (paletted)
- {
- SetTextColor(hdc, win_clr[a & 0x0F]);
- }
- else
- {
- SetTextColor(hdc, win_clr[a]);
- }
-
- SelectObject(hdc, td->font_id);
- if (use_bg) SetBkMode(hdc, TRANSPARENT);
-
- if (td->bizarre ||
- (td->tile_hgt != td->font_hgt) ||
- (td->tile_wid != td->font_wid))
- {
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
- if (use_bg) DrawBG(hdc, &rc);
-
- rc.left += ((td->tile_wid - td->font_wid) / 2);
- rc.right = rc.left + td->font_wid;
- rc.top += ((td->tile_hgt - td->font_hgt) / 2);
- rc.bottom = rc.top + td->font_hgt;
-
- for (int i = 0; i < n; i++)
- {
+ term_data *td = (term_data *)(Term->data);
+ static HBITMAP WALL;
+ static HBRUSH myBrush, oldBrush;
+ static HPEN oldPen;
+ static bool init_done = FALSE;
+
+ if (!init_done) {
+ WALL = LoadBitmap(hInstance, AppName);
+ myBrush = CreatePatternBrush(WALL);
+ init_done = TRUE;
+ }
+
+ RECT rc;
+ rc.left = x * td->tile_wid + td->size_ow1;
+ rc.right = rc.left + n * td->tile_wid;
+ rc.top = y * td->tile_hgt + td->size_oh1;
+ rc.bottom = rc.top + td->tile_hgt;
+
+ HDC hdc = GetDC(td->w);
+ SetBkColor(hdc, RGB(0, 0, 0));
+ if (colors16) {
+ SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
+ } else if (paletted) {
+ SetTextColor(hdc, win_clr[a & 0x0F]);
+ } else {
+ SetTextColor(hdc, win_clr[a]);
+ }
+
+ SelectObject(hdc, td->font_id);
+ if (use_bg)
+ SetBkMode(hdc, TRANSPARENT);
+
+ if (td->bizarre || (td->tile_hgt != td->font_hgt) || (td->tile_wid != td->font_wid)) {
+ ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
+ if (use_bg)
+ DrawBG(hdc, &rc);
+
+ rc.left += ((td->tile_wid - td->font_wid) / 2);
+ rc.right = rc.left + td->font_wid;
+ rc.top += ((td->tile_hgt - td->font_hgt) / 2);
+ rc.bottom = rc.top + td->font_hgt;
+
+ for (int i = 0; i < n; i++) {
#ifdef JP
- if (use_bigtile && *(s + i) == "■"[0] && *(s + i + 1) == "■"[1])
- {
- rc.right += td->font_wid;
- oldBrush = SelectObject(hdc, myBrush);
- oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
- Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
- SelectObject(hdc, oldBrush);
- SelectObject(hdc, oldPen);
- rc.right -= td->font_wid;
- i++;
- rc.left += 2 * td->tile_wid;
- rc.right += 2 * td->tile_wid;
- }
- else if (iskanji(*(s + i))) /* 2バイト文字 */
- {
- rc.right += td->font_wid;
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
- s + i, 2, NULL);
- rc.right -= td->font_wid;
- i++;
- rc.left += 2 * td->tile_wid;
- rc.right += 2 * td->tile_wid;
- }
- else if (*(s + i) == 127) {
- oldBrush = SelectObject(hdc, myBrush);
- oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
- Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
- SelectObject(hdc, oldBrush);
- SelectObject(hdc, oldPen);
- rc.left += td->tile_wid;
- rc.right += td->tile_wid;
- }
- else
- {
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
- rc.left += td->tile_wid;
- rc.right += td->tile_wid;
- }
+ if (use_bigtile && *(s + i) == "■"[0] && *(s + i + 1) == "■"[1]) {
+ rc.right += td->font_wid;
+ oldBrush = SelectObject(hdc, myBrush);
+ oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
+ Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
+ SelectObject(hdc, oldBrush);
+ SelectObject(hdc, oldPen);
+ rc.right -= td->font_wid;
+ i++;
+ rc.left += 2 * td->tile_wid;
+ rc.right += 2 * td->tile_wid;
+ } else if (iskanji(*(s + i))) /* 2バイト文字 */
+ {
+ rc.right += td->font_wid;
+ ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 2, NULL);
+ rc.right -= td->font_wid;
+ i++;
+ rc.left += 2 * td->tile_wid;
+ rc.right += 2 * td->tile_wid;
+ } else if (*(s + i) == 127) {
+ oldBrush = SelectObject(hdc, myBrush);
+ oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
+ Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
+ SelectObject(hdc, oldBrush);
+ SelectObject(hdc, oldPen);
+ rc.left += td->tile_wid;
+ rc.right += td->tile_wid;
+ } else {
+ ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
+ rc.left += td->tile_wid;
+ rc.right += td->tile_wid;
+ }
#else
- if (*(s + i) == 127)
- {
- oldBrush = SelectObject(hdc, myBrush);
- oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
- Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
- SelectObject(hdc, oldBrush);
- SelectObject(hdc, oldPen);
- rc.left += td->tile_wid;
- rc.right += td->tile_wid;
- }
- else
- {
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
- rc.left += td->tile_wid;
- rc.right += td->tile_wid;
- }
+ if (*(s + i) == 127) {
+ oldBrush = SelectObject(hdc, myBrush);
+ oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
+ Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
+ SelectObject(hdc, oldBrush);
+ SelectObject(hdc, oldPen);
+ rc.left += td->tile_wid;
+ rc.right += td->tile_wid;
+ } else {
+ ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
+ rc.left += td->tile_wid;
+ rc.right += td->tile_wid;
+ }
#endif
- }
- }
- else
- {
- ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc, s, n, NULL);
- }
-
- ReleaseDC(td->w, hdc);
- return 0;
-}
+ }
+ } else {
+ ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc, s, n, NULL);
+ }
+ ReleaseDC(td->w, hdc);
+ return 0;
+}
/*
* Low level graphics. Assumes valid input.
*/
static errr term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp)
{
- term_data *td = (term_data*)(Term->data);
- int i;
- HDC hdcMask = NULL;
- if (!use_graphics)
- {
- return (term_wipe_win(x, y, n));
- }
-
- TERM_LEN w1 = infGraph.CellWidth;
- TERM_LEN h1 = infGraph.CellHeight;
- TERM_LEN tw1 = infGraph.TileWidth;
- TERM_LEN th1 = infGraph.TileHeight;
- TERM_LEN w2, h2, tw2 = 0;
- if (td->map_active)
- {
- w2 = td->map_tile_wid;
- h2 = td->map_tile_hgt;
- }
- else
- {
- w2 = td->tile_wid;
- h2 = td->tile_hgt;
- tw2 = w2;
- if (use_bigtile) tw2 *= 2;
- }
-
- TERM_LEN x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
- TERM_LEN y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
- HDC hdc = GetDC(td->w);
- HDC hdcSrc = CreateCompatibleDC(hdc);
- HBITMAP hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
-
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
- {
- hdcMask = CreateCompatibleDC(hdc);
- SelectObject(hdcMask, infMask.hBitmap);
- }
-
- for (i = 0; i < n; i++, x2 += w2)
- {
- TERM_COLOR a = ap[i];
- char c = cp[i];
- int row = (a & 0x7F);
- int col = (c & 0x7F);
- TERM_LEN x1 = col * w1;
- TERM_LEN y1 = row * h1;
-
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
- {
- TERM_LEN x3 = (tcp[i] & 0x7F) * w1;
- TERM_LEN y3 = (tap[i] & 0x7F) * h1;
- tw2 = tw2 * w1 / tw1;
- h2 = h2 * h1 / th1;
- if ((tw1 == tw2) && (th1 == h2))
- {
- BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
- BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
- BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
- continue;
- }
-
- SetStretchBltMode(hdc, COLORONCOLOR);
- StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
- StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
- if ((x1 != x3) || (y1 != y3))
- {
- StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
- StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
- }
-
- continue;
- }
-
- if ((w1 == tw2) && (h1 == h2))
- {
- BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
- continue;
- }
-
- SetStretchBltMode(hdc, COLORONCOLOR);
- StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
- }
-
- SelectObject(hdcSrc, hbmSrcOld);
- DeleteDC(hdcSrc);
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
- {
- SelectObject(hdcMask, hbmSrcOld);
- DeleteDC(hdcMask);
- }
-
- ReleaseDC(td->w, hdc);
- return 0;
+ term_data *td = (term_data *)(Term->data);
+ int i;
+ HDC hdcMask = NULL;
+ if (!use_graphics) {
+ return (term_wipe_win(x, y, n));
+ }
+
+ TERM_LEN w1 = infGraph.CellWidth;
+ TERM_LEN h1 = infGraph.CellHeight;
+ TERM_LEN tw1 = infGraph.TileWidth;
+ TERM_LEN th1 = infGraph.TileHeight;
+ TERM_LEN w2, h2, tw2 = 0;
+ if (td->map_active) {
+ w2 = td->map_tile_wid;
+ h2 = td->map_tile_hgt;
+ } else {
+ w2 = td->tile_wid;
+ h2 = td->tile_hgt;
+ tw2 = w2;
+ if (use_bigtile)
+ tw2 *= 2;
+ }
+
+ TERM_LEN x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
+ TERM_LEN y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
+ HDC hdc = GetDC(td->w);
+ HDC hdcSrc = CreateCompatibleDC(hdc);
+ HBITMAP hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
+
+ if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ hdcMask = CreateCompatibleDC(hdc);
+ SelectObject(hdcMask, infMask.hBitmap);
+ }
+
+ for (i = 0; i < n; i++, x2 += w2) {
+ TERM_COLOR a = ap[i];
+ char c = cp[i];
+ int row = (a & 0x7F);
+ int col = (c & 0x7F);
+ TERM_LEN x1 = col * w1;
+ TERM_LEN y1 = row * h1;
+
+ if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ TERM_LEN x3 = (tcp[i] & 0x7F) * w1;
+ TERM_LEN y3 = (tap[i] & 0x7F) * h1;
+ tw2 = tw2 * w1 / tw1;
+ h2 = h2 * h1 / th1;
+ if ((tw1 == tw2) && (th1 == h2)) {
+ BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
+ BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
+ BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
+ continue;
+ }
+
+ SetStretchBltMode(hdc, COLORONCOLOR);
+ StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
+ StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
+ if ((x1 != x3) || (y1 != y3)) {
+ StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
+ StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
+ }
+
+ continue;
+ }
+
+ if ((w1 == tw2) && (h1 == h2)) {
+ BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
+ continue;
+ }
+
+ SetStretchBltMode(hdc, COLORONCOLOR);
+ StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
+ }
+
+ SelectObject(hdcSrc, hbmSrcOld);
+ DeleteDC(hdcSrc);
+ if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ SelectObject(hdcMask, hbmSrcOld);
+ DeleteDC(hdcMask);
+ }
+
+ ReleaseDC(td->w, hdc);
+ return 0;
}
-
static void windows_map(player_type *player_ptr)
{
- term_data *td = &data[0];
- TERM_COLOR ta;
- if (!use_graphics) return;
-
- term_xtra_win_clear();
- td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
- td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
- td->map_active = TRUE;
-
- TERM_LEN min_x = 0;
- TERM_LEN min_y = 0;
- TERM_LEN max_x = player_ptr->current_floor_ptr->width;
- TERM_LEN max_y = player_ptr->current_floor_ptr->height;
-
- char c;
- for (TERM_LEN x = min_x; x < max_x; x++)
- {
- for (TERM_LEN y = min_y; y < max_y; y++)
- {
- TERM_COLOR a;
- char tc;
- map_info(player_ptr, y, x, &a, (char*)&c, &ta, (char*)&tc);
- if ((a & 0x80) && (c & 0x80))
- {
- term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
- }
- }
- }
-
- term_curs_win(player_ptr->x - min_x, player_ptr->y - min_y);
- Term_inkey(&c, TRUE, TRUE);
- Term_flush();
- td->map_active = FALSE;
- term_xtra_win_clear();
- Term_redraw();
+ term_data *td = &data[0];
+ TERM_COLOR ta;
+ if (!use_graphics)
+ return;
+
+ term_xtra_win_clear();
+ td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
+ td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
+ td->map_active = TRUE;
+
+ TERM_LEN min_x = 0;
+ TERM_LEN min_y = 0;
+ TERM_LEN max_x = player_ptr->current_floor_ptr->width;
+ TERM_LEN max_y = player_ptr->current_floor_ptr->height;
+
+ char c;
+ for (TERM_LEN x = min_x; x < max_x; x++) {
+ for (TERM_LEN y = min_y; y < max_y; y++) {
+ TERM_COLOR a;
+ char tc;
+ map_info(player_ptr, y, x, &a, (char *)&c, &ta, (char *)&tc);
+ if ((a & 0x80) && (c & 0x80)) {
+ term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
+ }
+ }
+ }
+
+ term_curs_win(player_ptr->x - min_x, player_ptr->y - min_y);
+ Term_inkey(&c, TRUE, TRUE);
+ Term_flush();
+ td->map_active = FALSE;
+ term_xtra_win_clear();
+ Term_redraw();
}
-
/*
* Create and initialize a "term_data" given a title
*/
static void term_data_link(term_data *td)
{
- term *t = &td->t;
- term_init(t, td->cols, td->rows, td->keys);
- t->soft_cursor = TRUE;
- t->higher_pict = TRUE;
- t->attr_blank = TERM_WHITE;
- t->char_blank = ' ';
- t->user_hook = term_user_win;
- t->xtra_hook = term_xtra_win;
- t->curs_hook = term_curs_win;
- t->bigcurs_hook = term_bigcurs_win;
- t->wipe_hook = term_wipe_win;
- t->text_hook = term_text_win;
- t->pict_hook = term_pict_win;
- t->data = (vptr)(td);
+ term *t = &td->t;
+ term_init(t, td->cols, td->rows, td->keys);
+ t->soft_cursor = TRUE;
+ t->higher_pict = TRUE;
+ t->attr_blank = TERM_WHITE;
+ t->char_blank = ' ';
+ t->user_hook = term_user_win;
+ t->xtra_hook = term_xtra_win;
+ t->curs_hook = term_curs_win;
+ t->bigcurs_hook = term_bigcurs_win;
+ t->wipe_hook = term_wipe_win;
+ t->text_hook = term_text_win;
+ t->pict_hook = term_pict_win;
+ t->data = (vptr)(td);
}
-
/*
* Create the windows
*
*/
static void init_windows(void)
{
- term_data *td;
- td = &data[0];
- WIPE(td, term_data);
+ term_data *td;
+ td = &data[0];
+ WIPE(td, term_data);
#ifdef JP
- td->s = "変愚蛮怒";
+ td->s = "変愚蛮怒";
#else
- td->s = angband_term_name[0];
+ td->s = angband_term_name[0];
#endif
- td->keys = 1024;
- td->rows = 24;
- td->cols = 80;
- td->visible = TRUE;
- td->size_ow1 = 2;
- td->size_ow2 = 2;
- td->size_oh1 = 2;
- td->size_oh2 = 2;
- td->pos_x = 7 * 30;
- td->pos_y = 7 * 20;
- td->posfix = FALSE;
- td->bizarre = TRUE;
-
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- td = &data[i];
- WIPE(td, term_data);
- td->s = angband_term_name[i];
- td->keys = 16;
- td->rows = 24;
- td->cols = 80;
- td->visible = FALSE;
- td->size_ow1 = 1;
- td->size_ow2 = 1;
- td->size_oh1 = 1;
- td->size_oh2 = 1;
- td->pos_x = (7 - i) * 30;
- td->pos_y = (7 - i) * 20;
- td->posfix = FALSE;
- td->bizarre = TRUE;
- }
-
- load_prefs();
- td = &data[0];
- td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
- WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
- WS_VISIBLE);
- td->dwExStyle = 0;
- td->visible = TRUE;
-
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- td = &data[i];
- td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
- td->dwExStyle = (WS_EX_TOOLWINDOW);
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- td = &data[i];
- strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
- td->lf.lfCharSet = DEFAULT_CHARSET;
- td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
- term_force_font(td, NULL);
- if (!td->tile_wid) td->tile_wid = td->font_wid;
- if (!td->tile_hgt) td->tile_hgt = td->font_hgt;
-
- term_getsize(td);
- term_window_resize(td);
- }
-
- for (int i = MAX_TERM_DATA - 1; i >= 1; --i)
- {
- td = &data[i];
-
- my_td = td;
- td->w = CreateWindowEx(td->dwExStyle, AngList,
- td->s, td->dwStyle,
- td->pos_x, td->pos_y,
- td->size_wid, td->size_hgt,
- HWND_DESKTOP, NULL, hInstance, NULL);
- my_td = NULL;
- if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
-
- if (td->visible)
- {
- td->size_hack = TRUE;
- ShowWindow(td->w, SW_SHOW);
- td->size_hack = FALSE;
- }
-
- term_data_link(td);
- angband_term[i] = &td->t;
-
- if (td->visible)
- {
- /* Activate the window */
- SetActiveWindow(td->w);
- }
-
- if (data[i].posfix)
- {
- term_window_pos(&data[i], HWND_TOPMOST);
- }
- else
- {
- term_window_pos(&data[i], td->w);
- }
- }
-
- td = &data[0];
- my_td = td;
- td->w = CreateWindowEx(td->dwExStyle, AppName,
- td->s, td->dwStyle,
- td->pos_x, td->pos_y,
- td->size_wid, td->size_hgt,
- HWND_DESKTOP, NULL, hInstance, NULL);
- my_td = NULL;
- if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
-
- term_data_link(td);
- angband_term[0] = &td->t;
- normsize.x = td->cols;
- normsize.y = td->rows;
-
- if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
- else ShowWindow(td->w, SW_SHOW);
-
- SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- (void)new_palette();
- hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
- (void)term_xtra_win_flush();
+ td->keys = 1024;
+ td->rows = 24;
+ td->cols = 80;
+ td->visible = TRUE;
+ td->size_ow1 = 2;
+ td->size_ow2 = 2;
+ td->size_oh1 = 2;
+ td->size_oh2 = 2;
+ td->pos_x = 7 * 30;
+ td->pos_y = 7 * 20;
+ td->posfix = FALSE;
+ td->bizarre = TRUE;
+
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ td = &data[i];
+ WIPE(td, term_data);
+ td->s = angband_term_name[i];
+ td->keys = 16;
+ td->rows = 24;
+ td->cols = 80;
+ td->visible = FALSE;
+ td->size_ow1 = 1;
+ td->size_ow2 = 1;
+ td->size_oh1 = 1;
+ td->size_oh2 = 1;
+ td->pos_x = (7 - i) * 30;
+ td->pos_y = (7 - i) * 20;
+ td->posfix = FALSE;
+ td->bizarre = TRUE;
+ }
+
+ load_prefs();
+ td = &data[0];
+ td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_VISIBLE);
+ td->dwExStyle = 0;
+ td->visible = TRUE;
+
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ td = &data[i];
+ td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
+ td->dwExStyle = (WS_EX_TOOLWINDOW);
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ td = &data[i];
+ strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
+ td->lf.lfCharSet = DEFAULT_CHARSET;
+ td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
+ term_force_font(td, NULL);
+ if (!td->tile_wid)
+ td->tile_wid = td->font_wid;
+ if (!td->tile_hgt)
+ td->tile_hgt = td->font_hgt;
+
+ term_getsize(td);
+ term_window_resize(td);
+ }
+
+ for (int i = MAX_TERM_DATA - 1; i >= 1; --i) {
+ td = &data[i];
+
+ my_td = td;
+ td->w
+ = CreateWindowEx(td->dwExStyle, AngList, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
+ my_td = NULL;
+ if (!td->w)
+ quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
+
+ if (td->visible) {
+ td->size_hack = TRUE;
+ ShowWindow(td->w, SW_SHOW);
+ td->size_hack = FALSE;
+ }
+
+ term_data_link(td);
+ angband_term[i] = &td->t;
+
+ if (td->visible) {
+ /* Activate the window */
+ SetActiveWindow(td->w);
+ }
+
+ if (data[i].posfix) {
+ term_window_pos(&data[i], HWND_TOPMOST);
+ } else {
+ term_window_pos(&data[i], td->w);
+ }
+ }
+
+ td = &data[0];
+ my_td = td;
+ td->w = CreateWindowEx(td->dwExStyle, AppName, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
+ my_td = NULL;
+ if (!td->w)
+ quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
+
+ term_data_link(td);
+ angband_term[0] = &td->t;
+ normsize.x = td->cols;
+ normsize.y = td->rows;
+
+ if (win_maximized)
+ ShowWindow(td->w, SW_SHOWMAXIMIZED);
+ else
+ ShowWindow(td->w, SW_SHOW);
+
+ SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ (void)new_palette();
+ hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
+ (void)term_xtra_win_flush();
}
-
/*
* Prepare the menus
*/
static void setup_menus(void)
{
- HMENU hm = GetMenu(data[0].w);
- EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
-
- if (!current_world_ptr->character_generated)
- {
- EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
- }
-
- if (current_world_ptr->character_generated)
- {
- EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
- }
-
- EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_ENABLED);
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i, (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
- EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
-
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- CheckMenuItem(hm, IDM_WINDOW_POS_0 + i, (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i, (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_ENABLED);
-
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- for (int i = 0; i < MAX_TERM_DATA; i++)
- {
- EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
-
- if (data[i].visible)
- {
- EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
- }
- }
-
- EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ HMENU hm = GetMenu(data[0].w);
+ EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+
+ if (!current_world_ptr->character_generated) {
+ EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
+ }
+
+ if (current_world_ptr->character_generated) {
+ EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
+ }
+
+ EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_ENABLED);
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i, (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
+ EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ CheckMenuItem(hm, IDM_WINDOW_POS_0 + i, (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i, (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ for (int i = 0; i < MAX_TERM_DATA; i++) {
+ EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+
+ if (data[i].visible) {
+ EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+
+ EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
#ifdef JP
#else
- EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
#endif
- if (use_graphics != GRAPHICS_NONE)
- EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
- else
- EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
-
- CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
- (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
- (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
- (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
- (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
- (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
- (arg_music ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_SOUND,
- (arg_sound ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_BG,
- (use_bg ? MF_CHECKED : MF_UNCHECKED));
+ if (use_graphics != GRAPHICS_NONE)
+ EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
+ else
+ EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+
+ CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS, (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_BIGTILE, (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_MUSIC, (arg_music ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_SOUND, (arg_sound ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_BG, (use_bg ? MF_CHECKED : MF_UNCHECKED));
#ifdef JP
#else
- CheckMenuItem(hm, IDM_OPTIONS_SAVER,
- (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_SAVER, (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
#endif
- EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
- EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
- EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
- EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
- EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
- EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
+ EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_ENABLED);
}
-
/*
* Check for double clicked (or dragged) savefile
*
*/
static void check_for_save_file(player_type *player_ptr, LPSTR cmd_line)
{
- char *s;
- s = cmd_line;
- if (!*s) return;
-
- strcat(savefile, s);
- validate_file(savefile);
- game_in_progress = TRUE;
- play_game(player_ptr, FALSE);
+ char *s;
+ s = cmd_line;
+ if (!*s)
+ return;
+
+ strcat(savefile, s);
+ validate_file(savefile);
+ game_in_progress = TRUE;
+ play_game(player_ptr, FALSE);
}
-
/*
* Process a menu command
*/
static void process_menus(player_type *player_ptr, WORD wCmd)
{
- term_data *td;
- OPENFILENAME ofn;
- switch (wCmd)
- {
- case IDM_FILE_NEW:
- {
- if (!initialized)
- {
- plog(_("まだ初期化中です...", "You cannot do that yet..."));
- }
- else if (game_in_progress)
- {
- plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
- }
- else
- {
- game_in_progress = TRUE;
- Term_flush();
- play_game(player_ptr, TRUE);
- quit(NULL);
- }
-
- break;
- }
- case IDM_FILE_OPEN:
- {
- if (!initialized)
- {
- plog(_("まだ初期化中です...", "You cannot do that yet..."));
- }
- else if (game_in_progress)
- {
- plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
- }
- else
- {
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Save Files (*.)\0*\0";
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = savefile;
- ofn.nMaxFile = 1024;
- ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
-
- if (GetOpenFileName(&ofn))
- {
- validate_file(savefile);
- game_in_progress = TRUE;
- Term_flush();
- play_game(player_ptr, FALSE);
- quit(NULL);
- }
- }
-
- break;
- }
- case IDM_FILE_SAVE:
- {
- if (game_in_progress && current_world_ptr->character_generated)
- {
- if (!can_save)
- {
- plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
- break;
- }
-
- msg_flag = FALSE;
- do_cmd_save_game(player_ptr, FALSE);
- }
- else
- {
- plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
- }
-
- break;
- }
- case IDM_FILE_EXIT:
- {
- if (game_in_progress && current_world_ptr->character_generated)
- {
- if (!can_save)
- {
- plog(_("今は終了できません。", "You may not do that right now."));
- break;
- }
-
- msg_flag = FALSE;
- forget_lite(player_ptr->current_floor_ptr);
- forget_view(player_ptr->current_floor_ptr);
- clear_mon_lite(player_ptr->current_floor_ptr);
-
- Term_key_push(SPECIAL_KEY_QUIT);
- break;
- }
-
- quit(NULL);
- break;
- }
- case IDM_FILE_SCORE:
- {
- char buf[1024];
- path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(buf, O_RDONLY);
- if (highscore_fd < 0)
- {
- msg_print("Score file unavailable.");
- }
- else
- {
- screen_save();
- Term_clear();
- display_scores_aux(0, MAX_HISCORES, -1, NULL);
- (void)fd_close(highscore_fd);
- highscore_fd = -1;
- screen_load();
- Term_fresh();
- }
-
- break;
- }
- case IDM_FILE_MOVIE:
- {
- if (!initialized)
- {
- plog(_("まだ初期化中です...", "You cannot do that yet..."));
- }
- else if (game_in_progress)
- {
- plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
- }
- else
- {
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = savefile;
- ofn.nMaxFile = 1024;
- ofn.lpstrInitialDir = ANGBAND_DIR_USER;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
-
- if (GetOpenFileName(&ofn))
- {
- prepare_browse_movie_aux(savefile);
- play_game(player_ptr, FALSE);
- quit(NULL);
- return;
- }
- }
-
- break;
- }
- case IDM_WINDOW_VIS_0:
- {
- plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
- break;
- }
- case IDM_WINDOW_VIS_1:
- case IDM_WINDOW_VIS_2:
- case IDM_WINDOW_VIS_3:
- case IDM_WINDOW_VIS_4:
- case IDM_WINDOW_VIS_5:
- case IDM_WINDOW_VIS_6:
- case IDM_WINDOW_VIS_7:
- {
- int i = wCmd - IDM_WINDOW_VIS_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- if (!td->visible)
- {
- td->visible = TRUE;
- ShowWindow(td->w, SW_SHOW);
- term_data_redraw(player_ptr, td);
- }
- else
- {
- td->visible = FALSE;
- td->posfix = FALSE;
- ShowWindow(td->w, SW_HIDE);
- }
-
- break;
- }
- case IDM_WINDOW_FONT_0:
- case IDM_WINDOW_FONT_1:
- case IDM_WINDOW_FONT_2:
- case IDM_WINDOW_FONT_3:
- case IDM_WINDOW_FONT_4:
- case IDM_WINDOW_FONT_5:
- case IDM_WINDOW_FONT_6:
- case IDM_WINDOW_FONT_7:
- {
- int i = wCmd - IDM_WINDOW_FONT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- term_change_font(td);
- break;
- }
- case IDM_WINDOW_POS_1:
- case IDM_WINDOW_POS_2:
- case IDM_WINDOW_POS_3:
- case IDM_WINDOW_POS_4:
- case IDM_WINDOW_POS_5:
- case IDM_WINDOW_POS_6:
- case IDM_WINDOW_POS_7:
- {
- int i = wCmd - IDM_WINDOW_POS_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- if (!td->posfix && td->visible)
- {
- td->posfix = TRUE;
- term_window_pos(td, HWND_TOPMOST);
- }
- else
- {
- td->posfix = FALSE;
- term_window_pos(td, data[0].w);
- }
-
- break;
- }
- case IDM_WINDOW_BIZ_0:
- case IDM_WINDOW_BIZ_1:
- case IDM_WINDOW_BIZ_2:
- case IDM_WINDOW_BIZ_3:
- case IDM_WINDOW_BIZ_4:
- case IDM_WINDOW_BIZ_5:
- case IDM_WINDOW_BIZ_6:
- case IDM_WINDOW_BIZ_7:
- {
- int i = wCmd - IDM_WINDOW_BIZ_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- td->bizarre = !td->bizarre;
- term_getsize(td);
- term_window_resize(td);
- break;
- }
- case IDM_WINDOW_I_WID_0:
- case IDM_WINDOW_I_WID_1:
- case IDM_WINDOW_I_WID_2:
- case IDM_WINDOW_I_WID_3:
- case IDM_WINDOW_I_WID_4:
- case IDM_WINDOW_I_WID_5:
- case IDM_WINDOW_I_WID_6:
- case IDM_WINDOW_I_WID_7:
- {
- int i = wCmd - IDM_WINDOW_I_WID_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- td->tile_wid += 1;
- term_getsize(td);
- term_window_resize(td);
- break;
- }
- case IDM_WINDOW_D_WID_0:
- case IDM_WINDOW_D_WID_1:
- case IDM_WINDOW_D_WID_2:
- case IDM_WINDOW_D_WID_3:
- case IDM_WINDOW_D_WID_4:
- case IDM_WINDOW_D_WID_5:
- case IDM_WINDOW_D_WID_6:
- case IDM_WINDOW_D_WID_7:
- {
- int i = wCmd - IDM_WINDOW_D_WID_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- td->tile_wid -= 1;
- term_getsize(td);
- term_window_resize(td);
- break;
- }
- case IDM_WINDOW_I_HGT_0:
- case IDM_WINDOW_I_HGT_1:
- case IDM_WINDOW_I_HGT_2:
- case IDM_WINDOW_I_HGT_3:
- case IDM_WINDOW_I_HGT_4:
- case IDM_WINDOW_I_HGT_5:
- case IDM_WINDOW_I_HGT_6:
- case IDM_WINDOW_I_HGT_7:
- {
- int i = wCmd - IDM_WINDOW_I_HGT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- td->tile_hgt += 1;
- term_getsize(td);
- term_window_resize(td);
- break;
- }
- case IDM_WINDOW_D_HGT_0:
- case IDM_WINDOW_D_HGT_1:
- case IDM_WINDOW_D_HGT_2:
- case IDM_WINDOW_D_HGT_3:
- case IDM_WINDOW_D_HGT_4:
- case IDM_WINDOW_D_HGT_5:
- case IDM_WINDOW_D_HGT_6:
- case IDM_WINDOW_D_HGT_7:
- {
- int i = wCmd - IDM_WINDOW_D_HGT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA)) break;
-
- td = &data[i];
- td->tile_hgt -= 1;
- term_getsize(td);
- term_window_resize(td);
- break;
- }
- case IDM_OPTIONS_NO_GRAPHICS:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- if (arg_graphics != GRAPHICS_NONE)
- {
- arg_graphics = GRAPHICS_NONE;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- }
-
- break;
- }
- case IDM_OPTIONS_OLD_GRAPHICS:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- if (arg_graphics != GRAPHICS_ORIGINAL)
- {
- arg_graphics = GRAPHICS_ORIGINAL;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- }
-
- break;
- }
- case IDM_OPTIONS_NEW_GRAPHICS:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- if (arg_graphics != GRAPHICS_ADAM_BOLT)
- {
- arg_graphics = GRAPHICS_ADAM_BOLT;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- }
-
- break;
- }
- case IDM_OPTIONS_NEW2_GRAPHICS:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- if (arg_graphics != GRAPHICS_HENGBAND)
- {
- arg_graphics = GRAPHICS_HENGBAND;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- }
-
- break;
- }
- case IDM_OPTIONS_BIGTILE:
- {
- td = &data[0];
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- arg_bigtile = !arg_bigtile;
- Term_activate(&td->t);
- Term_resize(td->cols, td->rows);
- InvalidateRect(td->w, NULL, TRUE);
- break;
- }
- case IDM_OPTIONS_MUSIC:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- arg_music = !arg_music;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- break;
- }
- case IDM_OPTIONS_SOUND:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- arg_sound = !arg_sound;
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- break;
- }
- case IDM_OPTIONS_BG:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- use_bg = !use_bg;
- init_bg();
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- break;
- }
- case IDM_OPTIONS_OPEN_BG:
- {
- if (!inkey_flag)
- {
- plog("You may not do that right now.");
- break;
- }
-
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = bg_bitmap_file;
- ofn.nMaxFile = 1023;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
-
- if (GetOpenFileName(&ofn))
- {
- use_bg = 1;
- init_bg();
- }
-
- term_xtra_win_react(player_ptr);
- Term_key_push(KTRL('R'));
- break;
- }
- case IDM_DUMP_SCREEN_HTML:
- {
- static char buf[1024] = "";
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = buf;
- ofn.nMaxFile = 1023;
- ofn.lpstrDefExt = "html";
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
- ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
-
- if (GetSaveFileName(&ofn))
- {
- do_cmd_save_screen_html_aux(buf, 0);
- }
-
- break;
- }
- case IDM_OPTIONS_SAVER:
- {
- if (hwndSaver)
- {
- DestroyWindow(hwndSaver);
- hwndSaver = NULL;
- break;
- }
-
- hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
- "Angband Screensaver",
- WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
- 0, 0, GetSystemMetrics(SM_CXSCREEN),
- GetSystemMetrics(SM_CYSCREEN),
- NULL, NULL, hInstance, NULL);
-
- if (hwndSaver)
- {
- SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- }
- else
- {
- plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
- }
-
- break;
- }
- case IDM_OPTIONS_MAP:
- {
- windows_map(player_ptr);
- break;
- }
-
- case IDM_HELP_CONTENTS:
- {
- char buf[1024];
- char tmp[1024];
- path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
- if (check_file(tmp))
- {
- sprintf(buf, "winhelp.exe %s", tmp);
- WinExec(buf, SW_NORMAL);
- break;
- }
-
- plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
- plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
- break;
- }
- }
+ term_data *td;
+ OPENFILENAME ofn;
+ switch (wCmd) {
+ case IDM_FILE_NEW: {
+ if (!initialized) {
+ plog(_("まだ初期化中です...", "You cannot do that yet..."));
+ } else if (game_in_progress) {
+ plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
+ } else {
+ game_in_progress = TRUE;
+ Term_flush();
+ play_game(player_ptr, TRUE);
+ quit(NULL);
+ }
+
+ break;
+ }
+ case IDM_FILE_OPEN: {
+ if (!initialized) {
+ plog(_("まだ初期化中です...", "You cannot do that yet..."));
+ } else if (game_in_progress) {
+ plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
+ } else {
+ memset(&ofn, 0, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = data[0].w;
+ ofn.lpstrFilter = "Save Files (*.)\0*\0";
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = savefile;
+ ofn.nMaxFile = 1024;
+ ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
+
+ if (GetOpenFileName(&ofn)) {
+ validate_file(savefile);
+ game_in_progress = TRUE;
+ Term_flush();
+ play_game(player_ptr, FALSE);
+ quit(NULL);
+ }
+ }
+
+ break;
+ }
+ case IDM_FILE_SAVE: {
+ if (game_in_progress && current_world_ptr->character_generated) {
+ if (!can_save) {
+ plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
+ break;
+ }
+
+ msg_flag = FALSE;
+ do_cmd_save_game(player_ptr, FALSE);
+ } else {
+ plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
+ }
+
+ break;
+ }
+ case IDM_FILE_EXIT: {
+ if (game_in_progress && current_world_ptr->character_generated) {
+ if (!can_save) {
+ plog(_("今は終了できません。", "You may not do that right now."));
+ break;
+ }
+
+ msg_flag = FALSE;
+ forget_lite(player_ptr->current_floor_ptr);
+ forget_view(player_ptr->current_floor_ptr);
+ clear_mon_lite(player_ptr->current_floor_ptr);
+
+ Term_key_push(SPECIAL_KEY_QUIT);
+ break;
+ }
+
+ quit(NULL);
+ break;
+ }
+ case IDM_FILE_SCORE: {
+ char buf[1024];
+ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
+ highscore_fd = fd_open(buf, O_RDONLY);
+ if (highscore_fd < 0) {
+ msg_print("Score file unavailable.");
+ } else {
+ screen_save();
+ Term_clear();
+ display_scores_aux(0, MAX_HISCORES, -1, NULL);
+ (void)fd_close(highscore_fd);
+ highscore_fd = -1;
+ screen_load();
+ Term_fresh();
+ }
+
+ break;
+ }
+ case IDM_FILE_MOVIE: {
+ if (!initialized) {
+ plog(_("まだ初期化中です...", "You cannot do that yet..."));
+ } else if (game_in_progress) {
+ plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
+ } else {
+ memset(&ofn, 0, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = data[0].w;
+ ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = savefile;
+ ofn.nMaxFile = 1024;
+ ofn.lpstrInitialDir = ANGBAND_DIR_USER;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
+
+ if (GetOpenFileName(&ofn)) {
+ prepare_browse_movie_aux(savefile);
+ play_game(player_ptr, FALSE);
+ quit(NULL);
+ return;
+ }
+ }
+
+ break;
+ }
+ case IDM_WINDOW_VIS_0: {
+ plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
+ break;
+ }
+ case IDM_WINDOW_VIS_1:
+ case IDM_WINDOW_VIS_2:
+ case IDM_WINDOW_VIS_3:
+ case IDM_WINDOW_VIS_4:
+ case IDM_WINDOW_VIS_5:
+ case IDM_WINDOW_VIS_6:
+ case IDM_WINDOW_VIS_7: {
+ int i = wCmd - IDM_WINDOW_VIS_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ if (!td->visible) {
+ td->visible = TRUE;
+ ShowWindow(td->w, SW_SHOW);
+ term_data_redraw(player_ptr, td);
+ } else {
+ td->visible = FALSE;
+ td->posfix = FALSE;
+ ShowWindow(td->w, SW_HIDE);
+ }
+
+ break;
+ }
+ case IDM_WINDOW_FONT_0:
+ case IDM_WINDOW_FONT_1:
+ case IDM_WINDOW_FONT_2:
+ case IDM_WINDOW_FONT_3:
+ case IDM_WINDOW_FONT_4:
+ case IDM_WINDOW_FONT_5:
+ case IDM_WINDOW_FONT_6:
+ case IDM_WINDOW_FONT_7: {
+ int i = wCmd - IDM_WINDOW_FONT_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ term_change_font(td);
+ break;
+ }
+ case IDM_WINDOW_POS_1:
+ case IDM_WINDOW_POS_2:
+ case IDM_WINDOW_POS_3:
+ case IDM_WINDOW_POS_4:
+ case IDM_WINDOW_POS_5:
+ case IDM_WINDOW_POS_6:
+ case IDM_WINDOW_POS_7: {
+ int i = wCmd - IDM_WINDOW_POS_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ if (!td->posfix && td->visible) {
+ td->posfix = TRUE;
+ term_window_pos(td, HWND_TOPMOST);
+ } else {
+ td->posfix = FALSE;
+ term_window_pos(td, data[0].w);
+ }
+
+ break;
+ }
+ case IDM_WINDOW_BIZ_0:
+ case IDM_WINDOW_BIZ_1:
+ case IDM_WINDOW_BIZ_2:
+ case IDM_WINDOW_BIZ_3:
+ case IDM_WINDOW_BIZ_4:
+ case IDM_WINDOW_BIZ_5:
+ case IDM_WINDOW_BIZ_6:
+ case IDM_WINDOW_BIZ_7: {
+ int i = wCmd - IDM_WINDOW_BIZ_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ td->bizarre = !td->bizarre;
+ term_getsize(td);
+ term_window_resize(td);
+ break;
+ }
+ case IDM_WINDOW_I_WID_0:
+ case IDM_WINDOW_I_WID_1:
+ case IDM_WINDOW_I_WID_2:
+ case IDM_WINDOW_I_WID_3:
+ case IDM_WINDOW_I_WID_4:
+ case IDM_WINDOW_I_WID_5:
+ case IDM_WINDOW_I_WID_6:
+ case IDM_WINDOW_I_WID_7: {
+ int i = wCmd - IDM_WINDOW_I_WID_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ td->tile_wid += 1;
+ term_getsize(td);
+ term_window_resize(td);
+ break;
+ }
+ case IDM_WINDOW_D_WID_0:
+ case IDM_WINDOW_D_WID_1:
+ case IDM_WINDOW_D_WID_2:
+ case IDM_WINDOW_D_WID_3:
+ case IDM_WINDOW_D_WID_4:
+ case IDM_WINDOW_D_WID_5:
+ case IDM_WINDOW_D_WID_6:
+ case IDM_WINDOW_D_WID_7: {
+ int i = wCmd - IDM_WINDOW_D_WID_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ td->tile_wid -= 1;
+ term_getsize(td);
+ term_window_resize(td);
+ break;
+ }
+ case IDM_WINDOW_I_HGT_0:
+ case IDM_WINDOW_I_HGT_1:
+ case IDM_WINDOW_I_HGT_2:
+ case IDM_WINDOW_I_HGT_3:
+ case IDM_WINDOW_I_HGT_4:
+ case IDM_WINDOW_I_HGT_5:
+ case IDM_WINDOW_I_HGT_6:
+ case IDM_WINDOW_I_HGT_7: {
+ int i = wCmd - IDM_WINDOW_I_HGT_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ td->tile_hgt += 1;
+ term_getsize(td);
+ term_window_resize(td);
+ break;
+ }
+ case IDM_WINDOW_D_HGT_0:
+ case IDM_WINDOW_D_HGT_1:
+ case IDM_WINDOW_D_HGT_2:
+ case IDM_WINDOW_D_HGT_3:
+ case IDM_WINDOW_D_HGT_4:
+ case IDM_WINDOW_D_HGT_5:
+ case IDM_WINDOW_D_HGT_6:
+ case IDM_WINDOW_D_HGT_7: {
+ int i = wCmd - IDM_WINDOW_D_HGT_0;
+ if ((i < 0) || (i >= MAX_TERM_DATA))
+ break;
+
+ td = &data[i];
+ td->tile_hgt -= 1;
+ term_getsize(td);
+ term_window_resize(td);
+ break;
+ }
+ case IDM_OPTIONS_NO_GRAPHICS: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ if (arg_graphics != GRAPHICS_NONE) {
+ arg_graphics = GRAPHICS_NONE;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_OLD_GRAPHICS: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ if (arg_graphics != GRAPHICS_ORIGINAL) {
+ arg_graphics = GRAPHICS_ORIGINAL;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_NEW_GRAPHICS: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ if (arg_graphics != GRAPHICS_ADAM_BOLT) {
+ arg_graphics = GRAPHICS_ADAM_BOLT;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_NEW2_GRAPHICS: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ if (arg_graphics != GRAPHICS_HENGBAND) {
+ arg_graphics = GRAPHICS_HENGBAND;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_BIGTILE: {
+ td = &data[0];
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ arg_bigtile = !arg_bigtile;
+ Term_activate(&td->t);
+ Term_resize(td->cols, td->rows);
+ InvalidateRect(td->w, NULL, TRUE);
+ break;
+ }
+ case IDM_OPTIONS_MUSIC: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ arg_music = !arg_music;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ break;
+ }
+ case IDM_OPTIONS_SOUND: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ arg_sound = !arg_sound;
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ break;
+ }
+ case IDM_OPTIONS_BG: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ use_bg = !use_bg;
+ init_bg();
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ break;
+ }
+ case IDM_OPTIONS_OPEN_BG: {
+ if (!inkey_flag) {
+ plog("You may not do that right now.");
+ break;
+ }
+
+ memset(&ofn, 0, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = data[0].w;
+ ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = bg_bitmap_file;
+ ofn.nMaxFile = 1023;
+ ofn.lpstrInitialDir = NULL;
+ ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+
+ if (GetOpenFileName(&ofn)) {
+ use_bg = 1;
+ init_bg();
+ }
+
+ term_xtra_win_react(player_ptr);
+ Term_key_push(KTRL('R'));
+ break;
+ }
+ case IDM_DUMP_SCREEN_HTML: {
+ static char buf[1024] = "";
+ memset(&ofn, 0, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = data[0].w;
+ ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = buf;
+ ofn.nMaxFile = 1023;
+ ofn.lpstrDefExt = "html";
+ ofn.lpstrInitialDir = NULL;
+ ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
+ ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+
+ if (GetSaveFileName(&ofn)) {
+ do_cmd_save_screen_html_aux(buf, 0);
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_SAVER: {
+ if (hwndSaver) {
+ DestroyWindow(hwndSaver);
+ hwndSaver = NULL;
+ break;
+ }
+
+ hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass", "Angband Screensaver", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE, 0, 0,
+ GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
+
+ if (hwndSaver) {
+ SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ } else {
+ plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
+ }
+
+ break;
+ }
+ case IDM_OPTIONS_MAP: {
+ windows_map(player_ptr);
+ break;
+ }
+
+ case IDM_HELP_CONTENTS: {
+ char buf[1024];
+ char tmp[1024];
+ path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
+ if (check_file(tmp)) {
+ sprintf(buf, "winhelp.exe %s", tmp);
+ WinExec(buf, SW_NORMAL);
+ break;
+ }
+
+ plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
+ plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
+ break;
+ }
+ }
}
-
static bool process_keydown(WPARAM wParam, LPARAM lParam)
{
- bool mc = FALSE;
- bool ms = FALSE;
- bool ma = FALSE;
-
- if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
- if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
- if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
-
- term_no_press = (ma) ? TRUE : FALSE;
- if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]))
- {
- bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
- bool numpad = FALSE;
-
- Term_keypress(31);
- if (mc) Term_keypress('C');
- if (ms) Term_keypress('S');
- if (ma) Term_keypress('A');
-
- int i = LOBYTE(HIWORD(lParam));
- Term_keypress('x');
- switch (wParam)
- {
- case VK_DIVIDE:
- term_no_press = TRUE;
- case VK_RETURN:
- numpad = ext_key;
- break;
- case VK_NUMPAD0:
- case VK_NUMPAD1:
- case VK_NUMPAD2:
- case VK_NUMPAD3:
- case VK_NUMPAD4:
- case VK_NUMPAD5:
- case VK_NUMPAD6:
- case VK_NUMPAD7:
- case VK_NUMPAD8:
- case VK_NUMPAD9:
- case VK_ADD:
- case VK_MULTIPLY:
- case VK_SUBTRACT:
- case VK_SEPARATOR:
- case VK_DECIMAL:
- term_no_press = TRUE;
- case VK_CLEAR:
- case VK_HOME:
- case VK_END:
- case VK_PRIOR:
- case VK_NEXT:
- case VK_INSERT:
- case VK_DELETE:
- case VK_UP:
- case VK_DOWN:
- case VK_LEFT:
- case VK_RIGHT:
- numpad = !ext_key;
- }
-
- if (numpad) Term_keypress('K');
-
- Term_keypress(hexsym[i / 16]);
- Term_keypress(hexsym[i % 16]);
- Term_keypress(13);
-
- return 1;
- }
-
- return 0;
+ bool mc = FALSE;
+ bool ms = FALSE;
+ bool ma = FALSE;
+
+ if (GetKeyState(VK_CONTROL) & 0x8000)
+ mc = TRUE;
+ if (GetKeyState(VK_SHIFT) & 0x8000)
+ ms = TRUE;
+ if (GetKeyState(VK_MENU) & 0x8000)
+ ma = TRUE;
+
+ term_no_press = (ma) ? TRUE : FALSE;
+ if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)])) {
+ bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
+ bool numpad = FALSE;
+
+ Term_keypress(31);
+ if (mc)
+ Term_keypress('C');
+ if (ms)
+ Term_keypress('S');
+ if (ma)
+ Term_keypress('A');
+
+ int i = LOBYTE(HIWORD(lParam));
+ Term_keypress('x');
+ switch (wParam) {
+ case VK_DIVIDE:
+ term_no_press = TRUE;
+ case VK_RETURN:
+ numpad = ext_key;
+ break;
+ case VK_NUMPAD0:
+ case VK_NUMPAD1:
+ case VK_NUMPAD2:
+ case VK_NUMPAD3:
+ case VK_NUMPAD4:
+ case VK_NUMPAD5:
+ case VK_NUMPAD6:
+ case VK_NUMPAD7:
+ case VK_NUMPAD8:
+ case VK_NUMPAD9:
+ case VK_ADD:
+ case VK_MULTIPLY:
+ case VK_SUBTRACT:
+ case VK_SEPARATOR:
+ case VK_DECIMAL:
+ term_no_press = TRUE;
+ case VK_CLEAR:
+ case VK_HOME:
+ case VK_END:
+ case VK_PRIOR:
+ case VK_NEXT:
+ case VK_INSERT:
+ case VK_DELETE:
+ case VK_UP:
+ case VK_DOWN:
+ case VK_LEFT:
+ case VK_RIGHT:
+ numpad = !ext_key;
+ }
+
+ if (numpad)
+ Term_keypress('K');
+
+ Term_keypress(hexsym[i / 16]);
+ Term_keypress(hexsym[i % 16]);
+ Term_keypress(13);
+
+ return 1;
+ }
+
+ return 0;
}
-
/*!
* todo WNDCLASSに影響があるのでplayer_type*の追加は保留
*/
LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- PAINTSTRUCT ps;
- term_data *td;
- td = (term_data *)GetWindowLong(hWnd, 0);
-
- switch (uMsg)
- {
- case WM_NCCREATE:
- {
- SetWindowLong(hWnd, 0, (LONG)(my_td));
- break;
- }
- case WM_CREATE:
- {
- mop.dwCallback = (DWORD)hWnd;
- return 0;
- }
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO *lpmmi;
- RECT rc;
-
- lpmmi = (MINMAXINFO*)lParam;
- if (!td) return 1;
-
- rc.left = rc.top = 0;
- rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
- rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
-
- AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
-
- lpmmi->ptMinTrackSize.x = rc.right - rc.left;
- lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
-
- return 0;
- }
- case WM_PAINT:
- {
- BeginPaint(hWnd, &ps);
- if (td) term_data_redraw(p_ptr, td);
- EndPaint(hWnd, &ps);
- ValidateRect(hWnd, NULL);
- return 0;
- }
- case MM_MCINOTIFY:
- {
- if (wParam == MCI_NOTIFY_SUCCESSFUL)
- {
- mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
- mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
- }
-
- return 0;
- }
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
- {
- if (process_keydown(wParam, lParam))
- return 0;
- break;
- }
- case WM_CHAR:
- {
- if (term_no_press) term_no_press = FALSE;
- else Term_keypress(wParam);
- return 0;
- }
- case WM_LBUTTONDOWN:
- {
- mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
- mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
- mouse_down = TRUE;
- oldx = mousex;
- oldy = mousey;
- return 0;
- }
- case WM_LBUTTONUP:
- {
- HGLOBAL hGlobal;
- LPSTR lpStr;
- TERM_LEN dx = abs(oldx - mousex) + 1;
- TERM_LEN dy = abs(oldy - mousey) + 1;
- TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
- TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
-
- mouse_down = FALSE;
- paint_rect = FALSE;
+ PAINTSTRUCT ps;
+ term_data *td;
+ td = (term_data *)GetWindowLong(hWnd, 0);
+
+ switch (uMsg) {
+ case WM_NCCREATE: {
+ SetWindowLong(hWnd, 0, (LONG)(my_td));
+ break;
+ }
+ case WM_CREATE: {
+ mop.dwCallback = (DWORD)hWnd;
+ return 0;
+ }
+ case WM_GETMINMAXINFO: {
+ MINMAXINFO *lpmmi;
+ RECT rc;
+
+ lpmmi = (MINMAXINFO *)lParam;
+ if (!td)
+ return 1;
+
+ rc.left = rc.top = 0;
+ rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
+ rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
+
+ AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
+
+ lpmmi->ptMinTrackSize.x = rc.right - rc.left;
+ lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
+
+ return 0;
+ }
+ case WM_PAINT: {
+ BeginPaint(hWnd, &ps);
+ if (td)
+ term_data_redraw(p_ptr, td);
+ EndPaint(hWnd, &ps);
+ ValidateRect(hWnd, NULL);
+ return 0;
+ }
+ case MM_MCINOTIFY: {
+ if (wParam == MCI_NOTIFY_SUCCESSFUL) {
+ mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
+ mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
+ }
+
+ return 0;
+ }
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN: {
+ if (process_keydown(wParam, lParam))
+ return 0;
+ break;
+ }
+ case WM_CHAR: {
+ if (term_no_press)
+ term_no_press = FALSE;
+ else
+ Term_keypress(wParam);
+ return 0;
+ }
+ case WM_LBUTTONDOWN: {
+ mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
+ mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
+ mouse_down = TRUE;
+ oldx = mousex;
+ oldy = mousey;
+ return 0;
+ }
+ case WM_LBUTTONUP: {
+ HGLOBAL hGlobal;
+ LPSTR lpStr;
+ TERM_LEN dx = abs(oldx - mousex) + 1;
+ TERM_LEN dy = abs(oldy - mousey) + 1;
+ TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
+ TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
+
+ mouse_down = FALSE;
+ paint_rect = FALSE;
#ifdef JP
- int sz = (dx + 3) * dy;
+ int sz = (dx + 3) * dy;
#else
- int sz = (dx + 2) * dy;
+ int sz = (dx + 2) * dy;
#endif
- hGlobal = GlobalAlloc(GHND, sz + 1);
- if (hGlobal == NULL) return 0;
- lpStr = (LPSTR)GlobalLock(hGlobal);
+ hGlobal = GlobalAlloc(GHND, sz + 1);
+ if (hGlobal == NULL)
+ return 0;
+ lpStr = (LPSTR)GlobalLock(hGlobal);
- for (int i = 0; i < dy; i++)
- {
+ for (int i = 0; i < dy; i++) {
#ifdef JP
- char *s;
- char **scr = data[0].t.scr->c;
-
- C_MAKE(s, (dx + 1), char);
- strncpy(s, &scr[oy + i][ox], dx);
-
- if (ox > 0)
- {
- if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
- }
-
- if (ox + dx < data[0].cols)
- {
- if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
- }
-
- for (int j = 0; j < dx; j++)
- {
- if (s[j] == 127) s[j] = '#';
- *lpStr++ = s[j];
- }
+ char *s;
+ char **scr = data[0].t.scr->c;
+
+ C_MAKE(s, (dx + 1), char);
+ strncpy(s, &scr[oy + i][ox], dx);
+
+ if (ox > 0) {
+ if (iskanji(scr[oy + i][ox - 1]))
+ s[0] = ' ';
+ }
+
+ if (ox + dx < data[0].cols) {
+ if (iskanji(scr[oy + i][ox + dx - 1]))
+ s[dx - 1] = ' ';
+ }
+
+ for (int j = 0; j < dx; j++) {
+ if (s[j] == 127)
+ s[j] = '#';
+ *lpStr++ = s[j];
+ }
#else
- for (int j = 0; j < dx; j++)
- {
- *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
- }
+ for (int j = 0; j < dx; j++) {
+ *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
+ }
#endif
- if (dy > 1)
- {
- *lpStr++ = '\r';
- *lpStr++ = '\n';
- }
- }
-
- GlobalUnlock(hGlobal);
- if (OpenClipboard(hWnd) == 0)
- {
- GlobalFree(hGlobal);
- return 0;
- }
-
- EmptyClipboard();
- SetClipboardData(CF_TEXT, hGlobal);
- CloseClipboard();
- Term_redraw();
- return 0;
- }
- case WM_MOUSEMOVE:
- {
- if (!mouse_down) return 0;
-
- int dx, dy;
- int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
- int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
- int ox, oy;
-
- if (paint_rect)
- {
- dx = abs(oldx - mousex) + 1;
- dy = abs(oldy - mousey) + 1;
- ox = (oldx > mousex) ? mousex : oldx;
- oy = (oldy > mousey) ? mousey : oldy;
- term_inversed_area(hWnd, ox, oy, dx, dy);
- }
- else
- {
- paint_rect = TRUE;
- }
-
- dx = abs(cx - mousex) + 1;
- dy = abs(cy - mousey) + 1;
- ox = (cx > mousex) ? mousex : cx;
- oy = (cy > mousey) ? mousey : cy;
- term_inversed_area(hWnd, ox, oy, dx, dy);
-
- oldx = cx;
- oldy = cy;
- return 0;
- }
- case WM_INITMENU:
- {
- setup_menus();
- return 0;
- }
- case WM_CLOSE:
- {
- if (!game_in_progress || !current_world_ptr->character_generated)
- {
- quit(NULL);
- return 0;
- }
-
- if (!can_save)
- {
- plog(_("今は終了できません。", "You may not do that right now."));
- return 0;
- }
-
- msg_flag = FALSE;
- forget_lite(p_ptr->current_floor_ptr);
- forget_view(p_ptr->current_floor_ptr);
- clear_mon_lite(p_ptr->current_floor_ptr);
- Term_key_push(SPECIAL_KEY_QUIT);
- return 0;
- }
- case WM_QUERYENDSESSION:
- {
- if (!game_in_progress || !current_world_ptr->character_generated)
- {
- quit(NULL);
- return 0;
- }
-
- msg_flag = FALSE;
- if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
- exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
-
- p_ptr->panic_save = 1;
- signals_ignore_tstp();
- (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
- (void)save_player(p_ptr);
- quit(NULL);
- return 0;
- }
- case WM_QUIT:
- {
- quit(NULL);
- return 0;
- }
- case WM_COMMAND:
- {
- process_menus(p_ptr, LOWORD(wParam));
- return 0;
- }
- case WM_SIZE:
- {
- if (!td) return 1;
- if (!td->w) return 1;
- if (td->size_hack) return 1;
-
- // todo 二重のswitch文。後で分割する.
- switch (wParam)
- {
- case SIZE_MINIMIZED:
- {
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
- }
-
- return 0;
- }
- case SIZE_MAXIMIZED:
- case SIZE_RESTORED:
- {
- TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
- TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
- if ((td->cols != cols) || (td->rows != rows))
- {
- td->cols = cols;
- td->rows = rows;
- if (!IsZoomed(td->w) && !IsIconic(td->w))
- {
- normsize.x = td->cols;
- normsize.y = td->rows;
- }
-
- Term_activate(&td->t);
- Term_resize(td->cols, td->rows);
- InvalidateRect(td->w, NULL, TRUE);
- }
-
- td->size_hack = TRUE;
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
- }
-
- td->size_hack = FALSE;
-
- return 0;
- }
- }
-
- break;
- }
- case WM_PALETTECHANGED:
- {
- if ((HWND)wParam == hWnd) return 0;
- }
- case WM_QUERYNEWPALETTE:
- {
- if (!paletted) return 0;
-
- HDC hdc = GetDC(hWnd);
- SelectPalette(hdc, hPal, FALSE);
- int i = RealizePalette(hdc);
- if (i) InvalidateRect(hWnd, NULL, TRUE);
-
- ReleaseDC(hWnd, hdc);
- return 0;
- }
- case WM_ACTIVATE:
- {
- if (!wParam || HIWORD(lParam)) break;
-
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- if (!data[i].posfix) term_window_pos(&data[i], hWnd);
- }
-
- SetFocus(hWnd);
- return 0;
- }
- case WM_ACTIVATEAPP:
- {
- if (IsIconic(td->w)) break;
-
- for (int i = 1; i < MAX_TERM_DATA; i++)
- {
- if (data[i].visible)
- {
- if (wParam == TRUE)
- {
- ShowWindow(data[i].w, SW_SHOW);
- }
- else
- {
- ShowWindow(data[i].w, SW_HIDE);
- }
- }
- }
- }
- }
-
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ if (dy > 1) {
+ *lpStr++ = '\r';
+ *lpStr++ = '\n';
+ }
+ }
+
+ GlobalUnlock(hGlobal);
+ if (OpenClipboard(hWnd) == 0) {
+ GlobalFree(hGlobal);
+ return 0;
+ }
+
+ EmptyClipboard();
+ SetClipboardData(CF_TEXT, hGlobal);
+ CloseClipboard();
+ Term_redraw();
+ return 0;
+ }
+ case WM_MOUSEMOVE: {
+ if (!mouse_down)
+ return 0;
+
+ int dx, dy;
+ int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
+ int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
+ int ox, oy;
+
+ if (paint_rect) {
+ dx = abs(oldx - mousex) + 1;
+ dy = abs(oldy - mousey) + 1;
+ ox = (oldx > mousex) ? mousex : oldx;
+ oy = (oldy > mousey) ? mousey : oldy;
+ term_inversed_area(hWnd, ox, oy, dx, dy);
+ } else {
+ paint_rect = TRUE;
+ }
+
+ dx = abs(cx - mousex) + 1;
+ dy = abs(cy - mousey) + 1;
+ ox = (cx > mousex) ? mousex : cx;
+ oy = (cy > mousey) ? mousey : cy;
+ term_inversed_area(hWnd, ox, oy, dx, dy);
+
+ oldx = cx;
+ oldy = cy;
+ return 0;
+ }
+ case WM_INITMENU: {
+ setup_menus();
+ return 0;
+ }
+ case WM_CLOSE: {
+ if (!game_in_progress || !current_world_ptr->character_generated) {
+ quit(NULL);
+ return 0;
+ }
+
+ if (!can_save) {
+ plog(_("今は終了できません。", "You may not do that right now."));
+ return 0;
+ }
+
+ msg_flag = FALSE;
+ forget_lite(p_ptr->current_floor_ptr);
+ forget_view(p_ptr->current_floor_ptr);
+ clear_mon_lite(p_ptr->current_floor_ptr);
+ Term_key_push(SPECIAL_KEY_QUIT);
+ return 0;
+ }
+ case WM_QUERYENDSESSION: {
+ if (!game_in_progress || !current_world_ptr->character_generated) {
+ quit(NULL);
+ return 0;
+ }
+
+ msg_flag = FALSE;
+ if (p_ptr->chp < 0)
+ p_ptr->is_dead = FALSE;
+ exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
+
+ p_ptr->panic_save = 1;
+ signals_ignore_tstp();
+ (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
+ (void)save_player(p_ptr);
+ quit(NULL);
+ return 0;
+ }
+ case WM_QUIT: {
+ quit(NULL);
+ return 0;
+ }
+ case WM_COMMAND: {
+ process_menus(p_ptr, LOWORD(wParam));
+ return 0;
+ }
+ case WM_SIZE: {
+ if (!td)
+ return 1;
+ if (!td->w)
+ return 1;
+ if (td->size_hack)
+ return 1;
+
+ // todo 二重のswitch文。後で分割する.
+ switch (wParam) {
+ case SIZE_MINIMIZED: {
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (data[i].visible)
+ ShowWindow(data[i].w, SW_HIDE);
+ }
+
+ return 0;
+ }
+ case SIZE_MAXIMIZED:
+ case SIZE_RESTORED: {
+ TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
+ TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
+ if ((td->cols != cols) || (td->rows != rows)) {
+ td->cols = cols;
+ td->rows = rows;
+ if (!IsZoomed(td->w) && !IsIconic(td->w)) {
+ normsize.x = td->cols;
+ normsize.y = td->rows;
+ }
+
+ Term_activate(&td->t);
+ Term_resize(td->cols, td->rows);
+ InvalidateRect(td->w, NULL, TRUE);
+ }
+
+ td->size_hack = TRUE;
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (data[i].visible)
+ ShowWindow(data[i].w, SW_SHOW);
+ }
+
+ td->size_hack = FALSE;
+
+ return 0;
+ }
+ }
+
+ break;
+ }
+ case WM_PALETTECHANGED: {
+ if ((HWND)wParam == hWnd)
+ return 0;
+ }
+ case WM_QUERYNEWPALETTE: {
+ if (!paletted)
+ return 0;
+
+ HDC hdc = GetDC(hWnd);
+ SelectPalette(hdc, hPal, FALSE);
+ int i = RealizePalette(hdc);
+ if (i)
+ InvalidateRect(hWnd, NULL, TRUE);
+
+ ReleaseDC(hWnd, hdc);
+ return 0;
+ }
+ case WM_ACTIVATE: {
+ if (!wParam || HIWORD(lParam))
+ break;
+
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (!data[i].posfix)
+ term_window_pos(&data[i], hWnd);
+ }
+
+ SetFocus(hWnd);
+ return 0;
+ }
+ case WM_ACTIVATEAPP: {
+ if (IsIconic(td->w))
+ break;
+
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (data[i].visible) {
+ if (wParam == TRUE) {
+ ShowWindow(data[i].w, SW_SHOW);
+ } else {
+ ShowWindow(data[i].w, SW_HIDE);
+ }
+ }
+ }
+ }
+ }
+
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-
/*!
* todo WNDCLASSに影響があるのでplayer_type*の追加は保留
*/
LRESULT PASCAL AngbandListProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- term_data *td;
- PAINTSTRUCT ps;
- td = (term_data *)GetWindowLong(hWnd, 0);
-
- switch (uMsg)
- {
- case WM_NCCREATE:
- {
- SetWindowLong(hWnd, 0, (LONG)(my_td));
- break;
- }
- case WM_CREATE:
- {
- return 0;
- }
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO *lpmmi;
- RECT rc;
-
- lpmmi = (MINMAXINFO*)lParam;
- if (!td) return 1;
-
- rc.left = rc.top = 0;
- rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
- rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
-
- AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
- lpmmi->ptMinTrackSize.x = rc.right - rc.left;
- lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
- return 0;
- }
- case WM_SIZE:
- {
- if (!td) return 1;
- if (!td->w) return 1;
- if (td->size_hack) return 1;
-
- td->size_hack = TRUE;
-
- TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
- TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
- if ((td->cols != cols) || (td->rows != rows))
- {
- term *old_term = Term;
- td->cols = cols;
- td->rows = rows;
- Term_activate(&td->t);
- Term_resize(td->cols, td->rows);
- Term_activate(old_term);
- InvalidateRect(td->w, NULL, TRUE);
- p_ptr->window = 0xFFFFFFFF;
- handle_stuff(p_ptr);
- }
-
- td->size_hack = FALSE;
- return 0;
- }
- case WM_PAINT:
- {
- BeginPaint(hWnd, &ps);
- if (td) term_data_redraw(p_ptr, td);
- EndPaint(hWnd, &ps);
- return 0;
- }
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
- {
- if (process_keydown(wParam, lParam))
- return 0;
-
- break;
- }
- case WM_CHAR:
- {
- if (term_no_press) term_no_press = FALSE;
- else Term_keypress(wParam);
- return 0;
- }
- case WM_PALETTECHANGED:
- {
- if ((HWND)wParam == hWnd) return FALSE;
- }
- case WM_QUERYNEWPALETTE:
- {
- if (!paletted) return 0;
-
- HDC hdc = GetDC(hWnd);
- SelectPalette(hdc, hPal, FALSE);
- int i = RealizePalette(hdc);
- if (i) InvalidateRect(hWnd, NULL, TRUE);
-
- ReleaseDC(hWnd, hdc);
- return 0;
- }
- case WM_NCLBUTTONDOWN:
- {
+ term_data *td;
+ PAINTSTRUCT ps;
+ td = (term_data *)GetWindowLong(hWnd, 0);
+
+ switch (uMsg) {
+ case WM_NCCREATE: {
+ SetWindowLong(hWnd, 0, (LONG)(my_td));
+ break;
+ }
+ case WM_CREATE: {
+ return 0;
+ }
+ case WM_GETMINMAXINFO: {
+ MINMAXINFO *lpmmi;
+ RECT rc;
+
+ lpmmi = (MINMAXINFO *)lParam;
+ if (!td)
+ return 1;
+
+ rc.left = rc.top = 0;
+ rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
+ rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
+
+ AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
+ lpmmi->ptMinTrackSize.x = rc.right - rc.left;
+ lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
+ return 0;
+ }
+ case WM_SIZE: {
+ if (!td)
+ return 1;
+ if (!td->w)
+ return 1;
+ if (td->size_hack)
+ return 1;
+
+ td->size_hack = TRUE;
+
+ TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
+ TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
+ if ((td->cols != cols) || (td->rows != rows)) {
+ term *old_term = Term;
+ td->cols = cols;
+ td->rows = rows;
+ Term_activate(&td->t);
+ Term_resize(td->cols, td->rows);
+ Term_activate(old_term);
+ InvalidateRect(td->w, NULL, TRUE);
+ p_ptr->window = 0xFFFFFFFF;
+ handle_stuff(p_ptr);
+ }
+
+ td->size_hack = FALSE;
+ return 0;
+ }
+ case WM_PAINT: {
+ BeginPaint(hWnd, &ps);
+ if (td)
+ term_data_redraw(p_ptr, td);
+ EndPaint(hWnd, &ps);
+ return 0;
+ }
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN: {
+ if (process_keydown(wParam, lParam))
+ return 0;
+
+ break;
+ }
+ case WM_CHAR: {
+ if (term_no_press)
+ term_no_press = FALSE;
+ else
+ Term_keypress(wParam);
+ return 0;
+ }
+ case WM_PALETTECHANGED: {
+ if ((HWND)wParam == hWnd)
+ return FALSE;
+ }
+ case WM_QUERYNEWPALETTE: {
+ if (!paletted)
+ return 0;
+
+ HDC hdc = GetDC(hWnd);
+ SelectPalette(hdc, hPal, FALSE);
+ int i = RealizePalette(hdc);
+ if (i)
+ InvalidateRect(hWnd, NULL, TRUE);
+
+ ReleaseDC(hWnd, hdc);
+ return 0;
+ }
+ case WM_NCLBUTTONDOWN: {
#ifdef HTCLOSE
- if (wParam == HTCLOSE) wParam = HTSYSMENU;
+ if (wParam == HTCLOSE)
+ wParam = HTSYSMENU;
#endif /* HTCLOSE */
- if (wParam == HTSYSMENU)
- {
- if (td->visible)
- {
- td->visible = FALSE;
- ShowWindow(td->w, SW_HIDE);
- }
+ if (wParam == HTSYSMENU) {
+ if (td->visible) {
+ td->visible = FALSE;
+ ShowWindow(td->w, SW_HIDE);
+ }
- return 0;
- }
+ return 0;
+ }
- break;
- }
- }
+ break;
+ }
+ }
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-
LRESULT PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- static int iMouse = 0;
- static WORD xMouse = 0;
- static WORD yMouse = 0;
-
- switch (uMsg)
- {
- case WM_NCCREATE:
- {
- break;
- }
-
- case WM_SETCURSOR:
- {
- SetCursor(NULL);
- return 0;
- }
-
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_KEYDOWN:
- {
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- return 0;
- }
- case WM_MOUSEMOVE:
- {
- if (iMouse)
- {
- int dx = LOWORD(lParam) - xMouse;
- int dy = HIWORD(lParam) - yMouse;
-
- if (dx < 0) dx = -dx;
- if (dy < 0) dy = -dy;
-
- if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
- {
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- }
- }
-
- iMouse = 1;
- xMouse = LOWORD(lParam);
- yMouse = HIWORD(lParam);
-
- return 0;
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwndSaver);
- hwndSaver = NULL;
- return 0;
- }
- }
-
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ static int iMouse = 0;
+ static WORD xMouse = 0;
+ static WORD yMouse = 0;
+
+ switch (uMsg) {
+ case WM_NCCREATE: {
+ break;
+ }
+
+ case WM_SETCURSOR: {
+ SetCursor(NULL);
+ return 0;
+ }
+
+ case WM_LBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_KEYDOWN: {
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ return 0;
+ }
+ case WM_MOUSEMOVE: {
+ if (iMouse) {
+ int dx = LOWORD(lParam) - xMouse;
+ int dy = HIWORD(lParam) - yMouse;
+
+ if (dx < 0)
+ dx = -dx;
+ if (dy < 0)
+ dy = -dy;
+
+ if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS)) {
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ }
+ }
+
+ iMouse = 1;
+ xMouse = LOWORD(lParam);
+ yMouse = HIWORD(lParam);
+
+ return 0;
+ }
+ case WM_CLOSE: {
+ DestroyWindow(hwndSaver);
+ hwndSaver = NULL;
+ return 0;
+ }
+ }
+
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-
/*
* Display warning message (see "z-util.c")
*/
static void hack_plog(concptr str)
{
- if (str)
- {
+ if (str) {
#ifdef JP
- MessageBox(NULL, str, "警告!",
- MB_ICONEXCLAMATION | MB_OK);
+ MessageBox(NULL, str, "警告!", MB_ICONEXCLAMATION | MB_OK);
#else
- MessageBox(NULL, str, "Warning",
- MB_ICONEXCLAMATION | MB_OK);
+ MessageBox(NULL, str, "Warning", MB_ICONEXCLAMATION | MB_OK);
#endif
-
- }
+ }
}
-
/*
* Display error message and quit (see "z-util.c")
*/
static void hack_quit(concptr str)
{
- if (str)
- {
+ if (str) {
#ifdef JP
- MessageBox(NULL, str, "エラー!",
- MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ MessageBox(NULL, str, "エラー!", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
#else
- MessageBox(NULL, str, "Error",
- MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ MessageBox(NULL, str, "Error", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
#endif
+ }
- }
+ UnregisterClass(AppName, hInstance);
+ if (hIcon)
+ DestroyIcon(hIcon);
- UnregisterClass(AppName, hInstance);
- if (hIcon) DestroyIcon(hIcon);
-
- exit(0);
+ exit(0);
}
-
/*
* Display warning message (see "z-util.c")
*/
static void hook_plog(concptr str)
{
- if (str)
- {
+ if (str) {
#ifdef JP
- MessageBox(data[0].w, str, "警告!",
- MB_ICONEXCLAMATION | MB_OK);
+ MessageBox(data[0].w, str, "警告!", MB_ICONEXCLAMATION | MB_OK);
#else
- MessageBox(data[0].w, str, "Warning",
- MB_ICONEXCLAMATION | MB_OK);
+ MessageBox(data[0].w, str, "Warning", MB_ICONEXCLAMATION | MB_OK);
#endif
-
- }
+ }
}
-
/*
* Display error message and quit (see "z-util.c")
*/
static void hook_quit(concptr str)
{
- if (str)
- {
+ if (str) {
#ifdef JP
- MessageBox(data[0].w, str, "エラー!",
- MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ MessageBox(data[0].w, str, "エラー!", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
#else
- MessageBox(data[0].w, str, "Error",
- MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ MessageBox(data[0].w, str, "Error", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
#endif
- }
-
- save_prefs();
- for (int i = MAX_TERM_DATA - 1; i >= 0; --i)
- {
- term_force_font(&data[i], NULL);
- if (data[i].font_want) string_free(data[i].font_want);
- if (data[i].w) DestroyWindow(data[i].w);
- data[i].w = 0;
- }
-
- if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
- if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
- if (infMask.hPalette) DeleteObject(infMask.hPalette);
- if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
-
- DeleteObject(hbrYellow);
- delete_bg();
-
- if (hPal) DeleteObject(hPal);
-
- UnregisterClass(AppName, hInstance);
- if (hIcon) DestroyIcon(hIcon);
-
- exit(0);
+ }
+
+ save_prefs();
+ for (int i = MAX_TERM_DATA - 1; i >= 0; --i) {
+ term_force_font(&data[i], NULL);
+ if (data[i].font_want)
+ string_free(data[i].font_want);
+ if (data[i].w)
+ DestroyWindow(data[i].w);
+ data[i].w = 0;
+ }
+
+ if (infGraph.hPalette)
+ DeleteObject(infGraph.hPalette);
+ if (infGraph.hBitmap)
+ DeleteObject(infGraph.hBitmap);
+ if (infMask.hPalette)
+ DeleteObject(infMask.hPalette);
+ if (infMask.hBitmap)
+ DeleteObject(infMask.hBitmap);
+
+ DeleteObject(hbrYellow);
+ delete_bg();
+
+ if (hPal)
+ DeleteObject(hPal);
+
+ UnregisterClass(AppName, hInstance);
+ if (hIcon)
+ DestroyIcon(hIcon);
+
+ exit(0);
}
-
/*
* Init some stuff
*/
static void init_stuff(void)
{
- char path[1024];
- GetModuleFileName(hInstance, path, 512);
- argv0 = path;
- strcpy(path + strlen(path) - 4, ".INI");
- ini_file = string_make(path);
- int i = strlen(path);
-
- for (; i > 0; i--)
- {
- if (path[i] == '\\')
- {
- break;
- }
- }
-
- strcpy(path + i + 1, "lib\\");
- validate_dir(path, TRUE);
- init_file_paths(path);
- validate_dir(ANGBAND_DIR_APEX, FALSE);
- validate_dir(ANGBAND_DIR_BONE, FALSE);
- if (!check_dir(ANGBAND_DIR_EDIT))
- {
- validate_dir(ANGBAND_DIR_DATA, TRUE);
- }
- else
- {
- validate_dir(ANGBAND_DIR_DATA, FALSE);
- }
-
- validate_dir(ANGBAND_DIR_FILE, TRUE);
- validate_dir(ANGBAND_DIR_HELP, FALSE);
- validate_dir(ANGBAND_DIR_INFO, FALSE);
- validate_dir(ANGBAND_DIR_PREF, TRUE);
- validate_dir(ANGBAND_DIR_SAVE, FALSE);
- validate_dir(ANGBAND_DIR_USER, TRUE);
- validate_dir(ANGBAND_DIR_XTRA, TRUE);
- path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
-
- validate_file(path);
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
- ANGBAND_DIR_XTRA_GRAF = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
-
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
- ANGBAND_DIR_XTRA_SOUND = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
-
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
- ANGBAND_DIR_XTRA_MUSIC = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
-
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
- ANGBAND_DIR_XTRA_HELP = string_make(path);
+ char path[1024];
+ GetModuleFileName(hInstance, path, 512);
+ argv0 = path;
+ strcpy(path + strlen(path) - 4, ".INI");
+ ini_file = string_make(path);
+ int i = strlen(path);
+
+ for (; i > 0; i--) {
+ if (path[i] == '\\') {
+ break;
+ }
+ }
+
+ strcpy(path + i + 1, "lib\\");
+ validate_dir(path, TRUE);
+ init_file_paths(path);
+ validate_dir(ANGBAND_DIR_APEX, FALSE);
+ validate_dir(ANGBAND_DIR_BONE, FALSE);
+ if (!check_dir(ANGBAND_DIR_EDIT)) {
+ validate_dir(ANGBAND_DIR_DATA, TRUE);
+ } else {
+ validate_dir(ANGBAND_DIR_DATA, FALSE);
+ }
+
+ validate_dir(ANGBAND_DIR_FILE, TRUE);
+ validate_dir(ANGBAND_DIR_HELP, FALSE);
+ validate_dir(ANGBAND_DIR_INFO, FALSE);
+ validate_dir(ANGBAND_DIR_PREF, TRUE);
+ validate_dir(ANGBAND_DIR_SAVE, FALSE);
+ validate_dir(ANGBAND_DIR_USER, TRUE);
+ validate_dir(ANGBAND_DIR_XTRA, TRUE);
+ path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
+
+ validate_file(path);
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
+ ANGBAND_DIR_XTRA_GRAF = string_make(path);
+ validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
+
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
+ ANGBAND_DIR_XTRA_SOUND = string_make(path);
+ validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
+
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
+ ANGBAND_DIR_XTRA_MUSIC = string_make(path);
+ validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
+
+ path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
+ ANGBAND_DIR_XTRA_HELP = string_make(path);
}
-
/*!
* todo よく見るとhMutexはちゃんと使われていない……?
* @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
*/
static bool is_already_running(void)
{
- HANDLE hMutex;
- hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
- if (GetLastError() == ERROR_ALREADY_EXISTS)
- {
- return TRUE;
- }
-
- return FALSE;
-}
+ HANDLE hMutex;
+ hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ return TRUE;
+ }
+ return FALSE;
+}
/*!
* @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
*/
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
- WNDCLASS wc;
- HDC hdc;
- MSG msg;
-
- setlocale(LC_ALL, "ja_JP");
- (void)nCmdShow;
- hInstance = hInst;
- if (is_already_running())
- {
- MessageBox(NULL,
- _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
- _("エラー!", "Error"),
- MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
- return FALSE;
- }
-
- if (hPrevInst == NULL)
- {
- wc.style = CS_CLASSDC;
- wc.lpfnWndProc = AngbandWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 4;
- wc.hInstance = hInst;
- wc.hIcon = hIcon = LoadIcon(hInst, AppName);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName = AppName;
- wc.lpszClassName = AppName;
-
- if (!RegisterClass(&wc)) exit(1);
-
- wc.lpfnWndProc = AngbandListProc;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = AngList;
-
- if (!RegisterClass(&wc)) exit(2);
-
- wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
- wc.lpfnWndProc = AngbandSaverProc;
- wc.hCursor = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "WindowsScreenSaverClass";
-
- if (!RegisterClass(&wc)) exit(3);
- }
-
- plog_aux = hack_plog;
- quit_aux = hack_quit;
- core_aux = hack_quit;
-
- init_stuff();
- for (int i = 0; special_key_list[i]; ++i)
- {
- special_key[special_key_list[i]] = TRUE;
- }
-
- for (int i = 0; ignore_key_list[i]; ++i)
- {
- ignore_key[ignore_key_list[i]] = TRUE;
- }
-
- hdc = GetDC(NULL);
- colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
- paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
- ReleaseDC(NULL, hdc);
-
- for (int i = 0; i < 256; i++)
- {
- byte rv = angband_color_table[i][1];
- byte gv = angband_color_table[i][2];
- byte bv = angband_color_table[i][3];
- win_clr[i] = PALETTERGB(rv, gv, bv);
- angband_color_table[i][0] = win_pal[i];
- }
-
- init_windows();
- init_bg();
-
- plog_aux = hook_plog;
- quit_aux = hook_quit;
- core_aux = hook_quit;
-
- ANGBAND_SYS = "win";
- if (7 != GetKeyboardType(0))
- ANGBAND_KEYBOARD = "0";
- else
- {
- switch (GetKeyboardType(1))
- {
- case 0x0D01: case 0x0D02:
- case 0x0D03: case 0x0D04:
- case 0x0D05: case 0x0D06:
- /* NEC PC-98x1 */
- ANGBAND_KEYBOARD = "NEC98";
- break;
- default:
- /* PC/AT */
- ANGBAND_KEYBOARD = "JAPAN";
- }
- }
-
- signals_init();
- Term_activate(term_screen);
- init_angband(p_ptr, process_autopick_file_command);
- initialized = TRUE;
+ WNDCLASS wc;
+ HDC hdc;
+ MSG msg;
+
+ setlocale(LC_ALL, "ja_JP");
+ (void)nCmdShow;
+ hInstance = hInst;
+ if (is_already_running()) {
+ MessageBox(
+ NULL, _("変愚蛮怒はすでに起動しています。", "Hengband is already running."), _("エラー!", "Error"), MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ return FALSE;
+ }
+
+ if (hPrevInst == NULL) {
+ wc.style = CS_CLASSDC;
+ wc.lpfnWndProc = AngbandWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 4;
+ wc.hInstance = hInst;
+ wc.hIcon = hIcon = LoadIcon(hInst, AppName);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = GetStockObject(BLACK_BRUSH);
+ wc.lpszMenuName = AppName;
+ wc.lpszClassName = AppName;
+
+ if (!RegisterClass(&wc))
+ exit(1);
+
+ wc.lpfnWndProc = AngbandListProc;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = AngList;
+
+ if (!RegisterClass(&wc))
+ exit(2);
+
+ wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
+ wc.lpfnWndProc = AngbandSaverProc;
+ wc.hCursor = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = "WindowsScreenSaverClass";
+
+ if (!RegisterClass(&wc))
+ exit(3);
+ }
+
+ plog_aux = hack_plog;
+ quit_aux = hack_quit;
+ core_aux = hack_quit;
+
+ init_stuff();
+ for (int i = 0; special_key_list[i]; ++i) {
+ special_key[special_key_list[i]] = TRUE;
+ }
+
+ for (int i = 0; ignore_key_list[i]; ++i) {
+ ignore_key[ignore_key_list[i]] = TRUE;
+ }
+
+ hdc = GetDC(NULL);
+ colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
+ paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
+ ReleaseDC(NULL, hdc);
+
+ for (int i = 0; i < 256; i++) {
+ byte rv = angband_color_table[i][1];
+ byte gv = angband_color_table[i][2];
+ byte bv = angband_color_table[i][3];
+ win_clr[i] = PALETTERGB(rv, gv, bv);
+ angband_color_table[i][0] = win_pal[i];
+ }
+
+ init_windows();
+ init_bg();
+
+ plog_aux = hook_plog;
+ quit_aux = hook_quit;
+ core_aux = hook_quit;
+
+ ANGBAND_SYS = "win";
+ if (7 != GetKeyboardType(0))
+ ANGBAND_KEYBOARD = "0";
+ else {
+ switch (GetKeyboardType(1)) {
+ case 0x0D01:
+ case 0x0D02:
+ case 0x0D03:
+ case 0x0D04:
+ case 0x0D05:
+ case 0x0D06:
+ /* NEC PC-98x1 */
+ ANGBAND_KEYBOARD = "NEC98";
+ break;
+ default:
+ /* PC/AT */
+ ANGBAND_KEYBOARD = "JAPAN";
+ }
+ }
+
+ signals_init();
+ Term_activate(term_screen);
+ init_angband(p_ptr, process_autopick_file_command);
+ initialized = TRUE;
#ifdef CHUUKEI
- if (lpCmdLine[0] == '-') {
- switch (lpCmdLine[1])
- {
- case 'p':
- case 'P':
- {
- if (!lpCmdLine[2]) break;
- chuukei_server = TRUE;
- if (connect_chuukei_server(&lpCmdLine[2]) < 0) {
- msg_print("connect fail");
- return 0;
- }
- msg_print("connect");
- msg_print(NULL);
- break;
- }
-
- case 'c':
- case 'C':
- {
- if (!lpCmdLine[2]) break;
- chuukei_client = TRUE;
- connect_chuukei_server(&lpCmdLine[2]);
- play_game(player_ptr, FALSE);
- quit(NULL);
- return 0;
- }
- case 'X':
- case 'x':
- {
- if (!lpCmdLine[2]) break;
- prepare_browse_movie(&lpCmdLine[2]);
- play_game(player_ptr, FALSE);
- quit(NULL);
- return 0;
- }
- }
- }
+ if (lpCmdLine[0] == '-') {
+ switch (lpCmdLine[1]) {
+ case 'p':
+ case 'P': {
+ if (!lpCmdLine[2])
+ break;
+ chuukei_server = TRUE;
+ if (connect_chuukei_server(&lpCmdLine[2]) < 0) {
+ msg_print("connect fail");
+ return 0;
+ }
+ msg_print("connect");
+ msg_print(NULL);
+ break;
+ }
+
+ case 'c':
+ case 'C': {
+ if (!lpCmdLine[2])
+ break;
+ chuukei_client = TRUE;
+ connect_chuukei_server(&lpCmdLine[2]);
+ play_game(player_ptr, FALSE);
+ quit(NULL);
+ return 0;
+ }
+ case 'X':
+ case 'x': {
+ if (!lpCmdLine[2])
+ break;
+ prepare_browse_movie(&lpCmdLine[2]);
+ play_game(player_ptr, FALSE);
+ quit(NULL);
+ return 0;
+ }
+ }
+ }
#endif
#ifdef CHUUKEI
- if (!chuukei_server) check_for_save_file(lpCmdLine);
+ if (!chuukei_server)
+ check_for_save_file(lpCmdLine);
#else
- check_for_save_file(p_ptr, lpCmdLine);
+ check_for_save_file(p_ptr, lpCmdLine);
#endif
- prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
- Term_fresh();
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
+ Term_fresh();
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
- quit(NULL);
- return 0;
+ quit(NULL);
+ return 0;
}
#endif /* WINDOWS */
#include "inventory/inventory-slot-types.h"
#include "io/input-key-acceptor.h"
#include "io/report.h"
-#include "io/save.h"
#include "io/write-diary.h"
#include "main/music-definitions-table.h"
#include "main/sound-definitions-table.h"
#include "monster/monster-describer.h"
#include "monster/monster-description-types.h"
#include "monster/monster-info.h"
-#include "mutation/mutation-flag-types.h"
#include "mspell/mspells3.h"
+#include "mutation/mutation-flag-types.h"
#include "object-enchant/tr-types.h"
#include "object-hook/hook-armor.h"
+#include "object/item-tester-hooker.h"
#include "object/object-broken.h"
#include "object/object-flags.h"
#include "object/object-flavor.h"
-#include "object/item-tester-hooker.h"
#include "player/avatar.h"
#include "player/player-class.h"
#include "player/player-move.h"
#include "player/player-race-types.h"
#include "player/race-info-table.h"
#include "player/special-defense-types.h"
+#include "savedata/save.h"
#include "status/base-status.h"
#include "status/element-resistance.h"
#include "term/screen-processor.h"
#include "world/world.h"
/*!
-* @brief 酸攻撃による装備のAC劣化処理 /
-* Acid has hit the player, attempt to affect some armor.
-* @param 酸を浴びたキャラクタへの参照ポインタ
-* @return 装備による軽減があったならTRUEを返す
-* @details
-* Note that the "base armor" of an object never changes.
-* If any armor is damaged (or resists), the player takes less damage.
-*/
+ * @brief 酸攻撃による装備のAC劣化処理 /
+ * Acid has hit the player, attempt to affect some armor.
+ * @param 酸を浴びたキャラクタへの参照ポインタ
+ * @return 装備による軽減があったならTRUEを返す
+ * @details
+ * Note that the "base armor" of an object never changes.
+ * If any armor is damaged (or resists), the player takes less damage.
+ */
static bool acid_minus_ac(player_type *creature_ptr)
{
- object_type *o_ptr = NULL;
- BIT_FLAGS flgs[TR_FLAG_SIZE];
- GAME_TEXT o_name[MAX_NLEN];
-
- /* Pick a (possibly empty) creature_ptr->inventory_list slot */
- switch (randint1(7))
- {
- case 1: o_ptr = &creature_ptr->inventory_list[INVEN_RARM]; break;
- case 2: o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; break;
- case 3: o_ptr = &creature_ptr->inventory_list[INVEN_BODY]; break;
- case 4: o_ptr = &creature_ptr->inventory_list[INVEN_OUTER]; break;
- case 5: o_ptr = &creature_ptr->inventory_list[INVEN_HANDS]; break;
- case 6: o_ptr = &creature_ptr->inventory_list[INVEN_HEAD]; break;
- case 7: o_ptr = &creature_ptr->inventory_list[INVEN_FEET]; break;
- }
-
- if (!o_ptr->k_idx) return FALSE;
- if (!object_is_armour(creature_ptr, o_ptr)) return FALSE;
-
- object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
- object_flags(creature_ptr, o_ptr, flgs);
- /* No damage left to be done */
- if (o_ptr->ac + o_ptr->to_a <= 0)
- {
- msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), o_name);
- return FALSE;
- }
-
- /* Object resists */
- if (have_flag(flgs, TR_IGNORE_ACID))
- {
- msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
- return TRUE;
- }
-
- msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), o_name);
-
- /* Damage the item */
- o_ptr->to_a--;
-
- /* Calculate bonuses */
- creature_ptr->update |= (PU_BONUS);
- creature_ptr->window |= (PW_EQUIP | PW_PLAYER);
-
- calc_android_exp(creature_ptr);
-
- /* Item was damaged */
- return TRUE;
-}
+ object_type *o_ptr = NULL;
+ BIT_FLAGS flgs[TR_FLAG_SIZE];
+ GAME_TEXT o_name[MAX_NLEN];
+
+ /* Pick a (possibly empty) creature_ptr->inventory_list slot */
+ switch (randint1(7)) {
+ case 1:
+ o_ptr = &creature_ptr->inventory_list[INVEN_RARM];
+ break;
+ case 2:
+ o_ptr = &creature_ptr->inventory_list[INVEN_LARM];
+ break;
+ case 3:
+ o_ptr = &creature_ptr->inventory_list[INVEN_BODY];
+ break;
+ case 4:
+ o_ptr = &creature_ptr->inventory_list[INVEN_OUTER];
+ break;
+ case 5:
+ o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
+ break;
+ case 6:
+ o_ptr = &creature_ptr->inventory_list[INVEN_HEAD];
+ break;
+ case 7:
+ o_ptr = &creature_ptr->inventory_list[INVEN_FEET];
+ break;
+ }
+
+ if (!o_ptr->k_idx)
+ return FALSE;
+ if (!object_is_armour(creature_ptr, o_ptr))
+ return FALSE;
+
+ object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+ object_flags(creature_ptr, o_ptr, flgs);
+ /* No damage left to be done */
+ if (o_ptr->ac + o_ptr->to_a <= 0) {
+ msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), o_name);
+ return FALSE;
+ }
+
+ /* Object resists */
+ if (have_flag(flgs, TR_IGNORE_ACID)) {
+ msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
+ return TRUE;
+ }
+ msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), o_name);
+
+ /* Damage the item */
+ o_ptr->to_a--;
+
+ /* Calculate bonuses */
+ creature_ptr->update |= (PU_BONUS);
+ creature_ptr->window |= (PW_EQUIP | PW_PLAYER);
+
+ calc_android_exp(creature_ptr);
+
+ /* Item was damaged */
+ return TRUE;
+}
/*!
-* @brief 酸属性によるプレイヤー損害処理 /
-* Hurt the player with Acid
-* @param creature_ptr 酸を浴びたキャラクタへの参照ポインタ
-* @param dam 基本ダメージ量
-* @param kb_str ダメージ原因記述
-* @param monspell 原因となったモンスター特殊攻撃ID
-* @param aura オーラよるダメージが原因ならばTRUE
-* @return 修正HPダメージ量
-*/
+ * @brief 酸属性によるプレイヤー損害処理 /
+ * Hurt the player with Acid
+ * @param creature_ptr 酸を浴びたキャラクタへの参照ポインタ
+ * @param dam 基本ダメージ量
+ * @param kb_str ダメージ原因記述
+ * @param monspell 原因となったモンスター特殊攻撃ID
+ * @param aura オーラよるダメージが原因ならばTRUE
+ * @return 修正HPダメージ量
+ */
HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
{
- HIT_POINT get_damage;
- int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
- bool double_resist = is_oppose_acid(creature_ptr);
-
- /* Total Immunity */
- if (creature_ptr->immune_acid || (dam <= 0))
- {
- learn_spell(creature_ptr, monspell);
- return 0;
- }
-
- /* Vulnerability (Ouch!) */
- if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
- if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-
- /* Resist the damage */
- if (creature_ptr->resist_acid) dam = (dam + 2) / 3;
- if (double_resist) dam = (dam + 2) / 3;
-
- if (aura || !check_multishadow(creature_ptr))
- {
- if ((!(double_resist || creature_ptr->resist_acid)) &&
- one_in_(HURT_CHANCE))
- (void)do_dec_stat(creature_ptr, A_CHR);
-
- /* If any armor gets hit, defend the player */
- if (acid_minus_ac(creature_ptr)) dam = (dam + 1) / 2;
- }
-
- get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
-
- /* Inventory damage */
- if (!aura && !(double_resist && creature_ptr->resist_acid))
- inventory_damage(creature_ptr, set_acid_destroy, inv);
- return get_damage;
-}
+ HIT_POINT get_damage;
+ int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
+ bool double_resist = is_oppose_acid(creature_ptr);
+
+ /* Total Immunity */
+ if (creature_ptr->immune_acid || (dam <= 0)) {
+ learn_spell(creature_ptr, monspell);
+ return 0;
+ }
+
+ /* Vulnerability (Ouch!) */
+ if (creature_ptr->muta3 & MUT3_VULN_ELEM)
+ dam *= 2;
+ if (creature_ptr->special_defense & KATA_KOUKIJIN)
+ dam += dam / 3;
+
+ /* Resist the damage */
+ if (creature_ptr->resist_acid)
+ dam = (dam + 2) / 3;
+ if (double_resist)
+ dam = (dam + 2) / 3;
+
+ if (aura || !check_multishadow(creature_ptr)) {
+ if ((!(double_resist || creature_ptr->resist_acid)) && one_in_(HURT_CHANCE))
+ (void)do_dec_stat(creature_ptr, A_CHR);
+
+ /* If any armor gets hit, defend the player */
+ if (acid_minus_ac(creature_ptr))
+ dam = (dam + 1) / 2;
+ }
+ get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+
+ /* Inventory damage */
+ if (!aura && !(double_resist && creature_ptr->resist_acid))
+ inventory_damage(creature_ptr, set_acid_destroy, inv);
+ return get_damage;
+}
/*!
-* @brief 電撃属性によるプレイヤー損害処理 /
-* Hurt the player with electricity
-* @param creature_ptr 電撃を浴びたキャラクタへの参照ポインタ
-* @param dam 基本ダメージ量
-* @param kb_str ダメージ原因記述
-* @param monspell 原因となったモンスター特殊攻撃ID
-* @param aura オーラよるダメージが原因ならばTRUE
-* @return 修正HPダメージ量
-*/
+ * @brief 電撃属性によるプレイヤー損害処理 /
+ * Hurt the player with electricity
+ * @param creature_ptr 電撃を浴びたキャラクタへの参照ポインタ
+ * @param dam 基本ダメージ量
+ * @param kb_str ダメージ原因記述
+ * @param monspell 原因となったモンスター特殊攻撃ID
+ * @param aura オーラよるダメージが原因ならばTRUE
+ * @return 修正HPダメージ量
+ */
HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
{
- HIT_POINT get_damage;
- int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
- bool double_resist = is_oppose_elec(creature_ptr);
-
- /* Total immunity */
- if (creature_ptr->immune_elec || (dam <= 0))
- {
- learn_spell(creature_ptr, monspell);
- return 0;
- }
-
- /* Vulnerability (Ouch!) */
- if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
- if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
- if (is_specific_player_race(creature_ptr, RACE_ANDROID)) dam += dam / 3;
-
- /* Resist the damage */
- if (creature_ptr->resist_elec) dam = (dam + 2) / 3;
- if (double_resist) dam = (dam + 2) / 3;
-
- if (aura || !check_multishadow(creature_ptr))
- {
- if ((!(double_resist || creature_ptr->resist_elec)) &&
- one_in_(HURT_CHANCE))
- (void)do_dec_stat(creature_ptr, A_DEX);
- }
-
- get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
-
- /* Inventory damage */
- if (!aura && !(double_resist && creature_ptr->resist_elec))
- inventory_damage(creature_ptr, set_elec_destroy, inv);
-
- return get_damage;
-}
+ HIT_POINT get_damage;
+ int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
+ bool double_resist = is_oppose_elec(creature_ptr);
+
+ /* Total immunity */
+ if (creature_ptr->immune_elec || (dam <= 0)) {
+ learn_spell(creature_ptr, monspell);
+ return 0;
+ }
+ /* Vulnerability (Ouch!) */
+ if (creature_ptr->muta3 & MUT3_VULN_ELEM)
+ dam *= 2;
+ if (creature_ptr->special_defense & KATA_KOUKIJIN)
+ dam += dam / 3;
+ if (is_specific_player_race(creature_ptr, RACE_ANDROID))
+ dam += dam / 3;
+
+ /* Resist the damage */
+ if (creature_ptr->resist_elec)
+ dam = (dam + 2) / 3;
+ if (double_resist)
+ dam = (dam + 2) / 3;
+
+ if (aura || !check_multishadow(creature_ptr)) {
+ if ((!(double_resist || creature_ptr->resist_elec)) && one_in_(HURT_CHANCE))
+ (void)do_dec_stat(creature_ptr, A_DEX);
+ }
+
+ get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+
+ /* Inventory damage */
+ if (!aura && !(double_resist && creature_ptr->resist_elec))
+ inventory_damage(creature_ptr, set_elec_destroy, inv);
+
+ return get_damage;
+}
/*!
-* @brief 火炎属性によるプレイヤー損害処理 /
-* Hurt the player with Fire
-* @param creature_ptr 火炎を浴びたキャラクタへの参照ポインタ
-* @param dam 基本ダメージ量
-* @param kb_str ダメージ原因記述
-* @param monspell 原因となったモンスター特殊攻撃ID
-* @param aura オーラよるダメージが原因ならばTRUE
-* @return 修正HPダメージ量
-*/
+ * @brief 火炎属性によるプレイヤー損害処理 /
+ * Hurt the player with Fire
+ * @param creature_ptr 火炎を浴びたキャラクタへの参照ポインタ
+ * @param dam 基本ダメージ量
+ * @param kb_str ダメージ原因記述
+ * @param monspell 原因となったモンスター特殊攻撃ID
+ * @param aura オーラよるダメージが原因ならばTRUE
+ * @return 修正HPダメージ量
+ */
HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
{
- HIT_POINT get_damage;
- int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
- bool double_resist = is_oppose_fire(creature_ptr);
-
- /* Totally immune */
- if (creature_ptr->immune_fire || (dam <= 0))
- {
- learn_spell(creature_ptr, monspell);
- return 0;
- }
-
- /* Vulnerability (Ouch!) */
- if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
- if (is_specific_player_race(creature_ptr, RACE_ENT)) dam += dam / 3;
- if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-
- /* Resist the damage */
- if (creature_ptr->resist_fire) dam = (dam + 2) / 3;
- if (double_resist) dam = (dam + 2) / 3;
-
- if (aura || !check_multishadow(creature_ptr))
- {
- if ((!(double_resist || creature_ptr->resist_fire)) &&
- one_in_(HURT_CHANCE))
- (void)do_dec_stat(creature_ptr, A_STR);
- }
-
- get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
-
- /* Inventory damage */
- if (!aura && !(double_resist && creature_ptr->resist_fire))
- inventory_damage(creature_ptr, set_fire_destroy, inv);
-
- return get_damage;
-}
+ HIT_POINT get_damage;
+ int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
+ bool double_resist = is_oppose_fire(creature_ptr);
+
+ /* Totally immune */
+ if (creature_ptr->immune_fire || (dam <= 0)) {
+ learn_spell(creature_ptr, monspell);
+ return 0;
+ }
+
+ /* Vulnerability (Ouch!) */
+ if (creature_ptr->muta3 & MUT3_VULN_ELEM)
+ dam *= 2;
+ if (is_specific_player_race(creature_ptr, RACE_ENT))
+ dam += dam / 3;
+ if (creature_ptr->special_defense & KATA_KOUKIJIN)
+ dam += dam / 3;
+
+ /* Resist the damage */
+ if (creature_ptr->resist_fire)
+ dam = (dam + 2) / 3;
+ if (double_resist)
+ dam = (dam + 2) / 3;
+
+ if (aura || !check_multishadow(creature_ptr)) {
+ if ((!(double_resist || creature_ptr->resist_fire)) && one_in_(HURT_CHANCE))
+ (void)do_dec_stat(creature_ptr, A_STR);
+ }
+
+ get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+ /* Inventory damage */
+ if (!aura && !(double_resist && creature_ptr->resist_fire))
+ inventory_damage(creature_ptr, set_fire_destroy, inv);
+
+ return get_damage;
+}
/*!
-* @brief 冷気属性によるプレイヤー損害処理 /
-* Hurt the player with Cold
-* @param creature_ptr 冷気を浴びたキャラクタへの参照ポインタ
-* @param dam 基本ダメージ量
-* @param kb_str ダメージ原因記述
-* @param monspell 原因となったモンスター特殊攻撃ID
-* @param aura オーラよるダメージが原因ならばTRUE
-* @return 修正HPダメージ量
-*/
+ * @brief 冷気属性によるプレイヤー損害処理 /
+ * Hurt the player with Cold
+ * @param creature_ptr 冷気を浴びたキャラクタへの参照ポインタ
+ * @param dam 基本ダメージ量
+ * @param kb_str ダメージ原因記述
+ * @param monspell 原因となったモンスター特殊攻撃ID
+ * @param aura オーラよるダメージが原因ならばTRUE
+ * @return 修正HPダメージ量
+ */
HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
{
- HIT_POINT get_damage;
- int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
- bool double_resist = is_oppose_cold(creature_ptr);
-
- /* Total immunity */
- if (creature_ptr->immune_cold || (dam <= 0))
- {
- learn_spell(creature_ptr, monspell);
- return 0;
- }
-
- /* Vulnerability (Ouch!) */
- if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
- if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-
- /* Resist the damage */
- if (creature_ptr->resist_cold) dam = (dam + 2) / 3;
- if (double_resist) dam = (dam + 2) / 3;
-
- if (aura || !check_multishadow(creature_ptr))
- {
- if ((!(double_resist || creature_ptr->resist_cold)) &&
- one_in_(HURT_CHANCE))
- (void)do_dec_stat(creature_ptr, A_STR);
- }
-
- get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
-
- /* Inventory damage */
- if (!aura && !(double_resist && creature_ptr->resist_cold))
- inventory_damage(creature_ptr, set_cold_destroy, inv);
-
- return get_damage;
-}
+ HIT_POINT get_damage;
+ int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
+ bool double_resist = is_oppose_cold(creature_ptr);
+
+ /* Total immunity */
+ if (creature_ptr->immune_cold || (dam <= 0)) {
+ learn_spell(creature_ptr, monspell);
+ return 0;
+ }
+ /* Vulnerability (Ouch!) */
+ if (creature_ptr->muta3 & MUT3_VULN_ELEM)
+ dam *= 2;
+ if (creature_ptr->special_defense & KATA_KOUKIJIN)
+ dam += dam / 3;
+
+ /* Resist the damage */
+ if (creature_ptr->resist_cold)
+ dam = (dam + 2) / 3;
+ if (double_resist)
+ dam = (dam + 2) / 3;
+
+ if (aura || !check_multishadow(creature_ptr)) {
+ if ((!(double_resist || creature_ptr->resist_cold)) && one_in_(HURT_CHANCE))
+ (void)do_dec_stat(creature_ptr, A_STR);
+ }
+
+ get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+
+ /* Inventory damage */
+ if (!aura && !(double_resist && creature_ptr->resist_cold))
+ inventory_damage(creature_ptr, set_cold_destroy, inv);
+
+ return get_damage;
+}
/*
* Decreases players hit points and sets death flag if necessary
*/
int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concptr hit_from, int monspell)
{
- int old_chp = creature_ptr->chp;
-
- char death_message[1024];
- char tmp[1024];
-
- int warning = (creature_ptr->mhp * hitpoint_warn / 10);
- if (creature_ptr->is_dead) return 0;
-
- if (creature_ptr->sutemi) damage *= 2;
- if (creature_ptr->special_defense & KATA_IAI) damage += (damage + 4) / 5;
-
- if (easy_band) damage = (damage + 1) / 2;
-
- if (damage_type != DAMAGE_USELIFE)
- {
- disturb(creature_ptr, TRUE, TRUE);
- if (auto_more)
- {
- creature_ptr->now_damaged = TRUE;
- }
- }
-
- if (monspell >= 0) learn_spell(creature_ptr, monspell);
-
- /* Mega-Hack -- Apply "invulnerability" */
- if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
- {
- if (is_invuln(creature_ptr) && (damage < 9000))
- {
- if (damage_type == DAMAGE_FORCE)
- {
- msg_print(_("バリアが切り裂かれた!", "The attack cuts your shield of invulnerability open!"));
- }
- else if (one_in_(PENETRATE_INVULNERABILITY))
- {
- msg_print(_("無敵のバリアを破って攻撃された!", "The attack penetrates your shield of invulnerability!"));
- }
- else
- {
- return 0;
- }
- }
-
- if (check_multishadow(creature_ptr))
- {
- if (damage_type == DAMAGE_FORCE)
- {
- msg_print(_("幻影もろとも体が切り裂かれた!", "The attack hits Shadow together with you!"));
- }
- else if (damage_type == DAMAGE_ATTACK)
- {
- msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
- return 0;
- }
- }
-
- if (creature_ptr->wraith_form)
- {
- if (damage_type == DAMAGE_FORCE)
- {
- msg_print(_("半物質の体が切り裂かれた!", "The attack cuts through your ethereal body!"));
- }
- else
- {
- damage /= 2;
- if ((damage == 0) && one_in_(2)) damage = 1;
- }
- }
-
- if (creature_ptr->special_defense & KATA_MUSOU)
- {
- damage /= 2;
- if ((damage == 0) && one_in_(2)) damage = 1;
- }
- } /* not if LOSELIFE USELIFE */
-
- /* Hurt the player */
- creature_ptr->chp -= damage;
- if (damage_type == DAMAGE_GENO && creature_ptr->chp < 0)
- {
- damage += creature_ptr->chp;
- creature_ptr->chp = 0;
- }
-
- /* Display the hitpoints */
- creature_ptr->redraw |= (PR_HP);
-
- creature_ptr->window |= (PW_PLAYER);
-
- if (damage_type != DAMAGE_GENO && creature_ptr->chp == 0)
- {
- chg_virtue(creature_ptr, V_SACRIFICE, 1);
- chg_virtue(creature_ptr, V_CHANCE, 2);
- }
-
- /* Dead player */
- if (creature_ptr->chp < 0)
- {
- bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
+ int old_chp = creature_ptr->chp;
+
+ char death_message[1024];
+ char tmp[1024];
+
+ int warning = (creature_ptr->mhp * hitpoint_warn / 10);
+ if (creature_ptr->is_dead)
+ return 0;
+
+ if (creature_ptr->sutemi)
+ damage *= 2;
+ if (creature_ptr->special_defense & KATA_IAI)
+ damage += (damage + 4) / 5;
+
+ if (easy_band)
+ damage = (damage + 1) / 2;
+
+ if (damage_type != DAMAGE_USELIFE) {
+ disturb(creature_ptr, TRUE, TRUE);
+ if (auto_more) {
+ creature_ptr->now_damaged = TRUE;
+ }
+ }
+
+ if (monspell >= 0)
+ learn_spell(creature_ptr, monspell);
+
+ /* Mega-Hack -- Apply "invulnerability" */
+ if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE)) {
+ if (is_invuln(creature_ptr) && (damage < 9000)) {
+ if (damage_type == DAMAGE_FORCE) {
+ msg_print(_("バリアが切り裂かれた!", "The attack cuts your shield of invulnerability open!"));
+ } else if (one_in_(PENETRATE_INVULNERABILITY)) {
+ msg_print(_("無敵のバリアを破って攻撃された!", "The attack penetrates your shield of invulnerability!"));
+ } else {
+ return 0;
+ }
+ }
+
+ if (check_multishadow(creature_ptr)) {
+ if (damage_type == DAMAGE_FORCE) {
+ msg_print(_("幻影もろとも体が切り裂かれた!", "The attack hits Shadow together with you!"));
+ } else if (damage_type == DAMAGE_ATTACK) {
+ msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
+ return 0;
+ }
+ }
+
+ if (creature_ptr->wraith_form) {
+ if (damage_type == DAMAGE_FORCE) {
+ msg_print(_("半物質の体が切り裂かれた!", "The attack cuts through your ethereal body!"));
+ } else {
+ damage /= 2;
+ if ((damage == 0) && one_in_(2))
+ damage = 1;
+ }
+ }
+
+ if (creature_ptr->special_defense & KATA_MUSOU) {
+ damage /= 2;
+ if ((damage == 0) && one_in_(2))
+ damage = 1;
+ }
+ } /* not if LOSELIFE USELIFE */
+
+ /* Hurt the player */
+ creature_ptr->chp -= damage;
+ if (damage_type == DAMAGE_GENO && creature_ptr->chp < 0) {
+ damage += creature_ptr->chp;
+ creature_ptr->chp = 0;
+ }
+
+ /* Display the hitpoints */
+ creature_ptr->redraw |= (PR_HP);
+
+ creature_ptr->window |= (PW_PLAYER);
+
+ if (damage_type != DAMAGE_GENO && creature_ptr->chp == 0) {
+ chg_virtue(creature_ptr, V_SACRIFICE, 1);
+ chg_virtue(creature_ptr, V_CHANCE, 2);
+ }
+
+ /* Dead player */
+ if (creature_ptr->chp < 0) {
+ bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
#ifdef JP
- /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
- if (!cheat_save)
- if (!save_player(creature_ptr)) msg_print("セーブ失敗!");
+ /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
+ if (!cheat_save)
+ if (!save_player(creature_ptr))
+ msg_print("セーブ失敗!");
#endif
- sound(SOUND_DEATH);
+ sound(SOUND_DEATH);
- chg_virtue(creature_ptr, V_SACRIFICE, 10);
+ chg_virtue(creature_ptr, V_SACRIFICE, 10);
- handle_stuff(creature_ptr);
- creature_ptr->leaving = TRUE;
+ handle_stuff(creature_ptr);
+ creature_ptr->leaving = TRUE;
- /* Note death */
- creature_ptr->is_dead = TRUE;
+ /* Note death */
+ creature_ptr->is_dead = TRUE;
- if (creature_ptr->current_floor_ptr->inside_arena)
- {
- concptr m_name = r_name + r_info[arena_info[creature_ptr->arena_number].r_idx].name;
- msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name);
- msg_print(NULL);
- if (record_arena) exe_write_diary(creature_ptr, DIARY_ARENA, -1 - creature_ptr->arena_number, m_name);
- }
- else
- {
- QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level);
- bool seppuku = streq(hit_from, "Seppuku");
- bool winning_seppuku = current_world_ptr->total_winner && seppuku;
+ if (creature_ptr->current_floor_ptr->inside_arena) {
+ concptr m_name = r_name + r_info[arena_info[creature_ptr->arena_number].r_idx].name;
+ msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name);
+ msg_print(NULL);
+ if (record_arena)
+ exe_write_diary(creature_ptr, DIARY_ARENA, -1 - creature_ptr->arena_number, m_name);
+ } else {
+ QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level);
+ bool seppuku = streq(hit_from, "Seppuku");
+ bool winning_seppuku = current_world_ptr->total_winner && seppuku;
- play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
+ play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
#ifdef WORLD_SCORE
- /* Make screen dump */
- screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
+ /* Make screen dump */
+ screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
#endif
- /* Note cause of death */
- if (seppuku)
- {
- strcpy(creature_ptr->died_from, hit_from);
+ /* Note cause of death */
+ if (seppuku) {
+ strcpy(creature_ptr->died_from, hit_from);
#ifdef JP
- if (!winning_seppuku) strcpy(creature_ptr->died_from, "切腹");
+ if (!winning_seppuku)
+ strcpy(creature_ptr->died_from, "切腹");
#endif
- }
- else
- {
- char dummy[1024];
+ } else {
+ char dummy[1024];
#ifdef JP
- sprintf(dummy, "%s%s%s", !creature_ptr->paralyzed ? "" : creature_ptr->free_act ? "彫像状態で" : "麻痺状態で", creature_ptr->image ? "幻覚に歪んだ" : "", hit_from);
+ sprintf(dummy, "%s%s%s", !creature_ptr->paralyzed ? "" : creature_ptr->free_act ? "彫像状態で" : "麻痺状態で",
+ creature_ptr->image ? "幻覚に歪んだ" : "", hit_from);
#else
- sprintf(dummy, "%s%s", hit_from, !creature_ptr->paralyzed ? "" : " while helpless");
+ sprintf(dummy, "%s%s", hit_from, !creature_ptr->paralyzed ? "" : " while helpless");
#endif
- angband_strcpy(creature_ptr->died_from, dummy, sizeof creature_ptr->died_from);
- }
-
- /* No longer a winner */
- current_world_ptr->total_winner = FALSE;
-
- if (winning_seppuku)
- {
- exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
- }
- else
- {
- char buf[20];
-
- if (creature_ptr->current_floor_ptr->inside_arena)
- strcpy(buf, _("アリーナ", "in the Arena"));
- else if (!creature_ptr->current_floor_ptr->dun_level)
- strcpy(buf, _("地上", "on the surface"));
- else if (q_idx && (is_fixed_quest_idx(q_idx) &&
- !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
- strcpy(buf, _("クエスト", "in a quest"));
- else
- sprintf(buf, _("%d階", "level %d"), (int)creature_ptr->current_floor_ptr->dun_level);
-
- sprintf(tmp, _("%sで%sに殺された。", "killed by %s %s."), buf, creature_ptr->died_from);
- exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
- }
-
- exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
- exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
-
- flush();
-
- if (get_check_strict(creature_ptr, _("画面を保存しますか?", "Dump the screen? "), CHECK_NO_HISTORY))
- {
- do_cmd_save_screen(creature_ptr, process_autopick_file_command);
- }
-
- flush();
-
- /* Initialize "last message" buffer */
- if (creature_ptr->last_message) string_free(creature_ptr->last_message);
- creature_ptr->last_message = NULL;
-
- /* Hack -- Note death */
- if (!last_words)
- {
+ angband_strcpy(creature_ptr->died_from, dummy, sizeof creature_ptr->died_from);
+ }
+
+ /* No longer a winner */
+ current_world_ptr->total_winner = FALSE;
+
+ if (winning_seppuku) {
+ exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
+ } else {
+ char buf[20];
+
+ if (creature_ptr->current_floor_ptr->inside_arena)
+ strcpy(buf, _("アリーナ", "in the Arena"));
+ else if (!creature_ptr->current_floor_ptr->dun_level)
+ strcpy(buf, _("地上", "on the surface"));
+ else if (q_idx && (is_fixed_quest_idx(q_idx) && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
+ strcpy(buf, _("クエスト", "in a quest"));
+ else
+ sprintf(buf, _("%d階", "level %d"), (int)creature_ptr->current_floor_ptr->dun_level);
+
+ sprintf(tmp, _("%sで%sに殺された。", "killed by %s %s."), buf, creature_ptr->died_from);
+ exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
+ }
+
+ exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
+ exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
+
+ flush();
+
+ if (get_check_strict(creature_ptr, _("画面を保存しますか?", "Dump the screen? "), CHECK_NO_HISTORY)) {
+ do_cmd_save_screen(creature_ptr, process_autopick_file_command);
+ }
+
+ flush();
+
+ /* Initialize "last message" buffer */
+ if (creature_ptr->last_message)
+ string_free(creature_ptr->last_message);
+ creature_ptr->last_message = NULL;
+
+ /* Hack -- Note death */
+ if (!last_words) {
#ifdef JP
- msg_format("あなたは%sました。", android ? "壊れ" : "死に");
+ msg_format("あなたは%sました。", android ? "壊れ" : "死に");
#else
- msg_print(android ? "You are broken." : "You die.");
+ msg_print(android ? "You are broken." : "You die.");
#endif
- msg_print(NULL);
- }
- else
- {
- if (winning_seppuku)
- {
- get_rnd_line(_("seppuku_j.txt", "seppuku.txt"), 0, death_message);
- }
- else
- {
- get_rnd_line(_("death_j.txt", "death.txt"), 0, death_message);
- }
-
- do
- {
+ msg_print(NULL);
+ } else {
+ if (winning_seppuku) {
+ get_rnd_line(_("seppuku_j.txt", "seppuku.txt"), 0, death_message);
+ } else {
+ get_rnd_line(_("death_j.txt", "death.txt"), 0, death_message);
+ }
+
+ do {
#ifdef JP
- while (!get_string(winning_seppuku ? "辞世の句: " : "断末魔の叫び: ", death_message, 1024));
+ while (!get_string(winning_seppuku ? "辞世の句: " : "断末魔の叫び: ", death_message, 1024))
+ ;
#else
- while (!get_string("Last word: ", death_message, 1024));
+ while (!get_string("Last word: ", death_message, 1024))
+ ;
#endif
- } while (winning_seppuku && !get_check_strict(creature_ptr, _("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
+ } while (winning_seppuku && !get_check_strict(creature_ptr, _("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
- if (death_message[0] == '\0')
- {
+ if (death_message[0] == '\0') {
#ifdef JP
- strcpy(death_message, format("あなたは%sました。", android ? "壊れ" : "死に"));
+ strcpy(death_message, format("あなたは%sました。", android ? "壊れ" : "死に"));
#else
- strcpy(death_message, android ? "You are broken." : "You die.");
+ strcpy(death_message, android ? "You are broken." : "You die.");
#endif
- }
- else creature_ptr->last_message = string_make(death_message);
+ } else
+ creature_ptr->last_message = string_make(death_message);
#ifdef JP
- if (winning_seppuku)
- {
- int i, len;
- int w = Term->wid;
- int h = Term->hgt;
- int msg_pos_x[9] = { 5, 7, 9, 12, 14, 17, 19, 21, 23 };
- int msg_pos_y[9] = { 3, 4, 5, 4, 5, 4, 5, 6, 4 };
- concptr str;
- char* str2;
-
- Term_clear();
-
- /* 桜散る */
- for (i = 0; i < 40; i++)
- Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "υ");
-
- str = death_message;
- if (strncmp(str, "「", 2) == 0) str += 2;
-
- str2 = angband_strstr(str, "」");
- if (str2 != NULL) *str2 = '\0';
-
- i = 0;
- while (i < 9)
- {
- str2 = angband_strstr(str, " ");
- if (str2 == NULL) len = strlen(str);
- else len = str2 - str;
-
- if (len != 0)
- {
- Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
- TERM_WHITE, str);
- if (str2 == NULL) break;
- i++;
- }
- str = str2 + 1;
- if (*str == 0) break;
- }
-
- /* Hide cursor */
- Term_putstr(w - 1, h - 1, 1, TERM_WHITE, " ");
-
- flush();
+ if (winning_seppuku) {
+ int i, len;
+ int w = Term->wid;
+ int h = Term->hgt;
+ int msg_pos_x[9] = { 5, 7, 9, 12, 14, 17, 19, 21, 23 };
+ int msg_pos_y[9] = { 3, 4, 5, 4, 5, 4, 5, 6, 4 };
+ concptr str;
+ char *str2;
+
+ Term_clear();
+
+ /* 桜散る */
+ for (i = 0; i < 40; i++)
+ Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "υ");
+
+ str = death_message;
+ if (strncmp(str, "「", 2) == 0)
+ str += 2;
+
+ str2 = angband_strstr(str, "」");
+ if (str2 != NULL)
+ *str2 = '\0';
+
+ i = 0;
+ while (i < 9) {
+ str2 = angband_strstr(str, " ");
+ if (str2 == NULL)
+ len = strlen(str);
+ else
+ len = str2 - str;
+
+ if (len != 0) {
+ Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len, TERM_WHITE, str);
+ if (str2 == NULL)
+ break;
+ i++;
+ }
+ str = str2 + 1;
+ if (*str == 0)
+ break;
+ }
+
+ /* Hide cursor */
+ Term_putstr(w - 1, h - 1, 1, TERM_WHITE, " ");
+
+ flush();
#ifdef WORLD_SCORE
- /* Make screen dump */
- screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
+ /* Make screen dump */
+ screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
#endif
- /* Wait a key press */
- (void)inkey();
- }
- else
+ /* Wait a key press */
+ (void)inkey();
+ } else
#endif
- msg_print(death_message);
- }
- }
-
- /* Dead */
- return damage;
- }
-
- handle_stuff(creature_ptr);
-
- /* Hitpoint warning */
- if (creature_ptr->chp < warning)
- {
- /* Hack -- bell on first notice */
- if (old_chp > warning) bell();
-
- sound(SOUND_WARN);
-
- if (record_danger && (old_chp > warning))
- {
- if (creature_ptr->image && damage_type == DAMAGE_ATTACK)
- hit_from = _("何か", "something");
-
- sprintf(tmp, _("%sによってピンチに陥った。", "was in a critical situation because of %s."), hit_from);
- exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
- }
-
- if (auto_more)
- {
- /* stop auto_more even if DAMAGE_USELIFE */
- creature_ptr->now_damaged = TRUE;
- }
-
- msg_print(_("*** 警告:低ヒット・ポイント! ***", "*** LOW HITPOINT WARNING! ***"));
- msg_print(NULL);
- flush();
- }
- if (creature_ptr->wild_mode && !creature_ptr->leaving && (creature_ptr->chp < MAX(warning, creature_ptr->mhp / 5)))
- {
- change_wild_mode(creature_ptr, FALSE);
- }
- return damage;
+ msg_print(death_message);
+ }
+ }
+
+ /* Dead */
+ return damage;
+ }
+
+ handle_stuff(creature_ptr);
+
+ /* Hitpoint warning */
+ if (creature_ptr->chp < warning) {
+ /* Hack -- bell on first notice */
+ if (old_chp > warning)
+ bell();
+
+ sound(SOUND_WARN);
+
+ if (record_danger && (old_chp > warning)) {
+ if (creature_ptr->image && damage_type == DAMAGE_ATTACK)
+ hit_from = _("何か", "something");
+
+ sprintf(tmp, _("%sによってピンチに陥った。", "was in a critical situation because of %s."), hit_from);
+ exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
+ }
+
+ if (auto_more) {
+ /* stop auto_more even if DAMAGE_USELIFE */
+ creature_ptr->now_damaged = TRUE;
+ }
+
+ msg_print(_("*** 警告:低ヒット・ポイント! ***", "*** LOW HITPOINT WARNING! ***"));
+ msg_print(NULL);
+ flush();
+ }
+ if (creature_ptr->wild_mode && !creature_ptr->leaving && (creature_ptr->chp < MAX(warning, creature_ptr->mhp / 5))) {
+ change_wild_mode(creature_ptr, FALSE);
+ }
+ return damage;
}
/*!
-* @brief 属性に応じた敵オーラによるプレイヤーのダメージ処理
-* @param m_ptr オーラを持つモンスターの構造体参照ポインタ
-* @param immune ダメージを回避できる免疫フラグ
-* @param flags_offset オーラフラグ配列の参照オフセット
-* @param r_flags_offset モンスターの耐性配列の参照オフセット
-* @param aura_flag オーラフラグ配列
-* @param dam_func ダメージ処理を行う関数の参照ポインタ
-* @param message オーラダメージを受けた際のメッセージ
-* @return なし
-*/
+ * @brief 属性に応じた敵オーラによるプレイヤーのダメージ処理
+ * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
+ * @param immune ダメージを回避できる免疫フラグ
+ * @param flags_offset オーラフラグ配列の参照オフセット
+ * @param r_flags_offset モンスターの耐性配列の参照オフセット
+ * @param aura_flag オーラフラグ配列
+ * @param dam_func ダメージ処理を行う関数の参照ポインタ
+ * @param message オーラダメージを受けた際のメッセージ
+ * @return なし
+ */
static void process_aura_damage(monster_type *m_ptr, player_type *touched_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
HIT_POINT (*dam_func)(player_type *creature_type, HIT_POINT dam, concptr kb_str, int monspell, bool aura), concptr message)
{
}
/*!
-* @brief 敵オーラによるプレイヤーのダメージ処理
-* @param m_ptr オーラを持つモンスターの構造体参照ポインタ
-* @param touched_ptr オーラを持つ相手に振れたクリーチャーの参照ポインタ
-* @return なし
-*/
+ * @brief 敵オーラによるプレイヤーのダメージ処理
+ * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
+ * @param touched_ptr オーラを持つ相手に振れたクリーチャーの参照ポインタ
+ * @return なし
+ */
void touch_zap_player(monster_type *m_ptr, player_type *touched_ptr)
{
- process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
- fire_dam, _("突然とても熱くなった!", "You are suddenly very hot!"));
- process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
- cold_dam, _("突然とても寒くなった!", "You are suddenly very cold!"));
- process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
- elec_dam, _("電撃をくらった!", "You get zapped!"));
+ process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE, fire_dam,
+ _("突然とても熱くなった!", "You are suddenly very hot!"));
+ process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD, cold_dam,
+ _("突然とても寒くなった!", "You are suddenly very cold!"));
+ process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC, elec_dam,
+ _("電撃をくらった!", "You get zapped!"));
}
* are included in all such copies. Other copyrights may also apply.
*/
-#include "io/load.h"
+#include "savedata/load.h"
#include "art-definition/art-accessory-types.h"
#include "birth/quick-start.h"
#include "cmd-building/cmd-building.h"
#include "info-reader/fixed-map-parser.h"
#include "inventory/inventory-slot-types.h"
#include "io/report.h"
-#include "io/save.h"
#include "io/uid-checker.h"
#include "locale/japanese.h"
#include "market/arena.h"
#include "player/player-skill.h"
#include "player/race-info-table.h"
#include "player/special-defense-types.h"
+#include "savedata/save.h"
#include "spell/spells-status.h"
#include "store/store-util.h"
#include "store/store.h"
--- /dev/null
+/*!
+ * @file save.c
+ * @brief セーブファイル書き込み処理 / Purpose: interact with savefiles
+ * @date 2014/07/12
+ * @author
+ * <pre>
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies. Other copyrights may also apply.
+ * </pre>
+ */
+
+#include "savedata/save.h"
+#include "birth/quick-start.h"
+#include "cmd-building/cmd-building.h"
+#include "dungeon/dungeon.h"
+#include "dungeon/quest.h"
+#include "floor/floor-events.h"
+#include "floor/floor-town.h"
+#include "floor/floor.h"
+#include "floor/wild.h"
+#include "game-option/birth-options.h"
+#include "game-option/cheat-options.h"
+#include "game-option/option-flags.h"
+#include "game-option/option-types-table.h"
+#include "game-option/runtime-arguments.h"
+#include "game-option/special-options.h"
+#include "game-option/text-display-options.h"
+#include "grid/grid.h"
+#include "inventory/inventory-slot-types.h"
+#include "io/report.h"
+#include "io/uid-checker.h"
+#include "monster-race/monster-race.h"
+#include "monster/monster-compaction.h"
+#include "monster/monster-info.h"
+#include "monster/monster-status.h"
+#include "object-enchant/artifact.h"
+#include "object/object-kind.h"
+#include "savedata/load.h"
+#include "store/store-util.h"
+#include "store/store.h"
+#include "system/angband-version.h"
+#include "util/angband-files.h"
+#include "util/quarks.h"
+#include "util/sort.h"
+#include "view/display-messages.h"
+#include "world/world.h"
+
+/*
+ * Some "local" parameters, used to help write savefiles
+ */
+
+static FILE *fff; /* Current save "file" */
+static byte xor_byte; /* Simple encryption */
+static u32b v_stamp = 0L; /* A simple "checksum" on the actual values */
+static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */
+
+/*!
+ * @brief 1バイトをファイルに書き込む / These functions place information into a savefile a byte at a time
+ * @param v 書き込むバイト値
+ * @return なし
+ */
+static void sf_put(byte v)
+{
+ /* Encode the value, write a character */
+ xor_byte ^= v;
+ (void)putc((int)xor_byte, fff);
+
+ /* Maintain the checksum info */
+ v_stamp += v;
+ x_stamp += xor_byte;
+}
+
+/*!
+ * @brief 1バイトをファイルに書き込む(sf_put()の糖衣)
+ * @param v 書き込むバイト
+ * @return なし
+ */
+static void wr_byte(byte v) { sf_put(v); }
+
+/*!
+ * @brief 符号なし16ビットをファイルに書き込む
+ * @param v 書き込む符号なし16bit値
+ * @return なし
+ */
+static void wr_u16b(u16b v)
+{
+ sf_put((byte)(v & 0xFF));
+ sf_put((byte)((v >> 8) & 0xFF));
+}
+
+/*!
+ * @brief 符号あり16ビットをファイルに書き込む
+ * @param v 書き込む符号あり16bit値
+ * @return なし
+ */
+static void wr_s16b(s16b v) { wr_u16b((u16b)v); }
+
+/*!
+ * @brief 符号なし32ビットをファイルに書き込む
+ * @param v 書き込む符号なし32bit値
+ * @return なし
+ */
+static void wr_u32b(u32b v)
+{
+ sf_put((byte)(v & 0xFF));
+ sf_put((byte)((v >> 8) & 0xFF));
+ sf_put((byte)((v >> 16) & 0xFF));
+ sf_put((byte)((v >> 24) & 0xFF));
+}
+
+/*!
+ * @brief 符号あり32ビットをファイルに書き込む
+ * @param v 書き込む符号あり32bit値
+ * @return なし
+ */
+static void wr_s32b(s32b v) { wr_u32b((u32b)v); }
+
+/*!
+ * @brief 文字列をファイルに書き込む
+ * @param str 書き込む文字列
+ * @return なし
+ */
+static void wr_string(concptr str)
+{
+ while (*str) {
+ wr_byte(*str);
+ str++;
+ }
+ wr_byte(*str);
+}
+
+/*
+ * These functions write info in larger logical records
+ */
+
+/*!
+ * @brief アイテムオブジェクトを書き込む / Write an "item" record
+ * @param o_ptr アイテムオブジェクト保存元ポインタ
+ * @return なし
+ */
+static void wr_item(object_type *o_ptr)
+{
+ BIT_FLAGS flags = 0x00000000;
+
+ if (o_ptr->pval)
+ flags |= SAVE_ITEM_PVAL;
+ if (o_ptr->discount)
+ flags |= SAVE_ITEM_DISCOUNT;
+ if (o_ptr->number != 1)
+ flags |= SAVE_ITEM_NUMBER;
+ if (o_ptr->name1)
+ flags |= SAVE_ITEM_NAME1;
+ if (o_ptr->name2)
+ flags |= SAVE_ITEM_NAME2;
+ if (o_ptr->timeout)
+ flags |= SAVE_ITEM_TIMEOUT;
+ if (o_ptr->to_h)
+ flags |= SAVE_ITEM_TO_H;
+ if (o_ptr->to_d)
+ flags |= SAVE_ITEM_TO_D;
+ if (o_ptr->to_a)
+ flags |= SAVE_ITEM_TO_A;
+ if (o_ptr->ac)
+ flags |= SAVE_ITEM_AC;
+ if (o_ptr->dd)
+ flags |= SAVE_ITEM_DD;
+ if (o_ptr->ds)
+ flags |= SAVE_ITEM_DS;
+ if (o_ptr->ident)
+ flags |= SAVE_ITEM_IDENT;
+ if (o_ptr->marked)
+ flags |= SAVE_ITEM_MARKED;
+ if (o_ptr->art_flags[0])
+ flags |= SAVE_ITEM_ART_FLAGS0;
+ if (o_ptr->art_flags[1])
+ flags |= SAVE_ITEM_ART_FLAGS1;
+ if (o_ptr->art_flags[2])
+ flags |= SAVE_ITEM_ART_FLAGS2;
+ if (o_ptr->art_flags[3])
+ flags |= SAVE_ITEM_ART_FLAGS3;
+ if (o_ptr->art_flags[4])
+ flags |= SAVE_ITEM_ART_FLAGS4;
+ if (o_ptr->curse_flags)
+ flags |= SAVE_ITEM_CURSE_FLAGS;
+ if (o_ptr->held_m_idx)
+ flags |= SAVE_ITEM_HELD_M_IDX;
+ if (o_ptr->xtra1)
+ flags |= SAVE_ITEM_XTRA1;
+ if (o_ptr->xtra2)
+ flags |= SAVE_ITEM_XTRA2;
+ if (o_ptr->xtra3)
+ flags |= SAVE_ITEM_XTRA3;
+ if (o_ptr->xtra4)
+ flags |= SAVE_ITEM_XTRA4;
+ if (o_ptr->xtra5)
+ flags |= SAVE_ITEM_XTRA5;
+ if (o_ptr->feeling)
+ flags |= SAVE_ITEM_FEELING;
+ if (o_ptr->inscription)
+ flags |= SAVE_ITEM_INSCRIPTION;
+ if (o_ptr->art_name)
+ flags |= SAVE_ITEM_ART_NAME;
+
+ /*** Item save flags ***/
+ wr_u32b(flags);
+
+ /*** Write only un-obvious elements ***/
+ wr_s16b(o_ptr->k_idx);
+
+ wr_byte((byte)o_ptr->iy);
+ wr_byte((byte)o_ptr->ix);
+
+ if (flags & SAVE_ITEM_PVAL)
+ wr_s16b(o_ptr->pval);
+
+ if (flags & SAVE_ITEM_DISCOUNT)
+ wr_byte(o_ptr->discount);
+ if (flags & SAVE_ITEM_NUMBER)
+ wr_byte((byte)o_ptr->number);
+
+ wr_s16b((s16b)o_ptr->weight);
+
+ if (flags & SAVE_ITEM_NAME1)
+ wr_byte((byte)o_ptr->name1);
+ if (flags & SAVE_ITEM_NAME2)
+ wr_byte((byte)o_ptr->name2);
+ if (flags & SAVE_ITEM_TIMEOUT)
+ wr_s16b(o_ptr->timeout);
+
+ if (flags & SAVE_ITEM_TO_H)
+ wr_s16b(o_ptr->to_h);
+ if (flags & SAVE_ITEM_TO_D)
+ wr_s16b((s16b)o_ptr->to_d);
+ if (flags & SAVE_ITEM_TO_A)
+ wr_s16b(o_ptr->to_a);
+ if (flags & SAVE_ITEM_AC)
+ wr_s16b(o_ptr->ac);
+ if (flags & SAVE_ITEM_DD)
+ wr_byte((byte)o_ptr->dd);
+ if (flags & SAVE_ITEM_DS)
+ wr_byte((byte)o_ptr->ds);
+
+ if (flags & SAVE_ITEM_IDENT)
+ wr_byte(o_ptr->ident);
+
+ if (flags & SAVE_ITEM_MARKED)
+ wr_byte(o_ptr->marked);
+
+ if (flags & SAVE_ITEM_ART_FLAGS0)
+ wr_u32b(o_ptr->art_flags[0]);
+ if (flags & SAVE_ITEM_ART_FLAGS1)
+ wr_u32b(o_ptr->art_flags[1]);
+ if (flags & SAVE_ITEM_ART_FLAGS2)
+ wr_u32b(o_ptr->art_flags[2]);
+ if (flags & SAVE_ITEM_ART_FLAGS3)
+ wr_u32b(o_ptr->art_flags[3]);
+ if (flags & SAVE_ITEM_ART_FLAGS4)
+ wr_u32b(o_ptr->art_flags[4]);
+
+ if (flags & SAVE_ITEM_CURSE_FLAGS)
+ wr_u32b(o_ptr->curse_flags);
+
+ /* Held by monster index */
+ if (flags & SAVE_ITEM_HELD_M_IDX)
+ wr_s16b(o_ptr->held_m_idx);
+
+ /* Extra information */
+ if (flags & SAVE_ITEM_XTRA1)
+ wr_byte(o_ptr->xtra1);
+ if (flags & SAVE_ITEM_XTRA2)
+ wr_byte(o_ptr->xtra2);
+ if (flags & SAVE_ITEM_XTRA3)
+ wr_byte(o_ptr->xtra3);
+ if (flags & SAVE_ITEM_XTRA4)
+ wr_s16b(o_ptr->xtra4);
+ if (flags & SAVE_ITEM_XTRA5)
+ wr_s16b(o_ptr->xtra5);
+
+ /* Feelings */
+ if (flags & SAVE_ITEM_FEELING)
+ wr_byte(o_ptr->feeling);
+
+ if (flags & SAVE_ITEM_INSCRIPTION)
+ wr_string(quark_str(o_ptr->inscription));
+ if (flags & SAVE_ITEM_ART_NAME)
+ wr_string(quark_str(o_ptr->art_name));
+}
+
+/*!
+ * @brief モンスター情報を書き込む / Write a "monster" record
+ * @param m_ptr モンスター情報保存元ポインタ
+ * @return なし
+ */
+static void wr_monster(monster_type *m_ptr)
+{
+ BIT_FLAGS flags = 0x00000000;
+ if (!is_original_ap(m_ptr))
+ flags |= SAVE_MON_AP_R_IDX;
+ if (m_ptr->sub_align)
+ flags |= SAVE_MON_SUB_ALIGN;
+ if (monster_csleep_remaining(m_ptr))
+ flags |= SAVE_MON_CSLEEP;
+ if (monster_fast_remaining(m_ptr))
+ flags |= SAVE_MON_FAST;
+ if (monster_slow_remaining(m_ptr))
+ flags |= SAVE_MON_SLOW;
+ if (monster_stunned_remaining(m_ptr))
+ flags |= SAVE_MON_STUNNED;
+ if (monster_confused_remaining(m_ptr))
+ flags |= SAVE_MON_CONFUSED;
+ if (monster_fear_remaining(m_ptr))
+ flags |= SAVE_MON_MONFEAR;
+ if (m_ptr->target_y)
+ flags |= SAVE_MON_TARGET_Y;
+ if (m_ptr->target_x)
+ flags |= SAVE_MON_TARGET_X;
+ if (monster_invulner_remaining(m_ptr))
+ flags |= SAVE_MON_INVULNER;
+ if (m_ptr->smart)
+ flags |= SAVE_MON_SMART;
+ if (m_ptr->exp)
+ flags |= SAVE_MON_EXP;
+ if (m_ptr->mflag2)
+ flags |= SAVE_MON_MFLAG2;
+ if (m_ptr->nickname)
+ flags |= SAVE_MON_NICKNAME;
+ if (m_ptr->parent_m_idx)
+ flags |= SAVE_MON_PARENT;
+
+ /*** Monster save flags ***/
+ wr_u32b(flags);
+
+ /*** Write only un-obvious elements ***/
+ wr_s16b(m_ptr->r_idx);
+ wr_byte((byte)m_ptr->fy);
+ wr_byte((byte)m_ptr->fx);
+ wr_s16b((s16b)m_ptr->hp);
+ wr_s16b((s16b)m_ptr->maxhp);
+ wr_s16b((s16b)m_ptr->max_maxhp);
+ wr_u32b(m_ptr->dealt_damage);
+
+ /* Monster race index of its appearance */
+ if (flags & SAVE_MON_AP_R_IDX)
+ wr_s16b(m_ptr->ap_r_idx);
+
+ if (flags & SAVE_MON_SUB_ALIGN)
+ wr_byte(m_ptr->sub_align);
+ if (flags & SAVE_MON_CSLEEP)
+ wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]);
+
+ wr_byte((byte)m_ptr->mspeed);
+ wr_s16b(m_ptr->energy_need);
+
+ byte tmp8u;
+ if (flags & SAVE_MON_FAST) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_FAST];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_SLOW) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_SLOW];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_STUNNED) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_STUNNED];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_CONFUSED) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_CONFUSED];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_MONFEAR) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_MONFEAR];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_TARGET_Y)
+ wr_s16b((s16b)m_ptr->target_y);
+ if (flags & SAVE_MON_TARGET_X)
+ wr_s16b((s16b)m_ptr->target_x);
+ if (flags & SAVE_MON_INVULNER) {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_INVULNER];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_SMART)
+ wr_u32b(m_ptr->smart);
+ if (flags & SAVE_MON_EXP)
+ wr_u32b(m_ptr->exp);
+ if (flags & SAVE_MON_MFLAG2)
+ wr_byte(m_ptr->mflag2);
+ if (flags & SAVE_MON_NICKNAME)
+ wr_string(quark_str(m_ptr->nickname));
+ if (flags & SAVE_MON_PARENT)
+ wr_s16b(m_ptr->parent_m_idx);
+}
+
+/*!
+ * @brief モンスターの思い出を書き込む / Write a "lore" record
+ * @param r_idx モンスター種族ID
+ * @return なし
+ */
+static void wr_lore(MONRACE_IDX r_idx)
+{
+ /* Count sights/deaths/kills */
+ monster_race *r_ptr = &r_info[r_idx];
+ wr_s16b((s16b)r_ptr->r_sights);
+ wr_s16b((s16b)r_ptr->r_deaths);
+ wr_s16b((s16b)r_ptr->r_pkills);
+ wr_s16b((s16b)r_ptr->r_akills);
+ wr_s16b((s16b)r_ptr->r_tkills);
+
+ /* Count wakes and ignores */
+ wr_byte(r_ptr->r_wake);
+ wr_byte(r_ptr->r_ignore);
+
+ /* Extra stuff */
+ wr_byte(r_ptr->r_xtra1);
+ wr_byte(r_ptr->r_xtra2);
+
+ /* Count drops */
+ wr_byte((byte)r_ptr->r_drop_gold);
+ wr_byte((byte)r_ptr->r_drop_item);
+
+ /* Count spells */
+ wr_byte(0); /* unused now */
+ wr_byte(r_ptr->r_cast_spell);
+
+ /* Count blows of each type */
+ wr_byte(r_ptr->r_blows[0]);
+ wr_byte(r_ptr->r_blows[1]);
+ wr_byte(r_ptr->r_blows[2]);
+ wr_byte(r_ptr->r_blows[3]);
+
+ /* Memorize flags */
+ wr_u32b(r_ptr->r_flags1);
+ wr_u32b(r_ptr->r_flags2);
+ wr_u32b(r_ptr->r_flags3);
+ wr_u32b(r_ptr->r_flags4);
+ wr_u32b(r_ptr->r_flags5);
+ wr_u32b(r_ptr->r_flags6);
+ wr_u32b(r_ptr->r_flagsr);
+
+ /* Monster limit per level */
+ wr_byte((byte)r_ptr->max_num);
+
+ /* Location in saved floor */
+ wr_s16b(r_ptr->floor_id);
+
+ wr_byte(0);
+}
+
+/*!
+ * @brief その他のゲーム情報を書き込む(実質はアイテムの鑑定情報のみ) / Write an "xtra" record
+ * @param k_idx ベースアイテムのID
+ * @return なし
+ */
+static void wr_xtra(KIND_OBJECT_IDX k_idx)
+{
+ byte tmp8u = 0;
+
+ object_kind *k_ptr = &k_info[k_idx];
+
+ if (k_ptr->aware)
+ tmp8u |= 0x01;
+ if (k_ptr->tried)
+ tmp8u |= 0x02;
+
+ wr_byte(tmp8u);
+}
+
+/*!
+ * @brief セーブデータに店舗情報を書き込む / Write a "store" record
+ * @param store_ptr 店舗情報の参照ポインタ
+ * @return なし
+ */
+static void wr_store(store_type *store_ptr)
+{
+ /* Save the "open" counter */
+ wr_u32b(store_ptr->store_open);
+
+ /* Save the "insults" */
+ wr_s16b(store_ptr->insult_cur);
+
+ /* Save the current owner */
+ wr_byte(store_ptr->owner);
+
+ /* Save the stock size */
+ wr_s16b(store_ptr->stock_num);
+
+ /* Save the "haggle" info */
+ wr_s16b(store_ptr->good_buy);
+ wr_s16b(store_ptr->bad_buy);
+
+ wr_s32b(store_ptr->last_visit);
+
+ /* Save the stock */
+ for (int j = 0; j < store_ptr->stock_num; j++) {
+ /* Save each item in stock */
+ wr_item(&store_ptr->stock[j]);
+ }
+}
+
+/*!
+ * @brief セーブデータに乱数情報を書き込む / Write RNG state
+ * @return 常に0(成功を返す)
+ */
+static errr wr_randomizer(void)
+{
+ wr_u16b(0);
+ wr_u16b(Rand_place);
+
+ for (int i = 0; i < RAND_DEG; i++) {
+ wr_u32b(Rand_state[i]);
+ }
+
+ return 0;
+}
+
+/*!
+ * @brief ゲームオプション情報を書き込む / Write the "options"
+ * @return なし
+ */
+static void wr_options(void)
+{
+ for (int i = 0; i < 4; i++)
+ wr_u32b(0L);
+
+ /*** Special options ***/
+ /* Write "delay_factor" */
+ wr_byte(delay_factor);
+
+ /* Write "hitpoint_warn" */
+ wr_byte(hitpoint_warn);
+
+ /* Write "mana_warn" */
+ wr_byte(mana_warn);
+
+ /*** Cheating options ***/
+
+ u16b c = 0;
+ if (current_world_ptr->wizard)
+ c |= 0x0002;
+
+ if (cheat_sight)
+ c |= 0x0040;
+ if (cheat_turn)
+ c |= 0x0080;
+
+ if (cheat_peek)
+ c |= 0x0100;
+ if (cheat_hear)
+ c |= 0x0200;
+ if (cheat_room)
+ c |= 0x0400;
+ if (cheat_xtra)
+ c |= 0x0800;
+ if (cheat_know)
+ c |= 0x1000;
+ if (cheat_live)
+ c |= 0x2000;
+ if (cheat_save)
+ c |= 0x4000;
+ if (cheat_diary_output)
+ c |= 0x8000;
+
+ wr_u16b(c);
+
+ /* Autosave info */
+ wr_byte(autosave_l);
+ wr_byte(autosave_t);
+ wr_s16b(autosave_freq);
+
+ /*** Extract options ***/
+ /* Analyze the options */
+ for (int i = 0; option_info[i].o_desc; i++) {
+ int os = option_info[i].o_set;
+ int ob = option_info[i].o_bit;
+
+ /* Process real entries */
+ if (!option_info[i].o_var)
+ continue;
+
+ if (*option_info[i].o_var) {
+ option_flag[os] |= (1L << ob);
+ } else {
+ option_flag[os] &= ~(1L << ob);
+ }
+ }
+
+ /*** Normal options ***/
+ /* Dump the flags */
+ for (int i = 0; i < 8; i++)
+ wr_u32b(option_flag[i]);
+
+ /* Dump the masks */
+ for (int i = 0; i < 8; i++)
+ wr_u32b(option_mask[i]);
+
+ /*** Window options ***/
+ /* Dump the flags */
+ for (int i = 0; i < 8; i++)
+ wr_u32b(window_flag[i]);
+
+ /* Dump the masks */
+ for (int i = 0; i < 8; i++)
+ wr_u32b(window_mask[i]);
+}
+
+/*!
+ * @brief ダミー情報スキップを書き込む / Hack -- Write the "ghost" info
+ * @return なし
+ */
+static void wr_ghost(void)
+{
+ wr_string(_("不正なゴースト", "Broken Ghost"));
+
+ /* Hack -- stupid data */
+ for (int i = 0; i < 60; i++)
+ wr_byte(0);
+}
+
+/*!
+ * @brief クイック・スタート情報を書き込む / Save quick start data
+ * @return なし
+ */
+static void save_quick_start(void)
+{
+ wr_byte(previous_char.psex);
+ wr_byte((byte)previous_char.prace);
+ wr_byte((byte)previous_char.pclass);
+ wr_byte((byte)previous_char.pseikaku);
+ wr_byte((byte)previous_char.realm1);
+ wr_byte((byte)previous_char.realm2);
+
+ wr_s16b(previous_char.age);
+ wr_s16b(previous_char.ht);
+ wr_s16b(previous_char.wt);
+ wr_s16b(previous_char.sc);
+ wr_s32b(previous_char.au);
+
+ for (int i = 0; i < A_MAX; i++)
+ wr_s16b(previous_char.stat_max[i]);
+ for (int i = 0; i < A_MAX; i++)
+ wr_s16b(previous_char.stat_max_max[i]);
+
+ for (int i = 0; i < PY_MAX_LEVEL; i++)
+ wr_s16b((s16b)previous_char.player_hp[i]);
+
+ wr_s16b(previous_char.chaos_patron);
+
+ for (int i = 0; i < 8; i++)
+ wr_s16b(previous_char.vir_types[i]);
+
+ for (int i = 0; i < 4; i++)
+ wr_string(previous_char.history[i]);
+
+ /* UNUSED : Was number of random quests */
+ wr_byte(0);
+
+ /* No quick start after using debug mode or cheat options */
+ if (current_world_ptr->noscore)
+ previous_char.quick_ok = FALSE;
+
+ wr_byte((byte)previous_char.quick_ok);
+}
+
+/*!
+ * @brief その他の情報を書き込む / Write some "extra" info
+ * @return なし
+ */
+static void wr_extra(player_type *creature_ptr)
+{
+ wr_string(creature_ptr->name);
+ wr_string(creature_ptr->died_from);
+ wr_string(creature_ptr->last_message ? creature_ptr->last_message : "");
+
+ save_quick_start();
+
+ for (int i = 0; i < 4; i++) {
+ wr_string(creature_ptr->history[i]);
+ }
+
+ /* Race/Class/Gender/Spells */
+ wr_byte((byte)creature_ptr->prace);
+ wr_byte((byte)creature_ptr->pclass);
+ wr_byte((byte)creature_ptr->pseikaku);
+ wr_byte((byte)creature_ptr->psex);
+ wr_byte((byte)creature_ptr->realm1);
+ wr_byte((byte)creature_ptr->realm2);
+ wr_byte(0);
+
+ wr_byte((byte)creature_ptr->hitdie);
+ wr_u16b(creature_ptr->expfact);
+
+ wr_s16b(creature_ptr->age);
+ wr_s16b(creature_ptr->ht);
+ wr_s16b(creature_ptr->wt);
+
+ /* Dump the stats (maximum and current) */
+ for (int i = 0; i < A_MAX; ++i)
+ wr_s16b(creature_ptr->stat_max[i]);
+ for (int i = 0; i < A_MAX; ++i)
+ wr_s16b(creature_ptr->stat_max_max[i]);
+ for (int i = 0; i < A_MAX; ++i)
+ wr_s16b(creature_ptr->stat_cur[i]);
+
+ /* Ignore the transient stats */
+ for (int i = 0; i < 12; ++i)
+ wr_s16b(0);
+
+ wr_u32b(creature_ptr->au);
+
+ wr_u32b(creature_ptr->max_exp);
+ wr_u32b(creature_ptr->max_max_exp);
+ wr_u32b(creature_ptr->exp);
+ wr_u32b(creature_ptr->exp_frac);
+ wr_s16b(creature_ptr->lev);
+
+ for (int i = 0; i < 64; i++)
+ wr_s16b(creature_ptr->spell_exp[i]);
+ for (int i = 0; i < 5; i++)
+ for (int j = 0; j < 64; j++)
+ wr_s16b(creature_ptr->weapon_exp[i][j]);
+
+ for (int i = 0; i < GINOU_MAX; i++)
+ wr_s16b(creature_ptr->skill_exp[i]);
+ for (int i = 0; i < 108; i++)
+ wr_s32b(creature_ptr->magic_num1[i]);
+ for (int i = 0; i < 108; i++)
+ wr_byte(creature_ptr->magic_num2[i]);
+
+ wr_byte((byte)creature_ptr->start_race);
+ wr_s32b(creature_ptr->old_race1);
+ wr_s32b(creature_ptr->old_race2);
+ wr_s16b(creature_ptr->old_realm);
+
+ for (int i = 0; i < MAX_MANE; i++) {
+ wr_s16b((s16b)creature_ptr->mane_spell[i]);
+ wr_s16b((s16b)creature_ptr->mane_dam[i]);
+ }
+
+ wr_s16b(creature_ptr->mane_num);
+
+ for (int i = 0; i < MAX_BOUNTY; i++) {
+ wr_s16b(current_world_ptr->bounty_r_idx[i]);
+ }
+
+ for (int i = 0; i < 4; i++) {
+ wr_s16b(battle_mon[i]);
+ wr_u32b(mon_odds[i]);
+ }
+
+ wr_s16b(creature_ptr->town_num); /* -KMW- */
+
+ /* Write arena and rewards information -KMW- */
+ wr_s16b(creature_ptr->arena_number);
+ wr_s16b(creature_ptr->current_floor_ptr->inside_arena);
+ wr_s16b(creature_ptr->current_floor_ptr->inside_quest);
+ wr_s16b(creature_ptr->phase_out);
+ wr_byte(creature_ptr->exit_bldg);
+ wr_byte(0); /* Unused */
+
+ wr_s16b((s16b)creature_ptr->oldpx);
+ wr_s16b((s16b)creature_ptr->oldpy);
+
+ /* Was number of creature_ptr->rewards[] */
+ wr_s16b(0);
+
+ wr_s32b(creature_ptr->mhp);
+ wr_s32b(creature_ptr->chp);
+ wr_u32b(creature_ptr->chp_frac);
+
+ wr_s32b(creature_ptr->msp);
+ wr_s32b(creature_ptr->csp);
+ wr_u32b(creature_ptr->csp_frac);
+
+ /* Max Player and Dungeon Levels */
+ wr_s16b(creature_ptr->max_plv);
+ byte tmp8u = (byte)current_world_ptr->max_d_idx;
+ wr_byte(tmp8u);
+ for (int i = 0; i < tmp8u; i++)
+ wr_s16b((s16b)max_dlv[i]);
+
+ /* More info */
+ wr_s16b(0);
+ wr_s16b(0);
+ wr_s16b(0);
+ wr_s16b(0);
+ wr_s16b(creature_ptr->sc);
+ wr_s16b(creature_ptr->concent);
+
+ wr_s16b(0); /* old "rest" */
+ wr_s16b(creature_ptr->blind);
+ wr_s16b(creature_ptr->paralyzed);
+ wr_s16b(creature_ptr->confused);
+ wr_s16b(creature_ptr->food);
+ wr_s16b(0); /* old "food_digested" */
+ wr_s16b(0); /* old "protection" */
+ wr_s16b(creature_ptr->energy_need);
+ wr_s16b(creature_ptr->enchant_energy_need);
+ wr_s16b(creature_ptr->fast);
+ wr_s16b(creature_ptr->slow);
+ wr_s16b(creature_ptr->afraid);
+ wr_s16b(creature_ptr->cut);
+ wr_s16b(creature_ptr->stun);
+ wr_s16b(creature_ptr->poisoned);
+ wr_s16b(creature_ptr->image);
+ wr_s16b(creature_ptr->protevil);
+ wr_s16b(creature_ptr->invuln);
+ wr_s16b(creature_ptr->ult_res);
+ wr_s16b(creature_ptr->hero);
+ wr_s16b(creature_ptr->shero);
+ wr_s16b(creature_ptr->shield);
+ wr_s16b(creature_ptr->blessed);
+ wr_s16b(creature_ptr->tim_invis);
+ wr_s16b(creature_ptr->word_recall);
+ wr_s16b(creature_ptr->recall_dungeon);
+ wr_s16b(creature_ptr->alter_reality);
+ wr_s16b(creature_ptr->see_infra);
+ wr_s16b(creature_ptr->tim_infra);
+ wr_s16b(creature_ptr->oppose_fire);
+ wr_s16b(creature_ptr->oppose_cold);
+ wr_s16b(creature_ptr->oppose_acid);
+ wr_s16b(creature_ptr->oppose_elec);
+ wr_s16b(creature_ptr->oppose_pois);
+ wr_s16b(creature_ptr->tsuyoshi);
+ wr_s16b(creature_ptr->tim_esp);
+ wr_s16b(creature_ptr->wraith_form);
+ wr_s16b(creature_ptr->resist_magic);
+ wr_s16b(creature_ptr->tim_regen);
+ wr_s16b(creature_ptr->tim_pass_wall);
+ wr_s16b(creature_ptr->tim_stealth);
+ wr_s16b(creature_ptr->tim_levitation);
+ wr_s16b(creature_ptr->tim_sh_touki);
+ wr_s16b(creature_ptr->lightspeed);
+ wr_s16b(creature_ptr->tsubureru);
+ wr_s16b(creature_ptr->magicdef);
+ wr_s16b(creature_ptr->tim_res_nether);
+ wr_s16b(creature_ptr->tim_res_time);
+ wr_byte((byte)creature_ptr->mimic_form);
+ wr_s16b(creature_ptr->tim_mimic);
+ wr_s16b(creature_ptr->tim_sh_fire);
+ wr_s16b(creature_ptr->tim_sh_holy);
+ wr_s16b(creature_ptr->tim_eyeeye);
+
+ /* by henkma */
+ wr_s16b(creature_ptr->tim_reflect);
+ wr_s16b(creature_ptr->multishadow);
+ wr_s16b(creature_ptr->dustrobe);
+
+ wr_s16b(creature_ptr->chaos_patron);
+ wr_u32b(creature_ptr->muta1);
+ wr_u32b(creature_ptr->muta2);
+ wr_u32b(creature_ptr->muta3);
+
+ for (int i = 0; i < 8; i++)
+ wr_s16b(creature_ptr->virtues[i]);
+ for (int i = 0; i < 8; i++)
+ wr_s16b(creature_ptr->vir_types[i]);
+
+ wr_s16b(creature_ptr->ele_attack);
+ wr_u32b(creature_ptr->special_attack);
+ wr_s16b(creature_ptr->ele_immune);
+ wr_u32b(creature_ptr->special_defense);
+ wr_byte(creature_ptr->knowledge);
+ wr_byte(creature_ptr->autopick_autoregister);
+ wr_byte(0);
+ wr_byte((byte)creature_ptr->action);
+ wr_byte(0);
+ wr_byte(preserve_mode);
+ wr_byte(creature_ptr->wait_report_score);
+
+ /* Future use */
+ for (int i = 0; i < 12; i++)
+ wr_u32b(0L);
+
+ /* Ignore some flags */
+ wr_u32b(0L);
+ wr_u32b(0L);
+ wr_u32b(0L);
+
+ /* Write the "object seeds" */
+ wr_u32b(current_world_ptr->seed_flavor);
+ wr_u32b(current_world_ptr->seed_town);
+
+ /* Special stuff */
+ wr_u16b(creature_ptr->panic_save);
+ wr_u16b(current_world_ptr->total_winner);
+ wr_u16b(current_world_ptr->noscore);
+
+ /* Write death */
+ wr_byte(creature_ptr->is_dead);
+
+ /* Write feeling */
+ wr_byte(creature_ptr->feeling);
+
+ /* Turn when level began */
+ wr_s32b(creature_ptr->current_floor_ptr->generated_turn);
+
+ /* Turn of last "feeling" */
+ wr_s32b(creature_ptr->feeling_turn);
+
+ /* Current turn */
+ wr_s32b(current_world_ptr->game_turn);
+
+ wr_s32b(current_world_ptr->dungeon_turn);
+
+ wr_s32b(current_world_ptr->arena_start_turn);
+
+ wr_s16b(today_mon);
+ wr_s16b(creature_ptr->today_mon);
+ wr_s16b(creature_ptr->riding);
+
+ /* Current floor_id */
+ wr_s16b(creature_ptr->floor_id);
+
+ /* Save temporary preserved pets (obsolated) */
+ wr_s16b(0);
+
+ wr_u32b(current_world_ptr->play_time);
+ wr_s32b(creature_ptr->visit);
+ wr_u32b(creature_ptr->count);
+}
+
+/*!
+ * @brief 保存フロアの書き込み / Actually write a saved floor data using effectively compressed format.
+ * @param sf_ptr 保存したいフロアの参照ポインタ
+ * @return なし
+ */
+static void wr_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr)
+{
+ /*** Basic info ***/
+ /* Dungeon floor specific info follows */
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
+ if (!sf_ptr) {
+ /*** Not a saved floor ***/
+
+ wr_s16b((s16b)floor_ptr->dun_level);
+ } else {
+ /*** The saved floor ***/
+
+ wr_s16b(sf_ptr->floor_id);
+ wr_byte((byte)sf_ptr->savefile_id);
+ wr_s16b((s16b)sf_ptr->dun_level);
+ wr_s32b(sf_ptr->last_visit);
+ wr_u32b(sf_ptr->visit_mark);
+ wr_s16b(sf_ptr->upper_floor_id);
+ wr_s16b(sf_ptr->lower_floor_id);
+ }
+
+ wr_u16b((u16b)floor_ptr->base_level);
+ wr_u16b((s16b)player_ptr->current_floor_ptr->num_repro);
+ wr_u16b((u16b)player_ptr->y);
+ wr_u16b((u16b)player_ptr->x);
+ wr_u16b((u16b)floor_ptr->height);
+ wr_u16b((u16b)floor_ptr->width);
+ wr_byte(player_ptr->feeling);
+
+ /*********** Make template for grid_type **********/
+
+ /*
+ * Usually number of templates are fewer than 255. Even if
+ * more than 254 are exist, the occurrence of each template
+ * with larger ID is very small when we sort templates by
+ * occurrence. So we will use two (or more) bytes for
+ * templete ID larger than 254.
+ *
+ * Ex: 256 will be "0xff" "0x01".
+ * 515 will be "0xff" "0xff" "0x03"
+ */
+
+ /* Fake max number */
+ u16b max_num_temp = 255;
+
+ /* Allocate the "template" array */
+ grid_template_type *templates;
+ C_MAKE(templates, max_num_temp, grid_template_type);
+
+ /* Extract template array */
+ u16b num_temp = 0;
+ for (int y = 0; y < floor_ptr->height; y++) {
+ for (int x = 0; x < floor_ptr->width; x++) {
+ grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+
+ int i;
+ for (i = 0; i < num_temp; i++) {
+ if (templates[i].info == g_ptr->info && templates[i].feat == g_ptr->feat && templates[i].mimic == g_ptr->mimic
+ && templates[i].special == g_ptr->special) {
+ /* Same terrain is exist */
+ templates[i].occurrence++;
+ break;
+ }
+ }
+
+ /* Are there same one? */
+ if (i < num_temp)
+ continue;
+
+ /* If the max_num_temp is too small, increase it. */
+ if (num_temp >= max_num_temp) {
+ grid_template_type *old_template = templates;
+
+ /* Re-allocate the "template" array */
+ C_MAKE(templates, max_num_temp + 255, grid_template_type);
+ (void)C_COPY(templates, old_template, max_num_temp, grid_template_type);
+ C_KILL(old_template, max_num_temp, grid_template_type);
+ max_num_temp += 255;
+ }
+
+ /* Add new template */
+ templates[num_temp].info = g_ptr->info;
+ templates[num_temp].feat = g_ptr->feat;
+ templates[num_temp].mimic = g_ptr->mimic;
+ templates[num_temp].special = g_ptr->special;
+ templates[num_temp].occurrence = 1;
+
+ /* Increase number of template */
+ num_temp++;
+ }
+ }
+
+ /* Sort by occurrence */
+ int dummy_why;
+ ang_sort(player_ptr, templates, &dummy_why, num_temp, ang_sort_comp_cave_temp, ang_sort_swap_cave_temp);
+
+ /*** Dump templates ***/
+
+ /* Total templates */
+ wr_u16b(num_temp);
+
+ /* Dump the templates */
+ for (int i = 0; i < num_temp; i++) {
+ grid_template_type *ct_ptr = &templates[i];
+ wr_u16b((u16b)ct_ptr->info);
+ wr_s16b(ct_ptr->feat);
+ wr_s16b(ct_ptr->mimic);
+ wr_s16b(ct_ptr->special);
+ }
+
+ /*** "Run-Length-Encoding" of floor ***/
+ /* Note that this will induce two wasted bytes */
+ byte count = 0;
+ u16b prev_u16b = 0;
+
+ for (int y = 0; y < floor_ptr->height; y++) {
+ for (int x = 0; x < floor_ptr->width; x++) {
+ grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+ int i;
+ for (i = 0; i < num_temp; i++) {
+ if (templates[i].info == g_ptr->info && templates[i].feat == g_ptr->feat && templates[i].mimic == g_ptr->mimic
+ && templates[i].special == g_ptr->special)
+ break;
+ }
+
+ /* Extract an ID */
+ u16b tmp16u = (u16b)i;
+
+ /* If the run is broken, or too full, flush it */
+ if ((tmp16u == prev_u16b) && (count != MAX_UCHAR)) {
+ count++;
+ continue;
+ }
+
+ wr_byte((byte)count);
+
+ while (prev_u16b >= MAX_UCHAR) {
+ /* Mark as actual data is larger than 254 */
+ wr_byte(MAX_UCHAR);
+ prev_u16b -= MAX_UCHAR;
+ }
+
+ wr_byte((byte)prev_u16b);
+ prev_u16b = tmp16u;
+ count = 1;
+ }
+ }
+
+ /* Flush the data (if any) */
+ if (count > 0) {
+ wr_byte((byte)count);
+
+ while (prev_u16b >= MAX_UCHAR) {
+ /* Mark as actual data is larger than 254 */
+ wr_byte(MAX_UCHAR);
+ prev_u16b -= MAX_UCHAR;
+ }
+
+ wr_byte((byte)prev_u16b);
+ }
+
+ /* Free the "template" array */
+ C_KILL(templates, max_num_temp, grid_template_type);
+
+ /*** Dump objects ***/
+
+ /* Total objects */
+ wr_u16b(floor_ptr->o_max);
+
+ /* Dump the objects */
+ for (int i = 1; i < floor_ptr->o_max; i++) {
+ object_type *o_ptr = &floor_ptr->o_list[i];
+ wr_item(o_ptr);
+ }
+
+ /*** Dump the monsters ***/
+
+ /* Total monsters */
+ wr_u16b(floor_ptr->m_max);
+
+ /* Dump the monsters */
+ for (int i = 1; i < floor_ptr->m_max; i++) {
+ monster_type *m_ptr = &floor_ptr->m_list[i];
+ wr_monster(m_ptr);
+ }
+}
+
+/*!
+ * @brief 現在フロアの書き込み /
+ * Write the current dungeon (new method)
+ * @player_ptr プレーヤーへの参照ポインタ
+ * @return 保存に成功したらTRUE
+ */
+static bool wr_dungeon(player_type *player_ptr)
+{
+ forget_lite(player_ptr->current_floor_ptr);
+ forget_view(player_ptr->current_floor_ptr);
+ clear_mon_lite(player_ptr->current_floor_ptr);
+
+ /* Update lite/view */
+ player_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
+ player_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
+
+ /*** Meta info ***/
+
+ /* Number of floor_id used from birth */
+ wr_s16b(max_floor_id);
+
+ /* Current dungeon type */
+ wr_byte((byte)player_ptr->dungeon_idx);
+
+ /*** No saved floor (On the surface etc.) ***/
+ if (!player_ptr->floor_id) {
+ /* No array elements */
+ wr_byte(0);
+
+ /* Write the current floor data */
+ wr_saved_floor(player_ptr, NULL);
+
+ /* Success */
+ return TRUE;
+ }
+
+ /*** In the dungeon ***/
+
+ /* Number of array elements */
+ wr_byte(MAX_SAVED_FLOORS);
+
+ /* Write the saved_floors array */
+ for (int i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
+
+ wr_s16b(sf_ptr->floor_id);
+ wr_byte((byte)sf_ptr->savefile_id);
+ wr_s16b((s16b)sf_ptr->dun_level);
+ wr_s32b(sf_ptr->last_visit);
+ wr_u32b(sf_ptr->visit_mark);
+ wr_s16b(sf_ptr->upper_floor_id);
+ wr_s16b(sf_ptr->lower_floor_id);
+ }
+
+ /* Extract pointer to current floor */
+ saved_floor_type *cur_sf_ptr;
+ cur_sf_ptr = get_sf_ptr(player_ptr->floor_id);
+
+ /* Save current floor to temporary file */
+ if (!save_floor(player_ptr, cur_sf_ptr, (SLF_SECOND)))
+ return FALSE;
+
+ /* Move data in temporary files to the savefile */
+ for (int i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
+ if (!sf_ptr->floor_id)
+ continue;
+ if (!load_floor(player_ptr, sf_ptr, (SLF_SECOND | SLF_NO_KILL))) {
+ wr_byte(1);
+ continue;
+ }
+
+ wr_byte(0);
+ wr_saved_floor(player_ptr, sf_ptr);
+ }
+
+ if (!load_floor(player_ptr, cur_sf_ptr, (SLF_SECOND)))
+ return FALSE;
+ return TRUE;
+}
+
+/*!
+ * @brief セーブデータの書き込み /
+ * Actually write a save-file
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return 成功すればtrue
+ */
+static bool wr_savefile_new(player_type *player_ptr)
+{
+ /* Compact the objects */
+ compact_objects(player_ptr, 0);
+
+ /* Compact the monsters */
+ compact_monsters(player_ptr, 0);
+
+ /* Guess at the current time */
+ u32b now = (u32b)time((time_t *)0);
+
+ /* Note the operating system */
+ current_world_ptr->sf_system = 0L;
+
+ /* Note when the file was saved */
+ current_world_ptr->sf_when = now;
+
+ /* Note the number of saves */
+ current_world_ptr->sf_saves++;
+
+ /*** Actually write the file ***/
+ /* Dump the file header */
+ xor_byte = 0;
+ wr_byte(FAKE_VER_MAJOR);
+ xor_byte = 0;
+ wr_byte(FAKE_VER_MINOR);
+ xor_byte = 0;
+ wr_byte(FAKE_VER_PATCH);
+ xor_byte = 0;
+
+ /* Initial value of xor_byte */
+ byte tmp8u = (byte)Rand_external(256);
+ wr_byte(tmp8u);
+
+ /* Reset the checksum */
+ v_stamp = 0L;
+ x_stamp = 0L;
+
+ /* Write the savefile version for Hengband 1.1.1 and later */
+ wr_byte(H_VER_EXTRA);
+ wr_byte(H_VER_PATCH);
+ wr_byte(H_VER_MINOR);
+ wr_byte(H_VER_MAJOR);
+
+ /* Operating system */
+ wr_u32b(current_world_ptr->sf_system);
+
+ /* Time file last saved */
+ wr_u32b(current_world_ptr->sf_when);
+
+ /* Number of past lives */
+ wr_u16b(current_world_ptr->sf_lives);
+
+ /* Number of times saved */
+ wr_u16b(current_world_ptr->sf_saves);
+
+ wr_u32b(0L);
+ wr_u16b(0);
+ wr_byte(0);
+
+#ifdef JP
+#ifdef EUC
+ /* EUC kanji code */
+ wr_byte(2);
+#endif
+#ifdef SJIS
+ /* SJIS kanji code */
+ wr_byte(3);
+#endif
+#else
+ /* ASCII */
+ wr_byte(1);
+#endif
+
+ /* Write the RNG state */
+ wr_randomizer();
+
+ /* Write the boolean "options" */
+ wr_options();
+
+ /* Dump the number of "messages" */
+ u32b tmp32u = message_num();
+ if (compress_savefile && (tmp32u > 40))
+ tmp32u = 40;
+ wr_u32b(tmp32u);
+
+ /* Dump the messages (oldest first!) */
+ for (int i = tmp32u - 1; i >= 0; i--) {
+ wr_string(message_str((s16b)i));
+ }
+
+ /* Dump the monster lore */
+ u16b tmp16u = max_r_idx;
+ wr_u16b(tmp16u);
+ for (MONRACE_IDX r_idx = 0; r_idx < tmp16u; r_idx++) {
+ wr_lore(r_idx);
+ }
+
+ /* Dump the object memory */
+ tmp16u = max_k_idx;
+ wr_u16b(tmp16u);
+ for (KIND_OBJECT_IDX k_idx = 0; k_idx < tmp16u; k_idx++) {
+ wr_xtra(k_idx);
+ }
+
+ /* Dump the towns */
+ tmp16u = max_towns;
+ wr_u16b(tmp16u);
+
+ /* Dump the quests */
+ tmp16u = max_q_idx;
+ wr_u16b(tmp16u);
+
+ /* Dump the quests */
+ tmp8u = MAX_RANDOM_QUEST - MIN_RANDOM_QUEST;
+ wr_byte(tmp8u);
+
+ for (int i = 0; i < max_q_idx; i++) {
+ quest_type *const q_ptr = &quest[i];
+
+ /* Save status for every quest */
+ wr_s16b(q_ptr->status);
+
+ /* And the dungeon level too */
+ /* (prevents problems with multi-level quests) */
+ wr_s16b((s16b)q_ptr->level);
+
+ wr_byte((byte)q_ptr->complev);
+ wr_u32b(q_ptr->comptime);
+
+ bool is_quest_running = q_ptr->status == QUEST_STATUS_TAKEN;
+ is_quest_running |= q_ptr->status == QUEST_STATUS_COMPLETED;
+ is_quest_running |= !is_fixed_quest_idx(i);
+ if (!is_quest_running)
+ continue;
+
+ wr_s16b((s16b)q_ptr->cur_num);
+ wr_s16b((s16b)q_ptr->max_num);
+ wr_s16b(q_ptr->type);
+ wr_s16b(q_ptr->r_idx);
+ wr_s16b(q_ptr->k_idx);
+ wr_byte((byte)q_ptr->flags);
+ wr_byte((byte)q_ptr->dungeon);
+ }
+
+ /* Dump the position in the wilderness */
+ wr_s32b(player_ptr->wilderness_x);
+ wr_s32b(player_ptr->wilderness_y);
+
+ wr_byte(player_ptr->wild_mode);
+ wr_byte(player_ptr->ambush_flag);
+
+ wr_s32b(current_world_ptr->max_wild_x);
+ wr_s32b(current_world_ptr->max_wild_y);
+
+ /* Dump the wilderness seeds */
+ for (int i = 0; i < current_world_ptr->max_wild_x; i++) {
+ for (int j = 0; j < current_world_ptr->max_wild_y; j++) {
+ wr_u32b(wilderness[j][i].seed);
+ }
+ }
+
+ /* Hack -- Dump the artifacts */
+ tmp16u = max_a_idx;
+ wr_u16b(tmp16u);
+ for (int i = 0; i < tmp16u; i++) {
+ artifact_type *a_ptr = &a_info[i];
+ wr_byte(a_ptr->cur_num);
+ wr_s16b(a_ptr->floor_id);
+ }
+
+ /* Write the "extra" information */
+ wr_extra(player_ptr);
+
+ /* Dump the "player hp" entries */
+ tmp16u = PY_MAX_LEVEL;
+ wr_u16b(tmp16u);
+ for (int i = 0; i < tmp16u; i++) {
+ wr_s16b((s16b)player_ptr->player_hp[i]);
+ }
+
+ /* Write spell data */
+ wr_u32b(player_ptr->spell_learned1);
+ wr_u32b(player_ptr->spell_learned2);
+ wr_u32b(player_ptr->spell_worked1);
+ wr_u32b(player_ptr->spell_worked2);
+ wr_u32b(player_ptr->spell_forgotten1);
+ wr_u32b(player_ptr->spell_forgotten2);
+
+ wr_s16b(player_ptr->learned_spells);
+ wr_s16b(player_ptr->add_spells);
+
+ /* Dump the ordered spells */
+ for (int i = 0; i < 64; i++) {
+ wr_byte((byte)player_ptr->spell_order[i]);
+ }
+
+ for (int i = 0; i < INVEN_TOTAL; i++) {
+ object_type *o_ptr = &player_ptr->inventory_list[i];
+ if (!o_ptr->k_idx)
+ continue;
+
+ /* Dump index */
+ wr_u16b((u16b)i);
+
+ /* Dump object */
+ wr_item(o_ptr);
+ }
+
+ /* Add a sentinel */
+ wr_u16b(0xFFFF);
+
+ /* Note the towns */
+ tmp16u = max_towns;
+ wr_u16b(tmp16u);
+
+ /* Note the stores */
+ tmp16u = MAX_STORES;
+ wr_u16b(tmp16u);
+
+ /* Dump the stores of all towns */
+ for (int i = 1; i < max_towns; i++) {
+ for (int j = 0; j < MAX_STORES; j++) {
+ wr_store(&town_info[i].store[j]);
+ }
+ }
+
+ /* Write the pet command settings */
+ wr_s16b(player_ptr->pet_follow_distance);
+ wr_s16b(player_ptr->pet_extra_flags);
+
+ /* Write screen dump for sending score */
+ if (screen_dump && (player_ptr->wait_report_score || !player_ptr->is_dead)) {
+ wr_string(screen_dump);
+ } else {
+ wr_string("");
+ }
+
+ /* Player is not dead, write the dungeon */
+ if (!player_ptr->is_dead) {
+ /* Dump the dungeon */
+ if (!wr_dungeon(player_ptr))
+ return FALSE;
+
+ /* Dump the ghost */
+ wr_ghost();
+
+ /* No scripts */
+ wr_s32b(0);
+ }
+
+ /* Write the "value check-sum" */
+ wr_u32b(v_stamp);
+
+ /* Write the "encoded checksum" */
+ wr_u32b(x_stamp);
+
+ if (ferror(fff) || (fflush(fff) == EOF))
+ return FALSE;
+ return TRUE;
+}
+
+/*!
+ * @brief セーブデータ書き込みのサブルーチン /
+ * Medium level player saver
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return 成功すればtrue
+ * @details
+ * Angband 2.8.0 will use "fd" instead of "fff" if possible
+ */
+static bool save_player_aux(player_type *player_ptr, char *name)
+{
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Create the savefile */
+ int file_permission = 0644;
+ int fd = fd_make(name, file_permission);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ bool is_save_successful = FALSE;
+ fff = NULL;
+ if (fd >= 0) {
+ /* Close the "fd" */
+ (void)fd_close(fd);
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Open the savefile */
+ fff = angband_fopen(name, "wb");
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ /* Successful open */
+ if (fff) {
+ /* Write the savefile */
+ if (wr_savefile_new(player_ptr))
+ is_save_successful = TRUE;
+
+ /* Attempt to close it */
+ if (angband_fclose(fff))
+ is_save_successful = FALSE;
+ }
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Remove "broken" files */
+ if (!is_save_successful)
+ (void)fd_kill(name);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+ }
+
+ if (!is_save_successful)
+ return FALSE;
+
+ counts_write(player_ptr, 0, current_world_ptr->play_time);
+ current_world_ptr->character_saved = TRUE;
+ return TRUE;
+}
+
+/*!
+ * @brief セーブデータ書き込みのメインルーチン /
+ * Attempt to save the player in a savefile
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return 成功すればtrue
+ */
+bool save_player(player_type *player_ptr)
+{
+ char safe[1024];
+ strcpy(safe, savefile);
+ strcat(safe, ".new");
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ fd_kill(safe);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+ update_playtime();
+
+ /* Attempt to save the player */
+ bool result = FALSE;
+ if (save_player_aux(player_ptr, safe)) {
+ char temp[1024];
+
+ /* Old savefile */
+ strcpy(temp, savefile);
+ strcat(temp, ".old");
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Remove it */
+ fd_kill(temp);
+
+ /* Preserve old savefile */
+ fd_move(savefile, temp);
+
+ /* Activate new savefile */
+ fd_move(safe, savefile);
+
+ /* Remove preserved savefile */
+ fd_kill(temp);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ /* Hack -- Pretend the character was loaded */
+ current_world_ptr->character_loaded = TRUE;
+
+ result = TRUE;
+ }
+
+ /* Return the result */
+ return result;
+}
+
+/*!
+ * @brief セーブデータ読み込みのメインルーチン /
+ * Attempt to Load a "savefile"
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 成功すればtrue
+ * @details
+ * <pre>
+ * Version 2.7.0 introduced a slightly different "savefile" format from
+ * older versions, requiring a completely different parsing method.
+ *
+ * Note that savefiles from 2.7.0 - 2.7.2 are completely obsolete.
+ *
+ * Pre-2.8.0 savefiles lose some data, see "load2.c" for info.
+ *
+ * Pre-2.7.0 savefiles lose a lot of things, see "load1.c" for info.
+ *
+ * On multi-user systems, you may only "read" a savefile if you will be
+ * allowed to "write" it later, this prevents painful situations in which
+ * the player loads a savefile belonging to someone else, and then is not
+ * allowed to save his game when he quits.
+ *
+ * We return "TRUE" if the savefile was usable, and we set the global
+ * flag "current_world_ptr->character_loaded" if a real, living, character was loaded.
+ *
+ * Note that we always try to load the "current" savefile, even if
+ * there is no such file, so we must check for "empty" savefile names.
+ * </pre>
+ */
+bool load_player(player_type *player_ptr)
+{
+ concptr what = "generic";
+
+ current_world_ptr->game_turn = 0;
+ player_ptr->is_dead = FALSE;
+
+ /* Allow empty savefile name */
+ if (!savefile[0])
+ return TRUE;
+
+#if !defined(WINDOWS)
+
+ /* Fix this */
+
+ /* Verify the existance of the savefile */
+ if (access(savefile, 0) < 0) {
+ /* Give a message */
+ msg_print(_("セーブファイルがありません。", "Savefile does not exist."));
+
+ msg_print(NULL);
+
+ /* Allow this */
+ return TRUE;
+ }
+
+#endif
+
+ errr err = 0;
+ int fd = -1;
+ byte vvv[4];
+ if (!err) {
+ /* Open the savefile */
+ fd = fd_open(savefile, O_RDONLY);
+
+ /* No file */
+ if (fd < 0)
+ err = -1;
+
+ /* Message (below) */
+ if (err)
+ what = _("セーブファイルを開けません。", "Cannot open savefile");
+ }
+
+ /* Process file */
+ if (!err) {
+ /* Read the first four bytes */
+ if (fd_read(fd, (char *)(vvv), 4))
+ err = -1;
+
+ /* What */
+ if (err)
+ what = _("セーブファイルを読めません。", "Cannot read savefile");
+ (void)fd_close(fd);
+ }
+
+ /* Process file */
+ if (!err) {
+ /* Extract version */
+ current_world_ptr->z_major = vvv[0];
+ current_world_ptr->z_minor = vvv[1];
+ current_world_ptr->z_patch = vvv[2];
+ current_world_ptr->sf_extra = vvv[3];
+
+ Term_clear();
+
+ /* Attempt to load */
+ err = rd_savefile_new(player_ptr);
+
+ /* Message (below) */
+ if (err)
+ what = _("セーブファイルを解析出来ません。", "Cannot parse savefile");
+ }
+
+ if (!err) {
+ /* Invalid turn */
+ if (!current_world_ptr->game_turn)
+ err = -1;
+
+ /* Message (below) */
+ if (err)
+ what = _("セーブファイルが壊れています", "Broken savefile");
+ }
+
+ if (!err) {
+ /* Give a conversion warning */
+ if ((FAKE_VER_MAJOR != current_world_ptr->z_major) || (FAKE_VER_MINOR != current_world_ptr->z_minor)
+ || (FAKE_VER_PATCH != current_world_ptr->z_patch)) {
+ if (current_world_ptr->z_major == 2 && current_world_ptr->z_minor == 0 && current_world_ptr->z_patch == 6) {
+ msg_print(_("バージョン 2.0.* 用のセーブファイルを変換しました。", "Converted a 2.0.* savefile."));
+ } else {
+ msg_format(_("バージョン %d.%d.%d 用のセーブ・ファイルを変換しました。", "Converted a %d.%d.%d savefile."),
+ (current_world_ptr->z_major > 9) ? current_world_ptr->z_major - 10 : current_world_ptr->z_major, current_world_ptr->z_minor,
+ current_world_ptr->z_patch);
+ }
+ msg_print(NULL);
+ }
+
+ /* Player is dead */
+ if (player_ptr->is_dead) {
+ /* Cheat death */
+ if (arg_wizard) {
+ /* A character was loaded */
+ current_world_ptr->character_loaded = TRUE;
+ return TRUE;
+ }
+
+ /* Player is no longer "dead" */
+ player_ptr->is_dead = FALSE;
+
+ /* Count lives */
+ current_world_ptr->sf_lives++;
+
+ return TRUE;
+ }
+
+ /* A character was loaded */
+ current_world_ptr->character_loaded = TRUE;
+
+ {
+ u32b tmp = counts_read(player_ptr, 2);
+ if (tmp > player_ptr->count)
+ player_ptr->count = tmp;
+ if (counts_read(player_ptr, 0) > current_world_ptr->play_time || counts_read(player_ptr, 1) == current_world_ptr->play_time)
+ counts_write(player_ptr, 2, ++player_ptr->count);
+ counts_write(player_ptr, 1, current_world_ptr->play_time);
+ }
+
+ /* Success */
+ return TRUE;
+ }
+
+ msg_format(_("エラー(%s)がバージョン%d.%d.%d 用セーブファイル読み込み中に発生。", "Error (%s) reading %d.%d.%d savefile."), what,
+ (current_world_ptr->z_major > 9) ? current_world_ptr->z_major - 10 : current_world_ptr->z_major, current_world_ptr->z_minor,
+ current_world_ptr->z_patch);
+ msg_print(NULL);
+ return FALSE;
+}
+
+/*!
+ * @brief ゲームプレイ中のフロア一時保存出力処理サブルーチン / Actually write a temporary saved floor file
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param sf_ptr 保存フロア参照ポインタ
+ * @return なし
+ */
+static bool save_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr)
+{
+ /* Compact the objects */
+ compact_objects(player_ptr, 0);
+ /* Compact the monsters */
+ compact_monsters(player_ptr, 0);
+
+ /*** Actually write the file ***/
+ /* Initial value of xor_byte */
+ byte tmp8u = (byte)randint0(256);
+ xor_byte = 0;
+ wr_byte(tmp8u);
+
+ /* Reset the checksum */
+ v_stamp = 0L;
+ x_stamp = 0L;
+
+ /* Write the sign of this process */
+ wr_u32b(saved_floor_file_sign);
+
+ /* Dump the dungeon floor */
+ wr_saved_floor(player_ptr, sf_ptr);
+
+ /* Write the "value check-sum" */
+ wr_u32b(v_stamp);
+
+ /* Write the "encoded checksum" */
+ wr_u32b(x_stamp);
+
+ if (ferror(fff) || (fflush(fff) == EOF))
+ return FALSE;
+ return TRUE;
+}
+
+/*!
+ * @brief ゲームプレイ中のフロア一時保存出力処理メインルーチン / Attempt to save the temporarily saved-floor data
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param sf_ptr 保存フロア参照ポインタ
+ * @param mode 保存オプション
+ * @return なし
+ */
+bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mode)
+{
+ FILE *old_fff = NULL;
+ byte old_xor_byte = 0;
+ u32b old_v_stamp = 0;
+ u32b old_x_stamp = 0;
+
+ char floor_savefile[1024];
+ if (!(mode & SLF_SECOND)) {
+ }
+
+ /* We have one file already opened */
+ else {
+ /* Backup original values */
+ old_fff = fff;
+ old_xor_byte = xor_byte;
+ old_v_stamp = v_stamp;
+ old_x_stamp = x_stamp;
+ }
+
+ /* New savefile */
+ sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id);
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Remove it */
+ fd_kill(floor_savefile);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ /* Attempt to save the player */
+
+ /* No file yet */
+ fff = NULL;
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Create the savefile */
+ int fd = fd_make(floor_savefile, 0644);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ bool is_save_successful = FALSE;
+ if (fd >= 0) {
+ /* Close the "fd" */
+ (void)fd_close(fd);
+
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ /* Open the savefile */
+ fff = angband_fopen(floor_savefile, "wb");
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ /* Successful open */
+ if (fff) {
+ /* Write the savefile */
+ if (save_floor_aux(player_ptr, sf_ptr))
+ is_save_successful = TRUE;
+
+ /* Attempt to close it */
+ if (angband_fclose(fff))
+ is_save_successful = FALSE;
+ }
+
+ /* Remove "broken" files */
+ if (!is_save_successful) {
+ /* Grab permissions */
+ safe_setuid_grab(player_ptr);
+
+ (void)fd_kill(floor_savefile);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+ }
+ }
+
+ if (!(mode & SLF_SECOND)) {
+ }
+
+ /* We have one file already opened */
+ else {
+ /* Restore original values */
+ fff = old_fff;
+ xor_byte = old_xor_byte;
+ v_stamp = old_v_stamp;
+ x_stamp = old_x_stamp;
+ }
+
+ return is_save_successful;
+}