-- #include "cmapbaseobj.lua"

local CMapChunk = Struct('CMapChunk', CMapBaseObj)
    :embed('aIndex', C2iVector)
    :embed('sOffset', C2iVector)
    :embed('cOffset', C2iVector)
    :embed('center', C3Vector)
    :field('radius', 'float')
    :embed('bbox', CAaBox)
    :embed('bottomRight', C3Vector)
    :embed('topLeft', C3Vector)
    :embed('topLeftCoords', C3Vector)
    :field('distToCamera', 'float')
    :embed('bbox2', CAaBox)
    :ptr('detailDoodadInst')
    :ptr('renderChunk')
    :field('unk_AC', 'int32')
    :field('areaId', 'int32')
    :field('unk_B4', 'int32')
    :field('unk_B8', 'int32')
    :field('unk_BC', 'int32')
    :field('unk_C0', 'int32')
    :embed('doodadDefLinkList', TSExplicitList)
    :embed('mapObjDefLinkList', TSExplicitList)
    :embed('unkList', TSExplicitList)
    :embed('lightLinkList', TSExplicitList)
    :embed('mapSoundEmitterLinkList', TSExplicitList)
    :embed('liquidChunkLinkList', TSExplicitList)
    :ptr('chunkInfoBeginPtr')
    :ptr('header')
    :ptr('lowQualityTexMap')
    :ptr('predTexture')
    :ptr('vertices')
    :ptr('vertexShading')
    :ptr('normals')
    :ptr('shadowMap')
    :ptr('layers')
    :ptr('additionalShadowmap')
    :ptr('MCRF')
    :ptr('liquid')
    :ptr('soundEmitters')
    :field('unk_140', 'int32')
    :field('unk_144', 'int32')
    :field('unk_148', 'int32')
    :field('unk_14C', 'int32')
    :field('unk_150', 'int32')
    :field('unk_154', 'int32')

local address = 0x00795e25 -- at CWorldScene__LocateViewer3
debugger_onBreakpoint = nil
function onBreakpoint()
    loadStructToTable(CMapChunk, ECX)
    debugger_onBreakpoint = nil
    debug_removeBreakpoint(address)
    debug_continueFromBreakpoint(co_run)
    return 1
end

debug_setBreakpoint(address)
debugger_onBreakpoint = onBreakpoint
