/[LeafOK_CVS]/lbbs/src/bbs.c
ViewVC logotype

Diff of /lbbs/src/bbs.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.32 by sysadm, Thu Oct 23 14:49:24 2025 UTC Revision 1.35 by sysadm, Mon Nov 3 15:08:54 2025 UTC
# Line 36  int BBS_max_client_per_ip = MAX_CLIENT_P Line 36  int BBS_max_client_per_ip = MAX_CLIENT_P
36  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日";  char BBS_start_dt[BBS_start_dt_max_len + 1] = "2000年 1月 1日";
37  int BBS_sys_id = 1;  int BBS_sys_id = 1;
38    
39  const int BBS_section_list_load_interval = 5; // second  const int BBS_section_list_load_interval = 1; // second
40    
41  // User  // User
42  const int BBS_user_list_load_interval = 60;               // 1 minute  const int BBS_user_list_load_interval = 60;               // 1 minute
# Line 62  static const int astro_dates[] = { Line 62  static const int astro_dates[] = {
62  static const char *astro_names[] = {  static const char *astro_names[] = {
63          "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"};          "摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯"};
64    
65  static const int user_level_points[] = {  static const int BBS_user_level_points[] = {
66          INT_MIN, // 0          INT_MIN, // 0
67          50,              // 1          50,              // 1
68          200,     // 2          200,     // 2
# Line 79  static const int user_level_points[] = { Line 79  static const int user_level_points[] = {
79          80000,   // 13          80000,   // 13
80          90000,   // 14          90000,   // 14
81          100000,  // 15          100000,  // 15
         INT_MAX, // 16  
82  };  };
83    
84  static const char *user_level_names[] = {  static const char *BBS_user_level_names[] = {
85          "新手上路", // 0          "新手上路", // 0
86          "初来乍练", // 1          "初来乍练", // 1
87          "白手起家", // 2          "白手起家", // 2
# Line 101  static const char *user_level_names[] = Line 100  static const char *user_level_names[] =
100          "★★★★★",        // 15          "★★★★★",        // 15
101  };  };
102    
103  static const int user_level_cnt = sizeof(user_level_names) / sizeof(const char *);  static const int BBS_user_level_cnt = sizeof(BBS_user_level_names) / sizeof(const char *);
104    
105  const char *get_astro_name(time_t birthday)  const char *get_astro_name(time_t birthday)
106  {  {
# Line 117  const char *get_astro_name(time_t birthd Line 116  const char *get_astro_name(time_t birthd
116          return astro_names[tm_birth.tm_mon + 1];          return astro_names[tm_birth.tm_mon + 1];
117  }  }
118    
119  const char *get_user_level_name(int point)  int get_user_level(int point)
120  {  {
121          int left;          int left;
122          int right;          int right;
123          int mid;          int mid;
124    
125          left = 0;          left = 0;
126          right = user_level_cnt - 1;          right = BBS_user_level_cnt - 1;
127    
128          while (left < right)          while (left < right)
129          {          {
130                  mid = (left + right) / 2;                  mid = (left + right) / 2;
131                  if (point < user_level_points[mid + 1])                  if (point < BBS_user_level_points[mid])
132                  {                  {
133                          right = mid;                          right = mid - 1;
134                  }                  }
135                  else if (point > user_level_points[mid + 1])                  else if (point > BBS_user_level_points[mid])
136                  {                  {
137                          left = mid + 1;                          left = mid + 1;
138                  }                  }
139                  else // if (point == user_level_points[mid])                  else // if (point == user_level_points[mid])
140                  {                  {
141                          left = mid + 1;                          left = mid;
142                          break;                          break;
143                  }                  }
144          }          }
145    
146          return user_level_names[left];          if (point < BBS_user_level_points[left])
147            {
148                    left--;
149            }
150    
151            return left;
152    }
153    
154    const char *get_user_level_name(int level)
155    {
156            return BBS_user_level_names[level];
157  }  }
158    
159  char *setuserfile(char *buf, size_t len, const char *filename)  char *setuserfile(char *buf, size_t len, const char *filename)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1