Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2403 std #647

Merged
merged 107 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
3caec38
CODE: finish calculation early for convois with one vehicle
Dwachs Nov 20, 2021
45f7b67
FIX missing include
Ranran-the-JuicyPork Aug 16, 2023
ee3b398
(Dwachs) CODE: use ranged for instead of FOR macro
Ranran-the-JuicyPork Aug 16, 2023
cfd8dd2
CODE: Consistent line format with standard
Ranran-the-JuicyPork Aug 16, 2023
9b777e3
FIX crash if desc == NULL (may come from scripts)
Dwachs Feb 20, 2023
a04263b
add format specifier to translatable string
Dwachs Feb 25, 2023
9085810
FIX: cannot build double slopes if the pakset does not support it
Dwachs Feb 25, 2023
c1fdf90
ADD: scroll to selected font in load-font window
Dwachs Feb 26, 2023
92ae8d7
CODE: translate infowin_event comments
Roboron3042 Feb 27, 2023
9976584
CODE: remove unused function
Dwachs Mar 4, 2023
51a3221
CODE: remove unused parameter
Dwachs Mar 4, 2023
b85352c
CODE: simplify string length calculation routines
Dwachs Mar 4, 2023
4d7ecb1
CODE: move methods from simgraph* to unicode.h/.c
Dwachs Mar 4, 2023
9b069b8
Merge remote-tracking branch 'refs/remotes/origin/std-r10235' into 24…
Ranran-the-JuicyPork Mar 26, 2024
394707d
Update cherry-picked-commits.txt
Ranran-the-JuicyPork Mar 26, 2024
5d2c3f1
Revert "FIX: cannot build double slopes if the pakset does not suppor…
Ranran-the-JuicyPork Mar 26, 2024
72ab45d
FIX: window position not being saved in some cases (koroal)
Dwachs Dec 2, 2022
c23a2a1
FIX: merging conflict (simgraph16)
Ranran-the-JuicyPork Mar 26, 2024
9bc9597
FIX: merging error of r10875
Ranran-the-JuicyPork Mar 26, 2024
47e5032
FIX: Remove unnecessary HEAD mixed in by merging
Ranran-the-JuicyPork Mar 26, 2024
b5bc081
CODE: move uft-types to simtypes.h, reduce include dependency
Dwachs Mar 4, 2023
b3eeb35
FIX: improved width calculation for numberinput elements
Dwachs Mar 11, 2023
75f37c9
FIX: do not draw on the window boundary
Dwachs Mar 11, 2023
a2c69c1
CODE: use FT_Load_Char
Dwachs Mar 11, 2023
263f464
FIX crash in build-station tool without cursor
Dwachs Mar 12, 2023
9c230f7
Update cherry-picked-commits.txt
Ranran-the-JuicyPork Mar 26, 2024
15ea8e0
FIX: missing change in r10876
Ranran-the-JuicyPork Mar 26, 2024
2f03237
FIX/CODE: German to English change unintentionally reverted
Ranran-the-JuicyPork Mar 26, 2024
3964525
CODE: reduce code duplication for rgb555/565 specific code
Dwachs Feb 20, 2023
9dbe80f
FIX fix/remove more RGB555 stuff
Dwachs Feb 20, 2023
62a847d
CHG: use 5bit granularity for alpha-blending sometimes
Dwachs Feb 20, 2023
5f5763f
CODE remove if as both blocks are identical
Dwachs Feb 20, 2023
1c6d965
removed useless variable
Dwachs Feb 20, 2023
bf0189e
use 5bit alpha blending; reduce code duplication
Dwachs Feb 20, 2023
b76a74b
CODE: supply alpha_mask as parameter to internal routines instead of …
Dwachs Feb 20, 2023
00d4fbf
CODE: use the new color blend routine, get rid of all that helper arrays
Dwachs Feb 20, 2023
a284aaf
CODE: same format as standard
Ranran-the-JuicyPork Mar 26, 2024
b51c92a
add ENDFONT
Dwachs Mar 13, 2023
4e7f219
FIX problems with transparent pixels
Dwachs Mar 23, 2023
1b95067
FIX: Crash when displaying alpha images near window border
ceeac Apr 10, 2023
332093a
(r10447) CODE: use ranged for instead of FOR macro
Ranran-the-JuicyPork Mar 27, 2024
0dbbaab
Update cherry-picked-commits.txt
Ranran-the-JuicyPork Mar 27, 2024
3975fb3
CODE: use ranged for instead of FORT macro
Dwachs Feb 3, 2022
1efe3bf
CODE: use ranged for instead of FORX macro
Dwachs Feb 3, 2022
d5752bf
FIX format string checks
Dwachs Feb 25, 2023
595cb59
FIX use double percent sign in translatable strings
Dwachs Feb 25, 2023
7f5381a
FIX: try to repair broken format strings (replace % with %% for broke…
Dwachs Feb 25, 2023
217fa1c
FIX: Broken compat.tab parsing
ceeac Jun 13, 2023
4b4a9ed
FIX: Memory label cut off when increasing map size in New World dialogue
ceeac Jun 25, 2023
985c0ea
CODE: Remove unused variables
ceeac Jun 27, 2023
6aa3680
CODE: Remove unnecessary override of infowin_event
ceeac Jun 27, 2023
2042782
CODE: Fix uneven indentation
ceeac Jun 27, 2023
93b8543
Update cherry-picked-commits.txt
Ranran-the-JuicyPork Mar 28, 2024
d4ccc48
CODE: Make the format consistent with the standard
Ranran-the-JuicyPork Mar 28, 2024
be72dbd
compile for valgrind again/FIX valgrind annotation
Dwachs Sep 11, 2022
918d013
CODE: Update array2d_tpl (part of r9148)
Ranran-the-JuicyPork Mar 28, 2024
fb5adc1
CODE: Reduce indentation for classes in tpl/ to match other code
ceeac Oct 25, 2020
5974ffb
CODE: Fix indentation of comments in tpl/
ceeac Oct 28, 2020
7eca509
Update cherry-picked-commits.txt
Ranran-the-JuicyPork Mar 28, 2024
cf1005f
run ./cleanup_code.sh
Ranran-the-JuicyPork Mar 28, 2024
1dcdd37
FIX merging error in r9337
Ranran-the-JuicyPork Apr 1, 2024
b98a602
FIX: Error in merging r10852
Ranran-the-JuicyPork May 7, 2024
7205830
FIX: can not remove tree
Ranran-the-JuicyPork May 7, 2024
e66de80
:jp: Proofreading of Japanese translation
Ranran-the-JuicyPork May 9, 2024
33391c5
CHG: Reflect player button color when changing player color
Ranran-the-JuicyPork May 10, 2024
fddf43a
FIX: detail button does not stay pressed when halt detail is opened
Ranran-the-JuicyPork May 12, 2024
4a4cf28
CODE: Don't use env_t::listen directly in network_init_server
ceeac Aug 21, 2021
05f9c55
CODE: Use socket instead of client id for network_send_file
ceeac Aug 21, 2021
60f114f
update cherry-picked-commits.txt
Ranran-the-JuicyPork May 14, 2024
b25b950
FIX: merging error
Ranran-the-JuicyPork May 14, 2024
5a2e190
sqapi: enable scenario scripts to open info window also on clients
Dwachs Mar 2, 2018
1974f81
Update script API to latest standard version
ceeac Aug 26, 2022
39cafea
Integrate most of the Squirrel API from Standard where possible; fix …
ceeac Nov 1, 2022
683cee7
More tests for depots and ways
ceeac Aug 30, 2022
68f78d7
Enable more tests
ceeac Oct 23, 2022
30e6d03
Fix license header
ceeac Oct 30, 2022
828bbab
Upgrade to C++14
ceeac Aug 26, 2022
7603448
Update Squirrel to latest Standard version
ceeac Nov 1, 2022
ae66029
ADD: command-line parameter -scenario also looks in addons directory
Dwachs Dec 10, 2021
daae46b
ADD: Automated tests + GitHub Action to run them for each nightly build
ceeac Oct 17, 2021
9dc6704
Force English language when running tests via run-automated-tests.sh
ceeac Oct 18, 2021
d7c1d8f
Limit max runtime of tests in case of unexpected failure
ceeac Oct 18, 2021
541fc7b
Fix compile error
ceeac Oct 26, 2021
98211f1
Update base scripts
ceeac Aug 26, 2022
da4f9b7
Fix GitHub Action
ceeac Aug 27, 2022
76b5271
Sync run-automated-tests.sh with Standard
ceeac Aug 27, 2022
3608acd
Do not crash immediately on signed integer overflow
ceeac Aug 27, 2022
4d8263a
Temporarily disable abort-on-ub
ceeac Aug 27, 2022
80d8836
FIX slope -> ribi translation
ceeac Aug 27, 2022
340e295
Fix compilation error on macOS
ceeac Aug 29, 2022
9669f12
Add Action to run tests with thread sanitizer
ceeac Sep 26, 2022
97a9cb6
Improved error messages for ASSERT_TRUE and ASSERT_FALSE
ceeac Sep 13, 2022
ce58c5f
Enable test_label
ceeac Oct 23, 2022
07d8455
Upgrade to actions/cache v3
ceeac Oct 23, 2022
b2984c3
Re-enable abort-on-ub
ceeac Oct 30, 2022
4583201
FIX: Main menu is loaded when -scenario is specified
ceeac Nov 6, 2022
bd855fa
Disable failing tests
ceeac Nov 6, 2022
4810d84
Run tests on pull_request
ceeac Nov 6, 2022
6246552
Fix VS project
ceeac Nov 6, 2022
7553316
FIX: Function override error
Ranran-the-JuicyPork Jan 31, 2024
bcb5835
disable ex-15 parameters
Ranran-the-JuicyPork May 15, 2024
4cd54ac
bugfix
Ranran-the-JuicyPork May 19, 2024
7a272e2
FIX: Local compile error
jamespetts Nov 6, 2022
49dcaa0
Merge branch 'heads/jamespetts/master' into 2403-std
Ranran-the-JuicyPork May 21, 2024
2ec288f
CODE: compiler warning
Ranran-the-JuicyPork May 21, 2024
3a73a29
FIX: missing end of parentheses
Ranran-the-JuicyPork May 24, 2024
a202bb1
Merge remote-tracking branch 'refs/remotes/jamespetts/master' into 24…
Ranran-the-JuicyPork May 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
102 changes: 102 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#
# CI for running tests
#

on: [push, pull_request]
name: Automated Tests

jobs:
run-tests-asan-ubsan:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -ym install libbz2-dev zlib1g-dev libpng-dev autoconf clang-14 ccache moreutils
- name: Cache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache:${{ github.job }}:${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache:${{ github.job }}:${{ github.ref }}
ccache:${{ github.job }}
- name: Configure Simutrans Build
run: |
autoconf
CC="ccache clang-14" CXX="ccache clang++-14" ./configure
echo "FLAGS += -fsanitize=address,undefined -fno-sanitize-recover=all -fno-sanitize=shift,function" >> config.default
echo "LDFLAGS += -fsanitize=address,undefined" >> config.default
- name: Build Simutrans
run: |
CC="ccache clang-14" CXX="ccache clang++-14" make -j$(nproc)
- name: Install pak128.britain-ex-nightly
run: |
pushd simutrans
printf '2\ni\ny\n' | ../get_pak.sh
popd
- name: Link tests as scenario
run: |
mkdir -p ./simutrans/pak128.britain-ex-nightly/scenario
ln -sT $GITHUB_WORKSPACE/tests ./simutrans/pak128.britain-ex-nightly/scenario/automated-tests
- name: Create simuconf
run: |
mkdir -p ~/simutrans/
echo "frames_per_second = 100" >> ~/simutrans/simuconf.tab
echo "fast_forward_frames_per_second = 100" >> ~/simutrans/simuconf.tab
- name: Run tests
run: |
export ASAN_OPTIONS="print_stacktrace=1 abort_on_error=1 detect_leaks=0"
export UBSAN_OPTIONS="print_stacktrace=1 abort_on_error=1"
cp scripts/run-automated-tests.sh .
chmod +x run-automated-tests.sh
timeout 10m ./run-automated-tests.sh # 10 minutes ought to be enough for anybody.

run-tests-tsan:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -ym install libbz2-dev zlib1g-dev libpng-dev autoconf clang-14 ccache moreutils
- name: Cache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache:${{ github.job }}:${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache:${{ github.job }}:${{ github.ref }}
ccache:${{ github.job }}
- name: Configure Simutrans Build
run: |
autoconf
CC="ccache clang-14" CXX="ccache clang++-14" ./configure
echo "FLAGS += -fsanitize=thread" >> config.default
echo "LDFLAGS += -fsanitize=thread" >> config.default
- name: Build Simutrans
run: |
CC="ccache clang-14" CXX="ccache clang++-14" make -j$(nproc)
- name: Install pak128.britain-ex-nightly
run: |
pushd simutrans
printf '2\ni\ny\n' | ../get_pak.sh
popd
- name: Link tests as scenario
run: |
mkdir -p ./simutrans/pak128.britain-ex-nightly/scenario
ln -sT $GITHUB_WORKSPACE/tests ./simutrans/pak128.britain-ex-nightly/scenario/automated-tests
- name: Create simuconf
run: |
mkdir -p ~/simutrans/
echo "frames_per_second = 100" >> ~/simutrans/simuconf.tab
echo "fast_forward_frames_per_second = 100" >> ~/simutrans/simuconf.tab
- name: Run tests
run: |
export TSAN_OPTIONS="print_stacktrace=1 second_deadlock_stack=1 history_size=7 verbose=2"
cp scripts/run-automated-tests.sh .
chmod +x run-automated-tests.sh
timeout 10m ./run-automated-tests.sh # 10 minutes ought to be enough for anybody.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ text/zh


# Folders:
script/
pak*/
text/citylists/

Expand Down
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ project(simutrans-extended LANGUAGES C CXX)

include(SimutransCommitInfo)

# Force C++11 everywhere
set(CMAKE_CXX_STANDARD 11)
# Force C++14 everywhere
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -306,6 +306,23 @@ if (APPLE)
endif (APPLE)



#
# Tests
#
add_custom_target(test
$<TARGET_FILE:simutrans-extended>
-use_workdir
-objects pak128.britain-ex-nightly
-scenario automated-tests
-debug 2
-lang en
-fps 100
DEPENDS simutrans
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/simutrans
)


#
# Installation
#
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ else
endif

ifeq ($(OSTYPE),mac)
CFLAGS += -std=c++11 -stdlib=libc++
CFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif

Expand All @@ -84,13 +84,9 @@ else
SOURCES += sys/clipboard_internal.cc
endif

ifeq ($(OSTYPE),openbsd)
CXXFLAGS += -std=c++11
endif

LIBS += -lbz2 -lz -lpng

CXXFLAGS += -std=gnu++11
CXXFLAGS += -std=c++14

ifneq ($(OSTYPE),mingw)
LIBS += -lbz2 -lz
Expand Down Expand Up @@ -533,6 +529,7 @@ SOURCES += script/api_class.cc
SOURCES += script/api_function.cc
SOURCES += script/api_param.cc
SOURCES += script/api/api_city.cc
SOURCES += script/api/api_command.cc
SOURCES += script/api/api_const.cc
SOURCES += script/api/api_control.cc
SOURCES += script/api/api_convoy.cc
Expand All @@ -544,6 +541,7 @@ SOURCES += script/api/api_line.cc
SOURCES += script/api/api_map_objects.cc
SOURCES += script/api/api_obj_desc.cc
SOURCES += script/api/api_obj_desc_base.cc
SOURCES += script/api/api_pathfinding.cc
SOURCES += script/api/api_player.cc
SOURCES += script/api/api_scenario.cc
SOURCES += script/api/api_schedule.cc
Expand All @@ -556,6 +554,7 @@ SOURCES += script/api/get_next.cc
SOURCES += script/dynamic_string.cc
SOURCES += script/export_objs.cc
SOURCES += script/script.cc
SOURCES += script/script_loader.cc
SOURCES += squirrel/sq_extensions.cc
SOURCES += squirrel/squirrel/sqapi.cc
SOURCES += squirrel/squirrel/sqclass.cc
Expand Down Expand Up @@ -792,3 +791,6 @@ makeobj:

nettool:
$(Q)$(MAKE) -e -C nettools FLAGS="$(FLAGS)"
test: simutrans
$(BUILDDIR)/$(PROG) -set_workdir $(shell pwd)/simutrans -objects pak -scenario automated-tests -debug 2 -lang en -fps 100

5 changes: 4 additions & 1 deletion Simutrans-Extended.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,7 @@
<ClCompile Include="descriptor\reader\building_reader.cc" />
<ClCompile Include="player\finance.cc" />
<ClCompile Include="script\api\api_city.cc" />
<ClCompile Include="script\api\api_command.cc" />
<ClCompile Include="script\api\api_const.cc" />
<ClCompile Include="script\api\api_control.cc" />
<ClCompile Include="script\api\api_convoy.cc" />
Expand All @@ -2115,8 +2116,9 @@
<ClCompile Include="script\api\api_include.cc" />
<ClCompile Include="script\api\api_line.cc" />
<ClCompile Include="script\api\api_map_objects.cc" />
<ClCompile Include="script\api\api_obj_desc.cc" />
<ClCompile Include="script\api\api_obj_desc_base.cc" />
<ClCompile Include="script\api\api_obj_desc.cc" />
<ClCompile Include="script\api\api_pathfinding.cc" />
<ClCompile Include="script\api\api_player.cc" />
<ClCompile Include="script\api\api_scenario.cc" />
<ClCompile Include="script\api\api_schedule.cc" />
Expand All @@ -2132,6 +2134,7 @@
<ClCompile Include="script\dynamic_string.cc" />
<ClCompile Include="script\export_objs.cc" />
<ClCompile Include="script\script.cc" />
<ClCompile Include="script\script_loader.cc" />
<ClCompile Include="siminteraction.cc" />
<ClCompile Include="simloadingscreen.cc" />
<ClCompile Include="simsignalbox.cc" />
Expand Down
18 changes: 16 additions & 2 deletions bauer/brueckenbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,28 @@ void bridge_builder_t::fill_menu(tool_selector_t *tool_selector, const waytype_t
}

// now sorted ...
FOR(vector_tpl<bridge_desc_t const*>, const i, matching) {
for (bridge_desc_t const* const i : matching) {
tool_selector->add_tool_selector(i->get_builder());
}
}


const vector_tpl<const bridge_desc_t *>& bridge_builder_t::get_available_bridges(const waytype_t wtyp)
{
static vector_tpl<const bridge_desc_t *> dummy;
dummy.clear();
const uint16 time = welt->get_timeline_year_month();
for(auto const& i : desc_table) {
bridge_desc_t const* const b = i.value;
if ( b->get_waytype()==wtyp && b->is_available(time) ) {
dummy.append(b);
}
}
return dummy;
}


inline bool ribi_check( ribi_t::ribi ribi, ribi_t::ribi check_ribi )
static inline bool ribi_check( ribi_t::ribi ribi, ribi_t::ribi check_ribi )
{
// either check for single (if nothing given) otherwise ensure exact match
return check_ribi ? ribi == check_ribi : ribi_t::is_single( ribi );
Expand Down
5 changes: 5 additions & 0 deletions bauer/brueckenbauer.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class bridge_builder_t {
* @param wtyp way type
*/
static void fill_menu(tool_selector_t *tool_selector, const waytype_t wtyp, sint16 sound_ok);

/**
* Returns a list with available bridge types.
*/
static const vector_tpl<const bridge_desc_t *>& get_available_bridges(const waytype_t wtyp);
};

#endif
12 changes: 5 additions & 7 deletions bauer/fabrikbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void init_fab_map( karte_t *welt )
for( int i=0; i<fab_map_w*welt->get_size().y; i++ ) {
fab_map[i] = 0;
}
FOR(vector_tpl<fabrik_t*>, const f, welt->get_fab_list()) {
for(fabrik_t* const f : welt->get_fab_list()) {
add_factory_to_fab_map(welt, f);
}
if( welt->get_settings().get_max_factory_spacing_percent() ) {
Expand All @@ -94,7 +94,7 @@ void init_fab_map( karte_t *welt )


/**
* @param x,y world position
* @param x,y world position, needs to be valid coordinates
* @returns true, if factory coordinate
*/
inline bool is_factory_at(sint16 x, sint16 y)
Expand Down Expand Up @@ -431,7 +431,7 @@ class ocean_test_driver_t : public test_driver_t
bool check_next_tile(const grund_t* gr) const OVERRIDE { return gr->is_water(); };
ribi_t::ribi get_ribi(const grund_t* gr) const OVERRIDE { return gr->get_weg_ribi_unmasked(water_wt); };
waytype_t get_waytype() const OVERRIDE { return water_wt; }; // To trigger jps "jump" behavior; otherwise use invalid_wt
int get_cost(const grund_t *, const sint32, koord) OVERRIDE { return 1; };
int get_cost(const grund_t *, const sint32, ribi_t::ribi) OVERRIDE { return 1; };
bool is_target(const grund_t *, const grund_t *) OVERRIDE { return false; }; // unused
};

Expand Down Expand Up @@ -966,8 +966,7 @@ int factory_builder_t::build_chain_link(const fabrik_t* origin_fab, const factor
weighted_vector_tpl<const factory_desc_t*>producer;
find_producer(producer, ware, welt->get_timeline_year_month());
bool local_supplier_unavailable = true;
FOR(weighted_vector_tpl<const factory_desc_t*>, producer_type, producer)
{
for(const factory_desc_t* producer_type : producer) {
if (producer_type->get_building()->is_allowed_region(origin_region))
{
local_supplier_unavailable = false;
Expand Down Expand Up @@ -1177,8 +1176,7 @@ int factory_builder_t::build_chain_link(const fabrik_t* origin_fab, const factor
/* now the cross-connect part:
* connect also the factories we stole from before ...
*/
FOR(slist_tpl<fabrik_t*>, const fab, new_factories)
{
for(fabrik_t* const fab : new_factories) {
for(slist_tpl<factories_to_crossconnect_t>::iterator fabs_to_correct = factories_to_correct.begin(), end = factories_to_correct.end(); fabs_to_correct != end;)
{
fabs_to_correct->demand -= 1;
Expand Down
4 changes: 2 additions & 2 deletions bauer/goods_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ bool goods_manager_t::successfully_loaded()
// now assign unique category indices for unique categories
max_catg_index = 0;
// first assign special freight (which always needs an own category)
FOR(vector_tpl<goods_desc_t*>, const i, goods) {
for(goods_desc_t* const i : goods) {
if (i->get_catg() == 0) {
i->catg_index = max_catg_index++;
}
}
// mapping of waren_t::catg to catg_index, map[catg] = catg_index
uint8 map[255] = {0};

FOR(vector_tpl<goods_desc_t*>, const i, goods) {
for(goods_desc_t* const i : goods) {
uint8 const catg = i->get_catg();
if( catg > 0 ) {
if( map[catg] == 0 ) { // We didn't found this category yet -> just create new index.
Expand Down
Loading