예제 #1
0
 private void load(Default317Buffer buffer)
 {
     do
     {
         int opcode = buffer.getUnsignedByte();
         if (opcode == 0)
         {
             return;
         }
         if (opcode == 1)
         {
             buffer.getUnsignedByte();
         }
         else if (opcode == 2)
         {
             buffer.getUnsignedByte();
         }
         else if (opcode == 3)
         {
         }                 // dummy
         else if (opcode == 4)
         {
         }                 // dummy
         else if (opcode == 5)
         {
             type = buffer.getUnsignedLEShort();
         }
         else if (opcode == 6)
         {
         }                 // dummy
         else if (opcode == 7)
         {
             buffer.getInt();
         }
         else if (opcode == 8)
         {
         }                 // dummy
         else if (opcode == 10)
         {
             buffer.getString();
         }
         else if (opcode == 11)
         {
         }                 // dummy
         else if (opcode == 12)
         {
             buffer.getInt();
         }
         else if (opcode == 13)
         {
         }                 // dummy
         else
         {
             throw new InvalidOperationException($"Error unrecognized config code: {opcode}");
         }
     } while(true);
 }
예제 #2
0
 private void load(Default317Buffer buffer)
 {
     do
     {
         int opcode = buffer.getUnsignedByte();
         if (opcode == 0)
         {
             return;
         }
         if (opcode == 1)
         {
             configId            = buffer.getUnsignedLEShort();
             leastSignificantBit = buffer.getUnsignedByte();
             mostSignificantBit  = buffer.getUnsignedByte();
         }
         else if (opcode == 10)
         {
             buffer.getString();
         }
         else if (opcode == 2)
         {
         }                 // dummy
         else if (opcode == 3)
         {
             buffer.getInt();
         }
         else if (opcode == 4)
         {
             buffer.getInt();
         }
         else
         {
             throw new InvalidOperationException($"Error unrecognised config code: {opcode}");
         }
     } while(true);
 }
예제 #3
0
        public void start(Archive streamLoader, IBaseClient client1)
        {
            String[] strings = { "model_version", "anim_version", "midi_version", "map_version" };
            for (int i = 0; i < 4; i++)
            {
                byte[]           abyte0 = streamLoader.decompressFile(strings[i]);
                int              j      = abyte0.Length / 2;
                Default317Buffer stream = new Default317Buffer(abyte0);
                versions[i]       = new int[j];
                filePriorities[i] = new byte[j];
                for (int l = 0; l < j; l++)
                {
                    versions[i][l] = stream.getUnsignedLEShort();
                }
            }

            String[] strings2 = { "model_crc", "anim_crc", "midi_crc", "map_crc" };
            for (int k = 0; k < 4; k++)
            {
                byte[]           abyte1   = streamLoader.decompressFile(strings2[k]);
                int              i1       = abyte1.Length / 4;
                Default317Buffer stream_1 = new Default317Buffer(abyte1);
                crcs[k] = new int[i1];
                for (int l1 = 0; l1 < i1; l1++)
                {
                    crcs[k][l1] = stream_1.getInt();
                }
            }

            byte[] abyte2 = streamLoader.decompressFile("model_index");
            int    j1     = versions[0].Length;

            modelIndices = new byte[j1];
            for (int k1 = 0; k1 < j1; k1++)
            {
                if (k1 < abyte2.Length)
                {
                    modelIndices[k1] = abyte2[k1];
                }
                else
                {
                    modelIndices[k1] = 0;
                }
            }

            abyte2 = streamLoader.decompressFile("map_index");
            Default317Buffer stream2 = new Default317Buffer(abyte2);

            j1          = abyte2.Length / 7;
            mapIndices1 = new int[j1];
            mapIndices2 = new int[j1];
            mapIndices3 = new int[j1];
            mapIndices4 = new int[j1];
            for (int i2 = 0; i2 < j1; i2++)
            {
                mapIndices1[i2] = stream2.getUnsignedLEShort();
                mapIndices2[i2] = stream2.getUnsignedLEShort();
                mapIndices3[i2] = stream2.getUnsignedLEShort();
                mapIndices4[i2] = stream2.getUnsignedByte();
            }

            abyte2  = streamLoader.decompressFile("anim_index");
            stream2 = new Default317Buffer(abyte2);
            j1      = abyte2.Length / 2;
            frames  = new int[j1];
            for (int j2 = 0; j2 < j1; j2++)
            {
                frames[j2] = stream2.getUnsignedLEShort();
            }

            abyte2          = streamLoader.decompressFile("midi_index");
            stream2         = new Default317Buffer(abyte2);
            j1              = abyte2.Length;
            musicPriorities = new int[j1];
            for (int k2 = 0; k2 < j1; k2++)
            {
                musicPriorities[k2] = stream2.getUnsignedByte();
            }

            clientInstance = client1;
            running        = true;
            clientInstance.startRunnable(this, 2);
        }
예제 #4
0
        private void readValues(Default317Buffer stream)
        {
            do
            {
                int opcode = stream.getUnsignedByte();
                if (opcode == 0)
                {
                    break;
                }
                if (opcode == 1)
                {
                    frameCount      = stream.getUnsignedByte();
                    primaryFrames   = new int[frameCount];
                    secondaryFrames = new int[frameCount];
                    frameLengths    = new int[frameCount];
                    for (int frame = 0; frame < frameCount; frame++)
                    {
                        primaryFrames[frame]   = stream.getUnsignedLEShort();
                        secondaryFrames[frame] = stream.getUnsignedLEShort();
                        if (secondaryFrames[frame] == 65535)
                        {
                            secondaryFrames[frame] = -1;
                        }
                        frameLengths[frame] = stream.getUnsignedLEShort();
                    }
                }
                else if (opcode == 2)
                {
                    frameStep = stream.getUnsignedLEShort();
                }
                else if (opcode == 3)
                {
                    int flowCount = stream.getUnsignedByte();
                    flowControl = new int[flowCount + 1];
                    for (int flow = 0; flow < flowCount; flow++)
                    {
                        flowControl[flow] = stream.getUnsignedByte();
                    }

                    flowControl[flowCount] = 0x98967f;
                }
                else if (opcode == 4)
                {
                    dynamic = true;
                }
                else if (opcode == 5)
                {
                    priority = stream.getUnsignedByte();
                }
                else if (opcode == 6)
                {
                    playerReplacementShield = stream.getUnsignedLEShort();
                }
                else if (opcode == 7)
                {
                    playerReplacementWeapon = stream.getUnsignedLEShort();
                }
                else if (opcode == 8)
                {
                    maximumLoops = stream.getUnsignedByte();
                }
                else if (opcode == 9)
                {
                    /*
                     * when animating, 0 -> block walking, 1 -> yield to walking, 2 -> interleave
                     * with walking
                     */
                    precedenceAnimating = stream.getUnsignedByte();
                }
                else if (opcode == 10)
                {
                    /*
                     * when walking, 0 -> block walking, 1 -> yield to walking, 2 -> never used...
                     * interleave with walking?
                     */
                    precedenceWalking = stream.getUnsignedByte();
                }
                else if (opcode == 11)
                {
                    replayMode = stream.getUnsignedByte();
                }
                else if (opcode == 12)
                {
                    stream.getInt();
                }
                else
                {
                    throw new InvalidOperationException($"Error unrecognized seq config code: {opcode}");
                }
            } while(true);

            if (frameCount == 0)
            {
                frameCount         = 1;
                primaryFrames      = new int[1];
                primaryFrames[0]   = -1;
                secondaryFrames    = new int[1];
                secondaryFrames[0] = -1;
                frameLengths       = new int[1];
                frameLengths[0]    = -1;
            }

            if (precedenceAnimating == -1)
            {
                if (flowControl != null)
                {
                    precedenceAnimating = 2;
                }
                else
                {
                    precedenceAnimating = 0;
                }
            }
            if (precedenceWalking == -1)
            {
                if (flowControl != null)
                {
                    precedenceWalking = 2;
                    return;
                }

                precedenceWalking = 0;
            }
        }
예제 #5
0
        private void readValues(Default317Buffer stream)
        {
            do
            {
                int opcode = stream.getUnsignedByte();
                if (opcode == 0)
                {
                    return;
                }
                if (opcode == 1)
                {
                    modelId = stream.getUnsignedLEShort();
                }
                else if (opcode == 2)
                {
                    name = stream.getString();
                }
                else if (opcode == 3)
                {
                    description = stream.readBytes();
                }
                else if (opcode == 4)
                {
                    modelZoom = stream.getUnsignedLEShort();
                }
                else if (opcode == 5)
                {
                    modelRotationX = stream.getUnsignedLEShort();
                }
                else if (opcode == 6)
                {
                    modelRotationY = stream.getUnsignedLEShort();
                }
                else if (opcode == 7)
                {
                    modelOffset1 = stream.getUnsignedLEShort();
                    if (modelOffset1 > 32767)
                    {
                        modelOffset1 -= 0x10000;
                    }
                }
                else if (opcode == 8)
                {
                    modelOffset2 = stream.getUnsignedLEShort();
                    if (modelOffset2 > 32767)
                    {
                        modelOffset2 -= 0x10000;
                    }
                }
                else if (opcode == 10)
                {
                    stream.getUnsignedLEShort();
                }
                else if (opcode == 11)
                {
                    stackable = true;
                }
                else if (opcode == 12)
                {
                    value = stream.getInt();
                }
                else if (opcode == 16)
                {
                    membersObject = true;
                }
                else if (opcode == 23)
                {
                    maleEquipModelIdPrimary   = stream.getUnsignedLEShort();
                    equipModelTranslationMale = stream.get();
                }
                else if (opcode == 24)
                {
                    maleEquipModelIdSecondary = stream.getUnsignedLEShort();
                }
                else if (opcode == 25)
                {
                    femaleEquipModelIdPrimary   = stream.getUnsignedLEShort();
                    equipModelTranslationFemale = stream.get();
                }
                else if (opcode == 26)
                {
                    femaleEquipModelIdSecondary = stream.getUnsignedLEShort();
                }
                else if (opcode >= 30 && opcode < 35)
                {
                    if (groundActions == null)
                    {
                        groundActions = new String[5];
                    }
                    groundActions[opcode - 30] = stream.getString();
                    if (groundActions[opcode - 30].Equals("hidden", StringComparison.InvariantCultureIgnoreCase))
                    {
                        groundActions[opcode - 30] = null;
                    }
                }
                else if (opcode >= 35 && opcode < 40)
                {
                    if (actions == null)
                    {
                        actions = new String[5];
                    }
                    actions[opcode - 35] = stream.getString();
                }
                else if (opcode == 40)
                {
                    int colourCount = stream.getUnsignedByte();
                    modifiedModelColors = new int[colourCount];
                    originalModelColors = new int[colourCount];
                    for (int c = 0; c < colourCount; c++)
                    {
                        modifiedModelColors[c] = stream.getUnsignedLEShort();
                        originalModelColors[c] = stream.getUnsignedLEShort();
                    }
                }
                else if (opcode == 78)
                {
                    maleEquipModelIdEmblem = stream.getUnsignedLEShort();
                }
                else if (opcode == 79)
                {
                    femaleEquipModelIdEmblem = stream.getUnsignedLEShort();
                }
                else if (opcode == 90)
                {
                    maleDialogueModelId = stream.getUnsignedLEShort();
                }
                else if (opcode == 91)
                {
                    femaleDialogueModelId = stream.getUnsignedLEShort();
                }
                else if (opcode == 92)
                {
                    maleDialogueHatModelId = stream.getUnsignedLEShort();
                }
                else if (opcode == 93)
                {
                    femaleDialogueHatModelId = stream.getUnsignedLEShort();
                }
                else if (opcode == 95)
                {
                    modelRotationZ = stream.getUnsignedLEShort();
                }
                else if (opcode == 97)
                {
                    noteId = stream.getUnsignedLEShort();
                }
                else if (opcode == 98)
                {
                    noteTemplateId = stream.getUnsignedLEShort();
                }
                else if (opcode >= 100 && opcode < 110)
                {
                    if (stackableIds == null)
                    {
                        stackableIds     = new int[10];
                        stackableAmounts = new int[10];
                    }

                    stackableIds[opcode - 100]     = stream.getUnsignedLEShort();
                    stackableAmounts[opcode - 100] = stream.getUnsignedLEShort();
                }
                else if (opcode == 110)
                {
                    modelScaleX = stream.getUnsignedLEShort();
                }
                else if (opcode == 111)
                {
                    modelScaleY = stream.getUnsignedLEShort();
                }
                else if (opcode == 112)
                {
                    modelScaleZ = stream.getUnsignedLEShort();
                }
                else if (opcode == 113)
                {
                    lightModifier = stream.get();
                }
                else if (opcode == 114)
                {
                    shadowModifier = stream.get() * 5;
                }
                else if (opcode == 115)
                {
                    teamId = stream.getUnsignedByte();
                }
            } while(true);
        }
예제 #6
0
        public static void unpack(Archive streamLoader, GameFont[] fonts, Archive mediaArchive)
        {
            spriteCache = new Cache(50000);
            Default317Buffer stream = new Default317Buffer(streamLoader.decompressFile("data"));
            int parentId            = -1;
            int interfaceCount      = stream.getUnsignedLEShort();

            cache = new RSInterface[interfaceCount];
            while (stream.position < stream.buffer.Length)
            {
                int id = stream.getUnsignedLEShort();
                if (id == 65535)
                {
                    parentId = stream.getUnsignedLEShort();
                    id       = stream.getUnsignedLEShort();
                }

                RSInterface rsInterface = cache[id] = new RSInterface();
                rsInterface.id           = id;
                rsInterface.parentID     = parentId;
                rsInterface.type         = stream.getUnsignedByte();
                rsInterface.actionType   = stream.getUnsignedByte();
                rsInterface.contentType  = stream.getUnsignedLEShort();
                rsInterface.width        = stream.getUnsignedLEShort();
                rsInterface.height       = stream.getUnsignedLEShort();
                rsInterface.alpha        = (byte)stream.getUnsignedByte();
                rsInterface.hoveredPopup = stream.getUnsignedByte();
                if (rsInterface.hoveredPopup != 0)
                {
                    rsInterface.hoveredPopup = (rsInterface.hoveredPopup - 1 << 8) + stream.getUnsignedByte();
                }
                else
                {
                    rsInterface.hoveredPopup = -1;
                }
                int conditionCount = stream.getUnsignedByte();
                if (conditionCount > 0)
                {
                    rsInterface.conditionType  = new int[conditionCount];
                    rsInterface.conditionValue = new int[conditionCount];
                    for (int c = 0; c < conditionCount; c++)
                    {
                        rsInterface.conditionType[c]  = stream.getUnsignedByte();
                        rsInterface.conditionValue[c] = stream.getUnsignedLEShort();
                    }
                }

                int opcodeCount = stream.getUnsignedByte();
                if (opcodeCount > 0)
                {
                    rsInterface.opcodes = new int[opcodeCount][];
                    for (int c = 0; c < opcodeCount; c++)
                    {
                        int subOpcodeCount = stream.getUnsignedLEShort();
                        rsInterface.opcodes[c] = new int[subOpcodeCount];
                        for (int s = 0; s < subOpcodeCount; s++)
                        {
                            rsInterface.opcodes[c][s] = stream.getUnsignedLEShort();
                        }
                    }
                }

                if (rsInterface.type == 0)
                {
                    rsInterface.scrollMax = stream.getUnsignedLEShort();
                    rsInterface.hoverOnly = stream.getUnsignedByte() == 1;
                    int childCount = stream.getUnsignedLEShort();
                    rsInterface.children = new int[childCount];
                    rsInterface.childX   = new int[childCount];
                    rsInterface.childY   = new int[childCount];
                    for (int child = 0; child < childCount; child++)
                    {
                        rsInterface.children[child] = stream.getUnsignedLEShort();
                        rsInterface.childX[child]   = stream.getShort();
                        rsInterface.childY[child]   = stream.getShort();
                    }
                }

                if (rsInterface.type == 1)
                {
                    stream.getUnsignedLEShort();
                    stream.getUnsignedByte();
                }

                if (rsInterface.type == 2)
                {
                    rsInterface.inventoryItemId              = new int[rsInterface.width * rsInterface.height];
                    rsInterface.inventoryStackSize           = new int[rsInterface.width * rsInterface.height];
                    rsInterface.itemSwappable                = stream.getUnsignedByte() == 1;
                    rsInterface.inventory                    = stream.getUnsignedByte() == 1;
                    rsInterface.usableItemInterface          = stream.getUnsignedByte() == 1;
                    rsInterface.itemDeletesDragged           = stream.getUnsignedByte() == 1;
                    rsInterface.inventorySpritePaddingColumn = stream.getUnsignedByte();
                    rsInterface.inventorySpritePaddingRow    = stream.getUnsignedByte();
                    rsInterface.spritesX = new int[20];
                    rsInterface.spritesY = new int[20];
                    rsInterface.sprites  = new Sprite[20];
                    for (int sprite = 0; sprite < 20; sprite++)
                    {
                        int spriteExists = stream.getUnsignedByte();
                        if (spriteExists == 1)
                        {
                            rsInterface.spritesX[sprite] = stream.getShort();
                            rsInterface.spritesY[sprite] = stream.getShort();
                            String name = stream.getString();
                            if (mediaArchive != null && name.Length > 0)
                            {
                                int spriteId = name.LastIndexOf(',');
                                rsInterface.sprites[sprite] = getImage(int.Parse(name.Substring(spriteId + 1)),
                                                                       mediaArchive, name.Substring(0, spriteId));
                            }
                        }
                    }

                    rsInterface.actions = new String[5];
                    for (int action = 0; action < 5; action++)
                    {
                        rsInterface.actions[action] = stream.getString();
                        if (rsInterface.actions[action].Length == 0)
                        {
                            rsInterface.actions[action] = null;
                        }
                    }
                }

                if (rsInterface.type == 3)
                {
                    rsInterface.filled = stream.getUnsignedByte() == 1;
                }
                if (rsInterface.type == 4 || rsInterface.type == 1)
                {
                    rsInterface.textCentred = stream.getUnsignedByte() == 1;
                    int font = stream.getUnsignedByte();
                    if (fonts != null)
                    {
                        rsInterface.textDrawingAreas = fonts[font];
                    }
                    rsInterface.textShadowed = stream.getUnsignedByte() == 1;
                }

                if (rsInterface.type == 4)
                {
                    rsInterface.textDefault = stream.getString();
                    rsInterface.textActive  = stream.getString();
                }

                if (rsInterface.type == 1 || rsInterface.type == 3 || rsInterface.type == 4)
                {
                    rsInterface.colourDefault = stream.getInt();
                }
                if (rsInterface.type == 3 || rsInterface.type == 4)
                {
                    rsInterface.colourActive       = stream.getInt();
                    rsInterface.colourDefaultHover = stream.getInt();
                    rsInterface.colourActiveHover  = stream.getInt();
                }

                if (rsInterface.type == 5)
                {
                    String spriteName = stream.getString();
                    if (mediaArchive != null && spriteName.Length > 0)
                    {
                        int spriteId = spriteName.LastIndexOf(",");
                        rsInterface.spriteDefault = getImage(int.Parse(spriteName.Substring(spriteId + 1)),
                                                             mediaArchive, spriteName.Substring(0, spriteId));
                    }

                    spriteName = stream.getString();
                    if (mediaArchive != null && spriteName.Length > 0)
                    {
                        int spriteId = spriteName.LastIndexOf(",");
                        rsInterface.spriteActive = getImage(int.Parse(spriteName.Substring(spriteId + 1)),
                                                            mediaArchive, spriteName.Substring(0, spriteId));
                    }
                }

                if (rsInterface.type == 6)
                {
                    int interfaceId = stream.getUnsignedByte();
                    if (interfaceId != 0)
                    {
                        rsInterface.modelTypeDefault = 1;
                        rsInterface.modelIdDefault   = (interfaceId - 1 << 8) + stream.getUnsignedByte();
                    }

                    interfaceId = stream.getUnsignedByte();
                    if (interfaceId != 0)
                    {
                        rsInterface.modelTypeActive = 1;
                        rsInterface.modelIdActive   = (interfaceId - 1 << 8) + stream.getUnsignedByte();
                    }

                    interfaceId = stream.getUnsignedByte();
                    if (interfaceId != 0)
                    {
                        rsInterface.animationIdDefault = (interfaceId - 1 << 8) + stream.getUnsignedByte();
                    }
                    else
                    {
                        rsInterface.animationIdDefault = -1;
                    }
                    interfaceId = stream.getUnsignedByte();
                    if (interfaceId != 0)
                    {
                        rsInterface.animationIdActive = (interfaceId - 1 << 8) + stream.getUnsignedByte();
                    }
                    else
                    {
                        rsInterface.animationIdActive = -1;
                    }
                    rsInterface.modelZoom      = stream.getUnsignedLEShort();
                    rsInterface.modelRotationX = stream.getUnsignedLEShort();
                    rsInterface.modelRotationY = stream.getUnsignedLEShort();
                }

                if (rsInterface.type == 7)
                {
                    rsInterface.inventoryItemId    = new int[rsInterface.width * rsInterface.height];
                    rsInterface.inventoryStackSize = new int[rsInterface.width * rsInterface.height];
                    rsInterface.textCentred        = stream.getUnsignedByte() == 1;
                    int font = stream.getUnsignedByte();
                    if (fonts != null)
                    {
                        rsInterface.textDrawingAreas = fonts[font];
                    }
                    rsInterface.textShadowed  = stream.getUnsignedByte() == 1;
                    rsInterface.colourDefault = stream.getInt();
                    rsInterface.inventorySpritePaddingColumn = stream.getShort();
                    rsInterface.inventorySpritePaddingRow    = stream.getShort();
                    rsInterface.inventory = stream.getUnsignedByte() == 1;
                    rsInterface.actions   = new String[5];
                    for (int active = 0; active < 5; active++)
                    {
                        rsInterface.actions[active] = stream.getString();
                        if (rsInterface.actions[active].Length == 0)
                        {
                            rsInterface.actions[active] = null;
                        }
                    }
                }

                if (rsInterface.actionType == 2 || rsInterface.type == 2)
                {
                    rsInterface.selectedActionName = stream.getString();
                    rsInterface.spellName          = stream.getString();
                    rsInterface.spellUsableOn      = stream.getUnsignedLEShort();
                }

                if (rsInterface.type == 8)
                {
                    rsInterface.textDefault = stream.getString();
                }

                if (rsInterface.actionType == 1 || rsInterface.actionType == 4 || rsInterface.actionType == 5 ||
                    rsInterface.actionType == 6)
                {
                    rsInterface.tooltip = stream.getString();
                    if (rsInterface.tooltip.Length == 0)
                    {
                        if (rsInterface.actionType == 1)
                        {
                            rsInterface.tooltip = "Ok";
                        }
                        if (rsInterface.actionType == 4)
                        {
                            rsInterface.tooltip = "Select";
                        }
                        if (rsInterface.actionType == 5)
                        {
                            rsInterface.tooltip = "Select";
                        }
                        if (rsInterface.actionType == 6)
                        {
                            rsInterface.tooltip = "Continue";
                        }
                    }
                }
            }

            spriteCache = null;
        }