// receive maps from some other map-server (relayed via char-server) int chrif_recvmap(int fd) { int i, j; uint32 ip = ntohl(RFIFOL(fd,4)); uint16 port = ntohs(RFIFOW(fd,8)); for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) { map_setipport(RFIFOW(fd,i), ip, port); } if (battle_config.etc_log) ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j); other_mapserver_count++; return 0; }
/** * We receive account_reg2 from a char-server, and we send them to other char-servers. * @param fd: fd to parse from (char-serv) * @param id: id of char-serv * @param ip: char-serv ip (used for info) * @return 0 not enough info transmitted, 1 success */ int logchrif_parse_upd_global_accreg(int fd, int id, char* ip){ if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; else{ struct mmo_account acc; AccountDB* accounts = login_get_accounts_db(); uint32 account_id = RFIFOL(fd,4); if( !accounts->load_num(accounts, &acc, account_id) ) ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip); else mmo_save_global_accreg(accounts,fd,account_id,RFIFOL(fd, 8)); RFIFOSKIP(fd,RFIFOW(fd,2)); } return 1; }
/** * Reading Lan Support configuration. * @param lancfgName: Name of the lan configuration (could be fullpath) * @return 0:success, 1:failure (file not found|readable) */ int login_lan_config_read(const char *lancfgName) { FILE *fp; int line_num = 0, s_subnet=ARRAYLENGTH(subnet); char line[1024], w1[64], w2[64], w3[64], w4[64]; if((fp = fopen(lancfgName, "r")) == NULL) { ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName); return 1; } while(fgets(line, sizeof(line), fp)) { line_num++; if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; if(sscanf(line,"%63[^:]: %63[^:]:%63[^:]:%63[^\r\n]", w1, w2, w3, w4) != 4) { ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); continue; } if( strcmpi(w1, "subnet") == 0 ){ if(subnet_count>=s_subnet) { //We skip instead of break in case we want to add other conf in that file. ShowError("%s: Too many subnets defined, skipping line %d...\n", lancfgName, line_num); continue; } subnet[subnet_count].mask = str2ip(w2); subnet[subnet_count].char_ip = str2ip(w3); subnet[subnet_count].map_ip = str2ip(w4); if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) ) { ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); continue; } subnet_count++; } } if( subnet_count > 1 ) /* only useful if there is more than 1 available */ ShowStatus("Read information about %d subnetworks.\n", subnet_count); fclose(fp); return 0; }
static int guild_read_castledb(void) { FILE *fp; char line[1024]; int j,ln=0; char *str[32],*p; struct guild_castle *gc; sprintf(line, "%s/castle_db.txt", db_path); if( (fp=fopen(line,"r"))==NULL){ ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { if(line[0]=='/' && line[1]=='/') continue; memset(str,0,sizeof(str)); for(j=0,p=line;j<6 && p;j++){ str[j]=p; p=strchr(p,','); if(p) *p++=0; } if (j < 4) //Insufficient data for castle. [Skotlex] { ShowError("castle_db.txt: invalid line '%s'\n", line); continue; } gc=(struct guild_castle *)aCalloc(1,sizeof(struct guild_castle)); gc->castle_id=atoi(str[0]); gc->mapindex = mapindex_name2id(str[1]); safestrncpy(gc->castle_name,str[2],NAME_LENGTH); safestrncpy(gc->castle_event,str[3],NAME_LENGTH); idb_put(castle_db,gc->castle_id,gc); //intif_guild_castle_info(gc->castle_id); ln++; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"castle_db.txt"); return 0; }
int do_init(int argc, char **argv) { ShowMessage("===============================================================================\n"); ShowStatus("Starting tests.\n"); TEST("CONFIG_TRUE and CONFIG_FALSE", test_libconfig_truefalse); TEST("libconfig availability", test_libconfig_defaults); TEST("libconfig->init and libconfig->destroy", test_libconfig_init_destroy); TEST("libconfig->read_file_src", test_libconfig_read_file_src); TEST("libconfig->read", test_libconfig_read); TEST("libconfig->load_file", test_libconfig_load_file); (void)test_libconfig_write; //TEST("libconfig->write", test_libconfig_write); (void)test_libconfig_write_file; //TEST("libconfig->write_file", test_libconfig_write_file); TEST("libconfig->read_string", test_libconfig_read_string); TEST("libconfig syntax", test_libconfig_syntax); (void)test_libconfig_set_include_dir; //TEST("libconfig->set_include_dir", test_libconfig_set_include_dir); //int (*setting_set_format) (struct config_setting_t *setting, short format); //short (*setting_get_format) (const struct config_setting_t *setting); //struct config_setting_t * (*setting_set_int_elem) (struct config_setting_t *setting, int idx, int value); //struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, long long value); //struct config_setting_t * (*setting_set_float_elem) (struct config_setting_t *setting, int idx, double value); //struct config_setting_t * (*setting_set_bool_elem) (struct config_setting_t *setting, int idx, int value); //struct config_setting_t * (*setting_set_string_elem) (struct config_setting_t *setting, int idx, const char *value); //struct config_setting_t * (*setting_add) (struct config_setting_t *parent, const char *name, int type); //int (*setting_remove) (struct config_setting_t *parent, const char *name); //int (*setting_remove_elem) (struct config_setting_t *parent, unsigned int idx); //void (*setting_set_hook) (struct config_setting_t *setting, void *hook); //void (*set_destructor) (struct config_t *config, void (*destructor)(void *)); TEST("libconfig->lookup_*", test_libconfig_lookup); TEST("libconfig->setting_get_*", test_libconfig_setting_get); (void)test_libconfig_set; //TEST("libconfig->setting_set_*", test_libconfig_setting_set); TEST("libconfig->setting_lookup_*", test_libconfig_setting_lookup); TEST("setting types", test_libconfig_setting_types); //void (*setting_copy_simple) (struct config_setting_t *parent, const struct config_setting_t *src); //void (*setting_copy_elem) (struct config_setting_t *parent, const struct config_setting_t *src); //void (*setting_copy_aggregate) (struct config_setting_t *parent, const struct config_setting_t *src); //int (*setting_copy) (struct config_setting_t *parent, const struct config_setting_t *src); TEST("values", test_libconfig_values); TEST("path lookup", test_libconfig_path_lookup); TEST("setting key names", test_libconfig_setting_names); TEST("duplicate keys", test_libconfig_duplicate_keys); TEST("special string syntax", test_libconfig_special_string_syntax); core->runflag = CORE_ST_STOP; return EXIT_SUCCESS; }
void FileViewer::Show() { if (FullScreen) { if (Opt.ViOpt.ShowKeyBar) { ViewKeyBar.SetPosition(0,ScrY,ScrX,ScrY); ViewKeyBar.Redraw(); } SetPosition(0,0,ScrX,ScrY-(Opt.ViOpt.ShowKeyBar?1:0)); View.SetPosition(0,(Opt.ViOpt.ShowTitleBar?1:0),ScrX,ScrY-(Opt.ViOpt.ShowKeyBar?1:0)); } ScreenObject::Show(); ShowStatus(); }
/*====================================== * item_db table reading *======================================*/ static int itemdb_read_sqldb(void) { #if REMODE const char* item_db_name[] = { item_db_db, item_db_re_db, item_db2_db }; #else const char* item_db_name[] = { item_db_db, item_db2_db }; #endif int fi; for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) { uint32 lines = 0, count = 0; // retrieve all rows from the item database if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format char* str[22]; char* dummy = ""; int i; ++lines; for( i = 0; i < 22; ++i ) { Sql_GetData(mmysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS)) continue; ++count; } // free the query result Sql_FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]); } return 0; }
// Converte o arquivo pet_db.txt para SQL. void convert_pet_db(void) { FILE *fread, *fwrite; char line[1024], path[256]; int count = 0, i; sprintf(path, "%s", "db/pet_db.txt"); if (!(fread = fopen(path, "r"))) return; fwrite = fopen("sql/conversor/pet_db.sql", "w+"); while (fgets(line, sizeof(line), fread) != NULL) { char *token, **script, buf[1024], write[1024], *pos = buf; if ((line[0] == '/' && line[1] == '/') || line[0] == '\n') continue; line[strlen(line)-1] = '\0'; explode(&script, (char *)line, '{'); token = strtok(line, ","); for (i = 0; i < 22; i++) { if (i) { pos += sprintf(pos, ","); } if (i < 20) pos += ((i == 1 || i == 2)) ? sprintf(pos, "'%s'", escape_str(token)) : sprintf(pos, "%s", token); else pos += (i == 21) ? sprintf(pos, "'{%s'", escape_str(script[2])) : sprintf(pos, "'{%s'", replace_str(escape_str(script[1]), "},", "}")); token = strtok(NULL, ","); } snprintf(write, sizeof(write), "REPLACE INTO pet_db VALUES(%s);\n", buf); fprintf(fwrite, write); count++; } ShowStatus("Arquivo %s convertido com sucesso! linhas afetadas: %d\n", path, count); fclose(fread); fclose(fwrite); file_count++; }
bool CServer::CreateListenSocket() { CStdString ports = (m_pOptions ? m_pOptions->GetOption(OPTION_SERVERPORT) : _T("21")); bool success = CreateListenSocket(ports, false); bool ssl_enabled = m_pOptions && m_pOptions->GetOptionVal(OPTION_ENABLETLS) != 0; if (ssl_enabled) { ports = m_pOptions->GetOption(OPTION_TLSPORTS); success &= CreateListenSocket(ports, true); } if (success && m_ListenSocketList.empty()) { ShowStatus(_T("No listen ports set in settings"), 1); } return !m_ListenSocketList.empty(); }
// Converte o arquivo mob_skill_db.txt para SQL. void convert_mob_skill_db(void) { FILE *fread, *fwrite; char line[1024], path[256]; int count = 0, i; sprintf(path, "%s", "db/mob_skill_db.txt"); if (!(fread = fopen(path, "r"))) return; fwrite = fopen("sql/conversor/mob_skill_db.sql", "w+"); while (fgets(line, sizeof(line), fread) != NULL) { char *token, buf[1024], write[1024], *pos = buf; if ((line[0] == '/' && line[1] == '/') || line[0] == '\n') continue; line[strlen(line)-1] = '\0'; token = strtok(line, ","); for (i = 0; i < 19; i++) { if (i) { pos += sprintf(pos, ","); } if (i > 0) pos += (token == NULL) ? sprintf(pos, "%s", "NULL") : sprintf(pos, "'%s'", escape_str(token)); else pos += sprintf(pos, "%d", atoi(token)); token = strtok(NULL, ","); } snprintf(write, sizeof(write), "REPLACE INTO mob_skill_db VALUES(%s);\n", buf); fprintf(fwrite, write); count++; } ShowStatus("Arquivo %s convertido com sucesso! linhas afetadas: %d\n", path, count); fclose(fread); fclose(fwrite); file_count++; }
/*========================================== * [Zephyrus] DB de Items con Drop Alterado *------------------------------------------*/ static int itemdb_read_customrates(void) { FILE *fp; char line[1024]; int ln=0; int nameid,j; char *str[3],*p; struct item_data *id; sprintf(line, "%s/item_customrates.txt", db_path); if( (fp = fopen(line,"r")) == NULL ) { ShowError("can't read %s\n", line); return -1; } while( fgets(line, sizeof(line), fp) ) { if( line[0] == '/' && line[1] == '/' ) continue; memset(str, 0, sizeof(str)); for( j = 0, p = line; j < 3 && p; j++ ) { str[j] = p; p = strchr(p,','); if( p ) *p++=0; } if( str[0] == NULL ) continue; nameid = atoi(str[0]); if( nameid <= 0 || !(id = itemdb_exists(nameid)) ) continue; id->dropRate = atoi(str[1]); id->add_dropRate = atoi(str[2]); ln++; } fclose(fp); if( ln > 0 ) ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"item_customrates.txt"); return 0; }
void CSearchingDialog::OnCancel() { if (m_State != Cancelled) { m_nPort = -1; m_lSpeed = 0; CString csStatus; Util::SafeLoadString(IDS_CANCEL_ORDER, csStatus); ShowStatus(csStatus); SetState(Cancelled); if (m_pModem != NULL) { m_pModem->Abort(); } } }
/// Called when all the connection steps are completed. void chrif_on_ready(void) { ShowStatus("Map Server is now online.\n"); chrif_state = 2; chrif_check_shutdown(); //If there are players online, send them to the char-server. [Skotlex] send_users_tochar(); //Auth db reconnect handling auth_db->foreach(auth_db,chrif_reconnect); //Re-save any storages that were modified in the disconnection time. [Skotlex] do_reconnect_storage(); //Re-save any guild castles that were modified in the disconnection time. guild_castle_reconnect(-1, 0, 0); }
int inter_party_sql_init(void) { //memory alloc inter_party->db = idb_alloc(DB_OPT_RELEASE_DATA); inter_party->pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1); if (!inter_party->pt) { ShowFatalError("inter_party->sql_init: Out of Memory!\n"); exit(EXIT_FAILURE); } #if 0 // Enable if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex] ShowStatus("cleaning party table...\n"); if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL", party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) ) Sql_ShowDebug(inter->sql_handle); #endif // 0 return 0; }
void CServer::VerifyPassiveModeSettings(CAdminSocket *pAdminSocket) { bool nat = IsBehindIPv4Nat(); bool listensIPv4 = false; auto passiveIPType = m_pOptions->GetOptionVal(OPTION_CUSTOMPASVIPTYPE); for (auto const& s : m_ListenSocketList) { auto family = s->GetFamily(); if (family == AF_INET || family == AF_UNSPEC) { listensIPv4 = true; } } if (listensIPv4 && nat && !passiveIPType) { CStdString error = _T("You appear to be behind a NAT router. Please configure the passive mode settings and forward a range of ports in your router."); ShowStatus(error, 1, pAdminSocket); } }
int chlogif_parse_ackconnect(int fd, struct char_session_data* sd){ if (RFIFOREST(fd) < 3) return 0; if (RFIFOB(fd,2)) { //printf("connect login server error : %d\n", RFIFOB(fd,2)); ShowError("Can not connect to login-server.\n"); ShowError("The server communication passwords (default s1/p1) are probably invalid.\n"); ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n"); ShowError("The communication passwords are set in map_athena.conf and char_athena.conf\n"); set_eof(fd); return 0; } else { ShowStatus("Connected to login-server (connection #%d).\n", fd); chlogif_on_ready(); } RFIFOSKIP(fd,3); return 1; }
void CScreen::Show(CGameMap *maap, CPC *pc) { /* for(int i = 0; i < SCREEN_SIZE + 2; ++i ) { printf_s("%s\n", ShowMap(i, maap, pc).c_str()); } printf_s("\n"); for(int i = 0; i < 4;++i) printf_s("%s\n",ShowStatus(i , pc).c_str()); printf_s("\n"); printf_s("%s\n", CLog::GetInstance()->GetMonsterLog(4).c_str()); printf_s("\n"); for(int i = 0; i < 5; ++i) printf_s("%s\n",CLog::GetInstance()->Get(i).c_str()); */ //가로로 펼쳐주기. for(int i = 0; i < SCREEN_SIZE + 2; i++ ) { std::string str = ShowMap(i, maap, pc); char buf[100]; if(i >= 1 && i <= 2)//몬스터 로그 sprintf_s(buf, "%-30.30s %.60s", str.c_str(), CLog::GetInstance()->GetMonsterLog(i + 2).c_str() ); else if(i>3 && i <= 7)//내 상태창. sprintf_s(buf, "%-30.30s %.60s", str.c_str(), ShowStatus(i - 4, pc).c_str()); else sprintf_s(buf, "%-30.30s", str.c_str()); printf_s("%s\n", buf); } //일반적인 로그 printf_s("%s\n", maap->GetDetail().c_str()); for(int i = 0 ; i < 5; ++i) { printf_s("%s\n", CLog::GetInstance()->Get(i).c_str()); } pc->SetSkillNotShow(); }
/*========================================== * Reads item trade restrictions [Skotlex] *------------------------------------------*/ static int itemdb_read_itemtrade(void) { FILE *fp; int nameid, j, flag, gmlv, ln = 0; char line[1024], *str[10], *p; struct item_data *id; sprintf(line, "%s/item_trade.txt", db_path); if ((fp = fopen(line,"r")) == NULL) { ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { if (line[0] == '/' && line[1] == '/') continue; memset(str, 0, sizeof(str)); for (j = 0, p = line; j < 3 && p; j++) { str[j] = p; p = strchr(p, ','); if(p) *p++ = 0; } if (j < 3 || str[0] == NULL || (nameid = atoi(str[0])) < 0 || !(id = itemdb_exists(nameid))) continue; flag = atoi(str[1]); gmlv = atoi(str[2]); if (flag > 0 && flag < 128 && gmlv > 0) { //Check range id->flag.trade_restriction = flag; id->gm_lv_trade_override = gmlv; ln++; } } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, "item_trade.txt"); return 0; }
// Converte o arquivo item_combo_db.txt para SQL. void convert_item_combo_db(void) { FILE *fread, *fwrite; char line[1024], path[256]; int count = 0; sprintf(path, "%s", "db/item_combo_db.txt"); if (!(fread = fopen(path, "r"))) return; fwrite = fopen("sql/conversor/item_combo_db.sql", "w+"); while (fgets(line, sizeof(line), fread) != NULL) { char *token, write[1024], *row[2]; if ((line[0] == '/' && line[1] == '/') || line[0] == '\n') continue; line[strlen(line)-1] = '\0'; token = line; while (isspace(*token)) ++token; row[0] = token; token = strchr(token,','); *token = '\0'; token += 1; row[1] = escape_str(token); snprintf(write, sizeof(write), "REPLACE INTO item_combo_db VALUES('%s','%s');\n", row[0], row[1]); fprintf(fwrite, write); count++; } ShowStatus("Arquivo %s convertido com sucesso! linhas afetadas: %d\n", path, count); fclose(fread); fclose(fwrite); file_count++; }
int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data) { // Run One NPC_Event[OnAgitEliminate] char *name = (char*)data; size_t len = (name) ? strlen(name) : 0; // the rest is dangerous, but let it crash, // if this happens, it's ruined anyway int c=0; if(agit_flag) // Agit not already End { char *evname=(char*)aMalloc( (len + 10) * sizeof(char)); memcpy(evname,name,len - 5); strcpy(evname + len - 5,"Eliminate"); c = npc_event_do(evname); ShowStatus("NPC_Event:[%s] Run (%d) Events.\n",evname,c); aFree(evname); // [Lance] Should fix this } if(name) aFree(name); return 0; }
static void rdtsc_calibrate(){ uint64 t1, t2; int32 i; ShowStatus("Calibrating Timer Source, please wait... "); RDTSC_CLOCK = 0; for(i = 0; i < 5; i++){ t1 = _rdtsc(); usleep(1000000); //1000 MS t2 = _rdtsc(); RDTSC_CLOCK += (t2 - t1) / 1000; } RDTSC_CLOCK /= 5; RDTSC_BEGINTICK = _rdtsc(); ShowMessage(" done. (Frequency: %u Mhz)\n", (uint32)(RDTSC_CLOCK/1000) ); }
/*========================================== * *------------------------------------------*/ int chrif_sendmapack(int fd) { if (RFIFOB(fd,2)) { ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2)); exit(EXIT_FAILURE); } memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); ShowStatus("Map sending complete. Map Server is now online.\n"); chrif_state = 2; //If there are players online, send them to the char-server. [Skotlex] send_users_tochar(); //Re-save any storages that were modified in the disconnection time. [Skotlex] auth_db->foreach(auth_db,chrif_reconnect); do_reconnect_storage(); return 0; }
// initialize int inter_init_sql(const char *file) { //int i; ShowInfo ("inter-server inicializando...\n"); inter_config_read(file); //DB connection initialized sql_handle = Sql_Malloc(); ShowInfo("Conectando à DB de chars.... (Character Server)\n"); if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) ) { Sql_ShowDebug(sql_handle); Sql_Free(sql_handle); exit(EXIT_FAILURE); } if( *default_codepage ) { if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) Sql_ShowDebug(sql_handle); } ShowStatus("Conectado ao banco de dados principal '"CL_WHITE"%s"CL_RESET"'.\n", char_server_db); Sql_PrintExtendedInfo(sql_handle); wis_db = idb_alloc(DB_OPT_RELEASE_DATA); inter_guild_sql_init(); inter_storage_sql_init(); inter_party_sql_init(); inter_pet_sql_init(); inter_homunculus_sql_init(); inter_mercenary_sql_init(); inter_elemental_sql_init(); inter_accreg_sql_init(); inter_mail_sql_init(); inter_auction_sql_init(); geoip_readdb(); msg_config_read("conf/msg_athena.conf"); return 0; }
/*========================================== * guild_skill_tree.txt reading - from jA [Komurka] *------------------------------------------*/ int guild_read_guildskill_tree_db(void) { int i,k,id=0,ln=0; FILE *fp; char line[1024],*p; memset(guild_skill_tree,0,sizeof(guild_skill_tree)); sprintf(line, "%s/guild_skill_tree.txt", db_path); if( (fp=fopen(line,"r"))==NULL){ ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { char *split[50]; if(line[0]=='/' && line[1]=='/') continue; for(i=0,p=line;i<12 && p;i++){ split[i]=p; p=strchr(p,','); if(p) *p++=0; } if(i<12) continue; id = atoi(split[0]) - GD_SKILLBASE; if(id<0 || id>=MAX_GUILDSKILL) continue; guild_skill_tree[id].id=atoi(split[0]); guild_skill_tree[id].max=atoi(split[1]); if (guild_skill_tree[id].id==GD_GLORYGUILD && battle_config.require_glory_guild && guild_skill_tree[id].max==0) guild_skill_tree[id].max=1; for(k=0;k<5;k++){ guild_skill_tree[id].need[k].id=atoi(split[k*2+2]); guild_skill_tree[id].need[k].lv=atoi(split[k*2+3]); } ln++; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,"guild_skill_tree.txt"); return 0; }
/*========================================== * アイテム使用可能フラグのオーバーライド *------------------------------------------*/ static int itemdb_read_itemavail (void) { FILE *fp; int nameid, j, k, ln = 0; char line[1024], *str[10], *p; struct item_data *id; sprintf(line, "%s/item_avail.txt", db_path); if ((fp = fopen(line,"r")) == NULL) { ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { if (line[0] == '/' && line[1] == '/') continue; memset(str, 0, sizeof(str)); for (j = 0, p = line; j < 2 && p; j++) { str[j] = p; p = strchr(p, ','); if(p) *p++ = 0; } if (j < 2 || str[0] == NULL || (nameid = atoi(str[0])) < 0 || !(id = itemdb_exists(nameid))) continue; k = atoi(str[1]); if (k > 0) { id->flag.available = 1; id->view_id = k; } else id->flag.available = 0; ln++; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, "item_avail.txt"); return 0; }
// initialize int inter_init_sql(const char *file) { //int i; ShowInfo ("interserver initialize...\n"); inter_config_read(file); //DB connection initialized sql_handle = Sql_Malloc(); ShowInfo("Connect Character DB server.... (Character Server)\n"); if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) ) { Sql_ShowDebug(sql_handle); Sql_Free(sql_handle); exit(EXIT_FAILURE); } if( *default_codepage ) { if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) ) Sql_ShowDebug(sql_handle); } ShowStatus("Connected to main database '%s'.\n", char_server_db); Sql_PrintExtendedInfo(sql_handle); #ifndef TXT_SQL_CONVERT wis_db = idb_alloc(DB_OPT_RELEASE_DATA); inter_guild_sql_init(); inter_storage_sql_init(); inter_party_sql_init(); inter_pet_sql_init(); inter_homunculus_sql_init(); inter_mercenary_sql_init(); inter_accreg_sql_init(); inter_mail_sql_init(); inter_auction_sql_init(); #endif //TXT_SQL_CONVERT return 0; }
void read_homunculus_expdb(void) { int i; char *filename[]={ DBPATH"exp_homun.txt", DBIMPORT"/exp_homun.txt" }; memset(hexptbl,0,sizeof(hexptbl)); for(i=0; i<ARRAYLENGTH(filename); i++){ FILE *fp; char line[1024]; int j=0; sprintf(line, "%s/%s", db_path, filename[i]); fp=fopen(line,"r"); if(fp == NULL){ if(i != 0) continue; if(i==0) ShowError("Can't read %s\n",line); return; } while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL) { if(line[0] == '/' && line[1] == '/') continue; hexptbl[j] = strtoul(line, NULL, 10); if (!hexptbl[j++]) break; } if (hexptbl[MAX_LEVEL - 1]) // Last permitted level have to be 0! { ShowWarning("read_hexptbl: Reached max level in %s [%d]. Remaining lines were not read.\n ",filename,MAX_LEVEL); hexptbl[MAX_LEVEL - 1] = 0; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s/%s"CL_RESET"'.\n", j, db_path, filename[i]); } }
void read_homunculus_expdb(void) { FILE *fp; char line[1024]; int i, j=0; char *filename[]={"exp_homun.txt","exp_homun2.txt"}; memset(hexptbl,0,sizeof(hexptbl)); for(i=0; i<2; i++){ if( !battle_config.renewal_system_enable ) sprintf(line, "%s/%s", db_path, filename[i]); else sprintf(line, "%s/%s", db_path, !i ? "exp_homun_renewal.txt" : "exp_homun2_renewal.txt"); fp=fopen(line,"r"); if(fp == NULL){ if(i != 0) continue; ShowError("can't read %s\n",line); return; } while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL) { if(line[0] == '/' && line[1] == '/') continue; hexptbl[j] = strtoul(line, NULL, 10); if (!hexptbl[j++]) break; } if (hexptbl[MAX_LEVEL - 1]) // Last permitted level have to be 0! { ShowWarning("read_hexptbl: Reached max level in exp_homun [%d]. Remaining lines were not read.\n ", MAX_LEVEL); hexptbl[MAX_LEVEL - 1] = 0; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s"CL_RESET"'.\n", j, filename[i]); } }
/*========================================== * timer関数 * char鯖との接続を確認し、もし切れていたら再度接続する *------------------------------------------*/ int check_connect_char_server(int tid, unsigned int tick, int id, int data) { static int displayed = 0; if (char_fd <= 0 || session[char_fd] == NULL) { if (!displayed) { ShowStatus("Attempting to connect to Char Server. Please wait.\n"); displayed = 1; } chrif_state = 0; char_fd = make_connection(char_ip, char_port); if (char_fd == -1) { //Attempt to connect later. [Skotlex] char_fd = 0; return 0; } session[char_fd]->func_parse = chrif_parse; session[char_fd]->flag.server = 1; realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); chrif_connect(char_fd); chrif_connected = (chrif_state == 2); #ifndef TXT_ONLY srvinfo = 0; #endif /* not TXT_ONLY */ } else { #ifndef TXT_ONLY if (srvinfo == 0) { chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); srvinfo = 1; } #endif /* not TXT_ONLY */ } if (chrif_isconnected()) displayed = 0; return 0; }
int JVMP_ExecuteShmRequest(JVMP_ShmRequest* req) { int vendor, funcno, id, *pid; char sign[40], *buf, *status, *url, *target; int len, argc, *pargc; if (!req) return 0; vendor = JVMP_GET_VENDOR(req->func_no); if (vendor != WFNetscape4VendorID) return 0; funcno = JVMP_GET_EXT_FUNCNO(req->func_no); switch(funcno) { case 2: sprintf(sign, "Iia[0]"); len = 0; pargc = &argc; JVMP_DecodeRequest(req, 0, sign, &id, &pargc, &buf); pargc = &argc; PutParams(id, &buf, pargc, &len); sprintf(sign, "Iia[%d]", len); JVMP_EncodeRequest(req, sign, id, pargc, buf); free(buf); break; case 3: sprintf(sign, "IS"); JVMP_DecodeRequest(req, 1, sign, &id, &status); req->retval = ShowStatus(id, status); free(status); break; case 4: sprintf(sign, "ISS"); JVMP_DecodeRequest(req, 1, sign, &id, &url, &target); req->retval = ShowDocument(id, url, target); free(url); free(target); default: return 0; } return 1; }