Efficient Vehicle Looping
#17

Considering that a player will at max open the hood every few minutes in average, the MAX_VEHICLES loop will be much more economic after all. Iterators might sound fast, but they will eat up a lot of RAM (as pointed out before), and depending on how youre realizing them they are really slow. Removing a vehicle from the iterator means finding its index first, and then shifting the index of all following vehicles (though the pointer relocation method is a good way for array shifting). And as there might be dozens of vehicles streaming in and out each streaming tick for each player this would cause a huge amount of extra work for the server, even if noone opens a hood.

Iterators are only useful for "slow data", like player joins or vehicle creations, but not for data that changes thousands of times every second.

Quote:
Originally Posted by AndreT
Посмотреть сообщение
From C++, I can think of std::bitset, which would very much be your friend in such situation. For 200 players, having a bitset for 2000 vehicles would take up 400000 bits or 48 kilobytes, which is far less.
A bitset actually would have little to no advantages compared to the common loop

pawn Код:
// Common attempt
for (new i = 0; i < MAX_VEHICLES; i++) {
    if (!IsVehicleStreamedIn(i, playerid)) continue;
}

// Bitset (some pawn/c++ pseudo mixup)
for (new i = 0; i < MAX_VEHICLES; i++) {
    if (!bitset_playervehicles[playerid].test(i)) continue;
}
Reply


Messages In This Thread
Efficient Vehicle Looping - by MP2 - 05.05.2015, 08:56
Re: Efficient Vehicle Looping - by AIped - 05.05.2015, 09:08
Re: Efficient Vehicle Looping - by MicroD - 05.05.2015, 09:22
Re: Efficient Vehicle Looping - by Tamer - 05.05.2015, 09:43
Re: Efficient Vehicle Looping - by MP2 - 05.05.2015, 09:54
Re: Efficient Vehicle Looping - by Tamer - 05.05.2015, 10:00
Re: Efficient Vehicle Looping - by Misiur - 05.05.2015, 10:01
Re: Efficient Vehicle Looping - by Lordzy - 05.05.2015, 10:10
Re: Efficient Vehicle Looping - by MP2 - 05.05.2015, 10:29
Re: Efficient Vehicle Looping - by Konstantinos - 05.05.2015, 10:38
Re: Efficient Vehicle Looping - by MP2 - 05.05.2015, 10:51
Re: Efficient Vehicle Looping - by Kar - 05.05.2015, 21:28
Re: Efficient Vehicle Looping - by Emmet_ - 05.05.2015, 21:45
Re: Efficient Vehicle Looping - by Crayder - 05.05.2015, 21:59
Re: Efficient Vehicle Looping - by MP2 - 06.05.2015, 10:22
Re: Efficient Vehicle Looping - by AndreT - 06.05.2015, 11:51
Re: Efficient Vehicle Looping - by Mauzen - 06.05.2015, 13:31
Re: Efficient Vehicle Looping - by sammp - 06.05.2015, 14:57
Re: Efficient Vehicle Looping - by Tamer - 06.05.2015, 17:57
Re: Efficient Vehicle Looping - by AndreT - 06.05.2015, 19:31
Re: Efficient Vehicle Looping - by Marricio - 08.05.2015, 21:22
Re: Efficient Vehicle Looping - by Pottus - 09.05.2015, 01:39

Forum Jump:


Users browsing this thread: 1 Guest(s)