mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Fixes Map Loader issues.
See https://github.com/tgstation/-tg-station/issues/6083 and https://github.com/tgstation/-tg-station/pull/6120.
This commit is contained in:
@@ -156,24 +156,41 @@
|
|||||||
|
|
||||||
//The next part of the code assumes there's ALWAYS an /area AND a /turf on a given tile
|
//The next part of the code assumes there's ALWAYS an /area AND a /turf on a given tile
|
||||||
|
|
||||||
//first instance the /area and remove it from the members list
|
//in case of multiples turfs on one tile,
|
||||||
var/length = members.len
|
//will contains the images of all underlying turfs, to simulate the DMM multiple tiles piling
|
||||||
var/atom/instance
|
var/list/turfs_underlays = list()
|
||||||
var/dmm_suite/preloader/_preloader = new(members_attributes[length])//preloader for assigning set variables on atom creation
|
|
||||||
|
|
||||||
instance = locate(members[length])
|
//first instance the /area and remove it from the members list
|
||||||
|
index = members.len
|
||||||
|
var/atom/instance
|
||||||
|
var/dmm_suite/preloader/_preloader = new(members_attributes[index])//preloader for assigning set variables on atom creation
|
||||||
|
|
||||||
|
instance = locate(members[index])
|
||||||
instance.contents.Add(locate(xcrd,ycrd,zcrd))
|
instance.contents.Add(locate(xcrd,ycrd,zcrd))
|
||||||
|
|
||||||
if(_preloader && instance)
|
if(_preloader && instance)
|
||||||
_preloader.load(instance)
|
_preloader.load(instance)
|
||||||
|
|
||||||
members.Remove(members[length])
|
members.Remove(members[index])
|
||||||
|
|
||||||
//then instance the /turf and remove it from the members list
|
//then instance the /turf and, if multiple tiles are presents, simulates the DMM underlays piling effect
|
||||||
length = members.len
|
|
||||||
|
var/first_turf_index = 1
|
||||||
|
while(!ispath(members[first_turf_index],/turf)) //find first /turf object in members
|
||||||
|
first_turf_index++
|
||||||
|
|
||||||
|
//instanciate the first /turf
|
||||||
|
var/turf/T = instance_atom(members[first_turf_index],members_attributes[first_turf_index],xcrd,ycrd,zcrd)
|
||||||
|
|
||||||
|
//if others /turf are presents, simulates the underlays piling effect
|
||||||
|
index = first_turf_index + 1
|
||||||
|
while(index <= members.len)
|
||||||
|
turfs_underlays.Insert(1,image(T.icon,null,T.icon_state,T.layer,T.dir))//add the current turf image to the underlays list
|
||||||
|
var/turf/UT = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)//instance new turf
|
||||||
|
add_underlying_turf(UT,T,turfs_underlays)//simulates the DMM piling effect
|
||||||
|
T = UT
|
||||||
|
index++
|
||||||
|
|
||||||
instance_atom(members[length],members_attributes[length],xcrd,ycrd,zcrd)
|
|
||||||
members.Remove(members[length])
|
|
||||||
|
|
||||||
//Replace the previous part of the code with this if it's unsafe to assume tiles have ALWAYS an /area AND a /turf
|
//Replace the previous part of the code with this if it's unsafe to assume tiles have ALWAYS an /area AND a /turf
|
||||||
/*while(members.len > 0)
|
/*while(members.len > 0)
|
||||||
@@ -203,8 +220,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//finally instance all remainings objects/mobs
|
//finally instance all remainings objects/mobs
|
||||||
for(var/k=1,k<=members.len,k++)
|
for(index=1,index < first_turf_index,index++)
|
||||||
instance_atom(members[k],members_attributes[k],xcrd,ycrd,zcrd)
|
instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
//Helpers procs
|
//Helpers procs
|
||||||
@@ -220,6 +237,8 @@
|
|||||||
if(_preloader && instance)//second preloader pass, as some variables may have been reset/changed by New()
|
if(_preloader && instance)//second preloader pass, as some variables may have been reset/changed by New()
|
||||||
_preloader.load(instance)
|
_preloader.load(instance)
|
||||||
|
|
||||||
|
return instance
|
||||||
|
|
||||||
//text trimming (both directions) helper proc
|
//text trimming (both directions) helper proc
|
||||||
//optionally removes quotes before and after the text (for variable name)
|
//optionally removes quotes before and after the text (for variable name)
|
||||||
/dmm_suite/proc/trim_text(var/what as text,var/trim_quotes=0)
|
/dmm_suite/proc/trim_text(var/what as text,var/trim_quotes=0)
|
||||||
@@ -296,8 +315,16 @@
|
|||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
//simulates the DM multiple turfs on one tile underlaying
|
||||||
|
/dmm_suite/proc/add_underlying_turf(var/turf/placed,var/turf/underturf, var/list/turfs_underlays)
|
||||||
|
if(underturf.density)
|
||||||
|
placed.density = 1
|
||||||
|
if(underturf.opacity)
|
||||||
|
placed.opacity = 1
|
||||||
|
placed.underlays += turfs_underlays
|
||||||
|
|
||||||
//atom creation method that preloads variables before creation
|
//atom creation method that preloads variables before creation
|
||||||
atom/New(atom/loc, dmm_suite/preloader/_dmm_preloader)
|
/atom/New(atom/loc, dmm_suite/preloader/_dmm_preloader)
|
||||||
if(istype(_dmm_preloader, /dmm_suite/preloader))
|
if(istype(_dmm_preloader, /dmm_suite/preloader))
|
||||||
_dmm_preloader.load(src)
|
_dmm_preloader.load(src)
|
||||||
. = ..()
|
. = ..()
|
||||||
@@ -319,4 +346,4 @@ atom/New(atom/loc, dmm_suite/preloader/_dmm_preloader)
|
|||||||
/dmm_suite/preloader/proc/load(atom/what)
|
/dmm_suite/preloader/proc/load(atom/what)
|
||||||
for(var/attribute in attributes)
|
for(var/attribute in attributes)
|
||||||
what.vars[attribute] = attributes[attribute]
|
what.vars[attribute] = attributes[attribute]
|
||||||
Del()
|
Del()
|
||||||
|
|||||||
Reference in New Issue
Block a user