# Path: Ecstatica/Event.py
# class NextSceneEvent(Event):
#     '''
#     The ev_NEXT_SCENE-event is a special case.
#     It has additional data attached to it.
#     That's why we introduced a new class for that purpose
#     '''
#     def __init__(self, index, value1, value2, value3, uk_data):
#         Event.__init__(self, index, ev_NEXT_SCENE, value1, value2, value3)
#         self.uk_data = uk_data
#         
#     def __str__(self):
#         return Event.__str__(self) + ", extra data:\"" + self.uk_data + "\""


import struct
import itertools
import os
import unittest
from . import Sound
from . import Code
from . import Event
from . import MapArea
from . import SectorSection
from . import Camera
from . import Fixpoint
from .Event import NextSceneEvent
from . import FantFile    
    evttype = struct.unpack(">h", fileobj.read(2))[0]
    index = struct.unpack(">h", fileobj.read(2))[0]
    value1 = struct.unpack(">h", fileobj.read(2))[0]
    value2 = struct.unpack(">h", fileobj.read(2))[0]
    value3 = struct.unpack(">h", fileobj.read(2))[0]
    #There's a special case: ev_NEXT_SCENE
    #This Event is directly followed by at least 25 bytes of data which are used to initialize
    #a struc_19 object of the scene object
    #We simply read in the data and attach it to the Event
    if evttype == Event.ev_NEXT_SCENE:        
        #the additional data block is present only when index != 0
        if index != 0:            
            #read in data
            #The special data sections ends with a 0 byte
            #We have to read in data until we reach that, thgouh -after 24 bytes - we're not storing anymore what we read in
            uk_data = b""
            char = fileobj.read(1)
            length = 0
            while ord(char) != 0:
                if length >= 24:
                    break
                uk_data += char
                char = fileobj.read(1)
            while ord(char) != 0:
                print("exceeding char in NEXT_SCENE-Event:", ord(char))
                char = fileobj.read(1)
            #print "read attachment of length", len(uk_data)
        else: 
            uk_data = b""
                     

# Path: Ecstatica/Event.py
# class NextSceneEvent(Event):
#     '''
#     The ev_NEXT_SCENE-event is a special case.
#     It has additional data attached to it.
#     That's why we introduced a new class for that purpose
#     '''
#     def __init__(self, index, value1, value2, value3, uk_data):
#         Event.__init__(self, index, ev_NEXT_SCENE, value1, value2, value3)
#         self.uk_data = uk_data
#         
#     def __str__(self):
#         return Event.__str__(self) + ", extra data:\"" + self.uk_data + "\""


# Path: Ecstatica/FANTLoad.py
import struct
import itertools
import os
import unittest
from . import Sound
from . import Code
from . import Event
from . import MapArea
from . import SectorSection
from . import Camera
from . import Fixpoint
from .Event import NextSceneEvent
from . import FantFile    

    evttype = struct.unpack(">h", fileobj.read(2))[0]
    index = struct.unpack(">h", fileobj.read(2))[0]
    value1 = struct.unpack(">h", fileobj.read(2))[0]
    value2 = struct.unpack(">h", fileobj.read(2))[0]
    value3 = struct.unpack(">h", fileobj.read(2))[0]
    #There's a special case: ev_NEXT_SCENE
    #This Event is directly followed by at least 25 bytes of data which are used to initialize
    #a struc_19 object of the scene object
    #We simply read in the data and attach it to the Event
    if evttype == Event.ev_NEXT_SCENE:        
        #the additional data block is present only when index != 0
        if index != 0:            
            #read in data
            #The special data sections ends with a 0 byte
            #We have to read in data until we reach that, thgouh -after 24 bytes - we're not storing anymore what we read in
            uk_data = b""
            char = fileobj.read(1)
            length = 0
            while ord(char) != 0:
                if length >= 24:
                    break
                uk_data += char
                char = fileobj.read(1)
            while ord(char) != 0:
                print("exceeding char in NEXT_SCENE-Event:", ord(char))
                char = fileobj.read(1)
            #print "read attachment of length", len(uk_data)
        else: 
            uk_data = b""
                     

        return NextSceneEvent(index, value1, value2, value3, uk_data)