Explorar o código

Converted ZC_UPDATE_MAPINFO to struct

Lemongrass3110 hai 3 meses
pai
achega
94db40c360
Modificáronse 6 ficheiros con 35 adicións e 30 borrados
  1. 19 23
      src/map/clif.cpp
  2. 1 1
      src/map/clif.hpp
  3. 0 1
      src/map/clif_packetdb.hpp
  4. 3 3
      src/map/map.cpp
  5. 9 0
      src/map/packets.hpp
  6. 3 2
      src/map/skill.cpp

+ 19 - 23
src/map/clif.cpp

@@ -5325,32 +5325,28 @@ void clif_standing(block_list& bl){
 }
 
 
-/// Inform client(s) about a map-cell change (ZC_UPDATE_MAPINFO).
-/// 0192 <x>.W <y>.W <type>.W <map name>.16B
-void clif_changemapcell(int32 fd, int16 m, int32 x, int32 y, int32 type, enum send_target target)
-{
-	unsigned char buf[32];
+/// Inform client(s) about a map-cell change.
+/// 0192 <x>.W <y>.W <type>.W <map name>.16B (ZC_UPDATE_MAPINFO)
+void clif_changemapcell( int16 m, int16 x, int16 y, int16 type, send_target target, block_list* tbl ){
+	PACKET_ZC_UPDATE_MAPINFO p = {};
 
-	WBUFW(buf,0) = 0x192;
-	WBUFW(buf,2) = x;
-	WBUFW(buf,4) = y;
-	WBUFW(buf,6) = type;
-	mapindex_getmapname_ext(map_mapid2mapname(m),WBUFCP(buf,8));
+	p.packetType = HEADER_ZC_UPDATE_MAPINFO;
+	p.x = x;
+	p.y = y;
+	p.type = type;
+	mapindex_getmapname_ext( map_mapid2mapname( m ), p.mapname );
+
+	if( tbl != nullptr ){
+		clif_send( &p, sizeof( p ), tbl, target );
+	}else{
+		block_list dummy_bl = {};
 
-	if( session_isActive(fd) )
-	{
-		WFIFOHEAD(fd,packet_len(0x192));
-		memcpy(WFIFOP(fd,0), buf, packet_len(0x192));
-		WFIFOSET(fd,packet_len(0x192));
-	}
-	else
-	{
-		struct block_list dummy_bl;
 		dummy_bl.type = BL_NUL;
 		dummy_bl.x = x;
 		dummy_bl.y = y;
 		dummy_bl.m = m;
-		clif_send(buf,packet_len(0x192),&dummy_bl,target);
+
+		clif_send( &p, sizeof( p ), &dummy_bl, target );
 	}
 }
 
@@ -5475,7 +5471,7 @@ void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *unit,
 	clif_send(buf, len, bl, target);
 
 	if (unit->group->skill_id == WZ_ICEWALL)
-		clif_changemapcell(fd, unit->bl.m, unit->bl.x, unit->bl.y, 5, SELF);
+		clif_changemapcell( unit->bl.m, unit->bl.x, unit->bl.y, 5, SELF, bl );
 }
 
 /// 09ca <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.L <range>.B <visible>.B <skill level>.B (ZC_SKILL_ENTRY5)
@@ -5509,7 +5505,7 @@ static void clif_clearchar_skillunit( skill_unit& unit, map_session_data& sd ){
 	clif_send( &packet, sizeof( packet ), &sd.bl, SELF );
 
 	if( unit.group && unit.group->skill_id == WZ_ICEWALL ){
-		clif_changemapcell( sd.fd, unit.bl.m, unit.bl.x, unit.bl.y, unit.val2, SELF );
+		clif_changemapcell( unit.bl.m, unit.bl.x, unit.bl.y, unit.val2, SELF, &sd.bl );
 	}
 }
 
@@ -14963,7 +14959,7 @@ void clif_parse_GMChangeMapType(int32 fd, map_session_data *sd)
 	type = RFIFOW(fd,info->pos[2]);
 
 	map_setgatcell(sd->bl.m,x,y,type);
-	clif_changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP);
+	clif_changemapcell( sd->bl.m, x, y, type, ALL_SAMEMAP, &sd->bl );
 	//FIXME: once players leave the map, the client 'forgets' this information.
 }
 

+ 1 - 1
src/map/clif.hpp

@@ -1005,7 +1005,7 @@ void clif_servantball( map_session_data& sd, struct block_list* target = nullptr
 void clif_abyssball( map_session_data& sd, struct block_list* target = nullptr, enum send_target send_target = AREA );
 void clif_combo_delay( block_list& bl, t_tick wait );
 void clif_bladestop( block_list& src, uint32 target_id, bool active );
-void clif_changemapcell(int32 fd, int16 m, int32 x, int32 y, int32 type, enum send_target target);
+void clif_changemapcell( int16 m, int16 x, int16 y, int16 type, send_target target = ALL_SAMEMAP, block_list* tbl = nullptr );
 
 #define clif_status_load(bl, type, flag) clif_status_change((bl), (type), (flag), 0, 0, 0, 0)
 void clif_status_change(struct block_list *bl, int32 type, int32 flag, t_tick tick, int32 val1, int32 val2, int32 val3);

+ 0 - 1
src/map/clif_packetdb.hpp

@@ -196,7 +196,6 @@
 	packet( HEADER_ZC_ACK_REQMAKINGITEM, sizeof( PACKET_ZC_ACK_REQMAKINGITEM ) );
 	parseable_packet(0x0190,90,clif_parse_UseSkillToPosMoreInfo,2,4,6,8,10);
 	packet( HEADER_ZC_TALKBOX_CHATCONTENTS, sizeof( struct PACKET_ZC_TALKBOX_CHATCONTENTS ) );
-	packet(0x0192,24);
 	parseable_packet(0x0193,6,clif_parse_SolveCharName,2);
 	packet( HEADER_ZC_ACK_REQNAMEALL, sizeof( struct PACKET_ZC_ACK_REQNAMEALL ) );
 	packet(0x0196,9);

+ 3 - 3
src/map/map.cpp

@@ -3383,7 +3383,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int32 size, int8 dir, bool shootab
 		map_setcell(m, x1, y1, CELL_WALKABLE, false);
 		map_setcell(m, x1, y1, CELL_SHOOTABLE, shootable);
 
-		clif_changemapcell(0, m, x1, y1, map_getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+		clif_changemapcell( m, x1, y1, map_getcell( m, x1, y1, CELL_GETTYPE ) );
 	}
 
 	iwall->size = i;
@@ -3410,7 +3410,7 @@ void map_iwall_get(map_session_data *sd) {
 
 		for( i = 0; i < iwall->size; i++ ) {
 			map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
-			clif_changemapcell(sd->fd, iwall->m, x1, y1, map_getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF);
+			clif_changemapcell( iwall->m, x1, y1, map_getcell( iwall->m, x1, y1, CELL_GETTYPE ), SELF, &sd->bl );
 		}
 	}
 	dbi_destroy(iter);
@@ -3430,7 +3430,7 @@ bool map_iwall_remove(const char *wall_name)
 		map_setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true);
 		map_setcell(iwall->m, x1, y1, CELL_WALKABLE, true);
 
-		clif_changemapcell(0, iwall->m, x1, y1, map_getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+		clif_changemapcell( iwall->m, x1, y1, map_getcell( iwall->m, x1, y1, CELL_GETTYPE ) );
 	}
 
 	map_getmapdata(iwall->m)->iwall_num--;

+ 9 - 0
src/map/packets.hpp

@@ -1712,6 +1712,15 @@ struct PACKET_ZC_THROW_MVPITEM {
 } __attribute__((packed));
 DEFINE_PACKET_HEADER(ZC_THROW_MVPITEM, 0x10d);
 
+struct PACKET_ZC_UPDATE_MAPINFO{
+	int16 packetType;
+	int16 x;
+	int16 y;
+	int16 type;
+	char mapname[MAP_NAME_LENGTH_EXT];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_UPDATE_MAPINFO, 0x192);
+
 // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
 #if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
 	#pragma pack( pop )

+ 3 - 2
src/map/skill.cpp

@@ -21446,7 +21446,7 @@ struct skill_unit *skill_initunit(std::shared_ptr<s_skill_unit_group> group, int
 	switch (group->skill_id) {
 		case WZ_ICEWALL:
 			map_setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,5);
-			clif_changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,5,AREA);
+			clif_changemapcell( unit->bl.m, unit->bl.x, unit->bl.y, 5, AREA, &unit->bl );
 			skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true);
 			break;
 		case SA_LANDPROTECTOR:
@@ -21508,7 +21508,8 @@ int32 skill_delunit(struct skill_unit* unit)
 			break;
 		case WZ_ICEWALL:
 			map_setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
-			clif_changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug
+			// Hack to avoid clientside cell bug
+			clif_changemapcell( unit->bl.m, unit->bl.x, unit->bl.y, unit->val2, ALL_SAMEMAP, &unit->bl );
 			skill_unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false);
 			break;
 		case SA_LANDPROTECTOR: