Use a vector to store the list of random sounds played for an industry.
The removes manual memory allocation, flags to control memory management, a separate count member, and a try/catch block.
chinese (simplified): 1 change by WenSimEHRP
greek: 52 changes by KyriakosMich
german: 3 changes by Wuzzy2
basque: 36 changes by Porrumentzio
danish: 3 changes by bscargo
Deferred window resize was being applied to the initial window resize event, resulting in some window state (e.g. scroll bar capacity) not being initialised when expected.
A comment about "will actually do nothing" is out of date as that is not the case with std::vector.
These lists are always short lived (either within a command handler or in a window) so don't shrink_to_fit.
After sorting and filter lists for GUI, we often shirnk them to reduce size. However this has very little benefit:
1) The memory has already been allocated, so it doesn't prevent that memory being required.
2) It causes a new allocation and copy when the vector is shrunk, actually using more memory.
3) The list is in window state, so the lifetime is only while the window is open.
4) When a filter is clearer, the original size will be needed again, which will cause another allocation.
In fact it is beneficial to reserve to the known maximum in most cases, so do that instead.
english (au): 3 changes by krysclarke
russian: 3 changes by Ln-Wolf
finnish: 6 changes by hpiirai
dutch: 6 changes by Afoklala
portuguese (brazilian): 4 changes by pasantoro
polish: 3 changes by pAter-exe
swedish: 7 changes by joeax910
vietnamese: 15 changes by anmatngu
greek: 31 changes by gh658804, 2 changes by KyriakosMich
hungarian: 2 changes by egri-nagy
portuguese (brazilian): 2 changes by pasantoro
GUIList has a pointer only to the start of each sort/filter func list, which has the potential for UB as it is unable to validate that the selected sort or filter type is in range.
Use a std::span instead and check if the selected type is in range before using it.
ExtractString does not need to find a string terminator as StrMakeValid already does this, so simply pass the full bounds of the buffer.
Removes lengthof, array indices, and needs only the buffer as a parameter.
SlCalcConvMemLen(), SlCalcConfFileLen() and CalcOldVarLen() follow a pattern of looking up part of a value in an array.
These function returns the size of bytes of a variable type, but is not very clear. Replace with a switch block instead.
Removes lengthof, array indices, and magic numbers.
Combine 3 separate arrays into a single struct. This keeps related data together, and avoids needing to check that each array is same length.
Use of constexpr construct ensures data in the array is not default-initialised.
Removes lengthof.
Combine two separate fixed length arrays to allow simpler iteration.
No need to check that arrays are all the same length.
No need to separately store the number of sprites to draw.
Removes the upper limit of the number of sprites that can be drawn.
Removes lengthof and array indices.