Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Kenix

  1. 3 hours ago, IIYAMA said:

    Agree, didn't thought about that one, but the counting up loop would still have the issue of skipping one(or more > context) of the items for that frame. The loop doesn't take into account that the index should stop increasing when an item is removed, as the array is collapsing.

     

     

    Would this not cover all the issues?

    
    local i = 1repeat 	if a[ i ] == func then		table.remove( a, i )	else		i = i + 1	enduntil not a[ i ]

     

     

     

     

    I think it's good solution. Code updated.

  2. On 19/05/2019 at 14:24, IIYAMA said:

     

     

     

    If the loop isn't invert, this will not work well:

    
    -- This will go wrongfunction theFunction () -- first function  removeRenderEvent(theFunction)endaddRenderEvent(theFunction)-- add multiple functions, else the context isn't validfor i=1, 9 do  addRenderEvent(function () end)end

     

    functions:

    1, 2, 3, 4, 5, 6, 7, 8, 9, 10

     

    Looping: from 1 t/m 10

    | = index

    1, 2, 3, 4, 5, 6, 7, 8, 9, 10

     

    Deleting 1 during the loop:

    |

    1, 2, 3, 4, 5, 6, 7, 8, 9, 10

     

    Going on:

       | > > > > > > > >

    2, 3, 4, 5, 6, 7, 8, 9, 10, nothing

     

     

    error:

                                      |

    2, 3, 4, 5, 6, 7, 8, 9, 10, nothing

     

    If the loop is inverted, the loop will not have problems when items are removed.

     

     

     

     

     

     



    @IIYAMA It cause another problem with render events, it starts call from end (which is not needed to us, because dx render events has "layers" and you need to call from 1 to table lenght)

    If you're using table.remove function, everything should work fine after remove item from table.
    Let me explain:

    local a = {};
    
    local func = function() end;
    
    a[ #a + 1 ] = func;
    
    for i = 1, #a do
     if a[ i ] == func then
      table.remove( a, i );
     end
    end
    
    print( #( a ) ); -- 0

    table.remove safely remove item from table, it's not contains a [1] index with nil value, it's clear

    Proof:

    local a = {};
    
    local func = function() end;
    
    a[ #a + 1 ] = func;
    
    for i = 1, #a do
     if a[ i ] == func then
      table.remove( a, i );
     end
    end
    
    print( #( a ) ); -- 0
    
    local func = function() end;
    
    a[ #a + 1 ] = func;
    
    
    print( #( a ) ); -- 1



    Another example:
     

    local a = { 1, 2 };
    
    local func = function() end;
    
    a[ #a + 1 ] = func;
    
    for i = 1, #a do
     if a[ i ] == func then
      table.remove( a, i );
     end
    end
    
    print( #( a ) ); -- 2
    
    local func = function() end;
    
    a[ #a + 1 ] = func;
    
    for i = 1, #a do
     if a[ i ] == func then
      table.remove( a, i );
     end
    end
    
    print( #( a ) ); -- 2

    And finally (shows how another items is reordered): from { [1] = 1, [2] = func, [3] = 2} -> {[1] = 1, [2] = 2}
     

    local func = function() end;
    
    local a = { 1, func, 2 };
    
    print( "before", #a ); -- 3
    
    for i = 1, #a do
     if a[ i ] == func then
      table.remove( a, i );
     end
    end
    
    print( "after", #a ); -- 2

     

    test here: https://www.Lua.org/cgi-bin/demo

  3. VM: Virtual Box
    Error name: Segmentation fault
    OS: Debian 9.9 (x64)
    RAM: 1.7GB
    CPU: 2
    Version: MTA version r16569 (stable) (failed in another versions HEAD/etc)
    Additional: i had the same error using Docker with "ubuntu" image.
    Task: Just need to compile a custom MTA server.

    ================

    Debian 9.9 (compile MTA SA r16569)
    gcc version:
    6.3.0-18+deb9u1

    Dump log:
    https://pastebin.com/itVUvLWQ

    Backtrace (using gdb mta-server64):
    https://pastebin.com/acSvH4BU

    Dump:
    https://upload.mtasa.com/u/974313768/server_1.5.6-custom_20190503_1231.dmp_

    ================
    Debian 8.11 (compile MTA SA r16569)

    gcc version:
    4.9.2-10+deb8u2

    Dump log:
    https://pastebin.com/DyPJxPC9

    Backtrace:
    https://pastebin.com/utxwMnde

    Dump:
    https://upload.mtasa.com/u/287394891/server_1.5.6-custom_20190503_1611.dmp_

    ================
    Debian 9.9 (compile MTA SA HEAD)

    gcc 7.4.0.9 (updated)

    Dump log:
    https://pastebin.com/4CNAAW1V

    Backtrace:
    https://pastebin.com/LrResDcr

    Dump:
    https://upload.mtasa.com/u/218452296/server_1.5.6-custom_20190503_1814.dmp_

    UPD: Stable version r16569 (from linux.multitheftauto.com) works well. This error affects only on self-compiled version.

     

    UPD2:
    starting mta-server64 with -n flag doesn't help.

     

  4. Портал Gamevs это игровые проекты:
    - RP BOX
    - MTA Oblivion Lost
    - GTA Race
    - и многие другие

    Нам требуются Lua скриптеры.
    Опыт работы в сфере MTA:SA будет большим плюсом.
    Зарплата выше средней по рынку, определится по результатам собеседования.
    В теме письма укажите "Работа".

    Мы также приглашаем к сотрудничеству различные проекты. В теме письма укажите "Сотрудничество".

    Ваши резюме отправляйте на почту (UPD: 08.01.19):
    [email protected]

    Желаем вам удачи на собеседовании!

    • Like 2
×
×
  • Create New...