Implemented ZC_WARPLIST packet (#8600)

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
AoShinHo 2024-09-14 15:06:41 -03:00 committed by GitHub
parent 70e8518a32
commit fca803220b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 99 additions and 41 deletions

View File

@ -6151,37 +6151,71 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i
clif_send(buf,packet_len(0x117),src,AREA);
}
/// Presents a list of available warp destinations (ZC_WARPLIST).
/// 011c <skill id>.W { <map name>.16B }*4
void clif_skill_warppoint( map_session_data* sd, uint16 skill_id, uint16 skill_lv, const char* map1, const char* map2, const char* map3, const char* map4 ){
int fd;
nullpo_retv(sd);
fd = sd->fd;
/// Presents a list of available warp destinations.
/// 011c <skill id>.W { <map name>.16B }*4 (ZC_WARPLIST)
/// 0abe <lenght>.W <skill id>.W { <map name>.16B }*? (ZC_WARPLIST2)
void clif_skill_warppoint( map_session_data& sd, uint16 skill_id, uint16 skill_lv, std::vector<std::string>& maps ){
if(maps.empty())
return;
WFIFOHEAD(fd,packet_len(0x11c));
WFIFOW(fd,0) = 0x11c;
WFIFOW(fd,2) = skill_id;
memset(WFIFOP(fd,4), 0x00, 4*MAP_NAME_LENGTH_EXT);
if( strcmp( "", map1 ) != 0 ){
mapindex_getmapname_ext( map1, WFIFOCP( fd, 4 ) );
}
if( strcmp( "", map2 ) != 0 ){
mapindex_getmapname_ext( map2, WFIFOCP( fd, 20 ) );
}
if( strcmp( "", map3 ) != 0 ){
mapindex_getmapname_ext( map3, WFIFOCP( fd, 36 ) );
}
if( strcmp( "", map4 ) != 0 ){
mapindex_getmapname_ext( map4, WFIFOCP( fd, 52 ) );
}
WFIFOSET(fd,packet_len(0x11c));
#if PACKETVER_MAIN_NUM >= 20170502 || PACKETVER_RE_NUM >= 20170419 || defined(PACKETVER_ZERO)
PACKET_ZC_WARPLIST* p = reinterpret_cast<PACKET_ZC_WARPLIST*>( packet_buffer );
sd->menuskill_id = skill_id;
p->packetType = HEADER_ZC_WARPLIST;
p->packetLength = sizeof( *p );
p->skillId = skill_id;
size_t memoCount = 0;
for( std::string& map : maps ){
if( map.empty() ){
continue;
}
PACKET_ZC_WARPLIST_sub& warp = p->maps[memoCount];
mapindex_getmapname_ext( map.c_str(), warp.map );
p->packetLength += static_cast<decltype(p->packetLength)>( sizeof( warp ) );
memoCount++;
}
clif_send( p, p->packetLength, &sd.bl, SELF );
#else
PACKET_ZC_WARPLIST p = {};
p.packetType = HEADER_ZC_WARPLIST;
p.skillId = skill_id;
size_t memoCount = 0, max = 4;
for( std::string& map : maps ){
if( map.empty() ){
continue;
}
PACKET_ZC_WARPLIST_sub& warp = p.maps[memoCount];
mapindex_getmapname_ext( map.c_str(), warp.map );
if( memoCount++ == max ){
break;
}
}
for( ; memoCount < max; memoCount++ ){
PACKET_ZC_WARPLIST_sub& warp = p.maps[memoCount];
strcpy( warp.map, "" );
}
clif_send( &p, sizeof( p ), &sd.bl, SELF );
#endif
sd.menuskill_id = skill_id;
if (skill_id == AL_WARP) {
sd->menuskill_val = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
sd->state.workinprogress = WIP_DISABLE_ALL;
sd.menuskill_val = (sd.ud.skillx<<16)|sd.ud.skilly; //Store warp position here.
sd.state.workinprogress = WIP_DISABLE_ALL;
} else
sd->menuskill_val = skill_lv;
sd.menuskill_val = skill_lv;
}

View File

@ -944,7 +944,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,t_tick tick,
bool clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 skill_id,int heal,t_tick tick);
void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,int y,t_tick tick);
void clif_skill_estimation(map_session_data *sd,struct block_list *dst);
void clif_skill_warppoint( map_session_data* sd, uint16 skill_id, uint16 skill_lv, const char* map1, const char* map2 = "", const char* map3 = "", const char* map4 = "" );
void clif_skill_warppoint( map_session_data& sd, uint16 skill_id, uint16 skill_lv, std::vector<std::string>& maps );
void clif_skill_memomessage( map_session_data& sd, e_ack_remember_warppoint_result result );
void clif_skill_teleportmessage( map_session_data& sd, e_notify_mapinfo_result result );
void clif_skill_produce_mix_list( map_session_data& sd, int skill_id, int trigger );

View File

@ -136,7 +136,6 @@
packet(0x0119,13);
packet(0x011a,15);
parseable_packet(0x011b,20,clif_parse_UseSkillMap,2,4);
packet(0x011c,68);
parseable_packet(0x011d,2,clif_parse_RequestMemo,0);
packet(0x011f,16);
packet( cartlistequipType, -1 );

View File

@ -1389,6 +1389,12 @@ DEFINE_PACKET_HEADER(CZ_REQ_STYLE_CHANGE2, 0xafc)
DEFINE_PACKET_HEADER(ZC_REMOVE_EFFECT, 0x0b0d)
DEFINE_PACKET_HEADER(ZC_FEED_MER, 0x22f)
DEFINE_PACKET_HEADER(ZC_FEED_PET, 0x1a3)
#if PACKETVER_MAIN_NUM >= 20170502 || PACKETVER_RE_NUM >= 20170419 || defined(PACKETVER_ZERO)
DEFINE_PACKET_HEADER(ZC_WARPLIST, 0xabe)
#else
DEFINE_PACKET_HEADER(ZC_WARPLIST, 0x11c)
#endif
const int16 MAX_INVENTORY_ITEM_PACKET_NORMAL = ( ( INT16_MAX - ( sizeof( struct packet_itemlist_normal ) - ( sizeof( struct NORMALITEM_INFO ) * MAX_ITEMLIST) ) ) / sizeof( struct NORMALITEM_INFO ) );
const int16 MAX_INVENTORY_ITEM_PACKET_EQUIP = ( ( INT16_MAX - ( sizeof( struct packet_itemlist_equip ) - ( sizeof( struct EQUIPITEM_INFO ) * MAX_ITEMLIST ) ) ) / sizeof( struct EQUIPITEM_INFO ) );

View File

@ -9319,7 +9319,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AL_TELEPORT:
case ALL_ODINS_RECALL:
if(sd)
if(sd != nullptr)
{
if (map_getmapflag(bl->m, MF_NOTELEPORT) && skill_lv <= 2) {
clif_skill_teleportmessage( *sd, NOTIFY_MAPINFO_CANT_TP );
@ -9342,10 +9342,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
if( skill_lv == 1 && skill_id != ALL_ODINS_RECALL )
clif_skill_warppoint( sd, skill_id, skill_lv, "Random" );
else
clif_skill_warppoint( sd, skill_id, skill_lv, "Random", sd->status.save_point.map );
std::vector<std::string> maps = {
"Random"
};
if( skill_lv == 1 && skill_id != ALL_ODINS_RECALL ){
clif_skill_warppoint( *sd, skill_id, skill_lv, maps );
}else{
maps.push_back( sd->status.save_point.map );
clif_skill_warppoint( *sd, skill_id, skill_lv, maps );
}
} else
unit_warp(bl,-1,-1,-1,CLR_TELEPORT);
break;
@ -14037,13 +14045,24 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case AL_WARP:
if(sd)
{
clif_skill_warppoint(sd, skill_id, skill_lv, sd->status.save_point.map,
(skill_lv >= 2) ? sd->status.memo_point[0].map : "",
(skill_lv >= 3) ? sd->status.memo_point[1].map : "",
(skill_lv >= 4) ? sd->status.memo_point[2].map : ""
);
if(sd != nullptr) {
std::vector<std::string> maps( MAX_MEMOPOINTS + 1 );
maps.push_back( sd->status.save_point.map );
if( skill_lv >= 2 ){
maps.push_back( sd->status.memo_point[0].map );
if( skill_lv >= 3 ){
maps.push_back( sd->status.memo_point[1].map );
if( skill_lv >= 4 ){
maps.push_back( sd->status.memo_point[2].map );
}
}
}
clif_skill_warppoint( *sd, skill_id, skill_lv, maps );
}
if( sc && sc->getSCE(SC_CURSEDCIRCLE_ATKER) ) //Should only remove after the skill has been casted.
status_change_end(src,SC_CURSEDCIRCLE_ATKER);