Browse Source

Fixed #635, thank @julia40124009.

Signed-off-by: Cydh Ramdh <cydh@pservero.com>
Cydh Ramdh 9 years ago
parent
commit
857b82d6ee
7 changed files with 26 additions and 17 deletions
  1. 2 1
      src/map/clif.c
  2. 1 1
      src/map/instance.c
  3. 11 11
      src/map/map.c
  4. 1 1
      src/map/map.h
  5. 8 1
      src/map/pc.c
  6. 1 1
      src/map/script.c
  7. 2 1
      src/map/unit.c

+ 2 - 1
src/map/clif.c

@@ -9902,7 +9902,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
 	}
 
 	if( sd->ed ) {
-		map_addblock(&sd->ed->bl);
+		if (map_addblock(&sd->ed->bl))
+			return;
 		clif_spawn(&sd->ed->bl);
 		clif_elemental_info(sd);
 		clif_elemental_updatestatus(sd,SP_HP);

+ 1 - 1
src/map/instance.c

@@ -438,7 +438,7 @@ int instance_destroy(short instance_id)
 		else
 			type = 3;
 
-		for(i = 0; i < MAX_MAP_PER_INSTANCE; i++)
+		for(i = 0; i < im->cnt_map; i++)
 			map_delinstancemap(im->map[i].m);
 	}
 

+ 11 - 11
src/map/map.c

@@ -2386,6 +2386,7 @@ int map_addinstancemap(const char *name, int id)
 
 	map[dst_m].index = mapindex_addmap(-1, map[dst_m].name);
 	map[dst_m].channel = NULL;
+	map[dst_m].mob_delete_timer = INVALID_TIMER;
 
 	map_addmap2db(&map[dst_m]);
 
@@ -2414,10 +2415,10 @@ static int map_instancemap_clean(struct block_list *bl, va_list ap)
 {
 	nullpo_retr(0, bl);
 	switch(bl->type) {
-		case BL_PC:
-		// BL_PET, BL_HOM, BL_MER, and BL_ELEM are removed with BL_PC
+		/*case BL_PC:
+		// BL_PET, BL_HOM, BL_MER, and BL_ELEM are moved when BL_PC warped out in map_instancemap_leave
 			map_quit((struct map_session_data *) bl);
-			break;
+			break;*/
 		case BL_NPC:
 			npc_unload((struct npc_data *)bl,true);
 			break;
@@ -2452,22 +2453,17 @@ int map_delinstancemap(int m)
 	if( map[m].mob_delete_timer != INVALID_TIMER )
 		delete_timer(map[m].mob_delete_timer, map_removemobs_timer);
 
-	mapindex_removemap( map[m].index );
-
 	// Free memory
 	aFree(map[m].cell);
 	aFree(map[m].block);
 	aFree(map[m].block_mob);
-
-	map_removemapdb(&map[m]);
-	memset(&map[m], 0x00, sizeof(map[0]));
-
 	if( map[m].qi_data )
 		aFree(map[m].qi_data);
 
-	// Make delete timers invalid to avoid errors
+	mapindex_removemap( map[m].index );
+	map_removemapdb(&map[m]);
+	memset(&map[m], 0x00, sizeof(map[0]));
 	map[m].mob_delete_timer = INVALID_TIMER;
-
 	return 1;
 }
 
@@ -2569,6 +2565,10 @@ void map_removemobs(int16 m)
 	if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen
 		return; //Mobs are already scheduled for removal
 
+	// Don't remove mobs on instance map
+	if (map[m].instance_id)
+		return;
+
 	map[m].mob_delete_timer = add_timer(gettick()+battle_config.mob_remove_delay, map_removemobs_timer, m, 0);
 }
 

+ 1 - 1
src/map/map.h

@@ -711,7 +711,7 @@ struct map_data {
 	} drop_list[MAX_DROP_PER_MAP];
 
 	struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
-	int mob_delete_timer;	// [Skotlex]
+	int mob_delete_timer;	// Timer ID for map_removemobs_timer [Skotlex]
 	uint32 zone;	// zone number (for item/skill restrictions)
 	int nocommand; //Blocks @/# commands for non-gms. [Skotlex]
 	struct {

+ 8 - 1
src/map/pc.c

@@ -5370,6 +5370,13 @@ char pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int
 		sd->md->ud.dir = sd->ud.dir;
 	}
 
+	if( sd->ed ) {
+		sd->ed->bl.m = m;
+		sd->ed->bl.x = sd->ed->ud.to_x = x;
+		sd->ed->bl.y = sd->ed->ud.to_y = y;
+		sd->ed->ud.dir = sd->ud.dir;
+	}
+
 	pc_cell_basilica(sd);
 	
 	//check if we gonna be rewarped [lighta]
@@ -8845,7 +8852,7 @@ bool pc_setreg2(struct map_session_data *sd, const char *reg, int val) {
 		return false;
 	}
 
-	val = cap_value(val, 0, INT_MAX);
+	val = cap_value(val, INT_MIN, INT_MAX);
 
 	switch (prefix) {
 		case '.':

+ 1 - 1
src/map/script.c

@@ -6592,7 +6592,7 @@ BUILDIN_FUNC(countitem)
 
 /*==========================================
  * Check if item with this amount can fit in inventory
- * Checking : weight, stack amount >32k, slots amount >(MAX_INVENTORY)
+ * Checking : weight, stack amount >(MAX_AMOUNT), slots amount >(MAX_INVENTORY)
  * Return
  *	0 : fail
  *	1 : success (npc side only)

+ 2 - 1
src/map/unit.c

@@ -3074,7 +3074,8 @@ void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype)
 	unit_remove_map(&sd->bl,clrtype);
 
 	//CLR_RESPAWN is the warp from logging out, CLR_TELEPORT is the warp from teleporting, but pets/homunc need to just 'vanish' instead of showing the warping animation.
-	if (clrtype == CLR_RESPAWN || clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT;
+	if (clrtype == CLR_RESPAWN || clrtype == CLR_TELEPORT)
+		clrtype = CLR_OUTSIGHT;
 
 	if(sd->pd)
 		unit_remove_map(&sd->pd->bl, clrtype);