diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 40 | ||||
-rw-r--r-- | src/char_sql/char.c | 23 | ||||
-rw-r--r-- | src/login/login.c | 47 | ||||
-rw-r--r-- | src/login_sql/login.c | 38 | ||||
-rw-r--r-- | src/map/battle.c | 14 | ||||
-rw-r--r-- | src/map/map.c | 33 | ||||
-rw-r--r-- | src/map/skill.c | 67 | ||||
-rw-r--r-- | src/map/status.c | 4 |
8 files changed, 168 insertions, 98 deletions
diff --git a/src/char/char.c b/src/char/char.c index 93fd5ba44..73efbc864 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -228,6 +228,25 @@ char * search_character_name(int index) { return unknown_char_name; } +//------------------------------------------------- +// Set Character online/offline [Wizputer] +//------------------------------------------------- + +void set_char_online(int char_id, int account_id) { + if (login_fd <= 0 || session[login_fd]->eof) + return; + WFIFOW(login_fd,0) = 0x272b; + WFIFOL(login_fd,2) = account_id; + WFIFOSET(login_fd,6); +} +void set_char_offline(int char_id, int account_id) { + if (login_fd <= 0 || session[login_fd]->eof) + return; + WFIFOW(login_fd,0) = 0x272c; + WFIFOL(login_fd,2) = account_id; + WFIFOSET(login_fd,6); +} + /*--------------------------------------------------- Make a data line for friends list --------------------------------------------------*/ @@ -2526,7 +2545,25 @@ int parse_frommap(int fd) { RFIFOSKIP(fd, RFIFOW(fd,2)); // printf("char: save_account_reg (from map)\n"); break; - } + } + // Character disconnected set online 0 [Wizputer] + case 0x2b17: + if (RFIFOREST(fd) < 6) + return 0; + //printf("Setting %d char offline\n",RFIFOL(fd,2)); + set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6)); + RFIFOSKIP(fd,10); + break; + + // Character set online [Wizputer] + case 0x2b19: + if (RFIFOREST(fd) < 6) + return 0; + //printf("Setting %d char online\n",RFIFOL(fd,2)); + set_char_online(RFIFOL(fd,2),RFIFOL(fd,6)); + RFIFOSKIP(fd,10); + break; + default: // inter server処理に渡す { @@ -3470,6 +3507,7 @@ void do_final(void) { int do_init(int argc, char **argv) { int i; + SERVER_TYPE = SERVER_CHAR; char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]); lan_config_read((argc > 1) ? argv[1] : LOGIN_LAN_CONF_NAME); diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 1f90c27e1..d672bc0eb 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -208,18 +208,18 @@ void set_char_offline(int char_id, int account_id) { if ( char_id == 99 ) sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id); - else { - cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); - if (cp != NULL) { - aFree(cp); - numdb_erase(char_db_,char_id); - } + else { + cp = (struct mmo_charstatus*)numdb_search(char_db_,char_id); + if (cp != NULL) { + aFree(cp); + numdb_erase(char_db_,char_id); + } - sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id); + sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id); - if (mysql_query(&mysql_handle, tmp_sql)) - printf("DB server Error (set_char_offline)- %s\n", mysql_error(&mysql_handle)); - } + if (mysql_query(&mysql_handle, tmp_sql)) + printf("DB server Error (set_char_offline)- %s\n", mysql_error(&mysql_handle)); + } if (login_fd <= 0 || session[login_fd]->eof) return; @@ -2372,7 +2372,7 @@ int parse_char(int fd) { sd = (struct char_session_data*)session[fd]->session_data; - if(login_fd < 0) + if(login_fd < 0) session[fd]->eof = 1; if(session[fd]->eof) { if (fd == login_fd) @@ -3387,6 +3387,7 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ int do_init(int argc, char **argv){ int i; + SERVER_TYPE = SERVER_CHAR; for(i = 0; i < MAX_MAP_SERVERS; i++) { memset(&server[i], 0, sizeof(struct mmo_map_server)); server_fd[i] = -1; diff --git a/src/login/login.c b/src/login/login.c index bacf7a354..733411f56 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -165,6 +165,8 @@ int level_new_gm = 60; struct gm_account *gm_account_db; +static struct dbt *online_db; + int dynamic_pass_failure_ban = 1; int dynamic_pass_failure_ban_time = 5; int dynamic_pass_failure_ban_how_many = 3; @@ -204,6 +206,26 @@ int login_log(char *fmt, ...) { return 0; } +//----------------------------------------------------- +// Online User Database [Wizputer] +//----------------------------------------------------- + +void add_online_user (int account_id) { + int *p; + p = (int *)aMalloc(sizeof(int)); + *p = account_id; + numdb_insert(online_db, account_id, p); +} +int is_user_online (int account_id) { + int *p = (int*)numdb_search(online_db, account_id); + return (p != NULL); +} +void remove_online_user (int account_id) { + int *p; + p = (int*)numdb_erase(online_db, account_id); + aFree(p); +} + //---------------------------------------------------------------------- // Determine if an account (id) is a GM account // and returns its level (or 0 if it isn't a GM account or if not found) @@ -1736,6 +1758,21 @@ int parse_fromchar(int fd) { RFIFOSKIP(fd,6); } return 0; + + case 0x272b: // Set account_id to online [Wizputer] + if (RFIFOREST(fd) < 6) + return 0; + add_online_user(RFIFOL(fd,2)); + RFIFOSKIP(fd,6); + break; + + case 0x272c: // Set account_id to offline [Wizputer] + if (RFIFOREST(fd) < 6) + return 0; + remove_online_user(RFIFOL(fd,2)); + RFIFOSKIP(fd,6); + break; + case 0x3000: //change sex for chrif_changesex() if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; @@ -3870,11 +3907,18 @@ int flush_timer(int tid, unsigned int tick, int id, int data){ //-------------------------------------- // Function called at exit of the server //-------------------------------------- +static int online_db_final(void *key,void *data,va_list ap) +{ + int *p = (int *) data; + if (p) aFree(p); + return 0; +} void do_final(void) { int i, fd; printf("Terminating...\n"); fflush(stdout); mmo_auth_sync(); + numdb_final(online_db, online_db_final); if(auth_dat) aFree(auth_dat); if(gm_account_db) aFree(gm_account_db); @@ -3907,6 +3951,7 @@ void do_final(void) { int do_init(int argc, char **argv) { int i, j; + SERVER_TYPE = SERVER_LOGIN; // read login-server configuration login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); display_conf_warnings(); // not in login_config_read, because we can use 'import' option, and display same message twice or more @@ -3928,6 +3973,8 @@ int do_init(int argc, char **argv) { read_gm_account(); // set_termfunc(mmo_auth_sync); set_defaultparse(parse_login); + // Online user database init + online_db = numdb_init(); if (bind_ip_str[0] != '\0') bind_ip = inet_addr(bind_ip_str); diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 387f51a91..7c67b0174 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -152,36 +152,31 @@ struct dbt *online_db; //----------------------------------------------------- void add_online_user(int account_id) { - int *p; - if(register_users_online <= 0) - return; - p = (int*)aMalloc(sizeof(int)); - if (p == NULL) { - printf("add_online_user: memory allocation failure (malloc)!\n"); - exit(0); - } - *p = account_id; - numdb_insert(online_db, account_id, p); + int *p; + if(register_users_online <= 0) + return; + p = (int*)aMalloc(sizeof(int)); + *p = account_id; + numdb_insert(online_db, account_id, p); } int is_user_online(int account_id) { - int *p; - if(register_users_online <= 0) - return 0; + int *p; + if(register_users_online <= 0) + return 0; p = (int*)numdb_search(online_db, account_id); - if (p == NULL) - return 0; printf("Acccount %d\n",*p); - return 1; + + return (p != NULL); } void remove_online_user(int account_id) { - int *p; - if(register_users_online <= 0) - return; - p = (int*)numdb_erase(online_db,account_id); - aFree(p); + int *p; + if(register_users_online <= 0) + return; + p = (int*)numdb_erase(online_db,account_id); + aFree(p); } //----------------------------------------------------- @@ -1828,6 +1823,7 @@ int do_init(int argc,char **argv){ //initialize login server int i; + SERVER_TYPE = SERVER_LOGIN; //read login configue login_config_read( (argc>1)?argv[1]:LOGIN_CONF_NAME ); sql_config_read(SQL_CONF_NAME); diff --git a/src/map/battle.c b/src/map/battle.c index 421f85ec3..3529b9946 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -396,7 +396,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i } if(sc_data[SC_FOGWALL].timer != -1 && flag&BF_MAGIC) - if(rand()%100 < sc_data[SC_FOGWALL].val2) + if(rand()%100 < 75) damage = 0; } @@ -978,7 +978,7 @@ static struct Damage battle_calc_pet_weapon_attack( // 回避修正 if( hitrate < 1000000 && t_sc_data ) { // 必中攻撃 if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - hitrate -= 50; + hitrate -= 75; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 t_sc_data[SC_FREEZE].timer!=-1 || @@ -1000,7 +1000,7 @@ static struct Damage battle_calc_pet_weapon_attack( if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG) cardfix=cardfix*(100-t_sc_data[SC_DEFENDER].val2)/100; if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - cardfix=cardfix*(100-t_sc_data[SC_FOGWALL].val2)/100; + cardfix=cardfix*50/100; if(cardfix != 100) damage=damage*cardfix/100; } @@ -1488,7 +1488,7 @@ static struct Damage battle_calc_mob_weapon_attack( // 回避修正 if( hitrate < 1000000 && t_sc_data ) { // 必中攻撃 if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - hitrate -= 50; + hitrate -= 75; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 t_sc_data[SC_FREEZE].timer!=-1 || @@ -1537,7 +1537,7 @@ static struct Damage battle_calc_mob_weapon_attack( if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG) cardfix=cardfix*(100-t_sc_data[SC_DEFENDER].val2)/100; if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - cardfix=cardfix*(100-t_sc_data[SC_FOGWALL].val2)/100; + cardfix=cardfix*50/100; if(cardfix != 100) damage=damage*cardfix/100; } @@ -2495,7 +2495,7 @@ static struct Damage battle_calc_pc_weapon_attack( // 回避修正 if( hitrate < 1000000 && t_sc_data ) { // 必中攻撃 if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - hitrate -= 50; + hitrate -= 75; if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中 t_sc_data[SC_STAN].timer!=-1 || // スタンは必中 t_sc_data[SC_FREEZE].timer!=-1 || @@ -2635,7 +2635,7 @@ static struct Damage battle_calc_pc_weapon_attack( if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG) //ディフェンダー状態で遠距離攻撃 cardfix=cardfix*(100-t_sc_data[SC_DEFENDER].val2)/100; //ディフェンダーによる減衰 if(t_sc_data[SC_FOGWALL].timer != -1 && flag&BF_LONG) - cardfix=cardfix*(100-t_sc_data[SC_FOGWALL].val2)/100; + cardfix=cardfix*50/100; if(cardfix != 100) { damage=damage*cardfix/100; //ディフェンダー補正によるダメージ減少 damage2=damage2*cardfix/100; //ディフェンダー補正による左手ダメージ減少 diff --git a/src/map/map.c b/src/map/map.c index 902306ce8..4a9fc171e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -103,9 +103,7 @@ int read_gm_interval = 600000; char char_db[32] = "char"; static int online_timer(int,unsigned int,int,int); - int CHECK_INTERVAL = 3600000; // [Valaris] -int check_online_timer=0; // [Valaris] #endif /* not TXT_ONLY */ @@ -1555,9 +1553,7 @@ int map_quit(struct map_session_data *sd) { sd->npc_stackbuf = NULL; } -#ifndef TXT_ONLY chrif_char_offline(sd); -#endif { void *p = numdb_search(charid_db,sd->status.char_id); @@ -3072,41 +3068,27 @@ int log_sql_init(void){ return 0; } -int online_timer(int tid,unsigned int tick,int id,int data) +int online_timer (int tid,unsigned int tick,int id,int data) { if(check_online_timer != tid) return 0; - char_online_check(); - - check_online_timer=add_timer(gettick()+CHECK_INTERVAL,online_timer,0,0); - return 0; } - void char_online_check(void) { int i; - struct map_session_data *sd=NULL; + struct map_session_data *sd; chrif_char_reset_offline(); - for(i=0;i<fd_max;i++){ - if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth && - !(battle_config.hide_GM_session && pc_isGM(sd))) - if(sd->status.char_id) { + for (i = 0; i < fd_max; i++) { + if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->state.auth && + !(battle_config.hide_GM_session && pc_isGM(sd))) + if(sd->status.char_id) chrif_char_online(sd); - } } - - - if(check_online_timer && check_online_timer != -1) { - delete_timer(check_online_timer,online_timer); - add_timer(gettick()+CHECK_INTERVAL,online_timer,0,0); - } - } - #endif /* not TXT_ONLY */ //----------------------------------------------------- @@ -3275,6 +3257,7 @@ int do_init(int argc, char *argv[]) { FILE *data_conf; char line[1024], w1[1024], w2[1024]; + SERVER_TYPE = SERVER_MAP; #ifdef GCOLLECT GC_enable_incremental(); #endif @@ -3398,7 +3381,7 @@ int do_init(int argc, char *argv[]) { #ifndef TXT_ONLY // online status timer, checks every hour [Valaris] add_timer_func_list(online_timer, "online_timer"); - check_online_timer=add_timer(gettick()+CHECK_INTERVAL,online_timer,0,0); + add_timer_interval(gettick()+10, online_timer, 0, 0, CHECK_INTERVAL); #endif /* not TXT_ONLY */ do_init_chrif(); diff --git a/src/map/skill.c b/src/map/skill.c index 63e588eea..887395b40 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -978,8 +978,11 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int status_change_start(bl,SC_AUTOCOUNTER,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); break; case PF_FOGWALL: /* ホ?リ?クロス */ - if(src!=bl && rand()%100 < 3*skilllv*sc_def_int/100 ) - status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + if (src != bl) { + struct status_change *sc_data = status_get_sc_data(bl); + if (sc_data && sc_data[SC_DELUGE].timer == -1) + status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0); + } break; case LK_HEADCRUSH: /* ヘッドクラッシュ */ {//?件が良く分からないので適?に @@ -995,14 +998,11 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int break; case PF_SPIDERWEB: /* スパイダ?ウェッブ */ { - if(bl->type == BL_MOB) - { - int sec=skill_get_time2(skillid,skilllv); - if(map[src->m].flag.pvp) //PvPでは拘束時間半減? - sec = sec/2; - battle_stopwalking(bl,1); - status_change_start(bl,SC_SPIDERWEB,skilllv,0,0,0,sec,0); - } + int sec = skill_get_time2(skillid,skilllv); + if(map[src->m].flag.pvp) //PvPでは拘束時間半減? + sec = sec/2; + battle_stopwalking(bl,1); + status_change_start(bl,SC_SPIDERWEB,skilllv,0,0,0,sec,0); } break; case ASC_METEORASSAULT: /* メテオアサルト */ @@ -4389,16 +4389,19 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in break; case PF_HPCONVERSION: /* ライフ置き換え */ - clif_skill_nodamage(src,bl,skillid,skilllv,1); - if(sd){ - int conv_hp=0,conv_sp=0; - conv_hp=sd->status.hp/10; //基本はHPの10% - sd->status.hp -= conv_hp; //HPを減らす - conv_sp=conv_hp*10*skilllv/100; - conv_sp=(sd->status.sp+conv_sp>sd->status.max_sp)?sd->status.max_sp-sd->status.sp:conv_sp; - sd->status.sp += conv_sp; //SPを?やす - pc_heal(sd,-conv_hp,conv_sp); - clif_heal(sd->fd,SP_SP,conv_sp); + clif_skill_nodamage(src, bl, skillid, skilllv, 1); + if (sd) { + int conv_hp, conv_sp; + conv_hp = sd->status.max_hp / 10; //基本はHPの10% + //sd->status.hp -= conv_hp; //HPを減らす + conv_sp = conv_hp * 10 * skilllv / 100; + if (sd->status.sp + conv_sp > sd->status.max_sp) + conv_hp = sd->status.max_sp - sd->status.sp; + if (pc_checkoversp(sd)) + conv_hp = conv_sp = 0; + //sd->status.sp += conv_sp; //SPを?やす + pc_heal(sd, -conv_hp, conv_sp); + clif_heal(sd->fd, SP_SP, conv_sp); } break; case HT_REMOVETRAP: /* リム?ブトラップ */ @@ -4555,6 +4558,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in } break; + case PF_SPIDERWEB: /* スパイダ?ウェッブ */ + clif_skill_nodamage(src,bl,skillid,skilllv,1); + skill_unitsetting(src,skillid,skilllv,bl->x,bl->y,0); + break; + // Weapon Refining [Celest] case WS_WEAPONREFINE: if(sd) @@ -4975,7 +4983,6 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil case HT_CLAYMORETRAP: /* クレイモア?トラップ */ case AS_VENOMDUST: /* ベノムダスト */ case AM_DEMONSTRATION: /* デモンストレ?ション */ - case PF_SPIDERWEB: /* スパイダ?ウェッブ */ case PF_FOGWALL: /* フォグウォ?ル */ case HT_TALKIEBOX: /* ト?キ?ボックス */ skill_unitsetting(src,skillid,skilllv,x,y,0); @@ -5553,21 +5560,20 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int skill_blown(&src->bl,bl,1); break; - case 0xb6: /* フォグウォ?ル */ + case 0xb6: /* フォグウォ?ル */ if (sc_data && sc_data[type].timer!=-1) { - unit2 = (struct skill_unit *)sc_data[type].val4; - if (unit2 && unit2->group && - (unit2 == src || DIFF_TICK(sg->tick,unit2->group->tick)<=0)) + struct skill_unit_group *sg2 = (struct skill_unit_group *)sc_data[type].val4; + if (sg2 && (sg2 == src->group || DIFF_TICK(sg->tick,sg2->tick)<=0)) break; } - status_change_start(bl,type,sg->skill_lv,sg->val1,sg->val2, - (int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0); - skill_additional_effect(ss,bl,sg->skill_id,sg->skill_lv,BF_MISC,tick); + status_change_start (bl, type, sg->skill_lv, sg->val1, sg->val2, (int)sg, + skill_get_time2(sg->skill_id, sg->skill_lv), 0); + if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0) + skill_additional_effect (ss, bl, sg->skill_id, sg->skill_lv, BF_MISC, tick); break; case 0xb2: /* あなたを_?いたいです */ case 0xb3: /* ゴスペル */ - //case 0xb6: /* フォグウォ?ル */ - moved [celest] //とりあえず何もしない break; /* default: @@ -5911,8 +5917,7 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t case 0xb6: { - struct block_list *target = map_id2bl(sg->val2); - if(target && target==bl) { + if (sc_data[type].timer!=-1 && sc_data[type].val4==(int)sg) { status_change_end(bl,SC_FOGWALL,-1); if (sc_data && sc_data[SC_BLIND].timer!=-1) sc_data[SC_BLIND].timer = add_timer( diff --git a/src/map/status.c b/src/map/status.c index 68212e6e7..4418543de 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -3340,6 +3340,8 @@ int status_change_start(struct block_list *bl,int type,int val1,int val2,int val calc_flag = 1; val3 = val1>=5?15: (val1==4?14: (val1==3?12: ( val1==2?9:5 ) ) ); val4 = val1>=5?20: (val1==4?19: (val1==3?17: ( val1==2?14:10 ) ) ); + if (sc_data[SC_FOGWALL].timer != -1 && sc_data[SC_BLIND].timer != -1) + status_change_end(bl,SC_BLIND,-1); break; case SC_VIOLENTGALE: calc_flag = 1; @@ -3802,8 +3804,6 @@ int status_change_start(struct block_list *bl,int type,int val1,int val2,int val break; case SC_FOGWALL: - val2 = 75; - // calc_flag = 1; // not sure of effects yet [celest] break; case SC_PRESERVE: |