From d133925fd263c579494bc8d4f4af378ce5433603 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 26 Jan 2020 22:06:39 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20CHECK=5FLOAD=E3=81=AE?= =?utf8?q?=E3=83=97=E3=83=AA=E3=83=97=E3=83=AD=E3=82=92=E5=89=8A=E9=99=A4?= =?utf8?q?=20/=20Removed=20preprocessor=20CHECK=5FLOAD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/files.c | 128 --------------------------------------------------------- src/files.h | 2 - src/h-config.h | 10 ----- src/main.c | 6 --- 4 files changed, 146 deletions(-) diff --git a/src/files.c b/src/files.c index 50fb15375..95ff9c56b 100644 --- a/src/files.c +++ b/src/files.c @@ -1254,134 +1254,6 @@ errr process_pref_file(player_type *creature_ptr, concptr name) } -#ifdef CHECK_LOAD - -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 64 -#endif - -typedef struct statstime statstime; - -struct statstime -{ - int cp_time[4]; - int dk_xfer[4]; - unsigned int v_pgpgin; - unsigned int v_pgpgout; - unsigned int v_pswpin; - unsigned int v_pswpout; - unsigned int v_intr; - int if_ipackets; - int if_ierrors; - int if_opackets; - int if_oerrors; - int if_collisions; - unsigned int v_swtch; - long avenrun[3]; - struct timeval boottime; - struct timeval curtime; -}; - -/* - * Maximal load (if any). - */ -static int check_load_value = 0; - -#endif - - -/*! - * @brief Angbandプレイ禁止ホストのチェック / - * Handle CHECK_LOAD - * @return エラーコード - */ -errr check_load(void) -{ - -#ifdef CHECK_LOAD - - struct statstime st; - - /* Success if not checking */ - if (!check_load_value) return 0; - - /* Check the load */ - if (0 == rstat("localhost", &st)) - { - long val1 = (long)(st.avenrun[2]); - long val2 = (long)(check_load_value)* FSCALE; - - /* Check for violation */ - if (val1 >= val2) return 1; - } - -#endif - - /* Success */ - return 0; -} - - -/*! - * @brief Angbandプレイ禁止ホストの設定初期化 / - * Initialize CHECK_LOAD - * @return エラーコード - */ -errr check_load_init(void) -{ - -#ifdef CHECK_LOAD - - FILE *fp; - - char buf[1024]; - - char temphost[MAXHOSTNAMELEN + 1]; - char thishost[MAXHOSTNAMELEN + 1]; - - path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt"); - - /* Open the "load" file */ - fp = my_fopen(buf, "r"); - - /* No file, no restrictions */ - if (!fp) return 0; - - /* Default load */ - check_load_value = 100; - - /* Get the host name */ - (void)gethostname(thishost, (sizeof thishost) - 1); - - /* Parse it */ - while (0 == my_fgets(fp, buf, sizeof(buf))) - { - int value; - - /* Skip comments and blank lines */ - if (!buf[0] || (buf[0] == '#')) continue; - - /* Parse, or ignore */ - if (sscanf(buf, "%s%d", temphost, &value) != 2) continue; - - /* Skip other hosts */ - if (!streq(temphost, thishost) && - !streq(temphost, "localhost")) continue; - - /* Use that value */ - check_load_value = value; - - break; - } - my_fclose(fp); - -#endif - - /* Success */ - return 0; -} - - #define ENTRY_BARE_HAND 0 #define ENTRY_TWO_HANDS 1 #define ENTRY_RIGHT_HAND1 2 diff --git a/src/files.h b/src/files.h index a0cb486fb..4dddc8a8e 100644 --- a/src/files.h +++ b/src/files.h @@ -34,8 +34,6 @@ extern errr process_pref_file(player_type *creature_ptr, concptr name); extern errr process_autopick_file(player_type *creature_ptr, concptr name); extern errr process_histpref_file(player_type *creature_ptr, concptr name); extern void display_player_equippy(player_type *player_ptr, TERM_LEN y, TERM_LEN x, BIT_FLAGS16 mode); -extern errr check_load_init(void); -extern errr check_load(void); extern bool show_file(player_type *player_ptr, bool show_version, concptr name, concptr what, int line, BIT_FLAGS mode); extern void do_cmd_help(player_type *creature_ptr); extern void process_player_name(player_type *creature_ptr, bool sf); diff --git a/src/h-config.h b/src/h-config.h index ceeccef03..561d1bd15 100644 --- a/src/h-config.h +++ b/src/h-config.h @@ -407,7 +407,6 @@ #define PRIVATE_USER_PATH "~/.angband" #endif /* SET_UID */ - /* * On multiuser systems, add the "uid" to savefile names */ @@ -416,20 +415,11 @@ #endif /* - * OPTION: Check the "load" against "lib/file/load.txt" - * This may require the 'rpcsvs' library - */ -/* #define CHECK_LOAD */ - - -/* * OPTION: Capitalize the "user_name" (for "default" player name) * This option is only relevant on SET_UID machines. */ #define CAPITALIZE_USER_NAME - - /* * OPTION: Person to bother if something goes wrong. */ diff --git a/src/main.c b/src/main.c index adc75559d..2c5c95b55 100644 --- a/src/main.c +++ b/src/main.c @@ -338,12 +338,6 @@ int main(int argc, char *argv[]) #ifdef SET_UID - /* Initialize the "load" checker */ - if (check_load_init() || check_load()) - { - quit("The gates to Angband are closed (bad load)."); - } - /* Acquire the "user name" as a default player name */ user_name(p_ptr->name, p_ptr->player_uid); -- 2.11.0