diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mmo.h | 1 | ||||
-rw-r--r-- | src/map/atcommand.c | 2 | ||||
-rw-r--r-- | src/map/battle.c | 6 | ||||
-rw-r--r-- | src/map/clif.c | 32 | ||||
-rw-r--r-- | src/map/duel.h | 8 | ||||
-rw-r--r-- | src/map/elemental.c | 102 | ||||
-rw-r--r-- | src/map/elemental.h | 43 | ||||
-rw-r--r-- | src/map/guild.c | 262 | ||||
-rw-r--r-- | src/map/guild.h | 63 | ||||
-rw-r--r-- | src/map/homunculus.h | 2 | ||||
-rw-r--r-- | src/map/instance.c | 171 | ||||
-rw-r--r-- | src/map/instance.h | 7 | ||||
-rw-r--r-- | src/map/intif.c | 665 | ||||
-rw-r--r-- | src/map/intif.h | 104 | ||||
-rw-r--r-- | src/map/itemdb.c | 5 | ||||
-rw-r--r-- | src/map/log.c | 49 | ||||
-rw-r--r-- | src/map/log.h | 42 | ||||
-rw-r--r-- | src/map/map.c | 16 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/mercenary.c | 43 | ||||
-rw-r--r-- | src/map/mercenary.h | 16 | ||||
-rw-r--r-- | src/map/packets.h | 35 | ||||
-rw-r--r-- | src/map/party.c | 155 | ||||
-rw-r--r-- | src/map/party.h | 48 | ||||
-rw-r--r-- | src/map/pc.c | 27 | ||||
-rw-r--r-- | src/map/pc.h | 5 | ||||
-rw-r--r-- | src/map/script.c | 30 | ||||
-rw-r--r-- | src/map/skill.c | 40 | ||||
-rw-r--r-- | src/map/skill.h | 25 | ||||
-rw-r--r-- | src/map/status.c | 2 | ||||
-rw-r--r-- | src/map/storage.c | 47 | ||||
-rw-r--r-- | src/map/storage.h | 10 | ||||
-rw-r--r-- | src/map/unit.c | 2 |
33 files changed, 1129 insertions, 937 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index b51d0ec4a..f49a859e0 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -772,6 +772,7 @@ enum { JOB_KAGEROU = 4211, JOB_OBORO, + JOB_REBELLION = 4215, JOB_MAX, }; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4f784ecc5..cec314134 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3561,7 +3561,7 @@ ACMD(reloadmobdb) { homun->reload(); mercenary->read_db(); mercenary->read_skilldb(); - elemental->reload_elementaldb(); + elemental->reload_db(); clif->message(fd, msg_txt(98)); // Monster database has been reloaded. return true; diff --git a/src/map/battle.c b/src/map/battle.c index 98e132077..327a4b98c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -791,7 +791,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, damage += 4; if(sd->status.party_id && (skill2_lv=pc->checkskill(sd,TK_POWER)) > 0) { - if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 ) + if( (i = party->foreachsamemap(party->sub_count, sd, 0)) > 1 ) damage += 2 * skill2_lv * i * (damage /*+ unknown value*/) / 100 /*+ unknown value*/; } #else @@ -1556,7 +1556,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block c = 0; memset (p_sd, 0, sizeof(p_sd)); - party_foreachsamemap(skill->check_condition_char_sub, sd, 3, &sd->bl, &c, &p_sd, skill_id); + party->foreachsamemap(skill->check_condition_char_sub, sd, 3, &sd->bl, &c, &p_sd, skill_id); c = ( c > 1 ? rand()%c : 0 ); if( (psd = map->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){ @@ -4534,7 +4534,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #ifndef RENEWAL if(sd->status.party_id && (temp=pc->checkskill(sd,TK_POWER)) > 0){ - if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 ) // exclude the player himself [Inkfish] + if( (i = party->foreachsamemap(party->sub_count, sd, 0)) > 1 ) // exclude the player himself [Inkfish] ATK_ADDRATE(2*temp*i); } #endif diff --git a/src/map/clif.c b/src/map/clif.c index ed75e9aa0..d69d501ac 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9368,7 +9368,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { maplist[sd->bl.m].users_pvp++; } if( maplist[sd->bl.m].instance_id >= 0 ) { - instances[maplist[sd->bl.m].instance_id].users++; + instance->list[maplist[sd->bl.m].instance_id].users++; instance->check_idle(maplist[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] @@ -16017,20 +16017,20 @@ int clif_instance(int instance_id, int type, int flag) { unsigned char buf[255]; enum send_target target = PARTY; - switch( instances[instance_id].owner_type ) { + switch( instance->list[instance_id].owner_type ) { case IOT_NONE: return 0; case IOT_GUILD: target = GUILD; - sd = guild->getavailablesd(guild->search(instances[instance_id].owner_id)); + sd = guild->getavailablesd(guild->search(instance->list[instance_id].owner_id)); break; case IOT_PARTY: /* default is already PARTY */ - sd = party->getavailablesd(party->search(instances[instance_id].owner_id)); + sd = party->getavailablesd(party->search(instance->list[instance_id].owner_id)); break; case IOT_CHAR: target = SELF; - sd = map->id2sd(instances[instance_id].owner_id); + sd = map->id2sd(instance->list[instance_id].owner_id); break; } @@ -16043,7 +16043,7 @@ int clif_instance(int instance_id, int type, int flag) { // Required to start the instancing information window on Client // This window re-appear each "refresh" of client automatically until type 4 is send to client. WBUFW(buf,0) = 0x02CB; - memcpy(WBUFP(buf,2),instances[instance_id].name,INSTANCE_NAME_LENGTH); + memcpy(WBUFP(buf,2),instance->list[instance_id].name,INSTANCE_NAME_LENGTH); WBUFW(buf,63) = flag; clif->send(buf,packet_len(0x02CB),&sd->bl,target); break; @@ -16058,13 +16058,13 @@ int clif_instance(int instance_id, int type, int flag) { case 4: // S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L WBUFW(buf,0) = 0x02CD; - memcpy(WBUFP(buf,2),instances[instance_id].name,61); + memcpy(WBUFP(buf,2),instance->list[instance_id].name,61); if( type == 3 ) { - WBUFL(buf,63) = instances[instance_id].progress_timeout; + WBUFL(buf,63) = instance->list[instance_id].progress_timeout; WBUFL(buf,67) = 0; } else { WBUFL(buf,63) = 0; - WBUFL(buf,67) = instances[instance_id].idle_timeout; + WBUFL(buf,67) = instance->list[instance_id].idle_timeout; } clif->send(buf,packet_len(0x02CD),&sd->bl,target); break; @@ -16086,24 +16086,24 @@ int clif_instance(int instance_id, int type, int flag) { void clif_instance_join(int fd, int instance_id) { - if( instances[instance_id].idle_timer != INVALID_TIMER ) { + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); WFIFOL(fd,63) = 0; - WFIFOL(fd,67) = instances[instance_id].idle_timeout; + WFIFOL(fd,67) = instance->list[instance_id].idle_timeout; WFIFOSET(fd,packet_len(0x02CD)); - } else if( instances[instance_id].progress_timer != INVALID_TIMER ) { + } else if( instance->list[instance_id].progress_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); - WFIFOL(fd,63) = instances[instance_id].progress_timeout; + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); + WFIFOL(fd,63) = instance->list[instance_id].progress_timeout; WFIFOL(fd,67) = 0; WFIFOSET(fd,packet_len(0x02CD)); } else { WFIFOHEAD(fd,packet_len(0x02CB)); WFIFOW(fd,0) = 0x02CB; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); WFIFOW(fd,63) = 0; WFIFOSET(fd,packet_len(0x02CB)); } diff --git a/src/map/duel.h b/src/map/duel.h index 7802f6163..d1ec58415 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -1,5 +1,7 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _DUEL_H_ #define _DUEL_H_ @@ -11,8 +13,6 @@ struct duel { #define MAX_DUEL 1024 - - /*===================================== * Interface : duel.h * Generated by HerculesInterfaceMaker diff --git a/src/map/elemental.c b/src/map/elemental.c index 12e8f4c4e..5a3630c70 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -39,22 +39,24 @@ #include <string.h> #include <math.h> +struct elemental_interface elemental_s; + int elemental_search_index(int class_) { int i; - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->db[i].class_ == class_); return (i == MAX_ELEMENTAL_CLASS)?-1:i; } bool elemental_class(int class_) { - return (bool)(elemental_search_index(class_) > -1); + return (bool)(elemental->search_index(class_) > -1); } struct view_data * elemental_get_viewdata(int class_) { - int i = elemental_search_index(class_); + int i = elemental->search_index(class_); if( i < 0 ) return 0; - return &elemental->elemental_db[i].vd; + return &elemental->db[i].vd; } int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { @@ -64,10 +66,10 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet nullpo_retr(1,sd); - if( (i = elemental_search_index(class_)) < 0 ) + if( (i = elemental->search_index(class_)) < 0 ) return 0; - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; memset(&ele,0,sizeof(struct s_elemental)); ele.char_id = sd->status.char_id; @@ -75,27 +77,27 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet ele.mode = EL_MODE_PASSIVE; // Initial mode i = db->status.size+1; // summon level - //[(Caster�s Max HP/ 3 ) + (Caster�s INT x 10 )+ (Caster�s Job Level x 20 )] x [(Elemental Summon Level + 2) / 3] + //[(Caster's Max HP/ 3 ) + (Caster's INT x 10 )+ (Caster's Job Level x 20 )] x [(Elemental Summon Level + 2) / 3] ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3); - //Caster�s Max SP /4 + //Caster's Max SP /4 ele.sp = ele.max_sp = sd->battle_status.max_sp/4; - //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ] + //Caster's [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ] ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100); - //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) ] + //Caster's [ Max SP / (18 / Elemental Summon Skill Level) ] ele.atk2 = sd->battle_status.max_sp / 18; - //Caster�s HIT + (Caster�s Base Level ) + //Caster's HIT + (Caster's Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; - //[Elemental Summon Skill Level x (Caster�s INT / 2 + Caster�s DEX / 4)] + //[Elemental Summon Skill Level x (Caster's INT / 2 + Caster's DEX / 4)] ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); - //150 + [Caster�s DEX / 10] + [Elemental Summon Skill Level x 3 ] + //150 + [Caster's DEX / 10] + [Elemental Summon Skill Level x 3 ] ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3; - //Caster�s DEF + (Caster�s Base Level / (5 � Elemental Summon Skill Level) + //Caster's DEF + (Caster's Base Level / (5 - Elemental Summon Skill Level) ele.def = sd->battle_status.def + sd->status.base_level / (5-i); - //Caster�s MDEF + (Caster�s INT / (5 - Elemental Summon Skill Level) + //Caster's MDEF + (Caster's INT / (5 - Elemental Summon Skill Level) ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i); - //Caster�s FLEE + (Caster�s Base Level / (5 � Elemental Summon Skill Level) + //Caster's FLEE + (Caster's Base Level / (5 - Elemental Summon Skill Level) ele.flee = sd->status.base_level / (5-i); - //Caster�s HIT + (Caster�s Base Level ) + //Caster's HIT + (Caster's Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; //per individual bonuses @@ -167,7 +169,7 @@ int elemental_save(struct elemental_data *ed) { return 1; } -static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t data) { +int elemental_summon_end_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct elemental_data *ed; @@ -177,7 +179,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat return 1; if( ed->summon_timer != tid ) { - ShowError("elemental_summon_end %d != %d.\n", ed->summon_timer, tid); + ShowError("elemental_summon_end_timer %d != %d.\n", ed->summon_timer, tid); return 0; } @@ -190,7 +192,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat void elemental_summon_stop(struct elemental_data *ed) { nullpo_retv(ed); if( ed->summon_timer != INVALID_TIMER ) - timer->delete(ed->summon_timer, elemental_summon_end); + timer->delete(ed->summon_timer, elemental->summon_end_timer); ed->summon_timer = INVALID_TIMER; } @@ -215,7 +217,7 @@ int elemental_delete(struct elemental_data *ed, int reply) { void elemental_summon_init(struct elemental_data *ed) { if( ed->summon_timer == INVALID_TIMER ) - ed->summon_timer = timer->add(timer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); + ed->summon_timer = timer->add(timer->gettick() + ed->elemental.life_time, elemental->summon_end_timer, ed->master->bl.id, 0); ed->regen.state.block = 0; } @@ -224,7 +226,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { struct map_session_data *sd; struct elemental_data *ed; struct s_elemental_db *db; - int i = elemental_search_index(ele->class_); + int i = elemental->search_index(ele->class_); if( (sd = map->charid2sd(ele->char_id)) == NULL ) return 0; @@ -234,7 +236,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { return 0; } - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; if( !sd->ed ) { // Initialize it after first summon. sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data)); ed->bl.type = BL_ELEM; @@ -259,7 +261,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { status_calc_elemental(ed,1); ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; - elemental_summon_init(ed); + elemental->summon_init(ed); } else { memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); ed = sd->ed; @@ -598,7 +600,7 @@ int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { return 1; } -static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { +int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { struct elemental_data *ed; struct block_list **target; int dist; @@ -634,7 +636,7 @@ static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap return 0; } -static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) { +int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) { struct block_list *target = NULL; int master_dist, view_range, mode; @@ -713,7 +715,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ target = map->id2bl(ed->ud.target); if( !target ) - map->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); + map->foreachinrange(elemental->ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); if( !target ) { //No targets available. elemental->unlocktarget(ed); @@ -743,16 +745,16 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 0; } -static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { +int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { unsigned int tick = va_arg(ap,unsigned int); if(sd->status.ele_id && sd->ed) - elemental_ai_sub_timer(sd->ed,sd,tick); + elemental->ai_sub_timer(sd->ed,sd,tick); return 0; } -static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachpc(elemental_ai_sub_foreachclient,tick); +int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachpc(elemental->ai_sub_foreachclient,tick); return 0; } @@ -765,7 +767,9 @@ int read_elementaldb(void) { struct status_data *estatus; sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); - memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); + + if( runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up + memset(elemental->db,0,sizeof(elemental->db)); fp = fopen(line, "r"); if( !fp ) { @@ -792,7 +796,7 @@ int read_elementaldb(void) { continue; } - db = &elemental->elemental_db[j]; + db = &elemental->db[j]; db->class_ = atoi(str[0]); safestrncpy(db->sprite, str[1], NAME_LENGTH); safestrncpy(db->name, str[2], NAME_LENGTH); @@ -882,7 +886,7 @@ int read_elemental_skilldb(void) { } class_ = atoi(str[0]); - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->elemental_db[i].class_); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->db[i].class_); if( i == MAX_ELEMENTAL_CLASS ) { ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k); continue; @@ -894,7 +898,7 @@ int read_elemental_skilldb(void) { continue; } - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; skill_lv = atoi(str[2]); skillmode = atoi(str[3]); @@ -919,7 +923,7 @@ int read_elemental_skilldb(void) { } void reload_elementaldb(void) { - read_elementaldb(); + elemental->read_db(); elemental->reload_skilldb(); } @@ -928,11 +932,11 @@ void reload_elemental_skilldb(void) { } int do_init_elemental(void) { - read_elementaldb(); + elemental->read_db(); elemental->read_skilldb(); - timer->add_func_list(elemental_ai_timer,"elemental_ai_timer"); - timer->add_interval(timer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); + timer->add_func_list(elemental->ai_timer,"elemental_ai_timer"); + timer->add_interval(timer->gettick()+MIN_ELETHINKTIME,elemental->ai_timer,0,0,MIN_ELETHINKTIME); return 0; } @@ -949,6 +953,13 @@ void do_final_elemental(void) { void elemental_defaults(void) { elemental = &elemental_s; + /* */ + elemental->init = do_init_elemental; + elemental->final = do_final_elemental; + + /* */ + memset(elemental->db,0,sizeof(elemental->db)); + /* funcs */ elemental->class = elemental_class; @@ -978,8 +989,15 @@ void elemental_defaults(void) { elemental->skill_get_requirements = elemental_skill_get_requirements; elemental->read_skilldb = read_elemental_skilldb; - elemental->reload_elementaldb = reload_elementaldb; + elemental->reload_db = reload_elementaldb; elemental->reload_skilldb = reload_elemental_skilldb; - elemental->do_init_elemental = do_init_elemental; - elemental->do_final_elemental = do_final_elemental; + + elemental->search_index = elemental_search_index; + elemental->summon_init = elemental_summon_init; + elemental->summon_end_timer = elemental_summon_end_timer; + elemental->ai_sub_timer_activesearch = elemental_ai_sub_timer_activesearch; + elemental->ai_sub_timer = elemental_ai_sub_timer; + elemental->ai_sub_foreachclient = elemental_ai_sub_foreachclient; + elemental->ai_timer = elemental_ai_timer; + elemental->read_db = read_elementaldb; } diff --git a/src/map/elemental.h b/src/map/elemental.h index ccc3bcb5f..b42d5c0b7 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -1,9 +1,16 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _ELEMENTAL_H_ #define _ELEMENTAL_H_ + #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data + +/** + * Defines + **/ #define MIN_ELETHINKTIME 100 #define MIN_ELEDISTANCE 2 #define MAX_ELEDISTANCE 5 @@ -13,10 +20,18 @@ #define EL_SKILLMODE_PASIVE 0x1 #define EL_SKILLMODE_ASSIST 0x2 #define EL_SKILLMODE_AGGRESSIVE 0x4 + +#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) +#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) + +/** + * Structures + **/ struct elemental_skill { unsigned short id, lv; short mode; }; + struct s_elemental_db { int class_; char sprite[NAME_LENGTH], name[NAME_LENGTH]; @@ -26,6 +41,7 @@ struct s_elemental_db { struct view_data vd; struct elemental_skill skill[MAX_ELESKILLTREE]; }; + struct elemental_data { struct block_list bl; struct unit_data ud; @@ -46,9 +62,6 @@ struct elemental_data { int target_id, attacked_id; }; -#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) -#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) - /*===================================== * Interface : elemental.h * Generated by HerculesInterfaceMaker @@ -57,8 +70,11 @@ struct elemental_data { struct elemental_interface { /* vars */ - struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database + struct s_elemental_db db[MAX_ELEMENTAL_CLASS]; // Elemental Database + /* */ + int (*init) (void); + void (*final) (void); /* funcs */ bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); @@ -87,11 +103,18 @@ struct elemental_interface { struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); int (*read_skilldb) (void); - void (*reload_elementaldb) (void); + void (*reload_db) (void); void (*reload_skilldb) (void); - int (*do_init_elemental) (void); - void (*do_final_elemental) (void); -} elemental_s; + + int (*search_index) (int class_); + void (*summon_init) (struct elemental_data *ed); + int (*summon_end_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*ai_sub_timer_activesearch) (struct block_list *bl, va_list ap); + int (*ai_sub_timer) (struct elemental_data *ed, struct map_session_data *sd, unsigned int tick); + int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap); + int (*ai_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*read_db) (void); +}; struct elemental_interface *elemental; diff --git a/src/map/guild.c b/src/map/guild.c index 797b3b370..b66961262 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -32,50 +32,10 @@ struct guild_interface guild_s; -static DBMap* guild_db; // int guild_id -> struct guild* -static DBMap* castle_db; // int castle_id -> struct guild_castle* -static DBMap* guild_expcache_db; // int char_id -> struct guild_expcache* -static DBMap* guild_infoevent_db; // int guild_id -> struct eventlist* - -struct eventlist { - char name[EVENT_NAME_LENGTH]; - struct eventlist *next; -}; - -//Constant related to the flash of the Guild EXP cache -#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP -#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) -#define GUILD_PAYEXP_LIST 8192 //The maximum number of cache - -//Guild EXP cache - -struct guild_expcache { - int guild_id, account_id, char_id; - uint64 exp; -}; -static struct eri *expcache_ers; //For handling of guild exp payment. - -#define MAX_GUILD_SKILL_REQUIRE 5 -struct{ - int id; - int max; - struct{ - short id; - short lv; - }need[MAX_GUILD_SKILL_REQUIRE]; -} guild_skill_tree[MAX_GUILDSKILL]; - -int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data); -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); - -/* guild flags cache */ -struct npc_data **guild_flags; -unsigned short guild_flags_count; - /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] *------------------------------------------*/ -static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { +TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) @@ -90,15 +50,14 @@ static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { return sd; } - // Modified [Komurka] +// Modified [Komurka] int guild_skill_get_max (int id) { if (id < GD_SKILLBASE || id >= GD_SKILLBASE+MAX_GUILDSKILL) return 0; - return guild_skill_tree[id-GD_SKILLBASE].max; + return guild->skill_tree[id-GD_SKILLBASE].max; } // Retrive skill_lv learned by guild - int guild_checkskill(struct guild *g, int id) { int idx = id - GD_SKILLBASE; if (idx < 0 || idx >= MAX_GUILDSKILL) @@ -109,7 +68,7 @@ int guild_checkskill(struct guild *g, int id) { /*========================================== * guild_skill_tree.txt reading - from jA [Komurka] *------------------------------------------*/ -static bool guild_read_guildskill_tree_db(char* split[], int columns, int current) +bool guild_read_guildskill_tree_db(char* split[], int columns, int current) {// <skill id>,<max lv>,<req id1>,<req lv1>,<req id2>,<req lv2>,<req id3>,<req lv3>,<req id4>,<req lv4>,<req id5>,<req lv5> int k, id, skill_id; @@ -122,18 +81,18 @@ static bool guild_read_guildskill_tree_db(char* split[], int columns, int curren return false; } - guild_skill_tree[id].id = skill_id; - guild_skill_tree[id].max = atoi(split[1]); + guild->skill_tree[id].id = skill_id; + 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 ) + if( guild->skill_tree[id].id == GD_GLORYGUILD && battle_config.require_glory_guild && guild->skill_tree[id].max == 0 ) {// enable guild's glory when required for emblems - guild_skill_tree[id].max = 1; + guild->skill_tree[id].max = 1; } for( k = 0; k < MAX_GUILD_SKILL_REQUIRE; 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]); + guild->skill_tree[id].need[k].id = atoi(split[k*2+2]); + guild->skill_tree[id].need[k].lv = atoi(split[k*2+3]); } return true; @@ -155,14 +114,14 @@ int guild_check_skill_require(struct guild *g,int id) for(i=0;i<MAX_GUILD_SKILL_REQUIRE;i++) { - if(guild_skill_tree[idx].need[i].id == 0) break; - if(guild_skill_tree[idx].need[i].lv > guild->checkskill(g,guild_skill_tree[idx].need[i].id)) + if(guild->skill_tree[idx].need[i].id == 0) break; + if(guild->skill_tree[idx].need[i].lv > guild->checkskill(g,guild->skill_tree[idx].need[i].id)) return 0; } return 1; } -static bool guild_read_castledb(char* str[], int columns, int current) +bool guild_read_castledb(char* str[], int columns, int current) {// <castle id>,<map name>,<castle name>,<castle event>[,<reserved/unused switch flag>] struct guild_castle *gc; int mapindex = mapindex_name2id(str[1]); @@ -176,7 +135,7 @@ static bool guild_read_castledb(char* str[], int columns, int current) safestrncpy(gc->castle_name, str[2], sizeof(gc->castle_name)); safestrncpy(gc->castle_event, str[3], sizeof(gc->castle_event)); - idb_put(castle_db,gc->castle_id,gc); + idb_put(guild->castle_db,gc->castle_id,gc); //intif->guild_castle_info(gc->castle_id); @@ -186,14 +145,14 @@ static bool guild_read_castledb(char* str[], int columns, int current) /// lookup: guild id -> guild* struct guild* guild_search(int guild_id) { - return (struct guild*)idb_get(guild_db,guild_id); + return (struct guild*)idb_get(guild->db,guild_id); } /// lookup: guild name -> guild* struct guild* guild_searchname(char* str) { struct guild* g; - DBIterator *iter = db_iterator(guild_db); + DBIterator *iter = db_iterator(guild->db); for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) { @@ -208,14 +167,14 @@ struct guild* guild_searchname(char* str) /// lookup: castle id -> castle* struct guild_castle* guild_castle_search(int gcid) { - return (struct guild_castle*)idb_get(castle_db,gcid); + return (struct guild_castle*)idb_get(guild->castle_db,gcid); } /// lookup: map index -> castle* struct guild_castle* guild_mapindex2gc(short mapindex) { struct guild_castle* gc; - DBIterator *iter = db_iterator(castle_db); + DBIterator *iter = db_iterator(guild->castle_db); for( gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter) ) { @@ -303,7 +262,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { (g = guild->search(c->guild_id)) == NULL || (i = guild->getindex(g, c->account_id, c->char_id)) < 0 ) { - ers_free(expcache_ers, c); + ers_free(guild->expcache_ers, c); return 0; } @@ -316,13 +275,13 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { GMI_EXP,&g->member[i].exp,sizeof(g->member[i].exp)); c->exp=0; - ers_free(expcache_ers, c); + ers_free(guild->expcache_ers, c); return 0; } int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data) { - guild_expcache_db->clear(guild_expcache_db,guild_payexp_timer_sub); + guild->expcache_db->clear(guild->expcache_db,guild->payexp_timer_sub); return 0; } @@ -355,9 +314,9 @@ int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) } //Code from party_send_xy_timer [Skotlex] -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) +int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { - guild_db->foreach(guild_db,guild_send_xy_timer_sub,tick); + guild->db->foreach(guild->db,guild->send_xy_timer_sub,tick); return 0; } @@ -392,7 +351,7 @@ int guild_create(struct map_session_data *sd, const char *name) return 0; } - guild_makemember(&m,sd); + guild->makemember(&m,sd); m.position=0; intif->guild_create(name,&m); return 1; @@ -440,7 +399,7 @@ int guild_npc_request_info(int guild_id,const char *event) ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); memcpy(ev->name,event,strlen(event)); //The one in the db (if present) becomes the next event from this. - if (guild_infoevent_db->put(guild_infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) + if (guild->infoevent_db->put(guild->infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) ev->next = DB->data2ptr(&prev); } @@ -501,12 +460,12 @@ int guild_recv_info(struct guild *sg) { nullpo_ret(sg); - if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) { + if((g = (struct guild*)idb_get(guild->db,sg->guild_id))==NULL) { guild_new = true; g=(struct guild *)aCalloc(1,sizeof(struct guild)); g->instance = NULL; g->instances = 0; - idb_put(guild_db,sg->guild_id,g); + idb_put(guild->db,sg->guild_id,g); if( hChSys.ally ) { struct hChSysCh *channel; @@ -554,7 +513,7 @@ int guild_recv_info(struct guild *sg) { } before=*sg; //Perform the check on the user because the first load - guild_check_member(sg); + guild->check_member(sg); if ((sd = map->nick2sd(sg->master)) != NULL) { //If the guild master is online the first time the guild_info is received, //that means he was the first to join, so apply guild skill blocking here. @@ -583,7 +542,7 @@ int guild_recv_info(struct guild *sg) { for(i=bm=m=0;i<g->max_member;i++){ if(g->member[i].account_id>0){ - sd = g->member[i].sd = guild_sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id); + sd = g->member[i].sd = guild->sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id); if (sd) clif->charnameupdate(sd); // [LuzZza] m++; }else @@ -618,7 +577,7 @@ int guild_recv_info(struct guild *sg) { } //Occurrence of an event - if (guild_infoevent_db->remove(guild_infoevent_db, DB->i2key(sg->guild_id), &data)) { + if (guild->infoevent_db->remove(guild->infoevent_db, DB->i2key(sg->guild_id), &data)) { struct eventlist *ev = DB->data2ptr(&data), *ev2; while(ev) { npc->event_do(ev->name); @@ -731,7 +690,7 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) { return 0; } - guild_makemember(&m,sd); + guild->makemember(&m,sd); intif->guild_addmember(guild_id, &m); //TODO: send a minimap update to this player } @@ -1015,7 +974,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin g->connect_member=om; //Ensure validity of pointer (ie: player logs in/out, changes map-server) - g->member[idx].sd = guild_sd_check(guild_id, account_id, char_id); + g->member[idx].sd = guild->sd_check(guild_id, account_id, char_id); if(oldonline!=online) clif->guild_memberlogin_notice(g, idx, online); @@ -1095,8 +1054,7 @@ int guild_memberposition_changed(struct guild *g,int idx,int pos) /*==================================================== * Change guild title or member *---------------------------------------------------*/ -int guild_change_position(int guild_id,int idx, - int mode,int exp_mode,const char *name) +int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name) { struct guild_position p; @@ -1202,7 +1160,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) } } {// update guardians (mobs) - DBIterator* iter = db_iterator(castle_db); + DBIterator* iter = db_iterator(guild->castle_db); struct guild_castle* gc; for( gc = (struct guild_castle*)dbi_first(iter) ; dbi_exists(iter); gc = (struct guild_castle*)dbi_next(iter) ) { @@ -1228,9 +1186,9 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) dbi_destroy(iter); } {// update npcs (flags or other npcs that used flagemblem to attach to this guild) - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->u.scr.guild_id == guild_id ) { - clif->guild_emblem_area(&guild_flags[i]->bl); + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->u.scr.guild_id == guild_id ) { + clif->guild_emblem_area(&guild->flags[i]->bl); } } } @@ -1240,12 +1198,12 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) /** * @see DBCreateData */ -static DBData create_expcache(DBKey key, va_list args) +DBData create_expcache(DBKey key, va_list args) { struct guild_expcache *c; struct map_session_data *sd = va_arg(args, struct map_session_data*); - c = ers_alloc(expcache_ers, struct guild_expcache); + c = ers_alloc(guild->expcache_ers, struct guild_expcache); c->guild_id = sd->status.guild_id; c->account_id = sd->status.account_id; c->char_id = sd->status.char_id; @@ -1276,7 +1234,7 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp) { exp = exp * per / 100; //Otherwise tax everything. - c = DB->data2ptr(guild_expcache_db->ensure(guild_expcache_db, DB->i2key(sd->status.char_id), create_expcache, sd)); + c = DB->data2ptr(guild->expcache_db->ensure(guild->expcache_db, DB->i2key(sd->status.char_id), guild->create_expcache, sd)); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; @@ -1299,7 +1257,7 @@ int guild_getexp(struct map_session_data *sd,int exp) if (sd->status.guild_id == 0 || sd->guild == NULL) return 0; - c = DB->data2ptr(guild_expcache_db->ensure(guild_expcache_db, DB->i2key(sd->status.char_id), create_expcache, sd)); + c = DB->data2ptr(guild->expcache_db->ensure(guild->expcache_db, DB->i2key(sd->status.char_id), guild->create_expcache, sd)); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; else @@ -1459,11 +1417,11 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild_get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { clif->guild_allianceack(sd,4); return 0; } - if( guild_get_alliance_count(g[1],0) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g[1],0) >= battle_config.max_guild_alliance ) { clif->guild_allianceack(sd,3); return 0; } @@ -1511,12 +1469,12 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) g=sd->guild; tg=tsd->guild; - if(g==NULL || guild_get_alliance_count(g,0) >= battle_config.max_guild_alliance){ + if(g==NULL || guild->get_alliance_count(g,0) >= battle_config.max_guild_alliance){ clif->guild_allianceack(sd,4); clif->guild_allianceack(tsd,3); return 0; } - if(tg==NULL || guild_get_alliance_count(tg,0) >= battle_config.max_guild_alliance){ + if(tg==NULL || guild->get_alliance_count(tg,0) >= battle_config.max_guild_alliance){ clif->guild_allianceack(sd,3); clif->guild_allianceack(tsd,4); return 0; @@ -1582,7 +1540,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild_get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { clif->guild_oppositionack(sd,1); return 0; } @@ -1765,15 +1723,15 @@ int guild_broken(int guild_id,int flag) } } - guild_db->foreach(guild_db,guild_broken_sub,guild_id); - castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id); + guild->db->foreach(guild->db,guild->broken_sub,guild_id); + guild->castle_db->foreach(guild->castle_db,guild->castle_broken_sub,guild_id); gstorage->delete(guild_id); if( hChSys.ally ) { if( g->channel != NULL ) { clif->chsys_delete(( struct hChSysCh * )g->channel); } } - idb_remove(guild_db,guild_id); + idb_remove(guild->db,guild_id); return 0; } @@ -1911,7 +1869,7 @@ int guild_break(struct map_session_data *sd,char *name) { void guild_castle_map_init(void) { DBIterator* iter = NULL; - int num = db_size(castle_db); + int num = db_size(guild->castle_db); if (num > 0) { struct guild_castle* gc = NULL; @@ -1919,7 +1877,7 @@ void guild_castle_map_init(void) CREATE(castle_ids, int, num); cursor = castle_ids; - iter = db_iterator(castle_db); + iter = db_iterator(guild->castle_db); for (gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) { *(cursor++) = gc->castle_id; } @@ -2015,7 +1973,7 @@ void guild_castle_reconnect(int castle_id, int index, int value) static struct linkdb_node *gc_save_pending = NULL; if (castle_id < 0) { // char-server reconnected - linkdb_foreach(&gc_save_pending, guild_castle_reconnect_sub); + linkdb_foreach(&gc_save_pending, guild->castle_reconnect_sub); linkdb_final(&gc_save_pending); } else { int *data; @@ -2107,7 +2065,7 @@ int guild_checkcastles(struct guild *g) { int nb_cas = 0; struct guild_castle* gc = NULL; - DBIterator *iter = db_iterator(castle_db); + DBIterator *iter = db_iterator(guild->castle_db); for (gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) { if (gc->guild_id == g->guild_id) { @@ -2133,38 +2091,38 @@ void guild_flag_add(struct npc_data *nd) { int i; /* check */ - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->bl.id == nd->bl.id ) { + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->bl.id == nd->bl.id ) { return;/* exists, most likely updated the id. */ } } - i = guild_flags_count;/* save the current slot */ + i = guild->flags_count;/* save the current slot */ /* add */ - RECREATE(guild_flags,struct npc_data*,++guild_flags_count); + RECREATE(guild->flags,struct npc_data*,++guild->flags_count); /* save */ - guild_flags[i] = nd; + guild->flags[i] = nd; } void guild_flag_remove(struct npc_data *nd) { int i, cursor; - if( guild_flags_count == 0 ) + if( guild->flags_count == 0 ) return; /* find it */ - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->bl.id == nd->bl.id ) {/* found */ - guild_flags[i] = NULL; + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->bl.id == nd->bl.id ) {/* found */ + guild->flags[i] = NULL; break; } } /* compact list */ - for( i = 0, cursor = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] == NULL ) + for( i = 0, cursor = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] == NULL ) continue; if( cursor != i ) { - memmove(&guild_flags[cursor], &guild_flags[i], sizeof(struct npc_data*)); + memmove(&guild->flags[cursor], &guild->flags[i], sizeof(struct npc_data*)); } cursor++; @@ -2175,7 +2133,7 @@ void guild_flag_remove(struct npc_data *nd) { /** * @see DBApply */ -static int eventlist_db_final(DBKey key, DBData *data, va_list ap) { +int eventlist_db_final(DBKey key, DBData *data, va_list ap) { struct eventlist *next = NULL; struct eventlist *current = DB->data2ptr(data); while (current != NULL) { @@ -2189,15 +2147,15 @@ static int eventlist_db_final(DBKey key, DBData *data, va_list ap) { /** * @see DBApply */ -static int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) { - ers_free(expcache_ers, DB->data2ptr(data)); +int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) { + ers_free(guild->expcache_ers, DB->data2ptr(data)); return 0; } /** * @see DBApply */ -static int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { +int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { struct guild_castle* gc = DB->data2ptr(data); if( gc->temp_guardians ) aFree(gc->temp_guardians); @@ -2208,36 +2166,33 @@ static int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { /* called when scripts are reloaded/unloaded */ void guild_flags_clear(void) { int i; - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] ) - guild_flags[i] = NULL; + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] ) + guild->flags[i] = NULL; } - guild_flags_count = 0; + guild->flags_count = 0; } void do_init_guild(void) { - guild_db = idb_alloc(DB_OPT_RELEASE_DATA); - castle_db = idb_alloc(DB_OPT_BASE); - guild_expcache_db = idb_alloc(DB_OPT_BASE); - guild_infoevent_db = idb_alloc(DB_OPT_BASE); - expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); - - guild_flags_count = 0; - - sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); + guild->db = idb_alloc(DB_OPT_RELEASE_DATA); + guild->castle_db = idb_alloc(DB_OPT_BASE); + guild->expcache_db = idb_alloc(DB_OPT_BASE); + guild->infoevent_db = idb_alloc(DB_OPT_BASE); + guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); + + sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, guild->read_castledb); - memset(guild_skill_tree,0,sizeof(guild_skill_tree)); - sv->readdb(map->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka] + sv->readdb(map->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, guild->read_guildskill_tree_db); //guild skill tree [Komurka] - timer->add_func_list(guild_payexp_timer,"guild_payexp_timer"); - timer->add_func_list(guild_send_xy_timer, "guild_send_xy_timer"); - timer->add_interval(timer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); - timer->add_interval(timer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); + timer->add_func_list(guild->payexp_timer,"guild_payexp_timer"); + timer->add_func_list(guild->send_xy_timer, "guild_send_xy_timer"); + timer->add_interval(timer->gettick()+GUILD_PAYEXP_INVERVAL,guild->payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); + timer->add_interval(timer->gettick()+GUILD_SEND_XY_INVERVAL,guild->send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); } void do_final_guild(void) { - DBIterator *iter = db_iterator(guild_db); + DBIterator *iter = db_iterator(guild->db); struct guild *g; for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) { @@ -2251,13 +2206,14 @@ void do_final_guild(void) { dbi_destroy(iter); - db_destroy(guild_db); - castle_db->destroy(castle_db,guild_castle_db_final); - guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final); - guild_infoevent_db->destroy(guild_infoevent_db,eventlist_db_final); - ers_destroy(expcache_ers); - - aFree(guild_flags);/* never empty; created on boot */ + db_destroy(guild->db); + guild->castle_db->destroy(guild->castle_db,guild->castle_db_final); + guild->expcache_db->destroy(guild->expcache_db,guild->expcache_db_final); + guild->infoevent_db->destroy(guild->infoevent_db,guild->eventlist_db_final); + ers_destroy(guild->expcache_ers); + + if( guild->flags ) + aFree(guild->flags); } void guild_defaults(void) { guild = &guild_s; @@ -2265,6 +2221,18 @@ void guild_defaults(void) { guild->init = do_init_guild; guild->final = do_final_guild; /* */ + guild->db = NULL; + guild->castle_db = NULL; + guild->expcache_db = NULL; + guild->infoevent_db = NULL; + /* */ + guild->expcache_ers = NULL; + /* */ + memset(guild->skill_tree, 0, sizeof(guild->skill_tree)); + /* guild flags cache */ + guild->flags = NULL; + guild->flags_count = 0; + /* */ guild->skill_get_max = guild_skill_get_max; /* */ guild->checkskill = guild_checkskill; @@ -2341,4 +2309,22 @@ void guild_defaults(void) { guild->flags_clear = guild_flags_clear; /* guild aura */ guild->aura_refresh = guild_guildaura_refresh; + /* */ + guild->payexp_timer = guild_payexp_timer; + guild->sd_check = guild_sd_check; + guild->read_guildskill_tree_db = guild_read_guildskill_tree_db; + guild->read_castledb = guild_read_castledb; + guild->payexp_timer_sub = guild_payexp_timer_sub; + guild->send_xy_timer_sub = guild_send_xy_timer_sub; + guild->send_xy_timer = guild_send_xy_timer; + guild->create_expcache = create_expcache; + guild->eventlist_db_final = eventlist_db_final; + guild->expcache_db_final = guild_expcache_db_final; + guild->castle_db_final = guild_castle_db_final; + guild->broken_sub = guild_broken_sub; + guild->castle_broken_sub = castle_guild_broken_sub; + guild->makemember = guild_makemember; + guild->check_member = guild_check_member; + guild->get_alliance_count = guild_get_alliance_count; + guild->castle_reconnect_sub = guild_castle_reconnect_sub; } diff --git a/src/map/guild.h b/src/map/guild.h index 1f61df09e..566ca7ce4 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -6,14 +6,32 @@ #define _GUILD_H_ //#include "../common/mmo.h" +#include "map.h" // NAME_LENGTH + +/** + * Declarations + **/ struct guild; struct guild_member; struct guild_position; struct guild_castle; -#include "map.h" // NAME_LENGTH struct map_session_data; struct mob_data; +/** + * Defines + **/ +#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP +#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) +#define MAX_GUILD_SKILL_REQUIRE 5 + +/** + * Structures + **/ +struct eventlist { + char name[EVENT_NAME_LENGTH]; + struct eventlist *next; +}; //For quick linking to a guardian's info. [Skotlex] struct guardian_data { int number; //0-MAX_GUARDIANS-1 = Guardians. MAX_GUARDIANS = Emperium. @@ -23,11 +41,36 @@ struct guardian_data { char guild_name[NAME_LENGTH]; struct guild_castle* castle; }; +struct guild_expcache { + int guild_id, account_id, char_id; + uint64 exp; +}; +struct s_guild_skill_tree { + int id; + int max; + struct { + short id; + short lv; + } need[MAX_GUILD_SKILL_REQUIRE]; +}; + struct guild_interface { void (*init) (void); void (*final) (void); /* */ + DBMap* db; // int guild_id -> struct guild* + DBMap* castle_db; // int castle_id -> struct guild_castle* + DBMap* expcache_db; // int char_id -> struct guild_expcache* + DBMap* infoevent_db; // int guild_id -> struct eventlist* + /* */ + struct eri *expcache_ers; //For handling of guild exp payment. + /* */ + struct s_guild_skill_tree skill_tree[MAX_GUILDSKILL]; + /* guild flags cache */ + struct npc_data **flags; + unsigned short flags_count; + /* */ int (*skill_get_max) (int id); /* */ int (*checkskill) (struct guild *g,int id); @@ -104,6 +147,24 @@ struct guild_interface { void (*flags_clear) (void); /* guild aura */ void (*aura_refresh) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); + /* */ + int (*payexp_timer) (int tid, unsigned int tick, int id, intptr_t data); + TBL_PC* (*sd_check) (int guild_id, int account_id, int char_id); + bool (*read_guildskill_tree_db) (char* split[], int columns, int current); + bool (*read_castledb) (char* str[], int columns, int current); + int (*payexp_timer_sub) (DBKey key, DBData *data, va_list ap); + int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap); + int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); + DBData (*create_expcache) (DBKey key, va_list args); + int (*eventlist_db_final) (DBKey key, DBData *data, va_list ap); + int (*expcache_db_final) (DBKey key, DBData *data, va_list ap); + int (*castle_db_final) (DBKey key, DBData *data, va_list ap); + int (*broken_sub) (DBKey key, DBData *data, va_list ap); + int (*castle_broken_sub) (DBKey key, DBData *data, va_list ap); + void (*makemember) (struct guild_member *m,struct map_session_data *sd); + int (*check_member) (struct guild *g); + int (*get_alliance_count) (struct guild *g,int flag); + void (*castle_reconnect_sub) (void *key, void *data, va_list ap); }; struct guild_interface *guild; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index a90faf2e2..9562ed5c3 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -28,8 +28,6 @@ struct s_homunculus_db { unsigned char element, race, base_size, evo_size; }; -extern struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; - enum { HOMUNCULUS_CLASS, HOMUNCULUS_FOOD diff --git a/src/map/instance.c b/src/map/instance.c index 5ef089fae..17b66fa75 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -33,7 +33,7 @@ bool instance_is_valid(int instance_id) { return false; } - if( instances[instance_id].state == INSTANCE_FREE ) {// uninitialized/freed instance slot + if( instance->list[instance_id].state == INSTANCE_FREE ) {// uninitialized/freed instance slot return false; } @@ -88,30 +88,30 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ } if( type != IOT_NONE && *icptr ) { - ARR_FIND(0, *icptr, i, strcmp(instances[iptr[i]].name,name) == 0 ); + ARR_FIND(0, *icptr, i, strcmp(instance->list[iptr[i]].name,name) == 0 ); if( i != *icptr ) return -4;/* already got this instance */ } - ARR_FIND(0, instance->instances, i, instances[i].state == INSTANCE_FREE); + ARR_FIND(0, instance->instances, i, instance->list[i].state == INSTANCE_FREE); if( i == instance->instances ) - RECREATE(instances, struct instance_data, ++instance->instances); - - instances[i].state = INSTANCE_IDLE; - instances[i].id = i; - instances[i].idle_timer = INVALID_TIMER; - instances[i].idle_timeout = instances[i].idle_timeoutval = 0; - instances[i].progress_timer = INVALID_TIMER; - instances[i].progress_timeout = 0; - instances[i].users = 0; - instances[i].map = NULL; - instances[i].num_map = 0; - instances[i].owner_id = owner_id; - instances[i].owner_type = type; - instances[i].vars = idb_alloc(DB_OPT_RELEASE_DATA); - - safestrncpy( instances[i].name, name, sizeof(instances[i].name) ); + RECREATE(instance->list, struct instance_data, ++instance->instances); + + instance->list[i].state = INSTANCE_IDLE; + instance->list[i].id = i; + instance->list[i].idle_timer = INVALID_TIMER; + instance->list[i].idle_timeout = instance->list[i].idle_timeoutval = 0; + instance->list[i].progress_timer = INVALID_TIMER; + instance->list[i].progress_timeout = 0; + instance->list[i].users = 0; + instance->list[i].map = NULL; + instance->list[i].num_map = 0; + instance->list[i].owner_id = owner_id; + instance->list[i].owner_type = type; + instance->list[i].vars = idb_alloc(DB_OPT_RELEASE_DATA); + + safestrncpy( instance->list[i].name, name, sizeof(instance->list[i].name) ); if( type != IOT_NONE ) { ARR_FIND(0, *icptr, j, iptr[j] == -1); @@ -244,9 +244,9 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const maplist[im].instance_src_map = m; maplist[m].flag.src4instance = 1; // Flag this map as a src map for instances - RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map); + RECREATE(instance->list[instance_id].map, unsigned short, ++instance->list[instance_id].num_map); - instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance + instance->list[instance_id].map[instance->list[instance_id].num_map - 1] = im; // Attach to actual instance map->addmap2db(&maplist[im]); return im; @@ -264,9 +264,9 @@ int instance_map2imap(int16 m, int instance_id) { return -1; } - for( i = 0; i < instances[instance_id].num_map; i++ ) { - if( instances[instance_id].map[i] && maplist[instances[instance_id].map[i]].instance_src_map == m ) - return instances[instance_id].map[i]; + for( i = 0; i < instance->list[instance_id].num_map; i++ ) { + if( instance->list[instance_id].map[i] && maplist[instance->list[instance_id].map[i]].instance_src_map == m ) + return instance->list[instance_id].map[i]; } return -1; } @@ -313,10 +313,10 @@ void instance_init(int instance_id) { if( !instance->valid(instance_id) ) return; // nothing to do - for( i = 0; i < instances[instance_id].num_map; i++ ) - map->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + for( i = 0; i < instance->list[instance_id].num_map; i++ ) + map->foreachinmap(instance_map_npcsub, maplist[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); - instances[instance_id].state = INSTANCE_BUSY; + instance->list[instance_id].state = INSTANCE_BUSY; } /*-------------------------------------- @@ -410,18 +410,18 @@ void instance_del_map(int16 m) { } // Remove from instance - for( i = 0; i < instances[maplist[m].instance_id].num_map; i++ ) { - if( instances[maplist[m].instance_id].map[i] == m ) { - instances[maplist[m].instance_id].num_map--; - for( ; i < instances[maplist[m].instance_id].num_map; i++ ) - instances[maplist[m].instance_id].map[i] = instances[maplist[m].instance_id].map[i+1]; + for( i = 0; i < instance->list[maplist[m].instance_id].num_map; i++ ) { + if( instance->list[maplist[m].instance_id].map[i] == m ) { + instance->list[maplist[m].instance_id].num_map--; + for( ; i < instance->list[maplist[m].instance_id].num_map; i++ ) + instance->list[maplist[m].instance_id].map[i] = instance->list[maplist[m].instance_id].map[i+1]; i = -1; break; } } - if( i == instances[maplist[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instances[maplist[m].instance_id].name, m); + if( i == instance->list[maplist[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instance->list[maplist[m].instance_id].name, m); if( maplist[m].channel ) clif->chsys_delete(maplist[m].channel); @@ -456,41 +456,41 @@ void instance_destroy(int instance_id) { if( !instance->valid(instance_id) ) return; // nothing to do - if( instances[instance_id].progress_timeout && instances[instance_id].progress_timeout <= now ) + if( instance->list[instance_id].progress_timeout && instance->list[instance_id].progress_timeout <= now ) type = 1; - else if( instances[instance_id].idle_timeout && instances[instance_id].idle_timeout <= now ) + else if( instance->list[instance_id].idle_timeout && instance->list[instance_id].idle_timeout <= now ) type = 2; else type = 3; clif->instance(instance_id, 5, type); // Report users this instance has been destroyed - switch ( instances[instance_id].owner_type ) { + switch ( instance->list[instance_id].owner_type ) { case IOT_NONE: break; case IOT_CHAR: - if( ( sd = map->id2sd(instances[instance_id].owner_id) ) == NULL ) { + if( ( sd = map->id2sd(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = sd->instance; icptr = &sd->instances; break; case IOT_PARTY: - if( ( p = party->search(instances[instance_id].owner_id) ) == NULL ) { + if( ( p = party->search(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = p->instance; icptr = &p->instances; break; case IOT_GUILD: - if( ( g = guild->search(instances[instance_id].owner_id) ) == NULL ) { + if( ( g = guild->search(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = g->instance; icptr = &g->instances; break; default: - ShowError("instance_destroy: unknown type %d for owner_id %d and name '%s'.\n", instances[instance_id].owner_type,instances[instance_id].owner_id,instances[instance_id].name); + ShowError("instance_destroy: unknown type %d for owner_id %d and name '%s'.\n", instance->list[instance_id].owner_type,instance->list[instance_id].owner_id,instance->list[instance_id].name); break; } @@ -500,27 +500,27 @@ void instance_destroy(int instance_id) { iptr[j] = -1; } - while( instances[instance_id].num_map && last != instances[instance_id].map[0] ) { // Remove all maps from instance - last = instances[instance_id].map[0]; - instance->del_map( instances[instance_id].map[0] ); + while( instance->list[instance_id].num_map && last != instance->list[instance_id].map[0] ) { // Remove all maps from instance + last = instance->list[instance_id].map[0]; + instance->del_map( instance->list[instance_id].map[0] ); } - if( instances[instance_id].vars ) - db_destroy(instances[instance_id].vars); + if( instance->list[instance_id].vars ) + db_destroy(instance->list[instance_id].vars); - if( instances[instance_id].progress_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); - if( instances[instance_id].idle_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); + if( instance->list[instance_id].progress_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].progress_timer, instance->destroy_timer); + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].idle_timer, instance->destroy_timer); - instances[instance_id].vars = NULL; + instance->list[instance_id].vars = NULL; - if( instances[instance_id].map ) - aFree(instances[instance_id].map); + if( instance->list[instance_id].map ) + aFree(instance->list[instance_id].map); - instances[instance_id].map = NULL; - instances[instance_id].state = INSTANCE_FREE; - instances[instance_id].num_map = 0; + instance->list[instance_id].map = NULL; + instance->list[instance_id].state = INSTANCE_FREE; + instance->list[instance_id].num_map = 0; } /*-------------------------------------- @@ -530,20 +530,20 @@ void instance_check_idle(int instance_id) { bool idle = true; unsigned int now = (unsigned int)time(NULL); - if( !instance->valid(instance_id) || instances[instance_id].idle_timeoutval == 0 ) + if( !instance->valid(instance_id) || instance->list[instance_id].idle_timeoutval == 0 ) return; - if( instances[instance_id].users ) + if( instance->list[instance_id].users ) idle = false; - if( instances[instance_id].idle_timer != INVALID_TIMER && !idle ) { - timer->delete(instances[instance_id].idle_timer, instance_destroy_timer); - instances[instance_id].idle_timer = INVALID_TIMER; - instances[instance_id].idle_timeout = 0; + if( instance->list[instance_id].idle_timer != INVALID_TIMER && !idle ) { + timer->delete(instance->list[instance_id].idle_timer, instance->destroy_timer); + instance->list[instance_id].idle_timer = INVALID_TIMER; + instance->list[instance_id].idle_timeout = 0; clif->instance(instance_id, 3, 0); // Notify instance users normal instance expiration - } else if( instances[instance_id].idle_timer == INVALID_TIMER && idle ) { - instances[instance_id].idle_timeout = now + instances[instance_id].idle_timeoutval; - instances[instance_id].idle_timer = timer->add( timer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); + } else if( instance->list[instance_id].idle_timer == INVALID_TIMER && idle ) { + instance->list[instance_id].idle_timeout = now + instance->list[instance_id].idle_timeoutval; + instance->list[instance_id].idle_timer = timer->add( timer->gettick() + instance->list[instance_id].idle_timeoutval * 1000, instance->destroy_timer, instance_id, 0); clif->instance(instance_id, 4, 0); // Notify instance users it will be destroyed of no user join it again in "X" time } } @@ -558,30 +558,30 @@ void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsign if( !instance->valid(instance_id) ) return; - if( instances[instance_id].progress_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); - if( instances[instance_id].idle_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); + if( instance->list[instance_id].progress_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].progress_timer, instance->destroy_timer); + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].idle_timer, instance->destroy_timer); if( progress_timeout ) { - instances[instance_id].progress_timeout = now + progress_timeout; - instances[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); + instance->list[instance_id].progress_timeout = now + progress_timeout; + instance->list[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance->destroy_timer, instance_id, 0); } else { - instances[instance_id].progress_timeout = 0; - instances[instance_id].progress_timer = INVALID_TIMER; + instance->list[instance_id].progress_timeout = 0; + instance->list[instance_id].progress_timer = INVALID_TIMER; } if( idle_timeout ) { - instances[instance_id].idle_timeoutval = idle_timeout; - instances[instance_id].idle_timer = INVALID_TIMER; - instance_check_idle(instance_id); + instance->list[instance_id].idle_timeoutval = idle_timeout; + instance->list[instance_id].idle_timer = INVALID_TIMER; + instance->check_idle(instance_id); } else { - instances[instance_id].idle_timeoutval = 0; - instances[instance_id].idle_timeout = 0; - instances[instance_id].idle_timer = INVALID_TIMER; + instance->list[instance_id].idle_timeoutval = 0; + instance->list[instance_id].idle_timeout = 0; + instance->list[instance_id].idle_timer = INVALID_TIMER; } - if( instances[instance_id].idle_timer == INVALID_TIMER && instances[instance_id].progress_timer != INVALID_TIMER ) + if( instance->list[instance_id].idle_timer == INVALID_TIMER && instance->list[instance_id].progress_timer != INVALID_TIMER ) clif->instance(instance_id, 3, 0); } @@ -607,14 +607,15 @@ void do_final_instance(void) { instance->destroy(i); } - if( instances ) - aFree(instances); + if( instance->list ) + aFree(instance->list); + instance->list = NULL; instance->instances = 0; } void do_init_instance(void) { - timer->add_func_list(instance_destroy_timer, "instance_destroy_timer"); + timer->add_func_list(instance->destroy_timer, "instance_destroy_timer"); } void instance_defaults(void) { @@ -627,7 +628,8 @@ void instance_defaults(void) { instance->start_id = 0; /* count */ instance->instances = 0; - + /* */ + instance->list = NULL; /* */ instance->create = instance_create; instance->add_map = instance_add_map; @@ -640,4 +642,5 @@ void instance_defaults(void) { instance->check_kick = instance_check_kick; instance->set_timeout = instance_set_timeout; instance->valid = instance_is_valid; + instance->destroy_timer = instance_destroy_timer; } diff --git a/src/map/instance.h b/src/map/instance.h index 164aaf662..ba6d26d59 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -42,14 +42,14 @@ struct instance_data { unsigned int idle_timeout, idle_timeoutval; }; -struct instance_data *instances; - struct instance_interface { void (*init) (void); void (*final) (void); /* start point */ unsigned short start_id; - unsigned short instances; + unsigned short instances;/* count */ + /* */ + struct instance_data *list;/* pointer to a chunk of consecutive memory, access via instance->list[0]..etc */ /* */ int (*create) (int party_id, const char *name, enum instance_owner_type type); int (*add_map) (const char *name, int instance_id, bool usebasename, const char *map_name); @@ -62,6 +62,7 @@ struct instance_interface { void (*check_kick) (struct map_session_data *sd); void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout); bool (*valid) (int instance_id); + int (*destroy_timer) (int tid, unsigned int tick, int id, intptr_t data); }; struct instance_interface *instance; diff --git a/src/map/intif.c b/src/map/intif.c index 97ff8a681..e42679ec6 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -33,18 +33,7 @@ #include <string.h> -static const int packet_len_table[]={ - -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f - 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 - 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 - 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 - -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 - -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] - -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] - -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] - 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 - -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] -}; +struct intif_interface intif_s; #define inter_fd chrif->fd // alias @@ -850,7 +839,7 @@ int intif_homunculus_requestdelete(int homun_id) // Packets receive from inter server // Wisp/Page reception // rewritten by [Yor] -int intif_parse_WisMessage(int fd) { +void intif_parse_WisMessage(int fd) { struct map_session_data* sd; char *wisp_source; char name[NAME_LENGTH]; @@ -863,11 +852,11 @@ int intif_parse_WisMessage(int fd) { if(sd == NULL || strcmp(sd->status.name, name) != 0) { //Not found intif_wis_replay(id,1); - return 0; + return; } if(sd->state.ignoreAll) { intif_wis_replay(id, 2); - return 0; + return; } wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor] for(i=0; i < MAX_IGNORE_LIST && @@ -878,17 +867,15 @@ int intif_parse_WisMessage(int fd) { if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') { //Ignored intif_wis_replay(id, 2); - return 0; + return; } //Success to send whisper. clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); intif_wis_replay(id,0); // succes - return 0; } // Wisp/page transmission result reception -int intif_parse_WisEnd(int fd) -{ +void intif_parse_WisEnd(int fd) { struct map_session_data* sd; if (battle_config.etc_log) @@ -897,11 +884,10 @@ int intif_parse_WisEnd(int fd) if (sd != NULL) clif->wis_end(sd->fd, RFIFOB(fd,26)); - return 0; + return; } -static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) -{ +int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) { int permission = va_arg(va, int); char *wisp_name; char *message; @@ -918,7 +904,7 @@ static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) // Received wisp message from map-server via char-server for ALL gm // 0x3003/0x3803 <packet_len>.w <wispname>.24B <permission>.l <message>.?B -int mapif_parse_WisToGM(int fd) +void mapif_parse_WisToGM(int fd) { int permission, mes_len; char Wisp_name[NAME_LENGTH]; @@ -936,11 +922,10 @@ int mapif_parse_WisToGM(int fd) if (message != mbuf) aFree(message); - return 0; } // Request player registre -int intif_parse_Registers(int fd) +void intif_parse_Registers(int fd) { int j,p,len,max, flag; struct map_session_data *sd; @@ -955,7 +940,7 @@ int intif_parse_Registers(int fd) if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id) sd = NULL; //Character registry from another character. } - if (!sd) return 1; + if (!sd) return; flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1); @@ -977,7 +962,7 @@ int intif_parse_Registers(int fd) break; default: ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12)); - return 0; + return; } for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){ sscanf((char*)RFIFOP(fd,p), "%31c%n", reg[j].str,&len); @@ -991,10 +976,9 @@ int intif_parse_Registers(int fd) if (flag && sd->save_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1) pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex] - return 1; } -int intif_parse_LoadGuildStorage(int fd) +void intif_parse_LoadGuildStorage(int fd) { struct guild_storage *gstor; struct map_session_data *sd; @@ -1002,168 +986,143 @@ int intif_parse_LoadGuildStorage(int fd) guild_id = RFIFOL(fd,8); if(guild_id <= 0) - return 1; + return; sd=map->id2sd( RFIFOL(fd,4) ); if(sd==NULL){ ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4)); - return 1; + return; } gstor=gstorage->id2storage(guild_id); if(!gstor) { ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id); - return 1; + return; } if (gstor->storage_status == 1) { // Already open.. lets ignore this update ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id); - return 1; + return; } if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex] ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id); - return 1; + return; } if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){ ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage)); gstor->storage_status = 0; - return 1; + return; } memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage)); gstorage->open(sd); - return 0; } // ACK guild_storage saved -int intif_parse_SaveGuildStorage(int fd) +void intif_parse_SaveGuildStorage(int fd) { gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6)); - return 0; } // ACK party creation -int intif_parse_PartyCreated(int fd) +void intif_parse_PartyCreated(int fd) { if(battle_config.etc_log) ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2)); party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15)); - return 0; } // Receive party info -int intif_parse_PartyInfo(int fd) +void intif_parse_PartyInfo(int fd) { if( RFIFOW(fd,2) == 12 ){ ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8)); party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4)); - return 0; + return; } if( RFIFOW(fd,2) != 8+sizeof(struct party) ) ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party)); party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4)); - return 0; } // ACK adding party member -int intif_parse_PartyMemberAdded(int fd) +void intif_parse_PartyMemberAdded(int fd) { if(battle_config.etc_log) ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); party->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14)); - return 0; } // ACK changing party option -int intif_parse_PartyOptionChanged(int fd) +void intif_parse_PartyOptionChanged(int fd) { party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14)); - return 0; } // ACK member leaving party -int intif_parse_PartyMemberWithdraw(int fd) +void intif_parse_PartyMemberWithdraw(int fd) { if(battle_config.etc_log) ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); party->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - return 0; } // ACK party break -int intif_parse_PartyBroken(int fd) -{ +void intif_parse_PartyBroken(int fd) { party->broken(RFIFOL(fd,2)); - return 0; } // ACK party on new map -int intif_parse_PartyMove(int fd) +void intif_parse_PartyMove(int fd) { party->recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17)); - return 0; } // ACK party messages -int intif_parse_PartyMessage(int fd) -{ +void intif_parse_PartyMessage(int fd) { party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); - return 0; } // ACK guild creation -int intif_parse_GuildCreated(int fd) -{ +void intif_parse_GuildCreated(int fd) { guild->created(RFIFOL(fd,2),RFIFOL(fd,6)); - return 0; } // ACK guild infos -int intif_parse_GuildInfo(int fd) -{ +void intif_parse_GuildInfo(int fd) { if(RFIFOW(fd,2) == 8) { ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4)); guild->recv_noinfo(RFIFOL(fd,4)); - return 0; + return; } if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ) ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4); guild->recv_info((struct guild *)RFIFOP(fd,4)); - return 0; } // ACK adding guild member -int intif_parse_GuildMemberAdded(int fd) -{ +void intif_parse_GuildMemberAdded(int fd) { if(battle_config.etc_log) ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); guild->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); - return 0; } // ACK member leaving guild -int intif_parse_GuildMemberWithdraw(int fd) -{ +void intif_parse_GuildMemberWithdraw(int fd) { guild->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15)); - return 0; } // ACK guild member basic info -int intif_parse_GuildMemberInfoShort(int fd) -{ +void intif_parse_GuildMemberInfoShort(int fd) { guild->recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); - return 0; } // ACK guild break -int intif_parse_GuildBroken(int fd) -{ +void intif_parse_GuildBroken(int fd) { guild->broken(RFIFOL(fd,2),RFIFOB(fd,6)); - return 0; } // basic guild info change notice // 0x3839 <packet len>.w <guild id>.l <type>.w <data>.?b -int intif_parse_GuildBasicInfoChanged(int fd) -{ +void intif_parse_GuildBasicInfoChanged(int fd) { //int len = RFIFOW(fd,2) - 10; int guild_id = RFIFOL(fd,4); int type = RFIFOW(fd,8); @@ -1171,21 +1130,18 @@ int intif_parse_GuildBasicInfoChanged(int fd) struct guild* g = guild->search(guild_id); if( g == NULL ) - return 0; + return; switch(type) { - case GBI_EXP: g->exp = RFIFOQ(fd,10); break; - case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break; - case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break; + case GBI_EXP: g->exp = RFIFOQ(fd,10); break; + case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break; + case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break; } - - return 0; } // guild member info change notice // 0x383a <packet len>.w <guild id>.l <account id>.l <char id>.l <type>.w <data>.?b -int intif_parse_GuildMemberInfoChanged(int fd) -{ +void intif_parse_GuildMemberInfoChanged(int fd) { //int len = RFIFOW(fd,2) - 18; int guild_id = RFIFOL(fd,4); int account_id = RFIFOL(fd,8); @@ -1198,130 +1154,103 @@ int intif_parse_GuildMemberInfoChanged(int fd) g = guild->search(guild_id); if( g == NULL ) - return 0; + return; idx = guild->getindex(g,account_id,char_id); if( idx == -1 ) - return 0; + return; switch( type ) { - case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break; - case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break; - case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break; - case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break; - case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break; - case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break; - case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break; + case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break; + case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break; + case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break; + case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break; + case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break; + case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break; + case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break; } - return 0; } // ACK change of guild title -int intif_parse_GuildPosition(int fd) -{ +void intif_parse_GuildPosition(int fd) { if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ) ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12); guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); - return 0; } // ACK change of guild skill update -int intif_parse_GuildSkillUp(int fd) -{ +void intif_parse_GuildSkillUp(int fd) { guild->skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - return 0; } // ACK change of guild relationship -int intif_parse_GuildAlliance(int fd) -{ +void intif_parse_GuildAlliance(int fd) { guild->allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43)); - return 0; } // ACK change of guild notice -int intif_parse_GuildNotice(int fd) -{ +void intif_parse_GuildNotice(int fd) { guild->notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66)); - return 0; } // ACK change of guild emblem -int intif_parse_GuildEmblem(int fd) -{ +void intif_parse_GuildEmblem(int fd) { guild->emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12)); - return 0; } // ACK guild message -int intif_parse_GuildMessage(int fd) -{ +void intif_parse_GuildMessage(int fd) { guild->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); - return 0; } // Reply guild castle data request -int intif_parse_GuildCastleDataLoad(int fd) -{ - return guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4)); +void intif_parse_GuildCastleDataLoad(int fd) { + guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4)); } // ACK change of guildmaster -int intif_parse_GuildMasterChanged(int fd) -{ - return guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); +void intif_parse_GuildMasterChanged(int fd) { + guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); } // Request pet creation -int intif_parse_CreatePet(int fd) -{ +void intif_parse_CreatePet(int fd) { pet->get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6)); - return 0; } // ACK pet data -int intif_parse_RecvPetData(int fd) -{ +void intif_parse_RecvPetData(int fd) { struct s_pet p; int len; len=RFIFOW(fd,2); if(sizeof(struct s_pet)!=len-9) { if(battle_config.etc_log) ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9); - } - else{ + } else { memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet)); pet->recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8)); } - - return 0; } - +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ // ACK pet save data -int intif_parse_SavePetOk(int fd) -{ +void intif_parse_SavePetOk(int fd) { if(RFIFOB(fd,6) == 1) ShowError("pet data save failure\n"); - - return 0; } - +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ // ACK deleting pet -int intif_parse_DeletePetOk(int fd) -{ +void intif_parse_DeletePetOk(int fd) { if(RFIFOB(fd,2) == 1) ShowError("pet data delete failure\n"); - - return 0; } // ACK changing name resquest, players,pets,hommon -int intif_parse_ChangeNameOk(int fd) +void intif_parse_ChangeNameOk(int fd) { struct map_session_data *sd = NULL; if((sd=map->id2sd(RFIFOL(fd,2)))==NULL || sd->status.char_id != RFIFOL(fd,6)) - return 0; + return; switch (RFIFOB(fd,10)) { case 0: //Players [NOT SUPPORTED YET] @@ -1333,54 +1262,43 @@ int intif_parse_ChangeNameOk(int fd) homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); break; } - return 0; + return; } //---------------------------------------------------------------- // Homunculus recv packets [albator] -int intif_parse_CreateHomunculus(int fd) -{ - int len; - len=RFIFOW(fd,2)-9; +void intif_parse_CreateHomunculus(int fd) { + int len = RFIFOW(fd,2)-9; if(sizeof(struct s_homunculus)!=len) { if(battle_config.etc_log) ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len); - return 0; + return; } homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ; - return 0; } -int intif_parse_RecvHomunculusData(int fd) -{ - int len; - - len=RFIFOW(fd,2)-9; +void intif_parse_RecvHomunculusData(int fd) { + int len = RFIFOW(fd,2)-9; if(sizeof(struct s_homunculus)!=len) { if(battle_config.etc_log) ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len); - return 0; + return; } homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)); - return 0; } -int intif_parse_SaveHomunculusOk(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_SaveHomunculusOk(int fd) { if(RFIFOB(fd,6) != 1) ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2)); - - return 0; } -int intif_parse_DeleteHomunculusOk(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_DeleteHomunculusOk(int fd) { if(RFIFOB(fd,2) != 1) ShowError("Homunculus data delete failure\n"); - - return 0; } /************************************** @@ -1398,15 +1316,14 @@ int intif_request_questlog(TBL_PC *sd) return 0; } -int intif_parse_questlog(int fd) -{ +void intif_parse_QuestLog(int fd) { int char_id = RFIFOL(fd, 4); int i; TBL_PC * sd = map->charid2sd(char_id); //User not online anymore if(!sd) - return -1; + return; sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest); @@ -1420,7 +1337,7 @@ int intif_parse_questlog(int fd) if( sd->quest_index[i] < 0 ) { - ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id); + ShowError("intif_parse_QuestLog: quest %d not found in DB.\n",sd->quest_log[i].quest_id); sd->avail_quests--; sd->num_quests--; i--; @@ -1432,20 +1349,16 @@ int intif_parse_questlog(int fd) } quest->pc_login(sd); - - return 0; } -int intif_parse_questsave(int fd) { +void intif_parse_QuestSave(int fd) { int cid = RFIFOL(fd, 2); TBL_PC *sd = map->id2sd(cid); if( !RFIFOB(fd, 6) ) - ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid); + ShowError("intif_parse_QuestSave: Failed to save quest(s) for character %d!\n", cid); else if( sd ) sd->save_quest = false; - - return 0; } int intif_quest_save(TBL_PC *sd) @@ -1491,23 +1404,20 @@ int intif_Mail_requestinbox(int char_id, unsigned char flag) return 0; } -int intif_parse_Mail_inboxreceived(int fd) -{ +void intif_parse_MailInboxReceived(int fd) { struct map_session_data *sd; unsigned char flag = RFIFOB(fd,8); sd = map->charid2sd(RFIFOL(fd,4)); - if (sd == NULL) - { - ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4)); - return 1; + if (sd == NULL) { + ShowError("intif_parse_MailInboxReceived: char not found %d\n",RFIFOL(fd,4)); + return; } - if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) - { - ShowError("intif_parse_Mail_inboxreceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); - return 1; + if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) { + ShowError("intif_parse_MailInboxReceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); + return; } //FIXME: this operation is not safe [ultramage] @@ -1516,13 +1426,11 @@ int intif_parse_Mail_inboxreceived(int fd) if (flag) clif->mail_refreshinbox(sd); - else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) ) - { + else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) ) { char output[128]; sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked); clif->disp_onlyself(sd, output, strlen(output)); } - return 0; } /*------------------------------------------ * Mail Read @@ -1556,29 +1464,26 @@ int intif_Mail_getattach(int char_id, int mail_id) return 0; } -int intif_parse_Mail_getattach(int fd) { +void intif_parse_MailGetAttach(int fd) { struct map_session_data *sd; struct item item; int zeny = RFIFOL(fd,8); sd = map->charid2sd( RFIFOL(fd,4) ); - if (sd == NULL) - { - ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4)); - return 1; + if (sd == NULL) { + ShowError("intif_parse_MailGetAttach: char not found %d\n",RFIFOL(fd,4)); + return; } - if (RFIFOW(fd,2) - 12 != sizeof(struct item)) - { - ShowError("intif_parse_Mail_getattach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item)); - return 1; + if (RFIFOW(fd,2) - 12 != sizeof(struct item)) { + ShowError("intif_parse_MailGetAttach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item)); + return; } memcpy(&item, RFIFOP(fd,12), sizeof(struct item)); mail->getattachment(sd, zeny, &item); - return 0; } /*------------------------------------------ * Delete Message @@ -1597,24 +1502,21 @@ int intif_Mail_delete(int char_id, int mail_id) return 0; } -int intif_parse_Mail_delete(int fd) { +void intif_parse_MailDelete(int fd) { + struct map_session_data *sd; int char_id = RFIFOL(fd,2); int mail_id = RFIFOL(fd,6); bool failed = RFIFOB(fd,10); - - struct map_session_data *sd = map->charid2sd(char_id); - if (sd == NULL) - { - ShowError("intif_parse_Mail_delete: char not found %d\n", char_id); - return 1; + + if ( (sd = map->charid2sd(char_id)) == NULL) { + ShowError("intif_parse_MailDelete: char not found %d\n", char_id); + return; } - if (!failed) - { + if (!failed) { int i; ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); - if( i < MAIL_MAX_INBOX ) - { + if( i < MAIL_MAX_INBOX ) { memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); sd->mail.inbox.amount--; } @@ -1624,7 +1526,6 @@ int intif_parse_Mail_delete(int fd) { } clif->mail_delete(sd->fd, mail_id, failed); - return 0; } /*------------------------------------------ * Return Message @@ -1643,23 +1544,20 @@ int intif_Mail_return(int char_id, int mail_id) return 0; } -int intif_parse_Mail_return(int fd) { +void intif_parse_MailReturn(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); short fail = RFIFOB(fd,10); - if( sd == NULL ) - { - ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2)); - return 1; + if( sd == NULL ) { + ShowError("intif_parse_MailReturn: char not found %d\n",RFIFOL(fd,2)); + return; } - if( !fail ) - { + if( !fail ) { int i; ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); - if( i < MAIL_MAX_INBOX ) - { + if( i < MAIL_MAX_INBOX ) { memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); sd->mail.inbox.amount--; } @@ -1669,7 +1567,6 @@ int intif_parse_Mail_return(int fd) { } clif->mail_return(sd->fd, mail_id, fail); - return 0; } /*------------------------------------------ * Send Mail @@ -1691,15 +1588,13 @@ int intif_Mail_send(int account_id, struct mail_message *msg) return 1; } -static void intif_parse_Mail_send(int fd) -{ +void intif_parse_MailSend(int fd) { struct mail_message msg; struct map_session_data *sd; bool fail; - if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) - { - ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); + if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) { + ShowError("intif_parse_MailSend: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); return; } @@ -1719,7 +1614,7 @@ static void intif_parse_Mail_send(int fd) } } -static void intif_parse_Mail_new(int fd) { +void intif_parse_MailNew(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); const char* sender_name = (char*)RFIFOP(fd,10); @@ -1756,7 +1651,7 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se return 0; } -static void intif_parse_Auction_results(int fd) { +void intif_parse_AuctionResults(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,4)); short count = RFIFOW(fd,8); short pages = RFIFOW(fd,10); @@ -1784,12 +1679,12 @@ int intif_Auction_register(struct auction_data *auction) return 1; } -static void intif_parse_Auction_register(int fd) { +void intif_parse_AuctionRegister(int fd) { struct map_session_data *sd; struct auction_data auction; if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) { - ShowError("intif_parse_Auction_register: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); + ShowError("intif_parse_AuctionRegister: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); return; } @@ -1801,9 +1696,7 @@ static void intif_parse_Auction_register(int fd) { clif->auction_message(sd->fd, 1); // Confirmation Packet ?? if( map->save_settings&32 ) chrif->save(sd,0); - } - else - { + } else { int zeny = auction.hours*battle_config.auction_feeperhour; clif->auction_message(sd->fd, 4); @@ -1827,7 +1720,7 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_cancel(int fd) { +void intif_parse_AuctionCancel(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int result = RFIFOB(fd,6); @@ -1835,10 +1728,10 @@ static void intif_parse_Auction_cancel(int fd) { return; switch( result ) { - case 0: clif->auction_message(sd->fd, 2); break; - case 1: clif->auction_close(sd->fd, 2); break; - case 2: clif->auction_close(sd->fd, 1); break; - case 3: clif->auction_message(sd->fd, 3); break; + case 0: clif->auction_message(sd->fd, 2); break; + case 1: clif->auction_close(sd->fd, 2); break; + case 2: clif->auction_close(sd->fd, 1); break; + case 3: clif->auction_message(sd->fd, 3); break; } } @@ -1856,7 +1749,7 @@ int intif_Auction_close(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_close(int fd) { +void intif_parse_AuctionClose(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); @@ -1864,8 +1757,7 @@ static void intif_parse_Auction_close(int fd) { return; clif->auction_close(sd->fd, result); - if( result == 0 ) - { + if( result == 0 ) { // FIXME: Leeching off a parse function clif->pAuction_cancelreg(fd, sd); intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1); @@ -1891,7 +1783,7 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in return 0; } -static void intif_parse_Auction_bid(int fd) { +void intif_parse_AuctionBid(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int bid = RFIFOL(fd,6); unsigned char result = RFIFOB(fd,10); @@ -1910,7 +1802,7 @@ static void intif_parse_Auction_bid(int fd) { } // Used to send 'You have won the auction' and 'You failed to won the auction' messages -static void intif_parse_Auction_message(int fd) { +void intif_parse_AuctionMessage(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); @@ -1938,18 +1830,16 @@ int intif_mercenary_create(struct s_mercenary *merc) return 0; } -int intif_parse_mercenary_received(int fd) -{ +void intif_parse_MercenaryReceived(int fd) { int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_mercenary) != len ) - { + + if( sizeof(struct s_mercenary) != len ) { if( battle_config.etc_log ) ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len); - return 0; + return; } mercenary->data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4)); - return 0; } int intif_mercenary_request(int merc_id, int char_id) @@ -1976,13 +1866,10 @@ int intif_mercenary_delete(int merc_id) WFIFOSET(inter_fd,6); return 0; } - -int intif_parse_mercenary_deleted(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_MercenaryDeleted(int fd) { if( RFIFOB(fd,2) != 1 ) ShowError("Mercenary data delete failure\n"); - - return 0; } int intif_mercenary_save(struct s_mercenary *merc) @@ -1999,13 +1886,10 @@ int intif_mercenary_save(struct s_mercenary *merc) WFIFOSET(inter_fd,size); return 0; } - -int intif_parse_mercenary_saved(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_MercenarySaved(int fd) { if( RFIFOB(fd,2) != 1 ) ShowError("Mercenary data save failure\n"); - - return 0; } /*========================================== @@ -2026,18 +1910,16 @@ int intif_elemental_create(struct s_elemental *ele) return 0; } -int intif_parse_elemental_received(int fd) -{ +void intif_parse_ElementalReceived(int fd) { int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_elemental) != len ) - { + + if( sizeof(struct s_elemental) != len ) { if( battle_config.etc_log ) ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len); - return 0; + return; } elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); - return 0; } int intif_elemental_request(int ele_id, int char_id) @@ -2064,13 +1946,10 @@ int intif_elemental_delete(int ele_id) WFIFOSET(inter_fd,6); return 0; } - -int intif_parse_elemental_deleted(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_ElementalDeleted(int fd) { if( RFIFOB(fd,2) != 1 ) ShowError("Elemental data delete failure\n"); - - return 0; } int intif_elemental_save(struct s_elemental *ele) @@ -2087,13 +1966,10 @@ int intif_elemental_save(struct s_elemental *ele) WFIFOSET(inter_fd,size); return 0; } - -int intif_parse_elemental_saved(int fd) -{ +/* Really? Whats the point, shouldn't be sent when successful then [Ind] */ +void intif_parse_ElementalSaved(int fd) { if( RFIFOB(fd,2) != 1 ) ShowError("Elemental data save failure\n"); - - return 0; } void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) { @@ -2139,12 +2015,12 @@ int intif_parse(int fd) int packet_len, cmd; cmd = RFIFOW(fd,0); // Verify ID of the packet - if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) || - packet_len_table[cmd-0x3800]==0){ + if(cmd<0x3800 || cmd>=0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0])) || + intif->packet_len_table[cmd-0x3800]==0){ return 0; } // Check the length of the packet - packet_len = packet_len_table[cmd-0x3800]; + packet_len = intif->packet_len_table[cmd-0x3800]; if(packet_len==-1){ if(RFIFOREST(fd)<4) return 2; @@ -2155,81 +2031,81 @@ int intif_parse(int fd) } // Processing branch switch(cmd){ - case 0x3800: - if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. - clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); - else //Color announce. - clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); - break; - case 0x3801: intif_parse_WisMessage(fd); break; - case 0x3802: intif_parse_WisEnd(fd); break; - case 0x3803: mapif_parse_WisToGM(fd); break; - case 0x3804: intif_parse_Registers(fd); break; - case 0x3806: intif_parse_ChangeNameOk(fd); break; - case 0x3807: intif_parse_MessageToFD(fd); break; - case 0x3818: intif_parse_LoadGuildStorage(fd); break; - case 0x3819: intif_parse_SaveGuildStorage(fd); break; - case 0x3820: intif_parse_PartyCreated(fd); break; - case 0x3821: intif_parse_PartyInfo(fd); break; - case 0x3822: intif_parse_PartyMemberAdded(fd); break; - case 0x3823: intif_parse_PartyOptionChanged(fd); break; - case 0x3824: intif_parse_PartyMemberWithdraw(fd); break; - case 0x3825: intif_parse_PartyMove(fd); break; - case 0x3826: intif_parse_PartyBroken(fd); break; - case 0x3827: intif_parse_PartyMessage(fd); break; - case 0x3830: intif_parse_GuildCreated(fd); break; - case 0x3831: intif_parse_GuildInfo(fd); break; - case 0x3832: intif_parse_GuildMemberAdded(fd); break; - case 0x3834: intif_parse_GuildMemberWithdraw(fd); break; - case 0x3835: intif_parse_GuildMemberInfoShort(fd); break; - case 0x3836: intif_parse_GuildBroken(fd); break; - case 0x3837: intif_parse_GuildMessage(fd); break; - case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break; - case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break; - case 0x383b: intif_parse_GuildPosition(fd); break; - case 0x383c: intif_parse_GuildSkillUp(fd); break; - case 0x383d: intif_parse_GuildAlliance(fd); break; - case 0x383e: intif_parse_GuildNotice(fd); break; - case 0x383f: intif_parse_GuildEmblem(fd); break; - case 0x3840: intif_parse_GuildCastleDataLoad(fd); break; - case 0x3843: intif_parse_GuildMasterChanged(fd); break; - - //Quest system - case 0x3860: intif_parse_questlog(fd); break; - case 0x3861: intif_parse_questsave(fd); break; - -// Mail System - case 0x3848: intif_parse_Mail_inboxreceived(fd); break; - case 0x3849: intif_parse_Mail_new(fd); break; - case 0x384a: intif_parse_Mail_getattach(fd); break; - case 0x384b: intif_parse_Mail_delete(fd); break; - case 0x384c: intif_parse_Mail_return(fd); break; - case 0x384d: intif_parse_Mail_send(fd); break; -// Auction System - case 0x3850: intif_parse_Auction_results(fd); break; - case 0x3851: intif_parse_Auction_register(fd); break; - case 0x3852: intif_parse_Auction_cancel(fd); break; - case 0x3853: intif_parse_Auction_close(fd); break; - case 0x3854: intif_parse_Auction_message(fd); break; - case 0x3855: intif_parse_Auction_bid(fd); break; - -// Mercenary System - case 0x3870: intif_parse_mercenary_received(fd); break; - case 0x3871: intif_parse_mercenary_deleted(fd); break; - case 0x3872: intif_parse_mercenary_saved(fd); break; -// Elemental System - case 0x387c: intif_parse_elemental_received(fd); break; - case 0x387d: intif_parse_elemental_deleted(fd); break; - case 0x387e: intif_parse_elemental_saved(fd); break; - - case 0x3880: intif_parse_CreatePet(fd); break; - case 0x3881: intif_parse_RecvPetData(fd); break; - case 0x3882: intif_parse_SavePetOk(fd); break; - case 0x3883: intif_parse_DeletePetOk(fd); break; - case 0x3890: intif_parse_CreateHomunculus(fd); break; - case 0x3891: intif_parse_RecvHomunculusData(fd); break; - case 0x3892: intif_parse_SaveHomunculusOk(fd); break; - case 0x3893: intif_parse_DeleteHomunculusOk(fd); break; + case 0x3800: + if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. + clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); + else //Color announce. + clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); + break; + case 0x3801: intif->pWisMessage(fd); break; + case 0x3802: intif->pWisEnd(fd); break; + case 0x3803: intif->pWisToGM(fd); break; + case 0x3804: intif->pRegisters(fd); break; + case 0x3806: intif->pChangeNameOk(fd); break; + case 0x3807: intif->pMessageToFD(fd); break; + case 0x3818: intif->pLoadGuildStorage(fd); break; + case 0x3819: intif->pSaveGuildStorage(fd); break; + case 0x3820: intif->pPartyCreated(fd); break; + case 0x3821: intif->pPartyInfo(fd); break; + case 0x3822: intif->pPartyMemberAdded(fd); break; + case 0x3823: intif->pPartyOptionChanged(fd); break; + case 0x3824: intif->pPartyMemberWithdraw(fd); break; + case 0x3825: intif->pPartyMove(fd); break; + case 0x3826: intif->pPartyBroken(fd); break; + case 0x3827: intif->pPartyMessage(fd); break; + case 0x3830: intif->pGuildCreated(fd); break; + case 0x3831: intif->pGuildInfo(fd); break; + case 0x3832: intif->pGuildMemberAdded(fd); break; + case 0x3834: intif->pGuildMemberWithdraw(fd); break; + case 0x3835: intif->pGuildMemberInfoShort(fd); break; + case 0x3836: intif->pGuildBroken(fd); break; + case 0x3837: intif->pGuildMessage(fd); break; + case 0x3839: intif->pGuildBasicInfoChanged(fd); break; + case 0x383a: intif->pGuildMemberInfoChanged(fd); break; + case 0x383b: intif->pGuildPosition(fd); break; + case 0x383c: intif->pGuildSkillUp(fd); break; + case 0x383d: intif->pGuildAlliance(fd); break; + case 0x383e: intif->pGuildNotice(fd); break; + case 0x383f: intif->pGuildEmblem(fd); break; + case 0x3840: intif->pGuildCastleDataLoad(fd); break; + case 0x3843: intif->pGuildMasterChanged(fd); break; + + //Quest system + case 0x3860: intif->pQuestLog(fd); break; + case 0x3861: intif->pQuestSave(fd); break; + + // Mail System + case 0x3848: intif->pMailInboxReceived(fd); break; + case 0x3849: intif->pMailNew(fd); break; + case 0x384a: intif->pMailGetAttach(fd); break; + case 0x384b: intif->pMailDelete(fd); break; + case 0x384c: intif->pMailReturn(fd); break; + case 0x384d: intif->pMailSend(fd); break; + // Auction System + case 0x3850: intif->pAuctionResults(fd); break; + case 0x3851: intif->pAuctionRegister(fd); break; + case 0x3852: intif->pAuctionCancel(fd); break; + case 0x3853: intif->pAuctionClose(fd); break; + case 0x3854: intif->pAuctionMessage(fd); break; + case 0x3855: intif->pAuctionBid(fd); break; + + // Mercenary System + case 0x3870: intif->pMercenaryReceived(fd); break; + case 0x3871: intif->pMercenaryDeleted(fd); break; + case 0x3872: intif->pMercenarySaved(fd); break; + // Elemental System + case 0x387c: intif->pElementalReceived(fd); break; + case 0x387d: intif->pElementalDeleted(fd); break; + case 0x387e: intif->pElementalSaved(fd); break; + + case 0x3880: intif->pCreatePet(fd); break; + case 0x3881: intif->pRecvPetData(fd); break; + case 0x3882: intif->pSavePetOk(fd); break; + case 0x3883: intif->pDeletePetOk(fd); break; + case 0x3890: intif->pCreateHomunculus(fd); break; + case 0x3891: intif->pRecvHomunculusData(fd); break; + case 0x3892: intif->pSaveHomunculusOk(fd); break; + case 0x3893: intif->pDeleteHomunculusOk(fd); break; default: ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0)); return 0; @@ -2245,30 +2121,38 @@ int intif_parse(int fd) * created by Susu *-------------------------------------*/ void intif_defaults(void) { + const int packet_len_table [INTIF_PACKET_LEN_TABLE_SIZE] = { + -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f + 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 + 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 + 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 + -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 + -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] + -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] + -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] + 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 + -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] + }; + intif = &intif_s; - /* funcs */ + /* */ + memcpy(intif->packet_len_table,&packet_len_table,sizeof(intif->packet_len_table)); + /* funcs */ intif->parse = intif_parse; - intif->create_pet = intif_create_pet; - intif->broadcast = intif_broadcast; intif->broadcast2 = intif_broadcast2; intif->main_message = intif_main_message; - intif->wis_message = intif_wis_message; intif->wis_message_to_gm = intif_wis_message_to_gm; - intif->saveregistry = intif_saveregistry; intif->request_registry = intif_request_registry; - intif->request_guild_storage = intif_request_guild_storage; intif->send_guild_storage = intif_send_guild_storage; - intif->create_party = intif_create_party; intif->request_partyinfo = intif_request_partyinfo; - intif->party_addmember = intif_party_addmember; intif->party_changeoption = intif_party_changeoption; intif->party_leave = intif_party_leave; @@ -2276,7 +2160,6 @@ void intif_defaults(void) { intif->break_party = intif_break_party; intif->party_message = intif_party_message; intif->party_leaderchange = intif_party_leaderchange; - intif->guild_create = intif_guild_create; intif->guild_request_info = intif_guild_request_info; intif->guild_addmember = intif_guild_addmember; @@ -2330,6 +2213,68 @@ void intif_defaults(void) { intif->elemental_save = intif_elemental_save; /* @accinfo */ intif->request_accinfo = intif_request_accinfo; - + /* */ intif->CheckForCharServer = CheckForCharServer; + /* */ + intif->pWisMessage = intif_parse_WisMessage; + intif->pWisEnd = intif_parse_WisEnd; + intif->pWisToGM_sub = mapif_parse_WisToGM_sub; + intif->pWisToGM = mapif_parse_WisToGM; + intif->pRegisters = intif_parse_Registers; + intif->pChangeNameOk = intif_parse_ChangeNameOk; + intif->pMessageToFD = intif_parse_MessageToFD; + intif->pLoadGuildStorage = intif_parse_LoadGuildStorage; + intif->pSaveGuildStorage = intif_parse_SaveGuildStorage; + intif->pPartyCreated = intif_parse_PartyCreated; + intif->pPartyInfo = intif_parse_PartyInfo; + intif->pPartyMemberAdded = intif_parse_PartyMemberAdded; + intif->pPartyOptionChanged = intif_parse_PartyOptionChanged; + intif->pPartyMemberWithdraw = intif_parse_PartyMemberWithdraw; + intif->pPartyMove = intif_parse_PartyMove; + intif->pPartyBroken = intif_parse_PartyBroken; + intif->pPartyMessage = intif_parse_PartyMessage; + intif->pGuildCreated = intif_parse_GuildCreated; + intif->pGuildInfo = intif_parse_GuildInfo; + intif->pGuildMemberAdded = intif_parse_GuildMemberAdded; + intif->pGuildMemberWithdraw = intif_parse_GuildMemberWithdraw; + intif->pGuildMemberInfoShort = intif_parse_GuildMemberInfoShort; + intif->pGuildBroken = intif_parse_GuildBroken; + intif->pGuildMessage = intif_parse_GuildMessage; + intif->pGuildBasicInfoChanged = intif_parse_GuildBasicInfoChanged; + intif->pGuildMemberInfoChanged = intif_parse_GuildMemberInfoChanged; + intif->pGuildPosition = intif_parse_GuildPosition; + intif->pGuildSkillUp = intif_parse_GuildSkillUp; + intif->pGuildAlliance = intif_parse_GuildAlliance; + intif->pGuildNotice = intif_parse_GuildNotice; + intif->pGuildEmblem = intif_parse_GuildEmblem; + intif->pGuildCastleDataLoad = intif_parse_GuildCastleDataLoad; + intif->pGuildMasterChanged = intif_parse_GuildMasterChanged; + intif->pQuestLog = intif_parse_QuestLog; + intif->pQuestSave = intif_parse_QuestSave; + intif->pMailInboxReceived = intif_parse_MailInboxReceived; + intif->pMailNew = intif_parse_MailNew; + intif->pMailGetAttach = intif_parse_MailGetAttach; + intif->pMailDelete = intif_parse_MailDelete; + intif->pMailReturn = intif_parse_MailReturn; + intif->pMailSend = intif_parse_MailSend; + intif->pAuctionResults = intif_parse_AuctionResults; + intif->pAuctionRegister = intif_parse_AuctionRegister; + intif->pAuctionCancel = intif_parse_AuctionCancel; + intif->pAuctionClose = intif_parse_AuctionClose; + intif->pAuctionMessage = intif_parse_AuctionMessage; + intif->pAuctionBid = intif_parse_AuctionBid; + intif->pMercenaryReceived = intif_parse_MercenaryReceived; + intif->pMercenaryDeleted = intif_parse_MercenaryDeleted; + intif->pMercenarySaved = intif_parse_MercenarySaved; + intif->pElementalReceived = intif_parse_ElementalReceived; + intif->pElementalDeleted = intif_parse_ElementalDeleted; + intif->pElementalSaved = intif_parse_ElementalSaved; + intif->pCreatePet = intif_parse_CreatePet; + intif->pRecvPetData = intif_parse_RecvPetData; + intif->pSavePetOk = intif_parse_SavePetOk; + intif->pDeletePetOk = intif_parse_DeletePetOk; + intif->pCreateHomunculus = intif_parse_CreateHomunculus; + intif->pRecvHomunculusData = intif_parse_RecvHomunculusData; + intif->pSaveHomunculusOk = intif_parse_SaveHomunculusOk; + intif->pDeleteHomunculusOk = intif_parse_DeleteHomunculusOk; } diff --git a/src/map/intif.h b/src/map/intif.h index 8abcf819d..768e735de 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -1,8 +1,14 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _INTIF_H_ #define _INFIF_H_ -//#include "../common/mmo.h" + + +/** + * Declarations + **/ struct party_member; struct guild_member; struct guild_position; @@ -13,17 +19,13 @@ struct s_elemental; struct mail_message; struct auction_data; - - - - +/** + * Defines + **/ #define intif_rename_pc(sd, name) intif->rename(sd, 0, name) #define intif_rename_pet(sd, name) intif->rename(sd, 1, name) #define intif_rename_hom(sd, name) intif->rename(sd, 2, name) - - - - +#define INTIF_PACKET_LEN_TABLE_SIZE 161 /*===================================== @@ -32,30 +34,23 @@ struct auction_data; * created by Susu *-------------------------------------*/ struct intif_interface { + /* */ + int packet_len_table[INTIF_PACKET_LEN_TABLE_SIZE]; /* funcs */ - - int (*parse) (int fd); - int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, - short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); - + short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); int (*broadcast) (const char* mes, int len, int type); int (*broadcast2) (const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY); int (*main_message) (struct map_session_data* sd, const char* message); - int (*wis_message) (struct map_session_data *sd,char *nick,char *mes,int mes_len); int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes); - int (*saveregistry) (struct map_session_data *sd, int type); int (*request_registry) (struct map_session_data *sd, int flag); - int (*request_guild_storage) (int account_id, int guild_id); int (*send_guild_storage) (int account_id, struct guild_storage *gstor); - int (*create_party) (struct party_member *member,char *name,int item,int item2); int (*request_partyinfo) (int party_id, int char_id); - int (*party_addmember) (int party_id,struct party_member *member); int (*party_changeoption) (int party_id, int account_id, int exp, int item); int (*party_leave) (int party_id,int account_id, int char_id); @@ -63,7 +58,6 @@ struct intif_interface { int (*break_party) (int party_id); int (*party_message) (int party_id, int account_id, const char *mes,int len); int (*party_leaderchange) (int party_id,int account_id,int char_id); - int (*guild_create) (const char *name, const struct guild_member *master); int (*guild_request_info) (int guild_id); int (*guild_addmember) (int guild_id, struct guild_member *m); @@ -117,9 +111,71 @@ struct intif_interface { int (*elemental_save) (struct s_elemental *ele); /* @accinfo */ void (*request_accinfo) (int u_fd, int aid, int group_lv, char* query); - + /* */ int (*CheckForCharServer) (void); -} intif_s; + /* */ + void (*pWisMessage) (int fd); + void (*pWisEnd) (int fd); + int (*pWisToGM_sub) (struct map_session_data* sd,va_list va); + void (*pWisToGM) (int fd); + void (*pRegisters) (int fd); + void (*pChangeNameOk) (int fd); + void (*pMessageToFD) (int fd); + void (*pLoadGuildStorage) (int fd); + void (*pSaveGuildStorage) (int fd); + void (*pPartyCreated) (int fd); + void (*pPartyInfo) (int fd); + void (*pPartyMemberAdded) (int fd); + void (*pPartyOptionChanged) (int fd); + void (*pPartyMemberWithdraw) (int fd); + void (*pPartyMove) (int fd); + void (*pPartyBroken) (int fd); + void (*pPartyMessage) (int fd); + void (*pGuildCreated) (int fd); + void (*pGuildInfo) (int fd); + void (*pGuildMemberAdded) (int fd); + void (*pGuildMemberWithdraw) (int fd); + void (*pGuildMemberInfoShort) (int fd); + void (*pGuildBroken) (int fd); + void (*pGuildMessage) (int fd); + void (*pGuildBasicInfoChanged) (int fd); + void (*pGuildMemberInfoChanged) (int fd); + void (*pGuildPosition) (int fd); + void (*pGuildSkillUp) (int fd); + void (*pGuildAlliance) (int fd); + void (*pGuildNotice) (int fd); + void (*pGuildEmblem) (int fd); + void (*pGuildCastleDataLoad) (int fd); + void (*pGuildMasterChanged) (int fd); + void (*pQuestLog) (int fd); + void (*pQuestSave) (int fd); + void (*pMailInboxReceived) (int fd); + void (*pMailNew) (int fd); + void (*pMailGetAttach) (int fd); + void (*pMailDelete) (int fd); + void (*pMailReturn) (int fd); + void (*pMailSend) (int fd); + void (*pAuctionResults) (int fd); + void (*pAuctionRegister) (int fd); + void (*pAuctionCancel) (int fd); + void (*pAuctionClose) (int fd); + void (*pAuctionMessage) (int fd); + void (*pAuctionBid) (int fd); + void (*pMercenaryReceived) (int fd); + void (*pMercenaryDeleted) (int fd); + void (*pMercenarySaved) (int fd); + void (*pElementalReceived) (int fd); + void (*pElementalDeleted) (int fd); + void (*pElementalSaved) (int fd); + void (*pCreatePet) (int fd); + void (*pRecvPetData) (int fd); + void (*pSavePetOk) (int fd); + void (*pDeletePetOk) (int fd); + void (*pCreateHomunculus) (int fd); + void (*pRecvHomunculusData) (int fd); + void (*pSaveHomunculusOk) (int fd); + void (*pDeleteHomunculusOk) (int fd); +}; struct intif_interface *intif; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index ee0eea5ff..f7ee8a884 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -354,7 +354,10 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) if (jobmask & 1<<23) //Soul Linker bclass[2] |= 1<<MAPID_TAEKWON; if (jobmask & 1<<JOB_GUNSLINGER) + {//Rebellion job can equip Gunslinger equips. [Rytech] bclass[0] |= 1<<MAPID_GUNSLINGER; + bclass[1] |= 1<<MAPID_GUNSLINGER; + } if (jobmask & 1<<JOB_NINJA) {bclass[0] |= 1<<MAPID_NINJA; bclass[1] |= 1<<MAPID_NINJA;}//Kagerou/Oboro jobs can equip Ninja equips. [Rytech] @@ -366,6 +369,8 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) bclass[2] |= 1<<MAPID_GANGSI; if (jobmask & 1<<29) //Kagerou / Oboro bclass[1] |= 1<<MAPID_NINJA; + if (jobmask & 1<<30) //Rebellion + bclass[1] |= 1<<MAPID_GUNSLINGER; } void create_dummy_data(void) diff --git a/src/map/log.c b/src/map/log.c index 929143ba7..5d88e3df4 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -20,36 +20,8 @@ struct log_interface log_s; -/// filters for item logging -typedef enum e_log_filter { - LOG_FILTER_NONE = 0x000, - LOG_FILTER_ALL = 0x001, - // bits - LOG_FILTER_HEALING = 0x002, // Healing items (0) - LOG_FILTER_ETC_AMMO = 0x004, // Etc Items(3) + Arrows (10) - LOG_FILTER_USABLE = 0x008, // Usable Items(2) + Scrolls, Lures(11) + Usable Cash Items(18) - LOG_FILTER_WEAPON = 0x010, // Weapons(4) - LOG_FILTER_ARMOR = 0x020, // Shields, Armors, Headgears, Accessories, Garments and Shoes(5) - LOG_FILTER_CARD = 0x040, // Cards(6) - LOG_FILTER_PETITEM = 0x080, // Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs) - LOG_FILTER_PRICE = 0x100, // Log expensive items ( >= price_log ) - LOG_FILTER_AMOUNT = 0x200, // Log large amount of items ( >= amount_log ) - LOG_FILTER_REFINE = 0x400, // Log refined items ( refine >= refine_log ) [not implemented] - LOG_FILTER_CHANCE = 0x800, // Log rare items and Emperium ( drop chance <= rare_log ) -} -e_log_filter; - -#ifdef SQL_INNODB -// database is using an InnoDB engine so do not use DELAYED -#define LOG_QUERY "INSERT" -#else -// database is using a MyISAM engine so use DELAYED -#define LOG_QUERY "INSERT DELAYED" -#endif - - /// obtain log type character for item/zeny logs -static char log_picktype2char(e_log_pick_type type) { +char log_picktype2char(e_log_pick_type type) { switch( type ) { case LOG_TYPE_TRADE: return 'T'; // (T)rade case LOG_TYPE_VENDING: return 'V'; // (V)ending @@ -78,7 +50,7 @@ static char log_picktype2char(e_log_pick_type type) { /// obtain log type character for chat logs -static char log_chattype2char(e_log_chat_type type) { +char log_chattype2char(e_log_chat_type type) { switch( type ) { case LOG_CHAT_GLOBAL: return 'O'; // Gl(O)bal case LOG_CHAT_WHISPER: return 'W'; // (W)hisper @@ -94,7 +66,7 @@ static char log_chattype2char(e_log_chat_type type) { /// check if this item should be logged according the settings -static bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { +bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { int filter = logs->config.filter; if( id == NULL ) @@ -156,7 +128,7 @@ void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) " "VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", - logs->config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + logs->config.log_pick, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], maplist[m].name?maplist[m].name:"", itm->unique_id) ) { Sql_ShowDebug(logmysql_handle); @@ -173,7 +145,7 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", - timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + timestring, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], maplist[m].name?maplist[m].name:"", itm->unique_id); fclose(logfp); } @@ -184,7 +156,7 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it return; } - if( !should_log_item(itm->nameid, amount, itm->refine, data) ) + if( !logs->should_log_item(itm->nameid, amount, itm->refine, data) ) return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus] logs->pick_sub(id,m,type,amount,itm,data); @@ -204,7 +176,7 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct } void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) { if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", - logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) + logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, logs->picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) { Sql_ShowDebug(logmysql_handle); return; @@ -343,7 +315,7 @@ void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src SqlStmt* stmt; stmt = SQL->StmtMalloc(logmysql_handle); - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, logs->chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX)) || SQL_SUCCESS != SQL->StmtExecute(stmt) @@ -363,7 +335,7 @@ void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); + fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, logs->chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); fclose(logfp); } @@ -530,4 +502,7 @@ void log_defaults(void) { logs->config_read = log_config_read; logs->config_done = log_config_complete; + logs->picktype2char = log_picktype2char; + logs->chattype2char = log_chattype2char; + logs->should_log_item = should_log_item; } diff --git a/src/map/log.h b/src/map/log.h index 1da1696ab..caf9ce0c5 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -5,13 +5,32 @@ #ifndef _LOG_H_ #define _LOG_H_ +#include "../common/cbasetypes.h" +#include "../common/sql.h" + +/** + * Declarations + **/ struct block_list; struct map_session_data; struct mob_data; struct item; struct item_data; +/** + * Defines + **/ +#ifdef SQL_INNODB +// database is using an InnoDB engine so do not use DELAYED + #define LOG_QUERY "INSERT" +#else +// database is using a MyISAM engine so use DELAYED + #define LOG_QUERY "INSERT DELAYED" +#endif +/** + * Enumerations + **/ typedef enum e_log_chat_type { LOG_CHAT_GLOBAL = 0x01, LOG_CHAT_WHISPER = 0x02, @@ -22,7 +41,6 @@ typedef enum e_log_chat_type { LOG_CHAT_ALL = 0xFF, } e_log_chat_type; - typedef enum e_log_pick_type { LOG_TYPE_NONE = 0, LOG_TYPE_TRADE = 0x00001, @@ -48,6 +66,24 @@ typedef enum e_log_pick_type { LOG_TYPE_ALL = 0xFFFFF, } e_log_pick_type; +/// filters for item logging +typedef enum e_log_filter { + LOG_FILTER_NONE = 0x000, + LOG_FILTER_ALL = 0x001, + // bits + LOG_FILTER_HEALING = 0x002, // Healing items (0) + LOG_FILTER_ETC_AMMO = 0x004, // Etc Items(3) + Arrows (10) + LOG_FILTER_USABLE = 0x008, // Usable Items(2) + Scrolls, Lures(11) + Usable Cash Items(18) + LOG_FILTER_WEAPON = 0x010, // Weapons(4) + LOG_FILTER_ARMOR = 0x020, // Shields, Armors, Headgears, Accessories, Garments and Shoes(5) + LOG_FILTER_CARD = 0x040, // Cards(6) + LOG_FILTER_PETITEM = 0x080, // Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs) + LOG_FILTER_PRICE = 0x100, // Log expensive items ( >= price_log ) + LOG_FILTER_AMOUNT = 0x200, // Log large amount of items ( >= amount_log ) + LOG_FILTER_REFINE = 0x400, // Log refined items ( refine >= refine_log ) [not implemented] + LOG_FILTER_CHANCE = 0x800, // Log rare items and Emperium ( drop chance <= rare_log ) +} e_log_filter; + struct log_interface { struct { e_log_pick_type enable_logs; @@ -78,6 +114,10 @@ struct log_interface { int (*config_read) (const char* cfgName); void (*config_done) (void); + + char (*picktype2char) (e_log_pick_type type); + char (*chattype2char) (e_log_chat_type type); + bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id); }; struct log_interface *logs; diff --git a/src/map/map.c b/src/map/map.c index e121f0d55..ea05208a6 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -624,8 +624,8 @@ int map_foreachininstance(int (*func)(struct block_list*, va_list), int16 instan int i; int returnCount = 0; - for (i = 0; i < instances[instance_id].num_map; i++) { - int m = instances[instance_id].map[i]; + for (i = 0; i < instance->list[instance_id].num_map; i++) { + int m = instance->list[instance_id].map[i]; va_list ap; va_start(ap, type); returnCount += map_vforeachinmap(func, m, type, ap); @@ -4905,9 +4905,9 @@ void do_final(void) script->final(); itemdb->final(); instance->final(); - storage->final(); + gstorage->final(); guild->final(); - party->do_final_party(); + party->final(); pc->do_final_pc(); pet->final(); mob->final(); @@ -4918,7 +4918,7 @@ void do_final(void) unit->final(); bg->final(); duel->final(); - elemental->do_final_elemental(); + elemental->final(); do_final_maps(); vending->final(); @@ -5387,13 +5387,13 @@ int do_init(int argc, char *argv[]) mob->init(); pc->do_init_pc(); status->init(); - party->do_init_party(); + party->init(); guild->init(); - storage->init(); + gstorage->init(); pet->init(); homun->init(); mercenary->init(); - elemental->do_init_elemental(); + elemental->init(); quest->init(); npc->init(); unit->init(); diff --git a/src/map/map.h b/src/map/map.h index 4b06a065b..f3a74ed2e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -99,6 +99,7 @@ enum { MAPID_BLACKSMITH, MAPID_ASSASSIN, MAPID_STAR_GLADIATOR, + MAPID_REBELLION = JOBL_2_1|0x09, MAPID_KAGEROUOBORO = JOBL_2_1|0x0A, MAPID_DEATH_KNIGHT = JOBL_2_1|0x0E, //2-2 Jobs diff --git a/src/map/mercenary.c b/src/map/mercenary.c index a1e2986b2..8b8353f46 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -50,12 +50,12 @@ int merc_search_index(int class_) bool merc_class(int class_) { - return (bool)(merc_search_index(class_) > -1); + return (bool)(mercenary->search_index(class_) > -1); } struct view_data * merc_get_viewdata(int class_) { - int i = merc_search_index(class_); + int i = mercenary->search_index(class_); if( i < 0 ) return 0; @@ -69,7 +69,7 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime) int i; nullpo_retr(0,sd); - if( (i = merc_search_index(class_)) < 0 ) + if( (i = mercenary->search_index(class_)) < 0 ) return 0; db = &mercenary->db[i]; @@ -217,7 +217,7 @@ int mercenary_save(struct mercenary_data *md) return 1; } -static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) { +int merc_contract_end_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct mercenary_data *md; @@ -228,7 +228,7 @@ static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) if( md->contract_timer != tid ) { - ShowError("merc_contract_end %d != %d.\n", md->contract_timer, tid); + ShowError("merc_contract_end_timer %d != %d.\n", md->contract_timer, tid); return 0; } @@ -268,14 +268,14 @@ void merc_contract_stop(struct mercenary_data *md) { nullpo_retv(md); if( md->contract_timer != INVALID_TIMER ) - timer->delete(md->contract_timer, merc_contract_end); + timer->delete(md->contract_timer, mercenary->contract_end_timer); md->contract_timer = INVALID_TIMER; } void merc_contract_init(struct mercenary_data *md) { if( md->contract_timer == INVALID_TIMER ) - md->contract_timer = timer->add(timer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0); + md->contract_timer = timer->add(timer->gettick() + md->mercenary.life_time, mercenary->contract_end_timer, md->master->bl.id, 0); md->regen.state.block = 0; } @@ -284,7 +284,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) { struct map_session_data *sd; struct mercenary_data *md; struct s_mercenary_db *db; - int i = merc_search_index(merc->class_); + int i = mercenary->search_index(merc->class_); if( (sd = map->charid2sd(merc->char_id)) == NULL ) return 0; @@ -372,7 +372,7 @@ int mercenary_kills(struct mercenary_data *md) if( (md->mercenary.kill_count % 50) == 0 ) { mercenary->set_faith(md, 1); - mercenary_killbonus(md); + mercenary->killbonus(md); } if( md->master ) @@ -393,7 +393,7 @@ int mercenary_checkskill(struct mercenary_data *md, uint16 skill_id) return 0; } -static bool read_mercenarydb_sub(char* str[], int columns, int current) { +bool read_mercenarydb_sub(char* str[], int columns, int current) { int ele; struct s_mercenary_db *db; struct status_data *mstatus; @@ -448,12 +448,12 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current) { int read_mercenarydb(void) { memset(mercenary->db,0,sizeof(mercenary->db)); - sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); + sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, mercenary->read_db_sub); return 0; } -static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) +bool read_mercenary_skilldb_sub(char* str[], int columns, int current) {// <merc id>,<skill id>,<skill level> struct s_mercenary_db *db; int i, class_; @@ -485,22 +485,18 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) } int read_mercenary_skilldb(void) { - sv->readdb(map->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); + sv->readdb(map->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, mercenary->read_skill_db_sub); return 0; } -int do_init_mercenary(void) -{ +void do_init_mercenary(void) { mercenary->read_db(); mercenary->read_skilldb(); - //add_timer_func_list(mercenary_contract, "mercenary_contract"); - return 0; + timer->add_func_list(mercenary->contract_end_timer, "merc_contract_end_timer"); } -int do_final_mercenary(void); - /*===================================== * Default Functions : mercenary.h * Generated by HerculesInterfaceMaker @@ -539,5 +535,12 @@ void mercenary_defaults(void) { mercenary->checkskill = mercenary_checkskill; mercenary->read_db = read_mercenarydb; - mercenary->read_skilldb = read_mercenary_skilldb; + mercenary->read_skilldb = read_mercenary_skilldb; + + mercenary->killbonus = mercenary_killbonus; + mercenary->search_index = merc_search_index; + + mercenary->contract_end_timer = merc_contract_end_timer; + mercenary->read_db_sub = read_mercenarydb_sub; + mercenary->read_skill_db_sub = read_mercenary_skilldb_sub; } diff --git a/src/map/mercenary.h b/src/map/mercenary.h index b59a1c808..47f37ac66 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #ifndef _MERCENARY_H_ #define _MERCENARY_H_ @@ -58,7 +59,7 @@ struct mercenary_interface { /* funcs */ - int (*init) (void); + void (*init) (void); bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); @@ -83,7 +84,14 @@ struct mercenary_interface { int (*checkskill) (struct mercenary_data *md, uint16 skill_id); int (*read_db) (void); - int (*read_skilldb) (void); + int (*read_skilldb) (void); + + int (*killbonus) (struct mercenary_data *md); + int (*search_index) (int class_); + + int (*contract_end_timer) (int tid, unsigned int tick, int id, intptr_t data); + bool (*read_db_sub) (char* str[], int columns, int current); + bool (*read_skill_db_sub) (char* str[], int columns, int current); }; struct mercenary_interface *mercenary; diff --git a/src/map/packets.h b/src/map/packets.h index 8fcc6c863..326d436a8 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2369,6 +2369,38 @@ packet(0x020d,-1); packet(0x097C,4,clif->pRanklist); #endif +//2013-08-07Ragexe (Shakto) +#if PACKETVER >= 20130807 + packet(0x0369,7,clif->pActionRequest,2,6); + packet(0x083C,10,clif->pUseSkillToId,2,4,6); + packet(0x0437,5,clif->pWalkToXY,2); + packet(0x035F,6,clif->pTickSend,2); + packet(0x0202,5,clif->pChangeDir,2,4); + packet(0x07E4,6,clif->pTakeItem,2); + packet(0x0362,6,clif->pDropItem,2,4); + packet(0x07EC,8,clif->pMoveToKafra,2,4); + packet(0x0364,8,clif->pMoveFromKafra,2,4); + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x096A,6,clif->pGetCharNameRequest,2); + packet(0x0368,6,clif->pSolveCharName,2); + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x0360,6,clif->pReqClickBuyingStore,2); + packet(0x0817,2,clif->pReqCloseBuyingStore,0); + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x0365,41,clif->pPartyBookingRegisterReq,2,4); + // packet(0x0363,8); // CZ_JOIN_BATTLE_FIELD + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x022D,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0802,26,clif->pPartyInvite2,2); + // packet(0x0436,4); // CZ_GANGSI_RANK + packet(0x023B,26,clif->pFriendsListAdd,2); + packet(0x0361,5,clif->pHomMenu,2,4); + packet(0x0887,36,clif->pStoragePassword,0); +#endif /* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */ #if PACKETVER >= 20110817 @@ -2559,5 +2591,8 @@ packet(0x020d,-1); packetKeys(0x4FF90E23,0x0F1432F2,0x4CFA1EDA); /* Thanks to Shakto */ #endif +#if PACKETVER >= 20130807 + packetKeys(0x7E241DE0,0x5E805580,0x3D807D80); /* Thanks to Shakto */ +#endif #endif /* _PACKETS_H_ */ diff --git a/src/map/party.c b/src/map/party.c index a4eb38629..29ab5044c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" @@ -29,20 +30,13 @@ #include <string.h> -static DBMap* party_db; // int party_id -> struct party_data* (releases data) -static DBMap* party_booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] -static unsigned long party_booking_nextid = 1; - struct party_interface party_s; -int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); - /*========================================== * Fills the given party_member structure according to the sd provided. * Used when creating/adding people to a party. [Skotlex] *------------------------------------------*/ -static void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) -{ +void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) { member->account_id = sd->status.account_id; member->char_id = sd->status.char_id; safestrncpy(member->name, sd->status.name, NAME_LENGTH); @@ -54,8 +48,7 @@ static void party_fill_member(struct party_member* member, struct map_session_da } /// Get the member_id of a party member. /// Return -1 if not in party. -int party_getmemberid(struct party_data* p, struct map_session_data* sd) -{ +int party_getmemberid(struct party_data* p, struct map_session_data* sd) { int member_id; nullpo_retr(-1, p); if( sd == NULL ) @@ -68,7 +61,6 @@ int party_getmemberid(struct party_data* p, struct map_session_data* sd) return member_id; } - /*========================================== * Request an available sd of this party *------------------------------------------*/ @@ -83,8 +75,7 @@ struct map_session_data* party_getavailablesd(struct party_data *p) /*========================================== * Retrieves and validates the sd pointer for this party member [Skotlex] *------------------------------------------*/ - -static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { +TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) @@ -108,30 +99,12 @@ int party_db_final(DBKey key, DBData *data, va_list ap) { return 0; } -/*========================================== - * Destructor - * Called in map shutdown, cleanup var - *------------------------------------------*/ -void do_final_party(void) -{ - party_db->destroy(party_db,party_db_final); - party_booking_db->destroy(party_booking_db,NULL); // Party Booking [Spiria] -} -// Constructor, init vars -void do_init_party(void) -{ - party_db = idb_alloc(DB_OPT_RELEASE_DATA); - party_booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] - timer->add_func_list(party_send_xy_timer, "party_send_xy_timer"); - timer->add_interval(timer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval); -} - /// Party data lookup using party id. struct party_data* party_search(int party_id) { if(!party_id) return NULL; - return (struct party_data*)idb_get(party_db,party_id); + return (struct party_data*)idb_get(party->db,party_id); } /// Party data lookup using party name. @@ -139,7 +112,7 @@ struct party_data* party_searchname(const char* str) { struct party_data* p; - DBIterator *iter = db_iterator(party_db); + DBIterator *iter = db_iterator(party->db); for( p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter) ) { if( strncmpi(p->party.name,str,NAME_LENGTH) == 0 ) @@ -171,7 +144,7 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) sd->party_creating = true; - party_fill_member(&leader, sd, 1); + party->fill_member(&leader, sd, 1); intif->create_party(&leader,name,item,item2); return 0; @@ -219,29 +192,27 @@ int party_recv_noinfo(int party_id, int char_id) { return 0; } -static void party_check_state(struct party_data *p) -{ +void party_check_state(struct party_data *p) { int i; memset(&p->state, 0, sizeof(p->state)); - for (i = 0; i < MAX_PARTY; i ++) - { + for (i = 0; i < MAX_PARTY; i ++) { if (!p->party.member[i].online) continue; //Those not online shouldn't aport to skill usage and all that. switch (p->party.member[i].class_) { - case JOB_MONK: - case JOB_BABY_MONK: - case JOB_CHAMPION: - p->state.monk = 1; - break; - case JOB_STAR_GLADIATOR: - p->state.sg = 1; - break; - case JOB_SUPER_NOVICE: - case JOB_SUPER_BABY: - p->state.snovice = 1; - break; - case JOB_TAEKWON: - p->state.tk = 1; - break; + case JOB_MONK: + case JOB_BABY_MONK: + case JOB_CHAMPION: + p->state.monk = 1; + break; + case JOB_STAR_GLADIATOR: + p->state.sg = 1; + break; + case JOB_SUPER_NOVICE: + case JOB_SUPER_BABY: + p->state.snovice = 1; + break; + case JOB_TAEKWON: + p->state.tk = 1; + break; } } } @@ -260,7 +231,7 @@ int party_recv_info(struct party* sp, int char_id) nullpo_ret(sp); - p = (struct party_data*)idb_get(party_db, sp->party_id); + p = (struct party_data*)idb_get(party->db, sp->party_id); if( p != NULL ) {// diff members for( member_id = 0; member_id < MAX_PARTY; ++member_id ) { member = &p->party.member[member_id]; @@ -289,7 +260,7 @@ int party_recv_info(struct party* sp, int char_id) CREATE(p, struct party_data, 1); p->instance = NULL; p->instances = 0; - idb_put(party_db, sp->party_id, p); + idb_put(party->db, sp->party_id, p); } while( removed_count > 0 ) {// no longer in party member_id = removed[--removed_count]; @@ -305,9 +276,9 @@ int party_recv_info(struct party* sp, int char_id) member = &p->party.member[member_id]; if ( member->char_id == 0 ) continue;// empty - p->data[member_id].sd = party_sd_check(sp->party_id, member->account_id, member->char_id); + p->data[member_id].sd = party->sd_check(sp->party_id, member->account_id, member->char_id); } - party_check_state(p); + party->check_state(p); while( added_count > 0 ) { // new in party member_id = added[--added_count]; sd = p->data[member_id].sd; @@ -319,7 +290,7 @@ int party_recv_info(struct party* sp, int char_id) clif->party_info(p,NULL); for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -412,7 +383,7 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) { if( flag == 1 && !sd->party_creating && !sd->party_joining ) {// accepted and allowed sd->party_joining = true; - party_fill_member(&member, sd, 0); + party->fill_member(&member, sd, 0); intif->party_addmember(sd->party_invite, &member); } else @@ -442,7 +413,7 @@ void party_member_joined(struct map_session_data *sd) p->data[i].sd = sd; for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -504,7 +475,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) { for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -571,7 +542,7 @@ int party_member_withdraw(int party_id, int account_id, int char_id) memset(&p->party.member[i], 0, sizeof(p->party.member[0])); memset(&p->data[i], 0, sizeof(p->data[0])); p->party.count--; - party_check_state(p); + party->check_state(p); } } @@ -604,7 +575,7 @@ int party_broken(int party_id) for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { instance->destroy( p->instance[j] ); - instances[p->instance[j]].owner_id = 0; + instance->list[p->instance[j]].owner_id = 0; } } @@ -615,7 +586,7 @@ int party_broken(int party_id) } } - idb_remove(party_db,party_id); + idb_remove(party->db,party_id); return 0; } @@ -722,7 +693,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m m->online = online; m->lv = lv; //Check if they still exist on this map server - p->data[i].sd = party_sd_check(party_id, account_id, char_id); + p->data[i].sd = party->sd_check(party_id, account_id, char_id); clif->party_info(p,NULL); return 0; @@ -864,7 +835,7 @@ int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { struct party_data* p; - DBIterator *iter = db_iterator(party_db); + DBIterator *iter = db_iterator(party->db); // for each existing party, for( p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter) ) { @@ -1111,11 +1082,10 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess * Party Booking in KRO [Spiria] *------------------------------------------*/ -static struct party_booking_ad_info* create_party_booking_data(void) -{ +struct party_booking_ad_info* create_party_booking_data(void) { struct party_booking_ad_info *pb_ad; CREATE(pb_ad, struct party_booking_ad_info, 1); - pb_ad->index = party_booking_nextid++; + pb_ad->index = party->booking_nextid++; return pb_ad; } @@ -1130,12 +1100,12 @@ void party_booking_register(struct map_session_data *sd, short level, const char int i; #endif - pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id); + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) { - pb_ad = create_party_booking_data(); - idb_put(party_booking_db, sd->status.char_id, pb_ad); + pb_ad = party->create_booking_data(); + idb_put(party->booking_db, sd->status.char_id, pb_ad); } else {// already registered @@ -1172,7 +1142,7 @@ void party_booking_update(struct map_session_data *sd, const char *notice) #endif struct party_booking_ad_info *pb_ad; - pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id); + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); if( pb_ad == NULL ) return; @@ -1206,7 +1176,7 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid, int count = 0; struct party_booking_ad_info* result_list[PARTY_BOOKING_RESULTS]; bool more_result = false; - DBIterator* iter = db_iterator(party_booking_db); + DBIterator* iter = db_iterator(party->booking_db); memset(result_list, 0, sizeof(result_list)); @@ -1250,14 +1220,24 @@ bool party_booking_delete(struct map_session_data *sd) { struct party_booking_ad_info* pb_ad; - if((pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id))!=NULL) + if((pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id))!=NULL) { clif->PartyBookingDeleteNotify(sd, pb_ad->index); - idb_remove(party_booking_db,sd->status.char_id); + idb_remove(party->booking_db,sd->status.char_id); } return true; } - +void do_final_party(void) { + party->db->destroy(party->db,party->db_final); + db_destroy(party->booking_db); // Party Booking [Spiria] +} +// Constructor, init vars +void do_init_party(void) { + party->db = idb_alloc(DB_OPT_RELEASE_DATA); + party->booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] + timer->add_func_list(party->send_xy_timer, "party_send_xy_timer"); + timer->add_interval(timer->gettick()+battle_config.party_update_interval, party->send_xy_timer, 0, 0, battle_config.party_update_interval); +} /*===================================== * Default Functions : party.h * Generated by HerculesInterfaceMaker @@ -1266,10 +1246,14 @@ bool party_booking_delete(struct map_session_data *sd) void party_defaults(void) { party = &party_s; + /* */ + party->db = NULL; + party->booking_db = NULL; + party->booking_nextid = 1; /* funcs */ - - party->do_init_party = do_init_party; - party->do_final_party = do_final_party; + party->init = do_init_party; + party->final = do_final_party; + /* */ party->search = party_search; party->searchname = party_searchname; party->getmemberid = party_getmemberid; @@ -1307,4 +1291,11 @@ void party_defaults(void) { party->booking_update = party_booking_update; party->booking_search = party_booking_search; party->booking_delete = party_booking_delete; + party->foreachsamemap = party_foreachsamemap; + party->send_xy_timer = party_send_xy_timer; + party->fill_member = party_fill_member; + party->sd_check = party_sd_check; + party->check_state = party_check_state; + party->create_booking_data = create_party_booking_data; + party->db_final = party_db_final; } diff --git a/src/map/party.h b/src/map/party.h index 7ade6b841..c2c13cc4f 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -1,16 +1,16 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _PARTY_H_ #define _PARTY_H_ + #include "../common/mmo.h" // struct party #include "../config/core.h" -struct block_list; -struct map_session_data; -struct party; -struct item; - #include <stdarg.h> +#include "map.h" + #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 @@ -47,7 +47,7 @@ struct party_booking_ad_info { long expiretime; struct party_booking_detail p_detail; }; -#else +#else /* PARTY_RECRUIT */ #define PB_NOTICE_LENGTH (36 + 1) struct party_booking_detail { short level; @@ -60,14 +60,7 @@ struct party_booking_ad_info { char charname[NAME_LENGTH]; struct party_booking_detail p_detail; }; -#endif - - -int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range,...); - -/*========================================== - * Party Booking in KRO [Spiria] - *------------------------------------------*/ +#endif /* PARTY_RECRUIT */ /*===================================== * Interface : party.h @@ -75,11 +68,13 @@ int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_ses * created by Susu *-------------------------------------*/ struct party_interface { - + DBMap* db; // int party_id -> struct party_data* (releases data) + DBMap* booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] + unsigned long booking_nextid; /* funcs */ - - void (*do_init_party) (void); - void (*do_final_party) (void); + void (*init) (void); + void (*final) (void); + /* */ struct party_data* (*search) (int party_id); struct party_data* (*searchname) (const char* str); int (*getmemberid) (struct party_data* p, struct map_session_data* sd); @@ -113,16 +108,27 @@ struct party_interface { int (*share_loot) (struct party_data* p, struct map_session_data* sd, struct item* item_data, int first_charid); int (*send_dot_remove) (struct map_session_data *sd); int (*sub_count) (struct block_list *bl, va_list ap); + /*========================================== + * Party Booking in KRO [Spiria] + *------------------------------------------*/ #ifndef PARTY_RECRUIT void (*booking_register) (struct map_session_data *sd, short level, short mapid, short* job); void (*booking_update) (struct map_session_data *sd, short* job); void (*booking_search) (struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount); -#else +#else /* PARTY_RECRUIT */ void (*booking_register) (struct map_session_data *sd, short level, const char *notice); void (*booking_update) (struct map_session_data *sd, const char *notice); void (*booking_search) (struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount); #endif bool (*booking_delete) (struct map_session_data *sd); + /* */ + int (*foreachsamemap) (int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range,...); + int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); + void (*fill_member) (struct party_member* member, struct map_session_data* sd, unsigned int leader); + TBL_PC* (*sd_check) (int party_id, int account_id, int char_id); + void (*check_state) (struct party_data *p); + struct party_booking_ad_info* (*create_booking_data) (void); + int (*db_final) (DBKey key, DBData *data, va_list ap); }; struct party_interface *party; diff --git a/src/map/pc.c b/src/map/pc.c index d11eb7e75..362ee0873 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -337,7 +337,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { c = 0; memset(b_sd, 0, sizeof(b_sd)); - i = party_foreachsamemap(pc_check_banding,sd,range,&sd->bl,&c,&b_sd); + i = party->foreachsamemap(pc_check_banding,sd,range,&sd->bl,&c,&b_sd); if( c < 1 ) { //just recalc status no need to recalc hp @@ -4714,7 +4714,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil } if(battle_config.show_steal_in_same_party) - party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid); + party->foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid); //Logs items, Stolen from mobs [Lupus] logs->pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item, data); @@ -4791,13 +4791,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->instance[i]].map[j]].custom_name); - if( j != instances[sd->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->instance[i]].map[j]].custom_name); + if( j != instance->list[sd->instance[i]].num_map ) break; } } if( i != sd->instances ) { - m = instances[sd->instance[i]].map[j]; + m = instance->list[sd->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } @@ -4805,13 +4805,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m && !maplist[instances[p->instance[i]].map[j]].custom_name); - if( j != instances[p->instance[i]].num_map ) + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[p->instance[i]].map[j]].custom_name); + if( j != instance->list[p->instance[i]].num_map ) break; } } if( i != p->instances ) { - m = instances[p->instance[i]].map[j]; + m = instance->list[p->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } @@ -4819,13 +4819,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.guild_id && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->guild->instance[i]].map[j]].custom_name); - if( j != instances[sd->guild->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->guild->instance[i]].map[j]].custom_name); + if( j != instance->list[sd->guild->instance[i]].num_map ) break; } } if( i != sd->guild->instances ) { - m = instances[sd->guild->instance[i]].map[j]; + m = instance->list[sd->guild->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } @@ -5207,6 +5207,7 @@ int pc_jobid2mapid(unsigned short b_class) case JOB_STAR_GLADIATOR: return MAPID_STAR_GLADIATOR; case JOB_KAGEROU: case JOB_OBORO: return MAPID_KAGEROUOBORO; + case JOB_REBELLION: return MAPID_REBELLION; case JOB_DEATH_KNIGHT: return MAPID_DEATH_KNIGHT; //2-2 Jobs case JOB_CRUSADER: return MAPID_CRUSADER; @@ -5347,6 +5348,7 @@ int pc_mapid2jobid(unsigned short class_, int sex) case MAPID_ASSASSIN: return JOB_ASSASSIN; case MAPID_STAR_GLADIATOR: return JOB_STAR_GLADIATOR; case MAPID_KAGEROUOBORO: return sex?JOB_KAGEROU:JOB_OBORO; + case MAPID_REBELLION: return JOB_REBELLION; case MAPID_DEATH_KNIGHT: return JOB_DEATH_KNIGHT; //2-2 Jobs case MAPID_CRUSADER: return JOB_CRUSADER; @@ -5663,6 +5665,8 @@ const char* job_name(int class_) case JOB_KAGEROU: case JOB_OBORO: return msg_txt(653 - JOB_KAGEROU+class_); + case JOB_REBELLION: + return msg_txt(694); default: return msg_txt(655); @@ -9711,6 +9715,7 @@ void pc_read_skill_tree(void) { { "Expanded_Super_Baby", JOB_SUPER_BABY_E }, { "Kagerou", JOB_KAGEROU }, { "Oboro", JOB_OBORO }, + { "Rebellion", JOB_REBELLION }, }; if (conf_read_file(&skill_tree_conf, config_filename)) { diff --git a/src/map/pc.h b/src/map/pc.h index d384e0145..69bcdea8d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -634,7 +634,7 @@ enum equip_pos { #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE ) #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate ) #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 ) -#define pc_maxparameter(sd) ( ((((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) || (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle_config.max_baby_third_parameter : battle_config.max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter)) ) +#define pc_maxparameter(sd) ( ((((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) || (((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION) || (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle_config.max_baby_third_parameter : battle_config.max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter)) ) /** * Ranger **/ @@ -660,7 +660,8 @@ enum equip_pos { || ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \ || ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \ || ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \ -|| ( (class_) >= JOB_KAGEROU && (class_) < JOB_MAX ) \ +|| ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \ +|| ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \ ) #define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_) diff --git a/src/map/script.c b/src/map/script.c index 06c97bbe6..59af8d2b7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2361,7 +2361,7 @@ void get_val(struct script_state* st, struct script_data* data) break; case '\'': if ( st->instance_id >= 0 ) { - data->u.str = (char*)idb_get(instances[st->instance_id].vars,reference_getuid(data)); + data->u.str = (char*)idb_get(instance->list[st->instance_id].vars,reference_getuid(data)); } else { ShowWarning("script_get_val: cannot access instance variable '%s', defaulting to \"\"\n", name); data->u.str = NULL; @@ -2416,7 +2416,7 @@ void get_val(struct script_state* st, struct script_data* data) break; case '\'': if( st->instance_id >= 0 ) - data->u.num = (int)idb_iget(instances[st->instance_id].vars,reference_getuid(data)); + data->u.num = (int)idb_iget(instance->list[st->instance_id].vars,reference_getuid(data)); else { ShowWarning("script_get_val: cannot access instance variable '%s', defaulting to 0\n", name); data->u.num = 0; @@ -2474,8 +2474,8 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam return 1; case '\'': if( st->instance_id >= 0 ) { - idb_remove(instances[st->instance_id].vars, num); - if( str[0] ) idb_put(instances[st->instance_id].vars, num, aStrdup(str)); + idb_remove(instance->list[st->instance_id].vars, num); + if( str[0] ) idb_put(instance->list[st->instance_id].vars, num, aStrdup(str)); } return 1; default: @@ -2522,9 +2522,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam return 1; case '\'': if( st->instance_id >= 0 ) { - idb_remove(instances[st->instance_id].vars, num); + idb_remove(instance->list[st->instance_id].vars, num); if( val != 0 ) - idb_iput(instances[st->instance_id].vars, num, val); + idb_iput(instance->list[st->instance_id].vars, num, val); } return 1; default: @@ -15930,7 +15930,7 @@ BUILDIN(instance_init) { return true; } - if( instances[instance_id].state != INSTANCE_IDLE ) { + if( instance->list[instance_id].state != INSTANCE_IDLE ) { ShowError("instance_init: instance already initialized.\n"); return true; } @@ -15961,8 +15961,8 @@ BUILDIN(instance_announce) { if( !instance->valid(instance_id) ) return true; - for( i = 0; i < instances[instance_id].num_map; i++ ) - map->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, + for( i = 0; i < instance->list[instance_id].num_map; i++ ) + map->foreachinmap(buildin_announce_sub, instance->list[instance_id].map[i], BL_PC, mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; @@ -16015,8 +16015,8 @@ BUILDIN(has_instance) { if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m); - if( j != instances[sd->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[sd->instance[i]].num_map ) break; } } @@ -16026,8 +16026,8 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m); - if( j != instances[p->instance[i]].num_map ) + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[p->instance[i]].num_map ) break; } } @@ -16037,8 +16037,8 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m); - if( j != instances[sd->guild->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[sd->guild->instance[i]].num_map ) break; } } diff --git a/src/map/skill.c b/src/map/skill.c index 5c4dddc6f..506a13ea8 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5035,7 +5035,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } skill->area_temp[0] = 0; - party_foreachsamemap(skill->area_sub, + party->foreachsamemap(skill->area_sub, sd,skill->get_splash(skill_id, skill_lv), src,skill_id,skill_lv,tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); @@ -5743,7 +5743,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case MO_KITRANSLATION: - if(dstsd && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER) { + if(dstsd && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION)) { pc->addspiritball(dstsd,skill->get_time(skill_id,skill_lv),5); } break; @@ -5758,7 +5758,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case MO_ABSORBSPIRITS: i = 0; - if (dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m)) && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER) + if (dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m)) && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION)) { // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen] i = dstsd->spiritball * 7; pc->delspiritball(dstsd,dstsd->spiritball,0); @@ -5893,14 +5893,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd == NULL || sd->status.party_id == 0 || (flag & 1) ) clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); else if( sd ) - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; case MER_MAGNIFICAT: if( mer != NULL ) { clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); if( mer->master && mer->master->status.party_id != 0 && !(flag&1) ) - party_foreachsamemap(skill->area_sub, mer->master, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, mer->master, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); else if( mer->master && !(flag&1) ) clif->skill_nodamage(src, &mer->master->bl, skill_id, skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); } @@ -5914,7 +5914,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(bl,bl,skill_id,skill_lv, sc_start2(bl,type,100,skill_lv,(src == bl)? 1:0,skill->get_time(skill_id,skill_lv))); } else if (sd) { - party_foreachsamemap(skill->area_sub, + party->foreachsamemap(skill->area_sub, sd,skill->get_splash(skill_id, skill_lv), src,skill_id,skill_lv,tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); @@ -7639,7 +7639,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } else clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -7719,9 +7719,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill->area_temp[5]/4,skill->get_time(skill_id,skill_lv)); } else if( sd ) { if( sd->status.party_id ) { - i = party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,BCT_PARTY,skill->area_sub_count); + i = party->foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,BCT_PARTY,skill->area_sub_count); skill->area_temp[5] = 7 * i; // ATK - party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,flag|BCT_PARTY|1,skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,flag|BCT_PARTY|1,skill->castend_nodamage_id); } else sc_start2(bl,type,100,7,5,skill->get_time(skill_id,skill_lv)); } @@ -7785,7 +7785,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill->area_temp[5] |= 0x200; } clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } break; /** @@ -7887,7 +7887,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( !i ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); else - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } break; @@ -7895,7 +7895,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd == NULL || sd->status.party_id == 0 || flag&1 ) clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start4(bl, type, 100, skill_lv, 0, 0, 1, skill->get_time(skill_id, skill_lv))); else if( sd ) - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; case AB_CHEAL: @@ -7913,7 +7913,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } else if( sd ) - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; case AB_ORATIO: @@ -7942,7 +7942,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv))); } else if( sd ) - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; @@ -7959,7 +7959,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv))); } else if( sd ) - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; @@ -8564,7 +8564,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); else if( sd ) { // Only shows effects on caster. clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } break; @@ -8575,7 +8575,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start4(bl,type,100,skill_lv,6*skill_lv,(sd?pc->checkskill(sd,WM_LESSON):0),(sd?sd->status.job_level:0),skill->get_time(skill_id,skill_lv)); else if( sd ) { // Only shows effects on caster. clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } break; @@ -8667,7 +8667,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui uint16 lv = skill_lv; int count = skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),1); if( sc_start2(bl,type,100,skill_lv,count,skill->get_time(skill_id,skill_lv)) ) - party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,flag|BCT_PARTY|1,skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,flag|BCT_PARTY|1,skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } @@ -8883,7 +8883,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd->status.party_id == 0 || flag&1 ) skill->unitsetting(src,MG_SAFETYWALL,skill_lv,bl->x,bl->y,0); else - party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); + party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); break; case GN_CHANGEMATERIAL: @@ -12187,7 +12187,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 c = 0; memset (p_sd, 0, sizeof(p_sd)); if( is_chorus ) - i = party_foreachsamemap(skill->check_condition_char_sub,sd,AREA_SIZE,&sd->bl, &c, &p_sd, skill_id, *skill_lv); + i = party->foreachsamemap(skill->check_condition_char_sub,sd,AREA_SIZE,&sd->bl, &c, &p_sd, skill_id, *skill_lv); else i = map->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id); diff --git a/src/map/skill.h b/src/map/skill.h index 1609802f9..d2546c706 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1247,6 +1247,31 @@ enum e_skill { ALL_RAY_OF_PROTECTION, MC_CARTDECORATE, + RL_GLITTERING_GREED = 2551, + RL_RICHS_COIN, + RL_MASS_SPIRAL, + RL_BANISHING_BUSTER, + RL_B_TRAP, + RL_FLICKER, + RL_S_STORM, + RL_E_CHAIN, + RL_QD_SHOT, + RL_C_MARKER, + RL_FIREDANCE, + RL_H_MINE, + RL_P_ALTER, + RL_FALLEN_ANGEL, + RL_R_TRIP, + RL_D_TAIL, + RL_FIRE_RAIN, + RL_HEAT_BARREL, + RL_AM_BLAST, + RL_SLUGSHOT, + RL_HAMMER_OF_GOD, + RL_R_TRIP_PLUSATK, + RL_B_FLICKER_ATK, + RL_GLITTERING_GREED_ATK, + KO_YAMIKUMO = 3001, KO_RIGHT, KO_LEFT, diff --git a/src/map/status.c b/src/map/status.c index d8356264c..0b69ae2ef 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2278,7 +2278,7 @@ static unsigned int status_base_pc_maxhp(struct map_session_data *sd, struct sta uint64 val = pc->class2idx(sd->status.class_); val = 35 + sd->status.base_level*(int64)hp_coefficient2[val]/100 + hp_sigma_val[val][sd->status.base_level]; - if((sd->class_&MAPID_UPPERMASK) == MAPID_NINJA || (sd->class_&MAPID_UPPERMASK) == MAPID_GUNSLINGER) + if((sd->class_&MAPID_UPPERMASK) == MAPID_NINJA || (sd->class_&MAPID_UPPERMASK) == MAPID_GUNSLINGER || (sd->class_&MAPID_UPPERMASK) == MAPID_REBELLION) val += 100; //Since their HP can't be approximated well enough without this. if((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON)) val *= 3; //Triple max HP for top ranking Taekwons over level 90. diff --git a/src/map/storage.c b/src/map/storage.c index 041c2cd72..91515dfe1 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -30,7 +30,7 @@ struct guild_storage_interface gstorage_s; /*========================================== * Sort items in the warehouse *------------------------------------------*/ -static int storage_comp_item(const void *_i1, const void *_i2) +int storage_comp_item(const void *_i1, const void *_i2) { struct item *i1 = (struct item *)_i1; struct item *i2 = (struct item *)_i2; @@ -45,33 +45,21 @@ static int storage_comp_item(const void *_i1, const void *_i2) } //Sort item by storage_comp_item (nameid) -static void storage_sortitem(struct item* items, unsigned int size) +void storage_sortitem(struct item* items, unsigned int size) { nullpo_retv(items); if( battle_config.client_sort_storage ) { - qsort(items, size, sizeof(struct item), storage_comp_item); + qsort(items, size, sizeof(struct item), storage->comp_item); } } -/*========================================== - * Init/Terminate - *------------------------------------------*/ -/* ##TODO not really init_storage but init_gstorage, should rename/move */ -int do_init_storage(void) { // Called from map.c::do_init() - gstorage->db = idb_alloc(DB_OPT_RELEASE_DATA); - return 1; -} -void do_final_storage(void) { // by [MC Cameri] - gstorage->db->destroy(gstorage->db,NULL); -} - /** * Parses storage and saves 'dirty' ones upon reconnect. [Skotlex] * @see DBApply */ -static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap) +int storage_reconnect_sub(DBKey key, DBData *data, va_list ap) { struct guild_storage *stor = DB->data2ptr(data); if (stor->dirty && stor->storage_status == 0) //Save closed storages. @@ -82,7 +70,7 @@ static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap) //Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex] void do_reconnect_storage(void) { - gstorage->db->foreach(gstorage->db, storage_reconnect_sub); + gstorage->db->foreach(gstorage->db, storage->reconnect_sub); } /*========================================== @@ -104,7 +92,7 @@ int storage_storageopen(struct map_session_data *sd) } sd->state.storage_flag = 1; - storage_sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); + storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); clif->updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE); return 0; @@ -347,7 +335,7 @@ void storage_storage_quit(struct map_session_data* sd, int flag) { /** * @see DBCreateData */ -static DBData create_guildstorage(DBKey key, va_list args) +DBData create_guildstorage(DBKey key, va_list args) { struct guild_storage *gs = NULL; gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1); @@ -359,7 +347,7 @@ struct guild_storage *guild2storage(int guild_id) { struct guild_storage *gs = NULL; if(guild->search(guild_id) != NULL) - gs = idb_ensure(gstorage->db,guild_id,create_guildstorage); + gs = idb_ensure(gstorage->db,guild_id,gstorage->create); return gs; } @@ -409,7 +397,7 @@ int storage_guild_storageopen(struct map_session_data* sd) gstor->storage_status = 1; sd->state.storage_flag = 2; - storage_sortitem(gstor->items, ARRAYLENGTH(gstor->items)); + storage->sortitem(gstor->items, ARRAYLENGTH(gstor->items)); clif->storagelist(sd, gstor->items, ARRAYLENGTH(gstor->items)); clif->updatestorageamount(sd, gstor->storage_amount, MAX_GUILD_STORAGE); return 0; @@ -728,13 +716,16 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) { return 0; } +void do_init_gstorage(void) { + gstorage->db = idb_alloc(DB_OPT_RELEASE_DATA); +} +void do_final_gstorage(void) { + db_destroy(gstorage->db); +} void storage_defaults(void) { storage = &storage_s; /* */ - storage->init = do_init_storage; - storage->final = do_final_storage; - /* */ storage->reconnect = do_reconnect_storage; /* */ storage->delitem = storage_delitem; @@ -746,10 +737,17 @@ void storage_defaults(void) { storage->gettocart = storage_storagegettocart; storage->close = storage_storageclose; storage->pc_quit = storage_storage_quit; + storage->comp_item = storage_comp_item; + storage->sortitem = storage_sortitem; + storage->reconnect_sub = storage_reconnect_sub; } void gstorage_defaults(void) { gstorage = &gstorage_s; + /* */ + gstorage->init = do_init_gstorage; + gstorage->final = do_final_gstorage; + /* */ gstorage->id2storage = guild2storage; gstorage->id2storage2 = guild2storage2; gstorage->delete = guild_storage_delete; @@ -764,4 +762,5 @@ void gstorage_defaults(void) { gstorage->pc_quit = storage_guild_storage_quit; gstorage->save = storage_guild_storagesave; gstorage->saved = storage_guild_storagesaved; + gstorage->create = create_guildstorage; } diff --git a/src/map/storage.h b/src/map/storage.h index 83243a622..9258e0265 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -12,8 +12,6 @@ struct map_session_data; struct DBMap; struct storage_interface { - int (*init) (void); - void (*final) (void); /* */ void (*reconnect) (void); /* */ @@ -26,6 +24,9 @@ struct storage_interface { int (*gettocart) (struct map_session_data *sd,int index,int amount); void (*close) (struct map_session_data *sd); void (*pc_quit) (struct map_session_data *sd, int flag); + int (*comp_item) (const void *_i1, const void *_i2); + void (*sortitem) (struct item* items, unsigned int size); + int (*reconnect_sub) (DBKey key, DBData *data, va_list ap); }; struct storage_interface *storage; @@ -34,6 +35,10 @@ struct guild_storage_interface { /* */ struct guild_storage *(*id2storage) (int guild_id); struct guild_storage *(*id2storage2) (int guild_id); + /* */ + void (*init) (void); + void (*final) (void); + /* */ int (*delete) (int guild_id); int (*open) (struct map_session_data *sd); int (*additem) (struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount); @@ -46,6 +51,7 @@ struct guild_storage_interface { int (*pc_quit) (struct map_session_data *sd,int flag); int (*save) (int account_id, int guild_id, int flag); int (*saved) (int guild_id); //Ack from char server that guild store was saved. + DBData (*create) (DBKey key, va_list args); }; struct guild_storage_interface *gstorage; diff --git a/src/map/unit.c b/src/map/unit.c index 9d6f107e3..488a210bf 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2197,7 +2197,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i --maplist[bl->m].users_pvp; } if( maplist[bl->m].instance_id >= 0 ) { - instances[maplist[bl->m].instance_id].users--; + instance->list[maplist[bl->m].instance_id].users--; instance->check_idle(maplist[bl->m].instance_id); } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] |