Advertisement
Guest User

config.cpp

a guest
Dec 19th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.37 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <sstream>
  3. #ifndef __WIN32__
  4. #include <ifaddrs.h>
  5. #endif
  6.  
  7. #include "constants.h"
  8. #include "utils.h"
  9. #include "log.h"
  10. #include "desc.h"
  11. #include "desc_manager.h"
  12. #include "item_manager.h"
  13. #include "p2p.h"
  14. #include "char.h"
  15. #include "ip_ban.h"
  16. #include "war_map.h"
  17. #include "locale_service.h"
  18. #include "config.h"
  19. #include "dev_log.h"
  20. #include "db.h"
  21. #include "skill_power.h"
  22.  
  23. using std::string;
  24.  
  25. #ifdef __MOUNT_SYSTEM__
  26. static std::set<int> s_Mount_map_unallowed_find;
  27. #endif
  28. BYTE gTimeToStartPvP = 5;
  29. BYTE g_bChannel = 0;
  30. WORD mother_port = 50080;
  31. int passes_per_sec = 25;
  32. WORD db_port = 0;
  33. WORD p2p_port = 50900;
  34. char db_addr[ADDRESS_MAX_LEN + 1];
  35. int save_event_second_cycle = passes_per_sec * 120; // 3ºĞ
  36. int ping_event_second_cycle = passes_per_sec * 60;
  37. bool g_bNoMoreClient = false;
  38. bool g_bNoRegen = false;
  39.  
  40.  
  41. // TRAFFIC_PROFILER
  42. bool g_bTrafficProfileOn = false;
  43. DWORD g_dwTrafficProfileFlushCycle = 3600;
  44. // END_OF_TRAFFIC_PROFILER
  45.  
  46. int test_server = 0;
  47. int speed_server = 0;
  48. bool distribution_test_server = false;
  49. bool china_event_server = false;
  50. bool guild_mark_server = true;
  51. BYTE guild_mark_min_level = 3;
  52. bool no_wander = false;
  53. int g_iUserLimit = 32768;
  54.  
  55. char g_szPublicIP[16] = "0";
  56. char g_szInternalIP[16] = "0";
  57. bool g_bSkillDisable = false;
  58. int g_iFullUserCount = 325;
  59. int g_iBusyUserCount = 50;
  60. //Canada
  61. //int g_iFullUserCount = 600;
  62. //int g_iBusyUserCount = 350;
  63. //Brazil
  64. //int g_iFullUserCount = 650;
  65. //int g_iBusyUserCount = 450;
  66. bool g_bEmpireWhisper = true;
  67. BYTE g_bAuthServer = false;
  68.  
  69. bool g_bCheckClientVersion = true;
  70. string g_stClientVersion = "1215955205";
  71.  
  72. string g_stAuthMasterIP;
  73. WORD g_wAuthMasterPort = 0;
  74.  
  75. static std::set<DWORD> s_set_dwFileCRC;
  76. static std::set<DWORD> s_set_dwProcessCRC;
  77.  
  78. string g_stHostname = "";
  79. string g_table_postfix = "";
  80.  
  81. string g_stQuestDir = "./quest";
  82. //string g_stQuestObjectDir = "./quest/object";
  83. string g_stDefaultQuestObjectDir = "./quest/object";
  84. std::set<string> g_setQuestObjectDir;
  85.  
  86. std::vector<std::string> g_stAdminPageIP;
  87. std::string g_stAdminPagePassword = "SHOWMETHEMONEY";
  88.  
  89. string g_stBlockDate = "30000705";
  90.  
  91. extern string g_stLocale;
  92.  
  93. int SPEEDHACK_LIMIT_COUNT = 3000;
  94. int SPEEDHACK_LIMIT_BONUS = 300;
  95. int g_iSyncHackLimitCount = 10;
  96.  
  97. //½Ã¾ß = VIEW_RANGE + VIEW_BONUS_RANGE
  98. //VIEW_BONUSE_RANGE : Ŭ¶óÀ̾ğÆ®¿Í ½Ã¾ß 󸮿¡¼­³Ê¹« µü ¶³¾îÁú°æ¿ì ¹®Á¦°¡ ¹ß»ıÇÒ¼öÀÖ¾î 500CMÀÇ ¿©ºĞÀ» Ç×»óÁØ´Ù.
  99. int VIEW_RANGE = 5000;
  100. int VIEW_BONUS_RANGE = 500;
  101.  
  102. int g_server_id = 0;
  103. string g_strWebMallURL = "http://astekmt2.com/ishop/ishop";
  104.  
  105. unsigned int g_uiSpamBlockDuration = 60 * 15; // ±âº» 15ºĞ
  106. unsigned int g_uiSpamBlockScore = 100; // ±âº» 100Á¡
  107. unsigned int g_uiSpamReloadCycle = 60 * 10; // ±âº» 10ºĞ
  108.  
  109. bool g_bCheckMultiHack = true;
  110.  
  111. int g_iSpamBlockMaxLevel = 10;
  112.  
  113. void LoadStateUserCount();
  114. void LoadValidCRCList();
  115. bool LoadClientVersion();
  116. bool g_protectNormalPlayer = false; // ¹ü¹ıÀÚ°¡ "ÆòÈ­¸ğµå" ÀÎ ÀϹİÀ¯Àú¸¦ °ø°İÇÏÁö ¸øÇÔ
  117. bool g_noticeBattleZone = false; // Á߸³Áö´ë¿¡ ÀÔÀåÇÏ¸é ¾È³»¸Ş¼¼Áö¸¦ ¾Ë·ÁÁÜ
  118.  
  119. int gPlayerMaxLevel = 120;
  120.  
  121. bool g_BlockCharCreation = false;
  122.  
  123. bool g_bEnableNewKingdomForWolfman = true; // Wolfman character is born in self kingdom if you are disable this command.
  124.  
  125. template <int XORSTART, int BUFLEN, int XREFKILLER>
  126.  
  127. class XorStr
  128. {
  129. private:
  130. XorStr();
  131. public:
  132. char s[BUFLEN];
  133.  
  134. XorStr(const char * xs);
  135.  
  136. ~XorStr()
  137. {
  138. for (int i = 0; i < BUFLEN; i++) s[i] = 0;
  139. }
  140. };
  141.  
  142. template <int XORSTART, int BUFLEN, int XREFKILLER>
  143. XorStr<XORSTART, BUFLEN, XREFKILLER>::XorStr(const char * xs)
  144. {
  145. int xvalue = XORSTART;
  146. int i = 0;
  147.  
  148. for (; i < (BUFLEN - 1); i++)
  149. {
  150. s[i] = xs[i - XREFKILLER] ^ xvalue;
  151. xvalue += 1;
  152. xvalue %= 256;
  153. }
  154.  
  155. s[BUFLEN - 1] = 0;
  156. }
  157.  
  158. std::string LoginKey = /*ROHAN2LOGINKEYDFASDFASDFASTESTTESTTEST111222KKKOMERSIKER*/XorStr<0x86,57,0xA98FC2B6>("\xD4\xC8\xC0\xC8\xC4\xB9\xC0\xC2\xC9\xC6\xDE\xDA\xD7\xCA\xD0\xD3\xD7\xC4\xDC\xDF\xDB\xC8\xD8\xDB\xDF\xCC\xF4\xE4\xF1\xF7\xF0\xE0\xF5\xF3\xFC\xEC\xF9\xFF\x9D\x9C\x9F\x9D\x82\x83\xF9\xF8\xFF\xFA\xFB\xF2\xEA\xEA\xF3\xF0\xF9\xEF"+0xA98FC2B6).s;
  159.  
  160. bool is_string_true(const char * string)
  161. {
  162. bool result = 0;
  163. if (isnhdigit(*string))
  164. {
  165. str_to_number(result, string);
  166. return result > 0 ? true : false;
  167. }
  168. else if (LOWER(*string) == 't')
  169. return true;
  170. else
  171. return false;
  172. }
  173.  
  174. static std::set<int> s_set_map_allows;
  175.  
  176. bool map_allow_find(int index)
  177. {
  178. if (g_bAuthServer)
  179. return false;
  180.  
  181. if (s_set_map_allows.find(index) == s_set_map_allows.end())
  182. return false;
  183.  
  184. return true;
  185. }
  186.  
  187. void map_allow_log()
  188. {
  189. std::set<int>::iterator i;
  190.  
  191. for (i = s_set_map_allows.begin(); i != s_set_map_allows.end(); ++i)
  192. sys_log(0, "MAP_ALLOW: %d", *i);
  193. }
  194.  
  195. void map_allow_add(int index)
  196. {
  197. if (map_allow_find(index) == true)
  198. {
  199. fprintf(stdout, "!!! FATAL ERROR !!! multiple MAP_ALLOW setting!!\n");
  200. exit(1);
  201. }
  202.  
  203. fprintf(stdout, "MAP ALLOW %d\n", index);
  204. s_set_map_allows.insert(index);
  205. }
  206.  
  207. void map_allow_copy(long * pl, int size)
  208. {
  209. int iCount = 0;
  210. std::set<int>::iterator it = s_set_map_allows.begin();
  211.  
  212. while (it != s_set_map_allows.end())
  213. {
  214. int i = *(it++);
  215. *(pl++) = i;
  216.  
  217. if (++iCount > size)
  218. break;
  219. }
  220. }
  221.  
  222. #ifdef __MOUNT_SYSTEM__
  223. bool Mount_map_unallowed_find(int idx)
  224. {
  225. if (g_bAuthServer)
  226. return false;
  227.  
  228. if (s_Mount_map_unallowed_find.find(idx) == s_Mount_map_unallowed_find.end())
  229. return false;
  230.  
  231. return true;
  232. }
  233.  
  234. void Mount_map_unallowed_add(int idx)
  235. {
  236. if (Mount_map_unallowed_find(idx) == true)
  237. fprintf(stdout, "<Mount System> Error: there are multiple settings. Map index: %d\n", idx);
  238. else
  239. {
  240. fprintf(stdout, "<Mount System> Unallowed map index: %d\n", idx);
  241. s_Mount_map_unallowed_find.insert(idx);
  242. }
  243. }
  244. #endif
  245.  
  246. static void FN_add_adminpageIP(char *line)
  247. {
  248. char *last;
  249. const char *delim = " \t\r\n";
  250. char *v = strtok_r(line, delim, &last);
  251.  
  252. while (v)
  253. {
  254. g_stAdminPageIP.push_back(v);
  255. v = strtok_r(NULL, delim, &last);
  256. }
  257. }
  258.  
  259. static void FN_log_adminpage()
  260. {
  261. itertype(g_stAdminPageIP) iter = g_stAdminPageIP.begin();
  262.  
  263. while (iter != g_stAdminPageIP.end())
  264. {
  265. dev_log(LOG_DEB0, "ADMIN_PAGE_IP = %s", (*iter).c_str());
  266. ++iter;
  267. }
  268.  
  269. dev_log(LOG_DEB0, "ADMIN_PAGE_PASSWORD = %s", g_stAdminPagePassword.c_str());
  270. }
  271.  
  272. bool GetIPInfo()
  273. {
  274. #ifndef __WIN32__
  275. struct ifaddrs* ifaddrp = NULL;
  276.  
  277. if (0 != getifaddrs(&ifaddrp))
  278. return false;
  279.  
  280. for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
  281. {
  282. struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;
  283.  
  284. if (!ifap->ifa_netmask || // ignore if no netmask
  285. sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
  286. sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
  287. continue;
  288. #else
  289. WSADATA wsa_data;
  290. char host_name[100];
  291. HOSTENT* host_ent;
  292. int n = 0;
  293.  
  294. if (WSAStartup(0x0101, &wsa_data)) {
  295. return false;
  296. }
  297.  
  298. gethostname(host_name, sizeof(host_name));
  299. host_ent = gethostbyname(host_name);
  300. if (host_ent == NULL) {
  301. return false;
  302. }
  303. for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
  304. struct sockaddr_in addr;
  305. struct sockaddr_in* sai = &addr;
  306. memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
  307. #endif
  308.  
  309. char * netip = inet_ntoa(sai->sin_addr);
  310.  
  311. if (!strncmp(netip, "999.999", 7)) // ignore if address is starting with 192
  312. {
  313. strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
  314. #ifndef __WIN32__
  315. fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
  316. #else
  317. fprintf(stderr, "INTERNAL_IP: %s\n", netip);
  318. #endif
  319. }
  320. else if (!strncmp(netip, "10.", 3))
  321. {
  322. strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
  323. #ifndef __WIN32__
  324. fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
  325. #else
  326. fprintf(stderr, "INTERNAL_IP: %s\n", netip);
  327. #endif
  328. }
  329. else if (g_szPublicIP[0] == '0')
  330. {
  331. strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
  332. #ifndef __WIN32__
  333. fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name);
  334. #else
  335. fprintf(stderr, "PUBLIC_IP: %s\n", netip);
  336. #endif
  337. }
  338. }
  339.  
  340. #ifndef __WIN32__
  341. freeifaddrs( ifaddrp );
  342. #else
  343. WSACleanup();
  344. #endif
  345.  
  346. if (g_szPublicIP[0] != '0')
  347. return true;
  348. else
  349. {
  350. if (g_szInternalIP[0] == '0')
  351. return false;
  352. else
  353. strlcpy(g_szPublicIP, g_szInternalIP, sizeof(g_szPublicIP));
  354. return true;
  355. }
  356. }
  357.  
  358. #ifdef OFFLINE_SHOP
  359. std::map<DWORD, DWORD> g_ShopIndexCount;
  360. std::map<int, TShopCost> g_ShopCosts;
  361. #include <boost/algorithm/string.hpp>
  362. void LoadShopConfig()
  363. {
  364. SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT `id`,`time`,`time_type`+0,`cost` from shop_cost"));
  365. SQLResult * pRes = pkMsg->Get();
  366. if (pRes->uiNumRows)
  367. {
  368. MYSQL_ROW row;
  369. g_ShopIndexCount.clear();
  370. while ((row = mysql_fetch_row(pRes->pSQLResult)))
  371. {
  372. int id;
  373. str_to_number(id, row[0]);
  374. TShopCost c;
  375. str_to_number(c.days, row[1]);
  376. BYTE type;
  377. str_to_number(type, row[2]);
  378. if (type == 1)
  379. c.time = 86400;
  380. else if (type == 2)
  381. c.time = 3600;
  382. else
  383. c.time = 0;
  384. str_to_number(c.price, row[3]);
  385. g_ShopCosts[id] = c;
  386. }
  387. }
  388. const DESC_MANAGER::DESC_SET & set = DESC_MANAGER::instance().GetClientSet();
  389. DESC_MANAGER::DESC_SET::const_iterator it = set.begin();
  390.  
  391. while (it != set.end())
  392. {
  393. LPDESC d = *(it++);
  394.  
  395. if (!d->GetCharacter())
  396. continue;
  397. d->GetCharacter()->SendShopCost();
  398. }
  399.  
  400. }
  401. void LoadIndexShopLimit()
  402. {
  403. SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT map_index,shop_limit from `shop_limit` where channel=%d or channel=0", g_bChannel));
  404. SQLResult * pRes = pkMsg->Get();
  405. if (pRes->uiNumRows)
  406. {
  407. MYSQL_ROW row;
  408. g_ShopIndexCount.clear();
  409. while ((row = mysql_fetch_row(pRes->pSQLResult)))
  410. {
  411.  
  412. int index, limit;
  413. str_to_number(index, row[0]);
  414. str_to_number(limit, row[1]);
  415. if (!map_allow_find(index))
  416. continue;
  417. g_ShopIndexCount.insert(std::make_pair(index,limit));
  418. sys_log(0, "Shop Map %d limit %d\n", index, limit);
  419. }
  420. }
  421. fprintf(stdout, "\n");
  422.  
  423.  
  424. }
  425. #endif
  426.  
  427. void config_init(const string& st_localeServiceName)
  428. {
  429. FILE *fp;
  430.  
  431. char buf[256];
  432. char token_string[256];
  433. char value_string[256];
  434.  
  435. // LOCALE_SERVICE
  436. string st_configFileName;
  437.  
  438. st_configFileName.reserve(32);
  439. st_configFileName = "CONFIG";
  440.  
  441. if (!st_localeServiceName.empty())
  442. {
  443. st_configFileName += ".";
  444. st_configFileName += st_localeServiceName;
  445. }
  446. // END_OF_LOCALE_SERVICE
  447.  
  448. if (!(fp = fopen(st_configFileName.c_str(), "r")))
  449. {
  450. fprintf(stderr, "Can not open [%s]\n", st_configFileName.c_str());
  451. exit(1);
  452. }
  453.  
  454. if (!GetIPInfo())
  455. {
  456. fprintf(stderr, "Can not get public ip address\n");
  457. exit(1);
  458. }
  459.  
  460. //std::string chararraytostring = g_szPublicIP;
  461. //std::string lisans1 = /*192.168.1.24*/XorStr<0x8D,14,0xD3FC84D9>("\xBC\xB7\xBD\xBE\xA0\xA4\xAB\xBA\xA4\xB8\xA6\xA9\xA9"+0xD3FC84D9).s;
  462. //std::string lisans2 = /*185.50.69.242*/XorStr<0xEA,14,0x93B7472D>("\xDB\xD3\xD9\xC3\xDB\xDF\xDE\xC7\xCB\xDD\xC6\xC1\xC4"+0x93B7472D).s;
  463. //std::string m1 = /*Lisans Durumu : Aktif Edildi. / Rohan2Global Server Files*/XorStr<0x0E,58,0x49B88CD4>("\x42\x66\x63\x70\x7C\x60\x34\x51\x63\x65\x6D\x74\x6F\x3B\x26\x3D\x5F\x74\x54\x48\x44\x03\x61\x41\x4F\x4B\x4C\x40\x04\x0B\x03\x0D\x7C\x40\x58\x50\x5C\x01\x73\x59\x59\x55\x59\x55\x1A\x68\x59\x4F\x48\x5A\x32\x61\x04\x2A\x28\x20\x35"+0x49B88CD4).s;
  464. //std::string m2 = /*Lisans Durumu : Gecersiz. / Rohan2Global Server Files*/XorStr<0x56,54,0x7B3DF7E2>("\x1A\x3E\x2B\x38\x34\x28\x7C\x19\x2B\x2D\x15\x0C\x17\x43\x5E\x45\x21\x02\x0B\x0C\x18\x18\x05\x17\x40\x4F\x5F\x51\x20\x1C\x1C\x14\x18\x45\x3F\x15\x15\x19\x1D\x11\x5E\x2C\xE5\xF3\xF4\xE6\xF6\xA5\xC0\xEE\xE4\xEC\xF9"+0x7B3DF7E2).s;
  465.  
  466. //if (chararraytostring.find(lisans1.c_str()) != std::string::npos ||
  467. // chararraytostring.find(lisans2.c_str()) != std::string::npos)
  468. //{
  469. // printf("%s%s\n",m1.c_str(), chararraytostring.c_str());
  470. //}
  471. //else
  472. //{
  473. // printf("%s", m2.c_str());
  474. // exit(1);
  475. // return;
  476. //}
  477.  
  478. char db_host[2][64], db_user[2][64], db_pwd[2][64], db_db[2][64];
  479. // ... ¾Æ... db_port´Â ÀÌ¹Ì Àִµ¥... ³×ÀÌ¹Ö ¾îÂîÇؾßÇÔ...
  480. int mysql_db_port[2];
  481.  
  482. for (int n = 0; n < 2; ++n)
  483. {
  484. *db_host[n] = '\0';
  485. *db_user[n] = '\0';
  486. *db_pwd[n]= '\0';
  487. *db_db[n]= '\0';
  488. mysql_db_port[n] = 0;
  489. }
  490.  
  491. char log_host[64], log_user[64], log_pwd[64], log_db[64];
  492. int log_port = 0;
  493.  
  494. *log_host = '\0';
  495. *log_user = '\0';
  496. *log_pwd = '\0';
  497. *log_db = '\0';
  498.  
  499.  
  500. // DB¿¡¼­ ·ÎÄÉÀÏÁ¤º¸¸¦ ¼¼ÆÃÇϱâÀ§Çؼ­´Â ´Ù¸¥ ¼¼Æ𪺸´Ù ¼±ÇàµÇ¾î¼­
  501. // DBÁ¤º¸¸¸ Àоî¿Í ·ÎÄÉÀÏ ¼¼ÆÃÀ» ÇÑÈÄ ´Ù¸¥ ¼¼ÆÃÀ» Àû¿ë½ÃÄѾßÇÑ´Ù.
  502. // ÀÌÀ¯´Â ·ÎÄÉÀÏ°ü·ÃµÈ ÃʱâÈ­ ·çƾÀÌ °÷°÷¿¡ Á¸ÀçÇϱ⠶§¹®.
  503.  
  504. bool isCommonSQL = false;
  505. bool isPlayerSQL = false;
  506.  
  507. FILE* fpOnlyForDB;
  508.  
  509. if (!(fpOnlyForDB = fopen(st_configFileName.c_str(), "r")))
  510. {
  511. fprintf(stderr, "Can not open [%s]\n", st_configFileName.c_str());
  512. exit(1);
  513. }
  514.  
  515. while (fgets(buf, 256, fpOnlyForDB))
  516. {
  517. parse_token(buf, token_string, value_string);
  518.  
  519. TOKEN("BLOCK_LOGIN")
  520. {
  521. g_stBlockDate = value_string;
  522. }
  523.  
  524. TOKEN("adminpage_ip")
  525. {
  526. FN_add_adminpageIP(value_string);
  527. //g_stAdminPageIP[0] = value_string;
  528. }
  529.  
  530. TOKEN("adminpage_ip1")
  531. {
  532. FN_add_adminpageIP(value_string);
  533. //g_stAdminPageIP[0] = value_string;
  534. }
  535.  
  536. TOKEN("adminpage_ip2")
  537. {
  538. FN_add_adminpageIP(value_string);
  539. //g_stAdminPageIP[1] = value_string;
  540. }
  541.  
  542. TOKEN("adminpage_ip3")
  543. {
  544. FN_add_adminpageIP(value_string);
  545. //g_stAdminPageIP[2] = value_string;
  546. }
  547.  
  548. TOKEN("adminpage_password")
  549. {
  550. g_stAdminPagePassword = value_string;
  551. }
  552.  
  553. TOKEN("hostname")
  554. {
  555. g_stHostname = value_string;
  556. fprintf(stdout, "HOSTNAME: %s\n", g_stHostname.c_str());
  557. continue;
  558. }
  559.  
  560. TOKEN("channel")
  561. {
  562. str_to_number(g_bChannel, value_string);
  563. continue;
  564. }
  565.  
  566. TOKEN("player_sql")
  567. {
  568. const char * line = two_arguments(value_string, db_host[0], sizeof(db_host[0]), db_user[0], sizeof(db_user[0]));
  569. line = two_arguments(line, db_pwd[0], sizeof(db_pwd[0]), db_db[0], sizeof(db_db[0]));
  570.  
  571. if (NULL != line[0])
  572. {
  573. char buf[256];
  574. one_argument(line, buf, sizeof(buf));
  575. str_to_number(mysql_db_port[0], buf);
  576. }
  577.  
  578. if (!*db_host[0] || !*db_user[0] || !*db_pwd[0] || !*db_db[0])
  579. {
  580. fprintf(stderr, "PLAYER_SQL syntax: logsql <host user password db>\n");
  581. exit(1);
  582. }
  583.  
  584. char buf[1024];
  585. snprintf(buf, sizeof(buf), "PLAYER_SQL: %s %s %s %s %d", db_host[0], db_user[0], db_pwd[0], db_db[0], mysql_db_port[0]);
  586. isPlayerSQL = true;
  587. continue;
  588. }
  589.  
  590. TOKEN("common_sql")
  591. {
  592. const char * line = two_arguments(value_string, db_host[1], sizeof(db_host[1]), db_user[1], sizeof(db_user[1]));
  593. line = two_arguments(line, db_pwd[1], sizeof(db_pwd[1]), db_db[1], sizeof(db_db[1]));
  594.  
  595. if (NULL != line[0])
  596. {
  597. char buf[256];
  598. one_argument(line, buf, sizeof(buf));
  599. str_to_number(mysql_db_port[1], buf);
  600. }
  601.  
  602. if (!*db_host[1] || !*db_user[1] || !*db_pwd[1] || !*db_db[1])
  603. {
  604. fprintf(stderr, "COMMON_SQL syntax: logsql <host user password db>\n");
  605. exit(1);
  606. }
  607.  
  608. char buf[1024];
  609. snprintf(buf, sizeof(buf), "COMMON_SQL: %s %s %s %s %d", db_host[1], db_user[1], db_pwd[1], db_db[1], mysql_db_port[1]);
  610. isCommonSQL = true;
  611. continue;
  612. }
  613.  
  614. TOKEN("log_sql")
  615. {
  616. const char * line = two_arguments(value_string, log_host, sizeof(log_host), log_user, sizeof(log_user));
  617. line = two_arguments(line, log_pwd, sizeof(log_pwd), log_db, sizeof(log_db));
  618.  
  619. if (NULL != line[0])
  620. {
  621. char buf[256];
  622. one_argument(line, buf, sizeof(buf));
  623. str_to_number(log_port, buf);
  624. }
  625.  
  626. if (!*log_host || !*log_user || !*log_pwd || !*log_db)
  627. {
  628. fprintf(stderr, "LOG_SQL syntax: logsql <host user password db>\n");
  629. exit(1);
  630. }
  631.  
  632. char buf[1024];
  633. snprintf(buf, sizeof(buf), "LOG_SQL: %s %s %s %s %d", log_host, log_user, log_pwd, log_db, log_port);
  634. continue;
  635. }
  636. }
  637.  
  638. //󸮰¡ ³¡³µÀ¸´Ï ÆÄÀÏÀ» ´İÀÚ.
  639. fclose(fpOnlyForDB);
  640.  
  641. // CONFIG_SQL_INFO_ERROR
  642. if (!isCommonSQL)
  643. {
  644. puts("LOAD_COMMON_SQL_INFO_FAILURE:");
  645. puts("");
  646. puts("CONFIG:");
  647. puts("------------------------------------------------");
  648. puts("COMMON_SQL: HOST USER PASSWORD DATABASE");
  649. puts("");
  650. exit(1);
  651. }
  652.  
  653. if (!isPlayerSQL)
  654. {
  655. puts("LOAD_PLAYER_SQL_INFO_FAILURE:");
  656. puts("");
  657. puts("CONFIG:");
  658. puts("------------------------------------------------");
  659. puts("PLAYER_SQL: HOST USER PASSWORD DATABASE");
  660. puts("");
  661. exit(1);
  662. }
  663.  
  664. // Common DB °¡ Locale Á¤º¸¸¦ °¡Áö°í Àֱ⠶§¹®¿¡ °¡Àå ¸ÕÀú Á¢¼ÓÇØ¾ß ÇÑ´Ù.
  665. AccountDB::instance().Connect(db_host[1], mysql_db_port[1], db_user[1], db_pwd[1], db_db[1]);
  666.  
  667. if (false == AccountDB::instance().IsConnected())
  668. {
  669. fprintf(stderr, "cannot start server while no common sql connected\n");
  670. exit(1);
  671. }
  672.  
  673. fprintf(stdout, "CommonSQL connected\n");
  674.  
  675. // ·ÎÄÉÀÏ Á¤º¸¸¦ °¡Á®¿ÀÀÚ
  676. // <°æ°í> Äõ¸®¹®¿¡ Àı´ë Á¶°Ç¹®(WHERE) ´ŞÁö ¸¶¼¼¿ä. (´Ù¸¥ Áö¿ª¿¡¼­ ¹®Á¦°¡ »ı±æ¼ö ÀÖ½À´Ï´Ù)
  677. {
  678. char szQuery[512];
  679. snprintf(szQuery, sizeof(szQuery), "SELECT mKey, mValue FROM locale");
  680.  
  681. std::unique_ptr<SQLMsg> pMsg(AccountDB::instance().DirectQuery(szQuery));
  682.  
  683. if (pMsg->Get()->uiNumRows == 0)
  684. {
  685. fprintf(stderr, "COMMON_SQL: DirectQuery failed : %s\n", szQuery);
  686. exit(1);
  687. }
  688.  
  689. MYSQL_ROW row;
  690.  
  691. while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
  692. {
  693. // ·ÎÄÉÀÏ ¼¼ÆÃ
  694. if (strcasecmp(row[0], "LOCALE") == 0)
  695. {
  696. if (LocaleService_Init(row[1]) == false)
  697. {
  698. fprintf(stderr, "COMMON_SQL: invalid locale key %s\n", row[1]);
  699. exit(1);
  700. }
  701. }
  702. }
  703. }
  704.  
  705. // ·ÎÄÉÀÏ Á¤º¸¸¦ COMMON SQL¿¡ ¼¼ÆÃÇØÁØ´Ù.
  706. // Âü°í·Î g_stLocale Á¤º¸´Â LocaleService_Init() ³»ºÎ¿¡¼­ ¼¼ÆõȴÙ.
  707. fprintf(stdout, "Setting DB to locale %s\n", g_stLocale.c_str());
  708.  
  709. AccountDB::instance().SetLocale(g_stLocale);
  710.  
  711. AccountDB::instance().ConnectAsync(db_host[1], mysql_db_port[1], db_user[1], db_pwd[1], db_db[1], g_stLocale.c_str());
  712.  
  713. // Player DB Á¢¼Ó
  714. DBManager::instance().Connect(db_host[0], mysql_db_port[0], db_user[0], db_pwd[0], db_db[0]);
  715.  
  716. if (!DBManager::instance().IsConnected())
  717. {
  718. fprintf(stderr, "PlayerSQL.ConnectError\n");
  719. exit(1);
  720. }
  721.  
  722. fprintf(stdout, "PlayerSQL connected\n");
  723.  
  724. if (false == g_bAuthServer) // ÀÎÁõ ¼­¹ö°¡ ¾Æ´Ò °æ¿ì
  725. {
  726. // Log DB Á¢¼Ó
  727. LogManager::instance().Connect(log_host, log_port, log_user, log_pwd, log_db);
  728.  
  729. if (!LogManager::instance().IsConnected())
  730. {
  731. fprintf(stderr, "LogSQL.ConnectError\n");
  732. exit(1);
  733. }
  734.  
  735. fprintf(stdout, "LogSQL connected\n");
  736.  
  737. LogManager::instance().BootLog(g_stHostname.c_str(), g_bChannel);
  738. }
  739.  
  740. // SKILL_POWER_BY_LEVEL
  741. // ½ºÆ®¸µ ºñ±³ÀÇ ¹®Á¦·Î ÀÎÇؼ­ AccountDB::instance().SetLocale(g_stLocale) ÈĺÎÅÍ ÇÑ´Ù.
  742. // ¹°·Ğ ±¹³»´Â º°·Î ¹®Á¦°¡ ¾ÈµÈ´Ù(ÇØ¿Ü°¡ ¹®Á¦)
  743. {
  744. char szQuery[256];
  745. snprintf(szQuery, sizeof(szQuery), "SELECT mValue FROM locale WHERE mKey='SKILL_POWER_BY_LEVEL'");
  746. std::unique_ptr<SQLMsg> pMsg(AccountDB::instance().DirectQuery(szQuery));
  747.  
  748. if (pMsg->Get()->uiNumRows == 0)
  749. {
  750. fprintf(stderr, "[SKILL_PERCENT] Query failed: %s", szQuery);
  751. exit(1);
  752. }
  753.  
  754. MYSQL_ROW row;
  755.  
  756. row = mysql_fetch_row(pMsg->Get()->pSQLResult);
  757.  
  758. const char * p = row[0];
  759. int cnt = 0;
  760. char num[128];
  761. int aiBaseSkillPowerByLevelTable[SKILL_MAX_LEVEL+1];
  762.  
  763. //fprintf(stdout, "SKILL_POWER_BY_LEVEL %s\n", p);
  764. while (*p != '\0' && cnt < (SKILL_MAX_LEVEL + 1))
  765. {
  766. p = one_argument(p, num, sizeof(num));
  767. aiBaseSkillPowerByLevelTable[cnt++] = atoi(num);
  768.  
  769. //fprintf(stdout, "%d %d\n", cnt - 1, aiBaseSkillPowerByLevelTable[cnt - 1]);
  770. if (*p == '\0')
  771. {
  772. if (cnt != (SKILL_MAX_LEVEL + 1))
  773. {
  774. fprintf(stderr, "[SKILL_PERCENT] locale table has not enough skill information! (count: %d query: %s)", cnt, szQuery);
  775. exit(1);
  776. }
  777.  
  778. fprintf(stdout, "SKILL_POWER_BY_LEVEL: Done! (count %d)\n", cnt);
  779. break;
  780. }
  781. }
  782.  
  783. // Á¾Á·º° ½ºÅ³ ¼¼ÆÃ
  784. for (int job = 0; job < JOB_MAX_NUM * 2; ++job)
  785. {
  786. snprintf(szQuery, sizeof(szQuery), "SELECT mValue from locale where mKey='SKILL_POWER_BY_LEVEL_TYPE%d' ORDER BY CAST(mValue AS unsigned)", job);
  787. std::unique_ptr<SQLMsg> pMsg(AccountDB::instance().DirectQuery(szQuery));
  788.  
  789. // ¼¼ÆÃÀÌ ¾ÈµÇ¾îÀÖÀ¸¸é ±âº»Å×À̺íÀ» »ç¿ëÇÑ´Ù.
  790. if (pMsg->Get()->uiNumRows == 0)
  791. {
  792. CTableBySkill::instance().SetSkillPowerByLevelFromType(job, aiBaseSkillPowerByLevelTable);
  793. continue;
  794. }
  795.  
  796. row = mysql_fetch_row(pMsg->Get()->pSQLResult);
  797. cnt = 0;
  798. p = row[0];
  799. int aiSkillTable[SKILL_MAX_LEVEL + 1];
  800.  
  801. //fprintf(stdout, "SKILL_POWER_BY_JOB %d %s\n", job, p);
  802. while (*p != '\0' && cnt < (SKILL_MAX_LEVEL + 1))
  803. {
  804. p = one_argument(p, num, sizeof(num));
  805. aiSkillTable[cnt++] = atoi(num);
  806.  
  807. //fprintf(stdout, "%d %d\n", cnt - 1, aiBaseSkillPowerByLevelTable[cnt - 1]);
  808. if (*p == '\0')
  809. {
  810. if (cnt != (SKILL_MAX_LEVEL + 1))
  811. {
  812. fprintf(stderr, "[SKILL_PERCENT] locale table has not enough skill information! (count: %d query: %s)", cnt, szQuery);
  813. exit(1);
  814. }
  815.  
  816. fprintf(stdout, "SKILL_POWER_BY_JOB: Done! (job: %d count: %d)\n", job, cnt);
  817. break;
  818. }
  819. }
  820.  
  821. CTableBySkill::instance().SetSkillPowerByLevelFromType(job, aiSkillTable);
  822. }
  823. }
  824. // END_SKILL_POWER_BY_LEVEL
  825.  
  826. // LOG_KEEP_DAYS_EXTEND
  827. log_set_expiration_days(2);
  828. // END_OF_LOG_KEEP_DAYS_EXTEND
  829.  
  830. while (fgets(buf, 256, fp))
  831. {
  832. parse_token(buf, token_string, value_string);
  833.  
  834. TOKEN("empire_whisper")
  835. {
  836. bool b_value = 0;
  837. str_to_number(b_value, value_string);
  838. g_bEmpireWhisper = !!b_value;
  839. continue;
  840. }
  841.  
  842. TOKEN("mark_server")
  843. {
  844. guild_mark_server = is_string_true(value_string);
  845. continue;
  846. }
  847.  
  848. TOKEN("mark_min_level")
  849. {
  850. str_to_number(guild_mark_min_level, value_string);
  851. guild_mark_min_level = MINMAX(0, guild_mark_min_level, GUILD_MAX_LEVEL);
  852. continue;
  853. }
  854.  
  855. TOKEN("port")
  856. {
  857. str_to_number(mother_port, value_string);
  858. continue;
  859. }
  860.  
  861. TOKEN("log_keep_days")
  862. {
  863. int i = 0;
  864. str_to_number(i, value_string);
  865. log_set_expiration_days(MINMAX(1, i, 90));
  866. continue;
  867. }
  868.  
  869. TOKEN("passes_per_sec")
  870. {
  871. str_to_number(passes_per_sec, value_string);
  872. continue;
  873. }
  874.  
  875. TOKEN("p2p_port")
  876. {
  877. str_to_number(p2p_port, value_string);
  878. continue;
  879. }
  880.  
  881. TOKEN("db_port")
  882. {
  883. str_to_number(db_port, value_string);
  884. continue;
  885. }
  886.  
  887. TOKEN("db_addr")
  888. {
  889. strlcpy(db_addr, value_string, sizeof(db_addr));
  890.  
  891. for (int n =0; n < ADDRESS_MAX_LEN; ++n)
  892. {
  893. if (db_addr[n] == ' ')
  894. db_addr[n] = '\0';
  895. }
  896.  
  897. continue;
  898. }
  899.  
  900. TOKEN("save_event_second_cycle")
  901. {
  902. int cycle = 0;
  903. str_to_number(cycle, value_string);
  904. save_event_second_cycle = cycle * passes_per_sec;
  905. continue;
  906. }
  907.  
  908. TOKEN("ping_event_second_cycle")
  909. {
  910. int cycle = 0;
  911. str_to_number(cycle, value_string);
  912. ping_event_second_cycle = cycle * passes_per_sec;
  913. continue;
  914. }
  915.  
  916. TOKEN("table_postfix")
  917. {
  918. g_table_postfix = value_string;
  919. continue;
  920. }
  921.  
  922. TOKEN("test_server")
  923. {
  924. printf("\033[32m-----------------------------------------------\n");
  925. printf("\033[32mBEST Production Game Versiyon: 40250 [YAKUP POLAT]\n");
  926. printf("\033[32m-----------------------------------------------\n");
  927. str_to_number(test_server, value_string);
  928. continue;
  929. }
  930.  
  931. TOKEN("speed_server")
  932. {
  933. printf("\033[32m-----------------------------------------------\n");
  934. printf("\033[32mBEST Production Game Versiyon: 40250 [YAKUP POLAT]\n");
  935. printf("\033[32m-----------------------------------------------\n");
  936. str_to_number(speed_server, value_string);
  937. continue;
  938. }
  939. TOKEN("distribution_test_server")
  940. {
  941. str_to_number(distribution_test_server, value_string);
  942. continue;
  943. }
  944.  
  945. TOKEN("china_event_server")
  946. {
  947. str_to_number(china_event_server, value_string);
  948. continue;
  949. }
  950.  
  951. TOKEN("shutdowned")
  952. {
  953. g_bNoMoreClient = true;
  954. continue;
  955. }
  956.  
  957. TOKEN("no_regen")
  958. {
  959. g_bNoRegen = true;
  960. continue;
  961. }
  962.  
  963. #ifdef __MOUNT_SYSTEM__
  964. TOKEN("MOUNT_MAP_UNALLOWED")
  965. {
  966. char * p = value_string;
  967. string stNum;
  968. for (; *p; p++)
  969. {
  970. if (isnhspace(*p))
  971. {
  972. if (stNum.length())
  973. {
  974. int idx = 0;
  975. str_to_number(idx, stNum.c_str());
  976. Mount_map_unallowed_add(idx);
  977. stNum.clear();
  978. }
  979. }
  980. else
  981. stNum += *p;
  982. }
  983.  
  984. if (stNum.length())
  985. {
  986. int idx = 0;
  987. str_to_number(idx, stNum.c_str());
  988. Mount_map_unallowed_add(idx);
  989. }
  990.  
  991. continue;
  992. }
  993. #endif
  994. TOKEN("traffic_profile")
  995. {
  996. g_bTrafficProfileOn = true;
  997. continue;
  998. }
  999.  
  1000.  
  1001. TOKEN("map_allow")
  1002. {
  1003. char * p = value_string;
  1004. string stNum;
  1005.  
  1006. for (; *p; p++)
  1007. {
  1008. if (isnhspace(*p))
  1009. {
  1010. if (stNum.length())
  1011. {
  1012. int index = 0;
  1013. str_to_number(index, stNum.c_str());
  1014. map_allow_add(index);
  1015. stNum.clear();
  1016. }
  1017. }
  1018. else
  1019. stNum += *p;
  1020. }
  1021.  
  1022. if (stNum.length())
  1023. {
  1024. int index = 0;
  1025. str_to_number(index, stNum.c_str());
  1026. map_allow_add(index);
  1027. }
  1028.  
  1029. continue;
  1030. }
  1031.  
  1032. TOKEN("no_wander")
  1033. {
  1034. no_wander = true;
  1035. continue;
  1036. }
  1037.  
  1038. TOKEN("user_limit")
  1039. {
  1040. str_to_number(g_iUserLimit, value_string);
  1041. continue;
  1042. }
  1043.  
  1044. TOKEN("skill_disable")
  1045. {
  1046. str_to_number(g_bSkillDisable, value_string);
  1047. continue;
  1048. }
  1049.  
  1050. TOKEN("auth_server")
  1051. {
  1052. char szIP[32];
  1053. char szPort[32];
  1054.  
  1055. two_arguments(value_string, szIP, sizeof(szIP), szPort, sizeof(szPort));
  1056.  
  1057. if (!*szIP || (!*szPort && strcasecmp(szIP, "master")))
  1058. {
  1059. fprintf(stderr, "AUTH_SERVER: syntax error: <ip|master> <port>\n");
  1060. exit(1);
  1061. }
  1062.  
  1063. g_bAuthServer = true;
  1064.  
  1065. LoadBanIP("BANIP");
  1066.  
  1067. if (!strcasecmp(szIP, "master"))
  1068. fprintf(stdout, "BEST PRODUCTION SOURCE VERSION : 40250 \n");
  1069. else
  1070. {
  1071. g_stAuthMasterIP = szIP;
  1072. str_to_number(g_wAuthMasterPort, szPort);
  1073.  
  1074. fprintf(stdout, "AUTH_SERVER: master %s %u\n", g_stAuthMasterIP.c_str(), g_wAuthMasterPort);
  1075. }
  1076. continue;
  1077. }
  1078.  
  1079. TOKEN("quest_dir")
  1080. {
  1081. sys_log(0, "QUEST_DIR SETTING : %s", value_string);
  1082. g_stQuestDir = value_string;
  1083. }
  1084.  
  1085. TOKEN("quest_object_dir")
  1086. {
  1087. //g_stQuestObjectDir = value_string;
  1088. std::istringstream is(value_string);
  1089. sys_log(0, "QUEST_OBJECT_DIR SETTING : %s", value_string);
  1090. string dir;
  1091. while (!is.eof())
  1092. {
  1093. is >> dir;
  1094. if (is.fail())
  1095. break;
  1096. g_setQuestObjectDir.insert(dir);
  1097. sys_log(0, "QUEST_OBJECT_DIR INSERT : %s", dir .c_str());
  1098. }
  1099. }
  1100.  
  1101. TOKEN("synchack_limit_count")
  1102. {
  1103. str_to_number(g_iSyncHackLimitCount, value_string);
  1104. }
  1105.  
  1106. TOKEN("speedhack_limit_count")
  1107. {
  1108. str_to_number(SPEEDHACK_LIMIT_COUNT, value_string);
  1109. }
  1110.  
  1111. TOKEN("speedhack_limit_bonus")
  1112. {
  1113. str_to_number(SPEEDHACK_LIMIT_BONUS, value_string);
  1114. }
  1115.  
  1116. TOKEN("server_id")
  1117. {
  1118. str_to_number(g_server_id, value_string);
  1119. }
  1120.  
  1121. TOKEN("mall_url")
  1122. {
  1123. g_strWebMallURL = value_string;
  1124. }
  1125.  
  1126. TOKEN("PUBLIC_IP")
  1127. {
  1128. strlcpy(g_szPublicIP, value_string, sizeof(g_szPublicIP));
  1129. }
  1130.  
  1131. TOKEN("SHOP_SERVER_ID")
  1132. {
  1133. str_to_number(g_server_id, value_string);
  1134. }
  1135.  
  1136. TOKEN("SHOP_URL")
  1137. {
  1138. g_strWebMallURL = value_string;
  1139. }
  1140.  
  1141. TOKEN("view_range")
  1142. {
  1143. str_to_number(VIEW_RANGE, value_string);
  1144. }
  1145.  
  1146. TOKEN("spam_block_duration")
  1147. {
  1148. str_to_number(g_uiSpamBlockDuration, value_string);
  1149. }
  1150.  
  1151. TOKEN("spam_block_score")
  1152. {
  1153. str_to_number(g_uiSpamBlockScore, value_string);
  1154. g_uiSpamBlockScore = MAX(1, g_uiSpamBlockScore);
  1155. }
  1156.  
  1157. TOKEN("spam_block_reload_cycle")
  1158. {
  1159. str_to_number(g_uiSpamReloadCycle, value_string);
  1160. g_uiSpamReloadCycle = MAX(60, g_uiSpamReloadCycle); // ÃÖ¼Ò 1ºĞ
  1161. }
  1162.  
  1163. TOKEN("check_multihack")
  1164. {
  1165. str_to_number(g_bCheckMultiHack, value_string);
  1166. }
  1167.  
  1168. TOKEN("spam_block_max_level")
  1169. {
  1170. str_to_number(g_iSpamBlockMaxLevel, value_string);
  1171. }
  1172. TOKEN("protect_normal_player")
  1173. {
  1174. str_to_number(g_protectNormalPlayer, value_string);
  1175. }
  1176. TOKEN("notice_battle_zone")
  1177. {
  1178. str_to_number(g_noticeBattleZone, value_string);
  1179. }
  1180.  
  1181. TOKEN("pk_protect_level")
  1182. {
  1183. str_to_number(PK_PROTECT_LEVEL, value_string);
  1184. fprintf(stderr, "PK_PROTECT_LEVEL: %d", PK_PROTECT_LEVEL);
  1185. }
  1186.  
  1187. TOKEN("max_level")
  1188. {
  1189. str_to_number(gPlayerMaxLevel, value_string);
  1190.  
  1191. gPlayerMaxLevel = MINMAX(1, gPlayerMaxLevel, PLAYER_MAX_LEVEL_CONST);
  1192.  
  1193. fprintf(stderr, "PLAYER_MAX_LEVEL: %d\n", gPlayerMaxLevel);
  1194. }
  1195.  
  1196. TOKEN("block_char_creation")
  1197. {
  1198. int tmp = 0;
  1199.  
  1200. str_to_number(tmp, value_string);
  1201.  
  1202. if (0 == tmp)
  1203. g_BlockCharCreation = false;
  1204. else
  1205. g_BlockCharCreation = true;
  1206.  
  1207. continue;
  1208. }
  1209.  
  1210. TOKEN("ENABLE_NEW_WOLFMAN")
  1211. {
  1212. str_to_number(g_bEnableNewKingdomForWolfman, value_string);
  1213. continue;
  1214. }
  1215. }
  1216.  
  1217. if (g_setQuestObjectDir.empty())
  1218. g_setQuestObjectDir.insert(g_stDefaultQuestObjectDir);
  1219.  
  1220. if (0 == db_port)
  1221. {
  1222. fprintf(stderr, "DB_PORT not configured\n");
  1223. exit(1);
  1224. }
  1225.  
  1226. if (0 == g_bChannel)
  1227. {
  1228. fprintf(stderr, "CHANNEL not configured\n");
  1229. exit(1);
  1230. }
  1231.  
  1232. if (g_stHostname.empty())
  1233. {
  1234. fprintf(stderr, "HOSTNAME must be configured.\n");
  1235. exit(1);
  1236. }
  1237.  
  1238. // LOCALE_SERVICE
  1239. LocaleService_LoadLocaleStringFile();
  1240. LocaleService_TransferDefaultSetting();
  1241. LocaleService_LoadEmpireTextConvertTables();
  1242. // END_OF_LOCALE_SERVICE
  1243.  
  1244. fclose(fp);
  1245.  
  1246. if ((fp = fopen("CMD", "r")))
  1247. {
  1248. while (fgets(buf, 256, fp))
  1249. {
  1250. char cmd[32], levelname[32];
  1251. int level;
  1252.  
  1253. two_arguments(buf, cmd, sizeof(cmd), levelname, sizeof(levelname));
  1254.  
  1255. if (!*cmd || !*levelname)
  1256. {
  1257. fprintf(stderr, "CMD syntax error: <cmd> <DISABLE | LOW_WIZARD | WIZARD | HIGH_WIZARD | GOD>\n");
  1258. exit(1);
  1259. }
  1260.  
  1261. if (!strcasecmp(levelname, "LOW_WIZARD"))
  1262. level = GM_LOW_WIZARD;
  1263. else if (!strcasecmp(levelname, "WIZARD"))
  1264. level = GM_WIZARD;
  1265. else if (!strcasecmp(levelname, "HIGH_WIZARD"))
  1266. level = GM_HIGH_WIZARD;
  1267. else if (!strcasecmp(levelname, "GOD"))
  1268. level = GM_GOD;
  1269. else if (!strcasecmp(levelname, "IMPLEMENTOR"))
  1270. level = GM_IMPLEMENTOR;
  1271. else if (!strcasecmp(levelname, "DISABLE"))
  1272. level = GM_IMPLEMENTOR + 1;
  1273. else
  1274. {
  1275. fprintf(stderr, "CMD syntax error: <cmd> <DISABLE | LOW_WIZARD | WIZARD | HIGH_WIZARD | GOD>\n");
  1276. exit(1);
  1277. }
  1278.  
  1279. interpreter_set_privilege(cmd, level);
  1280. }
  1281.  
  1282. fclose(fp);
  1283. }
  1284.  
  1285. LoadValidCRCList();
  1286. LoadStateUserCount();
  1287. #ifdef OFFLINE_SHOP
  1288. LoadShopConfig();
  1289. LoadIndexShopLimit();
  1290. #endif
  1291.  
  1292. CWarMapManager::instance().LoadWarMapInfo(NULL);
  1293.  
  1294. FN_log_adminpage();
  1295. }
  1296.  
  1297. const char* get_table_postfix()
  1298. {
  1299. return g_table_postfix.c_str();
  1300. }
  1301.  
  1302. void LoadValidCRCList()
  1303. {
  1304. s_set_dwProcessCRC.clear();
  1305. s_set_dwFileCRC.clear();
  1306.  
  1307. FILE * fp;
  1308. char buf[256];
  1309.  
  1310. if ((fp = fopen("CRC", "r")))
  1311. {
  1312. while (fgets(buf, 256, fp))
  1313. {
  1314. if (!*buf)
  1315. continue;
  1316.  
  1317. DWORD dwValidClientProcessCRC;
  1318. DWORD dwValidClientFileCRC;
  1319.  
  1320. sscanf(buf, " %u %u ", &dwValidClientProcessCRC, &dwValidClientFileCRC);
  1321.  
  1322. s_set_dwProcessCRC.insert(dwValidClientProcessCRC);
  1323. s_set_dwFileCRC.insert(dwValidClientFileCRC);
  1324.  
  1325. fprintf(stderr, "CLIENT_CRC: %u %u\n", dwValidClientProcessCRC, dwValidClientFileCRC);
  1326. }
  1327.  
  1328. fclose(fp);
  1329. }
  1330. }
  1331.  
  1332. bool LoadClientVersion()
  1333. {
  1334. FILE * fp = fopen("CLIENT_VERSION", "r");
  1335.  
  1336. if (!fp)
  1337. return false;
  1338.  
  1339. char buf[256];
  1340. fgets(buf, 256, fp);
  1341.  
  1342. char * p = strchr(buf, '\n');
  1343. if (p) *p = '\0';
  1344.  
  1345. fprintf(stderr, "VERSION: \"%s\"\n", buf);
  1346.  
  1347. g_stClientVersion = buf;
  1348. fclose(fp);
  1349. return true;
  1350. }
  1351.  
  1352. void CheckClientVersion()
  1353. {
  1354. if (LC_IsEurope())
  1355. {
  1356. g_bCheckClientVersion = true;
  1357. }
  1358. else
  1359. {
  1360. g_bCheckClientVersion = false;
  1361. }
  1362.  
  1363. const DESC_MANAGER::DESC_SET & set = DESC_MANAGER::instance().GetClientSet();
  1364. DESC_MANAGER::DESC_SET::const_iterator it = set.begin();
  1365.  
  1366. while (it != set.end())
  1367. {
  1368. LPDESC d = *(it++);
  1369.  
  1370. if (!d->GetCharacter())
  1371. continue;
  1372.  
  1373.  
  1374. int version = atoi(g_stClientVersion.c_str());
  1375. int date = atoi(d->GetClientVersion() );
  1376.  
  1377. //if (0 != version.compare(d->GetClientVersion()) )
  1378. if (version != date)
  1379. {
  1380. d->GetCharacter()->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("Ŭ¶óÀ̾ğÆ® ¹öÀüÀÌ Æ²·Á ·Î±×¾Æ¿ô µË´Ï´Ù. Á¤»óÀûÀ¸·Î ÆĞÄ¡ ÈÄ Á¢¼ÓÇϼ¼¿ä."));
  1381. d->DelayedDisconnect(10);
  1382. }
  1383. }
  1384. }
  1385.  
  1386. void LoadStateUserCount()
  1387. {
  1388. FILE * fp = fopen("state_user_count", "r");
  1389.  
  1390. if (!fp)
  1391. return;
  1392.  
  1393. if (!LC_IsHongKong())
  1394. fscanf(fp, " %d %d ", &g_iFullUserCount, &g_iBusyUserCount);
  1395.  
  1396. fclose(fp);
  1397. }
  1398.  
  1399. bool IsValidProcessCRC(DWORD dwCRC)
  1400. {
  1401. return s_set_dwProcessCRC.find(dwCRC) != s_set_dwProcessCRC.end();
  1402. }
  1403.  
  1404. bool IsValidFileCRC(DWORD dwCRC)
  1405. {
  1406. return s_set_dwFileCRC.find(dwCRC) != s_set_dwFileCRC.end();
  1407. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement