Pārlūkot izejas kodu

- Added structure view_data to handle sprite information for all characters (equipment, weapons, hair, dyes, etc). Unified a bunch of clif functions now that you only need to handle the view_data (so instead of clif_spawn[pc/mob/npc/pet] you just have clif_spawn)
- Fixed the clif_change_class packet (it should check for non players classes, not a class above MAX_PC_CLASS), it fixes morphing enemies.
- Rewrote the way cloth dye packets are resent to optimize bandwidth usage.
- Fixed the npc_item_flag thing (enable_items/disable_items script command)
- Rewrote the disguise implementation to be bandwidth friendly.
- Modified the hide options to change your class to INVISIBLE_CLASS, since such classes don't even get their view packets sent around.
- Rewrote several clif functions to adapt to the new view_data class;
- Added class 139 to npcdb_checkid which was required by some npcs in the swordman quest? o.O


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5833 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 gadi atpakaļ
vecāks
revīzija
e9c44b50c8
17 mainītis faili ar 686 papildinājumiem un 1352 dzēšanām
  1. 13 0
      Changelog-Trunk.txt
  2. 15 49
      src/map/atcommand.c
  3. 284 886
      src/map/clif.c
  4. 9 21
      src/map/clif.h
  5. 25 10
      src/map/map.h
  6. 36 75
      src/map/mob.c
  7. 4 17
      src/map/mob.h
  8. 26 8
      src/map/npc.c
  9. 4 3
      src/map/npc.h
  10. 46 36
      src/map/pc.c
  11. 4 4
      src/map/pc.h
  12. 6 5
      src/map/pet.c
  13. 27 39
      src/map/script.c
  14. 14 33
      src/map/skill.c
  15. 147 63
      src/map/status.c
  16. 2 0
      src/map/status.h
  17. 24 103
      src/map/unit.c

+ 13 - 0
Changelog-Trunk.txt

@@ -4,6 +4,19 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/04/01
+	* Added structure view_data to handle sprite information for all characters
+	  (equipment, weapons, hair, dyes, etc). [Skotlex]
+	* Rewrote several clif functions to adapt to the new view_data class.
+	  [Skotlex]
+	* Rewrote the way cloth dye packets are resent to optimize bandwidth usage.
+	  [Skotlex]
+	* Fixed the npc_item_flag thing (enable_items/disable_items script command)
+	  [Skotlex]
+	* Rewrote the disguise implementation to be bandwidth friendly. [Skotlex]
+	* Modified the hide options to change your class to INVISIBLE_CLASS, since
+	  such classes don't even get their view packets sent around. [Skotlex]
+	* Added class 139 to npcdb_checkid which was required by some npcs in the
+	  swordman quest. [Skotlex]
 	* April fool! Improved soundeffectall script command. (No, this is not a lie) [Lance]
 
 2006/03/31

+ 15 - 49
src/map/atcommand.c

@@ -2178,9 +2178,14 @@ int atcommand_hide(
 	nullpo_retr(-1, sd);
 	if (sd->sc.option & OPTION_INVISIBLE) {
 		sd->sc.option &= ~OPTION_INVISIBLE;
+		if (sd->disguise)
+			status_set_viewdata(&sd->bl, sd->disguise);
+		else
+			status_set_viewdata(&sd->bl, sd->status.class_);
 		clif_displaymessage(fd, msg_table[10]); // Invisible: Off
 	} else {
 		sd->sc.option |= OPTION_INVISIBLE;
+		sd->vd.class_ = INVISIBLE_CLASS;
 		clif_displaymessage(fd, msg_table[11]); // Invisible: On
 	}
 	clif_changeoption(&sd->bl);
@@ -6473,21 +6478,7 @@ int atcommand_disguise(
 		return -1;
 	}
 
-	/* The previous way.... 
-	if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
-		mob_id = atoi(message);
-
-	if ((mob_id >=  46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
-	    (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
-	    (mob_id >= 813 && mob_id <= 858) || // NPC
-	    (mob_id > 1000 && mob_id < 1582)) { // monsters
-	*/
-	pc_stop_walking(sd,0);
-	clif_clearchar(&sd->bl, 0);
-	sd->disguise = id;
-	sd->state.disguised = 1; // set to override items with disguise script [Valaris]
-	clif_changeoption(&sd->bl);
-	clif_spawnpc(sd);
+	pc_disguise(sd, id);
 	clif_displaymessage(fd, msg_table[122]); // Disguise applied.
 
 	return 0;
@@ -6517,14 +6508,8 @@ int atcommand_disguiseall(
 	if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
 		pl_allsd = map_getallusers(&users);
 		for(i=0; i < users; i++) {
-			if((pl_sd = pl_allsd[i])) {
-				pc_stop_walking(pl_sd,0);
-				clif_clearchar(&pl_sd->bl, 0);
-				pl_sd->disguise = mob_id;
-				pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
-				clif_changeoption(&pl_sd->bl);
-				clif_spawnpc(pl_sd);
-			}
+			if((pl_sd = pl_allsd[i]))
+				pc_disguise(pl_sd, mob_id);
 		}
 		clif_displaymessage(fd, msg_table[122]); // Disguise applied.
 	} else {
@@ -6544,11 +6529,7 @@ int atcommand_undisguise(
 {
 	nullpo_retr(-1, sd);
 	if (sd->disguise) {
-		pc_stop_walking(sd,0);
-		clif_clearchar(&sd->bl, 0);
-		sd->disguise = 0;
-		clif_changeoption(&sd->bl);
-		clif_spawnpc(sd);
+		pc_disguise(sd, 0);
 		clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
 	} else {
 		clif_displaymessage(fd, msg_table[125]); // You're not disguised.
@@ -6573,13 +6554,8 @@ int atcommand_undisguiseall(
 	pl_allsd = map_getallusers(&users);
 	
 	for(i=0; i < users; i++) {
-		if((pl_sd = pl_allsd[i]) && pl_sd->disguise) {
-				pc_stop_walking(pl_sd,0);
-				clif_clearchar(&pl_sd->bl, 0);
-				pl_sd->disguise = 0;
-				clif_changeoption(&pl_sd->bl);
-				clif_spawnpc(pl_sd);
-		}
+		if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
+			pc_disguise(pl_sd, 0);
 	}
 	clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
 
@@ -6701,12 +6677,7 @@ int atcommand_chardisguise(
 
 	if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
 		if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
-			pc_stop_walking(pl_sd,0);
-			clif_clearchar(&pl_sd->bl, 0);
-			pl_sd->disguise = mob_id;
-			pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
-			clif_changeoption(&pl_sd->bl);
-			clif_spawnpc(pl_sd);
+			pc_disguise(pl_sd, mob_id);
 			clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
 		} else {
 			clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
@@ -6740,14 +6711,9 @@ int atcommand_charundisguise(
 
 	if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
 		if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
-			if (pl_sd->disguise) {
-				pc_stop_walking(pl_sd,0);
-				clif_clearchar(&pl_sd->bl, 0);
-				pl_sd->disguise = 0;
-				clif_changeoption(&pl_sd->bl);
-				clif_spawnpc(pl_sd);
-				clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
-			} else {
+			if (pl_sd->disguise)
+				pc_disguise(pl_sd, 0);
+			else {
 				clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
 				return -1;
 			}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 284 - 886
src/map/clif.c


+ 9 - 21
src/map/clif.h

@@ -50,24 +50,15 @@ int clif_clearchar(struct block_list*,int);	// area or fd
 int clif_clearchar_delay(unsigned int,struct block_list *,int);
 #define clif_clearchar_area(bl,type) clif_clearchar(bl,type)
 int clif_clearchar_id(int,int,int);
-int clif_spawnpc(struct map_session_data*);	//area
-int clif_spawnnpc(struct npc_data*);	// area
-int clif_spawnmob(struct mob_data*);	// area
-int clif_spawnpet(struct pet_data*);	// area
+int clif_spawn(struct block_list*);	//area
 int clif_walkok(struct map_session_data*);	// self
-int clif_movechar(struct map_session_data*);	// area
-int clif_movemob(struct mob_data*);	//area
-int clif_movepet(struct pet_data *pd);	//area
-int clif_movenpc(struct npc_data *nd);	// [Valaris]
+int clif_move(struct block_list*);	// area
 int clif_changemap(struct map_session_data*,short,int,int);	//self
 int clif_changemapserver(struct map_session_data*,char*,int,int,int,int);	//self
 int clif_blown(struct block_list *); // area
 int clif_slide(struct block_list *,int,int); // area
 int clif_fixpos(struct block_list *);	// area
-int clif_fixmobpos(struct mob_data *md);
-int clif_fixpcpos(struct map_session_data *sd);
-int clif_fixpetpos(struct pet_data *pd);
-int clif_fixnpcpos(struct npc_data *nd); // [Valaris]
+int clif_fixpos2(struct block_list *);	// area
 int clif_npcbuysell(struct map_session_data*,int);	//self
 int clif_buylist(struct map_session_data*,struct npc_data*);	//self
 int clif_selllist(struct map_session_data*);	//self
@@ -86,6 +77,7 @@ int clif_changestatus(struct block_list*,int,int);	//area
 int clif_damage(struct block_list *,struct block_list *,unsigned int,int,int,int,int,int,int);	// area
 #define clif_takeitem(src,dst) clif_damage(src,dst,0,0,0,0,0,1,0)
 int clif_changelook(struct block_list *,int,int);	// area
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area); //area specified in 'area'
 int clif_arrowequip(struct map_session_data *sd,int val); //self
 int clif_arrow_fail(struct map_session_data *sd,int type); //self
 int clif_arrow_create_list(struct map_session_data *sd);	//self
@@ -145,17 +137,11 @@ int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage
 int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor);
 int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount);
 
-int clif_pcinsight(struct block_list *,va_list);	// map_forallinmovearea callback
-int clif_pcoutsight(struct block_list *,va_list);	// map_forallinmovearea callback
-int clif_mobinsight(struct block_list *,va_list);	// map_forallinmovearea callback
-int clif_moboutsight(struct block_list *,va_list);	// map_forallinmovearea callback
-int clif_petoutsight(struct block_list *bl,va_list ap);
-int clif_petinsight(struct block_list *bl,va_list ap);
-int clif_npcoutsight(struct block_list *bl,va_list ap);
-int clif_npcinsight(struct block_list *bl,va_list ap);
+int clif_insight(struct block_list *,va_list);	// map_forallinmovearea callback
+int clif_outsight(struct block_list *,va_list);	// map_forallinmovearea callback
 
 int clif_class_change(struct block_list *bl,int class_,int type);
-int clif_mob_class_change(struct mob_data *md,int class_);
+#define clif_mob_class_change(md, class_) clif_class_change(&md->bl, class_, 1)
 int clif_mob_equip(struct mob_data *md,int nameid); // [Valaris]
 
 int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range);
@@ -335,6 +321,8 @@ int clif_disp_overhead(struct map_session_data *sd, char* mes);
 int do_final_clif(void);
 int do_init_clif(void);
 
+void clif_get_weapon_view(TBL_PC* sd, short *rhand, short *lhand);
+
 
 int clif_party_xy_remove(struct map_session_data *sd); //Fix for minimap [Kevin]
 void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv); 

+ 25 - 10
src/map/map.h

@@ -347,23 +347,23 @@ struct skill_unit_group_tickset {
 
 struct unit_data {
 	struct block_list *bl;
-	int walktimer;
 	struct walkpath_data walkpath;
+	struct skill_timerskill skilltimerskill[MAX_SKILLTIMERSKILL];
+	struct skill_unit_group skillunit[MAX_SKILLUNITGROUP];
+	struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
+	short attacktarget_lv;
 	short to_x,to_y;
-	unsigned char dir;
 	short skillx,skilly;
 	short skillid,skilllv;
 	int   skilltarget;
 	int   skilltimer;
-	struct skill_timerskill skilltimerskill[MAX_SKILLTIMERSKILL];
-	struct skill_unit_group skillunit[MAX_SKILLUNITGROUP];
-	struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
-	int   attacktimer;
 	int   attacktarget;
-	short attacktarget_lv;
+	int   attacktimer;
+	int   walktimer;
 	unsigned int attackabletime;
 	unsigned int canact_tick;
 	unsigned int canmove_tick;
+	unsigned char dir;
 	struct {
 		unsigned change_walk_target : 1 ;
 		unsigned skillcastcancel : 1 ;
@@ -430,6 +430,19 @@ struct weapon_data {
 	int add_damage_class_count;
 };
 
+struct view_data {
+	short class_;
+	short weapon;
+	short shield; //Or left-hand weapon.
+	short head_top;
+	short head_mid;
+	short head_bottom;
+	short hair_style;
+	short hair_color;
+	short cloth_color;
+	char sex;
+	unsigned dead_sit : 2;
+};
 struct npc_data;
 struct pet_db;
 struct item_data;
@@ -438,6 +451,7 @@ struct square;
 struct map_session_data {
 	struct block_list bl;
 	struct unit_data ud;
+	struct view_data vd;
 	struct status_change sc;
 	//NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
 	//status_calc_pc, while special_state is recalculated in each call. [Skotlex]
@@ -469,7 +483,6 @@ struct map_session_data {
 		unsigned showexp :1;
 		unsigned showzeny :1;
 		unsigned mainchat :1; //[LuzZza] 
-		unsigned disguised :1; //[Valaris]
 		unsigned deal_locked :2;
 		unsigned party_sent :1;
 		unsigned guild_sent :1;
@@ -547,7 +560,6 @@ struct map_session_data {
 	int hp_sub,sp_sub;
 	int inchealhptick,inchealsptick,inchealspirithptick,inchealspiritsptick;
 
-	short view_class;
 	short weapontype1,weapontype2;
 	short disguise; // [Valaris]
 
@@ -766,6 +778,7 @@ struct npc_item_list {
 struct npc_data {
 	struct block_list bl;
 	struct unit_data  ud; //Because they need to be able to move....
+	struct view_data *vd;
 	struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
 	short n;
 	short class_;
@@ -833,6 +846,7 @@ struct spawn_data {
 struct mob_data {
 	struct block_list bl;
 	struct unit_data  ud;
+	struct view_data *vd;
 	struct status_change sc;
 	struct mob_db *db;	//For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex]
 	char name[NAME_LENGTH];
@@ -885,7 +899,8 @@ struct mob_data {
 
 struct pet_data {
 	struct block_list bl;
-	struct unit_data  ud;
+	struct unit_data ud;
+	struct view_data vd;
 	struct mob_db *db;
 	int target_id;
 	short n;

+ 36 - 75
src/map/mob.c

@@ -124,6 +124,16 @@ int mobdb_checkid(const int id)
 	return id;
 }
 
+/*==========================================
+ * Returns the view data associated to this mob class.
+ *------------------------------------------
+ */
+struct view_data * mob_get_viewdata(class_) 
+{
+	if (mob_db(class_) == mob_dummy)
+		return 0;
+	return &mob_db(class_)->vd;
+}
 /*==========================================
  * Cleans up mob-spawn data to make it "valid"
  *------------------------------------------
@@ -202,7 +212,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
 	md->skillidx = -1;
 	for (i = 0; i < MAX_STATUSCHANGE; i++)
 		md->sc.data[i].timer = -1;
-
+	status_set_viewdata(&md->bl, md->class_);
 	map_addiddb(&md->bl);
 	return md;
 }
@@ -719,22 +729,9 @@ int mob_spawn (struct mob_data *md)
 		memset(md->lootitem, 0, sizeof(md->lootitem));
 	md->lootitem_count = 0;
 
-	if(md->db->option){ // Added for carts, falcons and pecos for cloned monsters. [Valaris]
-		if(md->db->option & 0x0008)
-			md->sc.option |= 0x0008;
-		if(md->db->option & 0x0080)
-			md->sc.option |= 0x0080;
-		if(md->db->option & 0x0100)
-			md->sc.option |= 0x0100;
-		if(md->db->option & 0x0200)
-			md->sc.option |= 0x0200;
-		if(md->db->option & 0x0400)
-			md->sc.option |= 0x0400;
-		if(md->db->option & OPTION_FALCON)
-			md->sc.option |= OPTION_FALCON;
-		if(md->db->option & OPTION_RIDING)
-			md->sc.option |= OPTION_RIDING;
-	}
+	if(md->db->option)
+		// Added for carts, falcons and pecos for cloned monsters. [Valaris]
+		md->sc.option = md->db->option;
 
 	md->max_hp = md->db->max_hp;
 	if(md->special_state.size==1) // change for sized monsters [Valaris]
@@ -744,10 +741,8 @@ int mob_spawn (struct mob_data *md)
 	md->hp = md->max_hp;
 
 	map_addblock(&md->bl);
+	clif_spawn(&md->bl);
 	skill_unit_move(&md->bl,tick,1);
-
-	clif_spawnmob(md);
-
 	mobskill_use(md, tick, MSC_SPAWN);
 	return 0;
 }
@@ -960,6 +955,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 			unit_can_move(&md->bl))
 		{
 			int i=0,dx,dy;
+			mob_stop_attack(md);
 			do {
 				if(i<=5){
 					dx=bl->x - md->bl.x;
@@ -1664,8 +1660,8 @@ int mob_respawn(int tid, unsigned int tick, int id,int data )
 	unit_dataset(&md->bl);
 	map_addblock(&md->bl);
 	mob_heal(md,data*status_get_max_hp(&md->bl)/100);
+	clif_spawn(&md->bl);
 	skill_unit_move(&md->bl,tick,1);
-	clif_spawnmob(md);
 	mobskill_use(md, tick, MSC_SPAWN);
 	return 1;
 }
@@ -2374,32 +2370,20 @@ int mob_class_change (struct mob_data *md, int class_)
 	else if(md->hp < 1) md->hp = 1;
 
 	memcpy(md->name,md->db->jname,NAME_LENGTH-1);
-	memset(&md->state,0,sizeof(md->state));
-	md->attacked_id = 0;
-	md->attacked_players = 0;
-	md->target_id = 0;
-	md->move_fail_count = 0;
-
 	md->speed = md->db->speed;
 	md->def_ele = md->db->element;
 
-	md->state.skillstate = MSS_IDLE;
-	md->last_thinktime = tick;
-	md->next_walktime = tick+rand()%50+5000;
-	md->last_linktime = tick;
 	mob_stop_attack(md);
 	mob_stop_walking(md, 0);
 	unit_skillcastcancel(&md->bl, 0);
-	unit_dataset(&md->bl);
+	status_set_viewdata(&md->bl, class_);
+	
 	for(i=0,c=tick-1000*3600*10;i<MAX_MOBSKILL;i++)
 		md->skilldelay[i] = c;
 
 	if(md->lootitem == NULL && md->db->mode&MD_LOOTER)
 		md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
 
-	clif_clearchar_area(&md->bl,0);
-	clif_spawnmob(md);
-
 	if (battle_config.show_mob_hp)
 		clif_charnameack(0, &md->bl);
 
@@ -2945,7 +2929,6 @@ int mob_clone_spawn(struct map_session_data *sd, char *map, int x, int y, const
 		return 0;
 
 	mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db));
-	mob_db_data[class_]->view_class=sd->status.class_;
 	sprintf(mob_db_data[class_]->name,sd->status.name);
 	sprintf(mob_db_data[class_]->jname,sd->status.name);
 	mob_db_data[class_]->lv=status_get_lv(&sd->bl);
@@ -2974,33 +2957,8 @@ int mob_clone_spawn(struct map_session_data *sd, char *map, int x, int y, const
 	mob_db_data[class_]->adelay=status_get_adelay(&sd->bl);
 	mob_db_data[class_]->amotion=status_get_amotion(&sd->bl);
 	mob_db_data[class_]->dmotion=status_get_dmotion(&sd->bl);
-	mob_db_data[class_]->sex=sd->status.sex;
-	mob_db_data[class_]->hair=sd->status.hair;
-	mob_db_data[class_]->hair_color=sd->status.hair_color;
-#if PACKETVER < 4
-	mob_db_data[class_]->weapon =	sd->status.weapon;
-	mob_db_data[class_]->shield = sd->status.shield;
-#else 
-	if (sd->equip_index[9] >= 0 && sd->inventory_data[sd->equip_index[9]] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
-		if (sd->inventory_data[sd->equip_index[9]]->view_id > 0)
-			mob_db_data[class_]->weapon=sd->inventory_data[sd->equip_index[9]]->view_id;
-		else
-			mob_db_data[class_]->weapon=sd->status.inventory[sd->equip_index[9]].nameid;
-	} else
-		mob_db_data[class_]->shield=0;
-	if (sd->equip_index[8] >= 0 && sd->equip_index[8] != sd->equip_index[9] && sd->inventory_data[sd->equip_index[8]] && sd->view_class != JOB_WEDDING && sd->view_class != JOB_XMAS) {
-		if (sd->inventory_data[sd->equip_index[8]]->view_id > 0)
-			mob_db_data[class_]->shield=sd->inventory_data[sd->equip_index[8]]->view_id;
-		else
-			mob_db_data[class_]->shield=sd->status.inventory[sd->equip_index[8]].nameid;
-	} else
-		mob_db_data[class_]->shield=0;
-#endif
-	mob_db_data[class_]->head_top=sd->status.head_top;
-	mob_db_data[class_]->head_mid=sd->status.head_mid;
-	mob_db_data[class_]->head_buttom=sd->status.head_bottom;
+	memcpy(&mob_db_data[class_]->vd, &sd->vd, sizeof(struct view_data));
 	mob_db_data[class_]->option=sd->sc.option;
-	mob_db_data[class_]->clothes_color=sd->status.clothes_color;
 
 	//Skill copy [Skotlex]
 	ms = &mob_db_data[class_]->skill[0];
@@ -3266,7 +3224,7 @@ static int mob_readdb(void)
 			if (mob_db_data[class_] == NULL)
 				mob_db_data[class_] = aCalloc(1, sizeof (struct mob_data));
 
-			mob_db_data[class_]->view_class = class_;
+			mob_db_data[class_]->vd.class_ = class_;
 			memcpy(mob_db_data[class_]->name, str[1], NAME_LENGTH-1);
 			memcpy(mob_db_data[class_]->jname, str[2], NAME_LENGTH-1);
 			mob_db_data[class_]->lv = atoi(str[3]);
@@ -3475,22 +3433,25 @@ static int mob_readdb_mobavail(void)
 			continue;
 		if (j >= 12 && k > 23 && k < 69)
 			k += 3977;	// advanced job/baby class
-		mob_db_data[class_]->view_class=k;
+
+		memset(&mob_db_data[class_]->vd, 0, sizeof(struct view_data));
+		mob_db_data[class_]->vd.class_=k;
 
 		//Player sprites
 		if(pcdb_checkid(k) && j>=12) {
-			mob_db_data[class_]->sex=atoi(str[2]);
-			mob_db_data[class_]->hair=atoi(str[3]);
-			mob_db_data[class_]->hair_color=atoi(str[4]);
-			mob_db_data[class_]->weapon=atoi(str[5]);
-			mob_db_data[class_]->shield=atoi(str[6]);
-			mob_db_data[class_]->head_top=atoi(str[7]);
-			mob_db_data[class_]->head_mid=atoi(str[8]);
-			mob_db_data[class_]->head_buttom=atoi(str[9]);
+			mob_db_data[class_]->vd.sex=atoi(str[2]);
+			mob_db_data[class_]->vd.hair_style=atoi(str[3]);
+			mob_db_data[class_]->vd.hair_color=atoi(str[4]);
+			mob_db_data[class_]->vd.weapon=atoi(str[5]);
+			mob_db_data[class_]->vd.shield=atoi(str[6]);
+			mob_db_data[class_]->vd.head_top=atoi(str[7]);
+			mob_db_data[class_]->vd.head_mid=atoi(str[8]);
+			mob_db_data[class_]->vd.head_bottom=atoi(str[9]);
 			mob_db_data[class_]->option=atoi(str[10])&~0x46;
-			mob_db_data[class_]->clothes_color=atoi(str[11]); // Monster player dye option - Valaris
+			mob_db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
 		}
-		else if(str[2] && atoi(str[2]) > 0) mob_db_data[class_]->equip=atoi(str[2]); // mob equipment [Valaris]
+		else if(str[2] && atoi(str[2]) > 0)
+			mob_db_data[class_]->vd.shield=atoi(str[2]); // mob equipment [Valaris]
 
 		ln++;
 	}
@@ -3889,7 +3850,7 @@ static int mob_read_sqldb(void)
 				
 				ln++;
 
-				mob_db_data[class_]->view_class = class_;
+				mob_db_data[class_]->vd.class_ = class_;
 				memcpy(mob_db_data[class_]->name, TO_STR(1), NAME_LENGTH-1);
 				memcpy(mob_db_data[class_]->jname, TO_STR(2), NAME_LENGTH-1);
 				mob_db_data[class_]->lv = TO_INT(3);

+ 4 - 17
src/map/mob.h

@@ -5,6 +5,7 @@
 #define _MOB_H_
 
 #include "unit.h"
+#include "map.h"
 
 #define MAX_RANDOMMONSTER 3
 #define MAX_MOB_RACE_DB 6
@@ -47,9 +48,8 @@ struct mob_db {
 	int mexp,mexpper;
 	struct { int nameid,p; } dropitem[10]; //8 -> 10 Lupus
 	struct { int nameid,p; } mvpitem[3];
-	int view_class,sex;
-	short hair,hair_color,weapon,shield,head_top,head_mid,head_buttom,option,clothes_color; // [Valaris]
-	int equip; // [Valaris]
+	struct view_data vd;
+	short option;
 	int summonper[MAX_RANDOMMONSTER];
 	int maxskill;
 	struct mob_skill skill[MAX_MOBSKILL];
@@ -112,6 +112,7 @@ struct mob_db* mob_db(int class_);
 int mobdb_searchname(const char *str);
 int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
 int mobdb_checkid(const int id);
+struct view_data* mob_get_viewdata(int class_);
 int mob_once_spawn(struct map_session_data *sd,char *mapname,
 	int x,int y,const char *mobname,int class_,int amount,const char *event);
 int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
@@ -135,27 +136,13 @@ int mob_heal(struct mob_data*,int);
 
 #define mob_stop_walking(md, type) { if (md->ud.walktimer != -1) unit_stop_walking(&md->bl, type); }
 #define mob_stop_attack(md) { if (md->ud.attacktimer != -1) unit_stop_attack(&md->bl); }
-//Defines to speed up search.
-#define mob_get_viewclass(class_) mob_db(class_)->view_class
-#define mob_get_sex(class_) mob_db(class_)->sex
-#define mob_get_hair(class_) mob_db(class_)->hair
-#define mob_get_hair_color(class_) mob_db(class_)->hair_color
-#define mob_get_weapon(class_) mob_db(class_)->weapon
-#define mob_get_shield(class_) mob_db(class_)->shield
-#define mob_get_head_top(class_) mob_db(class_)->head_top
-#define mob_get_head_mid(class_) mob_db(class_)->head_mid
-#define mob_get_head_buttom(class_) mob_db(class_)->head_buttom
-#define mob_get_clothes_color(class_) mob_db(class_)->clothes_color
-#define mob_get_equip(class_) mob_db(class_)->equip
 
 int do_init_mob(void);
 int do_final_mob(void);
 
 int mob_timer_delete(int tid, unsigned int tick, int id, int data);
-
 int mob_deleteslave(struct mob_data *md);
 
-
 int mob_random_class (int *value, size_t count);
 int mob_get_random_id(int type, int flag, int lv);
 int mob_class_change(struct mob_data *md,int class_);

+ 26 - 8
src/map/npc.c

@@ -63,6 +63,15 @@ static struct tm ev_tm_b;	// 
 
 static struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
 
+//For holding the view data of npc classes. [Skotlex]
+static struct view_data npc_viewdb[MAX_NPC_CLASS];
+
+struct view_data* npc_get_viewdata(int class_)
+{	//Returns the viewdata for normal npc classes.
+	if (npcdb_checkid(class_) || class_ == WARP_CLASS)
+		return &npc_viewdb[class_];
+	return NULL;
+}
 /*==========================================
  * NPCの無効化/有効化
  * npc_enable
@@ -102,7 +111,7 @@ int npc_enable(const char *name,int flag)
 
 	if (flag&1) {	// 有効化
 		nd->flag&=~1;
-		clif_spawnnpc(nd);
+		clif_spawn(&nd->bl);
 	}else if (flag&2){
 		nd->flag&=~1;
 		nd->sc.option = 0x0000;
@@ -1341,7 +1350,6 @@ int npc_unload (struct npc_data *nd)
 			}
 		}
 	}
-
 	aFree(nd);
 
 	return 0;
@@ -1487,7 +1495,9 @@ int npc_parse_warp (char *w1,char *w2,char *w3,char *w4)
 	nd->bl.type = BL_NPC;
 	nd->bl.subtype = WARP;
 	map_addblock(&nd->bl);
-	clif_spawnnpc(nd);
+	unit_dataset(&nd->bl);
+	status_set_viewdata(&nd->bl, nd->class_);
+	clif_spawn(&nd->bl);
 	strdb_put(npcname_db, nd->name, nd);
 
 	return 0;
@@ -1577,7 +1587,8 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
 	if (m >= 0) {
 		nd->n = map_addnpc(m,nd);
 		map_addblock(&nd->bl);
-		clif_spawnnpc(nd);
+		status_set_viewdata(&nd->bl, nd->class_);
+		clif_spawn(&nd->bl);
 	} else
 		// we skip map_addnpc, but still add it to the list of ID's
 		map_addiddb(&nd->bl);
@@ -1880,14 +1891,15 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
 	if (m >= 0) {
 		nd->n = map_addnpc(m, nd);
 		map_addblock(&nd->bl);
-
 		if (evflag) {	// イベント型
 			struct event_data *ev = (struct event_data *)aCalloc(1, sizeof(struct event_data));
 			ev->nd = nd;
 			ev->pos = 0;
 			strdb_put(ev_db, nd->exname, ev);
-		} else
-			clif_spawnnpc(nd);
+		} else {
+			status_set_viewdata(&nd->bl, nd->class_);
+			clif_spawn(&nd->bl);
+		}
 	} else {
 		// we skip map_addnpc, but still add it to the list of ID's
 		map_addiddb(&nd->bl);
@@ -2675,6 +2687,7 @@ static void npc_debug_warps_sub(struct npc_data *nd)
 		);
 	
 }
+
 static void npc_debug_warps()
 {
 	int m, i;
@@ -2691,9 +2704,14 @@ int do_init_npc(void)
 {
 	struct npc_src_list *nsl;
 	time_t last_time = time(0);
-	int busy = 0;
+	int busy;
 	char c = '-';
 
+	//Stock view data for normal npcs.
+	memset(&npc_viewdb, 0, sizeof(npc_viewdb));
+	for (busy = 0; busy < MAX_NPC_CLASS; busy++) 
+		npc_viewdb[busy].class_ = busy;
+	busy = 0;
 	// indoorrswtable.txt and etcinfo.txt [Celest]
 	if (battle_config.indoors_override_grffile)
 		npc_read_indoors();

+ 4 - 3
src/map/npc.h

@@ -10,14 +10,17 @@
 #define WARP_DEBUG_CLASS 722
 #define INVISIBLE_CLASS 32767
 
+#define MAX_NPC_CLASS 1000
 //Checks if a given id is a valid npc id. [Skotlex]
 //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
-#define npcdb_checkid(id) ((id >=  46 && id <= 125) || (id >= 700 && id <= 1000))
+#define npcdb_checkid(id) ((id >=  46 && id <= 125) || id == 139 || (id >= 700 && id <= MAX_NPC_CLASS))
 
 #ifdef PCRE_SUPPORT
 void npc_chat_finalize(struct npc_data *nd);
 int mob_chat_sub(struct block_list *bl, va_list ap);
 #endif
+
+struct view_data* npc_get_viewdata(int class_);
 int npc_chat_sub(struct block_list *bl, va_list ap);
 int npc_event_dequeue(struct map_session_data *sd);
 int npc_event_timer(int tid,unsigned int tick,int id,int data);
@@ -40,8 +43,6 @@ int npc_enable(const char *name,int flag);
 int npc_changename(const char *name, const char *newname, short look); // [Lance]
 struct npc_data* npc_name2id(const char *name);
 
-int npc_changestate(struct npc_data *nd,int state,int type);
-
 int npc_get_new_npc_id(void);
 
 void npc_addsrcfile(char *);

+ 46 - 36
src/map/pc.c

@@ -649,7 +649,6 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
 	// 基本的な初期化
 	sd->state.connect_new = 1;
 
-	sd->view_class = sd->status.class_;
 	sd->speed = DEFAULT_WALK_SPEED;
 	sd->followtimer = -1; // [MouseJstr]
 	sd->skillitem = -1;
@@ -679,7 +678,9 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
 	// アイテムチェック
 	pc_setinventorydata(sd);
 	pc_checkitem(sd);
-
+	
+	//Set here because we need the inventory data for weapon sprite parsing.
+	status_set_viewdata(&sd->bl, sd->status.class_);
 	// pet
 	sd->pet_hungry_timer = -1;
 
@@ -1100,6 +1101,26 @@ int pc_checkweighticon(struct map_session_data *sd)
 	return 0;
 }
 
+int pc_disguise(struct map_session_data *sd, int class_) {
+	if (!class_ && !sd->disguise)
+		return 0;
+	if (class_ && (sd->disguise || pc_isriding(sd)))
+		return 0;
+	
+	if (!class_) {
+		sd->disguise = 0;
+		class_ = sd->status.class_;
+	} else
+		sd->disguise=class_;
+
+	pc_stop_walking(sd, 0);
+	clif_clearchar(&sd->bl, 0);
+	status_set_viewdata(&sd->bl, class_);
+	clif_changeoption(&sd->bl);
+	clif_spawn(&sd->bl);
+	return 1;
+}
+
 static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id) {
 	int i;
 	for (i = 0; i < max && spell[i].id; i++) {
@@ -1531,12 +1552,8 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
 		}
 		break;
 	case SP_DISGUISE: // Disguise script for items [Valaris]
-		if(sd->state.lr_flag!=2 && !sd->state.disguised && !pc_isriding(sd)) {
-			clif_clearchar(&sd->bl, 0);
-			sd->disguise=val;
-			clif_changeoption(&sd->bl);
-			clif_spawnpc(sd);
-		}
+		if(sd->state.lr_flag!=2)
+			pc_disguise(sd, val);
 		break;
 	case SP_UNBREAKABLE:
 		if(sd->state.lr_flag!=2) {
@@ -5440,7 +5457,8 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
 
 	pc_setglobalreg (sd, "jobchange_level", sd->change_level);
 
-	sd->status.class_ = sd->view_class = job;
+	sd->status.class_ = job;
+	status_set_viewdata(&sd->bl, job);
 	fame_flag = pc_istop10fame(sd->status.char_id,sd->class_&MAPID_UPPERMASK);
 	sd->class_ = (unsigned short)b_class;
 	sd->status.job_level=1;
@@ -5455,14 +5473,10 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
 				pc_unequipitem(sd,sd->equip_index[i],2);	// ?備外し
 	}
 
-	clif_changelook(&sd->bl,LOOK_BASE,sd->view_class); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
+	clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
 
-	if(battle_config.save_clothcolor &&
-		sd->status.clothes_color > 0 &&
-		((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) ||
-		(sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) ||
-		(sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
-		clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+	if(sd->vd.cloth_color)
+		clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
 	
 	if(battle_config.muting_players && sd->status.manner < 0 && battle_config.manner_system)
 		clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
@@ -5577,13 +5591,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val)
 	case LOOK_SHOES:
 		break;
 	}
-
-	if((type==LOOK_CLOTHES_COLOR) && ((sd->view_class==JOB_WEDDING && battle_config.wedding_ignorepalette) ||
-	 (sd->view_class==JOB_XMAS && battle_config.xmas_ignorepalette)))
-		return 0;
-
 	clif_changelook(&sd->bl,type,val);
-
 	return 0;
 }
 
@@ -5599,22 +5607,22 @@ int pc_setoption(struct map_session_data *sd,int type)
 		switch (sd->status.class_)
 		{
 			case JOB_KNIGHT:
-				sd->status.class_ = sd->view_class = JOB_KNIGHT2;
+				sd->status.class_ = sd->vd.class_ = JOB_KNIGHT2;
 				break;
 			case JOB_CRUSADER:
-				sd->status.class_ = sd->view_class = JOB_CRUSADER2;
+				sd->status.class_ = sd->vd.class_ = JOB_CRUSADER2;
 				break;
 			case JOB_LORD_KNIGHT:
-				sd->status.class_ = sd->view_class = JOB_LORD_KNIGHT2;
+				sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT2;
 				break;
 			case JOB_PALADIN:
-				sd->status.class_ = sd->view_class = JOB_PALADIN2;
+				sd->status.class_ = sd->vd.class_ = JOB_PALADIN2;
 				break;
 			case JOB_BABY_KNIGHT:
-				sd->status.class_ = sd->view_class = JOB_BABY_KNIGHT2;
+				sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT2;
 				break;
 			case JOB_BABY_CRUSADER:
-				sd->status.class_ = sd->view_class = JOB_BABY_CRUSADER2;
+				sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER2;
 				break;
 		}
 		clif_status_load(&sd->bl,SI_RIDING,1);
@@ -5625,22 +5633,22 @@ int pc_setoption(struct map_session_data *sd,int type)
 		switch (sd->status.class_)
 		{
 			case JOB_KNIGHT2:
-				sd->status.class_ = sd->view_class = JOB_KNIGHT;
+				sd->status.class_ = sd->vd.class_ = JOB_KNIGHT;
 				break;
 			case JOB_CRUSADER2:
-				sd->status.class_ = sd->view_class = JOB_CRUSADER;
+				sd->status.class_ = sd->vd.class_ = JOB_CRUSADER;
 				break;
 			case JOB_LORD_KNIGHT2:
-				sd->status.class_ = sd->view_class = JOB_LORD_KNIGHT;
+				sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT;
 				break;
 			case JOB_PALADIN2:
-				sd->status.class_ = sd->view_class = JOB_PALADIN;
+				sd->status.class_ = sd->vd.class_ = JOB_PALADIN;
 				break;
 			case JOB_BABY_KNIGHT2:
-				sd->status.class_ = sd->view_class = JOB_BABY_KNIGHT;
+				sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT;
 				break;
 			case JOB_BABY_CRUSADER2:
-				sd->status.class_ = sd->view_class = JOB_BABY_CRUSADER;
+				sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER;
 				break;
 		}
 		clif_status_load(&sd->bl,SI_RIDING,0);
@@ -5654,11 +5662,13 @@ int pc_setoption(struct map_session_data *sd,int type)
 	//SG flying [Komurka]
 	if (type&OPTION_FLYING && !(sd->sc.option&OPTION_FLYING)) //Flying ON
 	{
-		if (sd->status.class_==JOB_STAR_GLADIATOR) sd->status.class_ = sd->view_class = JOB_STAR_GLADIATOR2;
+		if (sd->status.class_==JOB_STAR_GLADIATOR)
+			sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR2;
 	}
 	else if (!(type&OPTION_FLYING) && sd->sc.option&OPTION_FLYING) //Flying OFF
 	{
-		if (sd->status.class_==JOB_STAR_GLADIATOR2) sd->status.class_ = sd->view_class = JOB_STAR_GLADIATOR;
+		if (sd->status.class_==JOB_STAR_GLADIATOR2)
+			sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR;
 	}
 
 	sd->sc.option=type;

+ 4 - 4
src/map/pc.h

@@ -13,10 +13,10 @@
 //Update this max as necessary. 53 is the value needed for Super Baby currently
 #define MAX_SKILL_TREE 53
 
-#define pc_setdead(sd) ((sd)->state.dead_sit = 1)
-#define pc_setsit(sd) ((sd)->state.dead_sit = 2)
+#define pc_setdead(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 1)
+#define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2)
 #define pc_isdead(sd) ((sd)->state.dead_sit == 1)
-#define pc_issit(sd) ((sd)->state.dead_sit == 2)
+#define pc_issit(sd) ((sd)->vd.dead_sit == 2)
 #define pc_setdir(sd,b,h) ((sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
 #define pc_setchatid(sd,n) ((sd)->chatID = n)
 #define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK))
@@ -237,5 +237,5 @@ int map_day_timer(int,unsigned int,int,int); // by [yor]
 int map_night_timer(int,unsigned int,int,int); // by [yor]
 
 int pc_read_motd(void); // [Valaris]
-
+int pc_disguise(struct map_session_data *sd, int class_);
 #endif

+ 6 - 5
src/map/pet.c

@@ -434,6 +434,7 @@ int pet_data_init(struct map_session_data *sd)
 	pd->bl.subtype = MONS;
 	pd->bl.type = BL_PET;
 	pd->msd = sd;
+	status_set_viewdata(&pd->bl,pd->class_);
 	unit_dataset(&sd->pd->bl);
 	pd->ud.dir = sd->ud.dir;
 
@@ -488,7 +489,7 @@ int pet_birth_process(struct map_session_data *sd)
 	chrif_save(sd,0); //FIXME: As before, is it REALLY Needed to save the char for hatching a pet? [Skotlex]
 
 	map_addblock(&sd->pd->bl);
-	clif_spawnpet(sd->pd);
+	clif_spawn(&sd->pd->bl);
 	clif_send_petdata(sd,0,0);
 	clif_send_petdata(sd,5,battle_config.pet_hair_style);
 	clif_pet_equip(sd->pd,sd->pet.equip);
@@ -533,7 +534,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag)
 		pet_data_init(sd);
 		if(sd->pd && sd->bl.prev != NULL) {
 			map_addblock(&sd->pd->bl);
-			clif_spawnpet(sd->pd);
+			clif_spawn(&sd->pd->bl);
 			clif_send_petdata(sd,0,0);
 			clif_send_petdata(sd,5,battle_config.pet_hair_style);
 //			clif_pet_equip(sd->pd,sd->pet.equip);
@@ -736,7 +737,7 @@ int pet_change_name(struct map_session_data *sd,char *name)
 	memcpy(sd->pd->name, name, NAME_LENGTH-1);
 	
 	clif_clearchar_area(&sd->pd->bl,0);
-	clif_spawnpet(sd->pd);
+	clif_spawn(&sd->pd->bl);
 	clif_send_petdata(sd,0,0);
 	clif_send_petdata(sd,5,battle_config.pet_hair_style);
 	sd->pet.rename_flag = 1;
@@ -971,8 +972,8 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick)
 	}
 
 	//Return speed to normal.
-	if (pd->speed == 1 || pd->speed == sd->speed>>1);
-		pd->speed = status_get_speed(&pd->bl);
+	if (pd->speed != sd->petDB->speed)
+		pd->speed == sd->petDB->speed;
 	
 	if (pd->target_id) {
 		target= map_id2bl(pd->target_id);

+ 27 - 39
src/map/script.c

@@ -6333,11 +6333,9 @@ int buildin_changebase(struct script_state *st)
 		return 0;
 	}
 
-//	if(vclass==22) {
-//		pc_unequipitem(sd,sd->equip_index[9],0);	// ‘•”õŠO
-//	}
-
-	sd->view_class = vclass;
+	//If you are already using a special view (disguises?) prevent overriding it. [Skotlex]
+	if (sd->vd.class_ == sd->status.class_)
+		status_set_viewdata(&sd->bl, vclass);
 
 	return 0;
 }
@@ -8054,13 +8052,7 @@ int buildin_disguise(struct script_state *st)
 		return 0;
 	}
 
-	pc_stop_walking(sd,0);
-	clif_clearchar(&sd->bl, 0);
-	sd->disguise = id;
-	sd->state.disguised = 1; // set to override items with disguise script [Valaris]
-	clif_changeoption(&sd->bl);
-	clif_spawnpc(sd);
-
+	pc_disguise(sd, id);
 	push_val(st->stack,C_INT,id);
 	return 0;
 }
@@ -8074,11 +8066,7 @@ int buildin_undisguise(struct script_state *st)
 	struct map_session_data *sd=script_rid2sd(st);
 
 	if (sd->disguise) {
-		pc_stop_walking(sd,0);
-		clif_clearchar(&sd->bl, 0);
-		sd->disguise = 0;
-		clif_changeoption(&sd->bl);
-		clif_spawnpc(sd);
+		pc_disguise(sd, 0);
 		push_val(st->stack,C_INT,0);
 	} else {
 		push_val(st->stack,C_INT,1);
@@ -10209,17 +10197,17 @@ int buildin_getmobdata(struct script_state *st) {
 		setd_sub(map_id2sd(st->rid),name,9,(void *)(int)md->mode);
 		setd_sub(map_id2sd(st->rid),name,10,(void *)(int)md->special_state.ai);
 		setd_sub(map_id2sd(st->rid),name,11,(void *)(int)md->db->option);
-		setd_sub(map_id2sd(st->rid),name,12,(void *)(int)md->db->sex);
-		setd_sub(map_id2sd(st->rid),name,13,(void *)(int)md->db->view_class);
-		setd_sub(map_id2sd(st->rid),name,14,(void *)(int)md->db->hair);
-		setd_sub(map_id2sd(st->rid),name,15,(void *)(int)md->db->hair_color);
-		setd_sub(map_id2sd(st->rid),name,16,(void *)(int)md->db->head_buttom);
-		setd_sub(map_id2sd(st->rid),name,17,(void *)(int)md->db->head_mid);
-		setd_sub(map_id2sd(st->rid),name,18,(void *)(int)md->db->head_top);
-		setd_sub(map_id2sd(st->rid),name,19,(void *)(int)md->db->clothes_color);
-		setd_sub(map_id2sd(st->rid),name,20,(void *)(int)md->db->equip);
-		setd_sub(map_id2sd(st->rid),name,21,(void *)(int)md->db->weapon);
-		setd_sub(map_id2sd(st->rid),name,22,(void *)(int)md->db->shield);
+		setd_sub(map_id2sd(st->rid),name,12,(void *)(int)md->vd->sex);
+		setd_sub(map_id2sd(st->rid),name,13,(void *)(int)md->vd->class_);
+		setd_sub(map_id2sd(st->rid),name,14,(void *)(int)md->vd->hair_style);
+		setd_sub(map_id2sd(st->rid),name,15,(void *)(int)md->vd->hair_color);
+		setd_sub(map_id2sd(st->rid),name,16,(void *)(int)md->vd->head_bottom);
+		setd_sub(map_id2sd(st->rid),name,17,(void *)(int)md->vd->head_mid);
+		setd_sub(map_id2sd(st->rid),name,18,(void *)(int)md->vd->head_top);
+		setd_sub(map_id2sd(st->rid),name,19,(void *)(int)md->vd->cloth_color);
+		setd_sub(map_id2sd(st->rid),name,20,(void *)(int)md->vd->shield);
+		setd_sub(map_id2sd(st->rid),name,21,(void *)(int)md->vd->weapon);
+		setd_sub(map_id2sd(st->rid),name,22,(void *)(int)md->vd->shield);
 		setd_sub(map_id2sd(st->rid),name,23,(void *)(int)md->ud.dir);
 	}
 	return 0;
@@ -10271,37 +10259,37 @@ int buildin_setmobdata(struct script_state *st){
 				md->db->option = (short)value;
 				break;
 			case 12:
-				md->db->sex = value;
+				md->vd->sex = value;
 				break;
 			case 13:
-				md->db->view_class = value;
+				md->vd->class_ = value;
 				break;
 			case 14:
-				md->db->hair = (short)value;
+				md->vd->hair_style = (short)value;
 				break;
 			case 15:
-				md->db->hair_color = (short)value;
+				md->vd->hair_color = (short)value;
 				break;
 			case 16:
-				md->db->head_buttom = (short)value;
+				md->vd->head_bottom = (short)value;
 				break;
 			case 17:
-				md->db->head_mid = (short)value;
+				md->vd->head_mid = (short)value;
 				break;
 			case 18:
-				md->db->head_top = (short)value;
+				md->vd->head_top = (short)value;
 				break;
 			case 19:
-				md->db->clothes_color = (short)value;
+				md->vd->cloth_color = (short)value;
 				break;
 			case 20:
-				md->db->equip = value;
+				md->vd->shield = value;
 				break;
 			case 21:
-				md->db->weapon = (short)value;
+				md->vd->weapon = (short)value;
 				break;
 			case 22:
-				md->db->shield = (short)value;
+				md->vd->shield = (short)value;
 				break;
 			case 23:
 				md->ud.dir = (unsigned char)value;

+ 14 - 33
src/map/skill.c

@@ -1580,13 +1580,9 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
 	int dx=0,dy=0,nx,ny;
 	int x=target->x,y=target->y;
 	int dir,ret;
-	struct map_session_data *sd=NULL;
-	struct mob_data *md=NULL;
-	struct pet_data *pd=NULL;
 	struct skill_unit *su=NULL;
 
 	nullpo_retr(0, src);
-	nullpo_retr(0, target);
 
 	if (src != target && map_flag_gvg(target->m) && target->type != BL_SKILL)
 		return 0; //No knocking back in WoE, except for skills... because traps CAN be knocked back.
@@ -1594,22 +1590,13 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
 		return 0; //Actual knockback distance is 0.
 	
 	switch (target->type) {
-		case BL_PC:
-			sd=(struct map_session_data *)target;
-			break;
 		case BL_MOB:
-			md=(struct mob_data *)target;
-			if (md->class_ == MOBID_EMPERIUM)
+			if (((TBL_MOB*)target)->class_ == MOBID_EMPERIUM)
 				return 0;
 			break;
-		case BL_PET:
-			pd=(struct pet_data *)target;
-			break;
 		case BL_SKILL:
 			su=(struct skill_unit *)target;
 			break;
-		default:
-			return 0;
 	}
 
 	if (count&0xf00000)
@@ -1628,8 +1615,9 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
 	ret=path_blownpos(target->m,x,y,dx,dy,count&0xffff);
 	nx=ret>>16;
 	ny=ret&0xffff;
-	
-	unit_stop_walking(target,0); 
+
+	if (!su)
+		unit_stop_walking(target,0); 
 
 	dx = nx - x;
 	dy = ny - y;
@@ -1637,26 +1625,19 @@ int skill_blown( struct block_list *src, struct block_list *target,int count)
 	if (!dx && !dy) //Could not knockback.
 		return 0;
 	
-	if(sd)	/* ?面外に?oたので?チ去 */
-		map_foreachinmovearea(clif_pcoutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_ALL,sd);
-	else if(md)
-		map_foreachinmovearea(clif_moboutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
-	else if(pd)
-		map_foreachinmovearea(clif_petoutsight,target->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,pd);
+	map_foreachinmovearea(clif_outsight,target->m,
+		x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+		dx,dy,target->type==BL_PC?BL_ALL:BL_PC,target);
 		
-	if(su){
+	if(su)
 		skill_unit_move_unit_group(su->group,target->m,dx,dy);
-	}else{
+	else
 		map_moveblock(target, nx, ny, gettick());
-	}
-
-	if(sd)	/* ?面?に入ってきたので表示 */
-		map_foreachinmovearea(clif_pcinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_ALL,sd);
-	else if(md)
-		map_foreachinmovearea(clif_mobinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_PC,md);
-	else if(pd)
-		map_foreachinmovearea(clif_petinsight,target->m,nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,-dx,-dy,BL_PC,pd);
 
+	map_foreachinmovearea(clif_insight,target->m,
+		nx-AREA_SIZE,ny-AREA_SIZE,nx+AREA_SIZE,ny+AREA_SIZE,
+		-dx,-dy,target->type==BL_PC?BL_ALL:BL_PC,target);
+	
 	if(!(count&0x20000)) 
 		clif_blown(target);
 
@@ -8826,7 +8807,7 @@ int skill_frostjoke_scream(struct block_list *bl,va_list ap)
 		return 0;
 	if (bl->type == BL_PC) {
 		struct map_session_data *sd = (struct map_session_data *)bl;
-		if (sd && sd->sc.option & OPTION_INVISIBLE && pc_isGM(sd) > 0)
+		if (sd && sd->sc.option&OPTION_INVISIBLE)
 			return 0;
 	}
 	//It has been reported that Scream/Joke works the same regardless of woe-setting. [Skotlex]

+ 147 - 63
src/map/status.c

@@ -12,6 +12,7 @@
 #include "pc.h"
 #include "map.h"
 #include "pet.h"
+#include "npc.h"
 #include "mob.h"
 #include "clif.h"
 #include "guild.h"
@@ -626,8 +627,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
 	b_matk2 = sd->matk2;
 	b_mdef = sd->mdef;
 	b_mdef2 = sd->mdef2;
-	b_class = sd->view_class;
-	sd->view_class = sd->status.class_;
+	b_class = sd->vd.class_;
 	b_base_atk = sd->base_atk;
 
 	pc_calc_skilltree(sd);	// スキルツリ?の計算
@@ -799,14 +799,6 @@ int status_calc_pc(struct map_session_data* sd,int first)
 		+ sizeof(sd->add_mdmg_count)
 		);
 
-	if(!sd->state.disguised && sd->disguise) {
-		pc_stop_walking(sd,0);
-		clif_clearchar(&sd->bl, 0);
-		sd->disguise=0;
-		clif_changeoption(&sd->bl);
-		clif_spawnpc(sd);
-	}
-
 	for(i=0;i<10;i++) {
 		current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
 		if(index < 0)
@@ -1601,28 +1593,12 @@ int status_calc_pc(struct map_session_data* sd,int first)
 		calculating = 0;
 		return 0;
 	}
-
-	
-	if(sd->sc.data[SC_WEDDING].timer != -1 && sd->view_class != JOB_WEDDING)
-		sd->view_class=JOB_WEDDING;
 	
-	if(sd->sc.data[SC_XMAS].timer != -1 && sd->view_class != JOB_XMAS)
-		sd->view_class=JOB_XMAS;
-
-	if(b_class != sd->view_class) {
-		clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
-		clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
-		clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
-		clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
-	//Restoring cloth dye color after the view class changes. [Skotlex]
-	// Added Xmas Suit [Valaris]
-	if(battle_config.save_clothcolor && sd->status.clothes_color > 0 &&
-		((sd->view_class != JOB_WEDDING && sd->view_class !=JOB_XMAS) || (sd->view_class==JOB_WEDDING && !battle_config.wedding_ignorepalette) ||
-			 (sd->view_class==JOB_XMAS && !battle_config.xmas_ignorepalette)))
-			clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+	if(b_class != sd->vd.class_) {
+		clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_);
+		clif_changelook(&sd->bl,LOOK_WEAPON,sd->vd.weapon);
+		clif_changelook(&sd->bl,LOOK_SHIELD,sd->vd.shield);
+		clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
 	}
 
 	if(memcmp(b_skill,sd->status.skill,sizeof(sd->status.skill)))
@@ -2991,7 +2967,7 @@ int status_get_speed(struct block_list *bl)
 			speed-=((struct mob_data *)bl)->level - ((struct mob_data *)bl)->db->lv;
 	}
 	else if(bl->type==BL_PET)
-		speed = ((struct pet_data *)bl)->msd->petDB->speed;
+		speed = ((struct pet_data *)bl)->speed;
 	else if(bl->type==BL_NPC)	//Added BL_NPC (Skotlex)
 		speed = ((struct npc_data *)bl)->speed;
 
@@ -3208,6 +3184,8 @@ int status_get_guild_id(struct block_list *bl)
 			return msd->status.guild_id; //Alchemist's mobs [Skotlex]
 		return 0; //No guild.
 	}
+	if (bl->type == BL_NPC && bl->subtype == SCRIPT)
+		return ((TBL_NPC*)bl)->u.scr.guild_id;
 	if(bl->type==BL_SKILL)
 		return ((struct skill_unit *)bl)->group->guild_id;
 	return 0;
@@ -3302,6 +3280,98 @@ int status_isimmune(struct block_list *bl)
 	return 0;
 }
 
+struct view_data *status_get_viewdata(struct block_list *bl)
+{
+	nullpo_retr(NULL, bl);
+	switch (bl->type)
+	{
+		case BL_PC:
+			return &((TBL_PC*)bl)->vd;
+		case BL_MOB:
+			return ((TBL_MOB*)bl)->vd;
+		case BL_PET:
+			return &((TBL_PET*)bl)->vd;
+		case BL_NPC:
+			return ((TBL_NPC*)bl)->vd;
+	}
+	return NULL;
+}
+
+void status_set_viewdata(struct block_list *bl, int class_)
+{
+	struct view_data* vd;
+	nullpo_retv(bl);
+	if (mobdb_checkid(class_) || mob_is_clone(class_))
+		vd =  mob_get_viewdata(class_);
+	else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS))
+		vd = npc_get_viewdata(class_);
+	else
+		vd = NULL;
+
+	switch (bl->type) {
+	case BL_PC:
+		{
+			TBL_PC* sd = (TBL_PC*)bl;
+			if (pcdb_checkid(class_)) {
+				sd->vd.class_ = class_;
+				clif_get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield);
+				sd->vd.head_top = sd->status.head_top;
+				sd->vd.head_mid = sd->status.head_mid;
+				sd->vd.head_bottom = sd->status.head_bottom;
+				sd->vd.hair_style = sd->status.hair;
+				sd->vd.hair_color = sd->status.hair_color;
+				sd->vd.cloth_color = sd->status.clothes_color;
+				sd->vd.sex = sd->status.sex;
+			} else if (vd)
+				memcpy(&sd->vd, vd, sizeof(struct view_data));
+			else if (battle_config.error_log)
+				ShowError("status_set_viewdata (PC): No view data for class %d\n", class_);
+		}
+	break;
+	case BL_MOB:
+		{
+			TBL_MOB* md = (TBL_MOB*)bl;
+			if (vd)
+				md->vd = vd;
+			else if (battle_config.error_log)
+				ShowError("status_set_viewdata (MOB): No view data for class %d\n", class_);
+		}
+	break;
+	case BL_PET:
+		{
+			TBL_PET* pd = (TBL_PET*)bl;
+			if (vd) {
+				memcpy(&pd->vd, vd, sizeof(struct view_data));
+				if (!pcdb_checkid(vd->class_)) {
+					pd->vd.hair_style = battle_config.pet_hair_style;
+					if(pd->equip) {
+						pd->vd.shield = itemdb_viewid(pd->equip);
+						if (!pd->vd.shield)
+							pd->vd.shield = pd->equip;
+					}
+				}
+			} else if (battle_config.error_log)
+				ShowError("status_set_viewdata (PET): No view data for class %d\n", class_);
+		}
+	break;
+	case BL_NPC:
+		{
+			TBL_NPC* nd = (TBL_NPC*)bl;
+			if (vd)
+				nd->vd = vd;
+			else if (battle_config.error_log)
+				ShowError("status_set_viewdata (NPC): No view data for class %d\n", class_);
+		}
+	break;
+	}
+	vd = status_get_viewdata(bl);
+	if (vd && vd->cloth_color && (
+		(vd->class_==JOB_WEDDING && !battle_config.wedding_ignorepalette)
+		|| (vd->class_==JOB_XMAS && !battle_config.xmas_ignorepalette)
+	))
+		vd->cloth_color = 0;
+}
+
 struct status_change *status_get_sc(struct block_list *bl)
 {
 	nullpo_retr(NULL, bl);
@@ -3980,24 +4050,20 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
 
 		case SC_XMAS: // Xmas Suit [Valaris]
 		case SC_WEDDING:	//結婚用(結婚衣裳になって?くのが?いとか)
-		if (sd)
-		{	//Change look.
-			pc_stop_attack(sd);
-			if(type==SC_WEDDING)
-				sd->view_class = JOB_WEDDING;
-			else if(type==SC_XMAS)
-				sd->view_class = JOB_XMAS;
-			clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
-			clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
-			clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
-			clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
-			if(battle_config.save_clothcolor && sd->status.clothes_color > 0 && 
-				((type==SC_WEDDING && !battle_config.wedding_ignorepalette) || 
-					(type==SC_XMAS && !battle_config.xmas_ignorepalette)))
-				clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+		{
+			struct view_data *vd = status_get_viewdata(bl);
+			if (vd) {
+				//Store previous values as they could be removed.
+				val1 = vd->class_;
+				val2 = vd->weapon;
+				val3 = vd->shield;
+				val4 = vd->cloth_color;
+				unit_stop_attack(bl);
+				clif_changelook(bl,LOOK_BASE,type==SC_WEDDING?JOB_WEDDING:JOB_XMAS);
+				clif_changelook(bl,LOOK_WEAPON,0);
+				clif_changelook(bl,LOOK_SHIELD,0);
+				clif_changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color);
+			}
 		}
 			break;
 		case SC_NOCHAT:	//チャット禁止?態
@@ -4341,6 +4407,13 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
 				val4 = gettick(); //Store time at which you started running.
 			calc_flag = 1;
 			break;
+
+		case SC_TRICKDEAD:			/* 死んだふり */
+		{
+			struct view_data *vd = status_get_viewdata(bl);
+			if (vd) vd->dead_sit = 1;
+			break;
+		}
 		case SC_BLESSING:
 		case SC_CONCENTRATION:	/* コンセントレ?ション */case SC_ETERNALCHAOS:		/* エタ?ナルカオス */
 		case SC_DRUMBATTLE:			/* ?太鼓の響き */
@@ -4428,7 +4501,6 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
 		case SC_POEMBRAGI:			/* ブラギの詩 */
 		case SC_UGLYDANCE:			/* 自分勝手なダンス */
 		case SC_WEAPONPERFECTION:	/* ウェポンパ?フェクション */
-		case SC_TRICKDEAD:			/* 死んだふり */
 		case SC_FREEZE:				/* 凍結 */
 		case SC_STUN:				/* スタン(val2にミリ秒セット) */
 		case SC_ENERGYCOAT:			/* エナジ?コ?ト */
@@ -4849,18 +4921,23 @@ int status_change_end( struct block_list* bl , int type,int tid )
 
 			case SC_XMAS: // Xmas Suit [Valaris]
 			case SC_WEDDING:	//結婚用(結婚衣裳になって?くのが?いとか)
-			if (sd) {
-				//Restore look
-				sd->view_class = sd->status.class_;
-				clif_changelook(&sd->bl,LOOK_BASE,sd->view_class);
-#if PACKETVER < 4
-				clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
-				clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
-				clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
-				if(battle_config.save_clothcolor && sd->status.clothes_color > 0)
-					clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->status.clothes_color);
+			{
+				struct view_data *vd = status_get_viewdata(bl);
+				if (vd) {
+					if (sd) {
+						//Load data from sd->status.* as the stored values could have changed.
+						status_set_viewdata(bl, sd->status.class_);
+					} else {
+						vd->class_ = sc->data[type].val1;
+						vd->weapon = sc->data[type].val2;
+						vd->shield = sc->data[type].val3;
+						vd->cloth_color = sc->data[type].val4;
+					}
+					clif_changelook(bl,LOOK_BASE,vd->class_);
+					clif_changelook(bl,LOOK_WEAPON,vd->weapon);
+					clif_changelook(bl,LOOK_SHIELD,vd->shield);
+					clif_changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color);
+				}
 			}
 			break;
 			case SC_RUN://駆け足
@@ -5047,6 +5124,13 @@ int status_change_end( struct block_list* bl , int type,int tid )
 			case SC_MOONLIT: //Clear the unit effect. [Skotlex]
 				skill_setmapcell(bl,CG_MOONLIT, sc->data[SC_MOONLIT].val1, CELL_CLRMOONLIT);
 				break;
+			case SC_TRICKDEAD:			/* 死んだふり */
+			{
+				struct view_data *vd = status_get_viewdata(bl);
+				if (vd) vd->dead_sit = 0;
+				break;
+			}
+
 			//gs_something2 [Vicious]
 			case SC_MADNESSCANCEL:
 			case SC_ADJUSTMENT:

+ 2 - 0
src/map/status.h

@@ -481,6 +481,8 @@ int status_get_mode(struct block_list *bl);
 int status_get_mexp(struct block_list *bl);
 int status_get_race2(struct block_list *bl);
 
+struct view_data *status_get_viewdata(struct block_list *bl);
+void status_set_viewdata(struct block_list *bl, int class_);
 struct status_change *status_get_sc(struct block_list *bl);
 
 int status_get_matk1(struct block_list *bl);

+ 24 - 103
src/map/unit.c

@@ -57,21 +57,9 @@ int unit_walktoxy_sub(struct block_list *bl)
 
 	memcpy(&ud->walkpath,&wpd,sizeof(wpd));
 
-	switch (bl->type) {
-	case BL_PC:
+	if (bl->type == BL_PC)
 		clif_walkok((TBL_PC*)bl);
-		clif_movechar((TBL_PC*)bl);
-		break;
-	case BL_MOB:
-		clif_movemob((TBL_MOB*)bl);
-		break;
-	case BL_PET:
-		clif_movepet((TBL_PET*)bl);
-		break;
-	case BL_NPC:
-		clif_movenpc((TBL_NPC*)bl);
-		break;
-	}
+	clif_move(bl);
 
 	ud->state.change_walk_target=0;
 
@@ -151,22 +139,9 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
 		
 		// バシリカ判定
 
-		ud->walktimer = 1;
-		switch (bl->type) {
-		case BL_PC:
-			map_foreachinmovearea(clif_pcoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_ALL,sd);
-			break;
-		case BL_MOB:
-			map_foreachinmovearea(clif_moboutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
-			break;
-		case BL_PET:
-			map_foreachinmovearea(clif_petoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,(TBL_PET*)bl);
-			break;
-		case BL_NPC:
-			map_foreachinmovearea(clif_npcoutsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,(TBL_NPC*)bl);
-			break;	
-		}
-		ud->walktimer = -1;
+		map_foreachinmovearea(clif_outsight,bl->m,
+			x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+			dx,dy,sd?BL_ALL:BL_PC,bl);
 
 		if(md && md->min_chase > md->db->range2)
 			md->min_chase--;
@@ -176,20 +151,9 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
 		map_moveblock(bl, x, y, tick);
 
 		ud->walktimer = 1;
-		switch (bl->type) {
-		case BL_PC:
-			map_foreachinmovearea(clif_pcinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_ALL,sd);
-			break;
-		case BL_MOB:
-			map_foreachinmovearea(clif_mobinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,md);
-			break;
-		case BL_PET:
-			map_foreachinmovearea(clif_petinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_PET*)bl);
-			break;
-		case BL_NPC:
-			map_foreachinmovearea(clif_npcinsight,bl->m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_NPC*)bl);
-			break;
-		}
+		map_foreachinmovearea(clif_insight,bl->m,
+			x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
+			-dx,-dy,sd?BL_ALL:BL_PC,bl);
 		ud->walktimer = -1;
 		
 		if(sd) {
@@ -219,7 +183,6 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
 				clif_displaymessage(sd->fd,"[Miracle of the Sun, Moon and Stars]");
 				sc_start(&sd->bl,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration);
 			}
-
 		}
 	}
 
@@ -285,14 +248,11 @@ int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkp
 	int dx,dy,dir;
 	struct unit_data        *ud = NULL;
 	struct map_session_data *sd = NULL;
-	struct mob_data         *md = NULL;
 	struct walkpath_data wpd;
 
 	nullpo_retr(0, bl);
 	if( BL_CAST( BL_PC,  bl, sd ) ) {
 		ud = &sd->ud;
-	} else if( BL_CAST( BL_MOB, bl, md ) ) {
-		ud = &md->ud;
 	} else
 		ud = unit_bl2ud(bl);
 	
@@ -311,37 +271,16 @@ int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkp
 	dx = dst_x - bl->x;
 	dy = dst_y - bl->y;
 
-	switch (bl->type) {
-		case BL_PC:
-		map_foreachinmovearea(clif_pcoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_ALL,sd);
-		break;
-		case BL_MOB:
-		map_foreachinmovearea(clif_moboutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,md);
-		break;
-		case BL_PET:
-		map_foreachinmovearea(clif_petoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,(TBL_PET*)bl);
-		break;
-		case BL_NPC:
-		map_foreachinmovearea(clif_petoutsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,dx,dy,BL_PC,(TBL_NPC*)bl);
-		break;
-	}
+	map_foreachinmovearea(clif_outsight,bl->m,
+		bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
+		dx,dy,sd?BL_ALL:BL_PC,bl);
 
 	map_moveblock(bl, dst_x, dst_y, gettick());
+	
 	ud->walktimer = 1;
-	switch (bl->type) {
-	case BL_PC:
-		map_foreachinmovearea(clif_pcinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_ALL,sd);
-		break;
-	case BL_MOB:
-		map_foreachinmovearea(clif_mobinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,md);
-		break;
-	case BL_PET:
-		map_foreachinmovearea(clif_petinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_PET*)bl);
-		break;
-	case BL_NPC:
-		map_foreachinmovearea(clif_npcinsight,bl->m,bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,-dx,-dy,BL_PC,(TBL_NPC*)bl);
-		break;
-	}
+	map_foreachinmovearea(clif_insight,bl->m,
+		bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
+		-dx,-dy,sd?BL_ALL:BL_PC,bl);
 	ud->walktimer = -1;
 		
 	if(sd) {
@@ -454,21 +393,11 @@ int unit_warp(struct block_list *bl,int m,int x,int y,int type)
 	bl->m=m;
 
 	map_addblock(bl);
-	switch (bl->type) {
-	case BL_PC:
-		clif_spawnpc((TBL_PC*)bl);
-	break;
-	case BL_MOB:
-		clif_spawnmob((TBL_MOB*)bl);
-		mob_warpslave(bl,AREA_SIZE);
-	break;
-	case BL_PET:
-		clif_spawnpet((TBL_PET*)bl);
-	break;
-	case BL_NPC:
-		clif_spawnnpc((TBL_NPC*)bl);
-	break;
-	}
+	clif_spawn(bl);
+//This is broken because the mob already was changed from map.
+//Fortunately, the slave ai will make them chase their master automatically
+//	if (bl->type == BL_MOB)
+//		mob_warpslave(bl,AREA_SIZE);
 	skill_unit_move(bl,gettick(),1);
 	return 0;
 }
@@ -836,11 +765,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, int skill_num, int
 	}
 
 	if( casttime>0 || temp){ /* 詠唱が必要 */
-		if(sd && sd->disguise) { // [Valaris]
-			clif_skillcasting(src, src->id, target_id, 0,0, skill_num,0);
-			clif_skillcasting(src,-src->id, target_id, 0,0, skill_num,casttime);
-		} else
-			clif_skillcasting(src, src->id, target_id, 0,0, skill_num,casttime);
+
+		clif_skillcasting(src, src->id, target_id, 0,0, skill_num,casttime);
 
 		/* 詠唱反応モンスター */
 		if (sd && target->type == BL_MOB)
@@ -973,12 +899,7 @@ int unit_skilluse_pos2( struct block_list *src, int skill_x, int skill_y, int sk
 	if( casttime>0 ) {
 		/* 詠唱が必要 */
 		unit_stop_walking( src, 1);		// 歩行停止
-		if(sd && sd->disguise) { // [Valaris]
-			clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,0);
-			clif_skillcasting(src,-src->id, 0, skill_x,skill_y, skill_num,casttime);
-		}
-		else
-			clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,casttime);
+		clif_skillcasting(src, src->id, 0, skill_x,skill_y, skill_num,casttime);
 	}
 
 	if( casttime<=0 )	/* 詠唱の無いものはキャンセルされない */
@@ -1502,7 +1423,7 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
 				delete_timer(md->deletetimer,mob_timer_delete);
 			md->deletetimer=-1;
 			md->hp=0;
-			if(pcdb_checkid(mob_get_viewclass(md->class_))) //Player mobs are not removed automatically by the client.
+			if(pcdb_checkid(md->vd->class_)) //Player mobs are not removed automatically by the client.
 				clif_clearchar_delay(gettick()+3000,bl,0);
 			mob_deleteslave(md);
 

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels