BOSS = {}
local bosslist = io.open("bosslist.txt",IO.READ)
for line in bosslist:lines()
	if line != "" table.insert(BOSS,line) end
end
bosslist:close()
console.debug("Found "..#BOSS.." major boss classes.")

stage = {}
local entry_size = 0x20+0x20+4+0x20+0x20+0x20+1+0x20 -- tiles+file+bkMove+bkImg+npc1+npc2+boss+agtitle+wiititle+title

local tbl = io.open("stage.tbl",IO.READ,ENDIAN.LITTLE)
tbl:seek(0,SEEK.END) -- Go to the end of the file
local stage_count = math.floor(tbl:tell()/entry_size)-1 -- Use the file's length to get the number of maps it contains.
console.debug("Found "..stage_count.." stage headers.")

tbl:seek(0,SEEK.SET) -- Go back to the beginning
stage.header = {}
for i = 0,stage_count -- And read them all in.
	stage.header[i] = { -- Header by number
		tiles = tbl:getstr(0x20),
		file = tbl:getstr(0x20),
		bkMove = tbl:getnum(4,UNSIGNED),
		bkImg = tbl:getstr(0x20),
		npc1 = tbl:getstr(0x20),
		npc2 = tbl:getstr(0x20),
		boss = tbl:getnum(1,UNSIGNED),
		title = tbl:getstr(0x20)
	}
	stage.header[stage.header[i].file] = stage.header[i] -- Link the filename to this header too
end
tbl:close()

if CLIENT include "Client/stage.lua" else include "Server/stage.lua" end
