private static unsafe void run(TranslationStructure *settings)
        {
            unsafe {
                // Move to unmanaged memory

                //int dataSize = Marshal.SizeOf<EUDSettings>(settings);

                int               dataSize = 1024; // Stupid but works
                IntPtr            ptr      = Marshal.AllocHGlobal(dataSize);
                byte *            data     = (byte *)ptr;
                UnsafeWriteBuffer wb       = new UnsafeWriteBuffer(data);
                wb.writeByte(settings->action);
                wb.writeBytePtr(settings->inputFilePath);
                wb.writeBytePtr(settings->outputFilePath);

                wb.writeBytePtr(settings->stringData);
                wb.writeInt(settings->stringDataLength);

                wb.writeInt(settings->useCondition);
                wb.writeByte(settings->repack);

                wb.writeByte(settings->result);

                // Process
                IntPtr ms = (IntPtr)data;
                Process(ms);

                UnsafeReadBuffer rb = new UnsafeReadBuffer(data);
                settings->action = (byte)rb.readByte();

                settings->inputFilePath  = rb.readBytePtr();
                settings->outputFilePath = rb.readBytePtr();

                settings->stringData       = rb.readBytePtr();
                settings->stringDataLength = rb.readInt();

                settings->useCondition = rb.readInt();
                settings->repack       = (byte)rb.readByte();

                settings->result = (byte)rb.readByte();

                Marshal.FreeHGlobal(ptr);
            }
        }
Beispiel #2
0
        private static unsafe void run(EUDSettings *settings)
        {
            unsafe
            {
                // Move to unmanaged memory

                //int dataSize = Marshal.SizeOf<EUDSettings>(settings);

                int               dataSize = 1024; // Stupid but works
                IntPtr            ptr      = Marshal.AllocHGlobal(dataSize);
                byte *            data     = (byte *)ptr;
                UnsafeWriteBuffer wb       = new UnsafeWriteBuffer(data);
                wb.writeByte(settings->action);
                wb.writeBool(settings->addTouchRevive);
                wb.writeBool(settings->useDefaultGunShot);
                wb.writeBool(settings->useDefaultBackgroundMusic);
                wb.writeBool(settings->enableVisor);
                wb.writeBool(settings->enableBarrier);
                wb.writeBool(settings->addLeaderboard);
                wb.writeBool(settings->addTimeLock);

                wb.writeBool(settings->useSanctuaryColors);

                wb.writeBool(settings->recalculateHPAndDamage);
                wb.writeBool(settings->muteUnits);

                wb.writeBytePtr(settings->GunShotWavFilePath);
                wb.writeBytePtr(settings->VisorUsageFilePath);
                wb.writeBytePtr(settings->BackgroundWavFilePath);

                wb.writeBytePtr(settings->TimeLockMessage);
                wb.writeBytePtr(settings->TimeLockFrom);
                wb.writeBytePtr(settings->TimeLockTo);
                wb.writeBytePtr(settings->inputFilePath);
                wb.writeBytePtr(settings->outputFilePath);

                wb.writeShort(settings->EMPDamage);

                wb.writeInt(settings->result);
                wb.writeBytePtr(settings->preferredUnitSettings);
                wb.writeBytePtr(settings->ignoreArmors);

                wb.writeBytePtr(settings->mapName);
                wb.writeBytePtr(settings->description);
                wb.writeBytePtr(settings->objectives);
                wb.writeBool(settings->useObjectives);

                // Process
                IntPtr ms = (IntPtr)data;
                Process(ms);

                UnsafeReadBuffer rb = new UnsafeReadBuffer(data);
                settings->action                    = (byte)rb.readByte();
                settings->addTouchRevive            = rb.readBool();
                settings->useDefaultGunShot         = rb.readBool();
                settings->useDefaultBackgroundMusic = rb.readBool();
                settings->enableVisor               = rb.readBool();
                settings->enableBarrier             = rb.readBool();
                settings->addLeaderboard            = rb.readBool();
                settings->addTimeLock               = rb.readBool();
                settings->useSanctuaryColors        = rb.readBool();
                settings->recalculateHPAndDamage    = rb.readBool();
                settings->muteUnits                 = rb.readBool();

                settings->GunShotWavFilePath    = rb.readBytePtr();
                settings->VisorUsageFilePath    = rb.readBytePtr();
                settings->BackgroundWavFilePath = rb.readBytePtr();

                settings->TimeLockMessage       = rb.readBytePtr();
                settings->TimeLockFrom          = rb.readBytePtr();
                settings->TimeLockTo            = rb.readBytePtr();
                settings->inputFilePath         = rb.readBytePtr();
                settings->outputFilePath        = rb.readBytePtr();
                settings->EMPDamage             = (short)rb.readShort();
                settings->result                = rb.readInt();
                settings->preferredUnitSettings = rb.readBytePtr();
                settings->ignoreArmors          = rb.readBytePtr();

                settings->mapName       = rb.readBytePtr();
                settings->description   = rb.readBytePtr();
                settings->objectives    = rb.readBytePtr();
                settings->useObjectives = rb.readBool();

                Marshal.FreeHGlobal(ptr);
            }
        }