ID:141990
 
Code:
world
name = "Dungeon"
mob = /mob/creating_character
view = 10
maxx=50
maxy=50
turf = /turf/floor/grass
New()
..()
darke_mapwall = /turf/wall/concrete
darke_mappassage = /turf/door
darke_mapfloor = /turf/floor/indoor/tile
darke_roomX = 10
darke_roomY = 10
darke_openchance = 25
darke_passagechance = 15
darke_nodeX = 1 // horizontal size of a node
darke_nodeY = 1
// darke_mapfloor = mapfloor[rand(1,length(mapfloor))] // choose a random floor type for darke_mappassages
var/dmp_reader/new_reader = new()
//Call load_map() to load the map file.
if(fexists("[world.name].dmp"))
new_reader.load_map("[world.name].dmp")
world.log << "Loading dungeon [world.maxz]..."
else
world.log << "Generating dungeon..."
darke_MakeMap(1,world.maxx,1,world.maxy, 1)
/* var/turf/Turf
var/stairs_placed=0

for(var/Number = rand(10,20), Number > 0 , Number--)
do
// find a random turf
Turf = locate(rand(1,world.maxx),rand(1,world.maxy),maxz-1)
// keep looking until you find a floor that's empty
while(!isfloor(Turf) && Turf.contents)
if(!stairs_placed)
stairs_placed=1
var/obj/stairs/up/O=new /obj/stairs(Turf)
O.tag="stairsup[O.z]"
O.target="stairsdown[O.z+1]"
world << "Stairs placed ([O.x],[O.y])"*/

// switch(rand(1,2))
// if(1) // place a monster
// new/mob/zombie(Turf)
// else // place a sword
// new/obj/gear/weapons/blunt/bat(Turf)
Del()
if(fexists("[world.name].dmp"))
fdel("[world.name].dmp")
var/dmp_writer/D = new()
var/map_name=world.name
var/turf/south_west_deep = locate(1,1,1)
var/turf/north_east_shallow = locate(world.maxx,world.maxy,world.maxz-1)
D.save_map(south_west_deep, north_east_shallow, map_name, flags = DMP_IGNORE_PLAYERS)
..()


Problem description: Whenever I initially run, things work fine. Town.dmm goes on z level 2 and the dungeon on 1. It seems to just save z level 1. Great. Then, when I start it back up, it loads the dungeon to Z 3, town to Z 2 and a blank level to Z 1. This, then, gets saved. Why is it creating a blank Z level?

One odd thing I noticed:
I think you mixed up your variables here:
var/turf/north_east_shallow = locate(world.maxx,world.maxy,world.maxx-1)


You probably intended the last argument to be world.maxz-1, correct?

I'm not sure if that is the cause of your problems, but it may be contributing.

Also, this section has be baffled:
            for(var/Number = rand(10,20), Number > 0 , Number--)
do
// find a random turf
Turf = locate(rand(1,world.maxx),rand(1,world.maxy),2)
// keep looking until you find a floor that's empty
while(!isfloor(Turf) && Turf.contents)
if(!stairs_placed)
stairs_placed=1
var/obj/stairs/up/O=new /obj/stairs(Turf)
O.tag="stairsup[O.z]"
O.target="stairsdown[O.z+1]"
world << "Stairs placed ([O.x],[O.y])"


It seems to be searching z-level 2 (which you say is the town, correct?) for an open floor turf to place stairs going up. This makes me think you either mispoke, or had originally intended to have the town on z-1 and the dungeon on z-2, unless it's a floating dungeon...

Also, var/obj/stairs/up/O=new /obj/stairs(Turf) seems like an odd statement. Is there an /obj/stairs/up type, or was that accidentally left behind from something else? Either way, the new /obj/stairs(Turf) can be shortened to new(Turf).
In response to DarkCampainger (#1)
You are correct, it should be maxz-1. That's what I get for not just doing a copy/paste ;-)

The whole for loop is kind of a red herring. It's just a crude population loop. /obj/stair/up is indeed a type. The 2 is a bad arg, it should be world.maxz-1 which points to the first level of dungeon.
In response to Jmurph (#2)