コード例 #1
0
ファイル: Map.cs プロジェクト: WildGenie/uo-atlas-ob
        private unsafe short[] RenderBlock(int x, int y, bool drawStatics)
        {
            short[] data = new short[64];

            Tile[] tiles = m_Tiles.GetLandBlock(x, y);

            fixed(short *pColors = m_Colors)
            {
                fixed(int *pHeight = TileData.HeightTable)
                {
                    fixed(Tile *ptTiles = tiles)
                    {
                        Tile *pTiles = ptTiles;

                        fixed(short *pData = data)
                        {
                            short *pvData = pData;

                            if (drawStatics)
                            {
                                HuedTile[][][] statics = drawStatics ? m_Tiles.GetStaticBlock(x, y) : null;

                                for (int k = 0, v = 0; k < 8; ++k, v += 8)
                                {
                                    for (int p = 0; p < 8; ++p)
                                    {
                                        int highTop = -255;
                                        int highZ = -255;
                                        int highID = 0;
                                        int highHue = 0;
                                        int z, top;

                                        HuedTile[] curStatics = statics[p][k];

                                        if (curStatics.Length > 0)
                                        {
                                            fixed(HuedTile *phtStatics = curStatics)
                                            {
                                                HuedTile *pStatics    = phtStatics;
                                                HuedTile *pStaticsEnd = pStatics + curStatics.Length;

                                                while (pStatics < pStaticsEnd)
                                                {
                                                    z   = pStatics->m_Z;
                                                    top = z + pHeight[pStatics->m_ID & 0x3FFF];

                                                    if (top > highTop || (z > highZ && top >= highTop))
                                                    {
                                                        highTop = top;
                                                        highZ   = z;
                                                        highID  = pStatics->m_ID;
                                                        highHue = pStatics->m_Hue;
                                                    }

                                                    ++pStatics;
                                                }
                                            }
                                        }

                                        top = pTiles->m_Z;

                                        if (top > highTop)
                                        {
                                            highID  = pTiles->m_ID;
                                            highHue = 0;
                                        }

                                        if (highHue == 0)
                                        {
                                            *pvData++ = pColors[highID];
                                        }
                                        else
                                        {
                                            *pvData++ = Hues.GetHue(highHue - 1).Colors[(pColors[highID] >> 10) & 0x1F];
                                        }

                                        ++pTiles;
                                    }
                                }
                            }
                            else
                            {
                                Tile *pEnd = pTiles + 64;

                                while (pTiles < pEnd)
                                {
                                    *pvData++ = pColors[(pTiles++)->m_ID];
                                }
                            }
                        }
                    }
                }
            }

            return(data);
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: vsemchenkov/ServUO
        private unsafe short[] RenderBlock(int x, int y, bool drawStatics, bool diff)
        {
            var data = new short[64];

            Tile[] tiles = m_Tiles.GetLandBlock(x, y, diff);

            fixed(short *pColors = RadarCol.Colors)
            {
                fixed(int *pHeight = TileData.HeightTable)
                {
                    fixed(Tile *ptTiles = tiles)
                    {
                        Tile *pTiles = ptTiles;

                        fixed(short *pData = data)
                        {
                            short *pvData = pData;

                            if (drawStatics)
                            {
                                HuedTile[][][] statics = drawStatics ? m_Tiles.GetStaticBlock(x, y, diff) : null;

                                for (int k = 0, v = 0; k < 8; ++k, v += 8)
                                {
                                    for (int p = 0; p < 8; ++p)
                                    {
                                        int  highTop = -255;
                                        int  highZ = -255;
                                        int  highID = 0;
                                        int  highHue = 0;
                                        int  z, top;
                                        bool highstatic = false;

                                        HuedTile[] curStatics = statics[p][k];

                                        if (curStatics.Length > 0)
                                        {
                                            fixed(HuedTile *phtStatics = curStatics)
                                            {
                                                HuedTile *pStatics    = phtStatics;
                                                HuedTile *pStaticsEnd = pStatics + curStatics.Length;

                                                while (pStatics < pStaticsEnd)
                                                {
                                                    z   = pStatics->m_Z;
                                                    top = z + pHeight[pStatics->ID];

                                                    if (top > highTop || (z > highZ && top >= highTop))
                                                    {
                                                        highTop    = top;
                                                        highZ      = z;
                                                        highID     = pStatics->ID;
                                                        highHue    = pStatics->Hue;
                                                        highstatic = true;
                                                    }

                                                    ++pStatics;
                                                }
                                            }
                                        }
                                        StaticTile[] pending = m_Tiles.GetPendingStatics(x, y);
                                        if (pending != null)
                                        {
                                            foreach (StaticTile penS in pending)
                                            {
                                                if (penS.m_X == p)
                                                {
                                                    if (penS.m_Y == k)
                                                    {
                                                        z   = penS.m_Z;
                                                        top = z + pHeight[penS.m_ID];

                                                        if (top > highTop || (z > highZ && top >= highTop))
                                                        {
                                                            highTop    = top;
                                                            highZ      = z;
                                                            highID     = penS.m_ID;
                                                            highHue    = penS.m_Hue;
                                                            highstatic = true;
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        top = pTiles->m_Z;

                                        if (top > highTop)
                                        {
                                            highID     = pTiles->m_ID;
                                            highHue    = 0;
                                            highstatic = false;
                                        }

                                        if (highHue == 0)
                                        {
                                            try
                                            {
                                                if (highstatic)
                                                {
                                                    *pvData++ = pColors[highID + 0x4000];
                                                }
                                                else
                                                {
                                                    *pvData++ = pColors[highID];
                                                }
                                            }
                                            catch
                                            { }
                                        }
                                        else
                                        {
                                            *pvData++ = Hues.GetHue(highHue - 1).Colors[(pColors[highID + 0x4000] >> 10) & 0x1F];
                                        }

                                        ++pTiles;
                                    }
                                }
                            }
                            else
                            {
                                Tile *pEnd = pTiles + 64;

                                while (pTiles < pEnd)
                                {
                                    *pvData++ = pColors[(pTiles++)->m_ID];
                                }
                            }
                        }
                    }
                }
            }

            return(data);
        }
コード例 #3
0
ファイル: Map.cs プロジェクト: uotools/UltimaCore
        private unsafe short[] RenderBlock(int x, int y, bool drawstatics)
        {
            short[] data = new short[64];

            Tile[] tiles = _tiles.GetLandBlock(x, y);

            fixed(Tile *ptTiles = tiles)
            {
                Tile *ptiles = ptTiles;

                fixed(short *pdata = data)
                {
                    short *pvdata = pdata;

                    if (drawstatics)
                    {
                        HuedTile[][][] statics = _tiles.GetStaticBlock(x, y);

                        for (int k = 0, v = 0; k < 8; k++, v += 8)
                        {
                            for (int p = 0; p < 8; p++)
                            {
                                int  highTop = -255;
                                int  highZ = -255;
                                int  highID = 0;
                                int  highHue = 0;
                                int  z, top;
                                bool highstatic = false;

                                HuedTile[] curStatics = statics[p][k];

                                if (curStatics.Length > 0)
                                {
                                    fixed(HuedTile *phtStatics = curStatics)
                                    {
                                        HuedTile *pStatics    = phtStatics;
                                        HuedTile *pStaticsEnd = pStatics + curStatics.Length;

                                        while (pStatics < pStaticsEnd)
                                        {
                                            z   = pStatics->Z;
                                            top = z + TileData.StaticData[pStatics->ID].Height;

                                            if (top > highTop || (z > highZ && top >= highTop))
                                            {
                                                highTop    = top;
                                                highZ      = z;
                                                highID     = pStatics->ID;
                                                highHue    = pStatics->Hue;
                                                highstatic = true;
                                            }

                                            ++pStatics;
                                        }
                                    }
                                }

                                StaticTile[] pending = _tiles.GetPendingStatics(x, y);
                                if (pending != null)
                                {
                                    foreach (StaticTile pens in pending)
                                    {
                                        if (pens.X == p && pens.Y == k)
                                        {
                                            z   = pens.Z;
                                            top = z + TileData.StaticData[pens.ID].Height;

                                            if (top > highTop || (z > highZ && top >= highTop))
                                            {
                                                highTop    = top;
                                                highZ      = z;
                                                highID     = pens.ID;
                                                highHue    = pens.Hue;
                                                highstatic = true;
                                            }
                                        }
                                    }
                                }

                                top = ptiles->Z;

                                if (top > highTop)
                                {
                                    highID     = ptiles->ID;
                                    highHue    = 0;
                                    highstatic = false;
                                }

                                if (highHue == 0)
                                {
                                    if (highstatic)
                                    {
                                        *pvdata++ = (short)Hues.GetRadarColorData(highID + 0x4000);
                                    }
                                    else
                                    {
                                        *pvdata++ = (short)Hues.GetRadarColorData(highID);
                                    }
                                }
                                else
                                {
                                    *pvdata++ = (short)Hues.GetColor((ushort)(highHue - 1), (ushort)((Hues.GetRadarColorData(highID + 0x4000) >> 10) & 0x1F));
                                }


                                ++ptiles;
                            }
                        }
                    }
                    else
                    {
                        Tile *pend = ptiles + 64;
                        while (ptiles < pend)
                        {
                            *pvdata++ = (short)Hues.GetRadarColorData((ptiles++)->ID);
                        }
                    }
                }
            }

            return(data);
        }
コード例 #4
0
ファイル: Map.cs プロジェクト: drk84/ultimaonlinemapcreator-1
        private unsafe short[] RenderBlock(int x, int y, bool drawStatics)
        {
            int mID;

            HuedTile[][][] staticBlock;
            short[]        numArray  = new short[64];
            Tile[]         landBlock = this.m_Tiles.GetLandBlock(x, y);
            fixed(short *mColors = &Map.m_Colors[0])
            {
                fixed(int *heightTable = &TileData.HeightTable[0])
                {
                    fixed(Tile *tilePointer = &landBlock[0])
                    {
                        Tile *tilePointer1 = tilePointer;

                        fixed(short *numPointer = &numArray[0])
                        {
                            short *numPointer1 = numPointer;

                            if (!drawStatics)
                            {
                                Tile *tilePointer2 = tilePointer1 + 64 * sizeof(Tile);
                                while (tilePointer1 < tilePointer2)
                                {
                                    short *mID1 = numPointer1;
                                    numPointer1 = mID1 + 2;
                                    Tile *tilePointer3 = tilePointer1;
                                    tilePointer1 = tilePointer3 + sizeof(Tile);
                                    *mID1 = (short)(*(mColors + (void *)(*tilePointer3).m_ID * 2));
                                }
                            }
                            else
                            {
                                if (drawStatics)
                                {
                                    staticBlock = this.m_Tiles.GetStaticBlock(x, y);
                                }
                                else
                                {
                                    staticBlock = null;
                                }
                                HuedTile[][][] huedTileArray = staticBlock;
                                int            num           = 0;
                                int            num1          = 0;
                                while (num < 8)
                                {
                                    for (int i = 0; i < 8; i++)
                                    {
                                        int        num2           = -255;
                                        int        num3           = -255;
                                        int        mID2           = 0;
                                        int        mHue           = 0;
                                        HuedTile[] huedTileArray1 = huedTileArray[i][num];
                                        if ((int)huedTileArray1.Length > 0)
                                        {
                                            fixed(HuedTile *huedTilePointer = &huedTileArray1[0])
                                            {
                                                HuedTile *huedTilePointer1 = huedTilePointer;
                                                HuedTile *length           = huedTilePointer1 + (int)huedTileArray1.Length * sizeof(HuedTile);

                                                while (huedTilePointer1 < length)
                                                {
                                                    int mZ = (*huedTilePointer1).m_Z;
                                                    mID = mZ + *(heightTable + ((*huedTilePointer1).m_ID & 16383) * 4);
                                                    if (mID > num2 || mZ > num3 && mID >= num2)
                                                    {
                                                        num2 = mID;
                                                        num3 = mZ;
                                                        mID2 = (*huedTilePointer1).m_ID;
                                                        mHue = (*huedTilePointer1).m_Hue;
                                                    }
                                                    huedTilePointer1 = huedTilePointer1 + sizeof(HuedTile);
                                                }
                                            }
                                        }
                                        mID = (*tilePointer1).m_Z;
                                        if (mID > num2)
                                        {
                                            mID2 = (*tilePointer1).m_ID;
                                            mHue = 0;
                                        }
                                        if (mHue != 0)
                                        {
                                            short *colors = numPointer1;
                                            numPointer1 = colors + 2;
                                            *colors = Hues.GetHue(mHue - 1).Colors[*(mColors + mID2 * 2) >> 10 & 31];
                                        }
                                        else
                                        {
                                            short *numPointer2 = numPointer1;
                                            numPointer1 = numPointer2 + 2;
                                            *numPointer2 = *(mColors + mID2 * 2);
                                        }
                                        tilePointer1 = tilePointer1 + sizeof(Tile);
                                    }
                                    num++;
                                    num1 = num1 + 8;
                                }
                            }
                        }
                    }
                }
            }

            return(numArray);
        }
コード例 #5
0
ファイル: Map.cs プロジェクト: vilsonfarias/UOFiddler
        private unsafe short[] RenderBlock(int x, int y, bool drawStatics, bool diff)
        {
            var data = new short[64];

            Tile[] tiles = _tiles.GetLandBlock(x, y, diff);

            fixed(short *pColors = RadarCol.Colors)
            {
                fixed(int *pHeight = TileData.HeightTable)
                fixed(Tile * ptTiles = tiles)
                {
                    Tile *pTiles = ptTiles;

                    fixed(short *pData = data)
                    {
                        short *pvData = pData;

                        if (drawStatics)
                        {
                            HuedTile[][][] statics = _tiles.GetStaticBlock(x, y, diff);

                            for (int k = 0; k < 8; ++k)
                            {
                                for (int p = 0; p < 8; ++p)
                                {
                                    int  highTop = -255;
                                    int  highZ = -255;
                                    int  highId = 0;
                                    int  highHue = 0;
                                    int  z, top;
                                    bool highStatic = false;

                                    HuedTile[] curStatics = statics[p][k];

                                    if (curStatics.Length > 0)
                                    {
                                        fixed(HuedTile *phtStatics = curStatics)
                                        {
                                            HuedTile *pStatics    = phtStatics;
                                            HuedTile *pStaticsEnd = pStatics + curStatics.Length;

                                            while (pStatics < pStaticsEnd)
                                            {
                                                z   = pStatics->Z;
                                                top = z + pHeight[pStatics->Id];

                                                if (top > highTop || (z > highZ && top >= highTop))
                                                {
                                                    highTop    = top;
                                                    highZ      = z;
                                                    highId     = pStatics->Id;
                                                    highHue    = pStatics->Hue;
                                                    highStatic = true;
                                                }

                                                ++pStatics;
                                            }
                                        }
                                    }

                                    StaticTile[] pending = _tiles.GetPendingStatics(x, y);
                                    if (pending != null)
                                    {
                                        foreach (StaticTile penS in pending)
                                        {
                                            if (penS.X != p || penS.Y != k)
                                            {
                                                continue;
                                            }

                                            z   = penS.Z;
                                            top = z + pHeight[penS.Id];

                                            if (top <= highTop && (z <= highZ || top < highTop))
                                            {
                                                continue;
                                            }

                                            highTop    = top;
                                            highZ      = z;
                                            highId     = penS.Id;
                                            highHue    = penS.Hue;
                                            highStatic = true;
                                        }
                                    }

                                    top = pTiles->Z;

                                    if (top > highTop)
                                    {
                                        highId     = pTiles->Id;
                                        highHue    = 0;
                                        highStatic = false;
                                    }

                                    if (highHue == 0)
                                    {
                                        try
                                        {
                                            if (highStatic)
                                            {
                                                *pvData++ = pColors[highId + 0x4000];
                                            }
                                            else
                                            {
                                                *pvData++ = pColors[highId];
                                            }
                                        }
                                        catch
                                        {
                                            // TODO: ignored?
                                            // ignored
                                        }
                                    }
                                    else
                                    {
                                        *pvData++ = Hues.GetHue(highHue - 1)
                                                    .Colors[(pColors[highId + 0x4000] >> 10) & 0x1F];
                                    }

                                    ++pTiles;
                                }
                            }
                        }
                        else
                        {
                            Tile *pEnd = pTiles + 64;

                            while (pTiles < pEnd)
                            {
                                *pvData++ = pColors[(pTiles++)->Id];
                            }
                        }
                    }
                }
            }

            return(data);
        }
コード例 #6
0
ファイル: Map.cs プロジェクト: drk84/ultimaonlinemapcreator-1
        private unsafe short[] RenderBlock(int x, int y, bool drawStatics)
        {
            short[] numArray  = new short[64];
            Tile[]  landBlock = this.m_Tiles.GetLandBlock(x, y);
            fixed(short *numPtr1 = &Map.m_Colors[0])
            fixed(int *numPtr2    = &TileData.HeightTable[0])
            fixed(Tile * tilePtr1 = &landBlock[0])
            {
                Tile *tilePtr2 = tilePtr1;

                fixed(short *numPtr3 = &numArray[0])
                {
                    short *numPtr4 = numPtr3;

                    if (drawStatics)
                    {
                        HuedTile[][][] huedTileArray1 = drawStatics ? this.m_Tiles.GetStaticBlock(x, y) : (HuedTile[][][])null;
                        int            index1         = 0;
                        int            num1           = 0;
                        while (index1 < 8)
                        {
                            for (int index2 = 0; index2 < 8; ++index2)
                            {
                                int        num2           = -255;
                                int        num3           = -255;
                                int        index3         = 0;
                                int        num4           = 0;
                                HuedTile[] huedTileArray2 = huedTileArray1[index2][index1];
                                if (huedTileArray2.Length > 0)
                                {
                                    fixed(HuedTile *huedTilePtr1 = &huedTileArray2[0])
                                    {
                                        HuedTile *huedTilePtr2 = huedTilePtr1;

                                        for (HuedTile *huedTilePtr3 = huedTilePtr2 + huedTileArray2.Length; huedTilePtr2 < huedTilePtr3; ++huedTilePtr2)
                                        {
                                            int num5 = (int)huedTilePtr2->m_Z;
                                            int num6 = num5 + numPtr2[(int)huedTilePtr2->m_ID & 16383];
                                            if (num6 > num2 || num5 > num3 && num6 >= num2)
                                            {
                                                num2   = num6;
                                                num3   = num5;
                                                index3 = (int)huedTilePtr2->m_ID;
                                                num4   = (int)huedTilePtr2->m_Hue;
                                            }
                                        }
                                    }
                                }
                                if ((int)tilePtr2->m_Z > num2)
                                {
                                    index3 = (int)tilePtr2->m_ID;
                                    num4   = 0;
                                }
                                *numPtr4++ = num4 != 0 ? Hues.GetHue(num4 - 1).Colors[(int)numPtr1[index3] >> 10 & 31] : numPtr1[index3];
                                ++tilePtr2;
                            }
                            ++index1;
                            num1 += 8;
                        }
                    }
                    else
                    {
                        Tile *tilePtr3 = tilePtr2 + 64;
                        while (tilePtr2 < tilePtr3)
                        {
                            *numPtr4++ = numPtr1[tilePtr2++->m_ID];
                        }
                    }
                }
            }
            return(numArray);
        }