summaryrefslogtreecommitdiff
path: root/src/map/instance.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-08-14 12:41:17 -0300
committershennetsind <ind@henn.et>2013-08-14 12:41:17 -0300
commitb4cf8f280cc5cdd027685fb6dd2a2c5692e12115 (patch)
treec68c2ec6e97d1273e7622be34abfc241619f9759 /src/map/instance.c
parent0b05acb2fb1f64ec500b9b2ebc9cc9af08f36724 (diff)
downloadhercules-b4cf8f280cc5cdd027685fb6dd2a2c5692e12115.tar.gz
hercules-b4cf8f280cc5cdd027685fb6dd2a2c5692e12115.tar.bz2
hercules-b4cf8f280cc5cdd027685fb6dd2a2c5692e12115.tar.xz
hercules-b4cf8f280cc5cdd027685fb6dd2a2c5692e12115.zip
Fixed Bug #7646
Fixed changing map zones/flag of a instance map crashing, also added IOT_ (Instance Owner Type) constants to db/const.txt Special Thanks to purityz for all the help and test scenarios. http://hercules.ws/board/tracker/issue-7646-bg-mapflag-instance-reloadscript-mapserver-crash/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/instance.c')
-rw-r--r--src/map/instance.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/map/instance.c b/src/map/instance.c
index 3f4b29a89..84c0bd8e2 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -207,6 +207,37 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const
memset(map[im].moblist, 0x00, sizeof(map[im].moblist));
map[im].mob_delete_timer = INVALID_TIMER;
+ //Mimic unit
+ if( map[m].unit_count ) {
+ map[im].unit_count = map[m].unit_count;
+ CREATE( map[im].units, struct mapflag_skill_adjust*, map[im].unit_count );
+
+ for(i = 0; i < map[im].unit_count; i++) {
+ CREATE( map[im].units[i], struct mapflag_skill_adjust, 1);
+ memcpy( map[im].units[i],map[m].units[i],sizeof(struct mapflag_skill_adjust));
+ }
+ }
+ //Mimic skills
+ if( map[m].skill_count ) {
+ map[im].skill_count = map[m].skill_count;
+ CREATE( map[im].skills, struct mapflag_skill_adjust*, map[im].skill_count );
+
+ for(i = 0; i < map[im].skill_count; i++) {
+ CREATE( map[im].skills[i], struct mapflag_skill_adjust, 1);
+ memcpy( map[im].skills[i],map[m].skills[i],sizeof(struct mapflag_skill_adjust));
+ }
+ }
+ //Mimic zone mf
+ if( map[m].zone_mf_count ) {
+ map[im].zone_mf_count = map[m].zone_mf_count;
+ CREATE( map[im].zone_mf, char *, map[im].zone_mf_count );
+
+ for(i = 0; i < map[im].zone_mf_count; i++) {
+ CREATE(map[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH);
+ safestrncpy(map[im].zone_mf[i],map[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH);
+ }
+ }
+
map[im].m = im;
map[im].instance_id = instance_id;
map[im].instance_src_map = m;
@@ -353,6 +384,30 @@ void instance_del_map(int16 m) {
aFree(map[m].block);
aFree(map[m].block_mob);
+ if( map[m].unit_count ) {
+ for(i = 0; i < map[m].unit_count; i++) {
+ aFree(map[m].units[i]);
+ }
+ if( map[m].units )
+ aFree(map[m].units);
+ }
+
+ if( map[m].skill_count ) {
+ for(i = 0; i < map[m].skill_count; i++) {
+ aFree(map[m].skills[i]);
+ }
+ if( map[m].skills )
+ aFree(map[m].skills);
+ }
+
+ if( map[m].zone_mf_count ) {
+ for(i = 0; i < map[m].zone_mf_count; i++) {
+ aFree(map[m].zone_mf[i]);
+ }
+ if( map[m].zone_mf )
+ aFree(map[m].zone_mf);
+ }
+
// Remove from instance
for( i = 0; i < instances[map[m].instance_id].num_map; i++ ) {
if( instances[map[m].instance_id].map[i] == m ) {